|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.components.modules.input.AbstractInputModule org.apache.cocoon.components.modules.input.LocateResource
public class LocateResource
Locate a resource in a resource tree. Any attribute name is interpreted as a URI with the last part being the resource name unless it ends with a slash. The URI is checked if the resource exists and the URI is returned. If the resource does not exist, the URI is shortened until the resource name is found and the new URI is returned. If no resource with the given name exists, null is returned.
A use case is to locate the closest menu file or when moving a site from a filesystem path == URL system from a httpd to Cocoon and provide similar functions to .htaccess files.
Example: for context:/some/path/to/a/file.xml the following URIs are tested: context:/some/path/to/a/file.xml, context:/some/path/to/file.xml, context:/some/path/file.xml, context:/some/file.xml, and context:/file.xml. For the attribute name context:/some/path/foo/ tests context:/some/path/foo/, context:/some/path/, context:/some/, and context:/ are tested.
The getAttribute() method will return the URI for the first match while getAttributeValues() will return an array of all existing paths. getAttributeNames() will return an Iterator to an empty collection.
Field Summary | |
---|---|
protected static Collection |
col
|
protected ComponentManager |
manager
|
Fields inherited from class org.apache.cocoon.components.modules.input.AbstractInputModule |
---|
settings |
Fields inherited from interface org.apache.cocoon.components.modules.input.InputModule |
---|
ROLE |
Constructor Summary | |
---|---|
LocateResource()
|
Method Summary | |
---|---|
protected int |
calculateMinLen(String name)
Calculate the minimal length of the URL, that is the position of the first ":" if a protocol is provided or otherwise 0. |
void |
compose(ComponentManager manager)
Set the current ComponentManager instance used by this
Composable . |
protected String |
extractFilename(String urlstring)
if the url does not end with a "/", keep the last part in order to add it later again after traversing up |
Object |
getAttribute(String name,
Configuration modeConf,
Map objectModel)
Standard access to an attribute's value. |
Iterator |
getAttributeNames(Configuration modeConf,
Map objectModel)
Returns an Iterator of String objects containing the names of the attributes available. |
Object[] |
getAttributeValues(String name,
Configuration modeConf,
Map objectModel)
Returns an array of String objects containing all of the values the given attribute has, or null if the attribute does not exist. |
protected String |
locateResource(String urlstring,
String filename,
int minLen)
Locate a resource with the given URL consisting of urlstring + filename. |
protected String |
shortenURI(String urlstring,
int minLen)
Remove one path element from the URL unless minimum length has been reached. |
Methods inherited from class org.apache.cocoon.components.modules.input.AbstractInputModule |
---|
configure, dispose |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Collection col
protected ComponentManager manager
Constructor Detail |
---|
public LocateResource()
Method Detail |
---|
protected int calculateMinLen(String name)
name
-
protected String shortenURI(String urlstring, int minLen)
urlstring
- minLen
-
protected String extractFilename(String urlstring)
protected String locateResource(String urlstring, String filename, int minLen)
urlstring
- filename
- minLen
-
null
otherwisepublic void compose(ComponentManager manager) throws ComponentException
ComponentManager
instance used by this
Composable
.
compose
in interface Composable
ComponentException
public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException
InputModule
InputModule.getAttributeValues(String, Configuration, Map)
or
InputModule.getAttributeNames(Configuration, Map)
and
InputModule.getAttribute(String, Configuration, Map)
to get them one by one.
getAttribute
in interface InputModule
getAttribute
in class AbstractInputModule
name
- a String that specifies what the caller thinks
would identify an attribute. This is mainly a fallback if no
modeConf is present.modeConf
- column's mode configuration from resource
description. This argument is optional.
ConfigurationException
public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException
InputModule
getAttributeNames
in interface InputModule
getAttributeNames
in class AbstractInputModule
modeConf
- column's mode configuration from resource
description. This argument is optional.
ConfigurationException
public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException
InputModule
InputModule.getAttributeNames(Configuration, Map)
together with
InputModule.getAttribute(String, Configuration, Map)
can be used to get the
values one by one.
getAttributeValues
in interface InputModule
getAttributeValues
in class AbstractInputModule
name
- a String that specifies what the caller thinks
would identify an attributes. This is mainly a fallback
if no modeConf is present.modeConf
- column's mode configuration from resource
description. This argument is optional.
ConfigurationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |