Search in sources :

Example 1 with BIDeclaration

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

the class UnusedCustomizationChecker method check.

private void check(BIDeclaration decl, XSComponent c) {
    if (!decl.isAcknowledged()) {
        getErrorReporter().error(decl.getLocation(), Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION, decl.getName().getLocalPart());
        getErrorReporter().error(c.getLocator(), Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION_LOCATION);
        // mark it as acknowledged to avoid
        // duplicated error messages.
        decl.markAsAcknowledged();
    }
    for (BIDeclaration d : decl.getChildren()) check(d, c);
}
Also used : BIDeclaration(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration)

Example 2 with BIDeclaration

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration in project midpoint by Evolveum.

the class SchemaProcessor method getFieldReferenceUseAnnotationQName.

// e.g. c:link (as opposed to c:linkRef)
private QName getFieldReferenceUseAnnotationQName(JFieldVar field, ClassOutline classOutline) {
    BIDeclaration declaration = hasAnnotation(classOutline, field, A_OBJECT_REFERENCE);
    if (!(declaration instanceof BIXPluginCustomization)) {
        return null;
    }
    BIXPluginCustomization customization = (BIXPluginCustomization) declaration;
    if (customization.element == null) {
        return null;
    }
    Element element = customization.element;
    String strQName = element.getTextContent();
    String[] array = strQName.split(":");
    if (array.length == 2) {
        return new QName(PrefixMapper.C.getNamespace(), array[1]);
    } else if (array.length == 1) {
        return new QName(PrefixMapper.C.getNamespace(), array[0]);
    }
    return null;
}
Also used : BIDeclaration(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) BIXPluginCustomization(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIXPluginCustomization)

Example 3 with BIDeclaration

use of com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration in project midpoint by Evolveum.

the class ProcessorUtils method hasAnnotation.

private static BIDeclaration hasAnnotation(XSAnnotation annotation, QName qname) {
    if (annotation == null) {
        return null;
    }
    Object object = annotation.getAnnotation();
    if (!(object instanceof BindInfo)) {
        return null;
    }
    BindInfo info = (BindInfo) object;
    BIDeclaration[] declarations = info.getDecls();
    if (declarations == null) {
        return null;
    }
    for (BIDeclaration declaration : declarations) {
        if (qname.equals(declaration.getName())) {
            return declaration;
        }
    }
    return null;
}
Also used : BIDeclaration(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration) BindInfo(com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)

Example 4 with BIDeclaration

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

the class BGMBuilder method checkMultipleSchemaBindings.

/**
 * Reports an error if there are more than one jaxb:schemaBindings customization.
 */
private void checkMultipleSchemaBindings(XSSchema schema) {
    ArrayList<Locator> locations = new ArrayList<>();
    BindInfo bi = getBindInfo(schema);
    for (BIDeclaration bid : bi) {
        if (bid.getName() == BISchemaBinding.NAME)
            locations.add(bid.getLocation());
    }
    // OK
    if (locations.size() <= 1)
        return;
    // error
    getErrorReporter().error(locations.get(0), Messages.ERR_MULTIPLE_SCHEMA_BINDINGS, schema.getTargetNamespace());
    for (int i = 1; i < locations.size(); i++) getErrorReporter().error(locations.get(i), Messages.ERR_MULTIPLE_SCHEMA_BINDINGS_LOCATION);
}
Also used : Locator(org.xml.sax.Locator) BIDeclaration(com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration) ArrayList(java.util.ArrayList) BindInfo(com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)

Aggregations

BIDeclaration (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIDeclaration)4 BindInfo (com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo)2 BIXPluginCustomization (com.sun.tools.xjc.reader.xmlschema.bindinfo.BIXPluginCustomization)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 Element (org.w3c.dom.Element)1 Locator (org.xml.sax.Locator)1