📄 xssimpletypedecl.java
字号:
public boolean getAnonymous() { return fAnonymous || (fTypeName == null); } public short getVariety(){ // for anySimpleType, return absent variaty return fValidationDV == DV_ANYSIMPLETYPE ? VARIETY_ABSENT : fVariety; } public boolean isIDType(){ switch (fVariety) { case VARIETY_ATOMIC: return fValidationDV == DV_ID; case VARIETY_LIST: return fItemType.isIDType(); case VARIETY_UNION: for (int i = 0; i < fMemberTypes.length; i++) { if (fMemberTypes[i].isIDType()) return true; } } return false; } public short getWhitespace() throws DatatypeException{ if (fVariety == VARIETY_UNION) { throw new DatatypeException("dt-whitespace", new Object[]{fTypeName}); } return fWhiteSpace; } public short getPrimitiveKind() { if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) { if (fValidationDV == DV_ID || fValidationDV == DV_IDREF || fValidationDV == DV_ENTITY) { return DV_STRING; } else if (fValidationDV == DV_INTEGER) { return DV_DECIMAL; } else if (Constants.SCHEMA_1_1_SUPPORT && (fValidationDV == DV_YEARMONTHDURATION || fValidationDV == DV_DAYTIMEDURATION)) { return DV_DURATION; } else { return fValidationDV; } } else { // REVISIT: error situation. runtime exception? return (short)0; } } /** * Returns the closest built-in type category this type represents or * derived from. For example, if this simple type is a built-in derived * type integer the <code>INTEGER_DV</code> is returned. */ public short getBuiltInKind() { return this.fBuiltInKind; } /** * If variety is <code>atomic</code> the primitive type definition (a * built-in primitive datatype definition or the simple ur-type * definition) is available, otherwise <code>null</code>. */ public XSSimpleTypeDefinition getPrimitiveType() { if (fVariety == VARIETY_ATOMIC && fValidationDV != DV_ANYSIMPLETYPE) { XSSimpleTypeDecl pri = this; // recursively get base, until we reach anySimpleType while (pri.fBase != fAnySimpleType) pri = pri.fBase; return pri; } else { // REVISIT: error situation. runtime exception? return null; } } /** * If variety is <code>list</code> the item type definition (an atomic or * union simple type definition) is available, otherwise * <code>null</code>. */ public XSSimpleTypeDefinition getItemType() { if (fVariety == VARIETY_LIST) { return fItemType; } else { // REVISIT: error situation. runtime exception? return null; } } /** * If variety is <code>union</code> the list of member type definitions (a * non-empty sequence of simple type definitions) is available, * otherwise an empty <code>XSObjectList</code>. */ public XSObjectList getMemberTypes() { if (fVariety == VARIETY_UNION) { return new XSObjectListImpl(fMemberTypes, fMemberTypes.length); } else { // REVISIT: error situation. runtime exception? return null; } } /** * If <restriction> is chosen */ public void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, ValidationContext context) throws InvalidDatatypeFacetException { applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, context); } /** * built-in derived types by restriction */ void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet) { try { applyFacets(facets, presentFacet, fixedFacet, SPECIAL_PATTERN_NONE, fDummyContext); } catch (InvalidDatatypeFacetException e) { // should never gets here, internel error throw new RuntimeException("internal error"); } // we've now applied facets; so lock this object: fIsImmutable = true; } /** * built-in derived types by restriction */ void applyFacets1(XSFacets facets, short presentFacet, short fixedFacet, short patternType) { try { applyFacets(facets, presentFacet, fixedFacet, patternType, fDummyContext); } catch (InvalidDatatypeFacetException e) { // should never gets here, internel error throw new RuntimeException("internal error"); } // we've now applied facets; so lock this object: fIsImmutable = true; } /** * If <restriction> is chosen, or built-in derived types by restriction */ void applyFacets(XSFacets facets, short presentFacet, short fixedFacet, short patternType, ValidationContext context) throws InvalidDatatypeFacetException { // if the object is immutable, should not apply facets... if(fIsImmutable) return; ValidatedInfo tempInfo = new ValidatedInfo(); // clear facets. because we always inherit facets in the constructor // REVISIT: in fact, we don't need to clear them. // we can convert 5 string values (4 bounds + 1 enum) to actual values, // store them somewhere, then do facet checking at once, instead of // going through the following steps. (lots of checking are redundant: // for example, ((presentFacet & FACET_XXX) != 0)) fFacetsDefined = 0; fFixedFacet = 0; int result = 0 ; // step 1: parse present facets short allowedFacet = fDVs[fValidationDV].getAllowedFacets(); // length if ((presentFacet & FACET_LENGTH) != 0) { if ((allowedFacet & FACET_LENGTH) == 0) { reportError("cos-applicable-facets", new Object[]{"length", fTypeName}); } else { fLength = facets.length; lengthAnnotation = facets.lengthAnnotation; fFacetsDefined |= FACET_LENGTH; if ((fixedFacet & FACET_LENGTH) != 0) fFixedFacet |= FACET_LENGTH; } } // minLength if ((presentFacet & FACET_MINLENGTH) != 0) { if ((allowedFacet & FACET_MINLENGTH) == 0) { reportError("cos-applicable-facets", new Object[]{"minLength", fTypeName}); } else { fMinLength = facets.minLength; minLengthAnnotation = facets.minLengthAnnotation; fFacetsDefined |= FACET_MINLENGTH; if ((fixedFacet & FACET_MINLENGTH) != 0) fFixedFacet |= FACET_MINLENGTH; } } // maxLength if ((presentFacet & FACET_MAXLENGTH) != 0) { if ((allowedFacet & FACET_MAXLENGTH) == 0) { reportError("cos-applicable-facets", new Object[]{"maxLength", fTypeName}); } else { fMaxLength = facets.maxLength; maxLengthAnnotation = facets.maxLengthAnnotation; fFacetsDefined |= FACET_MAXLENGTH; if ((fixedFacet & FACET_MAXLENGTH) != 0) fFixedFacet |= FACET_MAXLENGTH; } } // pattern if ((presentFacet & FACET_PATTERN) != 0) { if ((allowedFacet & FACET_PATTERN) == 0) { reportError("cos-applicable-facets", new Object[]{"pattern", fTypeName}); } else { patternAnnotations = facets.patternAnnotations; RegularExpression regex = null; try { regex = new RegularExpression(facets.pattern, "X"); } catch (ParseException e) { reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage(), new Integer(e.getLocation())}); } if (regex != null) { fPattern = new Vector(); fPattern.addElement(regex); fPatternStr = new Vector(); fPatternStr.addElement(facets.pattern); fFacetsDefined |= FACET_PATTERN; if ((fixedFacet & FACET_PATTERN) != 0) fFixedFacet |= FACET_PATTERN; } } } // enumeration if ((presentFacet & FACET_ENUMERATION) != 0) { if ((allowedFacet & FACET_ENUMERATION) == 0) { reportError("cos-applicable-facets", new Object[]{"enumeration", fTypeName}); } else { fEnumeration = new Vector(); Vector enumVals = facets.enumeration; fEnumerationType = new short[enumVals.size()]; fEnumerationItemType = new ShortList[enumVals.size()]; Vector enumNSDecls = facets.enumNSDecls; ValidationContextImpl ctx = new ValidationContextImpl(context); enumerationAnnotations = facets.enumAnnotations; for (int i = 0; i < enumVals.size(); i++) { if (enumNSDecls != null) ctx.setNSContext((NamespaceContext)enumNSDecls.elementAt(i)); try { ValidatedInfo info = this.fBase.validateWithInfo((String)enumVals.elementAt(i), ctx, tempInfo); // check 4.3.5.c0 must: enumeration values from the value space of base fEnumeration.addElement(info.actualValue); fEnumerationType[i] = info.actualValueType; fEnumerationItemType[i] = info.itemValueTypes; } catch (InvalidDatatypeValueException ide) { reportError("enumeration-valid-restriction", new Object[]{enumVals.elementAt(i), this.getBaseType().getName()}); } } fFacetsDefined |= FACET_ENUMERATION; if ((fixedFacet & FACET_ENUMERATION) != 0) fFixedFacet |= FACET_ENUMERATION; } } // whiteSpace if ((presentFacet & FACET_WHITESPACE) != 0) { if ((allowedFacet & FACET_WHITESPACE) == 0) { reportError("cos-applicable-facets", new Object[]{"whiteSpace", fTypeName}); } else { fWhiteSpace = facets.whiteSpace; whiteSpaceAnnotation = facets.whiteSpaceAnnotation; fFacetsDefined |= FACET_WHITESPACE; if ((fixedFacet & FACET_WHITESPACE) != 0) fFixedFacet |= FACET_WHITESPACE; } } // maxInclusive if ((presentFacet & FACET_MAXINCLUSIVE) != 0) { if ((allowedFacet & FACET_MAXINCLUSIVE) == 0) { reportError("cos-applicable-facets", new Object[]{"maxInclusive", fTypeName}); } else { maxInclusiveAnnotation = facets.maxInclusiveAnnotation; try { fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true); fFacetsDefined |= FACET_MAXINCLUSIVE; if ((fixedFacet & FACET_MAXINCLUSIVE) != 0) fFixedFacet |= FACET_MAXINCLUSIVE; } catch (InvalidDatatypeValueException ide) { reportError(ide.getKey(), ide.getArgs()); reportError("FacetValueFromBase", new Object[]{fTypeName, facets.maxInclusive,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -