📄 documenttypeimpl.java
字号:
/**
* org/ozone-db/xml/dom/DocumentTypeImpl.java
*
* The contents of this file are subject to the OpenXML Public
* License Version 1.0; you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.openxml.org/license.html
*
* THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
* OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
* AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
* RIGHTS AND LIMITATIONS UNDER THE LICENSE.
*
* The Initial Developer of this code under the License is Assaf Arkin.
* Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
* All Rights Reserved.
*/
/**
* Changes for Persistent DOM running with ozone are
* Copyright 1999 by SMB GmbH. All rights reserved.
*/
package org.ozoneDB.xml.dom;
import java.util.*;
import org.w3c.dom.*;
/**
* Each document {@link org.w3c.dom.Document#getDoctype()} attribute whose
* value is either null or an object that represents the document type definition
* (DTD). HTML documents do not have a DTD. At the moment, this object provides
* the list of entities that are defined for the document and little else.
* Access is provided through {@link org.w3c.dom.NamedNodeMap} collections.
* <P>
* Notes:
* <OL>
* <LI>Node type is {@link org.w3c.dom.Node#DOCUMENT_TYPE_NODE}
* <LI>Does not support childern
* <LI>Node does not have a value
* <LI>Node does not have parents or siblings and is only accessible from
* {@link org.w3c.dom.Document}
* </OL>
* <P>
* The internal implementation also provides access to other elements that are
* part of the DTD, so full XML documents can be generated and parsed. These
* extensions are beyond the DOM API and are covered in an extended API.
* For more information see {@link org.ozoneDB.xml.DTDDocument}.
*
*
* @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
* @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
* @see org.w3c.dom.DocumentType
* @see org.ozoneDB.xml.DTDDocument
* @see NodeImpl
* @see org.w3c.dom.NamedNodeMap
*/
public class DocumentTypeImpl extends DocumentImpl implements DocumentTypeProxy {
final static long serialVersionUID = 1;
public java.lang.String getInternalSubset() {
throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,
"DocumentType.getInternalSubset(): ozone's persistent DOM doesn't support DOM level 2 yet." );
}
public short getNodeType() {
return DOCUMENT_TYPE_NODE;
}
public String getName() {
return getNodeName();
}
public NamedNodeMap getEntities() {
return _entities;
}
public void setEntities( NamedNodeMap entities ) {
_entities = (NamedNodeMapProxy)entities;
}
public NamedNodeMap getNotations() {
return _notations;
}
public void setNotations( NamedNodeMap notations ) {
_notations = (NamedNodeMapProxy)notations;
}
public Hashtable getParams() {
return _params;
}
public void setParams( Hashtable params ) {
_params = params;
}
public String getPublicId() {
return _publicId;
}
public void setSystemId( String systemId ) {
_systemId = systemId;
}
public void setPublicId( String publicId ) {
_publicId = publicId;
}
public String getSystemId() {
return _systemId;
}
public String internalAsText() {
return null;
}
public boolean getStandalone() {
return _standalone;
}
public void setStandalone( boolean standalone ) {
_standalone = standalone;
}
/**
* Creates a new external general entity declaration and returns it.
*
* @param name The notation name
* @param systemID The system identifier
* @param publicID The public identifier
* @return Returns a new entity node
*/
public Entity createEntity( String name, String systemID, String publicID ) {
EntityProxy entity = null;
try {
entity = (EntityProxy)database().createObject( EntityImpl.class.getName() );
entity.init( this, name, systemID, publicID );
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
return entity;
}
/**
* Creates a new unparsed general entity declaration and returns it.
*
* @param name The notation name
* @param systemID The system identifier
* @param publicID The public identifier
* @param notation The notation
* @return Returns a new entity node
*/
public Entity createEntity( String name, String systemID, String publicID, String notation ) {
EntityProxy entity = null;
try {
entity = (EntityProxy)database().createObject( EntityImpl.class.getName() );
entity.init( this, name, systemID, publicID, notation );
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
return entity;
}
/**
* Creates a new internal entity declaration and returns it. The entity value
* is given after parameter entity and character reference substitution.
*
* @param name The notation name
* @param value The entity value
* @return Returns a new entity node
*/
public Entity createEntity( String name, String value ) {
EntityProxy entity = null;
try {
entity = (EntityProxy)database().createObject( EntityImpl.class.getName() );
entity.init( this, name, value );
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
return entity;
}
/**
* Declares a new general entity declaration. If a general entity with the same
* name is already declared, it remains intact and the existing entity is
* returned. If no such entity exists, the entity is declared and returned.
*
* @param general The general entity to declare
* @return The declared entity
*/
public Entity declareEntity( Entity general ) {
EntityProxy old = null;
isReadOnly();
if (_entities == null) {
try {
_entities = (NamedNodeMapProxy)database().createObject( NamedNodeMapImpl.class.getName() );
_entities.init( this, new Hashtable() );
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
old = null;
} else {
old = (EntityProxy)_entities.getNamedItem( general.getNodeName() );
}
if (old == null) {
_entities.setNamedItem( general );
return general;
} else {
return old;
}
}
/**
* Returns the named general entity declaration if one has been declared.
*
* @param name The entity name
* @return The named general entity
*/
public Entity findEntity( String name ) {
if (_entities == null) {
return null;
}
return (Entity)_entities.getNamedItem( name );
}
/*
public EntityImpl deleteEntity( String name )
{
return (EntityImpl) _entities.removeNamedItem( name );
}
*/
/**
* Creates a new notation and returns it. Notation must have either or both
* system and public identifiers.
*
* @param name The notation name
* @param systemID The system identifier
* @param publicID The public identifier
* @return Returns a new notation node
*/
public Notation createNotation( String name, String systemID, String publicID ) {
NotationProxy notation = null;
try {
notation = (NotationProxy)database().createObject( NotationImpl.class.getName() );
notation.init( this, name, systemID, publicID );
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
return notation;
}
/**
* Declares a new notation. If a notation with the same name is already
* declared, it remains intact and the existing notation is returned.
* If no such notation exists, the notation is declared and returned.
*
* @param notation The notation to declare
* @return The declared notation
*/
public Notation declareNotation( Notation notation ) {
NotationProxy old;
isReadOnly();
if (_notations == null) {
try {
_notations = (NamedNodeMapProxy)database().createObject( NamedNodeMapImpl.class.getName() );
_notations.init( this, new Hashtable() );
old = null;
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
} else {
old = (NotationProxy)_notations.getNamedItem( notation.getNodeName() );
}
if (old == null) {
_notations.setNamedItem( notation );
return notation;
} else {
return old;
}
}
/**
* Returns the named notation if one has been declared.
*
* @param name The notation name
* @return The named notation
*/
public Notation findNotation( String name ) {
if (_notations == null) {
return null;
}
return (Notation)_notations.getNamedItem( name );
}
/**
* Creates a new external parameter entity and returns it.
*
* @param name The notation name
* @param systemID The system identifier
* @param publicID The public identifier
* @return Returns a new entity node
*/
public ParamEntity createParamEntity( String name, String systemID, String publicID ) {
ParamEntityProxy entity;
try {
entity = (ParamEntityProxy)database().createObject( ParamEntity.class.getName() );
entity.init( (DocumentProxy)self(), name, systemID, publicID );
} catch (Exception except) {
throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
}
return (ParamEntity)entity;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -