|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthings.data.impl.ThingsPropertyTreeBASIC
public class ThingsPropertyTreeBASIC
A basic property tree that supports load and save. You must INIT the parent before any child operations! Sub and ply collections are slow. Access is synchronized internally only during loads and saves. Otherwise, it is up to the users to keep it straight.
THIS IMPLEMENTATION IS A BIG FAT BUCKET OF ConcurrentModificationException, since it uses HashMap. This might cause you some hassle.
Version History
EPG - Initial - 26 MAR 05 EPG - Shift implementation to generic HashMap - 14 JUN 05 EPG - Added sub - 19 JUL 07
Field Summary |
---|
Constructor Summary | |
---|---|
ThingsPropertyTreeBASIC()
Default constructor |
|
ThingsPropertyTreeBASIC(java.util.HashMap<java.lang.String,java.lang.String[]> properties,
java.lang.String root,
ThingsPropertyTrunk trunk)
Construct a child. |
Method Summary | |
---|---|
ThingsPropertyViewReader |
branch(java.lang.String path)
Branch the view to create a new view. |
void |
copyAndGraftBranch(java.lang.String sourceBranchPath,
java.lang.String graftRoot)
Copy a branch and graft it somewhere else. |
ThingsPropertyTree |
copyBranch(java.lang.String branchPath)
Copy a branch of the tree as a new tree. |
ThingsPropertyView |
cutting(java.lang.String path)
Pruning to get a new a new view. |
ThingsPropertyView |
getBranch(java.lang.String path)
Get a view of a branch on the tree. |
static ThingsPropertyTreeBASIC |
getExpedientFromFile(java.lang.String path)
This will create a file based property view. |
java.lang.String |
getProperty(java.lang.String... pathElements)
Get a property value as a string. |
java.lang.String |
getProperty(java.lang.String path)
Get a property value as a string. |
java.lang.String[] |
getPropertyMultivalue(java.lang.String path)
Get a property value as a multivalue. |
NVImmutable |
getPropertyNV(java.lang.String path)
Get a property value as a multivalue. |
ThingsPropertyView |
getRoot()
Get a view from the root. |
void |
graft(ThingsPropertyView sourceView)
Graft one view onto this view. |
void |
infliltrate(ThingsPropertyTrunk tio)
This is how you load and merge properties into an already populated tree. |
void |
init(ThingsPropertyTrunk tio)
Tell the tree to init itself. |
void |
load()
Tell the tree to load fresh. |
java.util.Collection<java.lang.String> |
ply(java.lang.String path)
Get the ply at this path. |
void |
prune(java.lang.String path)
Prune off the path. |
void |
removeProperty(java.lang.String path)
Remove a specific property without subverting a tree. |
void |
save()
Tell the tree to save itself. |
void |
setProperty(NVImmutable item)
Set a property value from an NVImmutable item. |
void |
setProperty(java.lang.String path,
java.lang.String value)
Set a property value as a string. |
void |
setProperty(java.lang.String path,
java.lang.String value,
java.lang.String defaultValue)
Set a property value as a string. |
void |
setPropertyMultivalue(java.lang.String path,
java.lang.String... values)
Set a property value as a multivalue. |
java.util.Collection<java.lang.String> |
sub(java.lang.String path)
Get all property names under this at this path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ThingsPropertyTreeBASIC()
public ThingsPropertyTreeBASIC(java.util.HashMap<java.lang.String,java.lang.String[]> properties, java.lang.String root, ThingsPropertyTrunk trunk) throws ThingsException
ThingsException
Method Detail |
---|
public ThingsPropertyView getBranch(java.lang.String path) throws ThingsException
getBranch
in interface ThingsPropertyTree
path
- path to the branch. Null we return the root.
ThingsException
public ThingsPropertyView getRoot() throws ThingsException
getRoot
in interface ThingsPropertyTree
ThingsException
public ThingsPropertyTree copyBranch(java.lang.String branchPath) throws ThingsException
copyBranch
in interface ThingsPropertyTree
branchPath
- path to the branch from where to start the copy. An empty or null value will return the root.
ThingsException
public void prune(java.lang.String path) throws ThingsException
prune
in interface ThingsPropertyView
path
- the property path (relative to the view root). A null is not allowed.
ThingsException
public void copyAndGraftBranch(java.lang.String sourceBranchPath, java.lang.String graftRoot) throws ThingsException
copyAndGraftBranch
in interface ThingsPropertyTree
sourceBranchPath
- path to the branch from where to copy. An empty or null value will return the root.graftRoot
- the path to where it should be grafted.
ThingsException
public void load() throws ThingsException
load
in interface ThingsPropertyTree
ThingsException
public void save() throws ThingsException
save
in interface ThingsPropertyTree
save
in interface ThingsPropertyView
ThingsException
public void init(ThingsPropertyTrunk tio) throws ThingsException
init
in interface ThingsPropertyTree
tio
- a trunk to load and save the properties
ThingsException
public void infliltrate(ThingsPropertyTrunk tio) throws ThingsException
infliltrate
in interface ThingsPropertyTree
tio
- a trunk to load and save the properties
ThingsException
public void setProperty(java.lang.String path, java.lang.String value) throws ThingsException
setProperty
in interface ThingsPropertyView
path
- the property path (relative to the view root)value
- the property value as a string
ThingsException
public void setProperty(java.lang.String path, java.lang.String value, java.lang.String defaultValue) throws ThingsException
setProperty
in interface ThingsPropertyView
path
- the property path (relative to the view root)value
- the property value as a stringdefaultValue
- the default value.
ThingsException
public void setProperty(NVImmutable item) throws ThingsException
setProperty
in interface ThingsPropertyView
item
- the item
ThingsException
NVImmutable
public void setPropertyMultivalue(java.lang.String path, java.lang.String... values) throws ThingsException
setPropertyMultivalue
in interface ThingsPropertyView
path
- the property path (relative to the view root)values
- the property values as Strings.
ThingsException
public void removeProperty(java.lang.String path) throws ThingsException
removeProperty
in interface ThingsPropertyView
path
- the property path (relative to the view root). A null or bogus path will be ignored.
ThingsException
public ThingsPropertyView cutting(java.lang.String path) throws ThingsException
cutting
in interface ThingsPropertyView
path
- the property path (relative to the view root)
ThingsException
public void graft(ThingsPropertyView sourceView) throws ThingsException
SLOWWWW since it takes too passes. Yuck! We'll let the NVImmutable take care of the "copies so the original tree will be left unaltered).
graft
in interface ThingsPropertyView
sourceView
- view to graft on.
ThingsException
public ThingsPropertyViewReader branch(java.lang.String path) throws ThingsException
branch
in interface ThingsPropertyViewReader
path
- the property path (relative to the view root)
ThingsException
public java.lang.String getProperty(java.lang.String path) throws ThingsException
getProperty
in interface ThingsPropertyViewReader
path
- the property name
ThingsException
public java.lang.String getProperty(java.lang.String... pathElements) throws ThingsException
getProperty
in interface ThingsPropertyViewReader
pathElements
- a stitch-able path.
ThingsException
public java.lang.String[] getPropertyMultivalue(java.lang.String path) throws ThingsException
getPropertyMultivalue
in interface ThingsPropertyViewReader
path
- the property name
ThingsException
public NVImmutable getPropertyNV(java.lang.String path) throws ThingsException
getPropertyNV
in interface ThingsPropertyViewReader
path
- the property name
ThingsException
NVImmutable
public java.util.Collection<java.lang.String> sub(java.lang.String path) throws ThingsException
sub
in interface ThingsPropertyViewReader
path
- a root path. If it is null, it'll return everything.
ThingsException
public java.util.Collection<java.lang.String> ply(java.lang.String path) throws ThingsException
ply
in interface ThingsPropertyViewReader
path
- a root path.
ThingsException
public static ThingsPropertyTreeBASIC getExpedientFromFile(java.lang.String path) throws ThingsException
path
- file path to the INI file
ThingsException
ThingsPropertyTrunkIO
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |