PageMixer API - 3.1

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

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

public class ClassLoaderLocator
extends java.lang.Object
implements Locator

Locate resource by ClassLoader.

This gets InputStream of resource by Class#getResourceAsStream, so this does not locate resoruce out of class loading domain.

You should use LocalFSLocator if you want to dynamicaly re-read target resource in, when it is modified.

Since:
PageMixer 3.0(as one in this package)
See Also:
LocalFSLocator

Constructor Summary
ClassLoaderLocator()
          Create locator to locate resoruce by ClassLoader of itself.
ClassLoaderLocator(java.lang.Class baseClass)
          Create locator to locate resoruce by ClassLoader of specified class.
 
Method Summary
 void close(java.lang.Object descriptor)
          There is nothing to do.
 java.io.InputStream getInputStream(java.lang.Object descriptor)
          Get InputStream by Class#getResourceAsStream.
 long getLastModified(java.lang.Object descriptor)
          This implementation treats all resources as modified at 0L always.
 boolean isNewerThan(java.lang.Object descriptor, long timestamp)
          This implementation treats all resources as not modified.
 java.lang.Object open(java.lang.String id)
          Returns id itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoaderLocator

public ClassLoaderLocator()
Create locator to locate resoruce by ClassLoader of itself.

This is equivalent with ClassLoaderLocator(ClassLoaderLocator.class).


ClassLoaderLocator

public ClassLoaderLocator(java.lang.Class baseClass)
Create locator to locate resoruce by ClassLoader of specified class.
Parameters:
baseClass - to get ClassLoader from
Method Detail

open

public java.lang.Object open(java.lang.String id)
Returns id itself.
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)
This implementation treats all resources as modified at 0L always.
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)
This implementation treats all resources as not modified.
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 Class#getResourceAsStream.
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