MCPcopy Create free account
hub / github.com/GateNLP/gate-core / getDefaults

Method getDefaults

src/main/java/gate/creole/ParameterList.java:115–158  ·  view source on GitHub ↗

Get default parameter value set. Where more than one default is possible amongst disjunctive parameters, only the first will be set. To check if the default set is comprehensive, use isFullyDefaulted() . @see #isFullyDefaulted()

(List<List<Parameter>> parameters)

Source from the content-addressed store, hash-verified

113 * @see #isFullyDefaulted()
114 */
115 public FeatureMap getDefaults(List<List<Parameter>> parameters) throws ParameterException {
116 FeatureMap defaults = Factory.newFeatureMap();
117
118 // each element of the parameters list is a list of (disjunctive) params
119 Iterator<List<Parameter>> disjIter = parameters.iterator();
120
121 // for each parameter disjunction in parameters
122 disjIterLoop:
123 while(disjIter.hasNext()) {
124 boolean optional = false; // were any of this disj optional?
125
126 // get an iterator for this disjunction of parameters
127 List<Parameter> paramDisj = disjIter.next();
128 Iterator<Parameter> paramsIter = paramDisj.iterator();
129
130 // for each parameter in the disjunction
131 while(paramsIter.hasNext()) {
132 Parameter param = paramsIter.next();
133 if(DEBUG) Out.prln("Examining " + param);
134 if(!optional)
135 optional = param.isOptional();
136
137 // try and find a default value
138 Object defaultValue = param.calculateDefaultValue();
139
140 // no default found
141 if(defaultValue == null) {
142 // if none of this disj were optional, and we're the last, then
143 // we've got at least one non-optional param unset
144 if(!optional && !paramsIter.hasNext()) {
145 fullyDefaulted = false;
146 }
147
148 // valid default found - set it and continue with the next disj
149 } else {
150 defaults.put(param.getName(), defaultValue);
151 continue disjIterLoop;
152 }
153 } // paramsIter
154
155 } // disjIter
156
157 return defaults;
158 } // getDefaults()
159
160
161// this stuff is for if we decide to do more thorough checking

Callers 4

getRuntimeDefaultsMethod · 0.95
getInitimeDefaultsMethod · 0.95
initGUIMethod · 0.80
actionPerformedMethod · 0.80

Calls 9

newFeatureMapMethod · 0.95
prlnMethod · 0.95
isOptionalMethod · 0.95
calculateDefaultValueMethod · 0.95
getNameMethod · 0.95
iteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected