source: java/main/src/main/java/com/framsticks/params/types/ProcedureParam.java @ 85

Last change on this file since 85 was 85, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • upgrade to Java 7
    • use try-multi-catch clauses
    • use try-with-resources were appropriate
  • configure FindBugs? (use mvn site and then navigate in browser to the report)
    • remove most bugs found
  • parametrize Dispatching environment (Dispatcher, RunAt?) to enforce more control on the place of closures actual call

CHANGELOG:
Rework FavouritesXMLFactory.

FindBugs?. Thread start.

FindBugs?. Minor change.

FindBugs?. Iterate over entrySet.

FindBugs?. Various.

FindBug?.

FindBug?. Encoding.

FindBug?. Final fields.

FindBug?.

Remove synchronization bug in ClientConnection?.

Experiments with findbugs.

Finish parametrization.

Make RunAt? an abstract class.

More changes in parametrization.

More changes in parametrizing dispatching.

Several changes to parametrize tasks.

Rename Runnable to RunAt?.

Add specific framsticks Runnable.

Add JSR305 (annotations).

Add findbugs reporting.

More improvements to ParamBuilder? wording.

Make FramsClass? accept also ParamBuilder?.

Change wording of ParamBuilder?.

Change wording of Request creation.

Use Java 7 exception catch syntax.

Add ScopeEnd? class.

Upgrade to Java 7.

File size: 1.6 KB
Line 
1package com.framsticks.params.types;
2
3import com.framsticks.params.Param;
4import com.framsticks.util.lang.Strings;
5
6import java.util.ArrayList;
7import java.util.List;
8import java.util.regex.Matcher;
9import java.util.regex.Pattern;
10
11/**
12 * @author Piotr Sniegowski
13 */
14public class ProcedureParam extends Param {
15        private Param resultType;
16        private List<Param> argumentsType = new ArrayList<Param>();
17
18        private static Pattern addressPattern = Pattern.compile("^([^\\(]+)?\\(([^\\)]*)\\)$");
19
20        protected static Param parseType(String type, String name) {
21                return Param.build().type(type).name(name).finish();
22        }
23
24        public void parseSignature(String signature) throws Exception {
25                if (!Strings.notEmpty(signature)) {
26                        return;
27                }
28                Matcher matcher = addressPattern.matcher(signature);
29                if (!matcher.matches()) {
30                        throw new Exception("invalid signature");
31                }
32                String result = Strings.collapse(matcher.group(1));
33                if (result != null) {
34                        resultType = parseType(result, null);
35                }
36                String arguments = matcher.group(2);
37                if (!Strings.notEmpty(arguments)) {
38                        return;
39                }
40                for (String a : arguments.split(",")) {
41                        int space = a.indexOf(' ');
42                        String type;
43                        String name;
44                        if (space == -1) {
45                                type = a;
46                                name = null;
47                        } else {
48                                type = a.substring(0, space);
49                                name = a.substring(space + 1);
50                        }
51                        argumentsType.add(parseType(type, name));
52                }
53        }
54
55
56        @Override
57        public Class<?> getStorageType() {
58                return Void.class;
59        }
60
61        public Param getResultType() {
62                return resultType;
63        }
64
65        public List<Param> getArgumentsType() {
66                return argumentsType;
67        }
68
69        @Override
70        public String getFramsTypeName() {
71                return "p";
72        }
73
74}
Note: See TracBrowser for help on using the repository browser.