当前位置: 首页>>代码示例>>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;未经允许,请勿转载。