MCPcopy Index your code
hub / github.com/antlr/codebuff / addAggr

Method addAggr

output/java8/1.4.13/ST.java:295–326  ·  view source on GitHub ↗

Split aggrName.{propName1,propName2} into list [propName1, propName2] and the aggrName. Spaces are allowed around ','.

(String aggrSpec, Object ... values)

Source from the content-addressed store, hash-verified

293 */
294
295 public synchronized ST addAggr(String aggrSpec, Object ... values) {
296 int dot = aggrSpec.indexOf(".{");
297 if ( values==null || values.length==0 ) {
298 throw new IllegalArgumentException("missing values for aggregate attribute format: "+aggrSpec);
299 }
300
301 int finalCurly = aggrSpec.indexOf('}');
302 if ( dot<0 || finalCurly<0 ) {
303 throw new IllegalArgumentException("invalid aggregate attribute format: "+aggrSpec);
304 }
305
306 String aggrName = aggrSpec.substring(0, dot);
307 String propString = aggrSpec.substring(dot+2, aggrSpec.length()-1);
308 propString = propString.trim();
309 String[] propNames = propString.split("\\ *,\\ *");
310 if ( propNames==null || propNames.length==0 ) {
311 throw new IllegalArgumentException("invalid aggregate attribute format: "+aggrSpec);
312 }
313
314 if ( values.length!= propNames.length ) {
315 throw new IllegalArgumentException("number of properties and values mismatch for aggregate attribute format: "+aggrSpec);
316 }
317
318 int i = 0;
319 Aggregate aggr = new Aggregate();
320 for (String p : propNames) {
321 Object v = values[i++];
322 aggr.properties.put(p, v);
323 }
324 add(aggrName, aggr); // now add as usual
325 return this;
326 }
327
328 /** Remove an attribute value entirely (can't remove attribute definitions). */
329

Callers

nothing calls this directly

Calls 5

addMethod · 0.95
putMethod · 0.65
indexOfMethod · 0.45
lengthMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected