当前位置: 首页>>代码示例>>Java>>正文


Java Entity类代码示例

本文整理汇总了Java中org.w3c.dom.Entity的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Entity类属于org.w3c.dom包,在下文中一共展示了Entity类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: internalEntityDecl

import org.w3c.dom.Entity; //导入依赖的package包/类
public void internalEntityDecl(String name, String value)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("internal entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, null, null, null);
  if (entity != null)
    {
      Node text = doc.createTextNode(value);
      entity.appendChild(text);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:18,代码来源:SAXEventSink.java

示例2: visitNode

import org.w3c.dom.Entity; //导入依赖的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

示例3: enter

import org.w3c.dom.Entity; //导入依赖的package包/类
public boolean enter(Entity entity) {
    String name = entity.getNodeName();
    String pubId = entity.getPublicId();
    String sysId = entity.getSystemId();
    String notation = entity.getNotationName();
    buffer.append("<!ENTITY ");
    buffer.append(name);
    if (pubId != null) {
        buffer.append(" PUBLIC \"");
        buffer.append(pubId);
        buffer.append("\"");
    }
    if (sysId != null) {
        buffer.append(" SYSTEM \"");
        buffer.append(sysId);
        buffer.append("\"");
    }
    if (notation != null) {
        buffer.append(" NDATA ");
        buffer.append(notation);
    }
    buffer.append(">");
    return true;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:25,代码来源:SaveContextVisitor.java

示例4: getUnparsedEntityURI

import org.w3c.dom.Entity; //导入依赖的package包/类
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:SAXImpl.java

示例5: isEntityUnparsed

import org.w3c.dom.Entity; //导入依赖的package包/类
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:DOMValidatorHelper.java

示例6: doctypeDecl

import org.w3c.dom.Entity; //导入依赖的package包/类
public void doctypeDecl(DocumentType node) throws XNIException {
    /** Create new DocumentType node for the target. */
    if (fDocumentImpl != null) {
        DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId());
        final String internalSubset = node.getInternalSubset();
        /** Copy internal subset. */
        if (internalSubset != null) {
            ((DocumentTypeImpl) docType).setInternalSubset(internalSubset);
        }
        /** Copy entities. */
        NamedNodeMap oldMap = node.getEntities();
        NamedNodeMap newMap = docType.getEntities();
        int length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Entity oldEntity = (Entity) oldMap.item(i);
            EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName());
            newEntity.setPublicId(oldEntity.getPublicId());
            newEntity.setSystemId(oldEntity.getSystemId());
            newEntity.setNotationName(oldEntity.getNotationName());
            newMap.setNamedItem(newEntity);
        }
        /** Copy notations. */
        oldMap = node.getNotations();
        newMap = docType.getNotations();
        length = oldMap.getLength();
        for (int i = 0; i < length; ++i) {
            Notation oldNotation = (Notation) oldMap.item(i);
            NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName());
            newNotation.setPublicId(oldNotation.getPublicId());
            newNotation.setSystemId(oldNotation.getSystemId());
            newMap.setNamedItem(newNotation);
        }
        append(docType);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:DOMResultBuilder.java

示例7: createEntity

import org.w3c.dom.Entity; //导入依赖的package包/类
/**
 * NON-DOM Factory method; creates an Entity having this Document as its
 * OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building DTD
 * information unspecified.)
 *
 * @param name The name of the Entity we wish to provide a value for.
 *
 * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where
 * nonstandard entities are not permitted. (HTML not yet implemented.)
 */
public Entity createEntity(String name)
        throws DOMException {

    if (errorChecking && !isXMLName(name, xml11Version)) {
        String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
        throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
    }
    return new EntityImpl(this, name);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CoreDocumentImpl.java

示例8: declareEntity

import org.w3c.dom.Entity; //导入依赖的package包/类
/**
 * Records the declaration of a general entity in this DocumentType.
 *
 * @param name Name of the entity
 * @param publicId If non-null, provides the entity's PUBLIC identifier
 * @param systemId Provides the entity's SYSTEM identifier
 * @param notation If non-null, provides the entity's notation
 *    (indicating an unparsed entity)
 * @return The Entity that was declared, or null if the entity wasn't
 *    recorded (because it's a parameter entity or because an entity with
 *    this name was already declared).
 *
 * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
 *    DocumentType is no longer writable.
 * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
 *    is not associated with a document.
 */
public Entity declareEntity(String name,
                            String publicId,
                            String systemId,
                            String notation)
{
  DomEntity entity;

  if (name.charAt(0) == '%' || "[dtd]".equals(name))
    {
      return null;
    }
  if (isReadonly())
    {
      throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
    }
  getEntities();

  DomDocument.checkName(name, (owner != null) ?
                        "1.1".equals(owner.getXmlVersion()) : false);
  if (entities.getNamedItem(name) != null)
    {
      return null;
    }

  entity = new DomEntity(owner, name, publicId, systemId, notation);
  entities.setNamedItem(entity);
  return entity;
}
 
开发者ID:vilie,项目名称:javify,代码行数:46,代码来源:DomDoctype.java

示例9: startEntity

import org.w3c.dom.Entity; //导入依赖的package包/类
public void startEntity(String name)
  throws SAXException
{
  if (interrupted)
    return;
  DocumentType doctype = doc.getDoctype();
  if (doctype == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to entity in undeclared doctype");
    }
  if ("[dtd]".equals(name) || name.charAt(0) == '%')
    return;
  if (PREDEFINED_ENTITIES.contains(name))
    return;
  // Get entity
  NamedNodeMap entities = doctype.getEntities();
  Entity entity = (Entity) entities.getNamedItem(name);
  if (entity == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to undeclared entity: " + name);
    }
  EntityReference ref = doc.createEntityReference(name);
  // DomDocument populates with the entity replacement text, remove this
  Node child = ref.getFirstChild();
  while (child != null)
    {
      Node nextChild = child.getNextSibling();
      ref.removeChild(child);
      child = nextChild;
    }
  ctx.appendChild(ref);
  ctx = ref;
}
 
开发者ID:vilie,项目名称:javify,代码行数:36,代码来源:SAXEventSink.java

示例10: unparsedEntityDecl

import org.w3c.dom.Entity; //导入依赖的package包/类
public void unparsedEntityDecl(String name, String publicId, String systemId,
                               String notationName)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("unparsed entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId,
                                        notationName);
}
 
开发者ID:vilie,项目名称:javify,代码行数:15,代码来源:SAXEventSink.java

示例11: externalEntityDecl

import org.w3c.dom.Entity; //导入依赖的package包/类
public void externalEntityDecl(String name, String publicId, String systemId)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("external entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId, null);
}
 
开发者ID:vilie,项目名称:javify,代码行数:13,代码来源:SAXEventSink.java

示例12: getBaseURI

import org.w3c.dom.Entity; //导入依赖的package包/类
/**
 * The base URI of an entity reference is the base URI where the entity
 * declaration occurs.
 * @since DOM Level 3 Core
 */
public final String getBaseURI()
{
  DocumentType doctype = owner.getDoctype();
  if (doctype == null)
    {
      return null;
    }
  Entity entity = (Entity) doctype.getEntities().getNamedItem(name);
  if (entity == null)
    {
      return null;
    }
  return entity.getBaseURI();
}
 
开发者ID:vilie,项目名称:javify,代码行数:20,代码来源:DomEntityReference.java

示例13: declareEntity

import org.w3c.dom.Entity; //导入依赖的package包/类
/**
 * Records the declaration of a general entity in this DocumentType.
 *
 * @param name Name of the entity
 * @param publicId If non-null, provides the entity's PUBLIC identifier
 * @param systemId Provides the entity's SYSTEM identifier
 * @param notation If non-null, provides the entity's notation
 *	(indicating an unparsed entity)
 * @return The Entity that was declared, or null if the entity wasn't
 *	recorded (because it's a parameter entity or because an entity with
 *	this name was already declared).
 *
 * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
 *	DocumentType is no longer writable.
 * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
 *	is not associated with a document.
 */
public Entity declareEntity(String name,
                            String publicId,
                            String systemId,
                            String notation)
{
  DomEntity entity;
  
  if (name.charAt(0) == '%' || "[dtd]".equals(name))
    {
      return null;
    }
  if (isReadonly())
    {
      throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
    }
  getEntities();
  
  DomDocument.checkName(name, (owner != null) ?
                        "1.1".equals(owner.getXmlVersion()) : false);
  if (entities.getNamedItem(name) != null)
    {
      return null;
    }
  
  entity = new DomEntity(owner, name, publicId, systemId, notation);
  entities.setNamedItem(entity);
  return entity;
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:46,代码来源:DomDoctype.java


注:本文中的org.w3c.dom.Entity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。