com.sun.xml.xsom.XSFacet Java Examples

The following examples show how to use com.sun.xml.xsom.XSFacet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Long getValue(XSFacet facet) {
	final XmlString value = facet.getValue();

	if (value == null) {
		return null;
	} else {
		final String v = value.value;

		if (v == null) {
			return null;
		} else {
			final BigInteger integerValue = DatatypeConverter.parseInteger(v);
			if (integerValue.compareTo(BigInteger
					.valueOf(Long.MAX_VALUE)) > 0) {
				return Long.MAX_VALUE;
			} else {
				return integerValue.longValue();
			}
		}
	}
}
 
Example #2
Source File: XMLSchemaProcessor.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param schemaSimpleType
 * @return
 */
public Vector<String> getSimpleTypeEnumeration ( SchemaSimpleType schemaSimpleType ) {

    Vector<String> enumeration = new Vector<String>();
    XSSimpleType st = parse( schemaSimpleType );

    XSRestrictionSimpleType restriction = st.asRestriction();

    if ( restriction != null ) {

        Iterator<? extends XSFacet> i = restriction.getDeclaredFacets().iterator();
        while (i.hasNext()) {
            XSFacet facet = i.next();

            if ( facet.getName().equals( XSFacet.FACET_ENUMERATION ) ) {
                enumeration.add( facet.getValue().value );
            }
        }
    }
    return enumeration;

}
 
Example #3
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 5 votes vote down vote up
private static boolean hasMinLength(XSRestrictionSimpleType xsRrestriction) {
  Iterator<XSFacet> facets = xsRrestriction.iterateDeclaredFacets();
  while (facets.hasNext()) {
    XSFacet facet = facets.next();
    String name = facet.getName();
    if ((XSFacet.FACET_LENGTH.equals(name) || XSFacet.FACET_MINLENGTH.equals(name))
        && Integer.parseInt(facet.getValue().toString()) > 0)
      return true;
  }
  return false;
}
 
Example #4
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 5 votes vote down vote up
private static boolean isEnumeration(XSRestrictionSimpleType xsRrestriction) {
  Iterator<XSFacet> facets = xsRrestriction.iterateDeclaredFacets();
  while (facets.hasNext())
    if (XSFacet.FACET_ENUMERATION.equals(facets.next().getName()))
      return true;
  return false;
}
 
Example #5
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void restrictionSimpleType( XSRestrictionSimpleType type ) {

		if(type.getBaseType()==null) {
			// don't print anySimpleType
			if(!type.getName().equals("anySimpleType"))
				throw new InternalError();
			if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
				throw new InternalError();
			return;
		}

		XSSimpleType baseType = type.getSimpleBaseType();

		println(MessageFormat.format("<restriction{0}>",
				baseType.isLocal()?"":" base=\"{"+
						baseType.getTargetNamespace()+'}'+
						baseType.getName()+'\"'));
		indent++;

		if(baseType.isLocal())
			simpleType(baseType);

		Iterator<XSFacet> itr = type.iterateDeclaredFacets();
		while(itr.hasNext())
			facet( (XSFacet)itr.next() );

		indent--;
		println("</restriction>");
	}
 
Example #6
Source File: CollectEnumerationValuesVisitor.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void restrictionSimpleType(XSRestrictionSimpleType type) {
	final List<XSFacet> facets = type.getFacets(XSFacet.FACET_ENUMERATION);
	if (facets != null) {
		for (XSFacet facet : facets) {
			final XmlString value = facet.getValue();
			if (value != null) {
				this.values.add(value);
			}
		}
	}
}
 
Example #7
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void restrictionSimpleType( XSRestrictionSimpleType type ) {

        if(type.getBaseType()==null) {
            // don't print anySimpleType
            if(!type.getName().equals("anySimpleType"))
                throw new InternalError();
            if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
                throw new InternalError();
            return;
        }

        XSSimpleType baseType = type.getSimpleBaseType();

        println(MessageFormat.format("<restriction{0}>",
            baseType.isLocal()?"":" base=\"{"+
            baseType.getTargetNamespace()+'}'+
            baseType.getName()+'\"'));
        indent++;

        if(baseType.isLocal())
            simpleType(baseType);

        Iterator<XSFacet> itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
		if (baseType.isLocal())
			println("</restriction>");
    }
 
Example #8
Source File: RestrictionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XSFacet getDeclaredFacet( String name ) {
    int len = facets.size();
    for( int i=0; i<len; i++ ) {
        XSFacet f = facets.get(i);
        if(f.getName().equals(name))
            return f;
    }
    return null;
}
 
Example #9
Source File: RestrictionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public List<XSFacet> getDeclaredFacets(String name) {
    List<XSFacet> r = new ArrayList<XSFacet>();
    for( XSFacet f : facets )
        if(f.getName().equals(name))
            r.add(f);
    return r;
}
 
Example #10
Source File: RestrictionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XSFacet getFacet( String name ) {
    XSFacet f = getDeclaredFacet(name);
    if(f!=null)     return f;

    // none was found on this datatype. check the base type.
    return getSimpleBaseType().getFacet(name);
}
 
Example #11
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void restrictionSimpleType(XSRestrictionSimpleType type) {

        if (type.getBaseType() == null) {
            // don't print anySimpleType
            if (!type.getName().equals("anySimpleType")) {
                throw new InternalError();
            }
            if (!Const.schemaNamespace.equals(type.getTargetNamespace())) {
                throw new InternalError();
            }
            return;
        }

        XSSimpleType baseType = type.getSimpleBaseType();

        String str = MessageFormat.format("Restriction {0}",
                new Object[]{baseType.isLocal() ? "" : " base=\"{"
                + baseType.getTargetNamespace() + "}"
                + baseType.getName() + "\""});

        SchemaTreeNode newNode = new SchemaTreeNode(str, baseType.getLocator());
        this.currNode.add(newNode);
        this.currNode = newNode;

        if (baseType.isLocal()) {
            simpleType(baseType);
        }

        Iterator itr = type.iterateDeclaredFacets();
        while (itr.hasNext()) {
            facet((XSFacet) itr.next());
        }

        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    }
 
Example #12
Source File: SchemaWriter.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void restrictionSimpleType( XSRestrictionSimpleType type ) {

        if(type.getBaseType()==null) {
            // don't print anySimpleType
            if(!type.getName().equals("anySimpleType"))
                throw new InternalError();
            if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
                throw new InternalError();
            return;
        }

        XSSimpleType baseType = type.getSimpleBaseType();

        println(MessageFormat.format("<restriction{0}>",
            new Object[]{
                baseType.isLocal()?"":" base=\"{"+
                baseType.getTargetNamespace()+'}'+
                baseType.getName()+'\"'
            }));
        indent++;

        if(baseType.isLocal())
            simpleType(baseType);

        Iterator itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
        println("</restriction>");
    }
 
Example #13
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<XSFacet> simpleType(XSSimpleType type) {
    // TODO: it's not clear if "facets" mean all inherited facets or just declared facets
    XSRestrictionSimpleType r = type.asRestriction();
    if(r!=null)
        return r.iterateDeclaredFacets();
    else
        return empty();
}
 
Example #14
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 4 votes vote down vote up
private static void processRestrictions(XSRestrictionSimpleType xsRrestriction, Restrictions restrictions) {
  if (log.isDebugEnabled())
    log.debug("Restriction: " + xsRrestriction);

  Iterator<XSFacet> facets = xsRrestriction.iterateDeclaredFacets();
  while (facets.hasNext()) {
    XSFacet facet = facets.next();

    if (log.isDebugEnabled())
      log.debug("Facet: " + facet + " " + facet.getValue() + " Fixed: " + facet.isFixed());

    String facetName = facet.getName();
    String facetValue = facet.getValue().toString();
    
    // Enumeration
    
    if (XSFacet.FACET_ENUMERATION.equals(facetName))
      restrictions.getChoices().add(new ChoiceImpl(facetValue));
    
    // Length
    
    else if (XSFacet.FACET_LENGTH.equals(facetName))
      restrictions.setLength(Integer.parseInt(facetValue));
    else if (XSFacet.FACET_MINLENGTH.equals(facetName))
      restrictions.setMinLength(Integer.parseInt(facetValue));
    else if (XSFacet.FACET_MAXLENGTH.equals(facetName))
      restrictions.setMaxLength(Integer.parseInt(facetValue));
    
    // Number Range
    
    else if (XSFacet.FACET_MININCLUSIVE.equals(facetName))
      restrictions.setMinInclusive(readXmlValue(xsRrestriction, facetValue));
    else if (XSFacet.FACET_MINEXCLUSIVE.equals(facetName))
      restrictions.setMinExclusive(readXmlValue(xsRrestriction, facetValue));
    else if (XSFacet.FACET_MAXINCLUSIVE.equals(facetName))
      restrictions.setMaxInclusive(readXmlValue(xsRrestriction, facetValue));
    else if (XSFacet.FACET_MAXEXCLUSIVE.equals(facetName))
      restrictions.setMaxExclusive(readXmlValue(xsRrestriction, facetValue));
    
    else
      log.warn("Unsupported Facet: " + facetName);
  }
}
 
Example #15
Source File: Step.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected boolean match(XSFacet f) {
    return f.getName().equals(name);
}
 
Example #16
Source File: Step.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Facet(Axis<? extends XSFacet> axis, String facetName) {
    super(axis);
    this.name = facetName;
}
 
Example #17
Source File: RestrictionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Collection<? extends XSFacet> getDeclaredFacets() {
    return facets;
}
 
Example #18
Source File: RestrictionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Iterator<XSFacet> iterateDeclaredFacets() {
    return facets.iterator();
}
 
Example #19
Source File: RestrictionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void addFacet( XSFacet facet ) {
    facets.add(facet);
}
 
Example #20
Source File: ListSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public XSFacet getFacet( String name ) { return null; } 
Example #21
Source File: UnionSimpleTypeImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public XSFacet getFacet( String name ) { return null; } 
Example #22
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public List<XSFacet> getDeclaredFacets(String name) { return Collections.EMPTY_LIST; } 
Example #23
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public XSFacet getDeclaredFacet(String name) { return null; } 
Example #24
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public XSFacet getFacet(String name) { return null; } 
Example #25
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public Collection<? extends XSFacet> getDeclaredFacets() { return Collections.EMPTY_LIST; } 
Example #26
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 votes vote down vote up
public Iterator<XSFacet> iterateDeclaredFacets() { return Iterators.empty(); }