01: /*
02: * Indexer.java December 2005
03: *
04: * Copyright (C) 2005, Niall Gallagher <niallg@users.sf.net>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General
16: * Public License along with this library; if not, write to the
17: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18: * Boston, MA 02111-1307 USA
19: */
20:
21: package simple.http.serve;
22:
23: import simple.util.net.Path;
24: import simple.util.net.URI;
25: import java.util.Locale;
26: import java.io.File;
27:
28: /**
29: * The <code>Indexer</code> object is used to acquire meta data for
30: * a URI target. This provides a centralized source for meta data
31: * within the server. The need to acquire information such as MIME
32: * type, locale, and various other details for a URI frequently
33: * arises. In order to provide a consistant set of details for a
34: * specific target an <code>Indexer</code> implementation is used.
35: * This helps various services and resources acauire meta data
36: * quickly by facilitating a meta data cache for a context.
37: *
38: * @author Niall Gallagher
39: *
40: * @see simple.http.serve.Index
41: */
42: interface Indexer {
43:
44: /**
45: * This is used to acquire the <code>File</code> reference
46: * for the index target. This is typically rooted at a
47: * base path, for instance the <code>Context</code> root
48: * is typically used. This allows the file to be opened,
49: * deleted, or read should the need arise in a service.
50: *
51: * @param target the index target to get the OS file for
52: *
53: * @return this returns the OS file for the resource
54: */
55: public File getFile(URI target);
56:
57: /**
58: * This is used to acquire the <code>Path</code> object that
59: * exposes various parts of the URI path. This can be used
60: * to extract the individual path segments as strings as
61: * well as the file extension and various other details.
62: *
63: * @param target the index target to get the URI path for
64: *
65: * @return this returns a path object with various details
66: */
67: public Path getPath(URI target);
68:
69: /**
70: * This gets the locale for this index object the locale is
71: * set to the <code>Locale.getDefault</code> if there is no
72: * locale information available for the index target. This
73: * will provide the <code>Context.getLocale</code> object.
74: *
75: * @param target the index target to get the locale for
76: *
77: * @return this returns the locale for this index target
78: */
79: public Locale getLocale(URI target);
80:
81: /**
82: * This allows the MIME type of this <code>Index</code> to
83: * be acquired. The MIME type of a file is retrieved by the
84: * <code>Context.getContentType</code> method for a specific
85: * request URI. This should have a value and perhaps some
86: * parameters like the charset, "text/html; charset=UTF-8".
87: *
88: * @param target the index target to get the MIME type for
89: *
90: * @return the MIME type this object has been set to
91: */
92: public String getContentType(URI target);
93: }
|