Java XML Element Get getElementName(Object obj)

Here you can find the source of getElementName(Object obj)

Description

Returns the element name of the spedified object.

License

MIT License

Parameter

Parameter Description
obj the object

Return

XmlType.name()

Declaration

private static String getElementName(Object obj) 

Method Source Code

//package com.java2s;
/*/*from  w w w .  j  a  v a  2  s.c o m*/
 * Copyright (c) 2014 eSOL Co.,Ltd. and Nagoya University
 *
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */

import javax.xml.bind.annotation.XmlType;

public class Main {
    /**
     * Returns the element name of the spedified object.
     * 
     * @param obj
     *            the object
     * @return XmlType.name()
     */
    private static String getElementName(Object obj) {
        XmlType xmlType = obj.getClass().getAnnotation(XmlType.class);
        if (xmlType != null && xmlType.name() != null) {
            return xmlType.name();
        }
        return null;
    }
}

Related

  1. getElementName(Class clazz)
  2. getElementName(Element element)
  3. getElementName(Element element)
  4. getElementName(Element element)
  5. getElementName(Field field)
  6. getElementNameSansNamespace(Element element)
  7. getElementNamespaces(Element element, Set namespaces)
  8. getElementNamespaceURI(Element element)
  9. getElementNS(Element el, String nsuri, String name)