public class Directory extends Finder
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 and Description |
---|
Directory(Context context,
Reference rootLocalReference)
Constructor.
|
Directory(Context context,
java.lang.String rootUri)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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 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 |
setComparator(java.util.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(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 |
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.
|
java.lang.String |
toString() |
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.
|
create, create, createFinder, find, getTargetClass, setTargetClass
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner, start, stop
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. public java.util.Comparator<Reference> getComparator()
AlphaNumericComparator
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 void handle(Request request, Response response)
Finder
public boolean isDeeplyAccessible()
public boolean isListingAllowed()
public boolean isModifiable()
public boolean isNegotiatingContent()
public void setComparator(java.util.Comparator<Reference> comparator)
comparator
- The reference comparator.public void setDeeplyAccessible(boolean deeplyAccessible)
deeplyAccessible
- True if the sub-directories 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 setNegotiatingContent(boolean negotiatingContent)
negotiatingContent
- True if the best content is automatically negotiated.public void setRootRef(Reference rootRef)
rootRef
- The root URI.public void useAlphaComparator()
setComparator(Comparator)
public void useAlphaNumComparator()
Copyright © 2005-2024 Restlet.