Search in sources :

Example 1 with NameConverter

use of org.glassfish.jaxb.core.api.impl.NameConverter in project jaxb-ri by eclipse-ee4j.

the class BIGlobalBinding method onSetOwner.

@Override
public void onSetOwner() {
    super.onSetOwner();
    // if one is given by options, use that
    NameConverter nc = Ring.get(Model.class).options.getNameConverter();
    if (nc != null)
        nameConverter = nc;
}
Also used : NameConverter(org.glassfish.jaxb.core.api.impl.NameConverter)

Example 2 with NameConverter

use of org.glassfish.jaxb.core.api.impl.NameConverter in project jaxb-ri by eclipse-ee4j.

the class BIProperty method createAttributeProperty.

public CAttributePropertyInfo createAttributeProperty(XSAttributeUse use, TypeUse tu) {
    boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue() != null;
    String name = getPropertyName(forConstant);
    if (name == null) {
        NameConverter conv = getBuilder().getNameConverter();
        if (forConstant)
            name = conv.toConstantName(use.getDecl().getName());
        else
            name = conv.toPropertyName(use.getDecl().getName());
        if (tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode())
            name = JJavaName.getPluralForm(name);
    }
    markAsAcknowledged();
    constantPropertyErrorCheck();
    return wrapUp(new CAttributePropertyInfo(name, use, getCustomizations(use), use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired()), use);
}
Also used : NameConverter(org.glassfish.jaxb.core.api.impl.NameConverter) CAttributePropertyInfo(com.sun.tools.xjc.model.CAttributePropertyInfo)

Example 3 with NameConverter

use of org.glassfish.jaxb.core.api.impl.NameConverter in project jaxb-ri by eclipse-ee4j.

the class BIProperty method getPropertyName.

/**
 * Returns the customized property name.
 *
 * This method honors the "enableJavaNamingConvention" customization
 * and formats the property name accordingly if necessary.
 *
 * Thus the caller should <em>NOT</em> apply the XML-to-Java name
 * conversion algorithm to the value returned from this method.
 *
 * @param forConstant
 *      If the property name is intended for a constant property name,
 *      set to true. This will change the result
 *
 * @return
 *      This method can return null if the customization doesn't
 *      specify the name.
 */
public String getPropertyName(boolean forConstant) {
    if (name != null) {
        BIGlobalBinding gb = getBuilder().getGlobalBinding();
        NameConverter nc = getBuilder().model.getNameConverter();
        if (gb.isJavaNamingConventionEnabled() && !forConstant)
            // apply XML->Java conversion
            return nc.toPropertyName(name);
        else
            // ... or don't change the value
            return name;
    }
    BIProperty next = getDefault();
    if (next != null)
        return next.getPropertyName(forConstant);
    else
        return null;
}
Also used : NameConverter(org.glassfish.jaxb.core.api.impl.NameConverter)

Example 4 with NameConverter

use of org.glassfish.jaxb.core.api.impl.NameConverter in project jaxb-ri by eclipse-ee4j.

the class BIClass method getClassName.

/**
 * Gets the specified class name, or null if not specified.
 * (Not a fully qualified name.)
 *
 * @return
 *      Returns a class name. The caller should <em>NOT</em>
 *      apply XML-to-Java name conversion to the name
 *      returned from this method.
 */
@Nullable
public String getClassName() {
    if (className == null)
        return null;
    BIGlobalBinding gb = getBuilder().getGlobalBinding();
    NameConverter nc = getBuilder().model.getNameConverter();
    if (gb.isJavaNamingConventionEnabled())
        return nc.toClassName(className);
    else
        // don't change it
        return className;
}
Also used : NameConverter(org.glassfish.jaxb.core.api.impl.NameConverter) Nullable(com.sun.istack.Nullable)

Aggregations

NameConverter (org.glassfish.jaxb.core.api.impl.NameConverter)4 Nullable (com.sun.istack.Nullable)1 CAttributePropertyInfo (com.sun.tools.xjc.model.CAttributePropertyInfo)1