mixconfig.MixConfiguration Class Reference

List of all members.

Public Member Functions

 MixConfiguration () throws XMLParseException
 MixConfiguration (Reader r) throws XMLParseException, IOException
boolean setMixConfiguration (Reader r) throws XMLParseException, IOException
Document getDocument ()
void addChangeListener (ChangeListener a_changeListener)
void removeChangeListener (ChangeListener a_changeListener)
void save (Writer a_writer) throws IOException
boolean isSavedToFile ()
void setSavedToFile ()
File saveToFile () throws IOException
String[] getValues (String a_xmlPath)
String[] getValues (String a_xmlPath, String a_attribute, String a_attributeValue)
boolean isMixOnCDEnabled ()
boolean isAutoConfigurationAllowed ()
boolean isFallbackEnabled ()
boolean isAccountingNodePresent ()
void addAccounting ()
int getMixType ()
String getValue (String a_xmlPath)
void setValue (String a_xmlPath, String a_value)
void setValue (String a_xmlPath, String a_value, Attr a_attribute, boolean urlEncode)
void setValue (String a_xmlPath, boolean a_value)
void setValue (String a_xmlPath, int a_value)
void setValue (String a_xmlPath, byte[] a_value)
void setValue (String a_xmlPath, CascadePanel.MixListTableModel a_mixListModel)
void setValues (String a_xmlPath, String[] a_values)
void setValues (String a_xmlPath, String[] a_values, String a_attribute, String[] a_attrValues)
void setValue (String a_xmlPath, InfoServiceTableModel a_infoServiceModel)
void setValue (String a_xmlPath, IncomingConnectionTableModel a_inConnModel)
void setValue (String a_xmlPath, OutgoingConnectionTableModel a_outConnModel)
void setValue (String a_xmlPath, ProxyTableModel a_proxyTableModel)
void setValue (String a_xmlPath, XMLPriceCertificate a_cert)
void setValue (String a_xmlPath, Element a_elem)
void setAttribute (String a_xmlPath, String a_attribute, boolean a_Boolean)
void setAttribute (String a_xmlPath, String a_attribute, String a_value)
boolean hasAttribute (String a_xmlPath, String a_attribute)
String getAttributeValue (String a_xmlPath, String a_attribute)
boolean hasAttributes (String a_xmlPath)
void removeNode (String a_xmlPath)
void removeAttribute (String a_xmlPath, String a_attribute)
boolean performReloadCheck ()

Static Public Member Functions

static String getMixTypeAsString (int a_mixType)

Static Public Attributes

static final int MIXTYPE_FIRST = 1
static final int MIXTYPE_MIDDLE = 2
static final int MIXTYPE_LAST = 4
static final int LOG_NONE = 0
static final int LOG_CONSOLE = 1
static final int LOG_SYSLOG = 2
static final int LOG_DIRECTORY = 3
static final String XML_PATH_INFO_SERVICE = "InfoService"

Protected Member Functions

void fireStateChanged (String a_name, Object a_value)

Private Member Functions

void setDefaults ()
void initCheck ()
int getMixTypeAsInt (String a_s)
Node getAttributeNode (Node n, String a_namedItem)
Node getNode (String a_xmlPath, boolean create)

Static Private Member Functions

static Document open (InputSource r) throws XMLParseException, IOException

Private Attributes

Document m_configuration = null
boolean m_bSavedToFile = true
Vector< ChangeListener > m_changeListeners = new Vector<ChangeListener>()

Static Private Attributes

static final String MIXTYPE_NAME [] = {"FirstMix", "MiddleMix", "LastMix"}
static final String VERSION = "0.61"
static final String XML_ATTRIBUTE_VERSION = "version"


Detailed Description

This class provides unified access to the Mix configuration that is stored as a DOM document.

Author:
ronin <ronin2@web.de>

Johannes Renner


Constructor & Destructor Documentation

mixconfig.MixConfiguration.MixConfiguration (  )  throws XMLParseException

Constructs a new instance of MixConfiguration. The configuration contains only the root element and empty elements on the second level. The leaf elements are created as soon as the corresponding attributes are set.

Exceptions:
XMLParseException If parsing the configuration string causes an error

References mixconfig.MixConfiguration.m_configuration, mixconfig.MixConfiguration.setDefaults(), mixconfig.MixConfiguration.setSavedToFile(), and mixconfig.MixConfiguration.VERSION.

mixconfig.MixConfiguration.MixConfiguration ( Reader  r  )  throws XMLParseException, IOException

Constructs a new instance of MixConfiguration. The configuration is read from the specified java.io.Reader

Parameters:
r A Reader providing the configuration
Exceptions:
XMLParseException If an error occurs while parsing the input from the reader
IOException If an error occurs while reading the configuration

References mixconfig.MixConfiguration.setMixConfiguration(), and mixconfig.MixConfiguration.setSavedToFile().


Member Function Documentation

boolean mixconfig.MixConfiguration.setMixConfiguration ( Reader  r  )  throws XMLParseException, IOException

Set's a new MixConfiguration. Without creating a new Instance The configuration is read from the specified java.io.Reader

Parameters:
r A Reader providing the configuration
Returns:
true if an XML configuration file has been loaded; false otherwise
Exceptions:
XMLParseException If an error occurs while parsing the input from the reader
IOException If an error occurs while reading the configuration

References mixconfig.MixConfiguration.initCheck(), mixconfig.MixConfiguration.m_configuration, mixconfig.MixConfiguration.open(), and mixconfig.MixConfiguration.setSavedToFile().

Referenced by mixconfig.Menu.actionPerformed(), and mixconfig.MixConfiguration.MixConfiguration().

static String mixconfig.MixConfiguration.getMixTypeAsString ( int  a_mixType  )  [static]

Document mixconfig.MixConfiguration.getDocument (  ) 

void mixconfig.MixConfiguration.addChangeListener ( ChangeListener  a_changeListener  ) 

Adds a ChangeListener to this object's listeners list

Parameters:
a_changeListener A new ChangeListener to receive events every time an attribute changes

References mixconfig.MixConfiguration.m_changeListeners, and mixconfig.MixConfiguration.removeChangeListener().

void mixconfig.MixConfiguration.removeChangeListener ( ChangeListener  a_changeListener  ) 

Removes a ChangeListener to this object's listeners list

Parameters:
a_changeListener A ChangeListener in this objects listeners list

References mixconfig.MixConfiguration.m_changeListeners.

Referenced by mixconfig.MixConfiguration.addChangeListener().

void mixconfig.MixConfiguration.save ( Writer  a_writer  )  throws IOException

Write the configuration to the specified java.io.Writer. Normally this is a FileWriter to which an XML file is to be written.

Parameters:
a_writer A java.io.Writer to which to write the XML
Exceptions:
IOException If an error occurs while writing

References mixconfig.MixConfiguration.m_bSavedToFile, and mixconfig.MixConfiguration.m_configuration.

Referenced by mixconfig.Menu.actionPerformed(), and mixconfig.MixConfiguration.saveToFile().

boolean mixconfig.MixConfiguration.isSavedToFile (  ) 

Return if the configuration has been saved to a file.

Returns:
true if the configuration has been saved to a file; false otherwise

References mixconfig.MixConfiguration.m_bSavedToFile.

Referenced by mixconfig.Menu.actionPerformed().

void mixconfig.MixConfiguration.setSavedToFile (  ) 

File mixconfig.MixConfiguration.saveToFile (  )  throws IOException

Shows a file dialog and saves the configuration

Exceptions:
IOException If an I/O error occurs while saving the configuration
Returns:
the file if the saving succeeded, null if it was aborted by the user

References mixconfig.MixConfiguration.save().

String [] mixconfig.MixConfiguration.getValues ( String  a_xmlPath  ) 

Returns the values for all elements or attributes in the specified path.

Parameters:
a_xmlPath a path to an element or an attribute inside an element
Returns:
the values for all elements or attributes in the specified path

Referenced by mixconfig.panels.MixOnCDPanel.load(), and mixconfig.panels.MixOnCDPanel.loadPasswords().

String [] mixconfig.MixConfiguration.getValues ( String  a_xmlPath,
String  a_attribute,
String  a_attributeValue 
)

Returns the node values of elements with the specified attribute.

Parameters:
a_xmlPath String
a_attribute an attribute
a_attributeValue the attribute's wanted value
Returns:
String

References mixconfig.MixConfiguration.getNode().

boolean mixconfig.MixConfiguration.isMixOnCDEnabled (  ) 

boolean mixconfig.MixConfiguration.isAutoConfigurationAllowed (  ) 

Return true, if the mix may be configured by an info service

Returns:
true, if the mix may be configured by an info service; false otherwise

References mixconfig.MixConfiguration.getValue().

Referenced by mixconfig.panels.NextMixProxyPanel.check(), mixconfig.panels.PreviousMixPanel.enableComponents(), mixconfig.panels.NextMixProxyPanel.enableComponents(), and mixconfig.panels.GeneralPanel.load().

boolean mixconfig.MixConfiguration.isFallbackEnabled (  ) 

boolean mixconfig.MixConfiguration.isAccountingNodePresent (  ) 

Check if there is a tag <Accounting> in the XML TODO: Remove since it is not referenced?

Returns:
boolean

References mixconfig.MixConfiguration.m_configuration.

Referenced by mixconfig.MixConfiguration.initCheck(), and mixconfig.panels.PaymentPanel.stateChanged().

void mixconfig.MixConfiguration.addAccounting (  ) 

Add the node 'Accounting' and set default values

References mixconfig.MixConfiguration.setValue().

Referenced by mixconfig.MixConfiguration.setDefaults(), and mixconfig.panels.PaymentPanel.stateChanged().

int mixconfig.MixConfiguration.getMixType (  ) 

String mixconfig.MixConfiguration.getValue ( String  a_xmlPath  ) 

Returns the value of the attribute with the specified name. The name must be of the form "RootElement/ChildElement/ChildElement/... etc.", similar to the XPath syntax, but XPath functions and relative paths are not allowed.

Returns:
The attribute value as a String, or null if an element with this path does not exist.
Parameters:
a_xmlPath The path to the DOM element

References mixconfig.MixConfiguration.getMixTypeAsInt(), and mixconfig.MixConfiguration.getNode().

Referenced by mixconfig.panels.OwnCertificatesPanel.actionPerformed(), mixconfig.panels.CascadePanel.check(), mixconfig.panels.OwnCertificatesPanel.checkCertificateField(), mixconfig.panels.MixOnCDPanel.checkDHCPEnabled(), mixconfig.tools.EmailComposer.composeEmail(), mixconfig.panels.CascadePanel.enableComponents(), mixconfig.panels.OwnCertificatesPanel.OperatorCertCreationValidator.getExtensions(), mixconfig.panels.OwnCertificatesPanel.OwnCertCreationValidator.getExtensions(), mixconfig.MixConfiguration.getMixType(), mixconfig.panels.TermsAndConditionsPanel.getServiceOperator(), mixconfig.MixConfiguration.isAutoConfigurationAllowed(), mixconfig.MixConfiguration.isFallbackEnabled(), mixconfig.MixConfiguration.isMixOnCDEnabled(), mixconfig.panels.OwnCertificatesPanel.OperatorCertCreationValidator.isValid(), mixconfig.panels.OwnCertificatesPanel.OwnCertCreationValidator.isValid(), mixconfig.panels.OwnCertificatesPanel.load(), mixconfig.panels.MixConfigPanel.load(), mixconfig.panels.CascadePanel.load(), mixconfig.panels.AdvancedPanel.load(), mixconfig.panels.CascadePanel.recvMixList(), mixconfig.panels.MixConfigPanel.save(), mixconfig.panels.GeneralPanel.stateChanged(), mixconfig.panels.CascadePanel.stateChanged(), and mixconfig.panels.CascadePanel.MixListTableModel.toXmlElement().

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
String  a_value 
)

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
String  a_value,
Attr  a_attribute,
boolean  urlEncode 
)

Sets the value of the attribute with the specified name. The name must be of the form "RootElement/ChildElement/ChildElement/... etc.", similar to the XPath syntax, but XPath functions and relative paths are not allowed.

Parameters:
a_xmlPath The path to the DOM element
a_value The new node value for the element as a String
a_attribute Optional DOM attribute to be added to the DOM element
urlEncode Determines if the stored value is to be URL encoded (true or false)

References mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getNode(), and mixconfig.MixConfiguration.m_configuration.

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
boolean  a_value 
)

Set a Boolean node value

Parameters:
a_xmlPath The path to the DOM element
a_value The new (boolean) value for the node (to be converted to a String).

References mixconfig.MixConfiguration.setValue().

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
int  a_value 
)

Set an Integer node value

Parameters:
a_xmlPath The path to the DOM element
a_value The new (int) value for the node (to be converted to a String).

References mixconfig.MixConfiguration.getMixTypeAsString(), and mixconfig.MixConfiguration.setValue().

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
byte[]  a_value 
)

Sets the value of the attribute with the specified name. The name must be of the form "RootElement/ChildElement/ChildElement/... etc.", similar to the XPath syntax, but XPath functions and relative paths are not allowed.

Parameters:
a_xmlPath The path to the DOM element
a_value The new value for the attribute. The byte[] will be Base64-encoded before being saved.

References mixconfig.MixConfiguration.m_configuration, and mixconfig.MixConfiguration.setValue().

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
CascadePanel.MixListTableModel  a_mixListModel 
)

Converts the specified table model to a DOM tree and integrates it below the existing element with the specified name.

Parameters:
a_mixListModel An instance of mixconfig.CascadePanel.MixListTableModel
a_xmlPath The path to the DOM parent element of the connection element to be set

References mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getNode(), and mixconfig.MixConfiguration.m_configuration.

void mixconfig.MixConfiguration.setValues ( String  a_xmlPath,
String[]  a_values 
)

In the case that there is more than one value for a specified path, this method creates as many nodes with the same name as values.

Parameters:
a_xmlPath String
a_values String[]

Referenced by mixconfig.panels.MixOnCDPanel.save(), and mixconfig.panels.MixOnCDPanel.savePasswords().

void mixconfig.MixConfiguration.setValues ( String  a_xmlPath,
String[]  a_values,
String  a_attribute,
String[]  a_attrValues 
)

In the case that there is more than one value for a specified path, this method creates as many nodes with the same name as values. For each value it is possible to add one optional attribute.

Parameters:
a_xmlPath String
a_values String[]
a_attribute String
a_attrValues String[]

References mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getNode(), and mixconfig.MixConfiguration.m_configuration.

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
InfoServiceTableModel  a_infoServiceModel 
)

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
IncomingConnectionTableModel  a_inConnModel 
)

Converts the specified table model to a DOM tree and integrates it below the existing element with the specified name.

Parameters:
a_xmlPath The path to the DOM parent element of the connection element to be set
a_inConnModel An incoming connection table model

References mixconfig.network.IncomingConnectionTableModel.createAsElement(), mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getNode(), and mixconfig.MixConfiguration.m_configuration.

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
OutgoingConnectionTableModel  a_outConnModel 
)

Converts the specified table model to a DOM tree and integrates it below the existing element with the specified name.

Parameters:
a_xmlPath The path to the DOM parent element of the connection element to be set
a_outConnModel An outgoing connection table model

References mixconfig.network.OutgoingConnectionTableModel.createMixAsElement(), mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getNode(), mixconfig.MixConfiguration.m_configuration, and mixconfig.MixConfiguration.removeNode().

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
ProxyTableModel  a_proxyTableModel 
)

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
XMLPriceCertificate  a_cert 
)

void mixconfig.MixConfiguration.setValue ( String  a_xmlPath,
Element  a_elem 
)

Save a XML Element to the configuration

Parameters:
a_xmlPath 
a_cert 

References mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getNode(), and mixconfig.MixConfiguration.removeNode().

void mixconfig.MixConfiguration.setAttribute ( String  a_xmlPath,
String  a_attribute,
boolean  a_Boolean 
)

void mixconfig.MixConfiguration.setAttribute ( String  a_xmlPath,
String  a_attribute,
String  a_value 
)

Set an attribute to an element specified by an XML path, create the element if not existent

Parameters:
a_xmlPath Path to a DOM node
a_attribute Attribute name
a_value Attribute value

References mixconfig.MixConfiguration.fireStateChanged(), mixconfig.MixConfiguration.getDocument(), and mixconfig.MixConfiguration.getNode().

boolean mixconfig.MixConfiguration.hasAttribute ( String  a_xmlPath,
String  a_attribute 
)

Check the existence of a specific attribute at a certain xmlPath

Parameters:
a_xmlPath 
a_attribute 
Returns:

References mixconfig.MixConfiguration.getNode().

Referenced by mixconfig.MixConfiguration.initCheck().

String mixconfig.MixConfiguration.getAttributeValue ( String  a_xmlPath,
String  a_attribute 
)

Return the value of a certain attribute or null if the attribute does not exist

Parameters:
a_xmlPath 
a_attribute 
Returns:

References mixconfig.MixConfiguration.getNode().

Referenced by mixconfig.panels.PaymentPanel.isPaymentEnabled(), mixconfig.panels.GeneralPanel.load(), and mixconfig.panels.GeneralPanel.save().

boolean mixconfig.MixConfiguration.hasAttributes ( String  a_xmlPath  ) 

void mixconfig.MixConfiguration.removeNode ( String  a_xmlPath  ) 

void mixconfig.MixConfiguration.removeAttribute ( String  a_xmlPath,
String  a_attribute 
)

void mixconfig.MixConfiguration.fireStateChanged ( String  a_name,
Object  a_value 
) [protected]

Sends a ConfigurationEvent with the specified attribute name and value to all ChangeListeners. This method is called whenever the value of a node or attribute changes.

Parameters:
a_name The name of the changed attribute
a_value The new value

References mixconfig.MixConfiguration.getMixTypeAsInt(), mixconfig.MixConfiguration.m_bSavedToFile, and mixconfig.MixConfiguration.m_changeListeners.

Referenced by mixconfig.MixConfiguration.removeAttribute(), mixconfig.MixConfiguration.removeNode(), mixconfig.MixConfiguration.setAttribute(), mixconfig.MixConfiguration.setValue(), and mixconfig.MixConfiguration.setValues().

void mixconfig.MixConfiguration.setDefaults (  )  [private]

void mixconfig.MixConfiguration.initCheck (  )  [private]

Check for the existence of certain elements, attributes and set values accordingly. Call this method when loading a configuration e.g. from file.

References mixconfig.MixConfiguration.hasAttribute(), mixconfig.MixConfiguration.isAccountingNodePresent(), and mixconfig.MixConfiguration.setAttribute().

Referenced by mixconfig.MixConfiguration.setMixConfiguration().

boolean mixconfig.MixConfiguration.performReloadCheck (  ) 

FIXME: Rather make this a private method?

Perform a check by writing out the document to a string and reloading it again. To be called before the XML document is saved.

Returns:
true if the check succeeds, false otherwise

References mixconfig.MixConfiguration.m_configuration.

Referenced by mixconfig.Menu.actionPerformed().

int mixconfig.MixConfiguration.getMixTypeAsInt ( String  a_s  )  [private]

Returns the MIXTYPE_xxx constant corresponding to the specified Mix type name.

Parameters:
a_s A String representing a Mix type (first, middle or last)
Returns:
One of the MIXTYPE_xxx constants

References mixconfig.MixConfiguration.MIXTYPE_NAME.

Referenced by mixconfig.MixConfiguration.fireStateChanged(), and mixconfig.MixConfiguration.getValue().

Node mixconfig.MixConfiguration.getAttributeNode ( Node  n,
String  a_namedItem 
) [private]

Return a node's attribute given by name

Parameters:
n 
a_namedItem 
Returns:
The named attribute node

Referenced by mixconfig.MixConfiguration.getNode().

Node mixconfig.MixConfiguration.getNode ( String  a_xmlPath,
boolean  create 
) [private]

Gets the DOM node with the specified name. The name must be of the form "RootElement/ChildElement/ChildElement/... etc.", similar to the XPath syntax, but XPath functions and relative paths are not allowed.

Parameters:
a_xmlPath The path to the DOM element
create if true, the node is created if it does not exist
Returns:
The node with the specified path, or null there is no such node and create was set to false

References mixconfig.MixConfiguration.getAttributeNode(), and mixconfig.MixConfiguration.m_configuration.

Referenced by mixconfig.MixConfiguration.getAttributeValue(), mixconfig.MixConfiguration.getValue(), mixconfig.MixConfiguration.getValues(), mixconfig.MixConfiguration.hasAttribute(), mixconfig.MixConfiguration.hasAttributes(), mixconfig.MixConfiguration.removeAttribute(), mixconfig.MixConfiguration.removeNode(), mixconfig.MixConfiguration.setAttribute(), mixconfig.MixConfiguration.setValue(), and mixconfig.MixConfiguration.setValues().

static Document mixconfig.MixConfiguration.open ( InputSource  r  )  throws XMLParseException, IOException [static, private]

Open the specified input source (normally a Reader corresponding to an XML file) and read the DOM tree from it.

Parameters:
r the input source
Exceptions:
XMLParseException If an error occurs while parsing the input
IOException If an error occurs while reading the configuration
Returns:
A DOM document containing the configuration

References mixconfig.MixConfiguration.VERSION, and mixconfig.MixConfiguration.XML_ATTRIBUTE_VERSION.

Referenced by mixconfig.MixConfiguration.setMixConfiguration().


Member Data Documentation

Indicates that the Mix is within a cascade

Referenced by mixconfig.MixConfiguration.getMixTypeAsString().

final int mixconfig.MixConfiguration.LOG_NONE = 0 [static]

Indicates that no logging should take place

Indicates that logging output should be printed to the console

final int mixconfig.MixConfiguration.LOG_SYSLOG = 2 [static]

Indicates that logging output should be sent to the system log service

Indicates that logging output should be saved to a directory

final String mixconfig.MixConfiguration.XML_PATH_INFO_SERVICE = "InfoService" [static]

final String mixconfig.MixConfiguration.MIXTYPE_NAME[] = {"FirstMix", "MiddleMix", "LastMix"} [static, private]

An array containing the Mix types as String values. The indices correspond to the MIXTYPE_xxx constants

Referenced by mixconfig.MixConfiguration.getMixTypeAsInt(), and mixconfig.MixConfiguration.getMixTypeAsString().

final String mixconfig.MixConfiguration.VERSION = "0.61" [static, private]

The configuration file information version number.

Referenced by mixconfig.MixConfiguration.MixConfiguration(), and mixconfig.MixConfiguration.open().

final String mixconfig.MixConfiguration.XML_ATTRIBUTE_VERSION = "version" [static, private]

Document mixconfig.MixConfiguration.m_configuration = null [private]

Vector<ChangeListener> mixconfig.MixConfiguration.m_changeListeners = new Vector<ChangeListener>() [private]

A list of ChangeListeners receiving events from this object whenever the value of an attribute changes

Referenced by mixconfig.MixConfiguration.addChangeListener(), mixconfig.MixConfiguration.fireStateChanged(), and mixconfig.MixConfiguration.removeChangeListener().


The documentation for this class was generated from the following file:

Generated on Mon Nov 16 23:24:47 2009 for MixConfig by  doxygen 1.5.6