|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFacemorph.DataBase.iniFile
public class iniFile
Loads a ini style data file general format # a comment [block name.sub block name:type] variable1 = 56 variable2 = "a string" variable3 = [13,23,12,14] # a vector The resulting data is stored as a tree of node (starting with 'root') Each node represents a block, containing named variables and child blocks Each block has a 'type' associated with it (a string value) and a name. The full name (or absolute name) of the block (as appears above) involves concatinating the names of all the parent blocks with a '.' between them. Data is accessed first by entering the relevent block (by name) then using the get* or set* commands to enter or retrieve data. Once entry or reading is complete the command leaveBlock() is used to retrieve the block being accessed before entry. Normally this is the parent block, but this is not neccessarily the case is enterBlockAbsolute is used.
Nested Class Summary | |
---|---|
static class |
iniFile.IniFileException
|
static class |
iniFile.Node
|
Field Summary | |
---|---|
protected java.util.Stack<iniFile.Node> |
blockStack
|
protected iniFile.Node |
root
|
Constructor Summary | |
---|---|
iniFile()
Create an empty iniFile |
|
iniFile(java.io.File f)
Create a new iniFile be loading from a file |
Method Summary | |
---|---|
protected iniFile.Node |
addBlock(java.lang.String line)
|
protected void |
addVariable(java.lang.String line,
java.io.BufferedReader r,
iniFile.Node currentBlock)
|
protected boolean |
createBlock(java.lang.String name)
Create a new block as a child of this block |
boolean |
createBlock(java.lang.String name,
java.lang.String type)
Create a new block as a child of this block |
boolean |
enterBlock(java.lang.String name)
Enter a named block, must be a child (or sub-child) of the current block |
boolean |
enterBlockAbsolute(java.lang.String name)
Enter a named block using a name relative to the root node. |
void |
enterRootBlock()
Return to the root block (the stack is maintained, i.e. |
void |
enterRootBlock(boolean reset)
Return to the root block (if reset is false the stack is maintained, i.e. |
BigMat |
getBigMat(java.lang.String key)
|
BigMat |
getBigMat(java.lang.String key,
BigMat fallback)
|
java.lang.String |
getBlockName()
|
java.util.Vector<java.lang.String> |
getBlocks()
|
java.util.Vector<java.lang.String> |
getBlocksByType(java.lang.String type)
Search child nodes for all blocks of the required type |
java.lang.String |
getBlockType()
|
boolean |
getBoolean(java.lang.String key)
|
boolean |
getBoolean(java.lang.String key,
boolean fallback)
|
protected iniFile.Node |
getCurrentBlock()
|
double |
getDouble(java.lang.String key)
|
double |
getDouble(java.lang.String key,
double fallback)
|
int |
getInt(java.lang.String key)
|
int |
getInt(java.lang.String key,
int fallback)
|
java.util.Vector<java.lang.String> |
getList(java.lang.String key)
|
java.util.Vector<java.lang.String> |
getList(java.lang.String key,
java.util.Vector<java.lang.String> fallback)
|
java.lang.String |
getString(java.lang.String key)
|
java.lang.String |
getString(java.lang.String key,
java.lang.String fallback)
|
double[] |
getVector(java.lang.String key)
|
double[] |
getVector(java.lang.String key,
double[] fallback)
|
boolean |
hasBlock(java.lang.String name)
find a child block with the given name |
boolean |
hasBlockAbsolute(java.lang.String name)
find a child block with the given name relative to the root node |
boolean |
hasType(java.lang.String type)
find a child block with the given type |
boolean |
hasTypeAbsolute(java.lang.String type)
find a child block with the given type relative to the root node |
boolean |
hasVariable(java.lang.String key)
Returns true if the current block contains a variable called $key |
static boolean |
isNumber(java.lang.String in)
|
boolean |
leaveBlock()
return to the previous block in the stack (i.e. |
boolean |
read(java.io.BufferedReader r)
|
boolean |
read(java.io.File f)
|
void |
set(java.lang.String key,
BigMat value)
|
void |
set(java.lang.String key,
boolean value)
|
void |
set(java.lang.String key,
double value)
|
void |
set(java.lang.String key,
double[] value)
|
void |
set(java.lang.String key,
int value)
|
void |
set(java.lang.String key,
java.lang.String value)
|
void |
set(java.lang.String key,
java.util.Vector<java.lang.String> value)
|
boolean |
write(java.io.File f)
|
boolean |
write(java.io.PrintStream ps)
|
boolean |
write(java.lang.StringBuffer str)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected iniFile.Node root
protected java.util.Stack<iniFile.Node> blockStack
Constructor Detail |
---|
public iniFile()
public iniFile(java.io.File f) throws java.io.FileNotFoundException
f
- file to read from
java.io.FileNotFoundException
Method Detail |
---|
protected iniFile.Node getCurrentBlock()
public boolean enterBlock(java.lang.String name)
name
- the name of the block to enter
public boolean enterBlockAbsolute(java.lang.String name)
name
- the name of the block to enter, this is the name as it appears in the iniFile itself
public boolean leaveBlock()
public void enterRootBlock()
public void enterRootBlock(boolean reset)
reset
- set to true to clear the stackprotected boolean createBlock(java.lang.String name)
name
- the name (relative i.e. no '.'s)
public boolean createBlock(java.lang.String name, java.lang.String type)
name
- the name (relative i.e. no '.'s)type
- the type of data stored in this block
public java.lang.String getBlockName()
public java.lang.String getBlockType()
public boolean hasBlock(java.lang.String name)
name
- name of the block to search for
public boolean hasBlockAbsolute(java.lang.String name)
name
- absolute (full) name of the block
public boolean hasType(java.lang.String type)
name
- name of the type to search for
public boolean hasTypeAbsolute(java.lang.String type)
name
- absolute (full) name of the type to search for
public java.util.Vector<java.lang.String> getBlocks()
public java.util.Vector<java.lang.String> getBlocksByType(java.lang.String type)
type
- type to search for
public boolean hasVariable(java.lang.String key)
key
- the name of the variable
public int getInt(java.lang.String key)
public boolean getBoolean(java.lang.String key)
public double getDouble(java.lang.String key)
public java.lang.String getString(java.lang.String key)
public BigMat getBigMat(java.lang.String key)
public double[] getVector(java.lang.String key)
public java.util.Vector<java.lang.String> getList(java.lang.String key)
public int getInt(java.lang.String key, int fallback)
public boolean getBoolean(java.lang.String key, boolean fallback)
public double getDouble(java.lang.String key, double fallback)
public java.lang.String getString(java.lang.String key, java.lang.String fallback)
public BigMat getBigMat(java.lang.String key, BigMat fallback)
public double[] getVector(java.lang.String key, double[] fallback)
public java.util.Vector<java.lang.String> getList(java.lang.String key, java.util.Vector<java.lang.String> fallback)
public void set(java.lang.String key, int value)
public void set(java.lang.String key, double value)
public void set(java.lang.String key, boolean value)
public void set(java.lang.String key, double[] value)
public void set(java.lang.String key, BigMat value)
public void set(java.lang.String key, java.util.Vector<java.lang.String> value)
public void set(java.lang.String key, java.lang.String value)
public boolean read(java.io.File f) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public boolean read(java.io.BufferedReader r)
public boolean write(java.io.File f) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public boolean write(java.io.PrintStream ps)
public boolean write(java.lang.StringBuffer str)
protected iniFile.Node addBlock(java.lang.String line)
protected void addVariable(java.lang.String line, java.io.BufferedReader r, iniFile.Node currentBlock)
public static boolean isNumber(java.lang.String in)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |