Extension SDK 10.1.2

oracle.ide.model
Class PackageFolder

java.lang.Object
  extended byoracle.ide.model.DefaultDisplayable
      extended byoracle.ide.model.DefaultElement
          extended byoracle.ide.model.DefaultFolder
              extended byoracle.ide.model.HierarchicalFolder
                  extended byoracle.ide.model.PackageFolder
All Implemented Interfaces:
Category, Copyable, Data, Displayable, DynamicPropertySet, Element, Folder, Locatable, Subject

public final class PackageFolder
extends HierarchicalFolder
implements DynamicPropertySet, Subject

The PackageFolder class encapsulates a package element managed by the PackageFilter. A package folder may correspond to more than one physical directory on the file system; each directory, however, should correspond to the same package directory. This list of directories that this package folder represents is maintained in an URLPath.

For example, if the project's source path is:

    file:/Z:/jdev/src/java;file:/Z:/jbuilder/src/java
 
and the package name is "oracle", then the package folder's URLPath would be:
    file:/Z:/jdev/src/java/oracle;file:/Z:/jbuilder/src/java/oracle
 
While the PackageFolder technically implements the Locatable interface, the URL returned by the HierarchicalFolder.getURL() method is simply the first URL along this package's URLPath. We should instead return a synthetic URL that represents this package but does not correspond to a physical directory on the file system.


Field Summary
 
Fields inherited from class oracle.ide.model.HierarchicalFolder
filter, isOpen, longName, shortName, url
 
Fields inherited from class oracle.ide.model.DefaultFolder
_children
 
Fields inherited from interface oracle.ide.addin.Subject
OBJECT_MODIFIED
 
Fields inherited from interface oracle.ide.model.Category
UNDEFINED
 
Constructor Summary
  PackageFolder()
          Default constructor.
protected PackageFolder(java.lang.Object key, PackageFilter filter)
          Protected constructor that constructs a PackageFolder given a folder key and a PackageFilter that will manage this package folder.
  PackageFolder(java.net.URL url, PackageFilter filter)
          Constructs a PackageFolder given an URL and a PackageFilter that will manage this package folder.
 
Method Summary
protected  void addToPath(java.net.URL url)
          Adds an URL to the URLPath for this package.
 void attach(Observer observer)
          Registers an observer interested in being notified when the internal state of the class implementing the Subject interface changes.
protected  void close()
           
 java.lang.Object copyTo(java.lang.Object object)
          Not really copiable.
 void detach(Observer observer)
          Unregisters an observer that is not interested anymore in being notified when the internal state of the class implementing the Subject interface changes.
 boolean equals(java.lang.Object obj)
          One PackageFolder is equal to another if their #urlPath members are identical.
 java.util.Iterator getChildren()
          Returns an Iterator over the child Element objects belonging to this folder.
 PackageFilter.PackageFactory getFactory()
           
 javax.swing.Icon getIcon()
          Returns the icon tip for this Displayable.
 java.lang.String getLongLabel()
          Returns the long label for this Displayable.
 URLPath getPath()
          Returns the URLPath that represents the list of directory URLs for this package.
 java.util.Map getProperties()
          Retrieves a map holding the property-value pairs.
 java.lang.Object getProperty(java.lang.String name)
          Retrieves the value associated with a property.
 java.lang.Object getProperty(java.lang.String name, java.lang.Object defaultValue)
          Accessor to user data saved in the project file
 java.lang.String getShortLabel()
          Returns the short label for this Displayable.
 java.lang.String getToolTipText()
          Returns the tool tip for this Displayable.
protected  void init(java.lang.String packageName)
          Initializes the PackageFolder from the package name.
protected  boolean isInProject()
          Tests whether any Element objects belonging to the project are contained by this package folder.
 boolean isStrict()
          When true indicates that this package is strict with name and children
protected  java.net.URL[] list()
          Lists the files and directories belonging to this package folder.
 void notifyObservers(java.lang.Object subject, UpdateMessage change)
          Notifies all observers that the state of the subject has changed.
protected  void reset()
           
 void setFilter(HierarchicalFilter filter)
          Set the HierarchicalFilter associated with this folder.
 void setProperties(java.util.Map properties)
          Sets the map holding the property-value pairs.
 void setProperty(java.lang.String name, java.lang.Object value)
          Accessor to user data saved in the project file
 void setStrict(boolean strict)
          Indicate whether this package is strict with name and children.
 
Methods inherited from class oracle.ide.model.HierarchicalFolder
add, canAdd, canRemove, containsChild, getCategory, getFilter, getURL, getViewAllFiles, getViewHierarchically, remove, removeAll, setURL
 
Methods inherited from class oracle.ide.model.DefaultFolder
copyToImpl, equalsImpl, mayHaveChildren, size
 
Methods inherited from class oracle.ide.model.DefaultElement
getAttributes, getData
 
Methods inherited from class oracle.ide.model.DefaultDisplayable
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.ide.model.Element
getAttributes
 
Methods inherited from interface oracle.ide.model.Data
getData
 
Methods inherited from interface oracle.ide.model.Displayable
toString
 

Constructor Detail

PackageFolder

public PackageFolder()
Default constructor. Packages created using the default constructor are assumed to be contained in a project.


PackageFolder

public PackageFolder(java.net.URL url,
                     PackageFilter filter)
Constructs a PackageFolder given an URL and a PackageFilter that will manage this package folder. The given URL represents the first entry on this package's URLPath; additional URLs can be added to the URLPath by calling the addToPath(URL) method.

Parameters:
url - the URL for this folder.
filter - the HierarchicalFilter that manages this folder.

PackageFolder

protected PackageFolder(java.lang.Object key,
                        PackageFilter filter)
Protected constructor that constructs a PackageFolder given a folder key and a PackageFilter that will manage this package folder. The given key should be created by PackageFilter.getFolderKey(URL) or PackageFilter.getParentKey(Object).

This constructor is not for general use and should only ever be called by the PackageFilter.createFolder(Object) method.

Parameters:
key - the key for this folder.
filter - the HierarchicalFilter that manages this folder.
Method Detail

getProperties

public java.util.Map getProperties()
Description copied from interface: DynamicPropertySet
Retrieves a map holding the property-value pairs.

Specified by:
getProperties in interface DynamicPropertySet

setProperties

public void setProperties(java.util.Map properties)
Description copied from interface: DynamicPropertySet
Sets the map holding the property-value pairs.

Specified by:
setProperties in interface DynamicPropertySet

getProperty

public java.lang.Object getProperty(java.lang.String name)
Description copied from interface: DynamicPropertySet
Retrieves the value associated with a property.

Specified by:
getProperty in interface DynamicPropertySet
Parameters:
name - the property key for which a value is desired. exists.
Returns:
the value of the requested property, or a null value if the property does not exist or is not set.

getProperty

public java.lang.Object getProperty(java.lang.String name,
                                    java.lang.Object defaultValue)
Accessor to user data saved in the project file

Specified by:
getProperty in interface DynamicPropertySet
Parameters:
name - the property key for which a value is desired.
defaultValue - the value to return if no value currently exists.
Returns:
the value of the requested property, or the default value if the property does not exist.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Accessor to user data saved in the project file

Specified by:
setProperty in interface DynamicPropertySet
Parameters:
name - the property key to set
value - the value to set

copyTo

public java.lang.Object copyTo(java.lang.Object object)
Not really copiable. Need to implement method because of DynamicPropertySet. Method always return null

Specified by:
copyTo in interface Copyable
Parameters:
object - 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.

attach

public void attach(Observer observer)
Description copied from interface: Subject
Registers an observer interested in being notified when the internal state of the class implementing the Subject interface changes. Implementors should do nothing when the same observer is added more than once.

Specified by:
attach in interface Subject
Parameters:
observer - the Observer interested in change notification messages.

detach

public void detach(Observer observer)
Description copied from interface: Subject
Unregisters an observer that is not interested anymore in being notified when the internal state of the class implementing the Subject interface changes. Implementors should do nothing when the same observer is removed more than once.

Specified by:
detach in interface Subject
Parameters:
observer - the Observer disinterested in change notification messages.

notifyObservers

public void notifyObservers(java.lang.Object subject,
                            UpdateMessage change)
Description copied from interface: Subject
Notifies all observers that the state of the subject has changed.

Specified by:
notifyObservers in interface Subject
Parameters:
subject - the subject whose state has changed.
change - what changed.

list

protected java.net.URL[] list()
Lists the files and directories belonging to this package folder. This implementation calls the filter to list the contents of each URL along this package's URLPath and merge them together to eliminate duplicates.

Specified by:
list in class HierarchicalFolder
Returns:
an array of URL objects naming the files and directories contained by the URLPath for this package folder; if the contents of this package folder cannot be listed, then null is returned.

isInProject

protected boolean isInProject()
Tests whether any Element objects belonging to the project are contained by this package folder.

Specified by:
isInProject in class HierarchicalFolder
Returns:
returns true if any of the URL entries along this package's URLPath contain one or more Element objects belonging to the project.

isStrict

public boolean isStrict()
When true indicates that this package is strict with name and children

Overrides:
isStrict in class HierarchicalFolder

setStrict

public void setStrict(boolean strict)
Indicate whether this package is strict with name and children.


getFactory

public PackageFilter.PackageFactory getFactory()
Returns:
the PackageFilter.PackageFactory used to create packages with the same filter as this pacakage folder.

getShortLabel

public java.lang.String getShortLabel()
Returns the short label for this Displayable. This implementation returns the full package name when in flat view, and it returns the bottom-most package name when in nested view.

Specified by:
getShortLabel in interface Displayable
Overrides:
getShortLabel in class HierarchicalFolder

getLongLabel

public java.lang.String getLongLabel()
Returns the long label for this Displayable. This implementation returns the full package name.

Specified by:
getLongLabel in interface Displayable
Overrides:
getLongLabel in class HierarchicalFolder

getToolTipText

public java.lang.String getToolTipText()
Returns the tool tip for this Displayable. This implementation returns the full package name.

Specified by:
getToolTipText in interface Displayable
Overrides:
getToolTipText in class HierarchicalFolder

getIcon

public javax.swing.Icon getIcon()
Returns the icon tip for this Displayable. This implementation returns the package icon.

Specified by:
getIcon in interface Displayable
Overrides:
getIcon in class DefaultFolder
See Also:
Displayable.getIcon()

equals

public boolean equals(java.lang.Object obj)
One PackageFolder is equal to another if their #urlPath members are identical.


setFilter

public void setFilter(HierarchicalFilter filter)
Description copied from class: HierarchicalFolder
Set the HierarchicalFilter associated with this folder. The specified filter will only be set if it has never been set.

Overrides:
setFilter in class HierarchicalFolder

getChildren

public java.util.Iterator getChildren()
Returns an Iterator over the child Element objects belonging to this folder.

Specified by:
getChildren in interface Element
Overrides:
getChildren in class HierarchicalFolder

reset

protected void reset()

close

protected void close()

init

protected void init(java.lang.String packageName)
Initializes the PackageFolder from the package name. The URLPath for the package is automatically calculated from the package name and the filter's sourcepath.


addToPath

protected void addToPath(java.net.URL url)
Adds an URL to the URLPath for this package. The URL is assumed to be contained by the source path. The URL is also assumed to correspond to the same package directory as every other URL in the #urlPath.

Parameters:
url - the URL to add to the path.

getPath

public URLPath getPath()
Returns the URLPath that represents the list of directory URLs for this package.


Extension SDK

 

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