net.ponder2
Class Domain

java.lang.Object
  extended by net.ponder2.Domain
All Implemented Interfaces:
ManagedObject
Direct Known Subclasses:
SelfManagedCell

public class Domain
extends java.lang.Object
implements ManagedObject

Domain is the basic managed object for Ponder2 that supports hierarchies. View it like a directory or a folder in a filesystem

Version:
$Id: Domain.java,v 1.23 2006/03/15 13:36:42 kpt Exp $
Author:
Kevin Twidle

Constructor Summary
protected Domain(P2Object myP2Object)
          creates a new Domain managed object
 
Method Summary
protected  void add(java.lang.String name, P2ManagedObject mo)
          adds a new managed object to this domain
 boolean contains(P2Object anObject)
          returns true if anObject exists within the domain
 boolean contains(java.lang.String aName)
          returns true if the named object exists within the domain
 P2ManagedObject get(java.lang.String name)
          gets the P2ManagedObject of a named managed object
protected  java.lang.String[] names()
          returns an array of the names of the objects in this domain
protected  P2Hash operation_asHash()
          Returns a hash containing all the entries in the domain as name->object pairs
protected  P2Object operation_at_add(java.lang.String aName, P2Object p2Object)
          add anOid into the domain with aName.
protected  P2Object operation_at(P2Object source, java.lang.String aName, P2Block aBlock)
          Answer the P2Object associated with aName.
protected  P2Object operation_at(java.lang.String aName)
          answers the P2Object of the Managed Object at aName.
protected  P2Array operation_collect(P2Object source, P2Block aBlock)
          Calls aBlock with name/value pairs for each entry in the domain.
protected  void operation_do(P2Object source, P2Block aBlock)
          Calls aBlock with name/value pairs for each entry in the domain.
protected  P2Object operation_listNames()
          answers an array containing the names of all the domain's entries.
protected  P2Object operation_listObjects()
          answers an array of Managed Object names containing all the entries in the domain.
protected  P2Object operation_remove(java.lang.String aName)
          Removes aName and its ManagedObject from the domain.
protected  P2Object operation_resolve(java.lang.String aPath)
          Answers with the object from aPath relative to this domain
protected  P2ManagedObject remove(java.lang.String name)
          removes a managed object from a domain
protected  void removeAll()
          Removes all objects from the domain.
protected  boolean removeObject(P2Object anObject)
          Removes anObject from the receiver.
 int size()
          Answer the number of elements in the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Domain

protected Domain(P2Object myP2Object)
creates a new Domain managed object

Method Detail

add

protected void add(java.lang.String name,
                   P2ManagedObject mo)
adds a new managed object to this domain

Parameters:
name - the name of the new object to be added
mo - the OID of the object to be added

remove

protected P2ManagedObject remove(java.lang.String name)
                          throws Ponder2Exception
removes a managed object from a domain

Parameters:
name - the name of the object to be removed
Throws:
Ponder2Exception

get

public P2ManagedObject get(java.lang.String name)
gets the P2ManagedObject of a named managed object

Parameters:
name - the name of the object to be located
Returns:
the P2ManagedObject of the named object or null if not found

contains

public boolean contains(java.lang.String aName)
returns true if the named object exists within the domain

Parameters:
aName - the name of the object to be located
Returns:
true if the object is found

contains

public boolean contains(P2Object anObject)
returns true if anObject exists within the domain

Parameters:
anObject - the object to be located
Returns:
true if the object is found

size

public int size()
Answer the number of elements in the receiver.

Returns:
the number of elements held

names

protected java.lang.String[] names()
returns an array of the names of the objects in this domain

Returns:
a String array with the object names

operation_listNames

protected P2Object operation_listNames()
answers an array containing the names of all the domain's entries.

Returns:
a Ponder2 array with the object names

operation_listObjects

protected P2Object operation_listObjects()
answers an array of Managed Object names containing all the entries in the domain.

Returns:
an array containing all the object in this domain

operation_asHash

protected P2Hash operation_asHash()
Returns a hash containing all the entries in the domain as name->object pairs

Returns:
a hash containing all the object in this domain as name,object pairs

operation_at

protected P2Object operation_at(java.lang.String aName)
answers the P2Object of the Managed Object at aName. Answers NIL if the object does not exist.

Parameters:
aName - the name of the object to be returned
Returns:
the object located by aName

operation_at

protected P2Object operation_at(P2Object source,
                                java.lang.String aName,
                                P2Block aBlock)
                         throws Ponder2Exception
Answer the P2Object associated with aName. If not found evaluate aBlock (with no arguments) and return its result

Parameters:
aName - the name of the object to be returned
aBlock - a block to be executed if aName is not found
Returns:
the named object or the result of executing the block
Throws:
Ponder2Exception

operation_at_add

protected P2Object operation_at_add(java.lang.String aName,
                                    P2Object p2Object)
add anOid into the domain with aName. Answers anOid.

Parameters:
aName - the name to be used
p2Object - the object to be added
Returns:
the object added to the domain

operation_do

protected void operation_do(P2Object source,
                            P2Block aBlock)
                     throws Ponder2Exception
Calls aBlock with name/value pairs for each entry in the domain. Answers with the the receiver

Parameters:
aBlock - the block to be executed. It must take up to two arguments, the first being name and the second being value
Throws:
Ponder2Exception

operation_collect

protected P2Array operation_collect(P2Object source,
                                    P2Block aBlock)
                             throws Ponder2Exception
Calls aBlock with name/value pairs for each entry in the domain. Answers with an array with all the answers from the executions

Parameters:
aBlock - the block to be executed
Returns:
an array with the results of the block executions
Throws:
Ponder2Exception

operation_resolve

protected P2Object operation_resolve(java.lang.String aPath)
                              throws Ponder2Exception
Answers with the object from aPath relative to this domain

Parameters:
aPath - the relative path to be resolved
Returns:
the object found at the path location
Throws:
Ponder2Exception

operation_remove

protected P2Object operation_remove(java.lang.String aName)
                             throws Ponder2Exception
Removes aName and its ManagedObject from the domain. Answers the object removed. TODO Error checks?

Parameters:
aName - the name of the object to be removed
Returns:
the object removed or nil
Throws:
Ponder2Exception

removeObject

protected boolean removeObject(P2Object anObject)
                        throws Ponder2Exception
Removes anObject from the receiver. All copies of anObject will be removed. Answers true if one or more were removed.

Parameters:
anObject - the object to be removed
Returns:
true if an object was removed
Throws:
Ponder2Exception

removeAll

protected void removeAll()
                  throws Ponder2Exception
Removes all objects from the domain. Answers the receiver.

Throws:
Ponder2Exception


Copyright © 2008 Imperial College. All Rights Reserved.