|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.entry.DocImpl
com.ibm.di.entry.Entry
public class Entry
The Entry class is a container for attributes and their values. The Entry class is widely used in the IBM Tivoli Directory Integrator. In the scripting environment you use the Entry and Attribute classes by accessing the object's methods.
JavaScript Examples
// List all attributes and their values var conn = connector.getNextEntry(); var attrnames = conn.getAttributeNames(); for (i = 0; i < attrnames.length; i++) { var attr = conn.getAttribute(attrnames[i]); task.logmsg("Attribute: name = " + attr.getName() + ", #values = " + attr.size()); for (j = 0; j < attr.size(); j++) { task.logmsg(" Value " + j + ": " + attr.getValue(j)); } }The Entry could store date using two approaches:
setProperty(Object, Object)
method.toString()
) will be used as a key.getProperty(Object)
method.setProperty(Object, Object)
is called! In order to distinguish and
retrieve data by the key name the Object.equals(Object)
method of the key
is used.getPropertyNames()
method.getProperty(Object)
method instead. Document
interface, the Element
interface is implemented by the Attribute
class, the org.w3c.Attr
interface by the Property
class, the Text
is
implemented by the AttributeText
class and the
CDATASection
interface is implemented by the
AttributeCDATA
class. getAttribute(String)
method.getAttribute(String)
, setAttribute(String, Object)
,
getAttributeNames()
and getAttributeCollection()
methods or
any of the other methods using these ones. Script Example
// Access any property using the .@ notation var prop = work.@propertyName; // here the prop variable will have the value of the property with name propertyName // Note that properties with names "1propName", "prop#Name", "prop!Name" and so on, could not be accessed using that notation. // All of the following will result in an Exception being thrown by the Script Engine. var prop = work.@prop.Name; var prop = work.@prop!Name; // the names shouldn't start with a number either. var prop = work.@32443Prop; // use this approach to get the desired properties var prop = work.getProperty("prop.Name"); prop = work.getProperty("prop!Name"); prop = work.getProperty("32443Prop"); // You could also create/replace properties like this work.@newPropertyName = new java.lang.Object(); // If there were a property with the name newPropertyName then its value will be replaced. // Access any Attribute just refer to it using the local name it was mapped under var attr = work.attributeName; // here the attr variable will point to the Attribute object that was mapped to the key name "attributeName". // Note that the name after the . should be a simple one in order to access it. // Names that have special characters like: attribute-Name or !attribute*Name or 342AttrName are not resolvable. // For those kind of names use the entry.getAttribute("complexName"); approach. var attr = work.getAttriubte("@Complex346##.Name6"); // You could create/replace Attributes like this: work.elementsLocalName = work.createElement("elementsLocalName"); // This will create new Attribute with local name "elementsLocalName" and will map it under the key name "elementsLocalName". // Note: if you specify a different name on the left then that name will override the one of the element in the right. work.otherName = work.createElement("elementLocalName"); // You could think of this operation as if this was executed: work.setAttribute("otherName", work.createElement("elementsLocalName")); // Here the name on the left is set on the Attribute on the right. // cycle through the Entry's attributes using the for/in loop for (var v in work) { main.logmsg(v.getName()); }
Field Summary | |
---|---|
static char |
ESCAPE_CHAR
This is the character used to separate the simple names in a composite name |
static char |
OP_ADD
The Entry contains an entry which is supposed to be added |
static java.lang.String |
OP_ADD2
String representation of the OP_ADD field. |
static char |
OP_DEL
The Entry contains an entry which is supposed to be removed |
static java.lang.String |
OP_DEL2
String representation of the OP_DEL field. |
static char |
OP_GEN
The Entry contains an entry with no explicit knowledge of operation |
static java.lang.String |
OP_GEN2
String representation of the OP_GEN field. |
static char |
OP_MOD
The Entry contains an entry which is supposed to be modified |
static java.lang.String |
OP_MOD2
String representation of the OP_MOD field. |
static char |
OP_UNCHANGED
The Entry contains an entry which is unchanged |
static java.lang.String |
OP_UNCHANGED2
String representation of the OP_UNCHANGED field. |
static char |
PATH_SEPARATOR_CHAR
This is the character used to separate the simple names in a composite name |
static java.lang.String |
PATH_SEPARATOR_STR
This is the string representing the PATH_SEPARATOR_CHAR field. |
Fields inherited from interface org.w3c.dom.Node |
---|
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE |
Constructor Summary | |
---|---|
Entry()
Construct a new generic flat Entry |
|
Entry(boolean domEnabled)
Creates a new instance. |
|
Entry(java.util.Hashtable table)
Deprecated. will be remove in a future release. |
Method Summary | |
---|---|
void |
addAttributeValue(java.lang.Object name,
java.lang.Object value)
Deprecated. use addAttributeValue(String, Object) instead. |
void |
addAttributeValue(java.lang.Object name,
java.lang.Object value,
int op)
Deprecated. use addAttributeValue(String, Object, int) instead. |
void |
addAttributeValue(java.lang.String name,
java.lang.Object value)
Adds a value to an attribute. |
void |
addAttributeValue(java.lang.String name,
java.lang.Object value,
int op)
Adds a value to an attribute. |
org.w3c.dom.Node |
adoptNode(org.w3c.dom.Node source)
This method adopts the provided as parameter Node by setting its parent to null and setting the document reference to this entry object. |
Attribute |
appendChild(org.w3c.dom.Node newChild)
This will add the provided Attribute in the entry using the localName of that Attribute for a key name. |
Entry |
clone()
Creates a shallow clone of the receiver. |
Entry |
clone(Entry entry)
Deprecated. use the clone() method instead |
Entry |
cloneNode(boolean deep)
Clones this entry object |
Property |
createAttribute(java.lang.String name)
This method creates a new Property object that represents an element's attribute in terms of DOM concepts. |
Property |
createAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
This method creates new Property object that represents an element's attribute in terms of XML concepts. |
org.w3c.dom.CDATASection |
createCDATASection(java.lang.String data)
Creates new AttributeCDATA object that represents a CDATASection in terms of XML concepts. |
Attribute |
createElement(java.lang.String tagName)
This method creates new Attribute object that represents an element in terms of XML concepts. |
Attribute |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
This method creates new Attribute object that represents an element in terms of XML concepts. |
org.w3c.dom.Text |
createTextNode(java.lang.String data)
Creates new AttributeText object that represents a Text section in terms of XML concepts. |
void |
enableDOM()
This method changes the entry from pre-TDI7.0 flat structure to a hierarchical one. |
Attribute |
get(java.lang.Object p1)
Deprecated. use getAttribute(String) instead. |
Attribute |
getAttribute(java.lang.Object p1)
Deprecated. use getAttribute(String) instead. |
Attribute |
getAttribute(java.lang.String name)
Returns the Attribute object for a named attribute. |
java.util.Collection<java.lang.String> |
getAttributeCollection()
Returns a java.util.Collection containing attribute names in this entry. |
java.lang.String[] |
getAttributeNames()
Returns an array of strings containing attribute names in this entry. |
java.lang.Boolean |
getBooleanValue(java.lang.String xPath)
Execute an XPath expression and get the result as an Boolean * |
org.w3c.dom.NodeList |
getChildNodes()
Returns list of all children of the specified Node; |
Attribute |
getDocumentElement()
|
org.w3c.dom.NodeList |
getElementsByTagName(java.lang.String tagname)
Recursively searches for children with the specified tag name. |
org.w3c.dom.NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
Recursively searches for children that belong to the specified namespaceURI and have the specific localName. |
Attribute |
getFirstAttribute(java.lang.String xPath)
Execute an XPath expression and get the result as an Attribite * |
Attribute |
getFirstChild()
Retrieves the first child, that is, the first Attribute object inserted in the Entry |
Attribute |
getLastChild()
Retrieves the last child, that is, the last Attribute object inserted in the Entry |
org.w3c.dom.NodeList |
getNodeList(java.lang.String xPath)
Execute an XPath expression and get the result as an NodeList |
java.lang.Number |
getNumberValue(java.lang.String xPath)
Execute an XPath expression and get the result as an Number * |
java.lang.Object |
getObject(java.lang.Object p1)
Deprecated. use getObject(String) instead. |
java.lang.Object |
getObject(java.lang.String p1)
Returns the first value in an attribute as an object. |
char |
getOp()
Returns the operation field of this entry. |
java.lang.String |
getOperation()
Returns the operation field of this Entry. |
java.lang.Object |
getProperty(java.lang.Object propertyName)
Deprecated. use getProperty(String) instead. |
java.lang.Object |
getProperty(java.lang.String propertyName)
Returns a property value. |
java.lang.String[] |
getPropertyNames()
Returns a string array of the property names contained in this entry. |
java.lang.String |
getString(java.lang.Object p1)
Deprecated. use getString(String) instead. |
java.lang.String |
getString(java.lang.String p1)
Returns the first value in an attribute as a String. |
java.lang.String |
getStringValue(java.lang.String xPath)
Execute an XPath expression and get the result as an String * |
boolean |
hasChildNodes()
|
boolean |
hasProperty(java.lang.String propertyName)
Returns true if a property named by the propertyName parameter has a value. |
Attribute |
insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
If the refChild is not presented in the entry structure or
is null then the newChild will be appended to the end. |
protected void |
invalidateNamesList()
Raises the flag that means the tree have been updated to tell the Entry to clear its catches. |
boolean |
isDOMEnabled()
|
boolean |
isEqualNode(org.w3c.dom.Node other)
|
void |
merge(Entry e)
Convenience method that calls merge ( e, false ). |
void |
merge(Entry e,
boolean mergevalues)
Merges in the attributes and their values from another entry. |
void |
mergeAttributeValue(Attribute attr)
Merges in the values from an attribute. |
void |
mergeAttributeValue(java.lang.Object name,
AttributeInterface attr)
Deprecated. use mergeAttributeValue(String, Attribute) instead. |
void |
mergeAttributeValue(java.lang.String name,
Attribute attr)
Merges the values in one attribute with the values from another attribute. |
Attribute |
newAttribute(java.lang.String name)
This method is used to find/create an Attribute in the entry using the specified name. |
Attribute |
newAttribute(java.lang.String name,
char oper)
Returns an Attribute object from this entry's list of attributes. |
void |
removeAllAttributes()
Removes all attributes from this Entry. |
void |
removeAttribute(java.lang.Object p1)
Deprecated. use removeAttribute(String) instead. |
void |
removeAttribute(java.lang.String name)
Removes an attribute from this Entry's list of attributes. |
Attribute |
removeChild(org.w3c.dom.Node oldChild)
This method will remove the provided Attribute from the Entry. |
org.w3c.dom.Node |
renameNode(org.w3c.dom.Node n,
java.lang.String namespaceURI,
java.lang.String qualifiedName)
Renames the node. |
Attribute |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
This method will search the entry structure for the oldChild and will replace it with the newChild. |
void |
set(AttributeInterface attr)
Deprecated. Use setAttribute instead |
void |
setAttribute(Attribute attr)
Adds or replaces an attribute in this Entry's list of attributes. |
void |
setAttribute(AttributeInterface attr)
Deprecated. will be removed in future releases! Use setAttribute(Attribute) instead. |
void |
setAttribute(java.lang.Object name,
java.lang.Object value)
Deprecated. use setAttribute(String, Object) instead. |
void |
setAttribute(java.lang.Object name,
java.lang.Object value,
boolean protect)
Deprecated. use setAttribute(String, Object, boolean) instead. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Adds or replaces an attribute in this Entry's list of attributes. |
void |
setAttribute(java.lang.String name,
java.lang.Object value,
boolean protect)
Calls setAttribute(String, Object) but additionally uses the
protect argument to set the attribute as protected or not. |
void |
setAttributeValues(java.lang.String name,
java.lang.Object values)
This method creates a new attribute with the specified name and values and add it to the entry. |
void |
setOp(char operation)
Sets the operation code for this Entry. |
void |
setOperation(java.lang.String operation)
Sets the operation code for this Entry. |
void |
setProperty(java.lang.Object propertyName,
java.lang.Object propertyValue)
Deprecated. use setProperty(String, Object) insetad. |
void |
setProperty(java.lang.String propertyName,
java.lang.Object propertyValue)
Sets/replaces a property. |
int |
size()
Returns the number of attributes present in this entry. |
java.lang.String |
toDeltaString()
Returns a string representation of this entry, including delta information. |
java.lang.String |
toString()
Returns a string representation of this entry. |
java.lang.String |
toXML()
Returns a XML representation of this Entry object. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final char OP_ADD
public static final java.lang.String OP_ADD2
OP_ADD
field.
public static final char OP_MOD
public static final java.lang.String OP_MOD2
OP_MOD
field.
public static final char OP_DEL
public static final java.lang.String OP_DEL2
OP_DEL
field.
public static final char OP_UNCHANGED
public static final java.lang.String OP_UNCHANGED2
OP_UNCHANGED
field.
public static final char OP_GEN
public static final java.lang.String OP_GEN2
OP_GEN
field.
public static final char PATH_SEPARATOR_CHAR
public static final java.lang.String PATH_SEPARATOR_STR
PATH_SEPARATOR_CHAR
field.
public static final char ESCAPE_CHAR
Constructor Detail |
---|
public Entry()
public Entry(boolean domEnabled)
domEnabled
- specifies whether the created entry will be hierarchical or a
flat one. If the entry is not required to be hierarchical use
false here and it will be made hierarchical on demand if a
method from the DOM API is called.@Deprecated public Entry(java.util.Hashtable table)
table
- - a Hashtable representation of theMethod Detail |
---|
@Deprecated public Entry clone(Entry entry)
clone()
method instead
entry
- The Entry object to clone
public Entry clone()
clone
in class java.lang.Object
public char getOp()
public void setOp(char operation)
operation
- The operation codepublic java.lang.String getOperation()
public void setOperation(java.lang.String operation)
operation
- The operation code as a Stringpublic void set(AttributeInterface attr)
attr
- An Attribute object@Deprecated public void setAttribute(AttributeInterface attr)
setAttribute(Attribute)
instead.
attr
- An Attribute objectpublic void setAttribute(Attribute attr)
This will replace the attribute already mapped with the same key name (if
any).
Here are examples setting "plain" attributes.
Example with "plain" attributes:
ocAttr = system.newAttribute("objectClass"); ocAttr.addValue("top"); ocAttr.addValue("person"); ocAttr.addValue("organizationalPerson"); ocAttr.addValue("inetOrgPerson"); modentry.setAttribute(ocAttr);If there was an attribute named "objectClass" in the modentry then it would have been replaced by the newly created one.
attr
- An Attribute object if this parameter is null
then the call is ignored.@Deprecated public void setAttribute(java.lang.Object name, java.lang.Object value)
setAttribute(String, Object)
instead.
name
- The attribute namevalue
- The attribute value. If this parameter is null, then
the attribute is removed.public void setAttribute(java.lang.String name, java.lang.Object value)
name
- The name of the Attribute to use as a key name for the
mapping. If null
the call is ignored.value
- The attribute value. If this parameter is null, then
the attribute is removed.setAttribute(Attribute)
@Deprecated public void setAttribute(java.lang.Object name, java.lang.Object value, boolean protect)
setAttribute(String, Object, boolean)
instead.
name
- The attribute namevalue
- The attribute value. If this parameter is null, then
the attribute is removed.protect
- If this parameter is true, do not dump the Attribute values in
log filespublic void setAttribute(java.lang.String name, java.lang.Object value, boolean protect)
setAttribute(String, Object)
but additionally uses the
protect
argument to set the attribute as protected or not.
Note that the protection is set only on the attribute's level for a deep
protection use:
work.getAttribute(name).setProtected(true, true);
name
- The name of the Attribute to use as a key name for the
mapping.value
- The attribute value. If this parameter is null, then
the attribute is removed.protect
- If this parameter is true, do not dump the Attribute's values
in the log files.setAttribute(String, Object)
public void setAttributeValues(java.lang.String name, java.lang.Object values)
values
parameter is an
Attribute
then that Attribute's values are added to the new
Attribute. If the values
parameter is a List
then
its elements are added as values to the new Attribute. If any of the
elements are Attributes then the values of those attributes are also
added to the new Attribute, the element attributes however are not.
name
- The name of the Attribute to use as a key name for the
mapping.values
- The attribute values. If this parameter is null, then
the attribute is removed.setAttribute(Attribute)
public Attribute newAttribute(java.lang.String name)
Entry |---a |---b | |---c | |---b |---c |---dThen the method will start from the root (the Entry) and will firstly search for an Attribute called a. If the Attribute on the entry level does not exists it is automatically created and added to the entry. Then a search for a child of a with the name b is made. If that child is not found then it is created as well. In our case the first c is found on the next step and then searched for a child named d. No such child is found and therefore it is created.
NodeImpl.getParentNode()
.
name
- the composite of names to use when creating/navigating the
Attributes chain.
public Attribute newAttribute(java.lang.String name, char oper)
name
- The attribute name to create/returnoper
- The new Attribute's operation code. Only used if creating a
new Attribute.
@Deprecated public void addAttributeValue(java.lang.Object name, java.lang.Object value)
addAttributeValue(String, Object)
instead.
name
- The attribute namevalue
- The value to appendpublic void addAttributeValue(java.lang.String name, java.lang.Object value)
name
- The attribute namevalue
- The value to append@Deprecated public void addAttributeValue(java.lang.Object name, java.lang.Object value, int op)
addAttributeValue(String, Object, int)
instead.
name
- The attribute namevalue
- The value to appendop
- The attribute value operation, AV_UNCHANGED = 0, AV_ADD = 1,
AV_DELETE = 2public void addAttributeValue(java.lang.String name, java.lang.Object value, int op)
name
- The attribute namevalue
- The value to appendop
- The attribute value operation, AV_UNCHANGED = 0, AV_ADD = 1,
AV_DELETE = 2@Deprecated public void mergeAttributeValue(java.lang.Object name, AttributeInterface attr)
mergeAttributeValue(String, Attribute)
instead.
name
- The name of the attribute into which values are mergedattr
- The attribute (e.g. entry.getAttribute("xxx")) from which
values are collectedpublic void mergeAttributeValue(java.lang.String name, Attribute attr)
attr
are added, even if they
already exist.
name
- The name of the attribute into which values are merged. If
this parameter is null the call is ignored.attr
- The attribute (e.g. entry.getAttribute("xxx")) from which
values are collected.public void mergeAttributeValue(Attribute attr)
attr
- The attribute (e.g. entry.getAttribute("xxx")) from which we
get the name and values@Deprecated public Attribute get(java.lang.Object p1)
getAttribute(String)
instead.
p1
- The attribute name
@Deprecated public Attribute getAttribute(java.lang.Object p1)
getAttribute(String)
instead.
p1
- The attribute name
public Attribute getAttribute(java.lang.String name)
name
- The attribute name
public java.lang.String[] getAttributeNames()
public java.util.Collection<java.lang.String> getAttributeCollection()
@Deprecated public java.lang.String getString(java.lang.Object p1)
getString(String)
instead.
p1
- The attribute name
public java.lang.String getString(java.lang.String p1)
p1
- The attribute name
@Deprecated public java.lang.Object getObject(java.lang.Object p1)
getObject(String)
instead.
p1
- The attribute name
public java.lang.Object getObject(java.lang.String p1)
p1
- The attribute name
@Deprecated public void removeAttribute(java.lang.Object p1)
removeAttribute(String)
instead.
p1
- The name of the attribute to removepublic void removeAttribute(java.lang.String name)
getAttribute(String)
method. If there is another attribute
which is not mapped to this Entry it will not be removed by a subsequent
call. To remove such Attributes use the provided DOM API.
entry.removeAttribute("first.second");
when there is an
attribute called "first.second.third") will not really remove that
attribute from the tree. That attribute will only be cleared. This is
done for optimization reasons. Once removed that attribute will not show
in the array returned by getAttributeNames()
method. However
that Attribute will still be accessible through the DOM API.
name
- The name of the attribute to removepublic void removeAllAttributes()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toDeltaString()
@Deprecated public java.lang.Object getProperty(java.lang.Object propertyName)
getProperty(String)
instead.
propertyName
- The name of the property
public java.lang.Object getProperty(java.lang.String propertyName)
propertyName
- The name of the property
@Deprecated public void setProperty(java.lang.Object propertyName, java.lang.Object propertyValue)
setProperty(String, Object)
insetad.
propertyName
- The name of the propertypropertyValue
- The named property's valuepublic void setProperty(java.lang.String propertyName, java.lang.Object propertyValue)
propertyName
- The name of the propertypropertyValue
- The named property's valuepublic boolean hasProperty(java.lang.String propertyName)
public java.lang.String[] getPropertyNames()
public void merge(Entry e)
e
- The entry from which attributes are collectedpublic void merge(Entry e, boolean mergevalues)
Example: This entry contains these attributes Name Values a 1 b 1, 2 The other entry contains these attributes Name Values b 3 c 4 After the merge, mergevalues=FALSE, this entry will contain Name Values a 1 b 3 c 4 After the merge, mergevalues=TRUE, this entry will contain Name Values a 1 b 1, 2, 3 c 4
e
- The entry from which attributes are collectedmergevalues
- if false replace values, if true add valuesprotected void invalidateNamesList()
public boolean isDOMEnabled()
true
if this entry is storing the information as DOM
tree. If the entry has a pre-TDI 7.0 flat structure this method
returns false
.public void enableDOM()
getChildNodes()
.
public org.w3c.dom.NodeList getNodeList(java.lang.String xPath) throws javax.xml.xpath.XPathExpressionException
xPath
- the XPath expression
javax.xml.xpath.XPathExpressionException
- in case an invalid expression is passedpublic Attribute getFirstAttribute(java.lang.String xPath) throws javax.xml.xpath.XPathExpressionException
xPath
- the XPath expression
javax.xml.xpath.XPathExpressionException
- in case an invalid expression is passedpublic java.lang.String getStringValue(java.lang.String xPath) throws javax.xml.xpath.XPathExpressionException
xPath
- the XPath expression
javax.xml.xpath.XPathExpressionException
- in case an invalid expression is passedpublic java.lang.Number getNumberValue(java.lang.String xPath) throws javax.xml.xpath.XPathExpressionException
xPath
- the XPath expression
javax.xml.xpath.XPathExpressionException
- in case an invalid expression is passedpublic java.lang.Boolean getBooleanValue(java.lang.String xPath) throws javax.xml.xpath.XPathExpressionException
xPath
- the XPath expression
javax.xml.xpath.XPathExpressionException
- in case an invalid expression is passedpublic java.lang.String toXML()
public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws DOMException
adoptNode
in interface org.w3c.dom.Document
source
- the Node which parents to change.
DOMException
- in case the Node is not an instance of the NodeImpl class.public Property createAttribute(java.lang.String name) throws DOMException
This method implements org.w3c.dom.Document's createAttribute method and
only creates a new Property but not set it on an Attribute object. This
means that until you call Attribute.setAttributeNode(Attr)
with
the newly created Property object it will not be visible trough
Attribute's methods like getAttribute(String), getAttributes(), etc.
Example:
var entry = system.newEntry(); var hattr1 = entry.createElement("mother"); entry.appendChild(hattr1); var attr = entry.createAttribute("name"); var attr1 = entry.createAttribute("age"); var attr2 = entry.createAttribute("work"); attr1.setValue("33"); attr2.setValue("IBM Corporation"); attr.setValue("Marina"); hattr1.setAttributeNode(attr1); hattr1.setAttributeNode(attr2); //if we call hattr1.toString(); attribute 'name' will not be displayedDoes not make the Entry hierarchical.
createAttribute
in interface org.w3c.dom.Document
name
- - the name of the new Property
DOMException
- - in case an error occurs while creating the PropertycreateAttributeNS(String, String)
public Property createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws DOMException
qualifiedName
, namespaceURI:
namespaceURI
and nodeValue: null
.
This method implements org.w3c.dom.Document's createAttributeNS method
and only creates a new Property but not set it on Attribute object. This
means that until you call Attribute.setAttributeNode(Attr)
with
the newly created Property object it will not be visible trough the
Attribute's methods like getAttribute(String), getAttributes(), etc.
Example:
var entry = system.newEntry(); var hattr1 = entry.createElement("mother"); var hattr2 = entry.createElement("son"); entry.appendChild(hattr1); entry.appendChild(hattr2); var attr = entry.createAttribute("general", "name"); var attr1 = entry.createAttribute("personal", "age"); var attr2 = entry.createAttributeNS("occupation", "work"); attr.setValue("Marina"); attr1.setValue("33"); attr2.setValue("IBM Corporation"); hattr1.setAttributeNode(attr1); hattr1.setAttributeNode(attr2); //if we call hattr1.toString() attribute 'name' will not be displayedDoes not make the Entry hierarchical.
createAttributeNS
in interface org.w3c.dom.Document
namespaceURI
- - the namespace this Property belongs toqualifiedName
- - the name of the new Property, this could be in the format
prefix:localName
DOMException
- - in case an error occurs while creating the Propertypublic Attribute createElement(java.lang.String tagName) throws DOMException
Example:
var entry = system.newEntry(); entry.setAttribute("type", "family"); var hattr1 = entry.createElement("mother"); var hattr2 = entry.createElement("daughter"); var hattr3 = entry.createElement("son"); hattr1.appendChild(hattr2); hattr1.appendChild(hattr3); entry.appendChild(hattr1); task.dumpEntry(entry);Does not make the Entry hierarchical.
createElement
in interface org.w3c.dom.Document
tagName
- - the name this Attribute will have, any special characters
will be escaped prior to creating the Attribute.
DOMException
- - in case an error occurs while creating the Attributepublic Attribute createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName) throws DOMException
Here is an example of how to create elements with specified namespace, add them to some entry as children and print the results.
Example:
var entry = system.newEntry(); var hattr1 = entry.createElementNS("adult", "mother"); var hattr2 = entry.createElementNS("youth", "daughter"); var hattr3 = entry.createElementNS("youth", "son"); entry.appendChild(hattr1); entry.appendChild(hattr2); entry.appendChild(hattr3); var list = entry.getChildNodes(); for (i = 0; i < list.getLength(); i++) { task.logmsg("\tName: " + list.item(i).getNodeName()); task.logmsg("\tNS: " + list.item(i).getNamespaceURI()); }Does not make the Entry hierarchical.
createElementNS
in interface org.w3c.dom.Document
namespaceURI
- - the namespace this element will belong toqualifiedName
- - the name of the new Attribute, this could be in the format
prefix:localName. Any special characters will be escaped prior
to creating the Attribute.
DOMException
- - in case an error occurs while creating the Attributepublic org.w3c.dom.CDATASection createCDATASection(java.lang.String data) throws DOMException
createCDATASection
in interface org.w3c.dom.Document
data
- - the data this AttributeCDATA will contain
DOMException
- - in case an error occurs while creating the
AttributeCDATApublic org.w3c.dom.Text createTextNode(java.lang.String data)
createTextNode
in interface org.w3c.dom.Document
data
- - the data this AttributeText will contain
public Attribute getDocumentElement()
getDocumentElement
in interface org.w3c.dom.Document
public org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagname)
getElementsByTagName
in interface org.w3c.dom.Document
tagname
- - the search criteria
public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
getElementsByTagNameNS
in interface org.w3c.dom.Document
namespaceURI
- - the namespace the child should belong tolocalName
- - the name the child should have
public org.w3c.dom.Node renameNode(org.w3c.dom.Node n, java.lang.String namespaceURI, java.lang.String qualifiedName) throws DOMException
renameNode
in interface org.w3c.dom.Document
n
- - this methods accepts objects of type Attribute or type
PropertynamespaceURI
- - the new namespace that should be setqualifiedName
- - the new name this node should have, this name is the one
that later will be returned by Node.getNodeName()
DOMException
- if the n object is not of type Attribute or Property. If the
n object is a Property but the specified prefix has not been
declared previously.public Attribute appendChild(org.w3c.dom.Node newChild) throws DOMException
setAttribute(String, Object)
method instead if you want
to force a replacement of the existing Attribute.
Example:
var entry = system.newEntry(); entry.setAttribute("type", "family"); var hattr1 = entry.createElement("mother"); var hattr2 = entry.createElement("daughter"); var hattr3 = entry.createElement("son"); hattr1.appendChild(hattr1); hattr1.appendChild(hattr2); hattr1.appendChild(hattr3); entry.appendChild(hattr1); task.dumpEntry(entry);
appendChild
in interface org.w3c.dom.Node
newChild
- - Object that is an instance of the Attribute class. This
object will be added in the Entry if its local name does not
already exist in the key names set.
DOMException
- - in case the newChild parameter is not an instance of the
Attribute class or if an Attribute is already mapped with
that key name.public org.w3c.dom.NodeList getChildNodes()
Here is an example of how to print entry's all children name and NS.
Example:
var list = entry.getChildNodes(); for (i = 0; i < list.getLength(); i++) { task.logmsg("\tName: " + list.item(i).getNodeName()); task.logmsg("\tNS: " + list.item(i).getNamespaceURI()); } task.dumpEntry(entry);
getChildNodes
in interface org.w3c.dom.Node
public Attribute getFirstChild()
getFirstChild
in interface org.w3c.dom.Node
public Attribute getLastChild()
getLastChild
in interface org.w3c.dom.Node
public boolean hasChildNodes()
hasChildNodes
in interface org.w3c.dom.Node
public Attribute insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException
refChild
is not presented in the entry structure or
is null then the newChild
will be appended to the end. This
method will replace any existing Attribute that are already mapped under
a name which is equal to newChild
's localName.
insertBefore
in interface org.w3c.dom.Node
newChild
- the Attribute that is going to be insertedrefChild
- the Attribute which position will shift down
refChild
DOMException
- if the newChild
and the refChild
are not Attribute instancespublic Attribute removeChild(org.w3c.dom.Node oldChild) throws DOMException
removeChild
in interface org.w3c.dom.Node
oldChild
- - the Attribute that should be removed from the entry object
DOMException
- if the oldChild is not an instance of Attribute#removeAttribute(boolean, String)
public Attribute replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws DOMException
replaceChild
in interface org.w3c.dom.Node
newChild
- the Attribute that is going to be addedoldChild
- the Attribute which will be removed
DOMException
- if both of the parameters are not instances of the
Attribute classpublic boolean isEqualNode(org.w3c.dom.Node other)
isEqualNode
in interface org.w3c.dom.Node
public Entry cloneNode(boolean deep)
cloneNode
in interface org.w3c.dom.Node
deep
- if true a complete clone of the tree will be created (the
values are not cloned!). If false is specified the Attributes
of this entry are not cloned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |