1 19 20 25 26 package org.netbeans.modules.j2ee.dd.impl.commonws; 27 28 import org.netbeans.modules.schema2beans.Version; 29 import org.netbeans.modules.j2ee.dd.api.common.*; 30 import org.openide.ErrorManager; 31 32 public abstract class DescriptionBeanMultiple extends EnclosingBean implements DescriptionInterface { 33 34 public DescriptionBeanMultiple(java.util.Vector comps, Version version) { 35 super(comps, version); 36 } 37 public void setDescription(int index, java.lang.String value){} 39 public String getDescription(int index){return null;} 40 public void setDescription(java.lang.String [] value){} 41 public int sizeDescription(){return 0;} 43 public int addDescription(java.lang.String value){return 0;} 44 public void setDescriptionXmlLang(int index, java.lang.String value){} 46 public String getDescriptionXmlLang(int index){return null;} 47 48 public void setDescription(String locale, String description) throws VersionNotSupportedException { 49 if (description==null) removeDescriptionForLocale(locale); 50 else { 51 int size = sizeDescription(); 52 boolean found=false; 53 for (int i=0;i<size;i++) { 54 String loc=getDescriptionXmlLang(i); 55 if ((locale==null && loc==null) || (locale!=null && locale.equalsIgnoreCase(loc))) { 56 found=true; 57 setDescription(i, description); 58 break; 59 } 60 } 61 if (!found) { 62 addDescription(description); 63 if (locale!=null) setDescriptionXmlLang(size, locale.toLowerCase()); 64 } 65 } 66 } 67 68 public void setDescription(String description) { 69 try { 70 setDescription(null,description); 71 } catch (VersionNotSupportedException ex){ 72 ErrorManager.getDefault().notify(ex); 73 } 74 } 75 76 public void setAllDescriptions(java.util.Map descriptions) throws VersionNotSupportedException { 77 removeAllDescriptions(); 78 if (descriptions!=null) { 79 java.util.Iterator keys = descriptions.keySet().iterator(); 80 int i=0; 81 while (keys.hasNext()) { 82 String key = (String ) keys.next(); 83 addDescription((String )descriptions.get(key)); 84 setDescriptionXmlLang(i++, key); 85 } 86 } 87 } 88 89 public String getDescription(String locale) throws VersionNotSupportedException { 90 for (int i=0;i<sizeDescription();i++) { 91 String loc=getDescriptionXmlLang(i); 92 if ((locale==null && loc==null) || (locale!=null && locale.equalsIgnoreCase(loc))) { 93 return getDescription(i); 94 } 95 } 96 return null; 97 } 98 public String getDefaultDescription() { 99 try { 100 return getDescription(null); 101 } catch (VersionNotSupportedException ex){return null;} 102 } 103 public java.util.Map getAllDescriptions() { 104 java.util.Map map =new java.util.HashMap (); 105 for (int i=0;i<sizeDescription();i++) { 106 String desc=getDescription(i); 107 String loc=getDescriptionXmlLang(i); 108 map.put(loc, desc); 109 } 110 return map; 111 } 112 113 public void removeDescriptionForLocale(String locale) throws VersionNotSupportedException { 114 java.util.Map map = new java.util.HashMap (); 115 for (int i=0;i<sizeDescription();i++) { 116 String desc=getDescription(i); 117 String loc=getDescriptionXmlLang(i); 118 if ((locale==null && loc!=null) || (locale!=null && !locale.equalsIgnoreCase(loc))) 119 map.put(loc, desc); 120 } 121 setAllDescriptions(map); 122 } 123 124 public void removeDescription() { 125 try { 126 removeDescriptionForLocale(null); 127 } catch (VersionNotSupportedException ex){ 128 ErrorManager.getDefault().notify(ex); 129 } 130 } 131 public void removeAllDescriptions() { 132 setDescription(new String []{}); 133 } 134 } 135 | Popular Tags |