|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openide.util.SharedClassObject | +--org.openide.loaders.DataLoader
A data loader recognizes FileObject
s and creates appropriate
DataObject
s to represent them.
The created data object must be a subclass
of the representation class provided in the constructor.
Subclasses of DataLoader
should be made JavaBeans with
additional parameters, so a user may configure the loaders in the loader pool.
Inner Class Summary | |
static interface |
DataLoader.RecognizedFiles
Buffer holding a list of primary and secondary files marked as already recognized, to prevent further scanning. |
Field Summary | |
static String |
PROP_ACTIONS
property name of list of actions |
static String |
PROP_DISPLAY_NAME
property name of display name |
Constructor Summary | |
protected |
DataLoader(Class representationClass)
Create a new data loader. |
protected |
DataLoader(String representationClassName)
Create a new data loader. |
Method Summary | |
protected boolean |
clearSharedData()
Indicate whether the shared data of the last existing instance of this class should be cleared when that instance is finalized. |
protected SystemAction[] |
defaultActions()
Get default actions. |
protected String |
defaultDisplayName()
Get the default display name of this loader. |
DataObject |
findDataObject(FileObject fo,
DataLoader.RecognizedFiles recognized)
Find a data object appropriate to the given file object--the meat of this class. |
SystemAction[] |
getActions()
Get actions. |
String |
getDisplayName()
Get the current display name of this loader. |
static DataLoader |
getLoader(Class loaderClass)
Get a registered loader from the pool. |
Class |
getRepresentationClass()
|
protected abstract DataObject |
handleFindDataObject(FileObject fo,
DataLoader.RecognizedFiles recognized)
Find a data object appropriate to the given file object (as implemented in subclasses). |
void |
markFile(FileObject fo)
Utility method to mark a file as belonging to this loader. |
void |
readExternal(ObjectInput oi)
Reads actions and display name from the stream. |
void |
setActions(SystemAction[] actions)
Set actions. |
protected void |
setDisplayName(String displayName)
Set the display name for this loader. |
void |
writeExternal(ObjectOutput oo)
Writes nothing to the stream. |
Methods inherited from class org.openide.util.SharedClassObject |
addNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, initialize, putProperty, putProperty, removeNotify, removePropertyChangeListener, writeReplace |
Methods inherited from class java.lang.Object |
clone, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String PROP_DISPLAY_NAME
public static final String PROP_ACTIONS
Constructor Detail |
protected DataLoader(Class representationClass)
representationClass
- the superclass (not necessarily) of all objects
returned from findDataObject(org.openide.filesystems.FileObject, org.openide.loaders.DataLoader.RecognizedFiles)
. The class may be anything but
should be chosen to be as close as possible to the actual class of objects returned from the loader,
to best identify the loader's data objects to listeners.protected DataLoader(String representationClassName)
findDataObject(org.openide.filesystems.FileObject, org.openide.loaders.DataLoader.RecognizedFiles)
.representationClassName
- the name of the superclass for all objects
returned from
findDataObject(org.openide.filesystems.FileObject, org.openide.loaders.DataLoader.RecognizedFiles)
. The class may be anything but
should be chosen to be as close as possible to the actual class of objects returned from the loader,
to best identify the loader's data objects to listeners.Method Detail |
public final Class getRepresentationClass()
public final SystemAction[] getActions()
null
if this loader does not have any
actionsprotected SystemAction[] defaultActions()
null
if this loader
does not have any actions.
Typical example of usage:
return new SystemAction[] { SystemAction.get (OpenAction.class), ... SystemAction.get (PropertiesAction.class) };
public final void setActions(SystemAction[] actions)
Note that this method is public, not protected, so it is possible for anyone
to modify the loader's popup actions externally (after finding the loader
using DataLoaderPool.firstProducerOf(java.lang.Class)
).
While this is possible, anyone doing so must take care to place new actions
into sensible positions, including consideration of separators.
This may also adversely affect the intended feel of the data objects.
A preferable solution is generally to use service actions
.
actions
- actions for this loader or null
if it should not have anygetActions()
public final String getDisplayName()
protected final void setDisplayName(String displayName)
displayName
- new nameprotected String defaultDisplayName()
public final DataObject findDataObject(FileObject fo, DataLoader.RecognizedFiles recognized) throws IOException
For example: for files with the same basename but extensions .java and .class, the handler
should return the same DataObject
.
The loader can add all files it has recognized into the recognized
buffer. Then all these files will be excluded from further processing.
fo
- file object to recognizerecognized
- recognized file buffernull
if the handler cannot
recognize this object (or its group)DataObjectExistsException
- if the data object for the
primary file already existsIOException
- if the object is recognized but cannot be createdInvalidClassException
- if the class is not instance of
getRepresentationClass()
handleFindDataObject(org.openide.filesystems.FileObject, org.openide.loaders.DataLoader.RecognizedFiles)
protected abstract DataObject handleFindDataObject(FileObject fo, DataLoader.RecognizedFiles recognized) throws IOException
fo
- file object to recognizerecognized
- recognized file buffernull
DataObjectExistsException
- as in #findDataObject
IOException
- as in #findDataObject
findDataObject(org.openide.filesystems.FileObject, org.openide.loaders.DataLoader.RecognizedFiles)
public final void markFile(FileObject fo) throws IOException
This method is used by DataObject.markFiles()
.
fo
- file to markIOException
- if setting the file's attribute failedpublic void writeExternal(ObjectOutput oo) throws IOException
writeExternal
in class SharedClassObject
oo
- ignoredpublic void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException
readExternal
in class SharedClassObject
oi
- input source to read fromSafeException
- if some of the actions is not found in the
stream, but all the content has been read ok. Subclasses can
catch this exception and continue reading from the streamprotected boolean clearSharedData()
SharedClassObject
SharedClassObject.finalize()
.
The default implementation returns true
.
Classes which have precious shared data may want to return false
, so that
all instances may be finalized, after which new instances will pick up the same shared variables
without requiring a recalculation.
clearSharedData
in class SharedClassObject
org.openide.util.SharedClassObject
true
if all shared data should be cleared,
false
if it should stay in memorypublic static DataLoader getLoader(Class loaderClass)
loaderClass
- exact class of the loader (not its data object representation class)null
if there is no such loader registeredDataLoaderPool.allLoaders()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |