public class DefaultAttributes extends Object implements AbstractFileSystem.Attr, AbstractFileSystem.List
AbstractFileSystem.Attr
using a special file
in each folder for holding attributes.
It needs to hide
the file from the rest of system, so it also implements
AbstractFileSystem.List
to exclude the file from the children list
(it can then serve to filter a plain list implementation).
Description of format of special file ilustrates best DTD file that is showed in next lines:
<!ELEMENT attributes (fileobject)*>
<!ATTLIST attributes version CDATA #REQUIRED>
<!ELEMENT fileobject (attr)*>
<!ATTLIST fileobject name CDATA #REQUIRED>
<!ELEMENT attr EMPTY>
<!ATTLIST attr name CDATA #REQUIRED>
<!ATTLIST attr bytevalue CDATA #IMPLIED>
<!ATTLIST attr shortvalue CDATA #IMPLIED>
<!ATTLIST attr intvalue CDATA #IMPLIED>
<!ATTLIST attr longvalue CDATA #IMPLIED>
<!ATTLIST attr floatvalue CDATA #IMPLIED>
<!ATTLIST attr doublevalue CDATA #IMPLIED>
<!ATTLIST attr boolvalue CDATA #IMPLIED>
<!ATTLIST attr charvalue CDATA #IMPLIED>
<!ATTLIST attr stringvalue CDATA #IMPLIED>
<!ATTLIST attr methodvalue CDATA #IMPLIED>
<!ATTLIST attr serialvalue CDATA #IMPLIED>
<!ATTLIST attr urlvalue CDATA #IMPLIED>
Modifier and Type | Field and Description |
---|---|
static String |
ATTR_EXT
Deprecated.
does not handle XML attributes
|
static String |
ATTR_NAME
Deprecated.
does not handle XML attributes
|
static String |
ATTR_NAME_EXT
Deprecated.
does not handle XML attributes
|
Modifier | Constructor and Description |
---|---|
|
DefaultAttributes(AbstractFileSystem.Info info,
AbstractFileSystem.Change change,
AbstractFileSystem.List list)
Constructor.
|
protected |
DefaultAttributes(AbstractFileSystem.Info info,
AbstractFileSystem.Change change,
AbstractFileSystem.List list,
String fileName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Enumeration<String> |
attributes(String name)
Get all file attribute names for the file.
|
String[] |
children(String f)
Get the children list, filtering out the special attributes file.
|
void |
deleteAttributes(String name)
Called when a file is deleted, to also delete its attributes.
|
Object |
readAttribute(String name,
String attrName)
Get the file attribute with the specified name.
|
void |
renameAttributes(String oldName,
String newName)
Called when a file is renamed, to appropriately update its attributes.
|
void |
writeAttribute(String name,
String attrName,
Object value)
Set the file attribute with the specified name.
|
@Deprecated public static final String ATTR_NAME
@Deprecated public static final String ATTR_EXT
@Deprecated public static final String ATTR_NAME_EXT
public DefaultAttributes(AbstractFileSystem.Info info, AbstractFileSystem.Change change, AbstractFileSystem.List list)
info
- file object information to usechange
- file change hooks to uselist
- list to filter (can be null
, but then this object cannot work as a list)protected DefaultAttributes(AbstractFileSystem.Info info, AbstractFileSystem.Change change, AbstractFileSystem.List list, String fileName)
info
- file object information to usechange
- file change hooks to uselist
- list to filter (can be null
, but then this object cannot work as a list)fileName
- public String[] children(String f)
null
AbstractFileSystem.List
in the constructor for this to work. If you did not, the rest of the class will work
fine, but this method should not be called and this object should not be used
as a List
implementation.children
in interface AbstractFileSystem.List
f
- the folder, by name; e.g. top/next/afterthat
file.ext
(no path)public Object readAttribute(String name, String attrName)
AbstractFileSystem.Attr
readAttribute
in interface AbstractFileSystem.Attr
name
- the fileattrName
- name of the attributenull
if the attribute is unset (or could not be properly restored for some reason)public void writeAttribute(String name, String attrName, Object value) throws IOException
AbstractFileSystem.Attr
writeAttribute
in interface AbstractFileSystem.Attr
name
- the fileattrName
- name of the attributevalue
- new value or null
to clear the attribute. Must be serializable, although particular filesystems may or may not use serialization to store attribute values.IOException
- if the attribute cannot be set. If serialization is used to store it, this may in fact be a subclass such as NotSerializableException
.public Enumeration<String> attributes(String name)
AbstractFileSystem.Attr
attributes
in interface AbstractFileSystem.Attr
name
- the filepublic void renameAttributes(String oldName, String newName)
AbstractFileSystem.Attr
renameAttributes
in interface AbstractFileSystem.Attr
oldName
- old name of the filenewName
- new name of the filepublic void deleteAttributes(String name)
AbstractFileSystem.Attr
deleteAttributes
in interface AbstractFileSystem.Attr
name
- name of the file