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

The following examples show how to use com.sun.xml.internal.xsom.XSSimpleType. 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: BIGlobalBinding.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #2
Source File: UnionSimpleTypeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Iterator<XSSimpleType> iterator() {
    return new Iterator<XSSimpleType>() {
        int idx=0;
        public boolean hasNext() {
            return idx<memberTypes.length;
        }

        public XSSimpleType next() {
            return memberTypes[idx++].getType();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
Example #3
Source File: SimpleTypeBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns true if the given simple type can be mapped to a
 * type-safe enum class.
 *
 * <p>
 * JAXB spec places a restrictrion as to what type can be
 * mapped to a type-safe enum. This method enforces this
 * constraint.
 */
public static boolean canBeMappedToTypeSafeEnum( XSSimpleType type ) {
    do {
        if( WellKnownNamespace.XML_SCHEMA.equals(type.getTargetNamespace()) ) {
            // type must be derived from one of these types
            String localName = type.getName();
            if( localName!=null ) {
                if( localName.equals("anySimpleType") )
                    return false;   // catch all case
                if( localName.equals("ID") || localName.equals("IDREF") )
                    return false;   // not ID/IDREF

                // other allowed list
                if( builtinTypeSafeEnumCapableTypes.contains(localName) )
                    return true;
            }
        }

        type = type.getSimpleBaseType();
    } while( type!=null );

    return false;
}
 
Example #4
Source File: SchemaTreeTraverser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

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

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
Example #5
Source File: SchemaWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void dump( XSAttributeDecl decl, String additionalAtts ) {
    XSSimpleType type=decl.getType();

    println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
        decl.getName(),
        additionalAtts,
        type.isLocal()?"":
            MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()),
        decl.getFixedValue()==null ?
            "":" fixed=\""+decl.getFixedValue()+'\"',
        decl.getDefaultValue()==null ?
            "":" default=\""+decl.getDefaultValue()+'\"',
        type.isLocal()?"":" /"));

    if(type.isLocal()) {
        indent++;
        simpleType(type);
        indent--;
        println("</attribute>");
    }
}
 
Example #6
Source File: SchemaTreeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

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

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
Example #7
Source File: SchemaTreeTraverser.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();

        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 #8
Source File: SchemaWriter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void listSimpleType( XSListSimpleType type ) {
    XSSimpleType itemType = type.getItemType();

    if(itemType.isLocal()) {
        println("<list>");
        indent++;
        simpleType(itemType);
        indent--;
        println("</list>");
    } else {
        // global type
        println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
            itemType.getTargetNamespace(), itemType.getName()));
    }
}
 
Example #9
Source File: BIConversion.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private String parseMethodFor(XSSimpleType owner) {
    if(parseMethod!=null)   return parseMethod;

    if(inMemoryType.unboxify().isPrimitive()) {
        String method = getConversionMethod("parse", owner);
        if(method!=null) {
            // this cast is necessary for conversion between primitive Java types
            return '('+inMemoryType.unboxify().fullName()+')'+method;
        }
    }

    return "new";
}
 
Example #10
Source File: Axis.java    From jdk8u60 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 #11
Source File: NGCCRuntimeEx.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean ignorableDuplicateComponent(XSDeclaration c) {
    if(c.getTargetNamespace().equals(Const.schemaNamespace)) {
        if(c instanceof XSSimpleType)
            // hide artificial "double definitions" on simple types
            return true;
        if(c.isGlobal() && c.getName().equals("anyType"))
            return true; // ditto for anyType
    }
    return false;
}
 
Example #12
Source File: SchemaTreeTraverser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example #13
Source File: BIConversion.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private String parseMethodFor(XSSimpleType owner) {
    if(parseMethod!=null)   return parseMethod;

    if(inMemoryType.unboxify().isPrimitive()) {
        String method = getConversionMethod("parse", owner);
        if(method!=null) {
            // this cast is necessary for conversion between primitive Java types
            return '('+inMemoryType.unboxify().fullName()+')'+method;
        }
    }

    return "new";
}
 
Example #14
Source File: SchemaTreeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void simpleType(XSSimpleType type) {

        String str = MessageFormat.format("Simple type {0}",
                new Object[]{type.isLocal() ? "" : " name=\""
                + type.getName() + "\""});

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

        type.visit((XSSimpleTypeVisitor) this);

        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    }
 
Example #15
Source File: SchemaTreeTraverser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example #16
Source File: SchemaTreeTraverser.java    From openjdk-8-source 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 #17
Source File: BIConversion.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private String printMethodFor(XSSimpleType owner) {
    if(printMethod!=null)   return printMethod;

    if(inMemoryType.unboxify().isPrimitive()) {
        String method = getConversionMethod("print",owner);
        if(method!=null)
            return method;
    }

    return "toString";
}
 
Example #18
Source File: DefaultClassBinder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public CElement simpleType(XSSimpleType type) {
    CElement c = allow(type,type.getName());
    if(c!=null) return c;

    if(getGlobalBinding().isSimpleTypeSubstitution() && type.isGlobal()) {
        return new CClassInfo(model,selector.getClassScope(),
                deriveName(type), type.getLocator(), getName(type), null, type, null );
    }

    return never();
}
 
Example #19
Source File: BIConversion.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private String findBaseConversion(XSSimpleType owner) {
    // find the base simple type mapping.
    for( XSSimpleType st=owner; st!=null; st = st.getSimpleBaseType() ) {
        if( !WellKnownNamespace.XML_SCHEMA.equals(st.getTargetNamespace()) )
            continue;   // user-defined type

        String name = st.getName().intern();
        for( String s : knownBases )
            if(name.equalsIgnoreCase(s))
                return s;
    }

    return null;
}
 
Example #20
Source File: SchemaTreeTraverser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example #21
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 #22
Source File: SchemaTreeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example #23
Source File: NGCCRuntimeEx.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean ignorableDuplicateComponent(XSDeclaration c) {
    if(c.getTargetNamespace().equals(Const.schemaNamespace)) {
        if(c instanceof XSSimpleType)
            // hide artificial "double definitions" on simple types
            return true;
        if(c.isGlobal() && c.getName().equals("anyType"))
            return true; // ditto for anyType
    }
    return false;
}
 
Example #24
Source File: NGCCRuntimeEx.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static boolean ignorableDuplicateComponent(XSDeclaration c) {
    if(c.getTargetNamespace().equals(Const.schemaNamespace)) {
        if(c instanceof XSSimpleType)
            // hide artificial "double definitions" on simple types
            return true;
        if(c.isGlobal() && c.getName().equals("anyType"))
            return true; // ditto for anyType
    }
    return false;
}
 
Example #25
Source File: SchemaWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void schema( XSSchema s ) {

        // QUICK HACK: don't print the built-in components
        if(s.getTargetNamespace().equals(Const.schemaNamespace))
            return;

        println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
        indent++;

        Iterator itr;

        itr = s.iterateAttGroupDecls();
        while(itr.hasNext())
            attGroupDecl( (XSAttGroupDecl)itr.next() );

        itr = s.iterateAttributeDecls();
        while(itr.hasNext())
            attributeDecl( (XSAttributeDecl)itr.next() );

        itr = s.iterateComplexTypes();
        while(itr.hasNext())
            complexType( (XSComplexType)itr.next() );

        itr = s.iterateElementDecls();
        while(itr.hasNext())
            elementDecl( (XSElementDecl)itr.next() );

        itr = s.iterateModelGroupDecls();
        while(itr.hasNext())
            modelGroupDecl( (XSModelGroupDecl)itr.next() );

        itr = s.iterateSimpleTypes();
        while(itr.hasNext())
            simpleType( (XSSimpleType)itr.next() );

        indent--;
        println("</schema>");
    }
 
Example #26
Source File: SimpleTypeBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Entry point from outside. Builds a BGM type expression
 * from a simple type schema component.
 *
 * @param type
 *      the simple type to be bound.
 */
public TypeUse build( XSSimpleType type ) {
    XSSimpleType oldi = initiatingType;
    this.initiatingType = type;

    TypeUse e = checkRefererCustomization(type);
    if(e==null)
        e = compose(type);

    initiatingType = oldi;

    return e;
}
 
Example #27
Source File: SimpleTypeBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A version of the {@link #build(XSSimpleType)} method
 * used to bind the definition of a class generated from
 * the given simple type.
 */
public TypeUse buildDef( XSSimpleType type ) {
    XSSimpleType oldi = initiatingType;
    this.initiatingType = type;

    TypeUse e = type.apply(composer);

    initiatingType = oldi;

    return e;
}
 
Example #28
Source File: SchemaTreeTraverser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void simpleType(XSSimpleType type) {

        String str = MessageFormat.format("Simple type {0}",
                new Object[]{type.isLocal() ? "" : " name=\""
                + type.getName() + "\""});

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

        type.visit((XSSimpleTypeVisitor) this);

        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    }
 
Example #29
Source File: SchemaImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void addSimpleType(XSSimpleType newDecl, boolean overwrite) {
    if(overwrite || !simpleTypes.containsKey(newDecl.getName())) {
        simpleTypes.put(newDecl.getName(), newDecl);
        allTypes.put(newDecl.getName(), newDecl);
    }
}
 
Example #30
Source File: SchemaImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void addSimpleType(XSSimpleType newDecl, boolean overwrite) {
    if(overwrite || !simpleTypes.containsKey(newDecl.getName())) {
        simpleTypes.put(newDecl.getName(), newDecl);
        allTypes.put(newDecl.getName(), newDecl);
    }
}