1 23 24 package com.sun.enterprise.admin.common; 25 26 import java.io.Serializable ; 27 import java.util.*; 28 29 30 39 40 public class ParamList implements Serializable 41 { 42 public static long serialVersionUID = 5433279640964105821L; 43 44 private Vector mParams; 45 46 private static final String kDelimiterString = ", "; 47 private static final int kInitialCapacity = 4; 48 49 52 53 public ParamList() 54 { 55 mParams = new Vector( kInitialCapacity ); 56 } 57 58 64 65 public void addParam( Param param ) 66 { 67 int elementIndex = mParams.indexOf( param ); 69 boolean paramExists = ( elementIndex != -1 ); 70 71 if( paramExists ) 72 { 73 mParams.setElementAt ( param, elementIndex ); 74 } 75 else 76 { 77 mParams.add( param ); 78 } 79 } 80 81 88 89 public void addParam( String name, Serializable value ) 90 { 91 this.addParam( new Param (name, value ) ); 92 } 93 94 101 102 public Param getParam( String name ) 103 { 104 Param resultParam = null; 105 106 final int numItems = mParams.size( ); 107 108 Iterator iter = getElements( ); 109 while ( iter.hasNext( ) ) 110 { 111 Param aParam = ( Param )iter.next( ); 112 113 if( name.equals( aParam.mName ) ) 114 { 115 resultParam = aParam; 116 break; 117 } 118 } 119 120 return ( resultParam ); 121 } 122 123 129 130 public Iterator getElements( ) 131 { 132 return ( mParams.iterator( ) ); 134 } 135 136 144 public String toString() 145 { 146 Iterator iter = getElements(); 147 148 StringBuffer buf = new StringBuffer ( 256 ); 149 150 while ( iter.hasNext() ) 151 { 152 Param item = (Param)iter.next(); 153 154 buf.append( item ); 155 buf.append( kDelimiterString ); 156 } 157 if ( buf.length() != 0 ) 159 { 160 buf.setLength( buf.length() - kDelimiterString.length() ); 161 } 162 163 return( new String ( buf ) ); 164 } 165 } | Popular Tags |