| java.lang.Object org.openide.loaders.DataObject org.openide.loaders.MultiDataObject org.openide.loaders.InstanceDataObject
InstanceDataObject | public class InstanceDataObject extends MultiDataObject implements InstanceCookie.Of(Code) | | A data object whose only purpose is to supply InstanceCookie .
The instances are created by default instantiation; the name of the class
to instantiate is stored on disk, typically right in the file name.
This data object is generally used to configure menus and toolbars,
though it could be used in any situation requiring instances to be present in
a folder; for example, anything using
FolderInstance .
Typical instance classes are subclasses of
SystemAction to make
menu items or toolbar buttons;
javax.swing.JSeparator for a menu
separator; or
javax.swing.JToolBar.Separator for a toolbar
separator.
Use
InstanceDataObject.create and
InstanceDataObject.remove to make the objects.
Better yet, use an XML filesystem to install them declaratively.
Instance data object by default recognizes all files with .instance
suffix. Such file can have associated optional file attributes:
- instanceCreate
- instantionalized
Object (e.g. created by
methodvalue at XML filesystem)
- instanceOf
String that is tokenized at ':', ',', ';' and
whitespace boundaries. Resulting tokens represent class names that created
instance is instanceof . Utilizing it may improve performance.
(optional file attributes documented since 3.34).
author: Ian Formanek |
Field Summary | |
final static String | EA_NAME data object name cached in the attribute to prevent instance creation when
its InstanceNode is displayed. | final public static String | INSTANCE File extension for instance data objects. | final static String | SER_EXT File extension for serialized files. | final static String | XML_EXT File extension for xml settings. | final static long | serialVersionUID |
Method Summary | |
public static InstanceDataObject | create(DataFolder folder, String name, String className) Create a new InstanceDataObject in a given folder. | public static InstanceDataObject | create(DataFolder folder, String name, Class> clazz) Create a new InstanceDataObject in a given folder. | public static InstanceDataObject | create(DataFolder folder, String name, Object instance, ModuleInfo info) Create a new InstanceDataObject containing settings
in a given folder. | public static InstanceDataObject | create(DataFolder folder, String name, Object instance, ModuleInfo info, boolean create) Create a new InstanceDataObject containing settings
in a given folder. | protected Node | createNodeDelegate() | final boolean | creatorOf(Object inst) Checks whether the instance was created by this object. | protected void | dispose() | static String | escape(String text) Hex-escapes anything potentially nasty in some text. | static String | escapeAndCut(String name) | public static InstanceDataObject | find(DataFolder folder, String name, String className) Finds instance of specified name in a given folder. | public static InstanceDataObject | find(DataFolder folder, String name, Class> clazz) Finds instance of specified name in a given folder. | public T | getCookie(Class<T> clazz) | public HelpCtx | getHelpCtx() | public String | getName() | protected DataObject | handleCopy(DataFolder df) | protected DataObject | handleCreateFromTemplate(DataFolder df, String name) | protected void | handleDelete() | protected FileObject | handleRename(String name) | public Class> | instanceClass() | public Object | instanceCreate() | public String | instanceName() | public boolean | instanceOf(Class> type) Query if this instance can create object of given type. | void | notifyAttributeChanged(org.openide.filesystems.FileAttributeEvent fae) | void | notifyFileChanged(FileEvent fe) | public static boolean | remove(DataFolder folder, String name, String className) Remove an existing instance data object. | public static boolean | remove(DataFolder folder, String name, Class> clazz) Remove an existing instance data object. | final void | scheduleSave() | final void | setCustomClassLoader(ClassLoader cl) | static String | unescape(String text) Removes hex escapes and regenerates displayable Unicode. |
EA_NAME | final static String EA_NAME(Code) | | data object name cached in the attribute to prevent instance creation when
its InstanceNode is displayed.
|
INSTANCE | final public static String INSTANCE(Code) | | File extension for instance data objects.
|
SER_EXT | final static String SER_EXT(Code) | | File extension for serialized files.
|
XML_EXT | final static String XML_EXT(Code) | | File extension for xml settings.
|
serialVersionUID | final static long serialVersionUID(Code) | | generated Serialized Version UID
|
create | public static InstanceDataObject create(DataFolder folder, String name, String className) throws IOException(Code) | | Create a new InstanceDataObject in a given folder. If object with specified name already exists, it is returned.
You should specify the name if there is a chance another file of the same
instance class already exists in the folder; or just to provide a more
descriptive name, which will appear in the Explorer for example.
Note: use of XML layers to install instances is generally preferred.
Parameters: folder - the folder to create the instance data object in Parameters: name - the name to give to the object (can be null if no special name besides the class name is needed)but name cannot be empty Parameters: className - the name of the class the new object should provide an instance of (see class header for details) the newly created or existing instance data object exception: IOException - if the file cannot be created |
create | public static InstanceDataObject create(DataFolder folder, String name, Class> clazz) throws IOException(Code) | | Create a new InstanceDataObject in a given folder. If object with specified name already exists, it is returned.
You should specify the name if there is a chance another file of the same
instance class already exists in the folder; or just to provide a more
descriptive name, which will appear in the Explorer for example.
Note: use of XML layers to install instances is generally preferred.
Parameters: folder - the folder to create the instance data object in Parameters: name - the name to give to the object (can be null if no special name besides the class name is needed) Parameters: clazz - the class to create instance for (see class header for details) the newly created or existing instance data object exception: IOException - if the file cannot be created |
create | public static InstanceDataObject create(DataFolder folder, String name, Object instance, ModuleInfo info) throws IOException(Code) | | Create a new InstanceDataObject containing settings
in a given folder. If object with specified name already exists, it is returned.
If the module info is null then the origin module info
of an instance class is tried to find out.
Note: use of XML layers to install instances is generally preferred.
Parameters: folder - the folder to create the instance data object in Parameters: name - the name to give to the object (can be null if no special name besides the class name is needed)but name cannot be empty Parameters: instance - the serializable instance Parameters: info - the module info describing the settings provenance (can be null ) the newly created or existing instance data object exception: IOException - if the file cannot be created since: 1.28 |
create | public static InstanceDataObject create(DataFolder folder, String name, Object instance, ModuleInfo info, boolean create) throws IOException(Code) | | Create a new InstanceDataObject containing settings
in a given folder.
If the module info is null then the origin module info
of an instance class is tried to find out.
Note: use of XML layers to install instances is generally preferred.
Parameters: folder - the folder to create the instance data object in Parameters: name - the name to give to the object (can be null if no special name besides the class name is needed)but name cannot be empty Parameters: instance - the serializable instance Parameters: info - the module info describing the settings provenance (can be null ) Parameters: create - true - always create new file; false - store to existing file if exist the newly created or existing instance data object exception: IOException - if the file cannot be created since: 2.9 |
createNodeDelegate | protected Node createNodeDelegate()(Code) | | |
creatorOf | final boolean creatorOf(Object inst)(Code) | | Checks whether the instance was created by this object.
|
dispose | protected void dispose()(Code) | | |
escape | static String escape(String text)(Code) | | Hex-escapes anything potentially nasty in some text.
Package-private for the benefit of the test suite.
|
escapeAndCut | static String escapeAndCut(String name)(Code) | | escape a filename and map it to the name with max length MAX_FILENAME_LENGTH
See Also: issue #17186 |
find | public static InstanceDataObject find(DataFolder folder, String name, String className)(Code) | | Finds instance of specified name in a given folder.
Parameters: folder - the folder to create the instance data object in Parameters: name - the name to give to the object (can be null if no special name besides the class name is needed) Parameters: className - the name of the class the new object should provide an instance of the found instance data object or null if it does not exist |
find | public static InstanceDataObject find(DataFolder folder, String name, Class> clazz)(Code) | | Finds instance of specified name in a given folder.
Parameters: folder - the folder to create the instance data object in Parameters: name - the name to give to the object (can be null if no special name besides the class name is needed) Parameters: clazz - the class to create instance for (see class header for details) the found instance data object or null if it does not exist |
instanceOf | public boolean instanceOf(Class> type)(Code) | | Query if this instance can create object of given type.
Parameters: type - the type to create true or false |
remove | public static boolean remove(DataFolder folder, String name, String className)(Code) | | Remove an existing instance data object.
If you have the exact file name, just call
DataObject.delete ;
this method lets you delete an instance you do not have an exact record
of the file name for, based on the same information used to create it.
Note: use of XML layers to install instances is generally preferred.
Parameters: folder - the folder to remove the file from Parameters: name - the name of the instance (can be null ) Parameters: className - the name of class the object referred to (see class header for details) true if the instance was succesfully removed, false if not |
remove | public static boolean remove(DataFolder folder, String name, Class> clazz)(Code) | | Remove an existing instance data object.
If you have the exact file name, just call
DataObject.delete ;
this method lets you delete an instance you do not have an exact record
of the file name for, based on the same information used to create it.
Note: use of XML layers to install instances is generally preferred.
Parameters: folder - the folder to remove the file from Parameters: name - the name of the instance (can be null ) Parameters: clazz - the class the object referred to (see class header for details) true if the instance was succesfully removed, false if not |
scheduleSave | final void scheduleSave()(Code) | | schedule task to save the instance
|
unescape | static String unescape(String text)(Code) | | Removes hex escapes and regenerates displayable Unicode.
|
Methods inherited from org.openide.loaders.DataObject | public void addPropertyChangeListener(PropertyChangeListener l)(Code)(Java Doc) public void addVetoableChangeListener(VetoableChangeListener l)(Code)(Java Doc) final public DataObject copy(DataFolder f) throws IOException(Code)(Java Doc) final DataObject copyRename(DataFolder f, String name, String ext) throws IOException(Code)(Java Doc) final public DataObject createFromTemplate(DataFolder f) throws IOException(Code)(Java Doc) final public DataObject createFromTemplate(DataFolder f, String name) throws IOException(Code)(Java Doc) final public DataObject createFromTemplate(DataFolder f, String name, Map<String, ? extends Object> parameters) throws IOException(Code)(Java Doc) protected Node createNodeDelegate()(Code)(Java Doc) final public DataShadow createShadow(DataFolder f) throws IOException(Code)(Java Doc) final public void delete() throws IOException(Code)(Java Doc) protected void dispose()(Code)(Java Doc) public Set<FileObject> files()(Code)(Java Doc) public static DataObject find(FileObject fo) throws DataObjectNotFoundException(Code)(Java Doc) final protected void firePropertyChange(String name, Object oldValue, Object newValue)(Code)(Java Doc) final protected void fireVetoableChange(String name, Object oldValue, Object newValue) throws PropertyVetoException(Code)(Java Doc) Node getClonedNodeDelegate(DataFilter filter)(Code)(Java Doc) public T getCookie(Class<T> c)(Code)(Java Doc) protected T getCookie(DataShadow shadow, Class<T> clazz)(Code)(Java Doc) final public DataFolder getFolder()(Code)(Java Doc) abstract public HelpCtx getHelpCtx()(Code)(Java Doc) final public DataLoader getLoader()(Code)(Java Doc) public Lookup getLookup()(Code)(Java Doc) public String getName()(Code)(Java Doc) final public Node getNodeDelegate()(Code)(Java Doc) Node getNodeDelegateOrNull()(Code)(Java Doc) final public FileObject getPrimaryFile()(Code)(Java Doc) public static Registry getRegistry()(Code)(Java Doc) static String getString(String name)(Code)(Java Doc) abstract protected DataObject handleCopy(DataFolder f) throws IOException(Code)(Java Doc) protected DataObject handleCopyRename(DataFolder f, String name, String ext) throws IOException(Code)(Java Doc) abstract protected DataObject handleCreateFromTemplate(DataFolder df, String name) throws IOException(Code)(Java Doc) protected DataShadow handleCreateShadow(DataFolder f) throws IOException(Code)(Java Doc) abstract protected void handleDelete() throws IOException(Code)(Java Doc) abstract protected FileObject handleMove(DataFolder df) throws IOException(Code)(Java Doc) abstract protected FileObject handleRename(String name) throws IOException(Code)(Java Doc) abstract public boolean isCopyAllowed()(Code)(Java Doc) abstract public boolean isDeleteAllowed()(Code)(Java Doc) public boolean isModified()(Code)(Java Doc) abstract public boolean isMoveAllowed()(Code)(Java Doc) abstract public boolean isRenameAllowed()(Code)(Java Doc) public boolean isShadowAllowed()(Code)(Java Doc) final public boolean isTemplate()(Code)(Java Doc) final public boolean isValid()(Code)(Java Doc) final protected void markFiles() throws IOException(Code)(Java Doc) final void markInvalid0() throws PropertyVetoException(Code)(Java Doc) final public void move(DataFolder df) throws IOException(Code)(Java Doc) void notifyAttributeChanged(FileAttributeEvent fae)(Code)(Java Doc) void notifyFileChanged(FileEvent fe)(Code)(Java Doc) void notifyFileDataCreated(FileEvent fe)(Code)(Java Doc) void notifyFileDeleted(FileEvent fe)(Code)(Java Doc) void notifyFileRenamed(FileRenameEvent fe)(Code)(Java Doc) void recognizedByFolder()(Code)(Java Doc) public void removePropertyChangeListener(PropertyChangeListener l)(Code)(Java Doc) public void removeVetoableChangeListener(VetoableChangeListener l)(Code)(Java Doc) final public void rename(String name) throws IOException(Code)(Java Doc) public void setModified(boolean modif)(Code)(Java Doc) static boolean setTemplate(FileObject fo, boolean newTempl) throws IOException(Code)(Java Doc) final public void setTemplate(boolean newTempl) throws IOException(Code)(Java Doc) public void setValid(boolean valid) throws PropertyVetoException(Code)(Java Doc) Object synchObject()(Code)(Java Doc) protected FileLock takePrimaryFileLock() throws IOException(Code)(Java Doc) public String toString()(Code)(Java Doc) public Object writeReplace()(Code)(Java Doc)
|
|
|