Extension SDK 10.1.2

oracle.ide.model
Class DefaultRecognizer

java.lang.Object
  extended byoracle.ide.model.DefaultRecognizer
All Implemented Interfaces:
Recognizer
Direct Known Subclasses:
URLRecognizer, XMLRecognizer

public class DefaultRecognizer
extends java.lang.Object
implements Recognizer

The DefaultRecognizer is the default Recognizer implementation used in the IDE. It contains support for recognizing an URL based on , extension.


Constructor Summary
DefaultRecognizer()
          Pass in the Recognizer that DefaultRecognizer should delegate to when it needs to invoke a Recognizer operation on another URL.
 
Method Summary
 boolean canConvert(java.net.URL oldURL, java.net.URL newURL)
          This implementation looks at the two URLs to see what the corresponding Node class will be.
static void clearExtensionToClassMap()
          Clears the extension to class map.
 Node create(java.net.URL url, java.lang.Class clazz)
          Creates an instance of the design-time node associated with the specified URL.
static java.lang.Class getClassForExtension(java.lang.String extension)
          Return the class that has been registered with the given extension or null if not has been registered.
static DocumentInfo getDocumentInfo(java.lang.Class nodeClass)
          Returns the DocumentInfo associated with the specified nodeClass.
 java.util.Map getExtensionToClassMap()
           
 java.util.HashSet getValidConversions(java.lang.Class cls)
           
static void mapExtensionToClass(java.lang.String extension, java.lang.Class cls)
          Maps the given extension, which is a file extension, to the given Class which must be a Node class.
 java.lang.Class recognize(java.net.URL url)
          Gets the Class of the data item associated with the specified URL.
static void registerConversion(java.lang.Class oldNodeClass, java.lang.Class newNodeClass)
          Registers a conversion between Node classes that is to be considered valid.
static void registerDocumentInfo(java.lang.Class nodeClass, DocumentInfo info)
          Associates a document class with a record of information containing the icon and label identifying the document type.
static java.io.File sanitizeExtension(java.lang.String extension)
          Makes sure that the extension begins with a '.'.
static java.lang.String sanitizeExtensionAsString(java.lang.String extension)
           
 java.net.URL validate(java.net.URL newURL, java.net.URL oldURL)
          Validate the specified new name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRecognizer

public DefaultRecognizer()
Pass in the Recognizer that DefaultRecognizer should delegate to when it needs to invoke a Recognizer operation on another URL.

Method Detail

mapExtensionToClass

public static void mapExtensionToClass(java.lang.String extension,
                                       java.lang.Class cls)
Maps the given extension, which is a file extension, to the given Class which must be a Node class.

Addins that extend this class must provide their own static implementation of this method. Using the default implementation for any other purpose than to map extension defined by end users to registered node types will break current IDE behavior. In other words, this method is only for internal IDE purposes. The extension passed in is allowed to contain or omit the leading "."; if it is omitted, it will be added automatically.


clearExtensionToClassMap

public static void clearExtensionToClassMap()
Clears the extension to class map. Calling this method will render this recognizer unable to recognize any node types. This method should be called before a new set of extensions to class maps are going to be registered.


getClassForExtension

public static java.lang.Class getClassForExtension(java.lang.String extension)
Return the class that has been registered with the given extension or null if not has been registered.


registerConversion

public static void registerConversion(java.lang.Class oldNodeClass,
                                      java.lang.Class newNodeClass)
Registers a conversion between Node classes that is to be considered valid.

Parameters:
oldNodeClass - The Node class that the conversion is occuring from.
newNodeClass - The Node class that the oldNodeClass is being converted to.

registerDocumentInfo

public static void registerDocumentInfo(java.lang.Class nodeClass,
                                        DocumentInfo info)
Associates a document class with a record of information containing the icon and label identifying the document type.


getDocumentInfo

public static DocumentInfo getDocumentInfo(java.lang.Class nodeClass)
Returns the DocumentInfo associated with the specified nodeClass.


recognize

public java.lang.Class recognize(java.net.URL url)
Description copied from interface: Recognizer
Gets the Class of the data item associated with the specified URL. Implementations must return null if the URL is not recognized. The Class returned must be the data model class. This value is passed to the Recognizer.create(URL, Class) method which will create the design-time node.

Specified by:
recognize in interface Recognizer
Parameters:
url - unique URL identifying the document.
Returns:
the data Class.

create

public Node create(java.net.URL url,
                   java.lang.Class clazz)
            throws java.lang.IllegalAccessException,
                   java.lang.InstantiationException
Description copied from interface: Recognizer
Creates an instance of the design-time node associated with the specified URL. This method is called by the NodeFactory. This method must return a Node instance. The type parameter specifies the Class of the data object.

Specified by:
create in interface Recognizer
Parameters:
url - unique URL identifying the document.
clazz - the data Class.
Returns:
Design-time node.
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

validate

public java.net.URL validate(java.net.URL newURL,
                             java.net.URL oldURL)
                      throws RecognizerException
Description copied from interface: Recognizer
Validate the specified new name. Returns null if the name does not validate. This method may modify the URL to make it valid, such as adding a file extension. The old URL is used as the validation base. For example, if the new URL does not have the correct file extension, the old URL extension may be added to the new URL during the validation process.

Specified by:
validate in interface Recognizer
Parameters:
newURL - the new URL to validate.
oldURL - the old URL used as the validation base.
Returns:
the validated URL or null if the name does not validate.
Throws:
RecognizerException - if validation fails. The reason why validation failed is in the exception's message. The message should be suitably formatted so that it can be displayed to the user.

canConvert

public boolean canConvert(java.net.URL oldURL,
                          java.net.URL newURL)
This implementation looks at the two URLs to see what the corresponding Node class will be. If the conversion is compatible, then it is allowed.

The DefaultRecognizer implementation of this checks the Node class types that have been registered through registerConversion(Class, Class). If a mapping from the oldURL's recognized Node class can be found to the newURL's recognized Node class, then this method returns true. Otherwise, this method returns false.

Of course, if the Node class for the oldURL and the newURL are identical, then conversion is allowed.

Specified by:
canConvert in interface Recognizer
Parameters:
oldURL - the url of the node being renamed.
newURL - the new url for the node.
Returns:
true if conversion is possible.

getValidConversions

public java.util.HashSet getValidConversions(java.lang.Class cls)

getExtensionToClassMap

public java.util.Map getExtensionToClassMap()
Returns:
An unsynchronized Map that should be synchronized upon when used.

sanitizeExtension

public static java.io.File sanitizeExtension(java.lang.String extension)
Makes sure that the extension begins with a '.'. If it does, the extension is just returned as-is. If it doesn't, one is prepended to the extension, and the result is returned. The extension is returned as a File to make the extension follow the case-sensitivity rules of the local file system.


sanitizeExtensionAsString

public static java.lang.String sanitizeExtensionAsString(java.lang.String extension)

Extension SDK

 

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