|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Restlet
org.restlet.resource.Finder
org.restlet.resource.Directory
public class Directory
Finder mapping a directory of local resources. Those resources have
representations accessed by the file system, the class loaders or other URI
accessible protocols. Here is some sample code illustrating how to attach a
directory to a router:
Directory directory = new Directory(getContext(), "file:///user/data/files/"); Router router = new Router(getContext()); router.attach("/static/", directory);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.
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.
Constructor Summary | |
---|---|
Directory(Context context,
Reference rootLocalReference)
Constructor. |
|
Directory(Context context,
String rootUri)
Constructor. |
Method Summary | |
---|---|
Comparator<Reference> |
getComparator()
Returns the reference comparator used to sort index pages. |
String |
getIndexName()
Returns the index name, without extensions. |
Representation |
getIndexRepresentation(Variant variant,
ReferenceList indexContent)
Returns an actual index representation for a given variant. |
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 looked up. |
void |
handle(Request request,
Response response)
Handles a call. |
boolean |
isDeeplyAccessible()
Indicates if the sub-directories 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 |
isNegotiatingContent()
Indicates if the best content is automatically negotiated. |
void |
setAlphaComparator()
Deprecated. Call useAlphaComparator() instead |
void |
setAlphaNumComparator()
Deprecated. Call useAlphaComparator() instead |
void |
setComparator(Comparator<Reference> comparator)
Sets the reference comparator used to sort index pages. |
void |
setDeeplyAccessible(boolean deeplyAccessible)
Indicates if the sub-directories are deeply accessible (true by default). |
void |
setIndexName(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 |
setNegotiatingContent(boolean negotiatingContent)
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. |
void |
useAlphaComparator()
Sets the reference comparator based on classic alphabetical order. |
void |
useAlphaNumComparator()
Sets the reference comparator based on the more friendly "Alphanum Algorithm" created by David Koelle. |
Methods inherited from class org.restlet.resource.Finder |
---|
create, create, createFinder, find, getTargetClass, setTargetClass, toString |
Methods inherited from class org.restlet.Restlet |
---|
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Directory(Context context, Reference rootLocalReference)
context
- The context.rootLocalReference
- The root URI.public Directory(Context context, String rootUri)
context
- The context.rootUri
- The absolute root URI. Method Detail |
---|
public Comparator<Reference> getComparator()
setAlphaNumComparator()
public String getIndexName()
public Representation getIndexRepresentation(Variant variant, ReferenceList indexContent)
variant
- The selected variant.indexContent
- The directory index to represent.
public List<Variant> getIndexVariants(ReferenceList indexContent)
indexContent
- The list of references contained in the directory index.
public Reference getRootRef()
public void handle(Request request, Response response)
Finder
handle
in interface Uniform
handle
in class Finder
request
- The request to handle.response
- The response to update.public boolean isDeeplyAccessible()
public boolean isListingAllowed()
public boolean isModifiable()
public boolean isNegotiatingContent()
@Deprecated public void setAlphaComparator()
useAlphaComparator()
instead
setComparator(Comparator)
@Deprecated public void setAlphaNumComparator()
useAlphaComparator()
instead
setComparator(Comparator)
public void useAlphaComparator()
setComparator(Comparator)
public void useAlphaNumComparator()
setComparator(Comparator)
public void setComparator(Comparator<Reference> comparator)
comparator
- The reference comparator.public void setDeeplyAccessible(boolean deeplyAccessible)
deeplyAccessible
- True if the sub-directories are deeply accessible.public void setIndexName(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 setNegotiatingContent(boolean negotiatingContent)
negotiatingContent
- 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 |