source: java/Framclipse/com.framsticks.framclipse/src/com/framsticks/framclipse/script/model/Element.java @ 437

Last change on this file since 437 was 437, checked in by Mateusz Poszwa, 9 years ago

Added Framclipse as developed by Bartosz Kukawka and Tomek Maciejewski in 2010

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1package com.framsticks.framclipse.script.model;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.List;
6
7import com.thoughtworks.xstream.annotations.XStreamAlias;
8import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
9
10public class Element {
11
12        @XStreamAsAttribute
13        private String name, type;
14
15        @XStreamAsAttribute
16        private boolean function;
17
18        @XStreamAsAttribute
19        private Double min, max;
20
21        @XStreamAlias("default")
22        @XStreamAsAttribute
23        private Double def;
24
25        private String description;
26
27        private List<Argument> arguments = new ArrayList<Argument>(0);
28
29        public String getName() {
30                return name;
31        }
32
33        public String getType() {
34                return type;
35        }
36
37        public boolean isFunction() {
38                return function;
39        }
40
41        public Double getMin() {
42                return min;
43        }
44
45        public Double getMax() {
46                return max;
47        }
48
49        public Double getDef() {
50                return def;
51        }
52
53        public String getDescription() {
54                return description;
55        }
56
57        public List<Argument> getArguments() {
58                return arguments != null ? arguments : Collections.<Argument> emptyList();
59        }
60
61        public String toString() {
62                return name + " : " + type;
63        };
64
65        public String argumentsString(boolean includeType) {
66                StringBuilder builder = new StringBuilder("(");
67                if (!getArguments().isEmpty()) {
68                        for (int i = 0; i < getArguments().size(); i++) {
69                                Argument a = arguments.get(i);
70                                if (includeType) {
71                                        builder.append(a.getType() + " ");
72                                }
73                                builder.append(a.getName(i) + ", ");
74                        }
75                        builder.delete(builder.length() - 2, builder.length());
76                }
77                return builder.append(")").toString();
78        }
79
80        public String returnType() {
81                return type != null ? type : "?";
82        }
83
84}
Note: See TracBrowser for help on using the repository browser.