DataObject.FactoryMultiFileLoaderpublic abstract class DataLoader extends org.openide.util.SharedClassObject implements DataObject.Factory
FileObjects and creates appropriate
DataObjects 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.
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
DataLoader.RecognizedFiles |
Buffer holding a list of primary and secondary files marked as already recognized, to prevent further scanning.
|
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
PROP_ACTIONS |
property name of list of actions
|
static java.lang.String |
PROP_DISPLAY_NAME |
property name of display name
|
| Modifier | Constructor | Description |
|---|---|---|
protected |
DataLoader(java.lang.Class<? extends DataObject> representationClass) |
Deprecated.
Use
DataLoader(String) instead. |
protected |
DataLoader(java.lang.String representationClassName) |
Create a new data loader.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected java.lang.String |
actionsContext() |
Identifies the name of context in layer files where the
loader wishes to store its own actions and also read them.
|
protected boolean |
clearSharedData() |
|
protected org.openide.util.actions.SystemAction[] |
defaultActions() |
Deprecated.
Instead of overriding this method it is preferable to override
actionsContext(). |
protected java.lang.String |
defaultDisplayName() |
Get the default display name of this loader.
|
DataObject |
findDataObject(org.openide.filesystems.FileObject fo,
java.util.Set<? super org.openide.filesystems.FileObject> recognized) |
Find a data object appropriate to the given file object--the meat of this class.
|
DataObject |
findDataObject(org.openide.filesystems.FileObject fo,
DataLoader.RecognizedFiles recognized) |
Find a data object appropriate to the given file object--the meat of this class.
|
org.openide.util.actions.SystemAction[] |
getActions() |
Get actions.
|
java.lang.String |
getDisplayName() |
Get the current display name of this loader.
|
static <T extends DataLoader> |
getLoader(java.lang.Class<T> loaderClass) |
Get a registered loader from the pool.
|
java.lang.Class<? extends DataObject> |
getRepresentationClass() |
Get the representation class for this data loader, as passed to the constructor.
|
java.lang.String |
getRepresentationClassName() |
Get the name of the representation class for this data loader.
|
protected abstract DataObject |
handleFindDataObject(org.openide.filesystems.FileObject fo,
DataLoader.RecognizedFiles recognized) |
Find a data object appropriate to the given file object (as implemented in subclasses).
|
void |
markFile(org.openide.filesystems.FileObject fo) |
Utility method to mark a file as belonging to this loader.
|
void |
readExternal(java.io.ObjectInput oi) |
Reads actions and display name from the stream.
|
void |
setActions(org.openide.util.actions.SystemAction[] actions) |
Set actions.
|
protected void |
setDisplayName(java.lang.String displayName) |
Set the display name for this loader.
|
void |
writeExternal(java.io.ObjectOutput oo) |
Writes nothing to the stream.
|
public static final java.lang.String PROP_DISPLAY_NAME
public static final java.lang.String PROP_ACTIONS
@Deprecated protected DataLoader(java.lang.Class<? extends DataObject> representationClass)
DataLoader(String) instead.representationClass - the superclass (not necessarily) of all objects
returned from findDataObject(org.openide.filesystems.FileObject, java.util.Set<? super org.openide.filesystems.FileObject>). 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(java.lang.String representationClassName)
findDataObject(org.openide.filesystems.FileObject, java.util.Set<? super org.openide.filesystems.FileObject>).representationClassName - the name of the superclass for all objects
returned from
findDataObject(org.openide.filesystems.FileObject, java.util.Set<? super org.openide.filesystems.FileObject>). 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.public final java.lang.Class<? extends DataObject> getRepresentationClass()
public final java.lang.String getRepresentationClassName()
getRepresentationClass()public final org.openide.util.actions.SystemAction[] getActions()
null if this loader does not have any
actionsprotected java.lang.String actionsContext()
Action instance can be registered
in the context and it will be visible in the default DataNode
for data object created by this loader. Only SystemAction can however
be manipulated from DataLoader getActions/setActions methods.
The default implementation returns null to indicate that no
layer reading should be used (use defaultActions() instead).
JSeparator instances may be used to separate items.
Suggested context name: Loaders/PRIMARY-FILE/MIME-TYPE/Actions
@Deprecated protected org.openide.util.actions.SystemAction[] defaultActions()
actionsContext().public final void setActions(org.openide.util.actions.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<? extends org.openide.loaders.DataObject>)).
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 java.lang.String getDisplayName()
protected final void setDisplayName(java.lang.String displayName)
displayName - new nameprotected java.lang.String defaultDisplayName()
public final DataObject findDataObject(org.openide.filesystems.FileObject fo, java.util.Set<? super org.openide.filesystems.FileObject> recognized) throws java.io.IOException
findDataObject in interface DataObject.Factoryfo - file objectrecognized - set of already processed filesjava.io.IOExceptionDataObjectExistsException - if the data object for the
primary file already existsjava.io.InvalidClassException - if the class is not instance of
#getRepresentationClassDataLoaderpublic final DataObject findDataObject(org.openide.filesystems.FileObject fo, DataLoader.RecognizedFiles recognized) throws java.io.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 existsjava.io.IOException - if the object is recognized but cannot be createdjava.io.InvalidClassException - if the class is not instance of
getRepresentationClass()handleFindDataObject(org.openide.filesystems.FileObject, org.openide.loaders.DataLoader.RecognizedFiles)protected abstract DataObject handleFindDataObject(org.openide.filesystems.FileObject fo, DataLoader.RecognizedFiles recognized) throws java.io.IOException
fo - file object to recognizerecognized - recognized file buffernullDataObjectExistsException - as in #findDataObjectjava.io.IOException - as in #findDataObjectfindDataObject(org.openide.filesystems.FileObject, java.util.Set<? super org.openide.filesystems.FileObject>)public final void markFile(org.openide.filesystems.FileObject fo)
throws java.io.IOException
This method is used by DataObject.markFiles().
fo - file to markjava.io.IOException - if setting the file's attribute failedpublic void writeExternal(java.io.ObjectOutput oo)
throws java.io.IOException
writeExternal in class org.openide.util.SharedClassObjectoo - ignoredjava.io.IOExceptionpublic void readExternal(java.io.ObjectInput oi)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in class org.openide.util.SharedClassObjectoi - input source to read fromorg.openide.util.io.SafeException - 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 streamjava.io.IOExceptionjava.lang.ClassNotFoundExceptionprotected boolean clearSharedData()
clearSharedData in class org.openide.util.SharedClassObjectpublic static <T extends DataLoader> T getLoader(java.lang.Class<T> loaderClass)
loaderClass - exact class of the loader (not its data object representation class)null if there is no such loader registeredDataLoaderPool.allLoadersBuilt on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.