本文整理匯總了Java中org.w3c.dom.Node.ENTITY_NODE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Node.ENTITY_NODE屬性的具體用法?Java Node.ENTITY_NODE怎麽用?Java Node.ENTITY_NODE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.ENTITY_NODE屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isLegalContainer
/**
* Returns true IFF the given node can serve as a container
* for a range's boundary points.
*/
private boolean isLegalContainer( Node node )
{
if ( node==null )
return false;
while( node!=null )
{
switch( node.getNodeType() )
{
case Node.ENTITY_NODE:
case Node.NOTATION_NODE:
case Node.DOCUMENT_TYPE_NODE:
return false;
}
node = node.getParentNode();
}
return true;
}
示例2: isLegalContainedNode
/**
* Returns true IFF the given node can be contained by
* a range.
*/
private boolean isLegalContainedNode( Node node )
{
if ( node==null )
return false;
switch( node.getNodeType() )
{
case Node.DOCUMENT_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.ATTRIBUTE_NODE:
case Node.ENTITY_NODE:
case Node.NOTATION_NODE:
return false;
}
return true;
}
示例3: getNodeTypeFromCode
private String getNodeTypeFromCode(short code) {
String retval = null;
switch (code) {
case Node.ATTRIBUTE_NODE :
retval = "ATTRIBUTE_NODE"; break;
case Node.CDATA_SECTION_NODE :
retval = "CDATA_SECTION_NODE"; break;
case Node.COMMENT_NODE :
retval = "COMMENT_NODE"; break;
case Node.DOCUMENT_FRAGMENT_NODE :
retval = "DOCUMENT_FRAGMENT_NODE"; break;
case Node.DOCUMENT_NODE :
retval = "DOCUMENT_NODE"; break;
case Node.DOCUMENT_TYPE_NODE :
retval = "DOCUMENT_TYPE_NODE"; break;
case Node.ELEMENT_NODE :
retval = "ELEMENT_NODE"; break;
case Node.ENTITY_NODE :
retval = "ENTITY_NODE"; break;
case Node.ENTITY_REFERENCE_NODE :
retval = "ENTITY_REFERENCE_NODE"; break;
case Node.NOTATION_NODE :
retval = "NOTATION_NODE"; break;
case Node.PROCESSING_INSTRUCTION_NODE :
retval = "PROCESSING_INSTRUCTION_NODE"; break;
case Node.TEXT_NODE:
retval = "TEXT_NODE"; break;
}
return retval;
}
示例4: print
public void print(Node node) throws XMLStreamException {
switch (node.getNodeType()) {
case Node.DOCUMENT_NODE:
visitDocument((Document) node);
break;
case Node.DOCUMENT_FRAGMENT_NODE:
visitDocumentFragment((DocumentFragment) node);
break;
case Node.ELEMENT_NODE:
visitElement((Element) node);
break;
case Node.TEXT_NODE:
visitText((Text) node);
break;
case Node.CDATA_SECTION_NODE:
visitCDATASection((CDATASection) node);
break;
case Node.PROCESSING_INSTRUCTION_NODE:
visitProcessingInstruction((ProcessingInstruction) node);
break;
case Node.ENTITY_REFERENCE_NODE:
visitReference((EntityReference) node);
break;
case Node.COMMENT_NODE:
visitComment((Comment) node);
break;
case Node.DOCUMENT_TYPE_NODE:
break;
case Node.ATTRIBUTE_NODE:
case Node.ENTITY_NODE:
default:
throw new XMLStreamException("Unexpected DOM Node Type "
+ node.getNodeType()
);
}
}
示例5: addNodeInTree
/**
* Adds a node in the visual tree. This method is used by the @see fillDomTree method
*
* @param parent the parent (Can be the tree or a parent TreeItem)
* @param node the node to be added
*/
public boolean addNodeInTree(Object parent, Node node, IProgressMonitor monitor) {
TreeItem tItem = (TreeItem) parent;
String[] values = new String[2];
tItem.setData(node);
// calc the node text according to the node type
switch (node.getNodeType()) {
case Node.ELEMENT_NODE :
int dec = 0;
if (node.hasAttributes()) {// add a fake first node for 'Attributes' item
tItem.setData("dec", new Integer(dec = 1));
}
Node[] childs = XMLUtils.toNodeArray(node.getChildNodes());
tItem.setData("childs", childs);
tItem.setItemCount(childs.length + dec);
values[0] = node.getNodeName();
values[1] = getTextValue(node);
tItem.setText(values);
tItem.setImage(imageNode);
break;
case Node.TEXT_NODE :
tItem.setImage(imageText);
tItem.setText(node.getNodeValue().trim());
break;
case Node.ATTRIBUTE_NODE:
tItem.setImage(imageAttrib);
String str = node.getNodeName() + "=\"" + node.getNodeValue() + "\"";
tItem.setText(new String[] {str, str});
break;
case Node.ENTITY_NODE:
tItem.setText("[Entity]");
break;
case Node.ENTITY_REFERENCE_NODE :
tItem.setText("[Entityref]");
break;
case Node.PROCESSING_INSTRUCTION_NODE :
tItem.setText("[Pi]");
break;
case Node.COMMENT_NODE :
tItem.setText("[Comment]");
break;
case Node.DOCUMENT_FRAGMENT_NODE :
tItem.setText("[Docfgmt]");
break;
case Node.DOCUMENT_TYPE_NODE :
tItem.setText("[Doctype]");
break;
case Node.NOTATION_NODE :
tItem.setText("[Notation]");
break;
default: break;
}
return true;
}
示例6: addNodeInTree
private void addNodeInTree(Node node, Document document, Element parent) {
Element currentElement = createElement(document, node);
currentElement.setAttribute("type", Short.toString(node.getNodeType()));
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
currentElement.setAttribute("text", node.getNodeName());
NamedNodeMap map = node.getAttributes();
if (node.hasAttributes()) {
Element attributes = createElement(document, node, false);
attributes.setAttribute("text", "Attributes");
attributes.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
currentElement.appendChild(attributes);
for (int i = 0; i < map.getLength(); ++i) {
Element attribute = createElement(document, map.item(i));
attribute.setAttribute("text", map.item(i).getNodeName() + "=\"" + map.item(i).getNodeValue() + "\"");
attribute.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
attributes.appendChild(attribute);
}
}
break;
case Node.TEXT_NODE:
currentElement.setAttribute("text", node.getNodeValue() == null ? "" : node.getNodeValue().trim());
break;
case Node.ENTITY_NODE:
currentElement.setAttribute("text", "[Entity]");
break;
case Node.ENTITY_REFERENCE_NODE:
currentElement.setAttribute("text", "[Entityref]");
break;
case Node.PROCESSING_INSTRUCTION_NODE:
currentElement.setAttribute("text", "[Pi]");
break;
case Node.COMMENT_NODE:
currentElement.setAttribute("text", "[Comment]");
break;
case Node.DOCUMENT_FRAGMENT_NODE:
currentElement.setAttribute("text", "[Docfgmt]");
break;
case Node.DOCUMENT_TYPE_NODE:
currentElement.setAttribute("text", "[Doctype]");
break;
case Node.NOTATION_NODE:
currentElement.setAttribute("text", "[Notation]");
break;
default:
break;
}
parent.appendChild(currentElement);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node currentNode = nodeList.item(i);
addNodeInTree(currentNode, document, currentElement);
}
}
示例7: addNodeInTree2
private static void addNodeInTree2(Node node, Document document, Element parent, int [] index) {
Element currentElement = createElement2(document, node, index);
currentElement.setAttribute("type", Short.toString(node.getNodeType()));
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
currentElement.setAttribute("text", node.getNodeName());
NamedNodeMap map = node.getAttributes();
if (node.hasAttributes()) {
Element attributes = createElement2(document, node, index);
attributes.setAttribute("text", "Attributes");
attributes.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
currentElement.appendChild(attributes);
for (int i = 0; i < map.getLength(); ++i) {
Element attribute = createElement2(document, map.item(i), index);
attribute.setAttribute("text", map.item(i).getNodeName() + "=\"" + map.item(i).getNodeValue() + "\"");
attribute.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
attributes.appendChild(attribute);
}
}
break;
case Node.TEXT_NODE:
currentElement.setAttribute("text", node.getNodeValue() == null ? "" : node.getNodeValue().trim());
break;
case Node.ENTITY_NODE:
currentElement.setAttribute("text", "[Entity]");
break;
case Node.ENTITY_REFERENCE_NODE:
currentElement.setAttribute("text", "[Entityref]");
break;
case Node.PROCESSING_INSTRUCTION_NODE:
currentElement.setAttribute("text", "[Pi]");
break;
case Node.COMMENT_NODE:
currentElement.setAttribute("text", "[Comment]");
break;
case Node.DOCUMENT_FRAGMENT_NODE:
currentElement.setAttribute("text", "[Docfgmt]");
break;
case Node.DOCUMENT_TYPE_NODE:
currentElement.setAttribute("text", "[Doctype]");
break;
case Node.NOTATION_NODE:
currentElement.setAttribute("text", "[Notation]");
break;
default:
break;
}
parent.appendChild(currentElement);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node currentNode = nodeList.item(i);
addNodeInTree2(currentNode, document, currentElement, index);
}
}
示例8: lookupPrefix
/**
*
* DOM Level 3
* Look up the prefix associated to the given namespace URI, starting from this node.
*
* @param namespaceURI
* @return the prefix for the namespace
*/
@Override
public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true
// Prefix can't be bound to null namespace
if (namespaceURI == null) {
return null;
}
short type = this.getNodeType();
switch (type) {
/*
case Node.ELEMENT_NODE: {
String namespace = this.getNamespaceURI(); // to flip out children
return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
}
case Node.DOCUMENT_NODE:{
return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
}
*/
case Node.ENTITY_NODE :
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
// type is unknown
return null;
case Node.ATTRIBUTE_NODE:{
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
}
return null;
}
default:{
/*
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.lookupPrefix(namespaceURI);
}
*/
return null;
}
}
}
示例9: lookupPrefix
/**
*
* DOM Level 3 - Experimental:
* Look up the prefix associated to the given namespace URI, starting from this node.
*
* @param namespaceURI
* @return the prefix for the namespace
*/
public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true
// Prefix can't be bound to null namespace
if (namespaceURI == null) {
return null;
}
short type = this.getNodeType();
switch (type) {
case Node.ELEMENT_NODE: {
String namespace = this.getNamespaceURI(); // to flip out children
return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
}
case Node.DOCUMENT_NODE:{
return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
}
case Node.ENTITY_NODE :
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
// type is unknown
return null;
case Node.ATTRIBUTE_NODE:{
if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
return ownerNode.lookupPrefix(namespaceURI);
}
return null;
}
default:{
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.lookupPrefix(namespaceURI);
}
return null;
}
}
}
示例10: surroundContents
public void surroundContents(Node newParent)
throws DOMException, RangeException
{
if (newParent==null) return;
int type = newParent.getNodeType();
if (fDocument.errorChecking) {
if (fDetach) {
throw new DOMException(
DOMException.INVALID_STATE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
}
if (type == Node.ATTRIBUTE_NODE
|| type == Node.ENTITY_NODE
|| type == Node.NOTATION_NODE
|| type == Node.DOCUMENT_TYPE_NODE
|| type == Node.DOCUMENT_NODE
|| type == Node.DOCUMENT_FRAGMENT_NODE)
{
throw new RangeExceptionImpl(
RangeException.INVALID_NODE_TYPE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
}
}
Node realStart = fStartContainer;
Node realEnd = fEndContainer;
if (fStartContainer.getNodeType() == Node.TEXT_NODE) {
realStart = fStartContainer.getParentNode();
}
if (fEndContainer.getNodeType() == Node.TEXT_NODE) {
realEnd = fEndContainer.getParentNode();
}
if (realStart != realEnd) {
throw new RangeExceptionImpl(
RangeException.BAD_BOUNDARYPOINTS_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "BAD_BOUNDARYPOINTS_ERR", null));
}
DocumentFragment frag = extractContents();
insertNode(newParent);
newParent.appendChild(frag);
selectNode(newParent);
}
示例11: lookupPrefix
/**
*
* DOM Level 3 - Experimental:
* Look up the prefix associated to the given namespace URI, starting from this node.
*
* @param namespaceURI
* @return the prefix for the namespace
*/
public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true
// Prefix can't be bound to null namespace
if (namespaceURI == null) {
return null;
}
short type = this.getNodeType();
switch (type) {
/*
case Node.ELEMENT_NODE: {
String namespace = this.getNamespaceURI(); // to flip out children
return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
}
case Node.DOCUMENT_NODE:{
return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
}
*/
case Node.ENTITY_NODE :
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
// type is unknown
return null;
case Node.ATTRIBUTE_NODE:{
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
}
return null;
}
default:{
/*
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.lookupPrefix(namespaceURI);
}
*/
return null;
}
}
}
示例12: getNodeType
/**
* A short integer indicating what type of node this is. The named
* constants for this value are defined in the org.w3c.dom.Node interface.
*/
public short getNodeType() {
return Node.ENTITY_NODE;
}