001: /**
002: * org/ozone-db/xml/dom/NotationImpl.java
003: *
004: * The contents of this file are subject to the OpenXML Public
005: * License Version 1.0; you may not use this file except in compliance
006: * with the License. You may obtain a copy of the License at
007: * http://www.openxml.org/license.html
008: *
009: * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
010: * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
011: * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
012: * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
013: * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
014: * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
015: *
016: * The Initial Developer of this code under the License is Assaf Arkin.
017: * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
018: * All Rights Reserved.
019: */
020:
021: /**
022: * Changes for Persistent DOM running with ozone are
023: * Copyright 1999 by SMB GmbH. All rights reserved.
024: */package org.ozoneDB.xml.dom;
025:
026: import org.w3c.dom.*;
027:
028: /**
029: * Implements a notation. A notation node merely associates the notation's
030: * name with its system and/or public identifiers. The notation has no contents.
031: * This node is immutable.
032: * <P>
033: * Notes:
034: * <OL>
035: * <LI>Node type is {@link org.w3c.dom.Node#NOTATION_NODE}
036: * <LI>Node does not support childern
037: * <LI>Node does not have a value
038: * <LI>Node only accessible from {@link org.w3c.dom.DocumentType}
039: * </OL>
040: *
041: *
042: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
043: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
044: * @see org.w3c.dom.Notation
045: * @see NodeImpl
046: */
047: public final class NotationImpl extends NodeImpl implements
048: NotationProxy {
049:
050: final static long serialVersionUID = 1;
051:
052: public short getNodeType() {
053: return NOTATION_NODE;
054: }
055:
056: public final void setNodeValue(String value) {
057: throw new DOMExceptionImpl(DOMException.NO_DATA_ALLOWED_ERR,
058: "This node type does not support values.");
059: }
060:
061: public String getPublicId() {
062: return _publicID;
063: }
064:
065: public void setPublicId(String publicID) {
066: _publicID = publicID;
067: }
068:
069: public String getSystemId() {
070: return _systemID;
071: }
072:
073: public void setSystemId(String systemID) {
074: _systemID = systemID;
075: }
076:
077: public synchronized boolean equals(Object other) {
078: NotationProxy otherX;
079: boolean equal;
080:
081: // Test for node equality (this covers notation name and all its children)
082: // and then test for specific notation qualities. Either both public id's
083: // are null, or they are not null and equal. Same thing with system id.
084: if (super .equals(other)) {
085: otherX = (NotationProxy) other;
086: return (this .getPublicId() == null
087: && otherX.getPublicId() == null || this
088: .getPublicId() != null
089: && this .getPublicId().equals(otherX.getPublicId()))
090: && (this .getSystemId() == null
091: && otherX.getSystemId() == null || this
092: .getSystemId() != null
093: && this .getSystemId().equals(
094: otherX.getSystemId()));
095: }
096: return false;
097: }
098:
099: public final Object clone() {
100: TextProxy clone = null;
101: try {
102: clone = (TextProxy) database().createObject(
103: TextImpl.class.getName());
104: clone.init(_ownerDocument, getNodeValue());
105: cloneInto((NodeProxy) clone, true);
106: } catch (Exception except) {
107: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
108: except.getMessage());
109: }
110: return clone;
111: }
112:
113: public final Node cloneNode(boolean deep) {
114: TextProxy clone = null;
115: try {
116: clone = (TextProxy) database().createObject(
117: TextImpl.class.getName());
118: clone.init(_ownerDocument, getNodeValue());
119: cloneInto((NodeProxy) clone, deep);
120: } catch (Exception except) {
121: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
122: except.getMessage());
123: }
124: return clone;
125: }
126:
127: public String toString() {
128: String name;
129:
130: name = getNodeName();
131: if (name.length() > 32) {
132: name = name.substring(0, 32) + "..";
133: }
134: if (getSystemId() != null) {
135: name = name + "] SYSTEM [" + getSystemId();
136: }
137: if (getPublicId() != null) {
138: name = name + "] PUBLIC [" + getPublicId();
139: }
140: return "Notation decl: [" + name + "]";
141: }
142:
143: public synchronized void cloneInto(NodeProxy into, boolean deep) {
144: super .cloneInto(into, deep);
145: ((NotationProxy) into).setSystemId(_systemID);
146: ((NotationProxy) into).setPublicId(_publicID);
147: }
148:
149: protected final boolean supportsChildern() {
150: return false;
151: }
152:
153: /**
154: * Constructor requires owner document, notation name and all its attributes.
155: *
156: * @param owner The owner document
157: * @param name The entity name
158: * @param systemID The system identifier, if specified
159: * @param publicID The public identifier, if specified
160: */
161: public NotationImpl(DocumentImpl owner, String name,
162: String systemID, String publicID) {
163: init(owner, name, systemID, publicID);
164: }
165:
166: public NotationImpl() {
167: super ();
168: }
169:
170: public void init(DocumentProxy owner, String name, String systemID,
171: String publicID) {
172: super .init(owner, name, null, true);
173: if (_systemID == null && _publicID == null) {
174: throw new IllegalArgumentException(
175: "Both 'systemID' and 'publicID' are missing.");
176: }
177: _systemID = systemID;
178: _publicID = publicID;
179: }
180:
181: /**
182: * The system identifier of this notation, if specified.
183: */
184: private String _systemID;
185:
186: /**
187: * The public identifier of this notation, if specified.
188: */
189: private String _publicID;
190:
191: }
|