|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.izforge.izpack.util.SpecHelper
public class SpecHelper
This class contains some helper methods to simplify handling of xml specification files.
| Field Summary | |
|---|---|
private boolean |
_haveSpec
|
static java.lang.String |
NO
|
private static java.lang.String |
PACK_KEY
|
private static java.lang.String |
PACK_NAME
|
private IXMLElement |
spec
|
private java.lang.String |
specFilename
|
static java.lang.String |
YES
|
| Constructor Summary | |
|---|---|
SpecHelper()
The default constructor. |
|
| Method Summary | |
|---|---|
java.util.Vector<IXMLElement> |
getAllSubChildren(IXMLElement root,
java.lang.String[] childdef)
Returns a Vector with all leafs of the tree which is described with childdef. |
IXMLElement |
getPackForName(java.lang.String packDestName)
Returns a XML element which represents the pack for the given name. |
java.lang.String |
getRequiredAttribute(IXMLElement element,
java.lang.String attrName)
Returns the attribute for the given attribute name. |
java.io.InputStream |
getResource(java.lang.String res)
Gets the stream to a resource. |
IXMLElement |
getSpec()
Returns the specification. |
private java.util.Vector<IXMLElement> |
getSubChildren(IXMLElement root,
java.lang.String[] childdef,
int depth)
Returns a Vector with all leafs of the tree which is described with childdef beginning at the given depth. |
boolean |
haveSpec()
Returns true if a specification exist, else false. |
boolean |
isAttributeYes(IXMLElement element,
java.lang.String attribute,
boolean defaultValue)
Returns whether the value to the given attribute is "yes" or not. |
void |
parseError(IXMLElement parent,
java.lang.String message)
Create parse error with consistent messages. |
void |
readSpec(java.io.InputStream input)
Reads the XML specification given by the input stream. |
void |
readSpec(java.io.InputStream input,
VariableSubstitutor substitutor)
Reads the XML specification given by the input stream. |
void |
readSpec(java.lang.String specFileName)
Reads the XML specification given by the file name. |
void |
readSpec(java.lang.String specFileName,
VariableSubstitutor substitutor)
Reads the XML specification given by the file name. |
void |
setSpec(IXMLElement element)
Sets the specifaction to the given XML element. |
java.io.InputStream |
substituteVariables(java.io.InputStream input,
VariableSubstitutor substitutor)
Creates an temp file in to the substitutor the substituted contents of input writes; close it and (re)open it as FileInputStream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.lang.String specFilename
private IXMLElement spec
private boolean _haveSpec
public static final java.lang.String YES
public static final java.lang.String NO
private static final java.lang.String PACK_KEY
private static final java.lang.String PACK_NAME
| Constructor Detail |
|---|
public SpecHelper()
| Method Detail |
|---|
public void readSpec(java.lang.String specFileName)
throws java.lang.Exception
java.lang.Exception - for any problems in reading the specification
public void readSpec(java.lang.String specFileName,
VariableSubstitutor substitutor)
throws java.lang.Exception
java.lang.Exception - for any problems in reading the specification
public void readSpec(java.io.InputStream input)
throws java.lang.Exception
java.lang.Exception - for any problems in reading the specification
public void readSpec(java.io.InputStream input,
VariableSubstitutor substitutor)
throws java.lang.Exception
java.lang.Exception - for any problems in reading the specificationpublic java.io.InputStream getResource(java.lang.String res)
res - The resource id.
public IXMLElement getPackForName(java.lang.String packDestName)
packDestName - name of the pack which should be returned
public void parseError(IXMLElement parent,
java.lang.String message)
throws InstallerException
parent - The element in which the error occuredmessage - Brief message explaining error
InstallerExceptionpublic boolean haveSpec()
public IXMLElement getSpec()
public void setSpec(IXMLElement element)
element -
public java.util.Vector<IXMLElement> getAllSubChildren(IXMLElement root,
java.lang.String[] childdef)
root - the IXMLElement which is the current root for the searchchilddef - a String array which describes the tree; the last element contains the leaf
name
private java.util.Vector<IXMLElement> getSubChildren(IXMLElement root,
java.lang.String[] childdef,
int depth)
root - the IXMLElement which is the current root for the searchchilddef - a String array which describes the tree; the last element contains the leaf
namedepth - depth to start in childdef
public java.io.InputStream substituteVariables(java.io.InputStream input,
VariableSubstitutor substitutor)
throws java.lang.Exception
input - the opened input stream which contents should be substitutedsubstitutor - substitutor which should substitute the contents of input
java.lang.Exception
public boolean isAttributeYes(IXMLElement element,
java.lang.String attribute,
boolean defaultValue)
element - the XML element which contains the attributeattribute - the name of the attributedefaultValue - the default value
public java.lang.String getRequiredAttribute(IXMLElement element,
java.lang.String attrName)
throws InstallerException
element - XML element which should contain the attributeattrName - key of the attribute
InstallerException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||