Extension SDK 9.0.5

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
static class PackageFilter.PackageFactory
           
 
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, urlFilter, VIEW_HIERARCHICALLY, VIEW_PROJECT_FILES_ONLY, VIEW_SORT_BY_TYPE
 
Fields inherited from class oracle.ide.model.DefaultFilter
folderFirstComparator, folderFirstComparator2, sortedComparator
 
Fields inherited from interface oracle.ide.explorer.ChildFilter
NO_OPTIONS
 
Constructor Summary
PackageFilter()
          Constructs a PackageFilter.
 
Method Summary
protected  void addFolderToChildMap(HierarchicalFolder folder, java.lang.Object key)
          Method called when building the childMap and the folder has no children.
protected  HierarchicalFolder buildOtherChildrenMap(Element element, HierarchicalFolder parent, java.util.Map otherChildrenMap, int count)
           
 void cachePut(java.net.URL url, 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  TNode cacheRemove(java.net.URL key)
          Overrides superclass cache(TNode) to ensure that all URLs along the URLPath for a PackageFolder are unmapped to the TNode for that package in the cache.
 void closeChildren()
          Called when project is closed.
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.
static java.lang.String convertUrlToPackageName(java.net.URL url, URLPath srcPath)
          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 static java.lang.String convertUrlToRelativeSpec(java.net.URL url, URLPath sourcePath)
          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.
static Factory findFactory(Project project)
          Find the factory assicated with the specified project.
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.
 PackageFilter.PackageFactory getFactory()
           
static PackageFilter.PackageFactory getFactory(Project project)
          Get the factory assicated with the specified project.
protected  java.lang.Object getFolderKey(java.net.URL url)
          Returns the folder key for the folder that contains the specified URL.
protected  CategoryFolder getMiscFolder()
          Return the "Miscellaneous Files" CategoryFolder for this filter.
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  boolean handleHierarchicalFolder(java.lang.Object item, java.util.Collection out)
           
protected  TNode handleOtherAdditions(java.util.Map additionsMap, TreeExplorer tree, TNode childNode)
           
protected  TNode handleOtherRemovals(java.util.Map additionsMap, TreeExplorer tree, TNode childNode)
           
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  boolean isNodeContainerInProject(TNode node)
          Returns true if the specified TNode's Container is in the project.
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.
static Factory removeFactory(Project project)
          Remove the factory assicated with the specified project.
 void setOwner(TNode owner)
          Sets the node that owns this filter.
 void uncache(TNode node)
          Overrides superclass cache(TNode) to ensure that all URLs along the URLPath for a PackageFolder are unmapped to the TNode for that package in the cache.
 
Methods inherited from class oracle.ide.model.HierarchicalFilter
add, addElementToChildMap, cache, cacheGet, canRefresh, childrenAdded, childrenRemoved, clearChildren, containsChild, createElement, createElementNode, createFolderNode, findOrCreateChildList, getCategoryFolder, getChildren, getFolder, getFolderChildren, getFolderChildren, getFolderKey, getOptions, getProject, getSourcePath, getSourcePathEntry, getSourcePathEntry, getURLFilter, getViewAllFiles, getViewHierarchically, hasMiscFiles, initializeChildMap, initMiscFolder, isDirInProject, isHierarchicalFolder, isParentKey, isSortByType, isSourcePathEntry, isStrict, list, list, refresh, remove, removeElementFromChildMap, removeElementNode, reset, setComparator, setNodeInProject, setOptions, setSortByType, setSourcePath, setURLFilter, setViewAllFiles, setViewHierarchically, update, updateTreeComparatorOptions, validateParent
 
Methods inherited from class oracle.ide.model.DefaultFilter
canUpdate, checkElementAttributes, getComparator, getIcon, getLongLabel, getOwner, getShortLabel, getToolTipText, refreshExplorerNode, 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

getFactory

public static PackageFilter.PackageFactory getFactory(Project project)
Get the factory assicated with the specified project. If none available one is created.


removeFactory

public static Factory removeFactory(Project project)
Remove the factory assicated with the specified project.

Returns:
the factory removed.

findFactory

public static Factory findFactory(Project project)
Find the factory assicated with the specified project. If none available null is returned.


convertUrlToPackageName

public static java.lang.String convertUrlToPackageName(java.net.URL url,
                                                       URLPath srcPath)
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.

cachePut

public void cachePut(java.net.URL url,
                     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.

Overrides:
cachePut in class HierarchicalFilter

cacheRemove

protected TNode cacheRemove(java.net.URL key)
Overrides superclass cache(TNode) to ensure that all URLs along the URLPath for a PackageFolder are unmapped to the TNode for that package in the cache.

Overrides:
cacheRemove in class HierarchicalFilter

uncache

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

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

closeChildren

public void closeChildren()
Called when project is closed. We must close the cached package nodes.

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

getFactory

public PackageFilter.PackageFactory getFactory()
Returns:
the PackageFilter.PackageFactory used to create package instances.

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.

setOwner

public void setOwner(TNode owner)
Description copied from interface: ChildFilter
Sets the node that owns this filter.

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

getType

public int getType()
Returns FilterTypes.PACKAGE_LIST_FILTER.

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

handleHierarchicalFolder

protected boolean handleHierarchicalFolder(java.lang.Object item,
                                           java.util.Collection out)
Overrides:
handleHierarchicalFolder in class HierarchicalFilter

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

addFolderToChildMap

protected void addFolderToChildMap(HierarchicalFolder folder,
                                   java.lang.Object key)
Description copied from class: HierarchicalFilter
Method called when building the childMap and the folder has no children. This implementation does nothin.

Overrides:
addFolderToChildMap in class HierarchicalFilter

getMiscFolder

protected CategoryFolder getMiscFolder()
Description copied from class: HierarchicalFilter
Return the "Miscellaneous Files" CategoryFolder for this filter. This folder contains all children of the owning folder that are not on the source path.

Overrides:
getMiscFolder in class HierarchicalFilter

buildOtherChildrenMap

protected HierarchicalFolder buildOtherChildrenMap(Element element,
                                                   HierarchicalFolder parent,
                                                   java.util.Map otherChildrenMap,
                                                   int count)
Overrides:
buildOtherChildrenMap in class HierarchicalFilter

handleOtherRemovals

protected TNode handleOtherRemovals(java.util.Map additionsMap,
                                    TreeExplorer tree,
                                    TNode childNode)
Overrides:
handleOtherRemovals in class HierarchicalFilter

handleOtherAdditions

protected TNode handleOtherAdditions(java.util.Map additionsMap,
                                     TreeExplorer tree,
                                     TNode childNode)
Overrides:
handleOtherAdditions 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.

convertUrlToRelativeSpec

protected static java.lang.String convertUrlToRelativeSpec(java.net.URL url,
                                                           URLPath sourcePath)
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.
sourcePath - the URLPath for the sources.
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.

isNodeContainerInProject

protected boolean isNodeContainerInProject(TNode node)
Returns true if the specified TNode's Container is in the project.

Overrides:
isNodeContainerInProject in class HierarchicalFilter

Extension SDK

 

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