public class SpecHelper
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
SpecHelper()
The default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Vector |
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 |
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.
|
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
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 returnedpublic void parseError(XMLElement parent, java.lang.String message) throws InstallerException
parent - The element in which the error occuredmessage - Brief message explaining errorInstallerExceptionpublic boolean haveSpec()
public XMLElement getSpec()
public void setSpec(XMLElement element)
element - public java.util.Vector 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
nameprivate java.util.Vector 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 childdefpublic 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 inputjava.lang.Exceptionpublic 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 valuepublic java.lang.String getRequiredAttribute(XMLElement element, java.lang.String attrName) throws InstallerException
element - XML element which should contain the attributeattrName - key of the attributejava.lang.ExceptionInstallerException