1 15 package org.apache.tapestry.multipart; 16 17 import java.util.ArrayList ; 18 import java.util.List ; 19 20 26 27 public class ValuePart 28 { 29 private int _count; 30 31 private Object _value; 33 34 public ValuePart(String value) 35 { 36 _count = 1; 37 _value = value; 38 } 39 40 public int getCount() 41 { 42 return _count; 43 } 44 45 48 49 public String getValue() 50 { 51 if (_count == 1) 52 return (String ) _value; 53 54 List l = (List ) _value; 55 56 return (String ) l.get(0); 57 } 58 59 63 64 public String [] getValues() 65 { 66 if (_count == 1) 67 return new String [] 68 { (String ) _value }; 69 70 List l = (List ) _value; 71 72 return (String []) l.toArray(new String [_count]); 73 } 74 75 public void add(String newValue) 76 { 77 if (_count == 1) 78 { 79 List l = new ArrayList (); 80 l.add(_value); 81 l.add(newValue); 82 83 _value = l; 84 _count++; 85 return; 86 } 87 88 List l = (List ) _value; 89 l.add(newValue); 90 _count++; 91 } 92 93 96 97 public void cleanup() 98 { 99 } 100 } | Popular Tags |