Extension SDK 10.1.2

oracle.ide.panels
Class MetaTraversable

java.lang.Object
  extended byoracle.ide.panels.MetaTraversable
All Implemented Interfaces:
Copyable
Direct Known Subclasses:
Navigable, Step

public class MetaTraversable
extends java.lang.Object
implements Copyable

The MetaTraversable class is responsible for specifying metadata for a Traversable that has not yet been instantiated. The MetaTraversable class allows Traversable objects to be instantiated lazily while still providing some facility for context-sensitive customization of the Traversable creation and usage.

A typical example of context-sensitive customization is specifying the help topic ID associated with the Traversable. In cases where the same Traversable implementation can be used in different help contexts, each help context is specified through the MetaTraversable rather than in the Traversable implementation itself. This approach avoids cluttering the Traversable with code that determines the help topic ID based on where it is being used.


Constructor Summary
protected MetaTraversable()
          Should only be used by copyTo(Object).
  MetaTraversable(java.lang.Class traversableClass)
          Creates a MetaTraversable that instantiates the specified Traversable class using its default constructor.
  MetaTraversable(java.lang.Class traversableClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs)
          Creates a MetaTraversable that instantiates the specified Traversable class using the constructor whose parameter types exactly match the types indicated by constructorArgTypes.
 
Method Summary
 java.lang.Object copyTo(java.lang.Object target)
          Copies the internal state of this object to the specified copy.
protected  void copyToImpl(MetaTraversable copy)
           
 java.lang.Class getTraversableClass()
          Returns the class object of the described Traversable.
 boolean isUsingTraversableDefaultConstructor()
          Returns true of the construction of the associated Traversable uses its default constructor; returns false if a constructor other than the default is used.
protected  Traversable newTraversable()
          Overriding this method is the preferred means of overriding MetaTraversable's Traversable creation behavior.
 Traversable newTraversable(ApplyNotifier applyNotifier)
          This method specifies the Traversable that will be used in association with the Navigable; in general, only NavigableUIContainer implementations should call this method directly.
 void setHelpID(java.lang.String helpID)
          By default, a MetaTraversable does not specify a context-sensitive help topic ID; it is normally the responsibility of the Traversable to have the right help ID.
 void setNameLink(java.lang.String name, java.lang.String alias)
          This method provides a means of mapping the data name used by a Traversable to the data name that an object has in the TraversableContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaTraversable

public MetaTraversable(java.lang.Class traversableClass)
Creates a MetaTraversable that instantiates the specified Traversable class using its default constructor. The default constructor of the specified class must be public.


MetaTraversable

public MetaTraversable(java.lang.Class traversableClass,
                       java.lang.Class[] constructorArgTypes,
                       java.lang.Object[] constructorArgs)
Creates a MetaTraversable that instantiates the specified Traversable class using the constructor whose parameter types exactly match the types indicated by constructorArgTypes. The constructor must be public. When the constructor is called, constructorArgs will be passed in as the arguments.

The specified traversable class is allowed to be null. In this case, MetaTraversable must be subclassed, and the subclass must override newTraversable(ApplyNotifier). Otherwise,


MetaTraversable

protected MetaTraversable()
Should only be used by copyTo(Object).

Method Detail

copyTo

public java.lang.Object copyTo(java.lang.Object target)
Description copied from interface: Copyable
Copies the internal state of this object to the specified copy. If copy is null, then this method should create a new instance of this class and proceed to copy the internal state to the newly created object. Generally, only the persistent state of the object should be copied, but whether or not it is appropriate to copy transient properties is at the discretion of the individual implementor.

Regardless of whether the copy occurs to an existing object or to a newly created object, the return value is object to which this object's state was copied.

There is a standard implementation pattern for the copyTo method that helps avoid problems that arise when a Copyable object is subclassed. The pattern is:

public Object copyTo( Object target )
{
final <this_class> copy =
target != null ? (<this_class>) target : new <this_class>();
copyToImpl( copy );
return copy;
} protected final void copyToImpl( <this_class> copy ) { super.copyToImpl( copy ); // if necessary // put code here for copying the properties of <this_class> }
The parameter passed into the copyToImpl method is the same type of this class. The responsibility of copyToImpl is to copy the state of this class through direct access of the fields. The copyToImpl method should not use getters and setters since these may be overridden, causing the state of this class to be incompletely copied.

Specified by:
copyTo in interface Copyable
Parameters:
target - The target object to which the state of this object should be copied. If target is null, then the copyTo method will return a new instance of this class.
Returns:
The object to which the state of this object was copied. If the target was non-null, then the return value is the same as the target object that was passed in; otherwise, the return value is a new instance of this class.

copyToImpl

protected final void copyToImpl(MetaTraversable copy)

isUsingTraversableDefaultConstructor

public boolean isUsingTraversableDefaultConstructor()
Returns true of the construction of the associated Traversable uses its default constructor; returns false if a constructor other than the default is used.


getTraversableClass

public java.lang.Class getTraversableClass()
Returns the class object of the described Traversable.


newTraversable

public Traversable newTraversable(ApplyNotifier applyNotifier)
This method specifies the Traversable that will be used in association with the Navigable; in general, only NavigableUIContainer implementations should call this method directly.

NOTE: Subclasses should override the newTraversable() method instead of this method whenever possible. The reason for this is that the implementation of this method takes care of registering the Traversable returned by newTraversable() as an ApplyListener.

Implementations should return a new Traversable instance each time this method is called; specifically the implementation should not attempt to cache the returned Traversable because caching is the responsibility of the NavigableUIContainer that is rendering this Navigable.

By default, this method uses the Class that was specified when this Navigable was created and calls Class.newInstance() on that Class to create the new Traversable. If the class is null or the class does not implement a public default constructor or the newly created object cannot be cast to Traversable, this method will return an instance of DefaultTraversablePanel. If the class implements the ApplyListener interface, then the Traversable instance will be added as an ApplyListener to the NavigableUIContainer as well.

Parameters:
applyNotifier - Subclasses that override this method can register an ApplyListener with the NavigableUIContainer.
Returns:
A Traversable which represents the detail UI component that is shown when the user selects this Navigable in the NavigableUIContainer.

setHelpID

public void setHelpID(java.lang.String helpID)
By default, a MetaTraversable does not specify a context-sensitive help topic ID; it is normally the responsibility of the Traversable to have the right help ID. However, in cases where the same Traversable is used in different help contexts, this method is provided to override the help ID that is specified by the Traversable.


setNameLink

public void setNameLink(java.lang.String name,
                        java.lang.String alias)
This method provides a means of mapping the data name used by a Traversable to the data name that an object has in the TraversableContext. Normally, the name used by the Traversable will not need to be re-mapped, but there are situations where this extra level of indirection in the naming is necessary.

A Traversable locates data objects by querying the TraversableContext with the names of the data objects that it needs. However, if the data scope contains multiple instances of one of these data classes, each instance will need to have a different name. In such a situation, the same Traversable class will normally be used to edit all instances of that data class. The data instance that the Traversable ends up acquiring via Namespace.find(String) depends on the name link that is associated with the MetaTraversable that activated the Traversable. This method establishes such a name link.

Parameters:
name - The name that the Traversable will use when calling TraversableContext#find(String). A null name is allowed.
alias - The actual name of the object that resides in the TraversableContext. This object is delivered to the Traversable when the TraversableContext#find(String) method is called and this MetaTraversable is currently selected. A null alias is allowed.

newTraversable

protected Traversable newTraversable()
Overriding this method is the preferred means of overriding MetaTraversable's Traversable creation behavior.

This method is called by newTraversable(ApplyNotifier), which then also registers the returned Traversable with the current ApplyNotifier, if the Traversable is an instance of ApplyListener.


Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.