1 22 package org.jboss.resource.metadata; 23 24 import java.io.Serializable ; 25 import java.util.Collection ; 26 import java.util.Iterator ; 27 import java.util.Locale ; 28 29 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap; 30 31 37 public class DescriptionMetaDataContainer implements Serializable 38 { 39 private static final long serialVersionUID = 2831943526217092377L; 40 41 42 private ConcurrentReaderHashMap descriptions = new ConcurrentReaderHashMap(); 43 44 public DescriptionMetaDataContainer() 45 { 46 DescriptionMetaData dmd = new DescriptionMetaData(); 47 descriptions.put(dmd.getLanguage(), dmd); 48 } 49 50 56 public DescriptionMetaData getDescription() 57 { 58 DescriptionMetaData dmd = (DescriptionMetaData) descriptions.get(Locale.getDefault().getLanguage()); 60 if (dmd == null) 62 { 63 for (Iterator i = descriptions.values().iterator(); i.hasNext();) 64 { 65 dmd = (DescriptionMetaData) i.next(); 66 break; 67 } 68 } 69 return dmd; 70 } 71 72 78 public DescriptionMetaData getDescription(String lang) 79 { 80 return (DescriptionMetaData) descriptions.get(lang); 81 } 82 83 88 public void addDescription(DescriptionMetaData dmd) 89 { 90 descriptions.put(dmd.getLanguage(), dmd); 91 } 92 93 98 public Collection getDescriptions() 99 { 100 return descriptions.values(); 101 } 102 103 public String toString() 104 { 105 StringBuffer buffer = new StringBuffer (); 106 buffer.append("DescriptionMetaDataContainer").append('@'); 107 buffer.append(Integer.toHexString(System.identityHashCode(this))); 108 buffer.append("[descriptions=").append(descriptions.values()); 109 buffer.append(']'); 110 return buffer.toString(); 111 } 112 } 113 | Popular Tags |