Source for gnu.xml.dom.DomEntity

   1: /* DomEntity.java --
   2:    Copyright (C) 1999,2000,2004 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: package gnu.xml.dom;
  39: 
  40: import org.w3c.dom.Entity;
  41: 
  42: /**
  43:  * <p> "Entity" implementation.  This is a non-core DOM class, supporting the
  44:  * "XML" feature.  There are two types of entities, neither of which works
  45:  * particularly well in this API:</p><dl>
  46:  *
  47:  * <dt><em>Unparsed Entities</em></dt>
  48:  *      <dd>Since ENTITY/ENTITIES attributes, the only legal use of unparsed
  49:  *      entities in XML, can't be detected with DOM, there isn't much point in
  50:  *      trying to use unparsed entities in DOM applications.  (XML Linking is
  51:  *      working to provide a better version of this functionality.) </dd>
  52:  *
  53:  * <dt><em>Parsed Entities</em></dt>
  54:  *      <dd> While the DOM specification permits nodes for parsed entities
  55:  *      to have a readonly set of children, this is not required and there
  56:  *      is no portable way to provide such children.  <em>This implementation
  57:  *      currently does not permit children to be added to Entities.</em>
  58:  *      There are related issues with the use of EntityReference nodes.  </dd>
  59:  *
  60:  * </dl>
  61:  *
  62:  * <p> In short, <em>avoid using this DOM functionality</em>.
  63:  *
  64:  * @see DomDoctype
  65:  * @see DomEntityReference
  66:  * @see DomNotation
  67:  *
  68:  * @author David Brownell
  69:  * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
  70:  */
  71: public class DomEntity
  72:   extends DomExtern
  73:   implements Entity
  74: {
  75: 
  76:   private String notation;
  77: 
  78:   /**
  79:    * Constructs an Entity node associated with the specified document,
  80:    * with the specified descriptive data.
  81:    *
  82:    * <p>This constructor should only be invoked by a DomDoctype as part
  83:    * of its declareEntity functionality, or through a subclass which is
  84:    * similarly used in a "Sub-DOM" style layer.
  85:    *
  86:    * @param owner The document with which this entity is associated
  87:    * @param name Name of this entity
  88:    * @param publicId If non-null, provides the entity's PUBLIC identifier
  89:    * @param systemId Provides the entity's SYSTEM identifier (URI)
  90:    * @param notation If non-null, provides the unparsed entity's notation.
  91:    */
  92:   protected DomEntity(DomDocument owner,
  93:                       String name,
  94:                       String publicId,
  95:                       String systemId,
  96:                       String notation)
  97:   {
  98:     super(ENTITY_NODE, owner, name, publicId, systemId);
  99:     this.notation = notation;
 100: 
 101:     // NOTE:  if notation == null, this is a parsed entity
 102:     // which could reasonably be given child nodes ...
 103:     makeReadonly();
 104:   }
 105: 
 106:   /**
 107:    * <b>DOM L1</b>
 108:    * Returns the NOTATION identifier associated with this entity, if any.
 109:    */
 110:   final public String getNotationName()
 111:   {
 112:     return notation;
 113:   }
 114: 
 115:   // DOM Level 3 methods
 116: 
 117:   public String getInputEncoding()
 118:   {
 119:     // TODO
 120:     return null;
 121:   }
 122: 
 123:   public String getXmlEncoding()
 124:   {
 125:     // TODO
 126:     return null;
 127:   }
 128: 
 129:   public String getXmlVersion()
 130:   {
 131:     // TODO
 132:     return null;
 133:   }
 134: 
 135:   /**
 136:    * The base URI of an external entity is its system ID.
 137:    * The base URI of an internal entity is the parent document's base URI.
 138:    * @since DOM Level 3 Core
 139:    */
 140:   public String getBaseURI()
 141:   {
 142:     String systemId = getSystemId();
 143:     return (systemId == null) ? owner.getBaseURI() : systemId;
 144:   }
 145: 
 146: }