com.izforge.izpack.compiler
Class Property

java.lang.Object
  extended bycom.izforge.izpack.compiler.Property

public class Property
extends java.lang.Object

Sets a property by name, or set of properties (from file or resource) in the project. This is modeled after ant properties

Properties are immutable: once a property is set it cannot be changed. They are most definately not variable.

There are five ways to set properties:

Combinations of the above are considered an error.

The value part of the properties being set, might contain references to other properties. These references are resolved when the properties are set.

This also holds for properties loaded from a property file.

Properties are case sensitive.

When specifying the environment attribute, it's value is used as a prefix to use when retrieving environment variables. This functionality is currently only implemented on select platforms.

Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".

Note also that properties are case sensitive, even if the environment variables on your operating system are not, e.g. it will be ${env.Path} not ${env.PATH} on Windows 2000.

Note that when specifying either the prefix or environment attributes, if you supply a property name with a final "." it will not be doubled. ie environment="myenv." will still allow access of environment variables through "myenv.PATH" and "myenv.TERM".


Field Summary
protected  Compiler compiler
           
protected  CompilerConfig config
           
protected  java.lang.String env
           
protected  java.io.File file
           
protected  java.lang.String name
           
protected  java.lang.String prefix
           
protected  java.lang.String value
           
protected  XMLElement xmlProp
           
 
Constructor Summary
Property(XMLElement xmlProp, CompilerConfig config)
           
 
Method Summary
protected  void addProperties(java.util.Properties props)
          iterate through a set of properties, resolve them then assign them
protected  void addProperty(java.lang.String name, java.lang.String value)
          Add a name value pair to the project property set
 void execute()
          Set the property in the project to the value.
 java.lang.String getValue()
          get the value of this property
protected  void loadEnvironment(java.lang.String prefix)
          load the environment values
protected  void loadFile(java.io.File file)
          load properties from a file
private  void resolveAllProperties(java.util.Properties props)
          resolve properties inside a properties object
 java.lang.String toString()
          get the value of this property
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

value

protected java.lang.String value

file

protected java.io.File file

env

protected java.lang.String env

prefix

protected java.lang.String prefix

xmlProp

protected XMLElement xmlProp

config

protected CompilerConfig config

compiler

protected Compiler compiler
Constructor Detail

Property

public Property(XMLElement xmlProp,
                CompilerConfig config)
Method Detail

getValue

public java.lang.String getValue()
get the value of this property

Returns:
the current value or the empty string

toString

public java.lang.String toString()
get the value of this property

Returns:
the current value or the empty string

execute

public void execute()
             throws CompilerException
Set the property in the project to the value. If the task was give a file, resource or env attribute here is where it is loaded.

Throws:
CompilerException

loadFile

protected void loadFile(java.io.File file)
                 throws CompilerException
load properties from a file

Parameters:
file - file to load
Throws:
CompilerException

loadEnvironment

protected void loadEnvironment(java.lang.String prefix)
                        throws CompilerException
load the environment values

Parameters:
prefix - prefix to place before them
Throws:
CompilerException

addProperty

protected void addProperty(java.lang.String name,
                           java.lang.String value)
                    throws CompilerException
Add a name value pair to the project property set

Parameters:
name - name of property
value - value to set
Throws:
CompilerException

addProperties

protected void addProperties(java.util.Properties props)
                      throws CompilerException
iterate through a set of properties, resolve them then assign them

Throws:
CompilerException

resolveAllProperties

private void resolveAllProperties(java.util.Properties props)
                           throws CompilerException
resolve properties inside a properties object

Parameters:
props - properties to resolve
Throws:
CompilerException