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

The following examples show how to use com.sun.xml.internal.xsom.XmlString. 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: CElementInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void initContentType(TypeUse contentType, @Nullable XSElementDecl source, XmlString defaultValue) {
    assert this.property==null; // must not be called twice

    this.property = new CElementPropertyInfo("Value",
            contentType.isCollection()?REPEATED_VALUE:NOT_REPEATED,
            contentType.idUse(),
            contentType.getExpectedMimeType(),
            source,null,getLocator(),true);
    this.property.setAdapter(contentType.getAdapterUse());
    BIInlineBinaryData.handle(source,property);
    property.getTypes().add(new CTypeRef(contentType.getInfo(),tagName,CTypeRef.getSimpleTypeName(source), true,defaultValue));
    this.type = NavigatorImpl.createParameterizedType(
        NavigatorImpl.theInstance.ref(JAXBElement.class),
        getContentInMemoryType() );

    BIFactoryMethod factoryMethod = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIFactoryMethod.class);
    if(factoryMethod!=null) {
        factoryMethod.markAsAcknowledged();
        this.squeezedName = factoryMethod.name;
    }

}
 
Example #2
Source File: TypeUseImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
    if(isCollection())  return null;

    if(adapter==null)     return coreType.createConstant(outline, lexical);

    // [RESULT] new Adapter().unmarshal(CONSTANT);
    JExpression cons = coreType.createConstant(outline, lexical);
    Class<? extends XmlAdapter> atype = adapter.getAdapterIfKnown();

    // try to run the adapter now rather than later.
    if(cons instanceof JStringLiteral && atype!=null) {
        JStringLiteral scons = (JStringLiteral) cons;
        XmlAdapter a = ClassFactory.create(atype);
        try {
            Object value = a.unmarshal(scons.str);
            if(value instanceof String) {
                return JExpr.lit((String)value);
            }
        } catch (Exception e) {
            // assume that we can't eagerly bind this
        }
    }

    return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal").arg(cons);
}
 
Example #3
Source File: TypeUseImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
    if(isCollection())  return null;

    if(adapter==null)     return coreType.createConstant(outline, lexical);

    // [RESULT] new Adapter().unmarshal(CONSTANT);
    JExpression cons = coreType.createConstant(outline, lexical);
    Class<? extends XmlAdapter> atype = adapter.getAdapterIfKnown();

    // try to run the adapter now rather than later.
    if(cons instanceof JStringLiteral && atype!=null) {
        JStringLiteral scons = (JStringLiteral) cons;
        XmlAdapter a = ClassFactory.create(atype);
        try {
            Object value = a.unmarshal(scons.str);
            if(value instanceof String) {
                return JExpr.lit((String)value);
            }
        } catch (Exception e) {
            // assume that we can't eagerly bind this
        }
    }

    return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal").arg(cons);
}
 
Example #4
Source File: CTypeRef.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public CTypeRef(CNonElement type, QName elementName, QName typeName, boolean nillable, XmlString defaultValue) {
    assert type!=null;
    assert elementName!=null;

    this.type = type;
    this.elementName = elementName;
    this.typeName = typeName;
    this.nillable = nillable;
    this.defaultValue = defaultValue;
}
 
Example #5
Source File: FacetImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public FacetImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
    String _name, XmlString _value, boolean _fixed ) {

    super(owner,_annon,_loc,_fa);

    this.name = _name;
    this.value = _value;
    this.fixed = _fixed;
}
 
Example #6
Source File: TDTDReader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected CPropertyInfo createAttribute(
    String elementName, String attributeName, String attributeType,
    String[] enums, short attributeUse, String defaultValue )
        throws SAXException {

    boolean required = attributeUse==USE_REQUIRED;

    // get the attribute-property declaration
    BIElement edecl = bindInfo.element(elementName);
    BIAttribute decl=null;
    if(edecl!=null)     decl=edecl.attribute(attributeName);

    String propName;
    if(decl==null)  propName = model.getNameConverter().toPropertyName(attributeName);
    else            propName = decl.getPropertyName();

    QName qname = new QName("",attributeName);

    // if no declaration is specified, just wrap it by
    // a FieldItem and let the normalizer handle its content.
    TypeUse use;

    if(decl!=null && decl.getConversion()!=null)
        use = decl.getConversion().getTransducer();
    else
        use = builtinConversions.get(attributeType);

    CPropertyInfo r = new CAttributePropertyInfo(
        propName, null,null/*TODO*/, copyLocator(), qname, use, null, required );

    if(defaultValue!=null)
        r.defaultValue = CDefaultValue.create( use, new XmlString(defaultValue) );

    return r;
}
 
Example #7
Source File: TDTDReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected CPropertyInfo createAttribute(
    String elementName, String attributeName, String attributeType,
    String[] enums, short attributeUse, String defaultValue )
        throws SAXException {

    boolean required = attributeUse==USE_REQUIRED;

    // get the attribute-property declaration
    BIElement edecl = bindInfo.element(elementName);
    BIAttribute decl=null;
    if(edecl!=null)     decl=edecl.attribute(attributeName);

    String propName;
    if(decl==null)  propName = model.getNameConverter().toPropertyName(attributeName);
    else            propName = decl.getPropertyName();

    QName qname = new QName("",attributeName);

    // if no declaration is specified, just wrap it by
    // a FieldItem and let the normalizer handle its content.
    TypeUse use;

    if(decl!=null && decl.getConversion()!=null)
        use = decl.getConversion().getTransducer();
    else
        use = builtinConversions.get(attributeType);

    CPropertyInfo r = new CAttributePropertyInfo(
        propName, null,null/*TODO*/, copyLocator(), qname, use, null, required );

    if(defaultValue!=null)
        r.defaultValue = CDefaultValue.create( use, new XmlString(defaultValue) );

    return r;
}
 
Example #8
Source File: AttributeUseImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public AttributeUseImpl( SchemaDocumentImpl owner, AnnotationImpl ann, Locator loc, ForeignAttributesImpl fa, Ref.Attribute _decl,
    XmlString def, XmlString fixed, boolean req ) {

    super(owner,ann,loc,fa);

    this.att = _decl;
    this.defaultValue = def;
    this.fixedValue = fixed;
    this.required = req;
}
 
Example #9
Source File: ElementDecl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ElementDecl( PatcherManager reader, SchemaDocumentImpl owner,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa,
    String _tns, String _name, boolean _anonymous,

    XmlString _defv, XmlString _fixedv,
    boolean _nillable, boolean _abstract, Boolean _form,
    Ref.Type _type, Ref.Element _substHead,
    int _substDisallowed, int _substExcluded,
    List<IdentityConstraintImpl> idConstraints) {

    super(owner,_annon,_loc,fa,_tns,_name,_anonymous);

    this.defaultValue = _defv;
    this.fixedValue = _fixedv;
    this.nillable = _nillable;
    this._abstract = _abstract;
    this.form = _form;
    this.type = _type;
    this.substHead = _substHead;
    this.substDisallowed = _substDisallowed;
    this.substExcluded = _substExcluded;
    this.idConstraints = Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints);

    for (IdentityConstraintImpl idc : idConstraints)
        idc.setParent(this);

    if(type==null)
        throw new IllegalArgumentException();
}
 
Example #10
Source File: CEnumLeafInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString literal) {
    // correctly identifying which constant it maps to is hard, so
    // here I'm cheating
    JClass type = toType(outline,Aspect.EXPOSED);
    for (CEnumConstant mem : members) {
        if(mem.getLexicalValue().equals(literal.value))
            return type.staticRef(mem.getName());
    }
    return null;
}
 
Example #11
Source File: FacetImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public FacetImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
    String _name, XmlString _value, boolean _fixed ) {

    super(owner,_annon,_loc,_fa);

    this.name = _name;
    this.value = _value;
    this.fixed = _fixed;
}
 
Example #12
Source File: AttributeDeclImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public AttributeDeclImpl( SchemaDocumentImpl owner,
    String _targetNamespace, String _name,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, boolean _anonymous,
    XmlString _defValue, XmlString _fixedValue,
    Ref.SimpleType _type ) {

    super(owner,_annon,_loc,_fa,_targetNamespace,_name,_anonymous);

    if(_name==null) // assertion failed.
        throw new IllegalArgumentException();

    this.defaultValue = _defValue;
    this.fixedValue = _fixedValue;
    this.type = _type;
}
 
Example #13
Source File: CDefaultValue.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new {@link CDefaultValue} that computes the default value
 * by applying a lexical representation to a {@link TypeUse}.
 */
public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) {
    return new CDefaultValue() {
        public JExpression compute(Outline outline) {
            return typeUse.createConstant(outline,defaultValue);
        }
    };
}
 
Example #14
Source File: CElementInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an element in the given parent.
 *
 * <p>
 * When using this construction, {@link #initContentType(TypeUse, XSElementDecl, XmlString)}
 * must not be invoked.
 */
public CElementInfo(Model model,QName tagName, CClassInfoParent parent, TypeUse contentType, XmlString defaultValue, XSElementDecl source, CCustomizations customizations, Locator location ) {
    super(model,source,location,customizations);
    this.tagName = tagName;
    this.model = model;
    this.parent = parent;
    if(contentType!=null)
        initContentType(contentType, source, defaultValue);

    model.add(this);
}
 
Example #15
Source File: ElementDecl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public ElementDecl( PatcherManager reader, SchemaDocumentImpl owner,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa,
    String _tns, String _name, boolean _anonymous,

    XmlString _defv, XmlString _fixedv,
    boolean _nillable, boolean _abstract, Boolean _form,
    Ref.Type _type, Ref.Element _substHead,
    int _substDisallowed, int _substExcluded,
    List<IdentityConstraintImpl> idConstraints) {

    super(owner,_annon,_loc,fa,_tns,_name,_anonymous);

    this.defaultValue = _defv;
    this.fixedValue = _fixedv;
    this.nillable = _nillable;
    this._abstract = _abstract;
    this.form = _form;
    this.type = _type;
    this.substHead = _substHead;
    this.substDisallowed = _substDisallowed;
    this.substExcluded = _substExcluded;
    this.idConstraints = Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints);

    for (IdentityConstraintImpl idc : idConstraints)
        idc.setParent(this);

    if(type==null)
        throw new IllegalArgumentException();
}
 
Example #16
Source File: CEnumLeafInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString literal) {
    // correctly identifying which constant it maps to is hard, so
    // here I'm cheating
    JClass type = toType(outline,Aspect.EXPOSED);
    for (CEnumConstant mem : members) {
        if(mem.getLexicalValue().equals(literal.value))
            return type.staticRef(mem.getName());
    }
    return null;
}
 
Example #17
Source File: CBuiltinLeafInfo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
    QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical));
    return JExpr._new(outline.getCodeModel().ref(QName.class))
        .arg(qn.getNamespaceURI())
        .arg(qn.getLocalPart())
        .arg(qn.getPrefix());
}
 
Example #18
Source File: CDefaultValue.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new {@link CDefaultValue} that computes the default value
 * by applying a lexical representation to a {@link TypeUse}.
 */
public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) {
    return new CDefaultValue() {
        public JExpression compute(Outline outline) {
            return typeUse.createConstant(outline,defaultValue);
        }
    };
}
 
Example #19
Source File: CTypeRef.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public CTypeRef(CNonElement type, QName elementName, QName typeName, boolean nillable, XmlString defaultValue) {
    assert type!=null;
    assert elementName!=null;

    this.type = type;
    this.elementName = elementName;
    this.typeName = typeName;
    this.nillable = nillable;
    this.defaultValue = defaultValue;
}
 
Example #20
Source File: CEnumLeafInfo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString literal) {
    // correctly identifying which constant it maps to is hard, so
    // here I'm cheating
    JClass type = toType(outline,Aspect.EXPOSED);
    for (CEnumConstant mem : members) {
        if(mem.getLexicalValue().equals(literal.value))
            return type.staticRef(mem.getName());
    }
    return null;
}
 
Example #21
Source File: CDefaultValue.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new {@link CDefaultValue} that computes the default value
 * by applying a lexical representation to a {@link TypeUse}.
 */
public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) {
    return new CDefaultValue() {
        public JExpression compute(Outline outline) {
            return typeUse.createConstant(outline,defaultValue);
        }
    };
}
 
Example #22
Source File: CElementInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an element in the given parent.
 *
 * <p>
 * When using this construction, {@link #initContentType(TypeUse, XSElementDecl, XmlString)}
 * must not be invoked.
 */
public CElementInfo(Model model,QName tagName, CClassInfoParent parent, TypeUse contentType, XmlString defaultValue, XSElementDecl source, CCustomizations customizations, Locator location ) {
    super(model,source,location,customizations);
    this.tagName = tagName;
    this.model = model;
    this.parent = parent;
    if(contentType!=null)
        initContentType(contentType, source, defaultValue);

    model.add(this);
}
 
Example #23
Source File: TDTDReader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected CPropertyInfo createAttribute(
    String elementName, String attributeName, String attributeType,
    String[] enums, short attributeUse, String defaultValue )
        throws SAXException {

    boolean required = attributeUse==USE_REQUIRED;

    // get the attribute-property declaration
    BIElement edecl = bindInfo.element(elementName);
    BIAttribute decl=null;
    if(edecl!=null)     decl=edecl.attribute(attributeName);

    String propName;
    if(decl==null)  propName = model.getNameConverter().toPropertyName(attributeName);
    else            propName = decl.getPropertyName();

    QName qname = new QName("",attributeName);

    // if no declaration is specified, just wrap it by
    // a FieldItem and let the normalizer handle its content.
    TypeUse use;

    if(decl!=null && decl.getConversion()!=null)
        use = decl.getConversion().getTransducer();
    else
        use = builtinConversions.get(attributeType);

    CPropertyInfo r = new CAttributePropertyInfo(
        propName, null,null/*TODO*/, copyLocator(), qname, use, null, required );

    if(defaultValue!=null)
        r.defaultValue = CDefaultValue.create( use, new XmlString(defaultValue) );

    return r;
}
 
Example #24
Source File: AttributeUseImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public AttributeUseImpl( SchemaDocumentImpl owner, AnnotationImpl ann, Locator loc, ForeignAttributesImpl fa, Ref.Attribute _decl,
    XmlString def, XmlString fixed, boolean req ) {

    super(owner,ann,loc,fa);

    this.att = _decl;
    this.defaultValue = def;
    this.fixedValue = fixed;
    this.required = req;
}
 
Example #25
Source File: ElementDecl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ElementDecl( PatcherManager reader, SchemaDocumentImpl owner,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa,
    String _tns, String _name, boolean _anonymous,

    XmlString _defv, XmlString _fixedv,
    boolean _nillable, boolean _abstract, Boolean _form,
    Ref.Type _type, Ref.Element _substHead,
    int _substDisallowed, int _substExcluded,
    List<IdentityConstraintImpl> idConstraints) {

    super(owner,_annon,_loc,fa,_tns,_name,_anonymous);

    this.defaultValue = _defv;
    this.fixedValue = _fixedv;
    this.nillable = _nillable;
    this._abstract = _abstract;
    this.form = _form;
    this.type = _type;
    this.substHead = _substHead;
    this.substDisallowed = _substDisallowed;
    this.substExcluded = _substExcluded;
    this.idConstraints = Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints);

    for (IdentityConstraintImpl idc : idConstraints)
        idc.setParent(this);

    if(type==null)
        throw new IllegalArgumentException();
}
 
Example #26
Source File: AttributeDeclImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public AttributeDeclImpl( SchemaDocumentImpl owner,
    String _targetNamespace, String _name,
    AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, boolean _anonymous,
    XmlString _defValue, XmlString _fixedValue,
    Ref.SimpleType _type ) {

    super(owner,_annon,_loc,_fa,_targetNamespace,_name,_anonymous);

    if(_name==null) // assertion failed.
        throw new IllegalArgumentException();

    this.defaultValue = _defValue;
    this.fixedValue = _fixedValue;
    this.type = _type;
}
 
Example #27
Source File: XPathImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public XmlString getXPath() {
    return xpath;
}
 
Example #28
Source File: NGCCRuntimeEx.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public XmlString createXmlString(String value) {
    if(value==null)     return null;
    else    return new XmlString(value,createValidationContext());
}
 
Example #29
Source File: NamespaceContextAdapter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public NamespaceContextAdapter(XmlString xstr) {
    this.xstr = xstr;
}
 
Example #30
Source File: CBuiltinLeafInfo.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
    return null;
}