57 *
58 * @see #getElementName(Object)
59 */
60 public abstract boolean isElement(Object object);
61
62 /**
63 * <p>Get xml element qname for <code>jaxbElement</code>.</p>
64 *
65 * @param jaxbElement is an object that {@link #isElement(Object)} returned true.
66 *
67 * @return xml element qname associated with jaxbElement;
68 * null if <code>jaxbElement</code> is not a JAXB Element.
69 */
70 public abstract QName getElementName(Object jaxbElement);
71
72 /**
73 * <p>Get the element value of a JAXB element.</p>
74 *
75 * <p>Convenience method to abstract whether working with either
76 * a javax.xml.bind.JAXBElement instance or an instance of
77 * <tt>@XmlRootElement</tt> annotated Java class.</p>
78 *
79 * @param jaxbElement object that #isElement(Object) returns true.
80 *
81 * @return The element value of the <code>jaxbElement</code>.
82 */
83 public static Object getValue(Object jaxbElement) {
84 if (jaxbElement instanceof JAXBElement) {
85 return ((JAXBElement)jaxbElement).getValue();
86 } else {
87 // assume that class of this instance is
88 // annotated with @XmlRootElement.
89 return jaxbElement;
90 }
91 }
92 }
|
57 *
58 * @see #getElementName(Object)
59 */
60 public abstract boolean isElement(Object object);
61
62 /**
63 * <p>Get xml element qname for <code>jaxbElement</code>.</p>
64 *
65 * @param jaxbElement is an object that {@link #isElement(Object)} returned true.
66 *
67 * @return xml element qname associated with jaxbElement;
68 * null if <code>jaxbElement</code> is not a JAXB Element.
69 */
70 public abstract QName getElementName(Object jaxbElement);
71
72 /**
73 * <p>Get the element value of a JAXB element.</p>
74 *
75 * <p>Convenience method to abstract whether working with either
76 * a javax.xml.bind.JAXBElement instance or an instance of
77 * {@code @XmlRootElement} annotated Java class.</p>
78 *
79 * @param jaxbElement object that #isElement(Object) returns true.
80 *
81 * @return The element value of the <code>jaxbElement</code>.
82 */
83 public static Object getValue(Object jaxbElement) {
84 if (jaxbElement instanceof JAXBElement) {
85 return ((JAXBElement)jaxbElement).getValue();
86 } else {
87 // assume that class of this instance is
88 // annotated with @XmlRootElement.
89 return jaxbElement;
90 }
91 }
92 }
|