FreeHEP API
Version current

hep.aida.ref.tree
Class Tree

java.lang.Object
  extended byhep.aida.ref.event.AIDAObservable
      extended byhep.aida.ref.tree.Tree
All Implemented Interfaces:
IDevTree, IsObservable, hep.aida.ITree

public class Tree
extends AIDAObservable
implements IDevTree, IsObservable

Version:
$Id: Tree.java,v 1.62 2005/11/11 20:18:45 serbo Exp $
Author:
The AIDA team @ SLAC.
Source Code:
Tree.java

Field Summary
 
Fields inherited from class hep.aida.ref.event.AIDAObservable
connectionDidChange, isConnected, isValid
 
Constructor Summary
protected Tree(hep.aida.IAnalysisFactory analysisFactory)
          Create a new Tree.
protected Tree(hep.aida.IAnalysisFactory analysisFactory, String name, String storeName, String storeType, int mode, String options)
           
 
Method Summary
 void add(String path, hep.aida.IManagedObject child)
          This "add" method is called from the IStore, and can create new folders if it is needed.
 void addFromFactory(String path, hep.aida.IManagedObject child)
          This "add" method is called from Factories (HistogramFactory, ...), and can create new folders if it is needed.
 void cd(String path)
          Change to a given directory.
 void checkForChildren(String path)
          This message is sent by a listener to indicate interest in a particular path within the tree.
 void close()
          Closes the underlying store.
 void commit()
          Commit any open transaction to the underlying store(s).
 void cp(String oldPath, String newPath)
          Copy an object from a path to another.
 void cp(String oldPath, String newPath, boolean recursive)
          Copy an object from a path to another.
protected  int decrementMountCount()
           
 hep.aida.IManagedObject find(String path)
          Get the IManagedObject at a given path in the ITree.
 hep.aida.IManagedObject findObject(String path)
           
 String findPath(hep.aida.IManagedObject object)
          Get the full path of an IManagedObject.
 hep.aida.ITree findTree(String path)
           
 void fireConnectionEvent(String pathString, boolean connect)
           
protected  hep.aida.IManagedObject[] getAllManagedObjectsInPath(hep.aida.ref.tree.Path path)
           
 Object getLock()
           
 Map getOptions()
           
 void hasBeenFilled(String path)
          Is called by the Store to let Tree know that a particular folder has been filled already.
 boolean hasStore()
           
 void init(String storeName, boolean readOnly, boolean createNew, String storeType, String options, boolean readOnlyUserDefined)
          Associate the tree with a store
 void init(String storeName, String storeType, int mode, String options)
          Non-AIDA methods are down here.
 boolean isReadOnly()
           
 String[] listObjectNames()
          Get the list of names of the IManagedObjects under a given path, including directories (but not "." and "..").
 String[] listObjectNames(String path)
          Get the list of names of the IManagedObjects under a given path, including directories (but not "." and "..").
 String[] listObjectNames(String path, boolean recursive)
          Get the list of names of the IManagedObjects under a given path, including directories (but not "." and "..").
 String[] listObjectTypes()
          Get the list of types of the IManagedObjects under a given path.
 String[] listObjectTypes(String path)
          Get the list of types of the IManagedObjects under a given path.
 String[] listObjectTypes(String path, boolean recursive)
          Get the list of types of the IManagedObjects under a given path.
 void ls()
          List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path.
 void ls(String path)
          List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path.
 void ls(String path, boolean recursive)
          List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path.
 void ls(String path, boolean recursive, OutputStream os)
          List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path.
 void mkdir(String path)
          Create a new directory.
 void mkdirs(String path)
          Create a directory recursively.
 void mount(String path, hep.aida.ITree tree, String treePath)
          Mounts a tree within another (target) tree.
 void mv(String oldPath, String newPath)
          Move an IManagedObject or a directory from one directory to another.
 String name()
           
 String pwd()
          Get the path of the current working directory.
protected  void registerManagedObject(hep.aida.IManagedObject obj, hep.aida.ref.tree.Path path)
           
 void rm(String path)
          Remove an IManagedObject by specifying its path.
 void rmdir(String path)
          Remove a directory and all the contents underneath.
 void setFolderIsWatched(String path, boolean state)
          This message is sent by a listener to indicate interest in a particular path within the tree.
 void setLock(Object lock)
           
 void setOverwrite()
          Set the strategy of what should happen if two objects have the same path.
 void setOverwrite(boolean overwrite)
          Set the strategy of what should happen if two objects have the same path.
 String storeName()
          Get the name of the store.
 String storeType()
           
 void symlink(String path, String alias)
          Create a symbolic link to an object in the ITree.
 void unmount(String path)
          Unmount a subtree at a given path (mount point).
protected  void unRegisterManagedObject(hep.aida.IManagedObject obj)
           
 
Methods inherited from class hep.aida.ref.event.AIDAObservable
addListener, createEvent, fireStateChanged, fireStateChanged, fireStateChanged, isConnected, removeAllListeners, removeListener, setConnected, setIsValidAfterNotify, setValid, setValidForAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hep.aida.ref.event.IsObservable
addListener, removeAllListeners, removeListener, setValid
 

Constructor Detail

Tree

protected Tree(hep.aida.IAnalysisFactory analysisFactory)
Create a new Tree.


Tree

protected Tree(hep.aida.IAnalysisFactory analysisFactory,
               String name,
               String storeName,
               String storeType,
               int mode,
               String options)
        throws IOException
Method Detail

name

public String name()
Specified by:
name in interface hep.aida.ITree

storeName

public String storeName()
Get the name of the store.

Specified by:
storeName in interface hep.aida.ITree
Returns:
The store's name.

storeType

public String storeType()
Specified by:
storeType in interface hep.aida.ITree

setLock

public void setLock(Object lock)
Specified by:
setLock in interface IDevTree

getLock

public Object getLock()
Specified by:
getLock in interface IDevTree

hasStore

public boolean hasStore()

findObject

public hep.aida.IManagedObject findObject(String path)
                                   throws IllegalArgumentException
Throws:
IllegalArgumentException

find

public hep.aida.IManagedObject find(String path)
                             throws IllegalArgumentException
Get the IManagedObject at a given path in the ITree. The path can either be absolute or relative to the current working directory.

Specified by:
find in interface hep.aida.ITree
Parameters:
path - The path.
Returns:
The corresponding IManagedObject.
Throws:
IllegalArgumentException - If the path does not correspond to an IManagedObject.

findTree

public hep.aida.ITree findTree(String path)
                        throws IllegalArgumentException
Specified by:
findTree in interface hep.aida.ITree
Throws:
IllegalArgumentException

close

public void close()
           throws IOException
Closes the underlying store. Changes will be saved only if commit() has been called before. The call is propagated to the dependent mounted trees.

Specified by:
close in interface hep.aida.ITree
Throws:
IOException - If there are problems writing out the underlying store.

cd

public void cd(String path)
        throws IllegalArgumentException
Change to a given directory.

Specified by:
cd in interface hep.aida.ITree
Parameters:
path - The absolute or relative path of the directory we are changing to.
Throws:
IllegalArgumentException - If the path does not exist or path is not a directory.

pwd

public String pwd()
Get the path of the current working directory.

Specified by:
pwd in interface hep.aida.ITree
Returns:
The path of the current working directory.

ls

public void ls()
        throws IllegalArgumentException
List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path. Directories end with "/". The list can be recursive. in all the directories under path (the default is false.

Specified by:
ls in interface hep.aida.ITree
Throws:
IllegalArgumentException - If the path does not exist.

ls

public void ls(String path)
        throws IllegalArgumentException
List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path. Directories end with "/". The list can be recursive.

Specified by:
ls in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory "."). in all the directories under path (the default is false.
Throws:
IllegalArgumentException - If the path does not exist.

ls

public void ls(String path,
               boolean recursive)
        throws IllegalArgumentException
List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path. Directories end with "/". The list can be recursive.

Specified by:
ls in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory ".").
recursive - If true the list is extended recursively in all the directories under path (the default is false.
Throws:
IllegalArgumentException - If the path does not exist.

ls

public void ls(String path,
               boolean recursive,
               OutputStream os)
        throws IllegalArgumentException
List, into a given output stream, all the IManagedObjects, including directories (but not "." and ".."), in a given path. Directories end with "/". The list can be recursive.

Specified by:
ls in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory ".").
recursive - If true the list is extended recursively in all the directories under path (the default is false.
os - The output stream into which the list is dumped (by default the standard output).
Throws:
IllegalArgumentException - If the path does not exist.

listObjectNames

public String[] listObjectNames()
                         throws IllegalArgumentException
Get the list of names of the IManagedObjects under a given path, including directories (but not "." and ".."). Directories end with "/". The returned names are appended to the given path unless the latter is ".". in all the directories under path (the default is false.

Specified by:
listObjectNames in interface hep.aida.ITree
Throws:
IllegalArgumentException - If the path does not exist.

listObjectNames

public String[] listObjectNames(String path)
                         throws IllegalArgumentException
Get the list of names of the IManagedObjects under a given path, including directories (but not "." and ".."). Directories end with "/". The returned names are appended to the given path unless the latter is ".".

Specified by:
listObjectNames in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory "."). in all the directories under path (the default is false.
Throws:
IllegalArgumentException - If the path does not exist.

listObjectNames

public String[] listObjectNames(String path,
                                boolean recursive)
                         throws IllegalArgumentException
Get the list of names of the IManagedObjects under a given path, including directories (but not "." and ".."). Directories end with "/". The returned names are appended to the given path unless the latter is ".".

Specified by:
listObjectNames in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory ".").
recursive - If true the list is extended recursively in all the directories under path (the default is false.
Throws:
IllegalArgumentException - If the path does not exist.

listObjectTypes

public String[] listObjectTypes()
                         throws IllegalArgumentException
Get the list of types of the IManagedObjects under a given path. The types are the leaf class of the Interface, e.g. "IHistogram1D", "ITuple", etc. Directories are marked with "dir". The order of the types is the same as the order for the listObjectNames() method to achieve a one-to-one correspondance between object names and types. in all the directories under path (the default is false.

Specified by:
listObjectTypes in interface hep.aida.ITree
Throws:
IllegalArgumentException - If the path does not exist.

listObjectTypes

public String[] listObjectTypes(String path)
                         throws IllegalArgumentException
Get the list of types of the IManagedObjects under a given path. The types are the leaf class of the Interface, e.g. "IHistogram1D", "ITuple", etc. Directories are marked with "dir". The order of the types is the same as the order for the listObjectNames() method to achieve a one-to-one correspondance between object names and types.

Specified by:
listObjectTypes in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory "."). in all the directories under path (the default is false.
Throws:
IllegalArgumentException - If the path does not exist.

listObjectTypes

public String[] listObjectTypes(String path,
                                boolean recursive)
                         throws IllegalArgumentException
Get the list of types of the IManagedObjects under a given path. The types are the leaf class of the Interface, e.g. "IHistogram1D", "ITuple", etc. Directories are marked with "dir". The order of the types is the same as the order for the listObjectNames() method to achieve a one-to-one correspondance between object names and types.

Specified by:
listObjectTypes in interface hep.aida.ITree
Parameters:
path - The path where the list has to be performed (by default the current directory ".").
recursive - If true the list is extended recursively in all the directories under path (the default is false.
Throws:
IllegalArgumentException - If the path does not exist.

mkdir

public void mkdir(String path)
           throws IllegalArgumentException
Create a new directory. Given a path only the last directory in it is created if all the intermediate subdirectories already exist.

Specified by:
mkdir in interface hep.aida.ITree
Parameters:
path - The absolute or relative path of the new directory.
Throws:
IllegalArgumentException - If a subdirectory within the path does not exist or it is not a directory. Also if the directory already exists.

mkdirs

public void mkdirs(String path)
            throws IllegalArgumentException
Create a directory recursively. Given a path the last directory and all the intermediate non-existing subdirectories are created.

Specified by:
mkdirs in interface hep.aida.ITree
Parameters:
path - The absolute or relative path of the new directory.
Throws:
IllegalArgumentException - If an intermediate subdirectory is not a directory.

rmdir

public void rmdir(String path)
           throws IllegalArgumentException
Remove a directory and all the contents underneath.

Specified by:
rmdir in interface hep.aida.ITree
Parameters:
path - The absolute or relative path of the directory to be removed.
Throws:
IllegalArgumentException - If path does not exist or if it is not a directory.

rm

public void rm(String path)
        throws IllegalArgumentException
Remove an IManagedObject by specifying its path. If the path points to a mount point, the mount point should first commit, then close and delete the tree object.

Specified by:
rm in interface hep.aida.ITree
Parameters:
path - The absolute or relative path of the IManagedObject to be removed.
Throws:
IllegalArgumentException - If path does not exist.

findPath

public String findPath(hep.aida.IManagedObject object)
                throws IllegalArgumentException
Get the full path of an IManagedObject.

Specified by:
findPath in interface hep.aida.ITree
Parameters:
object - The IManagedObject whose path is to be returned.
Returns:
The object's absolute path. In C++ if the object does not exist, an empty string is returned.
Throws:
IllegalArgumentException - If the IManagedObject does not exist.

mv

public void mv(String oldPath,
               String newPath)
        throws IllegalArgumentException
Move an IManagedObject or a directory from one directory to another.

Specified by:
mv in interface hep.aida.ITree
Parameters:
oldPath - The path of the IManagedObject or direcoty to be moved.
newPath - The path of the diretory in which the object has to be moved to.
Throws:
IllegalArgumentException - If either path does not exist.

commit

public void commit()
            throws IOException
Commit any open transaction to the underlying store(s). It flushes objects into the disk for non-memory-mapped stores.

Specified by:
commit in interface hep.aida.ITree
Throws:
IOException - If the underlying store cannot be written out.

setOverwrite

public void setOverwrite()
Set the strategy of what should happen if two objects have the same path. Default is overwrite.

Specified by:
setOverwrite in interface hep.aida.ITree

setOverwrite

public void setOverwrite(boolean overwrite)
Set the strategy of what should happen if two objects have the same path. Default is overwrite.

Specified by:
setOverwrite in interface hep.aida.ITree
Parameters:
overwrite - true to enable overwriting.

cp

public void cp(String oldPath,
               String newPath)
        throws IllegalArgumentException
Copy an object from a path to another.

Specified by:
cp in interface hep.aida.ITree
Parameters:
oldPath - The path of the object to be copied.
newPath - The path where the object is to be copied.
Throws:
IllegalArgumentException - If either path does not exist.

cp

public void cp(String oldPath,
               String newPath,
               boolean recursive)
        throws IllegalArgumentException
Copy an object from a path to another.

Specified by:
cp in interface hep.aida.ITree
Parameters:
oldPath - The path of the object to be copied.
newPath - The path where the object is to be copied.
recursive - true if a recursive copy has to be performed.
Throws:
IllegalArgumentException - If either path does not exist.

symlink

public void symlink(String path,
                    String alias)
             throws IllegalArgumentException
Create a symbolic link to an object in the ITree.

Specified by:
symlink in interface hep.aida.ITree
Parameters:
path - The absolute or relative path of the object to be linked.
alias - The absolute or relative name of the link.
Throws:
IllegalArgumentException - If path or any subidrectory within path does not exist.

mount

public void mount(String path,
                  hep.aida.ITree tree,
                  String treePath)
           throws IllegalArgumentException
Mounts a tree within another (target) tree. A tree can only be mounted once. Example:
     target.mount("/home/tonyj",tree,"/");
 

Specified by:
mount in interface hep.aida.ITree
Parameters:
path - The path in the target tree
tree - The tree to mount within the target tree
treePath - The mount point within the tree to be mounted.
Throws:
IllegalArtumentException - If something does not exist.
IllegalArgumentException

unmount

public void unmount(String path)
             throws IllegalArgumentException
Unmount a subtree at a given path (mount point). Whenever a tree is destroyed it first unmounts all dependent trees.

Specified by:
unmount in interface hep.aida.ITree
Parameters:
path - The path of the subtree to be unmounted.
Throws:
IllegalArgumentException - If path does not exist.

init

public void init(String storeName,
                 String storeType,
                 int mode,
                 String options)
          throws IOException
Non-AIDA methods are down here.

Throws:
IOException

init

public void init(String storeName,
                 boolean readOnly,
                 boolean createNew,
                 String storeType,
                 String options,
                 boolean readOnlyUserDefined)
          throws IOException
Associate the tree with a store

Parameters:
storeName - The name of the output storage unit.
readOnly - true if the tree is readonly.
createNew - true if the tree has to create a new file.
storeType - The type of the output storage unit.
Throws:
IOException

hasBeenFilled

public void hasBeenFilled(String path)
                   throws IllegalArgumentException
Is called by the Store to let Tree know that a particular folder has been filled already. "path" is path to a folder, cannot point to an Object.

Specified by:
hasBeenFilled in interface IDevTree
Parameters:
path - The path of the diretory which has been filled by the Store.
Throws:
IllegalArgumentException - If the path does not exist, or if it is not a directory.

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface hep.aida.ITree

add

public void add(String path,
                hep.aida.IManagedObject child)
This "add" method is called from the IStore, and can create new folders if it is needed. Does not overwrite existing objects, just skip them.

Specified by:
add in interface IDevTree
Parameters:
path - The path of the diretory in which the object has to be added.
child - The IManagedObject to be added.

addFromFactory

public void addFromFactory(String path,
                           hep.aida.IManagedObject child)
This "add" method is called from Factories (HistogramFactory, ...), and can create new folders if it is needed. It does overwrite existing objects.


getAllManagedObjectsInPath

protected hep.aida.IManagedObject[] getAllManagedObjectsInPath(hep.aida.ref.tree.Path path)

registerManagedObject

protected void registerManagedObject(hep.aida.IManagedObject obj,
                                     hep.aida.ref.tree.Path path)

unRegisterManagedObject

protected void unRegisterManagedObject(hep.aida.IManagedObject obj)

fireConnectionEvent

public void fireConnectionEvent(String pathString,
                                boolean connect)

checkForChildren

public void checkForChildren(String path)
This message is sent by a listener to indicate interest in a particular path within the tree. If the path corresponds to a folder, that folder will be asked to notify listeners of all existing children, and to continue to notify listeners of any future changes.


setFolderIsWatched

public void setFolderIsWatched(String path,
                               boolean state)
This message is sent by a listener to indicate interest in a particular path within the tree. If the path corresponds to a folder, that folder will be asked to notify listeners of any future changes.


getOptions

public Map getOptions()

decrementMountCount

protected int decrementMountCount()

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.