## model
Class XMLFactory

    java.lang.Object
      model.XMLFactory

    public class XMLFactory

extends java.lang.Object

Helper class for XMLFile

Constructor Summary
`XMLFactory()`

Method Summary
`protected static org.w3c.dom.Element` `createDiscountElement(org.w3c.dom.Document doc, Discount discount)` Creates an XML element with subelements that can be used to store data from a Discount object
`protected static org.w3c.dom.Element` `createEntryElement(org.w3c.dom.Document doc, Entry entry)` Creates an XML element with subelements that can be used to store data from an Entry object
`protected static org.w3c.dom.Document` `createXMLDataDocument()` Creates an empty XML data document with the correct element structure
`protected static org.w3c.dom.Document` `createXMLDataDocument(java.io.File xml_file)` Creates an XML document based on a XML document file
`protected static org.w3c.dom.Element[]` `getSubElements(org.w3c.dom.Element element, java.lang.String... sub_element_names)` Returns a descendant of the parameter 'element'.
`protected static java.lang.String` `getSubElementText(org.w3c.dom.Element element, java.lang.String... sub_element_names)` Returns the sub element text content of a descendant of the parameter 'element'.
`protected static Entry` `parseEntry(org.w3c.dom.Element entry_elem, EntryInitializer initializer)` Creates a new Entry object from the entry XML element
`protected static org.w3c.dom.Element` `removeElement(org.w3c.dom.Element element)` Removes an XML element from a document.
`protected static java.lang.String` `setSubElementText(org.w3c.dom.Element element, java.lang.String new_text, java.lang.String... sub_element_names)` Sets the sub element text content of a descendant of the parameter 'element'.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XMLFactory

    public XMLFactory()

Method Detail

### createEntryElement

    protected static org.w3c.dom.Element createEntryElement(org.w3c.dom.Document doc,
                                                            Entry entry)

  Creates an XML element with subelements that can be used to store data from an Entry object

  Parameters:
    `doc` - parent document
    `entry` - the entry to be stored
  Returns:
    an XML element named 'entry' with data from theentry

### createDiscountElement

    protected static org.w3c.dom.Element createDiscountElement(org.w3c.dom.Document doc,
                                                               Discount discount)

  Creates an XML element with subelements that can be used to store data from a Discount object

  Parameters:
    `doc` - parent document
    `discount` - the discount to be stored
  Returns:
    an XML element named 'discount' with data from the discount

### parseEntry

    protected static Entry parseEntry(org.w3c.dom.Element entry_elem,
                                      EntryInitializer initializer)
                               throws GoException

  Creates a new Entry object from the entry XML element

  Parameters:
    `entry_elem` - XML element
    `initializer` - used to set the data of the new entry
  Returns:
    new Entry object
  Throws:
    `GoException` - throw if the initializer can't be read

### createXMLDataDocument

    protected static org.w3c.dom.Document createXMLDataDocument(java.io.File xml_file)
                                                         throws XMLParsingException

  Creates an XML document based on a XML document file

  Parameters:
    `xml_file` - XML data file
  Returns:
    an XML document
  Throws:
    `XMLParsingException`

### createXMLDataDocument

    protected static org.w3c.dom.Document createXMLDataDocument()
                                                         throws GoException

  Creates an empty XML data document with the correct element structure

  Returns:
    XML data document
  Throws:
    `GoException`

### getSubElementText

    protected static java.lang.String getSubElementText(org.w3c.dom.Element element,
                                                        java.lang.String... sub_element_names)

  Returns the sub element text content of a descendant of the parameter 'element'. (see method getSubElements)

### setSubElementText

    protected static java.lang.String setSubElementText(org.w3c.dom.Element element,
                                                        java.lang.String new_text,
                                                        java.lang.String... sub_element_names)

  Sets the sub element text content of a descendant of the parameter 'element'. (see method getSubElements)

### getSubElements

    protected static org.w3c.dom.Element[] getSubElements(org.w3c.dom.Element element,
                                                          java.lang.String... sub_element_names)

  Returns a descendant of the parameter 'element'. The descendant is found by going down the element tree according to the 'sub_element_names' parameters.

### removeElement

    protected static org.w3c.dom.Element removeElement(org.w3c.dom.Element element)

  Removes an XML element from a document.