|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.claudio.pediacache.model.Cache
public class Cache
Note: Cached pages should be refreshed when the user is online. For this look for pages with lastRead much less than lastFetched.
Copyright (C) 2006 Claudio Nieder <private@claudio.ch>, CH-8610 Uster
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
| Field Summary | |
|---|---|
static java.lang.String |
httpContentType
http content-type header |
static java.lang.String |
httpLastModified
http Last-Modified header |
static java.lang.String |
httpLocation
http Location header |
static java.lang.String |
httpReferer
http Location header |
static java.lang.String |
httpUserAgent
http User-Agent header |
| Constructor Summary | |
|---|---|
Cache()
|
|
| Method Summary | |
|---|---|
static java.net.URL |
decodeURL(java.lang.String url,
java.lang.String query)
Decode a Base64 string. |
static void |
deleteAllPages()
Deletes all pages in the cache. |
static java.lang.String |
encodeURL(java.net.URL url)
Base 64 encode an URL so that it can be safely used as part of another URL |
static CachedPage |
fetchPage(java.net.URL url,
Source associatedSource,
int priority)
Get page from cache or from Internet. |
static int |
getCacheSize()
Get the number of pages in the cache. |
static long |
getDBSize()
Get the size of the database file. |
static java.util.List<CachedPage> |
getLastPages()
Retrieve the last few pages. |
static java.util.List<SearchResult> |
getLastSearches()
Retrieve the last few pages. |
static CachedPage |
getPage(java.net.URL url)
Retrieve a page from cache given the URL. |
static int |
getQueueSize()
Get the size of the queue |
static java.util.List<Source> |
getSelectedSources()
Get the sources selected by the user. |
static java.util.List<Source> |
getSourcesSorted()
Get all sources |
static int |
getTotalSize()
Get the number of pages in the cache. |
static void |
initSource()
Initialise sources. |
static void |
main(java.lang.String[] args)
Note: executing this class as main class will cause the expiry thread to be initialized and thus the JVM will not terminate. |
static void |
selectSource(java.lang.String host)
Add the source with a given host name to the preferred ones |
static void |
setUserAgent(java.lang.String userAgentArg)
Sets the user agent to use for requests. |
static void |
startPingThread()
Start a thread which scans for the selected wiki sites and maintains their online status. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String httpContentType
public static final java.lang.String httpLocation
public static final java.lang.String httpReferer
public static final java.lang.String httpLastModified
public static final java.lang.String httpUserAgent
| Constructor Detail |
|---|
public Cache()
| Method Detail |
|---|
public static void startPingThread()
public static void initSource()
public static java.util.List<Source> getSourcesSorted()
public static java.util.List<Source> getSelectedSources()
public static void selectSource(java.lang.String host)
host - host name of the sourcepublic static long getDBSize()
public static java.util.List<CachedPage> getLastPages()
public static java.util.List<SearchResult> getLastSearches()
public static CachedPage getPage(java.net.URL url)
url - page URL
public static void setUserAgent(java.lang.String userAgentArg)
userAgentArg - string
public static CachedPage fetchPage(java.net.URL url,
Source associatedSource,
int priority)
url - to getassociatedSource - Source for this URL may be nullpriority - of this request. 0 if request from user.
public static java.lang.String encodeURL(java.net.URL url)
url - to encode
public static java.net.URL decodeURL(java.lang.String url,
java.lang.String query)
throws java.io.UnsupportedEncodingException,
java.net.MalformedURLException
url - to decodequery - optional query string
java.io.UnsupportedEncodingException
java.net.MalformedURLExceptionpublic static int getQueueSize()
public static int getCacheSize()
public static int getTotalSize()
public static void deleteAllPages()
public static void main(java.lang.String[] args)
args - ignored
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||