com.sun.xml.internal.xsom.XSFacet Java Examples

The following examples show how to use com.sun.xml.internal.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: Axis.java    From openjdk-8 with GNU General Public License v2.0 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 #2
Source File: Axis.java    From openjdk-8-source with GNU General Public License v2.0 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 #3
Source File: SimpleTypeBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private BigInteger readFacet(String facetName,int offset) {
    XSFacet me = initiatingType.getFacet(facetName);
    if(me==null)
        return null;
    BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
    if(offset!=0)
        bi = bi.add(BigInteger.valueOf(offset));
    return bi;
}
 
Example #4
Source File: SchemaWriter.java    From hottub with GNU General Public License v2.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 itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
        println("</restriction>");
    }
 
Example #5
Source File: Axis.java    From hottub with GNU General Public License v2.0 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 #6
Source File: SimpleTypeBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private BigInteger readFacet(String facetName,int offset) {
    XSFacet me = initiatingType.getFacet(facetName);
    if(me==null)
        return null;
    BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
    if(offset!=0)
        bi = bi.add(BigInteger.valueOf(offset));
    return bi;
}
 
Example #7
Source File: RestrictionSimpleTypeImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public List<XSFacet> getFacets( String name ) {
    List<XSFacet> f = getDeclaredFacets(name);
    if(!f.isEmpty())     return f;

    // none was found on this datatype. check the base type.
    return getSimpleBaseType().getFacets(name);
}
 
Example #8
Source File: RestrictionSimpleTypeImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public List<XSFacet> getFacets( String name ) {
    List<XSFacet> f = getDeclaredFacets(name);
    if(!f.isEmpty())     return f;

    // none was found on this datatype. check the base type.
    return getSimpleBaseType().getFacets(name);
}
 
Example #9
Source File: SimpleTypeBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private BigInteger readFacet(String facetName,int offset) {
    XSFacet me = initiatingType.getFacet(facetName);
    if(me==null)
        return null;
    BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
    if(offset!=0)
        bi = bi.add(BigInteger.valueOf(offset));
    return bi;
}
 
Example #10
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public List<XSFacet> getFacets( String name ) {
    List<XSFacet> f = getDeclaredFacets(name);
    if(!f.isEmpty())     return f;

    // none was found on this datatype. check the base type.
    return getSimpleBaseType().getFacets(name);
}
 
Example #11
Source File: Axis.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 #12
Source File: SchemaWriter.java    From openjdk-jdk9 with GNU General Public License v2.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 itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
        println("</restriction>");
    }
 
Example #13
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 #14
Source File: SimpleTypeBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private BigInteger readFacet(String facetName,int offset) {
    XSFacet me = initiatingType.getFacet(facetName);
    if(me==null)
        return null;
    BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
    if(offset!=0)
        bi = bi.add(BigInteger.valueOf(offset));
    return bi;
}
 
Example #15
Source File: SimpleTypeBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private BigInteger readFacet(String facetName,int offset) {
    XSFacet me = initiatingType.getFacet(facetName);
    if(me==null)
        return null;
    BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
    if(offset!=0)
        bi = bi.add(BigInteger.valueOf(offset));
    return bi;
}
 
Example #16
Source File: SimpleTypeBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private BigInteger readFacet(String facetName,int offset) {
    XSFacet me = initiatingType.getFacet(facetName);
    if(me==null)
        return null;
    BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
    if(offset!=0)
        bi = bi.add(BigInteger.valueOf(offset));
    return bi;
}
 
Example #17
Source File: SchemaTreeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.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();

        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 #18
Source File: RestrictionSimpleTypeImpl.java    From TencentKona-8 with GNU General Public License v2.0 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 #19
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #20
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #21
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 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 #22
Source File: SchemaWriter.java    From openjdk-8 with GNU General Public License v2.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 itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
        println("</restriction>");
    }
 
Example #23
Source File: Axis.java    From openjdk-jdk9 with GNU General Public License v2.0 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 #24
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 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 #25
Source File: RestrictionSimpleTypeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Collection<? extends XSFacet> getDeclaredFacets() {
    return facets;
}
 
Example #26
Source File: ClassBinderFilter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public CElement facet(XSFacet xsFacet) {
    return core.facet(xsFacet);
}
 
Example #27
Source File: RestrictionSimpleTypeImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public Collection<? extends XSFacet> getDeclaredFacets() {
    return facets;
}
 
Example #28
Source File: SimpleTypeBuilder.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example #29
Source File: SimpleTypeBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if a type-safe enum should be created from
 * the given simple type by default without an explicit &lt;jaxb:enum> customization.
 */
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {

    // if not, there will be a problem wrt the class name of this type safe enum type.
    if( type.isLocal() )    return false;

    // if redefined, we should map the new definition, not the old one.
    if( type.getRedefinedBy()!=null )   return false;

    List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
    if( facets.isEmpty() )
        // if the type itself doesn't have the enumeration facet,
        // it won't be mapped to a type-safe enum.
        return false;

    if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
        // if there are too many facets, it's not very useful
        // produce warning when simple type is not mapped to enum
        // see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711

        if(reportedEnumMemberSizeWarnings == null)
            reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();

        if(!reportedEnumMemberSizeWarnings.contains(type)) {
            getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
                    type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());

            reportedEnumMemberSizeWarnings.add(type);
        }

        return false;
    }

    if( !canBeMappedToTypeSafeEnum(type) )
        // we simply can't map this to an enumeration
        return false;

    // check for collisions among constant names. if a collision will happen,
    // don't try to bind it to an enum.

    // return true only when this type is derived from one of the "enum base type".
    for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
        if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
            return true;

    return false;
}
 
Example #30
Source File: Step.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected boolean match(XSFacet f) {
    return f.getName().equals(name);
}