sandygao 2002/07/22 11:11:24 Modified: java/src/org/apache/xerces/impl/dv/xs XSSimpleTypeDecl.java Log: Provide an empty validatoin context when no such context is specified. This makes the datatype libary easier to use for types that don't need the validation context. And it doesn't have performance impact: the null-pointer check happens anyway. Revision Changes Path 1.15 +38 -1 xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java Index: XSSimpleTypeDecl.java =================================================================== RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- XSSimpleTypeDecl.java 19 Jul 2002 15:51:18 -0000 1.14 +++ XSSimpleTypeDecl.java 22 Jul 2002 18:11:24 -0000 1.15 @@ -153,6 +153,37 @@ "preserve", "collapse", "replace", }; + static final ValidationContext fEmptyContext = new ValidationContext() { + public boolean needFacetChecking() { + return true; + } + public boolean needExtraChecking() { + return false; + } + public boolean needToNormalize() { + return true; + } + public boolean isEntityDeclared (String name) { + return false; + } + public boolean isEntityUnparsed (String name) { + return false; + } + public boolean isIdDeclared (String name) { + return false; + } + public void addId(String name) { + } + public void addIdRef(String name) { + } + public String getSymbol (String symbol) { + return null; + } + public String getURI(String prefix) { + return null; + } + }; + // this will be true if this is a static XSSimpleTypeDecl // and hence must remain immutable (i.e., applyFacets // may not be permitted to have any effect). @@ -1201,6 +1232,9 @@ */ public Object validate(String content, ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException { + if (context == null) + context = fEmptyContext; + if (validatedInfo == null) validatedInfo = new ValidatedInfo(); @@ -1223,6 +1257,9 @@ public void validate(ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException { + if (context == null) + context = fEmptyContext; + // then validate the actual value against the facets if (context.needFacetChecking() && (fFacetsDefined != 0 && fFacetsDefined != FACET_WHITESPACE)) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]