com.izforge.izpack.panels.userinput.field
Class Config

java.lang.Object
  extended by com.izforge.izpack.panels.userinput.field.Config

public class Config
extends Object

User input configuration.

Author:
Tim Anderson

Constructor Summary
Config(String path, Resources resources, InstallData installData, ObjectFactory factory, Messages messages)
          Constructs a Config.
 
Method Summary
 Alignment getAlignment(IXMLElement element, String name, Alignment defaultValue)
          Returns the named alignment value, replacing any variables present.
 String getAttribute(IXMLElement element, String name)
          Returns the named attribute value.
 String getAttribute(IXMLElement element, String name, boolean optional)
          Returns the named attribute value.
 boolean getBoolean(IXMLElement element, String name, boolean defaultValue)
          Returns the named attribute as an integer.
 Boolean getBooleanOrNull(IXMLElement element, String name)
          Returns the named attribute as an integer in a three-state logic.
 String getContext(IXMLElement element)
          Returns the context of an element, for error reporting purposes.
 IXMLElement getElement(IXMLElement parent, String name)
          Returns the named element.
 ObjectFactory getFactory()
          Returns a factory for creating configuration items.
 int getInt(IXMLElement element, String name, int defaultValue)
          Returns the named attribute as an integer.
 String getLocalString(String value)
          Returns a localised version of a string.
 String getPath()
          Returns the configuration file path.
 String getRawString(IXMLElement element, String name, String defaultValue)
          Returns the named attribute value without replacing any variables present.
 IXMLElement getRoot()
          Returns the root element.
 String getString(IXMLElement element, String name, String defaultValue)
          Returns the named attribute value, replacing any variables present.
 String getText(IXMLElement element)
          Extracts the text from an element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config

public Config(String path,
              Resources resources,
              InstallData installData,
              ObjectFactory factory,
              Messages messages)
Constructs a Config.

Parameters:
path - the resource path
resources - the resources
installData - the installation data
factory - the factory
messages - the messages
Method Detail

getPath

public String getPath()
Returns the configuration file path.

Returns:
the file path

getRoot

public IXMLElement getRoot()
Returns the root element.

Returns:
the root element

getElement

public IXMLElement getElement(IXMLElement parent,
                              String name)
Returns the named element.

Parameters:
parent - the parent element
name - the element name
Returns:
the corresponding element
Throws:
IzPackException - if the element is not found

getAttribute

public String getAttribute(IXMLElement element,
                           String name)
Returns the named attribute value.

Parameters:
element - the element
name - the attribute name
Returns:
the attribute value
Throws:
IzPackException - if the attribute is not found

getAttribute

public String getAttribute(IXMLElement element,
                           String name,
                           boolean optional)
Returns the named attribute value.

Parameters:
element - the element
name - the attribute name
optional - flag to allow null to be returned if attribute is optional
Returns:
the attribute value, or null if attribute does not exist and attribute is optional
Throws:
IzPackException - if the attribute is not found and attribute is required

getString

public String getString(IXMLElement element,
                        String name,
                        String defaultValue)
Returns the named attribute value, replacing any variables present.

Parameters:
element - the element
name - the attribute name
defaultValue - the default value if the attribute isn't set
Returns:
the corresponding value

getRawString

public String getRawString(IXMLElement element,
                           String name,
                           String defaultValue)
Returns the named attribute value without replacing any variables present.

Parameters:
element - the element
name - the attribute name
defaultValue - the default value if the attribute isn't set
Returns:
the corresponding value

getLocalString

public String getLocalString(String value)
Returns a localised version of a string.

Parameters:
value - the string value
Returns:
the localised version of value, or value if there is no localised version

getInt

public int getInt(IXMLElement element,
                  String name,
                  int defaultValue)
Returns the named attribute as an integer.

Any variables are replaced.

Parameters:
element - the element name
name - the attribute name
defaultValue - the value to return if the attribute isn't set or is invalid
Returns:
the attribute value or defaultValue if it isn't set or is invalid

getBoolean

public boolean getBoolean(IXMLElement element,
                          String name,
                          boolean defaultValue)
Returns the named attribute as an integer.

Parameters:
element - the element name
name - the attribute name
defaultValue - the value to return if the attribute isn't set or is invalid
Returns:
the attribute value or defaultValue if it isn't set or is invalid

getBooleanOrNull

public Boolean getBooleanOrNull(IXMLElement element,
                                String name)
Returns the named attribute as an integer in a three-state logic.

Parameters:
element - the element name
name - the attribute name
Returns:
the attribute value as Boolean or null if it isn't set or is invalid

getText

public String getText(IXMLElement element)
Extracts the text from an element. The text can be defined:
  1. in the locale's messages, under the key defined by the id attribute; or
  2. as value of the attribute txt.

Parameters:
element - the element from which to extract the text
Returns:
the text, or null if none can be found

getAlignment

public Alignment getAlignment(IXMLElement element,
                              String name,
                              Alignment defaultValue)
Returns the named alignment value, replacing any variables present.

Parameters:
element - the element
name - the attribute name
defaultValue - the default value if the attribute isn't set or is invalid
Returns:
the attribute value or defaultValue if it isn't set or is invalid

getContext

public String getContext(IXMLElement element)
Returns the context of an element, for error reporting purposes.

Parameters:
element - the element
Returns:
the element context, in the form ":"

getFactory

public ObjectFactory getFactory()
Returns a factory for creating configuration items.

Returns:
the factory


Copyright © 2018. All rights reserved.