public class SpecHelper extends Object
Modifier and Type | Field and Description |
---|---|
private boolean |
_haveSpec |
static String |
NO |
private static String |
PACK_KEY |
private static String |
PACK_NAME |
private net.n3.nanoxml.XMLElement |
spec |
private String |
specFilename |
static String |
YES |
Constructor and Description |
---|
SpecHelper()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
Vector |
getAllSubChildren(net.n3.nanoxml.XMLElement root,
String[] childdef)
Returns a Vector with all leafs of the tree which is described with childdef.
|
net.n3.nanoxml.XMLElement |
getPackForName(String packDestName)
Returns a XML element which represents the pack for the given name.
|
String |
getRequiredAttribute(net.n3.nanoxml.XMLElement element,
String attrName)
Returns the attribute for the given attribute name.
|
InputStream |
getResource(String res)
Gets the stream to a resource.
|
net.n3.nanoxml.XMLElement |
getSpec()
Returns the specification.
|
private Vector |
getSubChildren(net.n3.nanoxml.XMLElement root,
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(net.n3.nanoxml.XMLElement element,
String attribute,
boolean defaultValue)
Returns whether the value to the given attribute is "yes" or not.
|
void |
parseError(net.n3.nanoxml.XMLElement parent,
String message)
Create parse error with consistent messages.
|
void |
readSpec(InputStream input)
Reads the XML specification given by the input stream.
|
void |
readSpec(InputStream input,
VariableSubstitutor substitutor)
Reads the XML specification given by the input stream.
|
void |
readSpec(String specFileName)
Reads the XML specification given by the file name.
|
void |
readSpec(String specFileName,
VariableSubstitutor substitutor)
Reads the XML specification given by the file name.
|
void |
setSpec(net.n3.nanoxml.XMLElement element)
Sets the specifaction to the given XML element.
|
InputStream |
substituteVariables(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 String specFilename
private net.n3.nanoxml.XMLElement spec
private boolean _haveSpec
public static final String YES
public static final String NO
private static final String PACK_KEY
private static final String PACK_NAME
public SpecHelper()
public void readSpec(String specFileName) throws Exception
Exception
- for any problems in reading the specificationpublic void readSpec(String specFileName, VariableSubstitutor substitutor) throws Exception
Exception
- for any problems in reading the specificationpublic void readSpec(InputStream input) throws Exception
Exception
- for any problems in reading the specificationpublic void readSpec(InputStream input, VariableSubstitutor substitutor) throws Exception
Exception
- for any problems in reading the specificationpublic InputStream getResource(String res)
res
- The resource id.public net.n3.nanoxml.XMLElement getPackForName(String packDestName)
packDestName
- name of the pack which should be returnedpublic void parseError(net.n3.nanoxml.XMLElement parent, String message) throws InstallerException
parent
- The element in which the error occuredmessage
- Brief message explaining errorInstallerException
public boolean haveSpec()
public net.n3.nanoxml.XMLElement getSpec()
public void setSpec(net.n3.nanoxml.XMLElement element)
element
- public Vector getAllSubChildren(net.n3.nanoxml.XMLElement root, 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 Vector getSubChildren(net.n3.nanoxml.XMLElement root, 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 InputStream substituteVariables(InputStream input, VariableSubstitutor substitutor) throws Exception
input
- the opened input stream which contents should be substitutedsubstitutor
- substitutor which should substitute the contents of inputException
public boolean isAttributeYes(net.n3.nanoxml.XMLElement element, String attribute, boolean defaultValue)
element
- the XML element which contains the attributeattribute
- the name of the attributedefaultValue
- the default valuepublic String getRequiredAttribute(net.n3.nanoxml.XMLElement element, String attrName) throws InstallerException
element
- XML element which should contain the attributeattrName
- key of the attributeException
InstallerException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses