KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom > NotationImpl


1 /**
2  * org/ozone-db/xml/dom/NotationImpl.java
3  *
4  * The contents of this file are subject to the OpenXML Public
5  * License Version 1.0; you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at
7  * http://www.openxml.org/license.html
8  *
9  * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
10  * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
11  * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
12  * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
13  * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
14  * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
15  *
16  * The Initial Developer of this code under the License is Assaf Arkin.
17  * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
18  * All Rights Reserved.
19  */

20
21 /**
22  * Changes for Persistent DOM running with ozone are
23  * Copyright 1999 by SMB GmbH. All rights reserved.
24  */

25
26 package org.ozoneDB.xml.dom;
27
28 import org.w3c.dom.*;
29
30
31 /**
32  * Implements a notation. A notation node merely associates the notation's
33  * name with its system and/or public identifiers. The notation has no contents.
34  * This node is immutable.
35  * <P>
36  * Notes:
37  * <OL>
38  * <LI>Node type is {@link org.w3c.dom.Node#NOTATION_NODE}
39  * <LI>Node does not support childern
40  * <LI>Node does not have a value
41  * <LI>Node only accessible from {@link org.w3c.dom.DocumentType}
42  * </OL>
43  *
44  *
45  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
46  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
47  * @see org.w3c.dom.Notation
48  * @see NodeImpl
49  */

50 public final class NotationImpl extends NodeImpl implements NotationProxy {
51
52     final static long serialVersionUID = 1;
53
54
55     public short getNodeType() {
56         return NOTATION_NODE;
57     }
58
59
60     public final void setNodeValue( String JavaDoc value ) {
61         throw new DOMExceptionImpl( DOMException.NO_DATA_ALLOWED_ERR, "This node type does not support values." );
62     }
63
64
65     public String JavaDoc getPublicId() {
66         return _publicID;
67     }
68
69
70     public void setPublicId( String JavaDoc publicID ) {
71         _publicID = publicID;
72     }
73
74
75     public String JavaDoc getSystemId() {
76         return _systemID;
77     }
78
79
80     public void setSystemId( String JavaDoc systemID ) {
81         _systemID = systemID;
82     }
83
84
85     public synchronized boolean equals( Object JavaDoc other ) {
86         NotationProxy otherX;
87
88         // Test for node equality (this covers notation name and all its children)
89
// and then test for specific notation qualities. Either both public id's
90
// are null, or they are not null and equal. Same thing with system id.
91
if (super.equals( other )) {
92             otherX = (NotationProxy)other;
93             return
94                     (this.getPublicId() == null && otherX.getPublicId() == null || this.getPublicId() != null
95                     && this.getPublicId().equals( otherX.getPublicId() )) && (this.getSystemId() == null
96                     && otherX.getSystemId() == null || this.getSystemId() != null && this.getSystemId().equals(
97                     otherX.getSystemId() ));
98         }
99         return false;
100     }
101
102
103     public final Object JavaDoc clone() {
104         TextProxy clone = null;
105         try {
106             clone = (TextProxy)database().createObject( TextImpl.class.getName() );
107             clone.init( _ownerDocument, getNodeValue() );
108             cloneInto( clone, true );
109         } catch (Exception JavaDoc except) {
110             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
111         }
112         return clone;
113     }
114
115
116     public final Node cloneNode( boolean deep ) {
117         TextProxy clone = null;
118         try {
119             clone = (TextProxy)database().createObject( TextImpl.class.getName() );
120             clone.init( _ownerDocument, getNodeValue() );
121             cloneInto( clone, deep );
122         } catch (Exception JavaDoc except) {
123             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
124         }
125         return clone;
126     }
127
128
129     public String JavaDoc toString() {
130         String JavaDoc name;
131
132         name = getNodeName();
133         if (name.length() > 32) {
134             name = name.substring( 0, 32 ) + "..";
135         }
136         if (getSystemId() != null) {
137             name = name + "] SYSTEM [" + getSystemId();
138         }
139         if (getPublicId() != null) {
140             name = name + "] PUBLIC [" + getPublicId();
141         }
142         return "Notation decl: [" + name + "]";
143     }
144
145
146     public synchronized void cloneInto( NodeProxy into, boolean deep ) {
147         super.cloneInto( into, deep );
148         ((NotationProxy)into).setSystemId( _systemID );
149         ((NotationProxy)into).setPublicId( _publicID );
150     }
151
152
153     protected final boolean supportsChildern() {
154         return false;
155     }
156
157
158     /**
159      * Constructor requires owner document, notation name and all its attributes.
160      *
161      * @param owner The owner document
162      * @param name The entity name
163      * @param systemID The system identifier, if specified
164      * @param publicID The public identifier, if specified
165      */

166     public NotationImpl( DocumentImpl owner, String JavaDoc name, String JavaDoc systemID, String JavaDoc publicID ) {
167         init( owner, name, systemID, publicID );
168     }
169
170
171     public NotationImpl() {
172         super();
173     }
174
175
176     public void init( DocumentProxy owner, String JavaDoc name, String JavaDoc systemID, String JavaDoc publicID ) {
177         super.init( owner, name, null, true );
178         if (_systemID == null && _publicID == null) {
179             throw new IllegalArgumentException JavaDoc( "Both 'systemID' and 'publicID' are missing." );
180         }
181         _systemID = systemID;
182         _publicID = publicID;
183     }
184     /**
185      * The system identifier of this notation, if specified.
186      */

187     private String JavaDoc _systemID;
188
189     /**
190      * The public identifier of this notation, if specified.
191      */

192     private String JavaDoc _publicID;
193
194 }
195
Popular Tags