public final class XMLFileSystem extends AbstractFileSystem
Description of format of XML file (which can be parsed by XMLFileSystem) ================================================================== Allowed Elements: filesystem,file,folder,attr Mandatory attributes: -for filesystem version=... (e.g. "1.0") -for file,folder,attr name=.... (e.g.: <folder name="Config">) -for attr is mandatory one of bytevalue,shortvalue,intvalue,longvalue,floatvalue,doublevalue,boolvalue,charvalue,stringvalue,methodvalue,serialvalue,urlvalue,bundlevalue Allowed atributes: -for file: url=.... (e.g.: <file name="sample.xml" url="file:/c:/sample.xml">) -for folder,filesystem nothing allowed Note: file can contain content e.g.: < file name="sample.java"> < ![CDATA[ package org.sample; import java.io; ]]> < /file> But using url="..." is preferred. This class implements virtual FileSystem. It is special case of FileSystem in XML format. Description of this format best ilustrate DTD file that is showed in the following few lines: < !ELEMENT filesystem (file | folder)*> < !ATTLIST filesystem version CDATA #REQUIRED> //version not checkked yet < !ELEMENT folder (file |folder | attr)*> < !ATTLIST folder name CDATA #REQUIRED> //name of folder < !ELEMENT file (#PCDATA | attr)*> < !ATTLIST file name CDATA #REQUIRED> //name of file < !ATTLIST file url CDATA #IMPLIED> //content of the file can be find at url < !ELEMENT attr EMPTY> < !ATTLIST attr name CDATA #REQUIRED> //name of attribute < !ATTLIST attr bytevalue CDATA #IMPLIED>//the rest - types of attributes < !ATTLIST attr shortvalue CDATA #IMPLIED> < !ATTLIST attr intvalue CDATA #IMPLIED> < !ATTLIST attribute 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 newvalue CDATA #IMPLIED> < !ATTLIST attr serialvalue CDATA #IMPLIED> < !ATTLIST attr urlvalue CDATA #IMPLIED> < !ATTLIST attr bundlevalue CDATA #IMPLIED> <!-- since version 7.10 -->
The methodvalue attribute can be in form of pgk1.pkg2.ClassName.methodName
which should point to existing class with static method usually having no, one
or two arguments. This method does not need to be public or in public class, if
the filesystem has permissions to call the method. The method can take one
of the following signatures:
static Value methodName(); static Value methodName(FileObject fo); static Value methodName(FileObject fo, String attrName); static Value methodName(Mapwhereattrs); // since 7.0 static Value methodName(Map attrs, String attrName); // since 7.0
Value
can be any java type.
The newvalue should identify (using fully qualified name) a class with a no-arguments constructor. The constructor does not need to be public, just the filesystem has to have a permission to invoke it.
If you are interested just in the Class of an attribute, but
without creating its instance, use fileObject.getAttribute("class:attrName")
.
This instructs the XMLFileSystem to scan its XML files for definition of attrName
attribute and guess its class. The guessing is usually easy,
just for methodvalue
types, the system needs to use
some kind of heuristic: it locates the appropriate factory method and returns
its return type. This may not be the actual type of the returned object at the end,
but it seems as the best guess without instantiating it.
Modifier and Type | Class and Description |
---|---|
static class |
XMLFileSystem.Impl
Implementation of all interfaces List, Change, Info and Attr
that delegates to XMLFileSystem
|
AbstractFileSystem.Attr, AbstractFileSystem.Change, AbstractFileSystem.Info, AbstractFileSystem.List, AbstractFileSystem.SymlinkInfo, AbstractFileSystem.Transfer
FileSystem.AtomicAction
attr, change, info, list, transfer
PROP_DISPLAY_NAME, PROP_HIDDEN, PROP_READ_ONLY, PROP_ROOT, PROP_SYSTEM_NAME, PROP_VALID
Constructor and Description |
---|
XMLFileSystem()
Constructor.
|
XMLFileSystem(String uri)
Constructor.
|
XMLFileSystem(URL url)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addNotify()
Notifies this filesystem that it has been added to the repository.
|
protected <T extends FileObject> |
createReference(T fo)
Creates Reference.
|
String |
getDisplayName()
Provides a name for the system that can be presented to the user.
|
URL |
getXmlUrl()
Getter of url field.
|
URL[] |
getXmlUrls()
Getter of url fields.
|
boolean |
isReadOnly()
Test if the filesystem is read-only or not.
|
void |
removeNotify()
Notifies this filesystem that it has been removed from the repository.
|
void |
setXmlUrl(URL url)
Setter of url field.
|
void |
setXmlUrl(URL url,
boolean validate)
Setter of url field.
|
void |
setXmlUrls(URL[] urls)
Setter of url fields.
|
canRead, canWrite, checkVirtual, existingFileObjects, findReference, findResource, getRefreshTime, getRoot, markImportant, refresh, refreshResource, refreshRoot, setRefreshTime
addFileChangeListener, addFileStatusListener, addPropertyChangeListener, addVetoableChangeListener, createTempFile, find, findExtrasFor, fireFileStatusChanged, firePropertyChange, fireVetoableChange, getDecorator, getSystemName, getTempFolder, isDefault, isValid, removeFileChangeListener, removeFileStatusListener, removePropertyChangeListener, removeVetoableChangeListener, runAtomicAction, setSystemName, toString
public XMLFileSystem()
public XMLFileSystem(String uri) throws SAXException
uri
- to file with definition of XMLFileSystemSAXException
- if parsing is not succesfulpublic XMLFileSystem(URL url) throws SAXException
url
- to definition of XMLFileSystemSAXException
- if parsing not succesfulpublic URL getXmlUrl()
public void setXmlUrl(URL url) throws IOException, PropertyVetoException
url
- with definition of XMLFileSystemPropertyVetoException
- if the change is not allowed by a listenerIOException
- if the file is not validpublic void setXmlUrl(URL url, boolean validate) throws IOException, PropertyVetoException
url
- with definition of XMLFileSystemvalidate
- sets validating of SAXParserPropertyVetoException
- if the change is not allowed by a listenerIOException
- if the file is not validpublic URL[] getXmlUrls()
public void setXmlUrls(URL[] urls) throws IOException, PropertyVetoException
urls
- array of definitions (in xml form) of XMLFileSystemIOException
- if the file is not validPropertyVetoException
- if the change is not allowed by a listenerpublic String getDisplayName()
getDisplayName
in class AbstractFileSystem
public boolean isReadOnly()
isReadOnly
in class FileSystem
public void addNotify()
addNotify
in class FileSystem
public void removeNotify()
removeNotify
in class FileSystem
protected <T extends FileObject> Reference<T> createReference(T fo)
AbstractFileSystem
createReference
in class AbstractFileSystem
fo
- is FileObject. It`s reference yourequire to get.