001: /*
002: * Index.java December 2005
003: *
004: * Copyright (C) 2005, Niall Gallagher <niallg@users.sf.net>
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: * GNU Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General
016: * Public License along with this library; if not, write to the
017: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
018: * Boston, MA 02111-1307 USA
019: */
020:
021: package simple.http.serve;
022:
023: import simple.util.net.Path;
024: import java.util.Locale;
025: import java.io.File;
026:
027: /**
028: * The <code>Index</code> object is used to represent the properties
029: * a URI can contain. This is used so that properties relating to a
030: * file can be quickly extracted from an <code>Indexer</code>. This
031: * will contain all necessary meta data for a file or resource. With
032: * this the <code>File</code> reference to a resource as well as the
033: * locale, MIME type, name and other such data can be accessed.
034: *
035: * @author Niall Gallagher
036: *
037: * @see simple.http.serve.Indexer
038: */
039: public interface Index {
040:
041: /**
042: * This allows the name for this object to be acquired. The
043: * name usually refers to the last entry in the path. So if
044: * the index target path was "/usr/bin/" the name is "bin".
045: *
046: * @return this returns the name of this index target
047: */
048: public String getName();
049:
050: /**
051: * This allows the MIME type of this <code>Index</code> to
052: * be acquired. The MIME type of a file is retrieved by the
053: * <code>Context.getContentType</code> method for a specific
054: * request URI. This should have a value and perhaps some
055: * parameters like the charset, "text/html; charset=UTF-8".
056: *
057: * @return the MIME type this object has been set to
058: */
059: public String getContentType();
060:
061: /**
062: * This gets the locale for this index object the locale is
063: * set to the <code>Locale.getDefault</code> if there is no
064: * locale information available for the index target. This
065: * will provide the <code>Context.getLocale</code> object.
066: *
067: * @return this returns the locale for this index target
068: */
069: public Locale getLocale();
070:
071: /**
072: * This is used to get the path that this object refers to.
073: * This should be the fully qualified normalized path. This
074: * refers to the OS system specific path that this represents.
075: *
076: * @return this returns the OS specific path for the target
077: */
078: public String getRealPath();
079:
080: /**
081: * This is used to acquire the normalized URI style path for
082: * the index target. This allows the path to be used within
083: * the <code>Mapper</code> and other such objects that need
084: * a normalized URI style path to resolve resources.
085: *
086: * @return this returns the normalized path for the target
087: */
088: public String getRequestPath();
089:
090: /**
091: * This is used to acquire the <code>File</code> directory
092: * for the index target. This is typically rooted at a
093: * base path, for instance the <code>Context</code> root
094: * is typically used. This allows resources within the
095: * same directory to be acquired easily.
096: *
097: * @return this returns the OS file for the directory
098: */
099: public File getDirectory();
100:
101: /**
102: * This is used to acquire the <code>File</code> reference
103: * for the index target. This is typically rooted at a
104: * base path, for instance the <code>Context</code> root
105: * is typically used. This allows the file to be opened,
106: * deleted, or read should the need arise in a service.
107: *
108: * @return this returns the OS file for the resource
109: */
110: public File getFile();
111:
112: /**
113: * This is used to acquire the <code>Path</code> object that
114: * exposes various parts of the URI path. This can be used
115: * to extract the individual path segments as strings as
116: * well as the file extension and various other details.
117: *
118: * @return this returns a path object with various details
119: */
120: public Path getPath();
121: }
|