Java Code Examples for org.apache.cxf.helpers.DOMUtils#getAttributeValueEmptyNull()

The following examples show how to use org.apache.cxf.helpers.DOMUtils#getAttributeValueEmptyNull() . 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: XMLTypeCreator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Type getGenericParameterFromSpec(Element mapping, String componentType) {
    if (componentType.startsWith("#")) {
        String name = componentType.substring(1);
        Element propertyEl = getMatch(mapping, "./component[@name='" + name + "']");
        if (propertyEl == null) {
            throw new DatabindingException("Could not find <component> element in mapping named '" + name
                                           + "'");
        }

        String className = DOMUtils.getAttributeValueEmptyNull(propertyEl, "class");
        if (className == null) {
            throw new DatabindingException("A 'class' attribute must be specified for <component> "
                                           + name);
        }

        return loadComponentClass(className);
    }
    return loadComponentClass(componentType);
}
 
Example 2
Source File: XMLTypeCreator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Type getComponentType(Element mapping, Element parameter) {
    String componentSpec = DOMUtils.getAttributeValueEmptyNull(parameter, "componentType");
    if (componentSpec == null) {
        return null;
    }
    return getGenericParameterFromSpec(mapping, componentSpec);
}
 
Example 3
Source File: XMLTypeCreator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Type getKeyType(Element mapping, Element parameter) {
    String spec = DOMUtils.getAttributeValueEmptyNull(parameter, "keyType");
    if (spec == null) {
        return null;
    }
    return getGenericParameterFromSpec(mapping, spec);
}
 
Example 4
Source File: XMLTypeCreator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Type getValueType(Element mapping, Element parameter) {
    String spec = DOMUtils.getAttributeValueEmptyNull(parameter, "valueType");
    if (spec == null) {
        return null;
    }
    return getGenericParameterFromSpec(mapping, spec);
}
 
Example 5
Source File: XMLTypeCreator.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void setType(TypeClassInfo info, Element parameter) {
    String type = DOMUtils.getAttributeValueEmptyNull(parameter, "type");
    if (type != null) {
        try {
            Class<?> aegisTypeClass = ClassLoaderUtils.loadClass(type, getClass());
            info.setAegisTypeClass(Java5TypeCreator.castToAegisTypeClass(aegisTypeClass));
        } catch (ClassNotFoundException e) {
            throw new DatabindingException("Unable to load type class " + type, e);
        }
    }
}
 
Example 6
Source File: XMLBeanTypeInfo.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean registerType(PropertyDescriptor desc) {
    Element e = getPropertyElement(desc.getName());
    if (e != null && DOMUtils.getAttributeValueEmptyNull(e, "type") != null) {
        return false;
    }

    return super.registerType(desc);
}
 
Example 7
Source File: XMLBeanTypeInfo.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Element getPropertyElement(String name2) {
    for (Element mapping2 : mappings) {
        List<Element> elements = DOMUtils.getChildrenWithName(mapping2, "", "property");
        for (int i = 0; i < elements.size(); i++) {
            Element e = elements.get(i);
            String name = DOMUtils.getAttributeValueEmptyNull(e, "name");

            if (name != null && name.equals(name2)) {
                return e;
            }
        }
    }

    return null;
}
 
Example 8
Source File: XMLTypeCreator.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public AegisType createDefaultType(TypeClassInfo info) {
    Element mapping = findMapping(info.getType());
    List<Element> mappings = findMappings(info.getType());
    Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType());

    if (mapping != null || !mappings.isEmpty()) {
        String typeNameAtt = null;
        if (mapping != null) {
            typeNameAtt = DOMUtils.getAttributeValueEmptyNull(mapping, "name");
        }

        String extensibleElements = null;
        if (mapping != null) {
            extensibleElements = mapping.getAttribute("extensibleElements");
        }

        String extensibleAttributes = null;
        if (mapping != null) {
            extensibleAttributes = mapping.getAttribute("extensibleAttributes");
        }

        String defaultNS = NamespaceHelper.makeNamespaceFromClassName(relatedClass.getName(), "http");
        QName name = null;
        if (typeNameAtt != null) {
            name = NamespaceHelper.createQName(mapping, typeNameAtt, defaultNS);

            defaultNS = name.getNamespaceURI();
        }

        // We do not deal with Generic beans at this point.
        XMLBeanTypeInfo btinfo = new XMLBeanTypeInfo(relatedClass, mappings, defaultNS);
        btinfo.setTypeMapping(getTypeMapping());
        btinfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs());
        btinfo.setDefaultNillable(getConfiguration().isDefaultNillable());

        if (extensibleElements != null) {
            btinfo.setExtensibleElements(Boolean.parseBoolean(extensibleElements));
        } else {
            btinfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements());
        }

        if (extensibleAttributes != null) {
            btinfo.setExtensibleAttributes(Boolean.parseBoolean(extensibleAttributes));
        } else {
            btinfo.setExtensibleAttributes(getConfiguration().isDefaultExtensibleAttributes());
        }

        btinfo.setQualifyAttributes(this.getConfiguration().isQualifyAttributes());
        btinfo.setQualifyElements(this.getConfiguration().isQualifyElements());
        BeanType type = new BeanType(btinfo);

        if (name == null) {
            name = createQName(relatedClass);
        }

        type.setSchemaType(name);

        type.setTypeClass(info.getType());
        type.setTypeMapping(getTypeMapping());

        return type;
    }
    return nextCreator.createDefaultType(info);
}