1 23 24 package org.infoglue.cms.entities.management; 25 26 import java.util.HashMap ; 27 import java.util.Locale ; 28 import java.util.Map ; 29 30 36 37 38 public class ContentTypeAttributeParameterValue 39 { 40 private String id = null; 41 private Map attributes = new HashMap (); 42 43 public ContentTypeAttributeParameterValue() 44 { 45 } 46 47 public String getId() 48 { 49 return this.id; 50 } 51 52 public void setId(String id) 53 { 54 this.id = id; 55 } 56 57 public Map getAttributes() 58 { 59 return this.attributes; 60 } 61 62 public void addAttribute(String key, String value) 63 { 64 this.attributes.put(key, value); 65 } 66 67 public void setAttributes(Map attributes) 68 { 69 this.attributes = attributes; 70 } 71 72 public String getValue(String key) 73 { 74 return (String )this.attributes.get(key); 75 } 76 77 public String getLocalizedValue(String key, Locale locale) 78 { 79 String localizedKey = key + "_" + locale.getLanguage(); 80 if(this.attributes.containsKey(localizedKey)) 81 return (String )this.attributes.get(localizedKey); 82 else 83 return (String )this.attributes.get(key); 84 } 85 86 public String getLocalizedValue(String key, String langugeCode) 87 { 88 String localizedKey = key + "_" + langugeCode; 89 if(this.attributes.containsKey(localizedKey)) 90 return (String )this.attributes.get(localizedKey); 91 else 92 return (String )this.attributes.get(key); 93 } 94 95 public int getLocalizedValueAsInt(String key, Locale locale) 96 { 97 try 98 { 99 String localizedKey = key + "_" + locale.getLanguage(); 100 if(this.attributes.containsKey(localizedKey)) 101 return Integer.parseInt((String )this.attributes.get(localizedKey)); 102 else 103 return Integer.parseInt((String )this.attributes.get(key)); 104 } 105 catch(Exception e) 106 { 107 return 0; 108 } 109 } 110 111 public int getLocalizedValueAsInt(String key, String langugeCode) 112 { 113 try 114 { 115 String localizedKey = key + "_" + langugeCode; 116 if(this.attributes.containsKey(localizedKey)) 117 return Integer.parseInt((String )this.attributes.get(localizedKey)); 118 else 119 return Integer.parseInt((String )this.attributes.get(key)); 120 } 121 catch(Exception e) 122 { 123 return 0; 124 } 125 126 } 127 128 } | Popular Tags |