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