1 16 package com.google.gwt.dev.cfg; 17 18 import java.util.Arrays ; 19 import java.util.Collection ; 20 import java.util.HashMap ; 21 import java.util.Iterator ; 22 import java.util.Map ; 23 24 27 public class Properties { 28 29 private final Map map = new HashMap (); 30 31 private Property[] propertiesLazyArray; 32 33 37 public Property create(String name) { 38 if (name == null) { 39 throw new NullPointerException ("name"); 40 } 41 42 Property property = find(name); 43 if (property == null) { 44 property = new Property(name); 45 map.put(name, property); 46 } 47 48 return property; 49 } 50 51 public Property find(String name) { 52 return (Property) map.get(name); 53 } 54 55 public Iterator iterator() { 56 return map.values().iterator(); 57 } 58 59 62 public Property[] toArray() { 63 if (propertiesLazyArray == null) { 64 Collection properties = map.values(); 65 int n = properties.size(); 66 propertiesLazyArray = (Property[]) properties.toArray(new Property[n]); 67 Arrays.sort(propertiesLazyArray); 68 } 69 return propertiesLazyArray; 70 } 71 } 72 | Popular Tags |