public class XmlRootHandleImpl<T> extends Object implements XmlRootHandle<T>
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(VetoableChangeListener... listeners)
Adds a change listener to be invoked before any property is
set or a bean is added.
|
void |
addRoot()
This method can be used if the root of the
tree has no required fields, and is the
combination of
XmlService.createBean(Class)
and XmlRootHandle.addRoot(Object) . |
void |
addRoot(T newRoot)
If this handle does not already have a
root bean this method will add the one
given
|
List<VetoableChangeListener> |
getChangeListeners()
Gets the current list of change listeners
|
Map<String,String> |
getPackageNamespace(Class<?> clazz) |
T |
getReadOnlyRoot(boolean representDefaults)
This method returns a read-only copy of the existing
tree.
|
T |
getRoot()
Gets the root of the JavaBean tree
|
Class<T> |
getRootClass()
Returns the root interface of this handle
|
URI |
getURI()
Represents the original URI from which this
tree was parsed (or null if this tree did not
come from a URI)
|
XmlRootCopy<T> |
getXmlRootCopy()
Creates a copy of this tree that is not advertised.
|
boolean |
isAdvertisedInHub()
Returns true if this handles root and children
are advertised in the
Hub |
boolean |
isAdvertisedInLocator()
Returns true if this handles root and children
are advertised in it service locator
|
boolean |
isValidating()
True if this handle is currently validating
changes
|
XmlHandleTransaction<T> |
lockForTransaction()
This method will lock the bean tree represented by
this XmlRootHandle and start a transaction.
|
void |
marshal(OutputStream outputStream)
Will marshal this tree into the given stream.
|
void |
marshal(OutputStream outputStream,
Map<String,Object> options)
Will marshal this tree into the given stream.
|
void |
overlay(XmlRootHandle<T> newRoot)
This method overlays the current root and children with
the root and children from newRoot.
|
void |
removeChangeListener(VetoableChangeListener... listeners)
Removes a change listener.
|
T |
removeRoot()
If this handle has a root this method
will delete it and all children, leaving
the root of this tree null
|
void |
startValidating()
Does javax validation on the root bean from the root.
|
void |
stopValidating()
Stops this root handle from doing javax validation
on modifications
|
String |
toString() |
public T getRoot()
XmlRootHandle
getRoot
in interface XmlRootHandle<T>
public Class<T> getRootClass()
XmlRootHandle
getRootClass
in interface XmlRootHandle<T>
public URI getURI()
XmlRootHandle
getURI
in interface XmlRootHandle<T>
public boolean isAdvertisedInLocator()
XmlRootHandle
isAdvertisedInLocator
in interface XmlRootHandle<T>
public boolean isAdvertisedInHub()
XmlRootHandle
Hub
isAdvertisedInHub
in interface XmlRootHandle<T>
Hub
public void overlay(XmlRootHandle<T> newRoot)
XmlRootHandle
All nodes that are at the same spot in the tree (have the same xpath and same instance name) will not be modified, but will instead have attributes changed. All nodes present in newRoot but not in this root will be considered adds. All nodes not present in newRoot but in this root will be considered deletes
The URI will not be modified by this call, nor will the state of advertisement
overlay
in interface XmlRootHandle<T>
newRoot
- The non-null root that will be overlayed
onto this handlepublic XmlRootCopy<T> getXmlRootCopy()
XmlRootHandle
There is no requirement to call XmlRootCopy.merge()
since the parent keeps no track of children. However,
the XmlRootCopy.merge()
method will fail if
a modification has been made to the parent since the
time the copy was created
getXmlRootCopy
in interface XmlRootHandle<T>
public void addRoot(T newRoot)
XmlRootHandle
addRoot
in interface XmlRootHandle<T>
newRoot
- The non-null instance of the
root type of this handlepublic void addRoot()
XmlRootHandle
XmlService.createBean(Class)
and XmlRootHandle.addRoot(Object)
. This method
will throw an exception from the validator
(if validation is enabled) if the root type
has required fields or fails other validationaddRoot
in interface XmlRootHandle<T>
public T removeRoot()
XmlRootHandle
removeRoot
in interface XmlRootHandle<T>
public T getReadOnlyRoot(boolean representDefaults)
XmlRootHandle
If representsDefaults is true then getters for unset fields will return the default value. If representsDefaults is false then getters for unset fields will return null (or 0 (and false) for scalars). Setting representsDefault to false is useful if this tree is to be used to marshall back to XML, since JAXB will then not write the values back out to the file
getReadOnlyRoot
in interface XmlRootHandle<T>
representDefaults
- If true getters will return default values,
if false getters will return null (or zero/false for scalars)public void addChangeListener(VetoableChangeListener... listeners)
XmlRootHandle
Rules for change listener:
addChangeListener
in interface XmlRootHandle<T>
listeners
- non-null listeners to be called whenever
a property is changed in any bean in this root. Must be
suitable for storage in a HashSetpublic void removeChangeListener(VetoableChangeListener... listeners)
XmlRootHandle
removeChangeListener
in interface XmlRootHandle<T>
public List<VetoableChangeListener> getChangeListeners()
XmlRootHandle
getChangeListeners
in interface XmlRootHandle<T>
public XmlHandleTransaction<T> lockForTransaction() throws IllegalStateException
XmlRootHandle
In particular, the code using this transaction should logically behave like the following code:
XmlHandleTransactiontransaction = root.lockForTransaction(); try { // Do many many edits all at once } finally { transaction.commit(); }
lockForTransaction
in interface XmlRootHandle<T>
IllegalStateException
- if this bean tree is not allowed to have
a transaction started on itpublic void startValidating()
XmlRootHandle
startValidating
in interface XmlRootHandle<T>
public void stopValidating()
XmlRootHandle
stopValidating
in interface XmlRootHandle<T>
public boolean isValidating()
XmlRootHandle
isValidating
in interface XmlRootHandle<T>
public void marshal(OutputStream outputStream) throws IOException
XmlRootHandle
marshal
in interface XmlRootHandle<T>
outputStream
- A non-closed output stream. This method will
not close the output streamIOException
- On any exception that might happenpublic void marshal(OutputStream outputStream, Map<String,Object> options) throws IOException
XmlRootHandle
marshal
in interface XmlRootHandle<T>
outputStream
- A non-closed output stream. This method will
not close the output streamoptions
- optional (possibly null) options from the callerIOException
- On any exception that might happenCopyright © 2009–2023 Oracle Corporation. All rights reserved.