|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Finder
org.restlet.Directory
public class Directory
Finder mapping a directory of local resources. Those resources have
representations accessed by the file system or the class loaders.
An automatic content negotiation mechanism (similar to the one in Apache HTTP
server) is used to select the best representation of a resource based on the
available variants and on the client capabilities and preferences.
The directory can be used in read-only or modifiable mode. In the latter
case, you just need to set the "modifiable" property to true. The currently
supported methods are PUT and DELETE.
When no index is available in a given directory, a representation can be
automatically generated by the
getIndexRepresentation(Variant, ReferenceList)
method, unless the
"listingAllowed" property is turned off. You can even customize the way the
index entries are sorted by using the setComparator(Comparator)
method. The default sorting uses the friendly Alphanum algorithm based on
David Koelle's original
idea, using a different and faster implementation contributed by Rob
Heittman.
Concurrency note: instances of this class or its subclasses can be invoked by
several threads at the same time and therefore must be thread-safe. You
should be especially careful when storing state in member variables.
Constructor Summary | |
---|---|
Directory(Context context,
Reference rootLocalReference)
Constructor. |
|
Directory(Context context,
java.lang.String rootUri)
Constructor. |
Method Summary | |
---|---|
Handler |
findTarget(Request request,
Response response)
Finds the target handler if available. |
java.util.Comparator<Reference> |
getComparator()
Returns the reference comparator used to sort index pages. |
java.lang.String |
getIndexName()
Returns the index name, without extensions. |
Representation |
getIndexRepresentation(Variant variant,
ReferenceList indexContent)
Returns an actual index representation for a given variant. |
java.util.List<Variant> |
getIndexVariants(ReferenceList indexContent)
Returns the variant representations of a directory index. |
Reference |
getRootRef()
Returns the root URI from which the relative resource URIs will be lookep up. |
boolean |
isDeeplyAccessible()
Indicates if the subdirectories are deeply accessible (true by default). |
boolean |
isListingAllowed()
Indicates if the display of directory listings is allowed when no index file is found. |
boolean |
isModifiable()
Indicates if modifications to local resources (most likely files) are allowed. |
boolean |
isNegotiateContent()
Indicates if the best content is automatically negotiated. |
void |
setAlphaComparator()
Sets the reference comparator based on classic alphabetical order. |
void |
setAlphaNumComparator()
Sets the reference comparator based on the more friendly "Alphanum Algorithm" created by David Koelle. |
void |
setComparator(java.util.Comparator<Reference> comparator)
Sets the reference comparator used to sort index pages. |
void |
setDeeplyAccessible(boolean deeplyAccessible)
Indicates if the subdirectories are deeply accessible (true by default). |
void |
setIndexName(java.lang.String indexName)
Sets the index name, without extensions. |
void |
setListingAllowed(boolean listingAllowed)
Indicates if the display of directory listings is allowed when no index file is found. |
void |
setModifiable(boolean modifiable)
Indicates if modifications to local resources are allowed. |
void |
setNegotiateContent(boolean negotiateContent)
Indicates if the best content is automatically negotiated. |
void |
setRootRef(Reference rootRef)
Sets the root URI from which the relative resource URIs will be lookep up. |
Methods inherited from class org.restlet.Finder |
---|
createResource, createTarget, createTarget, getTargetClass, handle, setTargetClass |
Methods inherited from class org.restlet.Restlet |
---|
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext, start, stop |
Methods inherited from class org.restlet.Uniform |
---|
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Directory(Context context, Reference rootLocalReference)
context
- The context.rootLocalReference
- The root URI.public Directory(Context context, java.lang.String rootUri)
context
- The context.rootUri
- The absolute root URI. Method Detail |
---|
public Handler findTarget(Request request, Response response)
findTarget
in class Finder
request
- The request to filter.response
- The response to filter.
public java.util.Comparator<Reference> getComparator()
setAlphaNumComparator()
public java.lang.String getIndexName()
public Representation getIndexRepresentation(Variant variant, ReferenceList indexContent)
variant
- The selected variant.indexContent
- The directory index to represent.
public java.util.List<Variant> getIndexVariants(ReferenceList indexContent)
indexContent
- The list of references contained in the directory index.
public Reference getRootRef()
public boolean isDeeplyAccessible()
public boolean isListingAllowed()
public boolean isModifiable()
public boolean isNegotiateContent()
public void setAlphaComparator()
setComparator(Comparator)
public void setAlphaNumComparator()
setComparator(Comparator)
public void setComparator(java.util.Comparator<Reference> comparator)
comparator
- The reference comparator.public void setDeeplyAccessible(boolean deeplyAccessible)
deeplyAccessible
- True if the subdirectories are deeply accessible.public void setIndexName(java.lang.String indexName)
indexName
- The index name.public void setListingAllowed(boolean listingAllowed)
listingAllowed
- True if the display of directory listings is allowed when no
index file is found.public void setModifiable(boolean modifiable)
modifiable
- True if modifications to local resources are allowed.public void setNegotiateContent(boolean negotiateContent)
negotiateContent
- True if the best content is automatically negotiated.public void setRootRef(Reference rootRef)
rootRef
- The root URI.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |