Package org.exolab.castor.xml.schema

Examples of org.exolab.castor.xml.schema.Facet


        int count = 0;

        StringBuilder values = new StringBuilder("{\n");

        while (enumeration.hasMoreElements()) {
            Facet facet = (Facet) enumeration.nextElement();
            String value = facet.getValue();

            //-- Should we make sure the value is valid before proceeding??

            //-- we need to move this code to XSType so that we don't have to do
            //-- special code here for each type
View Full Code Here


        // create targeted schema
        _schema.addNamespace("pre", "my.namespace.org");

        SimpleType sType = _schema.createSimpleType("myType", "int", "");

        Facet min = new Facet(Facet.MIN_EXCLUSIVE, "0");
        Facet max = new Facet(Facet.MAX_EXCLUSIVE, "100");
        sType.addFacet(min);
        sType.addFacet(max);

        _schema.addSimpleType(sType);
View Full Code Here

    public void checkConstraints(
            final Enumeration localFacets, final Enumeration baseFacets)
            throws SchemaException {

        while (localFacets.hasMoreElements()) {
            final Facet other = (Facet) localFacets.nextElement();
            if (this == other) {
                continue; // do not check against self
            }
            final String otherName = other.getName();
            if (otherName.equals(Facet.MIN_INCLUSIVE)) {
                // Schema Component Constraint: minInclusive and minExclusive
                throw new SchemaException(
                        "It is an error for both minInclusive and minExclusive "
                        + "to be specified for the same datatype.");
            } else if (otherName.equals(Facet.MAX_INCLUSIVE)
                    && getOwningType().isNumericType()
                    && this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
                // Schema Component Constraint: minExclusive < maxInclusive
                throw new SchemaException(
                        "It is an error for the value specified "
                        + "for minExclusive to be greater than "
                        + "or equal to the value specified for "
                        + "maxInclusive for the same datatype.");
            }
        }
        if (baseFacets != null) {
            while (baseFacets.hasMoreElements()) {
                final Facet other = (Facet) baseFacets.nextElement();
                final String otherName = other.getName();

                // Schema Component Constraint: minExclusive valid restriction
                //   It is an error if any of the following conditions is true:
                if (otherName.equals(Facet.MIN_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) < 0) {
                    // [1]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minExclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is less than "
                            + "the {value} of the parent minExclusive.");
                } else if (otherName.equals(Facet.MAX_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) > 0) {
                    // [2]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxInclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is greater than "
                            + "the {value} of the parent maxInclusive.");
                } else if (otherName.equals(Facet.MIN_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) < 0) {
                    // [3]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minInclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is less than "
                            + "the {value} of the parent minInclusive.");
                } else if (otherName.equals(Facet.MAX_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
                    // [4]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxExclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is greater than "
View Full Code Here

    public void checkConstraints(
            final Enumeration localFacets, final Enumeration baseFacets)
            throws SchemaException {

        while (localFacets.hasMoreElements()) {
            final Facet other = (Facet) localFacets.nextElement();
            if (this == other) {
                continue; // do not check against self
            }
            final String otherName = other.getName();
            if (otherName.equals(Facet.MAX_INCLUSIVE)) {
                // Schema Component Constraint: maxInclusive and maxExclusive
                throw new SchemaException(
                        "It is an error for both maxInclusive and maxExclusive "
                        + "to be specified in the same derivation step "
                        + "of a datatype definition.");
            } else if (otherName.equals(Facet.MIN_EXCLUSIVE)
                     && other.toBigDecimal().compareTo(this.toBigDecimal()) > 0) {
                // Schema Component Constraint: minExclusive <= maxExclusive
                throw new SchemaException(
                        "It is an error for the value specified "
                        + "for minExclusive to be greater than the value "
                        + "specified for maxExclusive for the same datatype.");
            }
        }
        if (baseFacets != null) {
            while (baseFacets.hasMoreElements()) {
                final Facet other = (Facet) baseFacets.nextElement();
                final String otherName = other.getName();

                // Schema Component Constraint: maxExclusive valid restriction
                //   It is an error if any of the following conditions is true:
                if (otherName.equals(Facet.MAX_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) > 0) {
                    // [1]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxExclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is greater than "
                            + "the {value} of the parent maxExclusive.");
                } else if (otherName.equals(Facet.MAX_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) > 0) {
                    // [2]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxInclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is greater than "
                            + "the {value} of the parent maxInclusive.");
                } else if (otherName.equals(Facet.MIN_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) <= 0) {
                    // [3]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minInclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is less than "
                            + "or equal to the {value} of the parent minInclusive.");
                } else if (otherName.equals(Facet.MIN_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) <= 0) {
                    // [4]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minExclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is less than "
View Full Code Here

    public void checkConstraints(
            final Enumeration localFacets, final Enumeration baseFacets)
            throws SchemaException {

        while (localFacets.hasMoreElements()) {
            final Facet other = (Facet) localFacets.nextElement();
            if (this == other) {
                continue; // do not check against self
            }
            final String otherName = other.getName();
            if (otherName.equals(Facet.MIN_INCLUSIVE)
                    && getOwningType().isNumericType()
                    && other.toBigDecimal().compareTo(this.toBigDecimal()) > 0) {
                // Schema Component Constraint: minInclusive <= maxInclusive
                throw new SchemaException(
                        "It is an error for the value specified "
                        + "for minInclusive to be greater than "
                        + "the value specified for maxInclusive "
                        + "for the same datatype.");
            }
        }
        if (baseFacets != null) {
            while (baseFacets.hasMoreElements()) {
                final Facet other = (Facet) baseFacets.nextElement();
                final String otherName = other.getName();

                // Schema Component Constraint: maxInclusive valid restriction
                //   It is an error if any of the following conditions is true:
                if (otherName.equals(Facet.MAX_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) > 0) {
                    // [1]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxInclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is greater than "
                            + "the {value} of the parent maxInclusive.");
                } else if (otherName.equals(Facet.MAX_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
                    // [2]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxExclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is greater than "
                            + "or equal to the {value} of the parent maxExclusive.");
                } else if (otherName.equals(Facet.MIN_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) < 0) {
                    // [3]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minInclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is less than "
                            + "the {value} of the parent minInclusive.");
                } else if (otherName.equals(Facet.MIN_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) <= 0) {
                    // [4]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minExclusive is among the members of {facets} "
                            + "of {base type definition} and {value} is less than "
View Full Code Here

    public void checkConstraints(
            final Enumeration localFacets, final Enumeration baseFacets)
            throws SchemaException {

        while (localFacets.hasMoreElements()) {
            final Facet other = (Facet) localFacets.nextElement();
            if (this == other) {
                continue; // do not check against self
            }
            final String otherName = other.getName();
            if (otherName.equals(Facet.MAX_EXCLUSIVE)
                    && getOwningType().isNumericType()
                    && this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
                // Schema Component Constraint: minInclusive < maxExclusive
                throw new SchemaException(
                        "It is an error for the value specified "
                        + "for minInclusive to be greater than "
                        + "or equal to the value specified for "
                        + "maxExclusive for the same datatype.");
            }
        }
        if (baseFacets != null) {
            while (baseFacets.hasMoreElements()) {
                final Facet other = (Facet) baseFacets.nextElement();
                final String otherName = other.getName();

                // Schema Component Constraint: minInclusive valid restriction
                //   It is an error if any of the following conditions is true:
                if (otherName.equals(Facet.MIN_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) < 0) {
                    // [1]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minInclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is less than "
                            + "the {value} of the parent minInclusive.");
                } else if (otherName.equals(Facet.MAX_INCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) > 0) {
                    // [2]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxInclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is greater than "
                            + "the {value} of the parent maxInclusive.");
                } else if (otherName.equals(Facet.MIN_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) <= 0) {
                    // [3]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "minExclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is less than "
                            + "or equal to the {value} of the parent minExclusive.");
                } else if (otherName.equals(Facet.MAX_EXCLUSIVE)
                        && getOwningType().isNumericType()
                        && this.toBigDecimal().compareTo(other.toBigDecimal()) >= 0) {
                    // [4]
                    throw new SchemaException(
                            "It is an error if the following condition is true: "
                            + "maxExclusive is among the members of {facets} of "
                            + "{base type definition} and {value} is greater than "
View Full Code Here

  public void setFacets(SimpleType simpleType) {
    //-- copy valid facets
    Enumeration enumeration = getFacets(simpleType);
    while (enumeration.hasMoreElements()) {

      Facet facet = (Facet) enumeration.nextElement();
      String name = facet.getName();

      try {
        //-- maxExclusive
        if (Facet.MAX_EXCLUSIVE.equals(name))
          this.setMaxExclusive(Time.parseTime(facet.getValue()));
        //-- maxInclusive
        else if (Facet.MAX_INCLUSIVE.equals(name))
          this.setMaxInclusive(Time.parseTime(facet.getValue()));
        //-- minExclusive
        else if (Facet.MIN_EXCLUSIVE.equals(name))
          this.setMinExclusive(Time.parseTime(facet.getValue()));
        //-- minInclusive
        else if (Facet.MIN_INCLUSIVE.equals(name))
          this.setMinInclusive(Time.parseTime(facet.getValue()));
        //-- pattern
        else if (Facet.PATTERN.equals(name)) {
          //do nothing for the moment
          System.out.println(
            "Warning: The facet 'pattern' is not currently supported for XSTime.");
View Full Code Here

  public void setFacets(SimpleType simpleType) {
    //-- copy valid facets
    Enumeration enumeration = getFacets(simpleType);
    while (enumeration.hasMoreElements()) {

      Facet facet = (Facet) enumeration.nextElement();
      String name = facet.getName();

      //-- maxExclusive
      if (Facet.MAX_EXCLUSIVE.equals(name))
        setMaxExclusive(facet.toShort());
      //-- maxInclusive
      else if (Facet.MAX_INCLUSIVE.equals(name))
        setMaxInclusive(facet.toShort());
      //-- minExclusive
      else if (Facet.MIN_EXCLUSIVE.equals(name)) {
        setMinExclusive(facet.toShort());
      }
      //-- minInclusive
      else if (Facet.MIN_INCLUSIVE.equals(name))
        setMinInclusive(facet.toShort());
      //-- pattern
      else if (Facet.PATTERN.equals(name))
        setPattern(facet.getValue());

    }

  } //-- toXSShort
View Full Code Here

  public void setFacets(SimpleType simpleType) {
    //-- copy valid facets
    Enumeration enumeration = getFacets(simpleType);
    while (enumeration.hasMoreElements()) {

      Facet facet = (Facet) enumeration.nextElement();
      String name = facet.getName();

      try {
        //-- maxExclusive
        if (Facet.MAX_EXCLUSIVE.equals(name))
          this.setMaxExclusive(
            Duration.parseDuration(facet.getValue()));
        //-- maxInclusive
        else if (Facet.MAX_INCLUSIVE.equals(name))
          this.setMaxInclusive(
            Duration.parseDuration(facet.getValue()));
        //-- minExclusive
        else if (Facet.MIN_EXCLUSIVE.equals(name))
          this.setMinExclusive(
            Duration.parseDuration(facet.getValue()));
        //-- minInclusive
        else if (Facet.MIN_INCLUSIVE.equals(name))
          this.setMinInclusive(
            Duration.parseDuration(facet.getValue()));
        //-- pattern
        else if (Facet.PATTERN.equals(name)) {
          //do nothing for the moment
          System.out.println(
            "Warning: The facet 'pattern' is not currently supported for Duration.");
View Full Code Here

    {
        //-- copy valid facets
        Enumeration enumeration = getFacets(simpleType);
        while (enumeration.hasMoreElements()) {

            Facet facet = (Facet)enumeration.nextElement();
            String name = facet.getName();

            try {
                //-- maxExclusive
                if (Facet.MAX_EXCLUSIVE.equals(name))
                    this.setMaxExclusive(GDay.parseGDay(facet.getValue()));
                //-- maxInclusive
                else if (Facet.MAX_INCLUSIVE.equals(name))
                    this.setMaxInclusive(GDay.parseGDay(facet.getValue()));
                //-- minExclusive
                else if (Facet.MIN_EXCLUSIVE.equals(name))
                    this.setMinExclusive(GDay.parseGDay(facet.getValue()));
                //-- minInclusive
                else if (Facet.MIN_INCLUSIVE.equals(name))
                    this.setMinInclusive(GDay.parseGDay(facet.getValue()));
                //-- pattern
                else if (Facet.PATTERN.equals(name)) {
                    //do nothing for the moment
                    System.out.println("Warning: The facet 'pattern' is not currently supported for XSGDay.");
                }
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.schema.Facet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.