Package org.jdom.input
Class DOMBuilder
- java.lang.Object
-
- org.jdom.input.DOMBuilder
-
public class DOMBuilder extends Object
Builds a JDOM Document from a pre-existing DOMorg.w3c.dom.Document.If you are building a document that has Namespace declarations, you should ensure that the Namespaces are correctly recorded in the DOM document before building the JDOM document from the DOM. By default, the native Java DOMBuilderFactory is configured to ignore Namespaces, and thus they are 'lost' in the DOM tree. JDOM expects Namespace-aware documents, so you should ensure that you change the default settings on the DOMBuilderFactory before parsing the DOM document. For example:
DocumentBuilderFactory domfactory = DocumentBuilderFactory.newInstance(); domfactory.setNamespaceAware(true); DocumentBuilder dombuilder = domfac.newDocumentBuilder(); org.w3c.dom.Document doc = dombuilder.parse(....);
-
-
Constructor Summary
Constructors Constructor Description DOMBuilder()This creates a new DOMBuilder instance using the DefaultJDOMFactory to build the JDOM content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CDATAbuild(CDATASection cdata)This will build a JDOM CDATA from an existing DOM CDATASectionCommentbuild(Comment comment)This will build a JDOM Comment from an existing DOM CommentDocumentbuild(Document domDocument)This will build a JDOM tree from an existing DOM tree.DocTypebuild(DocumentType doctype)This will build a JDOM Element from an existing DOM ElementElementbuild(Element domElement)This will build a JDOM Element from an existing DOM ElementEntityRefbuild(EntityReference er)This will build a JDOM EntityRef from an existing DOM EntityReferenceProcessingInstructionbuild(ProcessingInstruction pi)This will build a JDOM ProcessingInstruction from an existing DOM ProcessingInstructionTextbuild(Text text)This will build a JDOM Text from an existing DOM TextJDOMFactorygetFactory()Returns the currentJDOMFactoryin use.voidsetFactory(JDOMFactory factory)This sets a custom JDOMFactory for the builder.
-
-
-
Method Detail
-
setFactory
public void setFactory(JDOMFactory factory)
This sets a custom JDOMFactory for the builder. Use this to build the tree with your own subclasses of the JDOM classes.- Parameters:
factory-JDOMFactoryto use
-
getFactory
public JDOMFactory getFactory()
Returns the currentJDOMFactoryin use.- Returns:
- the factory in use
-
build
public Document build(Document domDocument)
This will build a JDOM tree from an existing DOM tree.- Parameters:
domDocument-org.w3c.dom.Documentobject- Returns:
Document- JDOM document object.
-
build
public Element build(Element domElement)
This will build a JDOM Element from an existing DOM Element- Parameters:
domElement-org.w3c.dom.Elementobject- Returns:
Element- JDOM Element object
-
build
public CDATA build(CDATASection cdata)
This will build a JDOM CDATA from an existing DOM CDATASection- Parameters:
cdata-org.w3c.dom.CDATASectionobject- Returns:
CDATA- JDOM CDATA object- Since:
- JDOM2
-
build
public Text build(Text text)
This will build a JDOM Text from an existing DOM Text- Parameters:
text-org.w3c.dom.Textobject- Returns:
Text- JDOM Text object- Since:
- JDOM2
-
build
public Comment build(Comment comment)
This will build a JDOM Comment from an existing DOM Comment- Parameters:
comment-org.w3c.dom.Commentobject- Returns:
Comment- JDOM Comment object- Since:
- JDOM2
-
build
public ProcessingInstruction build(ProcessingInstruction pi)
This will build a JDOM ProcessingInstruction from an existing DOM ProcessingInstruction- Parameters:
pi-org.w3c.dom.ProcessingInstructionobject- Returns:
ProcessingInstruction- JDOM ProcessingInstruction object- Since:
- JDOM2
-
build
public EntityRef build(EntityReference er)
This will build a JDOM EntityRef from an existing DOM EntityReference- Parameters:
er-org.w3c.dom.EntityReferenceobject- Returns:
EnityRef- JDOM EntityRef object- Since:
- JDOM2
-
build
public DocType build(DocumentType doctype)
This will build a JDOM Element from an existing DOM Element- Parameters:
doctype-org.w3c.dom.Elementobject- Returns:
Element- JDOM Element object- Since:
- JDOM2
-
-