/*-- Copyright (C) 2000 Brett McLaughlin & Jason Hunter. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution. 3. The name "JDOM" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact license@jdom.org. 4. Products derived from this software may not be called "JDOM", nor may "JDOM" appear in their name, without prior written permission from the JDOM Project Management (pm@jdom.org). In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the JDOM Project (http://www.jdom.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.jdom.org/images/logos. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the JDOM Project and was originally created by Brett McLaughlin and Jason Hunter . For more information on the JDOM Project, please see . */ package org.jdom; import java.io.Serializable; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.util.StringTokenizer; /** *

* ProcessingInstruction defines behavior for an * XML processing instruction, modeled in Java. Methods * allow the user to obtain the target of the PI as well as its data. * The data can always be accessed as a String, and where appropriate * can be retrieved as name/value pairs. *

* * @author Brett McLaughlin * @author Jason Hunter * @version 1.0 */ public class UnescapedText implements Serializable, Cloneable { /** The data for the UT as a String */ protected String unescapedText; /** Parent element, or null if none */ protected Element parent; /** Document node if PI is outside the root element, or null if none */ protected Document document; /** *

* Default, no-args constructor for implementations * to use if needed. *

*/ protected UnescapedText() { } public UnescapedText(String theText) { this.unescapedText = theText; } /** *

* This will return the parent of this ProcessingInstruction. * If there is no parent, then this returns null. *

* * @return parent of this ProcessingInstruction */ public Element getParent() { return parent; } /** *

* This will set the parent of this Element. *

* * @param parent Element to be new parent. * @return this ProcessingInstruction modified. */ protected UnescapedText setParent(Element parent) { this.parent = parent; return this; } /** *

* This retrieves the owning {@link Document} for * this PI, or null if not a currently a member of a * {@link Document}. *

* * @return Document owning this PI, or null. */ public Document getDocument() { if (document != null) { return document; } Element p = getParent(); if (p != null) { return p.getDocument(); } return null; } /** *

* This sets the {@link Document} parent of this PI. *

* * @param document Document parent * @return this PI modified */ protected UnescapedText setDocument(Document document) { this.document = document; return this; } /** *

* This returns a String representation of the * ProcessingInstruction, suitable for debugging. If the XML * representation of the ProcessingInstruction is desired, * {@link #getSerializedForm} should be used. *

* * @return String - information about the * ProcessingInstruction */ public String toString() { return unescapedText; } /** *

* This will return the Comment in XML format, * usable in an XML document. *

* * @return String - the serialized form of the * Comment. */ public final String getSerializedForm() { // Return or if no data then just return unescapedText; } /** *

* This tests for equality of this ProcessingInstruction * to the supplied Object. *

* * @param ob Object to compare to. * @return boolean - whether the * ProcessingInstruction is equal to the supplied * Object. */ public final boolean equals(Object ob) { return (ob == this); } /** *

* This returns the hash code for this ProcessingInstruction. *

* * @return int - hash code. */ public final int hashCode() { return super.hashCode(); } /** *

* This will return a clone of this ProcessingInstruction. *

* * @return Object - clone of this * ProcessingInstruction. */ public Object clone() { return new UnescapedText(unescapedText); } }