Search in sources :

Example 6 with BISchemaBinding

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BISchemaBinding in project jaxb-ri by eclipse-ee4j.

the class ClassSelector method getPackage.

/**
 * Gets the Java package to which classes from
 * this namespace should go.
 *
 * <p>
 * Usually, the getOuterClass method should be used
 * to determine where to put a class.
 */
public JPackage getPackage(String targetNamespace) {
    XSSchema s = Ring.get(XSSchemaSet.class).getSchema(targetNamespace);
    BISchemaBinding sb = builder.getBindInfo(s).get(BISchemaBinding.class);
    if (sb != null)
        sb.markAsAcknowledged();
    String name = null;
    // "-p" takes precedence over everything else
    if (builder.defaultPackage1 != null)
        name = builder.defaultPackage1;
    // use the <jaxb:package> customization
    if (name == null && sb != null && sb.getPackageName() != null)
        name = sb.getPackageName();
    // the JAX-RPC option goes below the <jaxb:package>
    if (name == null && builder.defaultPackage2 != null)
        name = builder.defaultPackage2;
    // generate the package name from the targetNamespace
    if (name == null)
        name = builder.getNameConverter().toPackageName(targetNamespace);
    // if it generated into the default java package
    if (name == null)
        // the last resort
        name = "generated";
    // check if the package name is a valid name.
    if (checkedPackageNames.add(name)) {
        // this is the first time we hear about this package name.
        if (!JJavaName.isJavaPackageName(name))
            // TODO: s.getLocator() is not very helpful.
            // ideally, we'd like to use the locator where this package name
            // comes from.
            getErrorReporter().error(s.getLocator(), Messages.ERR_INCORRECT_PACKAGE_NAME, targetNamespace, name);
    }
    return Ring.get(JCodeModel.class)._package(name);
}
Also used : XSSchemaSet(com.sun.xml.xsom.XSSchemaSet) BISchemaBinding(com.sun.tools.xjc.reader.xmlschema.bindinfo.BISchemaBinding) JCodeModel(com.sun.codemodel.JCodeModel) XSSchema(com.sun.xml.xsom.XSSchema)

Aggregations

BISchemaBinding (com.sun.tools.xjc.reader.xmlschema.bindinfo.BISchemaBinding)6 XSSchema (com.sun.xml.xsom.XSSchema)4 JPackage (com.sun.codemodel.JPackage)2 CClassInfo (com.sun.tools.xjc.model.CClassInfo)2 CClassInfoParent (com.sun.tools.xjc.model.CClassInfoParent)2 CElement (com.sun.tools.xjc.model.CElement)2 XSSchemaSet (com.sun.xml.xsom.XSSchemaSet)2 JCodeModel (com.sun.codemodel.JCodeModel)1 JTextFile (com.sun.codemodel.fmt.JTextFile)1 CElementInfo (com.sun.tools.xjc.model.CElementInfo)1 BIClass (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIClass)1 BindInfo (com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)1 XSDeclaration (com.sun.xml.xsom.XSDeclaration)1 XSElementDecl (com.sun.xml.xsom.XSElementDecl)1 XSType (com.sun.xml.xsom.XSType)1 ComponentNameFunction (com.sun.xml.xsom.util.ComponentNameFunction)1 QName (javax.xml.namespace.QName)1 Locator (org.xml.sax.Locator)1