Extension SDK

oracle.ide.model
Class PackageFilter

java.lang.Object
  extended byoracle.ide.model.DefaultFilter
      extended byoracle.ide.model.HierarchicalFilter
          extended byoracle.ide.model.PackageFilter
All Implemented Interfaces:
ChildFilter, Displayable
Direct Known Subclasses:
PackageTreeFilter

public class PackageFilter
extends HierarchicalFilter

The PackageFilter organizes the children of a source folder into a package structure view. The PackageFilter typically organizes its children into a flat package structure view, with all subpackages displayed at the top-level. The PackageFilter can also organize its children into a nested package structure view that is reminiscent of the typical DirectoryFilter structure, but that is generally less desirable when viewing Java source files. For performance reasons, however, the nested package structure may be preferable to the flat package structure when viewing all files on the source path rather than just project files.


Nested Class Summary
 
Nested classes inherited from class oracle.ide.model.HierarchicalFilter
HierarchicalFilter.HierarchicalComparator
 
Nested classes inherited from class oracle.ide.model.DefaultFilter
DefaultFilter.SortedComparator, DefaultFilter.SortedFolderFirstComparator
 
Field Summary
 
Fields inherited from class oracle.ide.model.HierarchicalFilter
childMap, children, isOpen, miscFolder, nodeCache, NULL_KEY, options, sourcePath, TOP_FOLDER_KEY, uniqueNames, urlFilter, VIEW_HIERARCHICALLY, VIEW_PROJECT_FILES_ONLY
 
Fields inherited from class oracle.ide.model.DefaultFilter
folderFirstComparator, sortedComparator
 
Fields inherited from interface oracle.ide.explorer.ChildFilter
NO_OPTIONS
 
Constructor Summary
PackageFilter()
          Constructs a PackageFilter.
 
Method Summary
 void cache(TNode node)
          Overrides superclass cache(TNode) to ensure that all URLs along the URLPath for a PackageFolder are mapped to the TNode for that package in the cache.
protected  java.lang.String convertUrlToPackageName(java.net.URL url)
          Converts the specified URL to its corresponding package name; if the URL specifies a file, then the parent directory URL of the file is used.
protected  java.lang.String convertUrlToRelativeSpec(java.net.URL url)
          Converts the specified URL to its corresponding relative directory spec; if the URL specifies a file, then the parent directory URL of the file is used.
protected  Folder createFolder(java.lang.Object key)
          Creates a PackageFolder instance given the specified folder key.
protected  Folder createFolder(java.net.URL url)
          Creates a PackageFolder instance given the specified directory URL.
protected  java.lang.String getChildName(java.lang.Object parentKey, java.lang.Object childKey)
          Returns just the name part of a child folder given a parent folder key and the child folder key, or null if the first folder key is not a parent key of the second folder key.
protected  java.lang.Object getFolderKey(java.net.URL url)
          Returns the folder key for the folder that contains the specified URL.
protected  java.lang.Object getParentKey(java.lang.Object key)
          Returns the parent folder key for the specified folder key.
 int getType()
          Returns FilterTypes.PACKAGE_LIST_FILTER.
protected  void initChildren()
          Initializes the collection of top-level children for the filter.
protected  boolean isInSourcePath(java.net.URL url)
          Overrides superclass isInSourcePath(URL) to ensure that the URL also corresponds to a valid package name.
protected static boolean isValidPackageSpec(java.lang.String relativeSpec)
          Returns true if the relative directory spec corresponds to a valid package name.
protected static java.lang.String keyToPackageName(java.lang.Object key)
          Converts a folder key to a package name.
protected static java.lang.Object packageNameToKey(java.lang.String str)
          Converts a package name to a folder key.
protected static java.lang.String relativeSpecToPackageName(java.lang.String relativeSpec)
          Converts a relative directory spec to a package name.
 
Methods inherited from class oracle.ide.model.HierarchicalFilter
add, canRefresh, childrenAdded, childrenRemoved, clearChildren, createElement, getCategoryFolder, getChildren, getFolder, getFolderChildren, getFolderChildren, getMiscFolder, getOptions, getProject, getSourcePath, getSourcePathEntry, getURLFilter, getViewAllFiles, getViewHierarchically, hasMiscFiles, initializeChildMap, initMiscFolder, isDirInProject, isParentKey, isSourcePathEntry, list, list, refresh, remove, setComparator, setOptions, setSourcePath, setURLFilter, setViewAllFiles, setViewHierarchically, uncache, update
 
Methods inherited from class oracle.ide.model.DefaultFilter
getComparator, getIcon, getLongLabel, getOwner, getShortLabel, getToolTipText, refreshExplorerNode, setOwner, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackageFilter

public PackageFilter()
Constructs a PackageFilter.

Method Detail

cache

public void cache(TNode node)
Overrides superclass cache(TNode) to ensure that all URLs along the URLPath for a PackageFolder are mapped to the TNode for that package in the cache.

Specified by:
cache in interface ChildFilter
Overrides:
cache in class HierarchicalFilter

isInSourcePath

protected boolean isInSourcePath(java.net.URL url)
Overrides superclass isInSourcePath(URL) to ensure that the URL also corresponds to a valid package name. If the URL does not correspond to a valid package, this method returns false.

Overrides:
isInSourcePath in class HierarchicalFilter
Parameters:
url - the URL to test; the URL can correspond to either a file or a directory.

getType

public int getType()
Returns FilterTypes.PACKAGE_LIST_FILTER.

Specified by:
getType in interface ChildFilter
Overrides:
getType in class DefaultFilter

createFolder

protected Folder createFolder(java.net.URL url)
Creates a PackageFolder instance given the specified directory URL.

Specified by:
createFolder in class HierarchicalFilter
Parameters:
url - the URL of the Folder to create.
Returns:
a Folder instance, or null if the Folder could not be created for the specified URL.

createFolder

protected Folder createFolder(java.lang.Object key)
Creates a PackageFolder instance given the specified folder key.

Specified by:
createFolder in class HierarchicalFilter
Returns:
a Folder instance, or null if the Folder could not be created for the specified folder key.
See Also:
getFolderKey(URL), getParentKey(Object)

getFolderKey

protected java.lang.Object getFolderKey(java.net.URL url)
Returns the folder key for the folder that contains the specified URL. The folder key for a PackageFolder is simply the fully qualified package name of the folder.

Specified by:
getFolderKey in class HierarchicalFilter
Parameters:
url - the directory URL of the folder; if the URL specifies a file, then the parent URL of the file is used.
Returns:
the key of the folder containing the specified URL, or HierarchicalFilter.NULL_KEY if the URL is not on the source path.

getParentKey

protected java.lang.Object getParentKey(java.lang.Object key)
Returns the parent folder key for the specified folder key. The parent key for a PackageFolder is the fully qualified package name of the parent package, or HierarchicalFilter.TOP_FOLDER_KEY for the top-level package.

Specified by:
getParentKey in class HierarchicalFilter
Parameters:
key - the folder key to get the parent key of.
Returns:
the key of the parent folder, or HierarchicalFilter.NULL_KEY if the parent folder is no longer on the source path.
See Also:
getFolderKey(URL)

getChildName

protected java.lang.String getChildName(java.lang.Object parentKey,
                                        java.lang.Object childKey)
Returns just the name part of a child folder given a parent folder key and the child folder key, or null if the first folder key is not a parent key of the second folder key.

Since each folder key is just the fully qualified package name, just return the tail of the child's key skipping any leading dot character.

Specified by:
getChildName in class HierarchicalFilter
Parameters:
parentKey - the prospective parent folder key.
childKey - the prospective child folder key.

initChildren

protected void initChildren()
Initializes the collection of top-level children for the filter.

The children of the filter consists of all top-level PackageFolder objects (when the filter is in flat view, all packages in the project are considered top-level packages).

All source files that are in the top-level package are also considered children of the filter (i.e., all source files that are direct children of one of the directories on the sourcepath).

Specified by:
initChildren in class HierarchicalFilter

packageNameToKey

protected static java.lang.Object packageNameToKey(java.lang.String str)
Converts a package name to a folder key.


keyToPackageName

protected static java.lang.String keyToPackageName(java.lang.Object key)
Converts a folder key to a package name.


relativeSpecToPackageName

protected static java.lang.String relativeSpecToPackageName(java.lang.String relativeSpec)
Converts a relative directory spec to a package name. It is assumed that the relative directory spec is composed of directories which correspond to a valid Java identifier.


isValidPackageSpec

protected static boolean isValidPackageSpec(java.lang.String relativeSpec)
Returns true if the relative directory spec corresponds to a valid package name. Each directory component in the relative directory spec must be a valid Java identifier.


convertUrlToRelativeSpec

protected java.lang.String convertUrlToRelativeSpec(java.net.URL url)
Converts the specified URL to its corresponding relative directory spec; if the URL specifies a file, then the parent directory URL of the file is used.

The relative spec is obtained by finding the URL of the source path entry that contains the target URL, and then calling URLFileSystem.toRelativeSpec(URL,URL) on the two URLs.

Parameters:
url - the URL to get the relative spec for.
Returns:
the relative directory spec corresponding to the specified URL, or null if the URL is not on the source path.

convertUrlToPackageName

protected java.lang.String convertUrlToPackageName(java.net.URL url)
Converts the specified URL to its corresponding package name; if the URL specifies a file, then the parent directory URL of the file is used.

The package name is obtained by calculating the relative directory between the specified URL and the URL of the source path entry that contains it, replacing '/' characters with '.' characters.

Parameters:
url - the URL to get the package name for.
Returns:
the full package name corresponding to the specified URL, or null if the URL is not on the source path.

Extension SDK

 

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