maiolum.xml
Class XMLEdition

java.lang.Object
  extended bymaiolum.Edition
      extended bymaiolum.xml.XMLEdition

public class XMLEdition
extends Edition

Represents "metadata" like language, title, date and place of issue about logical units; these data are loaded from the XML file;


Field Summary
protected static java.util.Vector availEditions
          Vector of available Editions, i. e.
private static org.apache.log4j.Logger logger
          Logger associated with this class
protected static java.lang.String URI
          Current URI for the XML file containing language metadata.
protected static org.w3c.dom.Document xmlEditions
          DOM representation of the XML document, from which will be the Editions loaded
 
Fields inherited from class maiolum.Edition
ID, locale, title, translator, year
 
Constructor Summary
XMLEdition()
          Empty constructor.
XMLEdition(java.io.File editionsFile)
          Deprecated.  
XMLEdition(java.lang.String ID)
          Creates new XMLEdition with given ID and retrieves available metadata (language, translator etc.) about this XMLEdition from the internal representation of the XML file with data
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether one XMLEdition is "equal to" another Object.
 Edition[] getAvailableEditions()
          Returns array of available Editions, i. e.
private  java.lang.String getEditionElementChildValue(org.w3c.dom.Element elementNode, java.lang.String elementName)
          Returns String value of child element of <edition> elements.
 java.lang.String getURI()
          Returns URI pointing to the location of XML file containing Editions metadata.
protected  void loadAvailableLocales()
          Converts data contained in the DOM representation of data XML file to Edition objects.
protected  void loadXML(java.lang.String URI)
          Loads XML file from location given by URI parameter.
static void main(java.lang.String[] args)
           
private  Edition setEditionData(Edition edition, org.w3c.dom.Element el)
          Returns new Edition, which is Edition parameter with properties retrieved from children of the given < code>Element.
private  Edition setEditionData(Edition edition, java.lang.String ID)
          Returns new Edition, which is Edition with specified ID, having properties retrieved from children of the <edition> element corresponding to the given ID.
 void setURI(java.lang.String URI)
          Sets the URI (for example filename) of the XML file containing Editions metada.
 java.lang.String toString()
          Returns
 
Methods inherited from class maiolum.Edition
getID, getLocale, getTitle, getTranslator, getYear, setID, setLocale, setTitle, setTranslator, setYear
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static org.apache.log4j.Logger logger
Logger associated with this class


availEditions

protected static java.util.Vector availEditions
Vector of available Editions, i. e. Editions, that were successfully loaded from the XML file. This static Vector of available Editions is common to all instances of XMLEdition.


URI

protected static java.lang.String URI
Current URI for the XML file containing language metadata. Typically, this is languages.xml file with appropriate path. This static value is common to all instances of XMLEdition class. Default value is path to the languages.xml in user's home directory.


xmlEditions

protected static org.w3c.dom.Document xmlEditions
DOM representation of the XML document, from which will be the Editions loaded

Constructor Detail

XMLEdition

public XMLEdition()
           throws java.util.prefs.BackingStoreException
Empty constructor. Creates new XMLEdition with default values and loads available Editions from XML file, if necessary.

Throws:
java.util.prefs.BackingStoreException - when Edition metadata could not be load.

XMLEdition

public XMLEdition(java.io.File editionsFile)
           throws java.util.prefs.BackingStoreException
Deprecated.  

Creates new XMLEdition while reloading available languages from the given XML File. This behavior is as follows: - calling this constructor changes the URI globally for all XMLEdition objects and reloads language data from languages.xml file (reloading affects all instances, too)


XMLEdition

public XMLEdition(java.lang.String ID)
           throws java.util.prefs.BackingStoreException
Creates new XMLEdition with given ID and retrieves available metadata (language, translator etc.) about this XMLEdition from the internal representation of the XML file with data

Method Detail

setURI

public void setURI(java.lang.String URI)
Sets the URI (for example filename) of the XML file containing Editions metada. Metadata will be reloaded from this file. This will affect all instances of XMLEdition class.

Throws:
java.lang.IllegalArgumentException - when languages metadata could not be load from the specified URI.

getURI

public java.lang.String getURI()
Returns URI pointing to the location of XML file containing Editions metadata.


loadXML

protected void loadXML(java.lang.String URI)
                throws java.util.prefs.BackingStoreException
Loads XML file from location given by URI parameter. The XML file is loaded into DOM representation and normalized.

Throws:
java.util.prefs.BackingStoreException - when XML file cannot be load or parsed properly.

getAvailableEditions

public Edition[] getAvailableEditions()
Returns array of available Editions, i. e. Editions, that were stated and successfully loaded from the given XML file. If internal list of available locations is empty, method tries to reload it from the location given by URI.


loadAvailableLocales

protected void loadAvailableLocales()
Converts data contained in the DOM representation of data XML file to Edition objects.


getEditionElementChildValue

private java.lang.String getEditionElementChildValue(org.w3c.dom.Element elementNode,
                                                     java.lang.String elementName)
Returns String value of child element of <edition> elements. Actually it allows to return text values of direct descendants of <edition> -- it is similar to key = value representation. See structure of editions.xml.


setEditionData

private Edition setEditionData(Edition edition,
                               java.lang.String ID)
                        throws java.util.prefs.BackingStoreException
Returns new Edition, which is Edition with specified ID, having properties retrieved from children of the <edition> element corresponding to the given ID.

If the Edition parameter is null, properties are set on this variable. This Element must be element <edition>, and must have (by the languages.xml id, lang, title, translator, year

Throws:
java.util.prefs.BackingStoreException

setEditionData

private Edition setEditionData(Edition edition,
                               org.w3c.dom.Element el)
                        throws java.util.prefs.BackingStoreException
Returns new Edition, which is Edition parameter with properties retrieved from children of the given < code>Element. If the Edition parameter is null, new Edition is instantiated, properties are set and returned.

properties are set on this variable. This Element must be element <edition>, and must have (by the languages.xml id, lang, title, translator, year

Throws:
java.util.prefs.BackingStoreException

equals

public boolean equals(java.lang.Object o)
Indicates whether one XMLEdition is "equal to" another Object.

Two XMLEdition objects are equal, when both are instances of XMLEdition class and all of their metadata attributes are equal.

Returns:
true, when both XMLEdition objects are equal, otherwise returns false.

toString

public java.lang.String toString()
Returns

Overrides:
toString in class Edition

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception