示例#1
0
    /**
     * Reads and sets the facets for XSShort
     * @param simpletype the Simpletype containing the facets
     **/
    public void setFacets(SimpleType simpleType)
    {
        //-- copy valid facets
        Enumeration enum = getFacets(simpleType);
        while (enum.hasMoreElements()) {

            Facet facet = (Facet)enum.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
示例#2
0
  /**
   * Reads and sets the facets for XSXSGDay override the readFacet method of XSType
   *
   * @param simpleType the Simpletype containing the facets
   * @see org.exolab.castor.builder.types.XSType#getFacets
   */
  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(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)) {
          LOG.warn("Warning: The facet 'pattern' is not currently supported for XSGDay.");
        }
      } catch (ParseException e) {
        // not possible to set the facet properly
        // This can't happen since a ParseException would have been set
        // during the unmarshalling of the facets
        e.printStackTrace();
        return;
      }
    } // while
  } // setFacets