Top Description Inners Fields Constructors Methods
javax.xml.bind

public Class JAXBElement<T>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
javax.xml.namespace.QName, java.io.Serializable

JAXB representation of an Xml Element.

This class represents information about an Xml Element from both the element declaration within a schema and the element instance value within an xml document with the following properties

The declaredType and scope property are the JAXB class binding for the xml type definition.

Scope is either GlobalScope or the Java class representing the complex type definition containing the schema element declaration.

There is a property constraint that if value is null, then nil must be true. The converse is not true to enable representing a nil element with attribute(s). If nil is true, it is possible that value is non-null so it can hold the value of the attributes associated with a nil element.

Author
Kohsuke Kawaguchi, Joe Fialli
Since
1.6, JAXB 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JAXBElement.GlobalScope

Designates global scope for an xml element.

Field Summary

Modifier and TypeField and Description
protected final Class<T>
declaredType

Java datatype binding for xml element declaration's type.

protected final QName
name

xml element tag name

protected boolean
nil

true iff the xml element instance has xsi:nil="true".

protected final Class<T>
scope

Scope of xml element declaration representing this xml element instance.

private static final long
protected T
value

xml element value.

Constructor Summary

AccessConstructor and Description
public
JAXBElement(QName
Java binding of xml element tag name
name
,
Class<T>
Java binding of xml element declaration's type
declaredType
,
Class<T>
Java binding of scope of xml element declaration. Passing null is the same as passing GlobalScope.class
scope
,
T
Java instance representing xml element's value.
value
)

Construct an xml element instance.

public
JAXBElement(QName name, Class<T> declaredType, T value)

Construct an xml element instance.

Method Summary

Modifier and TypeMethod and Description
public Class<T>
getDeclaredType()

Returns the Java binding of the xml element declaration's type attribute.

public QName
getName()

Returns the xml element tag name.

public Class<T>

Returns:

GlobalScope.class if this element is of global scope.
getScope
()

Returns scope of xml element declaration.

public T
getValue()

Return the content model and attribute values for this element.

public boolean
isGlobalScope()

Returns true iff this xml element declaration is global.

public boolean
isNil()

Returns true iff this element instance content model is nil.

public boolean
isTypeSubstituted()

Returns true iff this xml element instance's value has a different type than xml element declaration's declared type.

public void
setNil(boolean value)

Set whether this element has nil content.

public void
setValue(T t)

Set the content model and attributes of this xml element.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

declaredTypeback to summary
protected final Class<T> declaredType

Java datatype binding for xml element declaration's type.

nameback to summary
protected final QName name

xml element tag name

nilback to summary
protected boolean nil

true iff the xml element instance has xsi:nil="true".

scopeback to summary
protected final Class<T> scope

Scope of xml element declaration representing this xml element instance. Can be one of the following values: - GlobalScope for global xml element declaration. - local element declaration has a scope set to the Java class representation of complex type defintion containing xml element declaration.

serialVersionUIDback to summary
private static final long serialVersionUID
valueback to summary
protected T value

xml element value. Represents content model and attributes of an xml element instance.

Constructor Detail

JAXBElementback to summary
public JAXBElement(QName name, Class<T> declaredType, Class<T> scope, T value)

Construct an xml element instance.

Parameters
name:QName

Java binding of xml element tag name

declaredType:Class<T>

Java binding of xml element declaration's type

scope:Class<T>

Java binding of scope of xml element declaration. Passing null is the same as passing GlobalScope.class

value:T

Java instance representing xml element's value.

See Also
getScope(), isTypeSubstituted()
JAXBElementback to summary
public JAXBElement(QName name, Class<T> declaredType, T value)

Construct an xml element instance. This is just a convenience method for new JAXBElement(name,declaredType,GlobalScope.class,value)

Method Detail

getDeclaredTypeback to summary
public Class<T> getDeclaredType()

Returns the Java binding of the xml element declaration's type attribute.

getNameback to summary
public QName getName()

Returns the xml element tag name.

getScopeback to summary
public Class<T> getScope()

Returns scope of xml element declaration.

Returns:Class<T>

GlobalScope.class if this element is of global scope.

See Also
isGlobalScope()
getValueback to summary
public T getValue()

Return the content model and attribute values for this element.

See isNil() for a description of a property constraint when this value is null

isGlobalScopeback to summary
public boolean isGlobalScope()

Returns true iff this xml element declaration is global.

isNilback to summary
public boolean isNil()

Returns true iff this element instance content model is nil.

This property always returns true when getValue() is null. Note that the converse is not true, when this property is true, getValue() can contain a non-null value for attribute(s). It is valid for a nil xml element to have attribute(s).

isTypeSubstitutedback to summary
public boolean isTypeSubstituted()

Returns true iff this xml element instance's value has a different type than xml element declaration's declared type.

setNilback to summary
public void setNil(boolean value)

Set whether this element has nil content.

See Also
isNil()
setValueback to summary
public void setValue(T t)

Set the content model and attributes of this xml element.

When this property is set to null, isNil() must by true. Details of constraint are described at isNil().

See Also
isTypeSubstituted()
javax.xml.bind back to summary

public final Class JAXBElement.GlobalScope

extends Object
Class Inheritance

Designates global scope for an xml element.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GlobalScopeback to summary
public GlobalScope()