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

Method convertToAttributeList

output/java8/1.4.17/ST.java:390–425  ·  view source on GitHub ↗
(Object curvalue)

Source from the content-addressed store, hash-verified

388 }
389
390 protected static AttributeList convertToAttributeList(Object curvalue) {
391 AttributeList multi;
392 if ( curvalue==null ) {
393 multi = new AttributeList(); // make list to hold multiple values
394 multi.add(curvalue); // add previous single-valued attribute
395 }
396 else if ( curvalue instanceof AttributeList ) { // already a list made by ST
397 multi = (AttributeList)curvalue;
398 }
399 else if ( curvalue instanceof List ) { // existing attribute is non-ST List
400 // must copy to an ST-managed list before adding new attribute
401 // (can't alter incoming attributes)
402 List<?> listAttr = (List<?>)curvalue;
403 multi = new AttributeList(listAttr.size());
404 multi.addAll(listAttr);
405 }
406 else if ( curvalue instanceof Object[] ) { // copy array to list
407 Object[] a = (Object[])curvalue;
408 multi = new AttributeList(a.length);
409 multi.addAll(Arrays.asList(a)); // asList doesn't copy as far as I can tell
410 }
411 else if ( curvalue.getClass().isArray() ) { // copy primitive array to list
412 int length = Array.getLength(curvalue);
413 multi = new AttributeList(length);
414 for (int i = 0; i< length; i++) {
415 multi.add(Array.get(curvalue, i));
416 }
417 }
418 else {
419 // curvalue nonlist and we want to add an attribute
420 // must convert curvalue existing to list
421 multi = new AttributeList(); // make list to hold multiple values
422 multi.add(curvalue); // add previous single-valued attribute
423 }
424 return multi;
425 }
426
427 public String getName() {
428 return impl.name;

Callers 1

addMethod · 0.95

Calls 6

addMethod · 0.65
sizeMethod · 0.65
addAllMethod · 0.65
getMethod · 0.65
asListMethod · 0.45
isArrayMethod · 0.45

Tested by

no test coverage detected