org.jopendocument.dom
Class ChildCreator

java.lang.Object
  extended by org.jopendocument.dom.ChildCreator

public class ChildCreator
extends Object

A helper to create children in the schema order.

Author:
Sylvain CUAZ

Constructor Summary
ChildCreator(org.jdom.Element content, org.jdom.Element... children)
           
ChildCreator(org.jdom.Element content, List<org.jdom.Element> children)
          Create a new instance to add children to content.
 
Method Summary
 org.jdom.Element addChild(org.jdom.Namespace childNS, String childName)
           
static ChildCreator createFromSets(org.jdom.Element content, List<Set<org.jdom.Element>> children)
          Create a new instance to add children to content.
 org.jdom.Element getChild(org.jdom.Element child, boolean create)
           
 org.jdom.Element getChild(org.jdom.Namespace childNS, String childName)
           
 org.jdom.Element getChild(org.jdom.Namespace childNS, String childName, boolean create)
          Return the asked child, optionally creating it.
 org.jdom.Element getElement()
           
 void setChild(org.jdom.Element elem)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChildCreator

public ChildCreator(org.jdom.Element content,
                    List<org.jdom.Element> children)
Create a new instance to add children to content.

Parameters:
content - the parent element where to create children.
children - the elements in the order they must appear inside content. One null can be included, it matches any element.
Throws:
IllegalArgumentException - if a child is specified more than once in children.
See Also:
createFromSets(Element, List)

ChildCreator

public ChildCreator(org.jdom.Element content,
                    org.jdom.Element... children)
Method Detail

createFromSets

public static ChildCreator createFromSets(org.jdom.Element content,
                                          List<Set<org.jdom.Element>> children)
Create a new instance to add children to content. This method accepts a list of set to be able to specify more than one element for the same index.

Parameters:
content - the parent element where to create children.
children - the elements in the order they must appear inside content. One null can be included, it matches any element.
Returns:
a new instance.
Throws:
IllegalArgumentException - if a child is specified more than once in children or if a set is empty.
See Also:
ChildCreator(Element, List)

getElement

public final org.jdom.Element getElement()

getChild

public final org.jdom.Element getChild(org.jdom.Namespace childNS,
                                       String childName)

getChild

public final org.jdom.Element getChild(org.jdom.Element child,
                                       boolean create)

getChild

public final org.jdom.Element getChild(org.jdom.Namespace childNS,
                                       String childName,
                                       boolean create)
Return the asked child, optionally creating it.

Parameters:
childNS - the namespace of the child.
childName - the name of the child.
create - whether it should be created in case it doesn't exist.
Returns:
the asked child or null if it doesn't exist and create is false

addChild

public final org.jdom.Element addChild(org.jdom.Namespace childNS,
                                       String childName)

setChild

public final void setChild(org.jdom.Element elem)


Copyright © 2010 jOpenDocument All Rights Reserved.