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