|
|||||||||
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 XMLElement |
spec
|
private java.lang.String |
specFilename
|
static java.lang.String |
YES
|
Constructor Summary | |
---|---|
SpecHelper()
The default constructor. |
Method Summary | |
---|---|
java.util.Vector<XMLElement> |
getAllSubChildren(XMLElement root,
java.lang.String[] childdef)
Returns a Vector with all leafs of the tree which is described with childdef. |
XMLElement |
getPackForName(java.lang.String packDestName)
Returns a XML element which represents the pack for the given name. |
java.lang.String |
getRequiredAttribute(XMLElement 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. |
XMLElement |
getSpec()
Returns the specification. |
private java.util.Vector<XMLElement> |
getSubChildren(XMLElement 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(XMLElement element,
java.lang.String attribute,
boolean defaultValue)
Returns whether the value to the given attribute is "yes" or not. |
void |
parseError(XMLElement 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(XMLElement 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 XMLElement 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 specificationpublic void readSpec(java.lang.String specFileName, VariableSubstitutor substitutor) throws java.lang.Exception
java.lang.Exception
- for any problems in reading the specificationpublic void readSpec(java.io.InputStream input) throws java.lang.Exception
java.lang.Exception
- for any problems in reading the specificationpublic 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 XMLElement getPackForName(java.lang.String packDestName)
packDestName
- name of the pack which should be returned
public void parseError(XMLElement parent, java.lang.String message) throws InstallerException
parent
- The element in which the error occuredmessage
- Brief message explaining error
InstallerException
public boolean haveSpec()
public XMLElement getSpec()
public void setSpec(XMLElement element)
element
- public java.util.Vector<XMLElement> getAllSubChildren(XMLElement root, java.lang.String[] childdef)
root
- the XMLElement 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<XMLElement> getSubChildren(XMLElement root, java.lang.String[] childdef, int depth)
root
- the XMLElement 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(XMLElement 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(XMLElement 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 |