PageMixer API - 3.1

jp.ne.dti.lares.foozy.pagemixer.page
Class LocalFSLocator

java.lang.Object
  |
  +--jp.ne.dti.lares.foozy.pagemixer.page.LocalFSLocator
All Implemented Interfaces:
Locator
Direct Known Subclasses:
WebAppLocator

public class LocalFSLocator
extends java.lang.Object
implements Locator

Locate resource on local file system.

This gets InputStream of resource from local file system.

This uses File#lastModified to get and examine timestamp of resource, so this gives you chance to decide whether re-read it or not, if it is modified after last your reading in.

You should use ClassLoaderLocator if you want to use resource included in JAR file.

Since:
PageMixer 3.0(as one in this package)

Constructor Summary
LocalFSLocator()
          Create locator to locate resource current directory relatively.
LocalFSLocator(java.lang.String basePath)
          Create locator to locate resource specified directory relatively.
 
Method Summary
 void close(java.lang.Object descriptor)
          There is nothing to do.
 java.io.InputStream getInputStream(java.lang.Object descriptor)
          Get InputStream by creating FileInputStream.
 long getLastModified(java.lang.Object descriptor)
          Get last modified timestamp by File#lastModified.
 boolean isNewerThan(java.lang.Object descriptor, long timestamp)
          Examine with File#lastModified.
 java.lang.Object open(java.lang.String id)
          Returns File object corresponded to given id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalFSLocator

public LocalFSLocator()
Create locator to locate resource current directory relatively.

This is equivalent with LocalFSLocator(".").


LocalFSLocator

public LocalFSLocator(java.lang.String basePath)
Create locator to locate resource specified directory relatively.
Parameters:
basePath -  
Method Detail

open

public java.lang.Object open(java.lang.String id)
Returns File object corresponded to given id.
Specified by:
open in interface Locator
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.page.Locator
Parameters:
id - to identify resource
Returns:
descriptor(must not null) ,implementation specific
Throws:
java.io.IOException - fail to create descriptor

close

public void close(java.lang.Object descriptor)
There is nothing to do.
Specified by:
close in interface Locator
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.page.Locator
Parameters:
descriptor - for resource
Returns:
descriptor ,implementation specific
Throws:
java.io.IOException - fail to discard descriptor

getLastModified

public long getLastModified(java.lang.Object descriptor)
Get last modified timestamp by File#lastModified.
Specified by:
getLastModified in interface Locator
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.page.Locator
Parameters:
descriptor - ,implementation specific
Returns:
last modified timestamp of resource
Throws:
java.io.IOException - fail to get last modified timestamp

isNewerThan

public boolean isNewerThan(java.lang.Object descriptor,
                           long timestamp)
Examine with File#lastModified.
Specified by:
isNewerThan in interface Locator
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.page.Locator
Parameters:
descriptor - ,implementation specific
Returns:
true if current resource is newer than one at given timestamp
Throws:
java.io.IOException - fail to compare

getInputStream

public java.io.InputStream getInputStream(java.lang.Object descriptor)
                                   throws java.io.IOException
Get InputStream by creating FileInputStream.
Specified by:
getInputStream in interface Locator
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.page.Locator
Parameters:
descriptor - ,implementation specific
Returns:
stream to input specified resource
Throws:
java.io.IOException - fail to create stream

PageMixer API - 3.1