1 7 package com.sun.corba.se.spi.orb ; 8 9 import java.util.List ; 10 import java.util.LinkedList ; 11 import java.util.Map ; 12 import java.util.HashMap ; 13 import java.util.Iterator ; 14 import java.util.Properties ; 15 16 import com.sun.corba.se.impl.orb.ParserAction ; 17 import com.sun.corba.se.impl.orb.ParserActionFactory ; 18 19 public class PropertyParser { 20 private List actions ; 21 22 public PropertyParser( ) 23 { 24 actions = new LinkedList () ; 25 } 26 27 public PropertyParser add( String propName, 28 Operation action, String fieldName ) 29 { 30 actions.add( ParserActionFactory.makeNormalAction( propName, 31 action, fieldName ) ) ; 32 return this ; 33 } 34 35 public PropertyParser addPrefix( String propName, 36 Operation action, String fieldName, Class componentType ) 37 { 38 actions.add( ParserActionFactory.makePrefixAction( propName, 39 action, fieldName, componentType ) ) ; 40 return this ; 41 } 42 43 45 public Map parse( Properties props ) 46 { 47 Map map = new HashMap () ; 48 Iterator iter = actions.iterator() ; 49 while (iter.hasNext()) { 50 ParserAction act = (ParserAction)(iter.next()) ; 51 52 Object result = act.apply( props ) ; 53 54 if (result != null) 57 map.put( act.getFieldName(), result ) ; 58 } 59 60 return map ; 61 } 62 63 public Iterator iterator() 64 { 65 return actions.iterator() ; 66 } 67 } 68 | Popular Tags |