1 23 24 package org.infoglue.cms.entities.management; 25 26 import java.util.Locale ; 27 28 import org.infoglue.cms.entities.kernel.BaseEntityVO; 29 import org.infoglue.cms.entities.management.impl.simple.LanguageImpl; 30 import org.infoglue.cms.exception.ConstraintException; 31 import org.infoglue.cms.util.ConstraintExceptionBuffer; 32 import org.infoglue.cms.util.validators.ValidatorFactory; 33 import org.infoglue.deliver.controllers.kernel.impl.simple.LanguageDeliveryController; 34 35 38 39 public class LanguageVO implements BaseEntityVO 40 { 41 private java.lang.Integer languageId; 42 private java.lang.String name; 43 private java.lang.String languageCode; 44 private java.lang.String charset = "ISO-8859-1"; 45 46 public String toString() 47 { 48 return getName(); 49 } 50 51 54 public Integer getId() { 55 return getLanguageId(); 56 } 57 58 public java.lang.Integer getLanguageId() 59 { 60 return this.languageId; 61 } 62 63 public void setLanguageId(java.lang.Integer languageId) 64 { 65 this.languageId = languageId; 66 } 67 68 public java.lang.String getName() 69 { 70 return this.name; 71 } 72 73 public java.lang.String getLanguageCode() 74 { 75 return this.languageCode; 76 } 77 78 public java.lang.String getCharset() 79 { 80 return this.charset; 81 } 82 83 public void setName(java.lang.String name) throws ConstraintException 84 { 85 ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); 86 ValidatorFactory.createStringValidator("Language.name", true, 4, 20).validate(name, ceb); 87 88 89 ceb.throwIfNotEmpty(); 90 this.name = name; 91 } 92 93 public void setLanguageCode(java.lang.String languageCode) throws ConstraintException 94 { 95 ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); 96 ValidatorFactory.createStringValidator("Language.languageCode", true, 2, 6).validate(languageCode, ceb); 97 98 ceb.throwIfNotEmpty(); 99 this.languageCode = languageCode; 100 } 101 102 public void setCharset(java.lang.String charset) 103 { 104 this.charset = charset; 105 } 106 107 110 111 public ConstraintExceptionBuffer validate() 112 { 113 ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); 114 if (name != null) ValidatorFactory.createStringValidator("Language.name", true, 4, 20, true, LanguageImpl.class, this.getId(), null).validate(name, ceb); 115 if (languageCode != null) ValidatorFactory.createStringValidator("Language.languageCode", true, 2, 6, true, LanguageImpl.class, this.getId(), null).validate(languageCode, ceb); 116 return ceb; 117 } 118 119 public boolean equals(Object o) 120 { 121 boolean equals = false; 122 123 if(o instanceof LanguageVO) 124 { 125 LanguageVO languageVO = (LanguageVO)o; 126 if(languageVO != null && languageVO.getLanguageId().equals(this.languageId)) 127 equals = true; 128 } 129 130 return equals; 131 } 132 133 public int hashCode() 134 { 135 return this.languageId.intValue(); 136 } 137 138 142 143 public Locale getLocale() 144 { 145 return LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithCode(this.languageCode); 146 } 147 148 152 153 public String getDisplayLanguage() 154 { 155 Locale locale = getLocale(); 156 return locale.getDisplayLanguage(); 157 } 158 159 163 164 public String getLocalizedDisplayLanguage() 165 { 166 Locale locale = getLocale(); 167 return locale.getDisplayLanguage(locale); 168 } 169 170 } 171 172 | Popular Tags |