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

The following examples show how to use com.sun.xml.internal.xsom.XmlString. These examples are extracted from open source projects. 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 Project: TencentKona-8   Source File: TypeUseImpl.java    License: 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 2
Source Project: jdk8u60   Source File: CElementInfo.java    License: 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 3
Source Project: jdk8u60   Source File: TypeUseImpl.java    License: 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
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 5
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 6
Source Project: TencentKona-8   Source File: FacetImpl.java    License: 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 7
Source Project: TencentKona-8   Source File: ElementDecl.java    License: 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 8
Source Project: TencentKona-8   Source File: TDTDReader.java    License: 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 9
Source Project: openjdk-jdk8u   Source File: FacetImpl.java    License: 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 10
Source Project: openjdk-jdk8u   Source File: TDTDReader.java    License: 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 11
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 12
Source Project: TencentKona-8   Source File: CDefaultValue.java    License: 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 13
Source Project: TencentKona-8   Source File: CTypeRef.java    License: 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 14
Source Project: TencentKona-8   Source File: CEnumLeafInfo.java    License: 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 15
Source Project: openjdk-jdk8u   Source File: CDefaultValue.java    License: 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 16
Source Project: openjdk-jdk8u   Source File: CTypeRef.java    License: 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 17
Source Project: jdk8u60   Source File: ElementDecl.java    License: 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 18
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 19
Source Project: jdk8u60   Source File: TDTDReader.java    License: 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 20
Source Project: jdk8u60   Source File: CElementInfo.java    License: 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 21
Source Project: openjdk-jdk8u   Source File: CEnumLeafInfo.java    License: 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 22
Source Project: openjdk-jdk8u   Source File: ElementDecl.java    License: 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 23
Source Project: openjdk-jdk8u   Source File: CElementInfo.java    License: 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 24
Source Project: jdk8u60   Source File: CDefaultValue.java    License: 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 25
Source Project: jdk8u60   Source File: CEnumLeafInfo.java    License: 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 26
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 Project: TencentKona-8   Source File: NGCCRuntimeEx.java    License: 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 28
public JExpression createConstant(Outline outline, XmlString lexical) {
    return JExpr.lit(DatatypeConverter.parseDouble(lexical.value));
}
 
Example 29
public XmlString getDefaultValue() {
    if( defaultValue!=null )    return defaultValue;
    else                        return getDecl().getDefaultValue();
}
 
Example 30
public XmlString getFixedValue() {
    if( fixedValue!=null )      return fixedValue;
    else                        return getDecl().getFixedValue();
}