Project JXTA

net.jxta.document
Class StructuredDocumentUtils

java.lang.Object
  |
  +--net.jxta.document.StructuredDocumentUtils

public final class StructuredDocumentUtils
extends java.lang.Object

Provides a number of static utility members which are helpful in manipluating StructuredDocuments.

Since:
JXTA 1.0
Version:
$Revision: 1.10 $

Constructor Summary
StructuredDocumentUtils()
           
 
Method Summary
static StructuredDocument copyAsDocument(Element from)
          copies the given element or document into a standalone document of same encoding, using the element's name as the document type and recursively copying all elements textValues and children to the new document.
static void copyChildren(StructuredDocument intoDoc, Element intoElement, Element from)
          Recursively copy children elements of from into the the element intoElement of document intoDoc.
static void copyElements(StructuredDocument intoDoc, Element intoElement, Element from)
          Recursively copy elements beginnging with from into the document identified by intoDoc.
static void copyElements(StructuredDocument intoDoc, Element intoElement, Element from, java.lang.Object newName)
          Recursively copy elements beginnging with from into the document identified by intoDoc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructuredDocumentUtils

public StructuredDocumentUtils()
Method Detail

copyChildren

public static void copyChildren(StructuredDocument intoDoc,
                                Element intoElement,
                                Element from)
Recursively copy children elements of from into the the element intoElement of document intoDoc.

BEWARE that this does NOT copy the TEXTVALUE (if any) of the fromParent element, ONLY CHILDREN. All other elements are fully copied, including their textValue.

It is not possible to copy a textValue in an existing element.

Parameters:
intoDoc - the document into which the elements will be copied.
intoElement - the element which will serve as the parent for the elements being copied.
from - the parent element of the elements which will be copied.

copyElements

public static void copyElements(StructuredDocument intoDoc,
                                Element intoElement,
                                Element from,
                                java.lang.Object newName)
Recursively copy elements beginnging with from into the document identified by intoDoc.
Parameters:
intoDoc - the document into which the elements which will be copied.
intoElement - the element which will serve as the parent for the elements being copied.
from - the root element of the hierarchy which will be copied.
newName - the root element being copied is renamed newName.

copyElements

public static void copyElements(StructuredDocument intoDoc,
                                Element intoElement,
                                Element from)
Recursively copy elements beginnging with from into the document identified by intoDoc.
Parameters:
intoDoc - the document into which the elements which will be copied.
intoElement - the element which will serve as the parent for the elements being copied.
from - the root element of the hierarchy which will be copied.

copyAsDocument

public static StructuredDocument copyAsDocument(Element from)
copies the given element or document into a standalone document of same encoding, using the element's name as the document type and recursively copying all elements textValues and children to the new document. The copy of the given element is the root of the new document.
Parameters:
from - the root element from which to begin copying.
Returns:
StructuredDocument the copy

Project JXTA