KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * org/ozone-db/xml/dom/ProcessingInstructionImpl.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 processing instruction. The target and data of the processing
33  * instruction are mapped into the name and value of the node.
34  * <P>
35  * Notes:
36  * <OL>
37  * <LI>Node type is {@link org.w3c.dom.Node#PROCESSING_INSTRUCTION_NODE}
38  * <LI>Node does not support childern
39  * </OL>
40  *
41  *
42  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
43  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
44  * @see org.w3c.dom.ProcessingInstruction
45  * @see NodeImpl
46  */

47 public final class ProcessingInstructionImpl extends NodeImpl implements ProcessingInstructionProxy {
48
49     final static long serialVersionUID = 1;
50
51
52     public short getNodeType() {
53         return this.PROCESSING_INSTRUCTION_NODE;
54     }
55
56
57     public String JavaDoc getTarget() {
58         // Same as calling getNodeName().
59
return getNodeName();
60     }
61
62
63     public String JavaDoc getData() {
64         // Same as calling getNodeValue().
65
return getNodeValue();
66     }
67
68
69     public void setData( String JavaDoc data ) throws DOMException {
70         // Same as calling setNodeValue().
71
setNodeValue( data );
72     }
73
74
75     public final Object JavaDoc clone() {
76         ProcessingInstructionProxy clone = null;
77         try {
78             clone = (ProcessingInstructionProxy)database().createObject( ProcessingInstructionImpl.class.getName() );
79             clone.init( _ownerDocument, getNodeName(), getNodeValue() );
80             cloneInto( clone, true );
81         } catch (Exception JavaDoc except) {
82             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
83         }
84         return clone;
85     }
86
87
88     public final Node cloneNode( boolean deep ) {
89         ProcessingInstructionProxy clone = null;
90         try {
91             clone = (ProcessingInstructionProxy)database().createObject( ProcessingInstructionImpl.class.getName() );
92             clone.init( _ownerDocument, getNodeName(), getNodeValue() );
93             cloneInto( clone, deep );
94         } catch (Exception JavaDoc except) {
95             throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );
96         }
97         return clone;
98     }
99
100
101     public String JavaDoc toString() {
102         String JavaDoc target;
103         String JavaDoc data;
104
105         target = getTarget();
106         if (target.length() > 32) {
107             target = target.substring( 0, 32 ) + "..";
108         }
109         data = getData();
110         if (data.length() > 32) {
111             data = data.substring( 0, 32 ) + "..";
112         }
113         return "PI node: [" + target + "] [" + data + "]";
114     }
115
116
117     protected final boolean supportsChildern() {
118         return false;
119     }
120
121
122     /**
123      * Hidden constructor.
124      *
125      * @param owner The owner of this document
126      * @param target The processing instruction target
127      * @param target The processing instruction data
128      */

129     public ProcessingInstructionImpl( DocumentImpl owner, String JavaDoc target, String JavaDoc data ) {
130         super( owner, target, data, true );
131     }
132
133
134     public ProcessingInstructionImpl() {
135         super();
136     }
137
138
139     public void init( DocumentProxy owner, String JavaDoc target, String JavaDoc data ) {
140         super.init( owner, target, data, true );
141     }
142 }
143
Popular Tags