public class HttpResource extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
HttpResource.HttpDataParams
Small parameter object that is sent to getData method, and all
methods thereafter.
|
| Modifier and Type | Field and Description |
|---|---|
String |
extension
The extension of the resource.
|
String |
fileName
The file name of the resource (includes the 'htdocs' path).
|
boolean |
isFromRoot
Is resource name is root directory address or relative the document root.
|
String |
name
The name of the resource.
|
HttpWebServer |
webServer
The web server.
|
| Constructor and Description |
|---|
HttpResource(HttpWebServer webServer,
String fileName,
String name,
String extension)
Creates a new file resource without loading it.
|
| Modifier and Type | Method and Description |
|---|---|
protected File |
createFile(String fn)
Creates the File object.
|
protected InputStream |
createInputStream()
Creates the input stream.
|
protected JarEntry |
createJarEntry(String fn)
Creates the JarEntry object.
|
byte[] |
getData(HttpSession httpSession,
HttpResource.HttpDataParams dParams)
Get the data that is transformed through parsing and modification of
the resource if the resource is an HTML document.
|
long |
getFileSize()
Gets the file size, typically used for large binary resources.
|
int |
getHitCount()
Gets the hit count of this resource.
|
long |
getLastModified()
Gets the variable that represents the time when this resource was last modified.
|
protected long |
getLength()
Gets the size of the File or JarEntry, 0 or -1 for error.
|
HttpResource.HttpDataParams |
getParamObj(boolean isInclude)
Get parameter object to getData method.
|
byte[] |
getRawData()
Gets the raw loaded data.
|
long |
getRawSize()
Gets the size of the raw data (e.g.
|
boolean |
hasDynamicData(HttpSession httpSession)
Checks if this resource could return different content for each call to getData
when the last modified time has not been changed.
|
void |
increaseHitCount()
Increases the hit count of this resource.
|
boolean |
isHandleSet()
Check if it's handle is set, i.e.
|
boolean |
isModifiedSince(Date dateValue)
Checks if resource has been modified since the given date.
|
boolean |
isUncached()
Checks if this resource is of "large" binary (byte array) type that exceeds
the block size for sending data to the client.
|
boolean |
isUnmodifiedSince(Date dateValue)
Checks if resource has not been modified since the given date.
|
protected long |
lastModified()
Gets the last modified time for the File or JarEntry, -1 for error.
|
long |
load(HttpResourceParameters httpParams)
Loads or reloads a resource if required.
|
protected byte[] |
loadFile()
Load the file into memory.
|
protected void |
loadInternal(boolean doPlaceInCache)
Loads or reloads the file.
|
protected void |
loadInternal(HttpResourceParameters httpParam)
Loads or reloads the file.
|
boolean |
reload()
Reloads a the resource if required.
|
protected boolean |
reload2()
Reloads a the resource if required.
|
void |
sendRawDataInBlocks(OutputStream out)
Sends the raw data in block size.
|
protected void |
setRawData(byte[] data)
Sets the raw data.
|
protected void |
setRawData(byte[] data,
long lastModified)
Sets the raw data.
|
public final HttpWebServer webServer
public final String name
public final String fileName
public final String extension
public boolean isFromRoot
public HttpResource(HttpWebServer webServer, String fileName, String name, String extension)
load method.public final void increaseHitCount()
public final int getHitCount()
protected File createFile(String fn)
protected JarEntry createJarEntry(String fn)
protected long lastModified()
protected long getLength()
public boolean isHandleSet()
public final long load(HttpResourceParameters httpParams) throws IOException
If a resource fails to load because it's not found, it will throw an error. The size it returns is zero if the resource is already loaded (previously or by another thread at the same time).
If the resource is reloaded because it has been changed on the file system since last load, the size returned is the difference between the first load and the new one.
IOException - if the loading of the resource fails even when it exists.FileNotFoundException - if the loading of the resource cannot be found.public boolean reload()
If the document is not loaded, nothing will happen.
No failures will occur, because (e.g.) if the file is not found anymore the first content will be used.
This is typically done for application or error documents.
protected final boolean reload2()
If the document is not loaded, nothing will happen.
No failures will occur, because (e.g.) if the file is not found anymore the first content will be used.
This is typically done for application or error documents.
protected void loadInternal(HttpResourceParameters httpParam) throws IOException
IOException - if the loading of the resource fails even when it exists.FileNotFoundException - if the loading of the resource cannot be found.protected final void loadInternal(boolean doPlaceInCache)
throws IOException
IOException - if the loading of the resource fails even when it exists.FileNotFoundException - if the loading of the resource cannot be found.protected byte[] loadFile()
throws IOException
IOException - if the loading of the resource fails even when it exists.public final long getFileSize()
public final long getRawSize()
public final byte[] getRawData()
public byte[] getData(HttpSession httpSession, HttpResource.HttpDataParams dParams)
For the HttpResource class, the raw data is returned.
public HttpResource.HttpDataParams getParamObj(boolean isInclude)
protected final void setRawData(byte[] data)
HtmlResource
if the HTML document starts with <noparse> and needs to change the raw data.protected final void setRawData(byte[] data,
long lastModified)
HtmlResource
if the HTML document starts with <noparse> and needs to change the raw data.public final boolean isUncached()
Note: This method cannot be overridden by an extending class.
protected InputStream createInputStream() throws IOException
IOException - for errors.public final void sendRawDataInBlocks(OutputStream out) throws IOException
Note: This method cannot be overridden by an extending class.
IOException - for errors.public final long getLastModified()
public final boolean isModifiedSince(Date dateValue)
public final boolean isUnmodifiedSince(Date dateValue)
public boolean hasDynamicData(HttpSession httpSession)
Phantom® and NetPhantom® are registered trademarks of Nexum Technologies SARL.
© Copyright Nexum Technologies SARL, 2011. All rights reserved.