Xindice API
version 1.1

org.apache.xindice.core.request
Class URIMapper

java.lang.Object
  |
  +--java.net.URLConnection
        |
        +--org.apache.xindice.core.request.URIMapper
All Implemented Interfaces:
Poolable

public final class URIMapper
extends URLConnection
implements Poolable

URIMapper maps a URI (from whence it came) to a Xindice object. Xindice URIs can identify any of several different object types, each of which exposes a different (or slightly different) interface to the outside world.

Version:
$Revision: 511426 $, $Date: 2007-02-24 22:25:02 -0500 (Sat, 24 Feb 2007) $

Field Summary
static int APPLICATION
           
static int COLLECTION
           
static String DEFAULT_ENCODING
           
static int DOCUMENT
           
static int UNKNOWN
           
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
URIMapper()
          Constructor for older URIMapper instances
URIMapper(String uri)
          Constructor for older URIMapper instances
URIMapper(URL u)
          Constructor for creating URIMapper instance using a standard URL
 
Method Summary
 void connect()
          Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
 String[] getArguments()
          getArguments returns method arguments in the form of a String array.
 Collection getCollection()
          getCollection returns the Collection object that was resolved in the parsing of the URI.
 Container getContainer()
          getContainer returns the Document Container that was resolved in the parsing of the URI.
 String getContentEncoding()
          Returns the value of the content-encoding header field.
 int getContentLength()
          Returns the value of the content-length header field.
 String getContentType()
          Returns the value of the content-type header field.
 Database getDatabase()
          getDatabase returns the Database that was resolved in the parsing of this URI.
 org.w3c.dom.Document getDocument()
          getDocument returns the Document object that was resolved in the parsing of the URI.
 InputStream getInputStream()
          Returns an input stream that reads from this open connection.
 long getLastModified()
          Returns the value of the last-modified header field.
 String getMethod()
          getMethod returns the method name that was resolved in the parsing of the URI.
 int getObjectType()
          getObjectType returns the type of Object that was identified in the parsing of the URI.
protected  int getParsedObjectType(Collection col, String name)
          Determine the type of object.
 Properties getProperties()
          getProperties returns the Properties object that was produced in parsing the URI's Query String.
 void reclaim()
          reclaim prompts the Poolable object to return itself to the ObjectPool.
 void setPool(ObjectPool pool)
          setPool passes a reference to the originating ObjectPool for this Object.
 void setURI(String uri)
          setURI sets the URI for the URIMapper and parses it.
protected  int walkURI(Collection col, String name, int objType)
          Recursive method to handle the parse of the URI and setup the instance objects.
 
Methods inherited from class java.net.URLConnection
getAllowUserInteraction, getContent, getContent, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getIfModifiedSince, getOutputStream, getPermission, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN

APPLICATION

public static final int APPLICATION

COLLECTION

public static final int COLLECTION

DOCUMENT

public static final int DOCUMENT

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
Constructor Detail

URIMapper

public URIMapper(URL u)
Constructor for creating URIMapper instance using a standard URL

URIMapper

public URIMapper(String uri)
          throws XindiceException
Constructor for older URIMapper instances

URIMapper

public URIMapper()
Constructor for older URIMapper instances
Method Detail

connect

public void connect()
Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
Overrides:
connect in class URLConnection

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns an input stream that reads from this open connection.
Overrides:
getInputStream in class URLConnection

getContentEncoding

public String getContentEncoding()
Returns the value of the content-encoding header field.
Overrides:
getContentEncoding in class URLConnection
Returns:
the content encoding of the resource that the URL references, or null if not known.

getContentType

public String getContentType()
Returns the value of the content-type header field.
Overrides:
getContentType in class URLConnection
Returns:
the content type of the resource that the URL references, or null if not known.

getContentLength

public int getContentLength()
Returns the value of the content-length header field.
Overrides:
getContentLength in class URLConnection
Returns:
the content length of the resource that this connection's URL references, or -1 if the content length is not known.

getLastModified

public long getLastModified()
Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT.
Overrides:
getLastModified in class URLConnection
Returns:
the date the resource referenced by this URLConnection was last modified, or 0 if not known.

setPool

public void setPool(ObjectPool pool)
Description copied from interface: Poolable
setPool passes a reference to the originating ObjectPool for this Object. This will allow the Poolable Object to call back to the ObjectPool in order to be reclaimed.
Specified by:
setPool in interface Poolable
Following copied from interface: org.apache.xindice.util.Poolable
Parameters:
pool - The parent ObjectPool

reclaim

public void reclaim()
Description copied from interface: Poolable
reclaim prompts the Poolable object to return itself to the ObjectPool. A Poolable implementation should perform any necessary cleanup before calling pool.putObject to return itself to the ObjectPool.
Specified by:
reclaim in interface Poolable

setURI

public void setURI(String uri)
            throws XindiceException
setURI sets the URI for the URIMapper and parses it. The parsed components of a URI can be retrieved using getObjectType and any of the get methods.
Parameters:
uri - The URI

walkURI

protected int walkURI(Collection col,
                      String name,
                      int objType)
               throws XindiceException
Recursive method to handle the parse of the URI and setup the instance objects.

getParsedObjectType

protected int getParsedObjectType(Collection col,
                                  String name)
                           throws XindiceException
Determine the type of object. If more then one object has the same name the order of precedence is COLLECTION - XMLOBJECT - DOCUMENT

getObjectType

public int getObjectType()
getObjectType returns the type of Object that was identified in the parsing of the URI. This method will return one of the following values: UNKNOWN, APPLICATION, DATABASE, COLLECTION, DOCUMENT or XMLOBJECT.
Returns:
The object type

getDatabase

public Database getDatabase()
getDatabase returns the Database that was resolved in the parsing of this URI.
Returns:
The Database

getCollection

public Collection getCollection()
getCollection returns the Collection object that was resolved in the parsing of the URI. If no Collection was resolved, this method will return null.
Returns:
The Collection

getDocument

public org.w3c.dom.Document getDocument()
getDocument returns the Document object that was resolved in the parsing of the URI. If no Document was resolved, this method will return null.
Returns:
The Document

getContainer

public Container getContainer()
getContainer returns the Document Container that was resolved in the parsing of the URI. If no Container was resolved, this method will return null.
Returns:
The Container

getMethod

public String getMethod()
getMethod returns the method name that was resolved in the parsing of the URI. Method names are associated with XMLObjects. If no method name was resolved, this method will return null.
Returns:
The method name

getProperties

public Properties getProperties()
getProperties returns the Properties object that was produced in parsing the URI's Query String. Properties are passed into methods that are associated with XMLObjects. This method will return null if no Properties were resolved.
Returns:
The Query String Properties

getArguments

public String[] getArguments()
getArguments returns method arguments in the form of a String array. Method arguments are passed to a method in the order that they are specified in the URI. If no arguments were parsed, this method will return null.
Returns:
The method arguments

Xindice API
version 1.1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.