ARoad0.gBase
Class CNodeImpl

java.lang.Object
  extended by ARoad0.gBase.CNodeImpl
All Implemented Interfaces:
java.io.Serializable

public class CNodeImpl
extends java.lang.Object
implements java.io.Serializable

This class is an embedded class responsible for modeling a node which contains children (leaves and nodes) as a private attribute of a composite class instance, called the master instance. The master delegates the processing of its children to an instance of this class. The master class may be a Directory or a VirtualFolder, and it transfers the operations on the children to this class. The children are Resources or VirtualFolders. They all deleted when the node is deleted, on the contrary of the members of a virtual folder, for instance. This class implements the Node interface for its master, but this is not directly controlled by Java since this class does not implement the interface to avoid to be a public class. The Leaf interface is not processed, so the master has to managed it since any node is a leaf.

All variables are private to secure the white box inheritances from this class. It is a javabean with the following bound properties:

- 'Children'.

The listeners are proper to this instance. Excepting for EPRViewInBaseImpl, they are outside gBase, transient (not serialized in this instance backup). They are called in any order. They receive only a copy of the new value, to protect the property. All the exceptions from the listeners are catched, and a dialog box is displayed to inform the user. This class is public to be overriden in the AcsAddons, and in this case, the subclass is only called by some classes in the same package. See the Copyright.

See Also:
Node, Resource, VirtualFolder, Serialized Form

Field Summary
protected  java.beans.PropertyChangeSupport changeSupport_
          manages all the property change listeners of this class and its subclasses
(package private) static CNodeImpl EMPTY_INSTANCE
          A reusable empty instance for initialization, to avoid the use of 'new' for temporary values.
protected static int INCREMENT_CAPACITY
           
protected static int INITIAL_CAPACITY
          Protected variables
protected static int INITIAL_CAPACITY_2
           
protected  ImmutableLeaf[] l_Children_
           
protected  Node master_
           
static java.io.ObjectStreamField[] serialPersistentFields
          variable for the JDK 2 serialization
private static long serialVersionUID
           
 
Constructor Summary
protected CNodeImpl()
          The basic constructor.
protected CNodeImpl(Node _master)
          Used by the master constructor.
 
Method Summary
protected  void addEorChild(ImmutableLeaf _child)
          Adds a child to the CNode, without control on the master type and the ACS type policy.
protected  void addPropertyChangeListener(java.beans.PropertyChangeListener _l)
          Adds a listener to the bean, for all the bound properties.
protected  void addPropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Adds a listener to the bean.
protected  CNodeImpl cloneC(Node _master)
          Clone for embeddd class without registering the new object in the ACSs.
protected  CNodeImpl copy(Node _masterCopy)
          This method provides a copy of the instance with another name, without children copying because the copy order will not be always correct.
 boolean equals(java.lang.Object _obj)
           
protected  void finalize()
          This method removes the CNode from the ACS lists, but there is no guarantee that the JVM calls this method before the end of the application.
protected  void finalizeForBase()
          Finalizes the CNode and ALL ITS CHILDREN.
protected  void finalizeFromDeserialization()
          This method finalizes all the children, since it is used after a deserialization.
protected  void firePropertyChange(java.lang.String _propertyName, java.lang.Object _oldValue, java.lang.Object _newValue)
          Fires an event to every registered listener, in any order.
protected  ImmutableLeaf[] getEorL_Children()
          Gets a sorted array of external object references on the children of this node, which may be leaves or nodes.
 java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String _propertyName)
          Returns the change listeners for a property.
 long getSerialVersionUID()
           
 int hashCode()
           
protected  void removeEorChild(ImmutableLeaf _child)
          Removes a child from the CNode.
protected  void removePropertyChangeListener(java.beans.PropertyChangeListener _l)
          Removes a listener to the bean, for all the bound properties.
protected  void removePropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Removes a listener to the bean.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

protected static final int INITIAL_CAPACITY
Protected variables

See Also:
Constant Field Values

INITIAL_CAPACITY_2

protected static final int INITIAL_CAPACITY_2
See Also:
Constant Field Values

INCREMENT_CAPACITY

protected static final int INCREMENT_CAPACITY
See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

master_

protected Node master_

l_Children_

protected ImmutableLeaf[] l_Children_

EMPTY_INSTANCE

static final CNodeImpl EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. Caution: never change the state of the returned instance.


changeSupport_

protected transient java.beans.PropertyChangeSupport changeSupport_
manages all the property change listeners of this class and its subclasses


serialPersistentFields

public static final java.io.ObjectStreamField[] serialPersistentFields
variable for the JDK 2 serialization

Constructor Detail

CNodeImpl

protected CNodeImpl()
The basic constructor.


CNodeImpl

protected CNodeImpl(Node _master)
             throws CreateError
Used by the master constructor.

Parameters:
_master - is the master of this embedded class
Throws:
CreateError - the master is null
Method Detail

copy

protected CNodeImpl copy(Node _masterCopy)
                  throws CreateError
This method provides a copy of the instance with another name, without children copying because the copy order will not be always correct.

Parameters:
_masterCopy - is the master of the new copy
Returns:
copy as CNodeImpl instance
Throws:
CreateError - of the constructor with the same parameters.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
a value derived from the parent nick name hashcode

getEorL_Children

protected final ImmutableLeaf[] getEorL_Children()
Gets a sorted array of external object references on the children of this node, which may be leaves or nodes.

Returns:
ImmutableLeaf[]. May be null but not empty.

addEorChild

protected void addEorChild(ImmutableLeaf _child)
Adds a child to the CNode, without control on the master type and the ACS type policy. Used only by the master, which may add controls on the parameter class. Has to be used by the leaf constructor, so does not update the parent internal variable in the child. Controls the child ACS name. No control on the ACS type policy, since it is done in the ResourceImpl and VirtualFolderImpl constructors which calls the master for adding a new child. Detects the child presence through a name comparison. Fires the event 'Children'.

Parameters:
_child - is a leaf to put in this CNode. No action if null, or already known.
Throws:
java.lang.InternalError - if the leaves list is null. If firePropertyChange() throws an exception, displays an user message.

removeEorChild

protected void removeEorChild(ImmutableLeaf _child)
                       throws UpDateError
Removes a child from the CNode. Used by the children finalizing methods. Does not update the parent internal variable in the child. Detects the child presence through a name comparison. Fires 'Children' property. If firePropertyChange() throws an exception, displays an user message. No action if the children list is null, to speed up the finalizing of this instance, when children are called to be finalizing.

Parameters:
_child - is a leaf which is in this CNode. No action if null.
Throws:
UpDateError - if _child is not known.

addPropertyChangeListener

protected void addPropertyChangeListener(java.beans.PropertyChangeListener _l)
Adds a listener to the bean, for all the bound properties.

Parameters:
_l - PropertyChangeListener to add

addPropertyChangeListener

protected void addPropertyChangeListener(java.lang.String _propertyName,
                                         java.beans.PropertyChangeListener _l)
Adds a listener to the bean. Used by Gui1.CommonPropertyEditor for all the bound properties: 'Children'.

Parameters:
_propertyName - name of the property
_l - PropertyChangeListener to add

removePropertyChangeListener

protected void removePropertyChangeListener(java.beans.PropertyChangeListener _l)
Removes a listener to the bean, for all the bound properties.

Parameters:
_l - PropertyChangeListener to remove

removePropertyChangeListener

protected void removePropertyChangeListener(java.lang.String _propertyName,
                                            java.beans.PropertyChangeListener _l)
Removes a listener to the bean. Used by Gui1.CommonPropertyEditor for all the bound properties: 'Children'.

Parameters:
_propertyName - name of the property
_l - PropertyChangeListener to remove

getPropertyChangeListeners

public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String _propertyName)
Returns the change listeners for a property. Used by the AcsAddons.

Parameters:
_propertyName - name of the listened property.
Returns:
the change listeners. May be null.

finalizeForBase

protected void finalizeForBase()
                        throws UpDateError
Finalizes the CNode and ALL ITS CHILDREN. HAVE TO BE USED before the deleting of the CNode.

Throws:
UpDateError - if the CNode is unknown of the main ACS (if it is a clone without setName(), typically)

finalizeFromDeserialization

protected void finalizeFromDeserialization()
This method finalizes all the children, since it is used after a deserialization. There, the attributes have been deserialized but are not 'true' objects of the base. The instance is NOT removed as a listener, since there is no listener. The internal maps are set to null, but not the private bound properties sets. Does not call finalizeForBase(). Called for EPRViewInBaseImpl only.


cloneC

protected CNodeImpl cloneC(Node _master)
Clone for embeddd class without registering the new object in the ACSs. Caution: don't use any modifying method that may altere the integrity of the base. The children list is cloned without deep copy. The external object references are not cloned (see "Eor" in get method). The links between the EOR and the new instance are not set, but the lists of OER are cloned (children) so it is possible to get these active objects.

Parameters:
_master - the clone master
Returns:
cloned object with _master as the master
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object _obj)
Overrides:
equals in class java.lang.Object
Parameters:
_obj - Object
Returns:
true if _obj is a CNodeImpl instance (or an instance of an extended class) equals to the current one

getSerialVersionUID

public long getSerialVersionUID()
Returns:
long: serial version UID for serialization of the instance

firePropertyChange

protected void firePropertyChange(java.lang.String _propertyName,
                                  java.lang.Object _oldValue,
                                  java.lang.Object _newValue)
Fires an event to every registered listener, in any order. For the properties 'Children'.

Parameters:
_propertyName - name of the changing property
_oldValue - of the property
_newValue - of the property. No operation if equal to _oldValue and not null.

finalize

protected void finalize()
                 throws java.lang.Throwable
This method removes the CNode from the ACS lists, but there is no guarantee that the JVM calls this method before the end of the application.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable