|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
XoDMInstance
is the representation of an XML document in Xotics environment.
Method Summary | |
XoObject |
addChild(XoObject child,
XoContainer parent)
Appends param child to the list of children of param parent .
|
XoObject |
addChild(XoObject child,
XoContainer parent,
int index)
Inserts param child to the list of children of param parent at specified index .
|
void |
addNSMapping(java.lang.String nsref,
java.lang.String nsprefix)
Sets for this DM instance a prefix to associate to namespace nsref . |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a listener of PropertyChangeEvent fired
for this properties and for properties of all XoObject contained in this . |
void |
addResourceRef(java.net.URL resUrl)
Adds a resource path URL to the local class loader. |
void |
addXoContainerListener(XoContainerListener l)
Adds a listener of XoContainerEvent fired by this when an
XoObject is added to or removed from this content tree. |
void |
addXoUndoableListener(XoUndoableListener l)
Registers an XoUndoableEvent listener interested in receiving all Undo events fired by this . |
void |
changeNSMapping(java.lang.String nsref,
java.lang.String nsprefix)
Changes the prefix string as param nsprefix associated to a namespace specified by param nsref . |
void |
checkValidity()
Apply all defined validity rules to entire content tree to check its validity. |
void |
checkValidity(XoObject xo,
boolean deep)
Checks validity from XO object xo . |
java.lang.Object |
clone()
Clone method of XoDMInstance . |
XoObject |
cloneXoObject(XoObject xo,
boolean deep)
Clones an XO object belonging to this . |
boolean |
contains(XoObject xo)
Checks whether this contains XO object param xo . |
boolean |
contains(XoObject xo,
XoObject container)
Checks whether XO object param xo is or is descendant of param container . |
boolean |
deepEquals(XoObject src,
XoObject cmp)
Checks XO equality of two sub-trees using XoObject.equalsXoObject(XoObject) method. |
XoDMInstance |
exportDMInstance(XoRoot rpos)
Creates a new DM instance and sets its content with a deep copy of a rootable object of this .
|
java.lang.Class |
getClassResource(java.lang.String clname)
Loads a class searched in classpaths of internal resource refs. |
java.net.URL |
getDMLocation(java.lang.String nsref)
Gets URL location permitting to load DM module specified by param nsref |
java.net.URL[] |
getDMLocations()
Gets URL location list permitting to load all Data-Model modules loaded |
java.lang.String |
getEncoding()
Returns the current charset encoding used to save this . |
XoEnvironment |
getEnvironment()
Returns the current Xotics Environment. |
int |
getHistorySize()
Gets the number of changes on this kept in memory to be able to call
undo() . |
int |
getIndexOfChild(XoObject child)
Returns the index of child in brotherhood. |
java.lang.String |
getInstanceName()
Gets the name of this instance. |
void |
getLock()
Waits until caller thread acquires a lock on this DM instance. |
java.lang.String |
getNamespaceURI(java.lang.String nsprefix)
Returns the namespace URI string associated to param nsprefix prefix. |
java.lang.String[] |
getNamespaceURIs()
Gets the list of namespace URIs of Data-Models used by this . |
java.lang.String |
getNSPrefix(java.lang.String nsref)
Returns the prefix associated to namespace URI nsref . |
java.lang.String[] |
getReferencedIds()
Returns the list of XO object ID values currently registered by this . |
XoRegistry |
getRegistry()
Returns the Registry of current Xotics Environment. |
java.net.URL |
getResourceURL(java.lang.String path)
Searches URL corresponding to a path string seeked in internal resource refs. |
XoRoot |
getRoot()
Returns the root XoRoot object. |
java.lang.String |
getRootNamespaceURI()
Helper method which gets the namespace URI of the root XO object. |
java.net.URL |
getSourceLocation()
Gets the location URL of the document file from which this is generated and/or
to save this to. |
XoUpdateHandler |
getUpdateHandler()
This method is not yet implemented and reseved for the next version of this API. |
XoObject |
getXoObjectById(java.lang.String id)
Returns the registered Xo object having id paameter as ID value. |
boolean |
hasNSMapping(java.lang.String nsref)
Tells whether or not param nsref namespace URI is used by this |
void |
importDMInstance(XoDMInstance edm,
XoContainer ppos)
Imports entire content copy of external DM instance edm
as child of container param ppos . note that this is a deep copy made
from content tree that is added as child of ppos |
boolean |
isInsertDMLocation()
Indicates whether or not this will insert a processing instruction, when saving this to file,
indicating the DM modules needed to create this during XML parsing. |
boolean |
isLocked()
Tells whether this is locked by any thread. |
boolean |
isLockOwner()
Tells whether calling thread is the lock owner of this. |
boolean |
isReadOnly()
Tells whether this is in read-only mode. |
boolean |
isReleased()
Tells whether this has been released. |
boolean |
isRequestable()
If this methods returns false, it means that this instance can not be requested by XPath. |
boolean |
isWelcome(XoContainer parent,
XoObject child,
int index)
This method is the thread-safe version of XoContainer.isXoObjectWelcome(XoObject, int) .
|
void |
redo()
This method is not yet implemented and reseved for the next version of this API. |
void |
release()
This method makes free all XO objects belonging to this : after calling
XoRoot.xoRelease() , DM instance owner of all XO objects is set to null.
|
XoObject |
remove(XoObject xo)
Removes XO object param xo and its sub-tree from this . |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a listener of PropertyChangeEvent fired
for this properties and for properties of all XoObject contained in this . |
void |
removeXoContainerListener(XoContainerListener l)
Removes a listener of XoContainerEvent fired by this when an
XoObject is added to or removed from this content tree. |
void |
removeXoUndoableListener(XoUndoableListener l)
Unregisters an XoUndoableEvent listener interested in receiving all Undo events fired by this . |
XoDataType |
request(java.lang.String reqIdOrXPath,
XoNode ctx,
java.util.Map xpathVars)
performs an XPath request from context node ctx , using an optional map of XPath variables xpathVars . |
XoNode[] |
requestXoNodes(java.lang.String reqIdOrXPath,
XoNode ctx,
java.util.Map vars)
The same as request( reqIdOrXPath, ctx, vars ) except that result is transformed in an array of
XoNode objects. |
void |
save()
Saves this as XML document using URL provided by getSourceLocation() |
void |
save(java.io.OutputStream os)
Saves this as XML document into output stream os |
void |
save(java.net.URL url)
Saves this as XML document on URL specified by url param. |
void |
save(java.io.Writer wr)
Saves this as XML document into writer wr . |
void |
setDMLocation(java.lang.String nsref,
java.net.URL url)
This method can set or change a Data-Model location URL for a specific namespace. |
void |
setEncoding(java.lang.String charsetEncoding)
Sets the charset encoding to use when saving this . |
void |
setInsertDMLocation(boolean enabled)
Tells to this whether to insert a processing instruction, when saving this to file,
specifying the Data-Model modules needed to create this during XML parsing. |
void |
setInstanceName(java.lang.String iname)
Sets the name of this instance. |
void |
setReadOnly(boolean rd)
Sets the document in read-only mode. |
void |
setSourceLocation(java.net.URL loc)
Sets the location URL of the document file from which this is generated and/or
to save this to. |
void |
setUpdateHandler(XoUpdateHandler uh)
This method is not yet implemented and reseved for the next version of this API. |
void |
transferResourceRefs(XoDMInstance extdm)
Copy into an external DM instance the list of all local resource path URLs. |
void |
undo()
Removes the last historized change, to make this in the exact state before last
operation (add/remove XO object or property change). |
void |
unlock()
Removes any lock previously set on this . |
void |
update()
This method is not yet implemented and reseved for the next version of this API. |
Method Detail |
public void setUpdateHandler(XoUpdateHandler uh)
uh
- public XoUpdateHandler getUpdateHandler()
public void update() throws XoException
XoException
public void release() throws XoException
this
: after calling
XoRoot.xoRelease()
, DM instance owner of all XO objects is set to null.
After a call to this method, this DM instance is no more useable.
XoException
public boolean isReleased()
release()
has been called, false otherwise.public void getLock()
this
is locked, most methods will throw an XoLockedException
if
they are called by another thread than the lock owner.
public void unlock() throws XoException
this
.
XoLockedException
- if this
is locked by another thread
XoException
public boolean isLockOwner()
public boolean isLocked()
public int getHistorySize()
this
kept in memory to be able to call
undo()
. Historized changes are XO child addition or removal and property change.
History size is a constant value, set at DM instance creation, either to a specified value
or to a default value defined in DMDL document of root element's namespace, by init option
XoConstants.INIT_HISTORY_SIZE
.
A special value, -1, means unlimited size. History size
public void undo() throws XoException
this
in the exact state before last
operation (add/remove XO object or property change). Does nothing if history is empty.
XoException
- and more precisely XoLockedException if DM instance is lockedpublic void redo() throws XoException
XoException
- and more precisely XoLockedException if DM instance is lockedpublic void setReadOnly(boolean rd) throws XoException
addChild(XoObject, XoContainer)
or remove(XoObject)
will cause an XoException
to be thrown, and any
attempt to modify a property of an XO object in this
should throw
a PropertyVetoException
(provided this JavaBean feature is coded in property setter method).
At creation time, a DM instance can be set by default in read-only mode, by init option XoConstants.INIT_READ_ONLY
rd
- true to set this
in read-only mode.
XoException
- and more precisely XoLockedException if DM instance is lockedpublic boolean isReadOnly() throws XoException
this
is in read-only mode.
XoException
- and more precisely XoLockedException if DM instance is lockedpublic void setSourceLocation(java.net.URL loc) throws XoException
this
is generated and/or
to save this
to. In current version, allowed protocols are http and file.
loc
- an URL of the XML file storing this instance
XoException
- and more precisely XoLockedException if DM instance is lockedpublic java.net.URL getSourceLocation() throws XoException
this
is generated and/or
to save this
to.
XoException
- and more precisely XoLockedException if DM instance is lockedpublic void setInsertDMLocation(boolean enabled) throws XoException
this
whether to insert a processing instruction, when saving this
to file,
specifying the Data-Model modules needed to create this
during XML parsing. This value
can be set also by default at creation time by init option XoConstants.INIT_DMD_AUTO_LOADING_ENABLED
.
enabled
- true if this should insert DM modules location URLs to load if needed
XoException
- and more precisely XoLockedException if DM instance is lockedpublic boolean isInsertDMLocation() throws XoException
this
will insert a processing instruction, when saving this
to file,
indicating the DM modules needed to create this during XML parsing.
this
will insert DM modules location URLs to load if needed
XoException
- and more precisely XoLockedException if DM instance is lockedpublic java.net.URL[] getDMLocations() throws XoException
XoException
- and more precisely XoLockedException if DM instance is lockedpublic java.net.URL getDMLocation(java.lang.String nsref) throws XoException
nsref
XoLockedException
- if this
is locked
XoException
- for invalid nsref
public void setDMLocation(java.lang.String nsref, java.net.URL url) throws XoException
nsref
- the namespace of DMurl
- the DM location URL
XoLockedException
- if this
is locked
XoException
- for invalid nsref
public void setInstanceName(java.lang.String iname) throws XoException
iname
- instance name of this
XoException
- and more precisely XoLockedException if DM instance is lockedpublic java.lang.String getInstanceName() throws XoException
XoException
- and more precisely XoLockedException if DM instance is lockedpublic java.lang.String[] getReferencedIds() throws XoException
this
.
XoException
- and more precisely XoLockedException if DM instance is lockedpublic XoObject getXoObjectById(java.lang.String id) throws XoException
id
- the string value of an Xo object ID property
XoLockedException
- if this
is locked
XoException
- if no object was found with ID id
public XoRoot getRoot() throws XoException
XoRoot
object.
XoRoot
root object of content tree.
XoLockedException
- if this
is locked by another thread
XoException
public int getIndexOfChild(XoObject child) throws XoException
XoUtilities.getIndexOfChild(XoObject)
.
XoLockedException
- if this is locked by another thread
XoException
- if child belongs to another DM instance, or if some error occurred
during index searchingpublic XoRegistry getRegistry()
XoRegistry
unique instancepublic XoEnvironment getEnvironment()
XoEnvironment
instancepublic java.lang.String getEncoding() throws XoException
this
.
XoException
- and more precisely XoLockedException if DM instance is lockedsave()
public void setEncoding(java.lang.String charsetEncoding) throws XoException
this
.
charsetEncoding
-
XoException
- and more precisely XoLockedException if DM instance is lockedsave()
public void checkValidity() throws XoException
XoLockedException
- if this
is locked by another thread
XoValidityException
- if content tree is not valid against all validity rules defined.
XoException
public void checkValidity(XoObject xo, boolean deep) throws XoException
xo
.
xo
- root of sub-tree to checkdeep
- if true, checks possible sub-tree, if false checks xo
only
XoLockedException
- if this
is locked by antoher thread
XoValidityException
- if xo
and its sub-tree is not valid
XoException
- if xo
belongs to another DM instancepublic boolean deepEquals(XoObject src, XoObject cmp) throws XoException
XoObject.equalsXoObject(XoObject)
method.
XoLockedException
- if this
is locked by antoher thread
XoException
- if src
or cmp belongs to another DM instance,
or if some error occurred during sub-tree walking.
public boolean contains(XoObject xo) throws XoException
xo
.
xo
- an XoObject
instance to control.
xo
belongs to this
XoLockedException
- if this
is locked by antoher thread
XoException
public boolean contains(XoObject xo, XoObject container) throws XoException
xo
is or is descendant of param container
.
xo
- an XoObject
instance to control.container
- an XoContainer
instance
xo
is descendant of container
or if xo
is container
, return false
otherwise, especially if xo
or container
belong to another DM instance
XoLockedException
- if this
is locked by antoher thread
XoException
public boolean isWelcome(XoContainer parent, XoObject child, int index) throws XoException
XoContainer.isXoObjectWelcome(XoObject, int)
.
If child
is a polymorph wrapper, appropriate implementation is resolved.
parent
- a container belonging to this
child
- an XO object (including XoPolymorphWrapper
) to checkindex
- desired insertion index
child
is welcome as child of parent
at specified index
XoException
- if this
is locked, parent
belongs
to another DM instance, or if some error occurred during testingpublic void addNSMapping(java.lang.String nsref, java.lang.String nsprefix) throws XoException
nsref
. A unique prefix
must be set for all namespace used in this DM instance, first to be able to save
as XML document. A namespace is used when an XO object of this namespace belongs to content tree.
If a new namespace is encountered when an XO object is added to content tree, this method
is automatically called with a prefix of the form : nsx
where x is an incremented counter.
This method has also a side effect : when calling this method for a namespace not already used,
all corresponding Data-Model informations are loaded in this
. This permits to load
XS datatypes and XPath functions specifically defined for this namespace.
- Parameters:
nsref
- the namespace referencensprefix
- the unique prefix for this namespace
- Throws:
XoLockedException
- if this
is locked
XoException
- if nsprefix
is already used for another namespace, or if some
error occurred during method call.
public boolean hasNSMapping(java.lang.String nsref) throws XoException
nsref
namespace URI is used by this
nsref
- the namespace URI to check
nsref
is used by this
XoException
public void changeNSMapping(java.lang.String nsref, java.lang.String nsprefix) throws XoException
nsprefix
associated to a namespace specified by param nsref
.
nsref
- the namespace URI stringnsprefix
- the new prefix to associate to
XoException
public java.lang.String getNamespaceURI(java.lang.String nsprefix) throws XoException
nsprefix
prefix.
nsprefix
-
XoException
public java.lang.String getRootNamespaceURI() throws XoException
XoException
public java.lang.String[] getNamespaceURIs() throws XoException
this
.
this
.
XoException
public java.lang.String getNSPrefix(java.lang.String nsref) throws XoException
nsref
.
nsref
- the namespace URI
XoException
public void importDMInstance(XoDMInstance edm, XoContainer ppos) throws XoException
edm
as child of container param ppos
. note that this is a deep copy made
from content tree that is added as child of ppos
edm
- DM instance whose content copy is to be importedppos
- container accepting edm copy as child
XoLockedException
- if this
or edm
is locked by antoher thread
XoException
- if ppos
belongs to another DM instance, or if some error
occurred during sub-tree walkingpublic XoDMInstance exportDMInstance(XoRoot rpos) throws XoException
this
.
Notes that rpos
is not mandatory to be the root of this
,
but can be any instance of XoRoot
anywhere in this
.
Notice also that instance name is not copied, as it can serve as some kind of ID.
XoDMInstance
created based on content of this
XoLockedException
- if this
is locked by antoher thread
XoException
- if rpos
belongs to another DM instance, or if some error
occurred during sub-tree walkingpublic java.lang.Object clone()
XoDMInstance
. If some error occurred during cloning process,
null
is returned, no exception thrown. To have better visibility,
you should rather use exportDMInstance(XoRoot)
.
this
public XoObject cloneXoObject(XoObject xo, boolean deep) throws XoException
this
. Cloning can be a deep copy or single object copy.
If xo
is a XoPolymorphWrapper
, param deep
has no effect.
xo
- object to clonedeep
- true if deep copy is wanted
XoLockedException
- if this
is locked by antoher thread
XoException
- if xo
belongs to another DM instance, or if some error
occurred during sub-tree walkingpublic XoObject addChild(XoObject child, XoContainer parent) throws XoException
child
to the list of children of param parent
.
Equivalent to call addChild(XoObject, XoContainer, int)
with index at -1.
child
- the child to addparent
- the futur parent
child
is a polymorph wrapper (XoPolymorphWrapper
)
XoLockedException
- if this
is locked by antoher thread
XoException
- if unable to add param child
public XoObject addChild(XoObject child, XoContainer parent, int index) throws XoException
child
to the list of children of param parent
at specified index
.
Concerning index, adding rules of XoContainer.addXoChild(XoObject, int)
are used.
child
- the child to addparent
- the futur parentindex
- the insert index
child
is a polymorph wrapper (XoPolymorphWrapper
)
XoLockedException
- if this
is locked by antoher thread
XoException
- if unable to add param child
public XoObject remove(XoObject xo) throws XoException
xo
and its sub-tree from this
.
xo
- XO object to remove
xo
is a polymorph object (XoPolymorph
)
XoLockedException
- if this
is locked by antoher thread
XoException
- if unable to remove param xo
public boolean isRequestable()
request(String, XoNode, Map)
and requestXoNodes(String, XoNode, Map)
will throw an XoException
.
This requestable property is set at creation time by init option XoConstants.INIT_REQUESTABLE
and can not be changed, as it influences the way DM instance is created.
this
is requestable, false otherwisepublic XoDataType request(java.lang.String reqIdOrXPath, XoNode ctx, java.util.Map xpathVars) throws XoException
ctx
, using an optional map of XPath variables xpathVars
.
reqIdOrXPath
- the XPath request string or an ID of itctx
- the context node of XPath request, or null
for using
root node as context node (i.e this
, as XML document).xpathVars
- the XPath variables in a map (String name, value object) or null if no variable to provide
XoDataType
object
XoLockedException
- if this
is locked by antoher thread
XoException
- if some error occurred during XPath request processing or if
ctx
belongs to another DM instance (if ctx
is an XO object)public XoNode[] requestXoNodes(java.lang.String reqIdOrXPath, XoNode ctx, java.util.Map vars) throws XoException
reqIdOrXPath, ctx, vars
) except that result is transformed in an array of
XoNode
objects. If the result doesn't contains any XoNode
, empty array is returned.
If result contains anything else that XoNode
, it is discarded.
reqIdOrXPath
- the XPath request string or an ID of itctx
- the context node of XPath requestvars
- the XPath variables in a map (String name, value object)
XoNode
objects
XoLockedException
- if this
is locked by antoher thread
XoException
- if some error occurred during XPath request processing or if
ctx
belongs to another DM instancepublic java.lang.Class getClassResource(java.lang.String clname) throws XoException
clname
- a class name with package
XoException
- if this
is locked or if some error occurred during class loading processpublic java.net.URL getResourceURL(java.lang.String path) throws XoException
path
string seeked in internal resource refs.
path
- a path string
path
XoException
- if this
is locked or if some error occurred during URL resolving processpublic void addResourceRef(java.net.URL resUrl) throws XoException
resUrl
- a path URL to a resource location.
XoException
- if this is locked or if some error occurred during URL adding processpublic void transferResourceRefs(XoDMInstance extdm) throws XoException
extdm
- the target DM instance
XoException
- if this is locked or if some error occurred during URL transfer processpublic void addXoUndoableListener(XoUndoableListener l)
XoUndoableEvent
listener interested in receiving all Undo events fired by this
.
l
- a listener of XoUndoableEvent
XoUndoableEvent
public void removeXoUndoableListener(XoUndoableListener l)
XoUndoableEvent
listener interested in receiving all Undo events fired by this
.
l
- a listener of XoUndoableEvent
XoUndoableEvent
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
PropertyChangeEvent
fired
for this properties and for properties of all XoObject
contained in this
.
l
- a listener of PropertyChangeEvent
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
PropertyChangeEvent
fired
for this properties and for properties of all XoObject
contained in this
.
l
- a listener of PropertyChangeEvent
public void addXoContainerListener(XoContainerListener l)
XoContainerEvent
fired by this
when an
XoObject
is added to or removed from this
content tree.
l
- a listener of XoContainerEvent
public void removeXoContainerListener(XoContainerListener l)
XoContainerEvent
fired by this
when an
XoObject
is added to or removed from this
content tree.
l
- a listener of XoContainerEvent
public void save(java.net.URL url) throws java.io.IOException, XoException
this
as XML document on URL specified by url
param. Valids protocols are
file and http.
url
- URL to save this
to
java.io.IOException
- if an IO error occurred during saving
XoLockedException
- if this
is locked
XoException
- if URL is not of proto file or http or if some other error occured during savingpublic void save() throws java.io.IOException, XoException
this
as XML document using URL provided by getSourceLocation()
java.io.IOException
- if an IO error occurred during saving
XoLockedException
- if this
is locked
XoException
- if this.getSourceLocation()
is null
or if some other error occured during savingpublic void save(java.io.OutputStream os) throws java.io.IOException, XoException
this
as XML document into output stream os. Uses getEncoding()
as
charset name to convert chars in appropriate byte values.
- Parameters:
os
- the output stream used to save this
- Throws:
java.io.IOException
- if an IO error occurred during saving
XoLockedException
- if this
is locked
XoException
- if some error occured during saving
public void save(java.io.Writer wr) throws java.io.IOException, XoException
this
as XML document into writer wr
.
wr
- the Writer used to save this
java.io.IOException
- if an IO error occurred during saving
XoLockedException
- if this
is locked
XoException
- if some error occured during saving
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |