1 57 58 package org.enhydra.apache.xerces.validators.schema; 59 60 import java.util.ListResourceBundle ; 61 import java.util.Locale ; 62 import java.util.ResourceBundle ; 63 64 import org.enhydra.apache.xerces.utils.XMLMessageProvider; 65 66 71 public class SchemaMessageProvider implements XMLMessageProvider { 72 75 public static final String SCHEMA_DOMAIN = "http://www.w3.org/TR/xml-schema-1"; 76 77 80 public void setLocale(Locale locale) { 81 fLocale = locale; 82 } 83 86 public Locale getLocale() { 87 return fLocale; 88 } 89 90 100 public String createMessage(Locale locale, int majorCode, int minorCode, Object args[]) { 101 boolean throwex = false; 102 if (fResourceBundle == null || locale != fLocale) { 103 if (locale != null) 104 fResourceBundle = ListResourceBundle.getBundle("org.enhydra.apache.xerces.msg.SchemaMessages", locale); 105 if (fResourceBundle == null) 106 fResourceBundle = ListResourceBundle.getBundle("org.enhydra.apache.xerces.msg.SchemaMessages"); 107 } 108 if (majorCode < 0 || majorCode >= fgMessageKeys.length) { 109 majorCode = MSG_BAD_MAJORCODE; 110 throwex = true; 111 } 112 String msgKey = fgMessageKeys[majorCode]; 113 String msg = fResourceBundle.getString(msgKey); 114 if (args != null) { 115 try { 116 msg = java.text.MessageFormat.format(msg, args); 117 } catch (Exception e) { 118 msg = fResourceBundle.getString(fgMessageKeys[MSG_FORMAT_FAILURE]); 119 msg += " " + fResourceBundle.getString(msgKey); 120 } 121 } 122 123 if (throwex) { 124 throw new RuntimeException (msg); 125 } 126 return msg; 127 } 128 private Locale fLocale = null; 132 private ResourceBundle fResourceBundle = null; 133 public static final int 137 MSG_BAD_MAJORCODE = 0, MSG_FORMAT_FAILURE = 1, NoValidatorFor = 2, 140 IncorrectDatatype = 3, 141 AttMissingType = 4, 142 NotADatatype = 5, 143 TextOnlyContentWithType = 6, 144 FeatureUnsupported = 7, 145 NestedOnlyInElemOnly = 8, 146 EltRefOnlyInMixedElemOnly = 9, 147 OnlyInEltContent = 10, 148 OrderIsAll = 11, 149 DatatypeWithType = 12, 150 DatatypeQualUnsupported = 13, 151 GroupContentRestricted = 14, 152 UnknownBaseDatatype = 15, 153 BadAttWithRef = 16, 154 NoContentForRef = 17, 155 IncorrectDefaultType = 18, 156 IllegalAttContent = 19, 157 ValueNotInteger = 20, 158 DatatypeError = 21, 159 TypeAlreadySet = 22, 160 GenericError = 23, 161 UnclassifiedError = 24, 162 ContentError = 25, 163 AnnotationError = 26, 164 ListUnionRestrictionError = 27, 165 ProhibitedAttributePresent = 28, 166 UniqueNotEnoughValues = 29, 168 KeyNotEnoughValues = 30, 169 KeyRefNotEnoughValues = 31, 170 DuplicateField = 32, 171 DuplicateUnique = 33, 172 DuplicateKey = 34, 173 KeyNotFound = 35, 174 UnknownField = 36, 175 KeyRefReferNotFound = 37, 176 FixedDiffersFromActual = 38, 177 InvalidBaseType = 39, 179 FieldMultipleMatch = 40, 180 KeyRefOutOfScope = 41, 181 AbsentKeyValue = 42, 182 KeyMatchesNillable = 43, 183 BadMinMaxForAllElem = 44, 184 BadMinMaxForGroupWithAll = 45, 185 SeqChoiceContentRestricted = 46, 186 AllContentRestricted = 47, 187 AllContentLimited = 48, 188 MinMaxOnGroupChild = 49, 189 BadMinMaxForAllGp = 50, 190 SchemaLocation = 51, 191 UniqueParticleAttribution = 52, 192 Con3X3ElementAppearance = 53, 193 Con3X3AttributeAppearance = 54, 194 Con3X3AttributeMustAppear = 55, 195 Con3X3AttributeInvalidValue = 56, 196 CardinalityNotEqual = 57, 197 199 MSG_MAX_CODE = 58; 200 public static final int 204 MSG_NONE = 0; 205 206 public static final String [] fgMessageKeys = { 207 "BadMajorCode", "FormatFailed", "NoValidatorFor", "IncorrectDatatype", "AttMissingType", "NotADatatype", "TextOnlyContentWithType", "FeatureUnsupported", "NestedOnlyInElemOnly", "EltRefOnlyInMixedElemOnly", "OnlyInEltContent", "OrderIsAll", "DatatypeWithType", "DatatypeQualUnsupported", "GroupContentRestricted", "UnknownBaseDatatype", "BadAttWithRef", "NoContentForRef", "IncorrectDefaultType", "IllegalAttContent", "ValueNotInteger", "DatatypeError", "TypeAlreadySet", "GenericError", "UnclassifiedError", "ContentError", "AnnotationError", "ListUnionRestrictionError", "ProhibitedAttributePresent", "UniqueNotEnoughValues", 238 "KeyNotEnoughValues", 239 "KeyRefNotEnoughValues", 240 "DuplicateField", 241 "DuplicateUnique", 242 "DuplicateKey", 243 "KeyNotFound", 244 "UnknownField", 245 "KeyRefReferNotFound", 246 "FixedDiffersFromActual", 247 "InvalidBaseType", 248 "FieldMultipleMatch", 249 "KeyRefOutOfScope", 250 "AbsentKeyValue", 251 "KeyMatchesNillable", 252 "BadMinMaxForAllElem", 253 "BadMinMaxForGroupWithAll", 254 "SeqChoiceContentRestricted", 255 "AllContentRestricted", 256 "AllContentLimited", 257 "MinMaxOnGroupChild", 258 "BadMinMaxForAllGp", 259 "SchemaLocation", 260 "UniqueParticleAttribution", 261 "Con3X3ElementAppearance", 262 "Con3X3AttributeAppearance", 263 "Con3X3AttributeMustAppear", 264 "Con3X3AttributeInvalidValue", 265 "CardinalityNotEqual", 266 }; 268 } 269 | Popular Tags |