Extension SDK 10.1.2

oracle.ide.model
Class NodeFactory

java.lang.Object
  extended byoracle.ide.model.Factory
      extended byoracle.ide.model.NodeFactory

public final class NodeFactory
extends Factory

The NodeFactory class is responsible for creating intances of Node.

The type of Node that gets created depends on the URL that is passed into the findOrCreate(URL) and findOrCreate(Class, URL) methods. The NodeFactory makes use of registered Recognizer instances to determine what Node class corresponds to a particular URL.

Every Node instance created by the NodeFactory is cached. An instance of an already created Node can be retrieved from the cache by calling the find(URL) method.

See Also:
Node, Recognizer

Nested Class Summary
 
Nested classes inherited from class oracle.ide.model.Factory
Factory.RecognizerList
 
Field Summary
 
Fields inherited from class oracle.ide.model.Factory
NODE_CACHED, NODE_CREATED, NODE_UNCACHED
 
Constructor Summary
NodeFactory()
           
 
Method Summary
static void addRecognizer(int index, Recognizer recognizer)
          Registers a Recognizer, placing it in the specified location in the list of recognizers.
static void addRecognizer(Recognizer recognizer)
          Registers a ElementRecognizer, appending it to the end of the list of recognizers.
static Recognizer asRecognizer()
          Returns a Recognizer object that delegates its operations to the NodeFactory.
static Node clone(Node srcNode, java.net.URL dstNodeURL)
          Returns a new Node instance whose contents are identical to (and copied from) the specified Node.
static Node clone(java.net.URL srcNodeURL, java.net.URL dstNodeURL)
          Clones the Node at srcNodeURL to create a Node that is saved at dstNodeURL.
static Node find(java.net.URL url)
          Find the Node associated with the URL.
static Node findInFolder(Folder folder, java.net.URL url)
          Searches the specified Folder for an instance of Node whose URL matches the specified URL.
static Node findOrCreate(java.lang.Class type, java.net.URL url)
          Returns the Node associated with the URL.
static Node findOrCreate(java.net.URL url)
          Returns the Node associated with the URL.
static Node findOrCreateDefaultNode(java.net.URL url)
          Creates an instance of the default node class.
static Recognizer findRecognizer(java.net.URL url)
          Returns the instance of Recognizer that is able to specify the Node class that should be instantiated for the given URL.
static java.util.Iterator getCachedNodes()
          Returns an Iterator over the Node instances that are currently cached.
static java.lang.Class getDefaultNodeClass()
          Returns the node class that will be recognized when no Recognizer recognizes a given URL.
static DefaultRecognizer getDefaultRecognizer()
          Returns the default recognizer.
static java.util.Iterator getRecognizers()
          Returns the list of registered recognizers.
static void recache(java.net.URL oldURL, java.net.URL newURL, Node node)
          Removes the oldURL from the cache and puts the newURL in the cache so that it is associated with the given Node.
static void recache(java.net.URL oldURL, java.net.URL newURL, Node node, boolean notify)
          Removes the oldURL from the cache and puts the newURL in the cache so that it is associated with the given Node.
static java.lang.Class recognize(java.net.URL url)
          Returns the instance of Recognizer that is able to specify the Element class that should be instantiated for the given url.
static void removeRecognizer(Recognizer recognizer)
          Unregisters a Recognizer.
 void setDefaultNodeClass(java.lang.Class defaultClass)
          Sets the node class that will be recognized when no Recognizer recognizes a give URL.
static void setDefaultRecognizer(DefaultRecognizer recognizer)
          Sets the default recognizer.
static Node uncache(java.net.URL url)
          Removes the Node with the specified URL from the NodeFactory's cache.
static Node uncache(java.net.URL url, boolean notify)
          Removes the Node with the specified URL from the NodeFactory's cache.
 
Methods inherited from class oracle.ide.model.Factory
attach, detach, notify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeFactory

public NodeFactory()
Method Detail

asRecognizer

public static Recognizer asRecognizer()
Returns a Recognizer object that delegates its operations to the NodeFactory. This method is provided for the sake of classes that need to use the NodeFactory at runtime but need a way to not depend directly on the NodeFactory at compile time.


findOrCreate

public static Node findOrCreate(java.net.URL url)
                         throws java.lang.IllegalAccessException,
                                java.lang.InstantiationException
Returns the Node associated with the URL. If the Node does not exist, a new Node is created.

Parameters:
url - unique URL identifying the node.
Returns:
an existing node or a newly created one.
Throws:
java.lang.IllegalAccessException - if the Node class or its initializer is not accessible.
java.lang.InstantiationException - if the Node class is an abstract class, an interface, an array class, a primitive type, or void; or if the instantiation fails for some other reason.

findOrCreate

public static Node findOrCreate(java.lang.Class type,
                                java.net.URL url)
                         throws java.lang.IllegalAccessException,
                                java.lang.InstantiationException
Returns the Node associated with the URL. If the Node does not exist, a new Node is created.

Parameters:
type - The Class of the node type to create.
url - URL identifying the node's persistent location.
Returns:
an existing Node or a newly created one.
Throws:
java.lang.IllegalAccessException - if the Class or its initializer is not accessible.
java.lang.InstantiationException - if the Class is an abstract class, an interface, an array class, a primitive type, or void; or if the instantiation fails for some other reason.

find

public static Node find(java.net.URL url)
Find the Node associated with the URL. If the Node does not exist, null is returned.

Parameters:
url - URL identifying the Node.
Returns:
An existing Node, or null if none exists.

findInFolder

public static Node findInFolder(Folder folder,
                                java.net.URL url)
Searches the specified Folder for an instance of Node whose URL matches the specified URL. If no such Node can be found, null is returned.


clone

public static Node clone(java.net.URL srcNodeURL,
                         java.net.URL dstNodeURL)
Clones the Node at srcNodeURL to create a Node that is saved at dstNodeURL.


clone

public static Node clone(Node srcNode,
                         java.net.URL dstNodeURL)
Returns a new Node instance whose contents are identical to (and copied from) the specified Node. The original Node is not modified. The copying is done based on the last saved state of the srcNode. The returned Node is cached and assigned the URL specified by dstNodeURL.

Parameters:
srcNode - The Node that will be cloned.
dstNodeURL - The URL that is to be assigned to the clone after all of its data has been loaded from the original. This is the URL under which the new Node will be cached by the NodeFactory.
Returns:
The new Node that is a clone of the srcNode.

uncache

public static Node uncache(java.net.URL url)
Removes the Node with the specified URL from the NodeFactory's cache.


uncache

public static Node uncache(java.net.URL url,
                           boolean notify)
Removes the Node with the specified URL from the NodeFactory's cache. If notify is true, it notifies observers that the node was uncached.


recache

public static void recache(java.net.URL oldURL,
                           java.net.URL newURL,
                           Node node)
Removes the oldURL from the cache and puts the newURL in the cache so that it is associated with the given Node.


recache

public static void recache(java.net.URL oldURL,
                           java.net.URL newURL,
                           Node node,
                           boolean notify)
Removes the oldURL from the cache and puts the newURL in the cache so that it is associated with the given Node.


getCachedNodes

public static java.util.Iterator getCachedNodes()
Returns an Iterator over the Node instances that are currently cached. There is no guarantee as to what order the Nodes will be iterated over. Each object iterated over can be downcast to Node.


findRecognizer

public static Recognizer findRecognizer(java.net.URL url)
Returns the instance of Recognizer that is able to specify the Node class that should be instantiated for the given URL. If no Recognizer can determine the Node class, then null is returned.


recognize

public static java.lang.Class recognize(java.net.URL url)
Returns the instance of Recognizer that is able to specify the Element class that should be instantiated for the given url. If no Recognizer can determine the Element class, then null is returned.


addRecognizer

public static void addRecognizer(Recognizer recognizer)
Registers a ElementRecognizer, appending it to the end of the list of recognizers.

Parameters:
recognizer - instance of a ElementRecognizer implementation.

addRecognizer

public static void addRecognizer(int index,
                                 Recognizer recognizer)
Registers a Recognizer, placing it in the specified location in the list of recognizers. Specifying a position less than or equal to 0 prepends this recognizer to the list. A position value larger than (or equal to) the current list size appends this recognizer to the end of the list. All other values insert this recognizer somewhere in the middle of the list.

Parameters:
index - the index into the list of recognizers where this recognizer will be added
recognizer - instance of a Recognizer implementation.

removeRecognizer

public static void removeRecognizer(Recognizer recognizer)
Unregisters a Recognizer.

Parameters:
recognizer - instance of a Recognizer implemenation.

getRecognizers

public static java.util.Iterator getRecognizers()
Returns the list of registered recognizers.


getDefaultRecognizer

public static DefaultRecognizer getDefaultRecognizer()
Returns the default recognizer. The default recognizer is the last recognizer to be called.


setDefaultRecognizer

public static void setDefaultRecognizer(DefaultRecognizer recognizer)
Sets the default recognizer. The default recognizer is the last recognizer to be called.


getDefaultNodeClass

public static java.lang.Class getDefaultNodeClass()
Returns the node class that will be recognized when no Recognizer recognizes a given URL.


setDefaultNodeClass

public void setDefaultNodeClass(java.lang.Class defaultClass)
Sets the node class that will be recognized when no Recognizer recognizes a give URL.


findOrCreateDefaultNode

public static Node findOrCreateDefaultNode(java.net.URL url)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.InstantiationException
Creates an instance of the default node class. If an instance already exist that matches the default node class it returns that instance. If the found instance class does not match the default node class, the method throws an InstantiationException.

Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

Extension SDK

 

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