001: /**
002: * org/ozone-db/xml/dom/DocumentFragmentImpl.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 lightweight or minimal {@link org.w3c.dom.Document}.
030: * Primarily used to carry document parts from one document to another,
031: * or to hold impartial documents without maintaining any {@link
032: * org.w3c.dom.Document} consistency rules on them.
033: * <P>
034: * Notes:
035: * <OL>
036: * <LI>Node type is {@link org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE}
037: * <LI>Node supports childern
038: * <LI>Node name is always "#document-fragment"
039: * <LI>Node does not have a value
040: * <LI>Special rules apply when adding fragment to other nodes (see
041: * {@link org.w3c.dom.Node#appendChild}).
042: * </OL>
043: *
044: *
045: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
046: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
047: * @see org.w3c.dom.DocumentFragment
048: * @see NodeImpl
049: */
050: public final class DocumentFragmentImpl extends NodeImpl implements
051: DocumentFragmentProxy {
052:
053: final static long serialVersionUID = 1;
054:
055: public short getNodeType() {
056: return DOCUMENT_FRAGMENT_NODE;
057: }
058:
059: public final void setNodeValue(String value) {
060: throw new DOMExceptionImpl(DOMException.NO_DATA_ALLOWED_ERR,
061: "This node type does not support values.");
062: }
063:
064: protected boolean supportsChildern() {
065: return true;
066: }
067:
068: public final Object clone() {
069: TextProxy clone = null;
070: try {
071: clone = (TextProxy) database().createObject(
072: TextImpl.class.getName());
073: clone.init(_ownerDocument, getNodeValue());
074: cloneInto((NodeProxy) clone, true);
075: } catch (Exception except) {
076: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
077: except.getMessage());
078: }
079: return clone;
080: }
081:
082: public final Node cloneNode(boolean deep) {
083: TextProxy clone = null;
084: try {
085: clone = (TextProxy) database().createObject(
086: TextImpl.class.getName());
087: clone.init(_ownerDocument, getNodeValue());
088: cloneInto((NodeProxy) clone, deep);
089: } catch (Exception except) {
090: throw new DOMExceptionImpl(DOMExceptionImpl.PDOM_ERR,
091: except.getMessage());
092: }
093: return clone;
094: }
095:
096: public String toString() {
097: return "Document Fragment (" + getChildCount() + " nodes)";
098: }
099:
100: /**
101: * Constructor requires only document owner.
102: */
103: DocumentFragmentImpl(DocumentImpl owner) {
104: super (owner, "#document-fragment", null, false);
105: }
106:
107: public DocumentFragmentImpl() {
108: super ();
109: }
110:
111: public final void init(DocumentProxy owner, String value) {
112: super .init(owner, "#document-fragment", value, false);
113: }
114:
115: }
|