|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.inria.ns.reflex.xml.operator.XMaster
public class XMaster
The entry point for processing any XML and X-operable object.
Each method is a switch to the relevant XOperator method according
to the object type. Never use directly XOperator methods,
use the static methods of this class ; null
is
also supported in each method.
Any basic operation is supplied with a static method. Use the most suitable operation each time it is possible instead of using a more general mean ; for example, if you have to get the position of a node, use the relevant method, do not use the list of children and look for the item to retrieve the position : the best strategy that depends on the object type will be applied.
Method Summary | |
---|---|
static void |
append(Object referent,
Object operand)
Append a child to an item. |
static boolean |
booleanValueOf(Object referent)
Return the boolean evaluation of a value, given by the XPath boolean() function. |
static Map |
extractNamespaces(Map attributes)
Extract the namespace declarations defined in an attribute map. |
static Map |
getAttributes(Object referent)
Return the attributes of a node. |
static List |
getChildren(Object referent)
Return the list of children of a node. |
static Object |
getCommentAt(Object referent,
int index)
Return the child comment at the index specified. |
static Object |
getElementAt(Object referent,
int index)
Return the child element at the index specified. |
static Object |
getElementById(QName elementId,
Object referent)
Return the element whose ID is given by elementId. |
static Iterator |
getElementsByName(Object referent,
QName nodeName)
Return the elements with a specific name. |
static int |
getFamilyIndex(Object referent)
Return the intrinsic position of this item amongs items of the same family ; for an element <f:foo>, the XPath pattern f:*[n] would use this method in order to test its position. |
static int |
getFamilySize(Object referent)
|
static XFile |
getInScopeBaseFile(Object node,
XFile base)
Return the base file property of a node, given by the @xml:base attribute of the node or one of its ancestor. |
static String |
getInScopeLang(Object node)
Return the in-scope language property of a node, given by the @xml:lang attribute of the node or one of its ancestor. |
static Map |
getInScopeNamespaces(Object node)
Return the in-scope namespaces of a node, that is to say the namespace declarations set on the node and its ancestor. |
static Object |
getNamedElementAt(Object referent,
int index,
QName qname)
Return the child element at the index specified. |
static Object |
getNamedProcessingInstructionAt(Object referent,
int index,
QName target)
Return the child PI at the index specified. |
static int |
getNameIndex(Object referent)
Return the intrinsic position of this item amongs items of the same name ; for an element <foo>, the XPath pattern foo[n] would use this method in order to test its position. |
static int |
getNameSize(Object referent)
|
static Map |
getNamespaces(Object referent)
Return the namespaces defined explicitely by a node. |
static int |
getNaturalIndex(Object referent)
Return the intrinsic position of this item ; for an element <foo>, the XPath pattern node()[n] would use this method in order to test its position. |
static int |
getNaturalSize(Object referent)
Return the intrinsic size of an object. |
static Object |
getNodeAt(Object referent,
int index)
Return the child at the index specified. |
static XOperator |
getNullOperator()
Return the null operator. |
static Object |
getParent(Object referent)
Return the parent of a node. |
static Object |
getProcessingInstructionAt(Object referent,
int index)
Return the child PI at the index specified. |
static QName |
getQName(Object referent)
Return the QName of a referent if any. |
static Object |
getRoot(Object referent)
Return the root in the hierarchy. |
static Object |
getTextAt(Object referent,
int index)
Return the child text at the index specified. |
static int |
getTypeIndex(Object referent)
Return the intrinsic position of this item amongs items of the same type ; for an element <foo>, the XPath pattern *[n] would use this method in order to test its position. |
static QName |
getTypeName(Object referent)
Return the type name of the referent. |
static int |
getTypeSize(Object referent)
Return the intrinsic size of this item amongs items of the same type. |
static short |
getXMLType(Object referent)
Return the XML type of the given referent. |
static XOperator |
getXOperator(Object referent)
Lookup for the XOperator of an object. |
static boolean |
isAttribute(Object referent)
Indicate if the referent is an attribute. |
static boolean |
isComment(Object referent)
Indicate if the referent is a comment. |
static boolean |
isDocument(Object referent)
Indicate if the referent is a document. |
static boolean |
isElement(Object referent)
Indicate if the referent is an element. |
static boolean |
isFallbackOperator(XOperator op)
Indicates whether the given operator is the fallback operator or not. |
static boolean |
isParentNode(Object referent)
Indicate if the referent is a parent node, that is to say if it can have children. |
static boolean |
isProcessingInstruction(Object referent)
Indicate if the referent is a PI. |
static boolean |
isText(Object referent)
Indicate if the referent is a text. |
static Number |
numberValueOf(Object referent)
Return the number evaluation of a value, given by the XPath number() function. |
void |
register(Class clazz,
XOperator operator)
Register a class to the master operator. |
static void |
remove(Object referent,
Object parent)
Remove an item from its collection. |
static void |
rename(Object referent,
Object parent,
QName newName)
Rename an item. |
static String |
stringValueOf(Object referent)
Return the string evaluation of a value, given by the XPath string() function. |
static Object |
valueOf(Object referent)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static XOperator getNullOperator()
public void register(Class clazz, XOperator operator)
clazz
- The class to register.operator
- The operator that can perform XML-oriented operations.
IllegalStateException
- If there is an operator already
registered for the class.public static XOperator getXOperator(Object referent)
referent
- The object, may be null
.
null
XOperator.public static boolean isFallbackOperator(XOperator op)
op
- The XOperator to test.
true
if it is the fallback operator,
false
otherwise.public static Object getParent(Object referent)
The XOperator of the referent is involved in this operation if it is not a ChildItem.
referent
- The referent, may be null
.
null
.ChildItem
public static List getChildren(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent, may be null
.
null
list of children.public static Map getAttributes(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent, may be null
.
null
map of attributes as {QName, Map.Entry}.public static Object getElementById(QName elementId, Object referent)
The XOperator of the referent is involved in this operation.
referent
- A node that belongs to a document to look inside.elementId
- The unique ID for an element.
null
.public static Iterator getElementsByName(Object referent, QName nodeName)
The XOperator of the referent is involved in this operation.
referent
- A node that belongs to a document to look inside.elementId
- The unique ID for an element.
null
.public static Object getElementAt(Object referent, int index)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.
null
.public static Object getNodeAt(Object referent, int index)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.
null
.public static Object getTextAt(Object referent, int index)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.
null
.public static Object getCommentAt(Object referent, int index)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.
null
.public static Object getProcessingInstructionAt(Object referent, int index)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.
null
.public static Object getNamedElementAt(Object referent, int index, QName qname)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.The
- name of the element.
null
.public static Object getNamedProcessingInstructionAt(Object referent, int index, QName target)
The XOperator of the referent is involved in this operation.
referent
- The parent referent.index
- The index.target
- The PI targetn as an NCName.
null
.public static QName getQName(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
null
QName.QName.QNULL
public static boolean isDocument(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is a document, false
otherwise.public static boolean isElement(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is an element, false
otherwise.public static boolean isAttribute(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is an attribute, false
otherwise.public static boolean isText(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is a text, false
otherwise.public static boolean isComment(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is a comment, false
otherwise.public static boolean isProcessingInstruction(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is a PI, false
otherwise.public static boolean isParentNode(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
true
if it is a parent node, false
otherwise.public static short getXMLType(Object referent)
The XOperator of the referent is involved in this operation.
referent
- The referent.
XType
public static QName getTypeName(Object referent)
referent
- The referent.
null
type name.
It can be a QName built with the class
name of the referent as NCName.public static Map getNamespaces(Object referent)
Changes made on the map are not reflected on the referent object. Act on the attribute map instead.
The XOperator of the referent is involved in this operation.
referent
- The node.
null
map of { QName, Map.Entry }.
The string value of the attribute is the namespace URI
of the namespace node.QName
,
getInScopeNamespaces(Object)
,
getAttributes(Object)
public static Map extractNamespaces(Map attributes)
Each attribute that is a namespace declaration will be in the output result in the same form. That is to say the QName keeps the form of the original attribute : xmlns:prefix or xmlns.
referent
- The referent object.
null
map of {QName, ChildItem}.XMLNames.XMLNS_NAMESPACE_URI
,
QName
,
ChildItem
,
getInScopeNamespaces(Object)
,
getNamespaces(Object)
public static String stringValueOf(Object referent)
string()
function. Objects other than those usually
processed by the XPath string()
function are converted
with their own toString()
method.
The XOperator of the referent is involved in this operation.
referent
- The object to convert to string.
null
string value of the object.public static Number numberValueOf(Object referent)
number()
function. Objects other than those usually
processed by the XPath number()
function are converted
with their own toString()
method then with the
number()
function to the result string.
The XOperator of the referent is involved in this operation.
referent
- The object to convert to number.
null
number value of the object, can be NaN.public static boolean booleanValueOf(Object referent)
boolean()
function. Objects other than those usually
processed by the XPath boolean()
function are converted
with their own toString()
method then with the
boolean()
function to the result string.
The XOperator of the referent is involved in this operation.
referent
- The object to convert to boolean.
public static Object valueOf(Object referent)
public static Object getRoot(Object referent)
The XOperator of the referent is involved in this operation.
referent
- Where to start.
public static void remove(Object referent, Object parent)
The XOperator of the referent is involved in this operation if it is not a Removable.
referent
- The item to remove.parent
- Its parent.Removable
public static void rename(Object referent, Object parent, QName newName)
The XOperator of the referent is involved in this operation if it is not a Renamable.
referent
- The item to rename.parent
- Its parent.newName
- Its new name.Renamable
public static void append(Object referent, Object operand)
The XOperator of the referent is involved in this operation if it is not an Appendable.
referent
- The item to which the child will be append.operand
- The child to append.Appendable
public static String getInScopeLang(Object node)
node
- The node that might contain the @xml:lang attribute ;
may be null
.
null
if not specified.public static Map getInScopeNamespaces(Object node)
If the node is an element, there is always at least one entry in this map : xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns="" is not present in the result, since it is a declaration used for undeclaring the default namespace.
node
- The node.
QName
,
getNamespaces(Object)
public static XFile getInScopeBaseFile(Object node, XFile base) throws FileSystemException
node
- The node that might contain the @xml:base attribute ;
may be null
.base
- The base to use for absolutizing a relative reference.
null
if not specified.
FileSystemException
public static int getNaturalIndex(Object referent)
referent
- The referent object.
getNaturalSize(Object)
,
getTypeIndex(Object)
,
getFamilyIndex(Object)
,
getNameIndex(Object)
public static int getNaturalSize(Object referent)
referent
- The referent object.
getNaturalIndex(Object)
,
getTypeSize(Object)
,
getFamilySize(Object)
,
getNameSize(Object)
public static int getTypeIndex(Object referent)
referent
- The referent object.
public static int getTypeSize(Object referent)
referent
- The referent object.
public static int getFamilyIndex(Object referent)
referent
- The referent object.
public static int getFamilySize(Object referent)
referent
- The referent object.
public static int getNameIndex(Object referent)
referent
- The referent object.
public static int getNameSize(Object referent)
referent
- The referent object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |