Java Code Examples for javax.xml.bind.annotation.XmlAttribute#name()

The following examples show how to use javax.xml.bind.annotation.XmlAttribute#name() . 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: AttributePropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 2
Source File: AttributePropertyInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 3
Source File: AttributePropertyInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 4
Source File: AttributePropertyInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 5
Source File: AttributePropertyInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 6
Source File: AttributePropertyInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 7
Source File: AttributePropertyInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 8
Source File: AttributePropertyInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
Example 9
Source File: DOMFactory.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the attribute name to a field.
 * @param field The field to get the atribute name.
 * @return The attribute name of this field.
 */
private String getAttributeName(final Field field) {
    String attributeName;
    XmlAttribute xmlAttribute = field.getAnnotation(XmlAttribute.class);
    if (xmlAttribute != null) {
        attributeName = xmlAttribute.name();
    }
    else {
        attributeName = javaNameToXMLName(field.getName());
    }
    return attributeName;
}
 
Example 10
Source File: XPathUtil.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static
public String formatElementOrAttribute(Class<? extends PMMLObject> elementClazz, Field field){
	XmlElement element = field.getAnnotation(XmlElement.class);
	XmlAttribute attribute = field.getAnnotation(XmlAttribute.class);

	if(element != null){
		Class<?> childElementClazz = field.getType();

		if((List.class).isAssignableFrom(childElementClazz)){
			ParameterizedType listType = (ParameterizedType)field.getGenericType();

			Type[] typeArguments = listType.getActualTypeArguments();
			if(typeArguments.length != 1){
				throw new IllegalArgumentException();
			}

			childElementClazz = (Class<?>)typeArguments[0];
		}

		try {
			return getElementName(elementClazz) + "/" + getElementName(childElementClazz);
		} catch(IllegalArgumentException iae){
			return getElementName(elementClazz) + "/" + element.name();
		}
	} else

	if(attribute != null){
		return getElementName(elementClazz) + "@" + attribute.name();
	}

	throw new IllegalArgumentException();
}
 
Example 11
Source File: MainFindOccurrances.java    From ph-ubl with Apache License 2.0 5 votes vote down vote up
/**
 * Create an XML name from the passed field. It uses the {@link XmlElement},
 * {@link XmlAttribute} and {@link XmlValue} annotations to differentiate.
 *
 * @param aField
 *        Source field
 * @return Never <code>null</code>.
 */
@Nonnull
public static String _getXMLName (@Nonnull final Field aField)
{
  final XmlElement aElement = aField.getAnnotation (XmlElement.class);
  if (aElement != null)
    return "/" + aElement.name ();
  final XmlAttribute aAttr = aField.getAnnotation (XmlAttribute.class);
  if (aAttr != null)
    return "/@" + aAttr.name ();
  if (aField.getAnnotation (XmlValue.class) != null)
    return "/value()";
  throw new IllegalStateException ("Field is neither XML element nor attribute nor value: " + aField);
}