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

Method addAggr

output/java8/1.4.17/ST.java:299–330  ·  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

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

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