Java XML Element Check isXmlElementChoice(Field f, String xmlElementName)

Here you can find the source of isXmlElementChoice(Field f, String xmlElementName)

Description

Checks whether xmlElementName is applicable for the filed

License

Open Source License

Parameter

Parameter Description
Field f
String xmlElementName

Return

boolean indicating

Declaration

public static boolean isXmlElementChoice(Field f, String xmlElementName) 

Method Source Code

//package com.java2s;
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

import java.lang.reflect.Field;

import javax.xml.bind.annotation.XmlElement;

import javax.xml.bind.annotation.XmlElements;

public class Main {
    /** Checks whether xmlElementName is applicable for the filed
     * //from w w  w  . j  a va 2 s.c o m
     * @param Field f
     * @param String xmlElementName
     * 
     * @return boolean indicating 
     * 
     * */
    public static boolean isXmlElementChoice(Field f, String xmlElementName) {
        boolean ret = false;

        if (null != f && null != xmlElementName) {
            XmlElements xmlElements = getXmlElements(f);
            if (null != xmlElements && null != xmlElements.value()) {
                for (XmlElement xmlElement : xmlElements.value()) {
                    if (xmlElementName.equals(xmlElement.name())) {
                        ret = true;
                        break;
                    }
                }
            }
        }

        return ret;
    }

    public static XmlElements getXmlElements(Field f) {
        XmlElements ret = null;

        if (null != f) {
            ret = (XmlElements) f.getAnnotation(XmlElements.class);
        }

        return ret;
    }
}

Related

  1. isTableNodes(Element e)
  2. isTextOnly(final Element element)
  3. isTrue(Element el, String tagName, boolean defaultResult)
  4. isUIParameter(Element ele)
  5. isUnder5_6(Element root)
  6. isXmlElementRequired(Field f)
  7. isXULElement(Element elem)