當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityReference類代碼示例

本文整理匯總了Java中org.w3c.dom.EntityReference的典型用法代碼示例。如果您正苦於以下問題:Java EntityReference類的具體用法?Java EntityReference怎麽用?Java EntityReference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityReference類屬於org.w3c.dom包,在下文中一共展示了EntityReference類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getText

import org.w3c.dom.EntityReference; //導入依賴的package包/類
/**
 * Extract the textual content from a Node.
 * This is rather like the XPath value of a Node.
 * @param node The node to extract the text from
 * @return The textual value of the node
 */
public static String getText(Node node)
{
    StringBuffer reply = new StringBuffer();

    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
        Node child = children.item(i);

        if ((child instanceof CharacterData && !(child instanceof Comment)) || child instanceof EntityReference)
        {
            reply.append(child.getNodeValue());
        }
        else if (child.getNodeType() == Node.ELEMENT_NODE)
        {
            reply.append(getText(child));
        }
    }

    return reply.toString();
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:DomUtil.java

示例2: getTextForNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
public static String getTextForNode(Node node) {
    StringBuilder sb = new StringBuilder();

    NodeList children = node.getChildNodes();
    if (children.getLength() == 0)
        return null;

    for (int i = 0; i < children.getLength(); ++i) {
        Node n = children.item(i);

        if (n instanceof Text)
            sb.append(n.getNodeValue());
        else if (n instanceof EntityReference) {
            String s = getTextForNode(n);
            if (s == null)
                return null;
            else
                sb.append(s);
        } else
            return null;
    }

    return sb.toString();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:XmlUtil.java

示例3: endNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
/**
 * End processing of given node
 *
 *
 * @param node Node we just finished processing
 *
 * @throws org.xml.sax.SAXException
 */
protected void endNode(Node node) throws org.xml.sax.SAXException {

    switch (node.getNodeType()) {
        case Node.DOCUMENT_NODE :
            break;
        case Node.DOCUMENT_TYPE_NODE :
            serializeDocType((DocumentType) node, false);
            break;
        case Node.ELEMENT_NODE :
            serializeElement((Element) node, false);
            break;
        case Node.CDATA_SECTION_NODE :
            break;
        case Node.ENTITY_REFERENCE_NODE :
            serializeEntityReference((EntityReference) node, false);
            break;
        default :
            }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:DOM3TreeWalker.java

示例4: moveToChild

import org.w3c.dom.EntityReference; //導入依賴的package包/類
protected int moveToChild(final int currentChild) {
    content = getCurrentElement().getChildNodes().item(currentChild);

    if (content instanceof Text) {
        return CHARACTERS;
    } else if (content instanceof Element) {
        return START_ELEMENT;
    } else if (content instanceof CDATASection) {
        return CDATA;
    } else if (content instanceof Comment) {
        return CHARACTERS;
    } else if (content instanceof EntityReference) {
        return ENTITY_REFERENCE;
    }

    throw new IllegalStateException();
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:18,代碼來源:DOMStreamReader.java

示例5: startEntity

import org.w3c.dom.EntityReference; //導入依賴的package包/類
public void startEntity (String name)
throws SAXException
{
    // are we ignoring what would be contents of an
    // entity ref, since we can't populate it?
    if (currentEntity != null)
        return;

    // Are we hiding all entity boundaries?
    if (consumer.isHidingReferences ())
        return;

    // SAX2 shows parameter entities; DOM hides them
    if (name.charAt (0) == '%' || "[dtd]".equals (name))
        return;

    // Since we can't create a populated entity ref node in any
    // standard way, we create an unpopulated one.
    EntityReference ref = document.createEntityReference (name);
    top.appendChild (ref);
    top = ref;

    // ... allowing subclasses to populate them
    if (!canPopulateEntityRefs ())
        currentEntity = name;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:DomConsumer.java

示例6: createEntityReference

import org.w3c.dom.EntityReference; //導入依賴的package包/類
/**
 * <b>DOM L1</b>
 * Returns a newly created reference to the specified entity.
 * The caller should populate this with the appropriate children
 * and then mark it as readonly.
 *
 * @see DomNode#makeReadonly
 */
public EntityReference createEntityReference(String name)
{
  DomEntityReference ret = new DomEntityReference(this, name);
  DocumentType doctype = getDoctype();
  if (doctype != null)
    {
      DomEntity ent = (DomEntity) doctype.getEntities().getNamedItem(name);
      if (ent != null)
        {
          for (DomNode ctx = ent.first; ctx != null; ctx = ctx.next)
            {
              ret.appendChild(ctx.cloneNode(true));
            }
        }
    }
  ret.makeReadonly();
  return ret;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:DomDocument.java

示例7: startEntity

import org.w3c.dom.EntityReference; //導入依賴的package包/類
public void startEntity (String name)
throws SAXException
{
    // are we ignoring what would be contents of an
    // entity ref, since we can't populate it?
    if (currentEntity != null)
	return;

    // Are we hiding all entity boundaries?
    if (consumer.isHidingReferences ())
	return;

    // SAX2 shows parameter entities; DOM hides them
    if (name.charAt (0) == '%' || "[dtd]".equals (name))
	return;

    // Since we can't create a populated entity ref node in any
    // standard way, we create an unpopulated one.
    EntityReference ref = document.createEntityReference (name);
    top.appendChild (ref);
    top = ref;

    // ... allowing subclasses to populate them
    if (!canPopulateEntityRefs ())
	currentEntity = name;
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:27,代碼來源:DomConsumer.java

示例8: appendNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
public static void appendNode(Node node, StringBuffer buf) {
    switch (node.getNodeType()) {
    case Node.ELEMENT_NODE:
        appendElement((Element) node, buf);
        break;
    case Node.TEXT_NODE:
        appendText((Text) node, buf);
        break;
    case Node.CDATA_SECTION_NODE:
        appendCDATASection((CDATASection) node, buf);
        break;
    case Node.ENTITY_REFERENCE_NODE:
        appendEntityReference((EntityReference) node, buf);
        break;
    }
}
 
開發者ID:lastaflute,項目名稱:lasta-di,代碼行數:17,代碼來源:LdiDomUtil.java

示例9: visitNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
static <R> R visitNode(Node node, NodeVisitor<R> visitor) {
  switch (node.getNodeType()) {
    case Node.ELEMENT_NODE: return visitor.visitElement((Element) node);
    case Node.ATTRIBUTE_NODE: return visitor.visitAttr((Attr) node);
    case Node.TEXT_NODE: return visitor.visitText((Text) node);
    case Node.CDATA_SECTION_NODE: return visitor.visitCDATASection((CDATASection) node);
    case Node.ENTITY_REFERENCE_NODE: return visitor.visitEntityReference((EntityReference) node);
    case Node.ENTITY_NODE: return visitor.visitEntity((Entity) node);
    case Node.PROCESSING_INSTRUCTION_NODE:
        return visitor.visitProcessingInstruction((ProcessingInstruction) node);
    case Node.COMMENT_NODE: return visitor.visitComment((Comment) node);
    case Node.DOCUMENT_NODE: return visitor.visitDocument((Document) node);
    case Node.DOCUMENT_TYPE_NODE: return visitor.visitDocumentType((DocumentType) node);
    case Node.DOCUMENT_FRAGMENT_NODE:
        return visitor.visitDocumentFragment((DocumentFragment) node);
    case Node.NOTATION_NODE: return visitor.visitNotation((Notation) node);
    default: throw new RuntimeException();
  }
}
 
開發者ID:jbosstools,項目名稱:chromedevtools,代碼行數:20,代碼來源:DomUtils.java

示例10: endNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
/**
 * End processing of given node 
 *
 *
 * @param node Node we just finished processing
 *
 * @throws org.xml.sax.SAXException
 */
protected void endNode(Node node) throws org.xml.sax.SAXException {

    switch (node.getNodeType()) {
        case Node.DOCUMENT_NODE :
            break;
        case Node.DOCUMENT_TYPE_NODE :
            serializeDocType((DocumentType) node, false);
            break;
        case Node.ELEMENT_NODE :
            serializeElement((Element) node, false);
            break;
        case Node.CDATA_SECTION_NODE :
            break;
        case Node.ENTITY_REFERENCE_NODE :
            serializeEntityReference((EntityReference) node, false);
            break;
        default :
            }
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:28,代碼來源:DOM3TreeWalker.java

示例11: testIsSupported4

import org.w3c.dom.EntityReference; //導入依賴的package包/類
@TestTargetNew(
    level = TestLevel.PARTIAL,
    notes = "Verifies that isSupported method returns false value.",
    method = "isSupported",
    args = {java.lang.String.class, java.lang.String.class}
)
public void testIsSupported4() throws Throwable {
    Document doc;
    EntityReference entRef;
    boolean success;
    doc = (Document) load("staffNS", builder);
    entRef = doc.createEntityReference("ent1");
    assertNotNull("createdEntRefNotNull", entRef);
    success = entRef.isSupported("XML CORE", "");
    assertFalse("nodeissupported04", success);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:17,代碼來源:NodeIsSupported.java

示例12: writeNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
/**
 * @param xmlNode XML node
 * @param xmlStreamWriter XML stream writer
 * @throws XMLStreamException the XML stream exception
 */
public static void writeNode(Node xmlNode, XMLStreamWriter xmlStreamWriter)
    throws XMLStreamException {
  if (xmlNode instanceof Element) {
    addElement((Element) xmlNode, xmlStreamWriter);
  } else if (xmlNode instanceof Text) {
    xmlStreamWriter.writeCharacters(xmlNode.getNodeValue());
  } else if (xmlNode instanceof CDATASection) {
    xmlStreamWriter.writeCData(((CDATASection) xmlNode).getData());
  } else if (xmlNode instanceof Comment) {
    xmlStreamWriter.writeComment(((Comment) xmlNode).getData());
  } else if (xmlNode instanceof EntityReference) {
    xmlStreamWriter.writeEntityRef(xmlNode.getNodeValue());
  } else if (xmlNode instanceof ProcessingInstruction) {
    ProcessingInstruction procInst = (ProcessingInstruction) xmlNode;
    xmlStreamWriter.writeProcessingInstruction(procInst.getTarget(),
        procInst.getData());
  } else if (xmlNode instanceof Document) {
    writeToDocument((Document) xmlNode, xmlStreamWriter);
  }
}
 
開發者ID:OfficeDev,項目名稱:ews-java-api,代碼行數:26,代碼來源:EwsServiceXmlWriter.java

示例13: writeNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
/**
 * 
 * @param xmlNode
 * @param xmlStreamWriter
 * @throws XMLStreamException
 */
public static void writeNode(Node xmlNode, XMLStreamWriter xmlStreamWriter)
		throws XMLStreamException {
	if (xmlNode instanceof Element) {
		addElement((Element) xmlNode, xmlStreamWriter);
	} else if (xmlNode instanceof Text) {
		xmlStreamWriter.writeCharacters(((Text) xmlNode).getNodeValue());
	} else if (xmlNode instanceof CDATASection) {
		xmlStreamWriter.writeCData(((CDATASection) xmlNode).getData());
	} else if (xmlNode instanceof Comment) {
		xmlStreamWriter.writeComment(((Comment) xmlNode).getData());
	} else if (xmlNode instanceof EntityReference) {
		xmlStreamWriter.writeEntityRef(((EntityReference) xmlNode)
				.getNodeValue());
	} else if (xmlNode instanceof ProcessingInstruction) {
		ProcessingInstruction procInst = (ProcessingInstruction) xmlNode;
		xmlStreamWriter.writeProcessingInstruction(procInst.getTarget(),
				procInst.getData());
	} else if (xmlNode instanceof Document) {
		writeToDocument((Document) xmlNode, xmlStreamWriter);
	}
}
 
開發者ID:sheymans,項目名稱:todopl,代碼行數:28,代碼來源:EwsServiceXmlWriter.java

示例14: getTextForNode

import org.w3c.dom.EntityReference; //導入依賴的package包/類
public static String getTextForNode(Node node) {
    StringBuffer sb = new StringBuffer();

    NodeList children = node.getChildNodes();
    if (children.getLength() == 0)
        return null;

    for (int i = 0; i < children.getLength(); ++i) {
        Node n = children.item(i);

        if (n instanceof Text)
            sb.append(n.getNodeValue());
        else if (n instanceof EntityReference) {
            String s = getTextForNode(n);
            if (s == null)
                return null;
            else
                sb.append(s);
        } else
            return null;
    }

    return sb.toString();
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:25,代碼來源:XmlUtil.java

示例15: getTextValue

import org.w3c.dom.EntityReference; //導入依賴的package包/類
@Override
public String getTextValue(Element valueEle) {
    if (valueEle != null) {
        StringBuilder sb = new StringBuilder();
        NodeList nl = valueEle.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node item = nl.item(i);
            if ((item instanceof CharacterData && !(item instanceof Comment))
                    || item instanceof EntityReference) {
                sb.append(item.getNodeValue());
            }
        }
        return sb.toString().trim();
    }
    return null;
}
 
開發者ID:zollty-org,項目名稱:zollty-mvc,代碼行數:17,代碼來源:DefaultDom.java


注:本文中的org.w3c.dom.EntityReference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。