com.sun.tools.internal.xjc.model.CDefaultValue Java Examples

The following examples show how to use com.sun.tools.internal.xjc.model.CDefaultValue. 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: BindPurple.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #2
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 #3
Source File: BindPurple.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #4
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 #5
Source File: BindPurple.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
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: BindPurple.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #8
Source File: TDTDReader.java    From openjdk-jdk8u-backup 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 #9
Source File: BindPurple.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #10
Source File: TDTDReader.java    From openjdk-jdk9 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 #11
Source File: BindPurple.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #12
Source File: TDTDReader.java    From hottub 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 #13
Source File: BindPurple.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #14
Source File: TDTDReader.java    From openjdk-8-source 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 #15
Source File: BindPurple.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Attribute use always becomes a property.
 */
public void attributeUse(XSAttributeUse use) {
    boolean hasFixedValue = use.getFixedValue()!=null;
    BIProperty pc = BIProperty.getCustomization(use);

    // map to a constant property ?
    boolean toConstant = pc.isConstantProperty() && hasFixedValue;
    TypeUse attType = bindAttDecl(use.getDecl());

    CPropertyInfo prop = pc.createAttributeProperty( use, attType );

    if(toConstant) {
        prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        prop.realization = builder.fieldRendererFactory.getConst(prop.realization);
    } else
    if(!attType.isCollection() && (prop.baseType == null ? true : !prop.baseType.isPrimitive())) {
        // don't support a collection default value. That's difficult to do.
        // primitive types default value is problematic too - we can't check whether it has been set or no ( ==null) isn't possible TODO: emit a waring in these cases

        if(use.getDefaultValue()!=null) {
            // this attribute use has a default value.
            // the item type is guaranteed to be a leaf type... or TODO: is it really so?
            // don't support default values if it's a list
            prop.defaultValue = CDefaultValue.create(attType,use.getDefaultValue());
        } else
        if(use.getFixedValue()!=null) {
            prop.defaultValue = CDefaultValue.create(attType,use.getFixedValue());
        }
    } else if(prop.baseType != null && prop.baseType.isPrimitive()) {
        ErrorReporter errorReporter = Ring.get(ErrorReporter.class);

        errorReporter.warning(prop.getLocator(), Messages.WARN_DEFAULT_VALUE_PRIMITIVE_TYPE, prop.baseType.name());
    }

    getCurrentBean().addProperty(prop);
}
 
Example #16
Source File: TDTDReader.java    From openjdk-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;
}