001: /**
002: * org/ozone-db/xml/dom/ProcessingInstructionImpl.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 processing instruction. The target and data of the processing
030: * instruction are mapped into the name and value of the node.
031: * <P>
032: * Notes:
033: * <OL>
034: * <LI>Node type is {@link org.w3c.dom.Node#PROCESSING_INSTRUCTION_NODE}
035: * <LI>Node does not support childern
036: * </OL>
037: *
038: *
039: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
040: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
041: * @see org.w3c.dom.ProcessingInstruction
042: * @see NodeImpl
043: */
044: public final class ProcessingInstructionImpl extends NodeImpl implements
045: ProcessingInstructionProxy {
046:
047: final static long serialVersionUID = 1;
048:
049: public short getNodeType() {
050: return this .PROCESSING_INSTRUCTION_NODE;
051: }
052:
053: public String getTarget() {
054: // Same as calling getNodeName().
055: return getNodeName();
056: }
057:
058: public String getData() {
059: // Same as calling getNodeValue().
060: return getNodeValue();
061: }
062:
063: public void setData(String data) throws DOMException {
064: // Same as calling setNodeValue().
065: setNodeValue(data);
066: }
067:
068: public final Object clone() {
069: ProcessingInstructionProxy clone = null;
070: try {
071: clone = (ProcessingInstructionProxy) database()
072: .createObject(
073: ProcessingInstructionImpl.class.getName());
074: clone.init(_ownerDocument, getNodeName(), getNodeValue());
075: cloneInto((NodeProxy) clone, true);
076: } catch (Exception except) {
077: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
078: except.getMessage());
079: }
080: return clone;
081: }
082:
083: public final Node cloneNode(boolean deep) {
084: ProcessingInstructionProxy clone = null;
085: try {
086: clone = (ProcessingInstructionProxy) database()
087: .createObject(
088: ProcessingInstructionImpl.class.getName());
089: clone.init(_ownerDocument, getNodeName(), getNodeValue());
090: cloneInto((NodeProxy) clone, deep);
091: } catch (Exception except) {
092: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
093: except.getMessage());
094: }
095: return clone;
096: }
097:
098: public String toString() {
099: String target;
100: String data;
101:
102: target = getTarget();
103: if (target.length() > 32) {
104: target = target.substring(0, 32) + "..";
105: }
106: data = getData();
107: if (data.length() > 32) {
108: data = data.substring(0, 32) + "..";
109: }
110: return "PI node: [" + target + "] [" + data + "]";
111: }
112:
113: protected final boolean supportsChildern() {
114: return false;
115: }
116:
117: /**
118: * Hidden constructor.
119: *
120: * @param owner The owner of this document
121: * @param target The processing instruction target
122: * @param target The processing instruction data
123: */
124: public ProcessingInstructionImpl(DocumentImpl owner, String target,
125: String data) {
126: super (owner, target, data, true);
127: }
128:
129: public ProcessingInstructionImpl() {
130: super ();
131: }
132:
133: public void init(DocumentProxy owner, String target, String data) {
134: super .init(owner, target, data, true);
135: }
136: }
|