public abstract class Context<ABSTRACT_SESSION extends CoreAbstractSession,DESCRIPTOR extends Descriptor<?,?,?,?,?,NAMESPACE_RESOLVER,?,?,?,?>,FIELD extends Field,NAMESPACE_RESOLVER extends NamespaceResolver,PROJECT extends CoreProject,SESSION extends CoreSession,SESSION_EVENT_LISTENER extends CoreSessionEventListener>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Context.ContextState<ABSTRACT_SESSION extends CoreAbstractSession,DESCRIPTOR extends Descriptor,PROJECT extends CoreProject,SESSION extends CoreSession,SESSION_EVENT_LISTENER extends CoreSessionEventListener> |
Constructor and Description |
---|
Context() |
Modifier and Type | Method and Description |
---|---|
<T> T |
createByXPath(java.lang.Object parentObject,
java.lang.String xPath,
NAMESPACE_RESOLVER namespaceResolver,
java.lang.Class<T> returnType)
Create a new object instance for a given XPath, relative to the parentObject.
|
abstract Marshaller |
createMarshaller() |
abstract Unmarshaller |
createUnmarshaller() |
DESCRIPTOR |
getDescriptor(javax.xml.namespace.QName qName)
INTERNAL:
Return the Descriptor with the default root mapping matching the QName
parameter.
|
DESCRIPTOR |
getDescriptor(XPathQName xpathQName)
INTERNAL:
Return the Descriptor with the default root mapping matching the
XPathQName parameter.
|
DESCRIPTOR |
getDescriptorByGlobalType(XPathFragment xPathFragment)
INTERNAL:
Return the Descriptor mapped to the global type matching the
XPathFragment parameter.
|
SESSION |
getSession()
INTERNAL:
|
ABSTRACT_SESSION |
getSession(java.lang.Class clazz)
INTERNAL:
Return the session corresponding to this class.
|
ABSTRACT_SESSION |
getSession(DESCRIPTOR descriptor) |
ABSTRACT_SESSION |
getSession(java.lang.Object object)
INTERNAL:
Return the session corresponding to this object.
|
<T> T |
getValueByXPath(java.lang.Object object,
java.lang.String xPath,
NAMESPACE_RESOLVER namespaceResolver,
java.lang.Class<T> returnType)
Query the object model based on the corresponding document.
|
abstract boolean |
hasDocumentPreservation()
INTERNAL:
Return true if any session held onto by this context has a document preservation
policy that requires unmarshalling from a Node.
|
void |
setValueByXPath(java.lang.Object object,
java.lang.String xPath,
NAMESPACE_RESOLVER namespaceResolver,
java.lang.Object value)
Set values in the object model based on the corresponding document.
|
public <T> T createByXPath(java.lang.Object parentObject, java.lang.String xPath, NAMESPACE_RESOLVER namespaceResolver, java.lang.Class<T> returnType)
T
- The return type of this method corresponds to the returnType parameter.parentObject
- The XPath will be executed relative to this object.xPath
- The XPath statement.namespaceResolver
- A NamespaceResolver containing the prefix/URI pairings from the XPath statement.returnType
- The return type.public abstract Marshaller createMarshaller()
public abstract Unmarshaller createUnmarshaller()
public DESCRIPTOR getDescriptor(javax.xml.namespace.QName qName)
public DESCRIPTOR getDescriptor(XPathQName xpathQName)
public DESCRIPTOR getDescriptorByGlobalType(XPathFragment xPathFragment)
public ABSTRACT_SESSION getSession(java.lang.Class clazz)
public SESSION getSession()
public ABSTRACT_SESSION getSession(DESCRIPTOR descriptor)
public ABSTRACT_SESSION getSession(java.lang.Object object)
public <T> T getValueByXPath(java.lang.Object object, java.lang.String xPath, NAMESPACE_RESOLVER namespaceResolver, java.lang.Class<T> returnType)
Query the object model based on the corresponding document. The following pairings are equivalent:
Return the Customer's IDInteger id = context.getValueByXPath(customer, "@id", null, Integer.class); Integer id = customer.getId();Return the Customer's Name
String name = context.getValueByXPath(customer, "ns:personal-info/ns:name/text()", null, String.class); String name = customer.getName();Return the Customer's Address
Address address = context.getValueByXPath(customer, "ns:contact-info/ns:address", aNamespaceResolver, Address.class); Address address = customer.getAddress();Return all the Customer's PhoneNumbers
List phoneNumbers = context.getValueByXPath(customer, "ns:contact-info/ns:phone-number", aNamespaceResolver, List.class); List phoneNumbers = customer.getPhoneNumbers();Return the Customer's second PhoneNumber
PhoneNumber phoneNumber = context.getValueByXPath(customer, "ns:contact-info/ns:phone-number[2]", aNamespaceResolver, PhoneNumber.class); PhoneNumber phoneNumber = customer.getPhoneNumbers().get(1);Return the base object
Customer customer = context.getValueByXPath(customer, ".", aNamespaceResolver, Customer.class); Customer customer = customer;
T
- The return type of this method corresponds to the returnType parameter.object
- The XPath will be executed relative to this object.xPath
- The XPath statementnamespaceResolver
- A NamespaceResolver containing the prefix/URI pairings from the XPath statement.returnType
- The return type.public abstract boolean hasDocumentPreservation()
public void setValueByXPath(java.lang.Object object, java.lang.String xPath, NAMESPACE_RESOLVER namespaceResolver, java.lang.Object value)
Set values in the object model based on the corresponding document. The following pairings are equivalent:
Set the Customer's IDcontext.setValueByXPath(customer, "@id", null, new Integer(123)); customer.setId(new Integer(123));Set the Customer's Name
context.setValueByXPath(customer, "ns:personal-info/ns:name/text()", aNamespaceResolver, "Jane Doe"); customer.setName("Jane Doe");Set the Customer's Address
context.setValueByXPath(customer, "ns:contact-info/ns:address", aNamespaceResolver, anAddress); customer.setAddress(anAddress);Set the Customer's PhoneNumbers
context.setValueByXPath(customer, "ns:contact-info/ns:phone-number", aNamespaceResolver, phoneNumbers); customer.setPhoneNumbers(phoneNumbers);Set the Customer's second PhoneNumber
context.setValueByXPath(customer, "ns:contact-info/ns:phone-number[2]", aNamespaceResolver, aPhoneNumber); customer.getPhoneNumbers().get(1);
object
- The XPath will be executed relative to this object.xPath
- The XPath statementnamespaceResolver
- A NamespaceResolver containing the prefix/URI pairings from the XPath statement.value
- The value to be set.EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference