PageMixer API - 3.1

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

java.lang.Object
  |
  +--jp.ne.dti.lares.foozy.pagemixer.page.DefaultPage
All Implemented Interfaces:
Page

public class DefaultPage
extends java.lang.Object
implements Page

Page information accessing for 'default' page.

ATTENTION:Some Servlet container implementations (at least, Tomcat 4.1.x or 5.0.x) can not handle composite suffix, like '*.ja.html' or '*.tar.gz', because matching algorithm of Servlet mapping. You should map Servlet by single suffix(like as '*.ja_html' for example) or use I18NDefaultPage for building multi locale and (web container independently)portable web application up.

This class treats the model of 'page' that:

shares same information with other pages:
this implementation contains PageEntry for multiple pages, which are identified by their own location.
has fixed (same) content type:
content type of page(s) is fixed (same) value.
has fixed (same) encoding:
encoding of InputStream is fixed (same) value.
is locale insensitive:
content of page is not locale sensitive.

For example: all '*.ja.html' pages in your web application have 'text/html; charset=Windows-31J' content, are encoded in "Windows-31J" in local file system, and have locale insensitive content.

The name 'default' comes from 'default' of custom specification by LocalePage or MonoPage.

Since:
PageMixer 3.0

Fields inherited from interface jp.ne.dti.lares.foozy.pagemixer.page.Page
DEFAULT_ENCODING
 
Constructor Summary
DefaultPage(java.lang.String contentType, java.lang.String encoding)
          Constructor.
 
Method Summary
 void close(java.lang.Object descriptor)
          Does nothing because no resource requires release.
 void expire(long limit)
          Expire old page entries.
 java.lang.String getContentType(java.lang.Object descriptor)
          Return fixed content type specified at construction time.
 java.lang.String getEncoding(java.lang.Object descriptor)
          Return fixed encoding specified at construction time.
 java.lang.String getLocation(java.lang.Object descriptor)
          Return resource location of page.
 PageEntry getPageEntry(java.lang.Object descriptor)
          Get page entry stored with location of page as key from "Map".
 java.lang.Object open(java.lang.String location, java.util.Locale locale)
          Return specified location as descriptor object.
 void putPageEntry(java.lang.Object descriptor, PageEntry entry)
          Store specified entry into "Map" with location of page as key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPage

public DefaultPage(java.lang.String contentType,
                   java.lang.String encoding)
Constructor.

"Encoding" is treated as shown below:

null
result of getCharSet(contentType)(this also may be null) is used
"default encoding"
null, which means using default encoding of runtime environment, is used
otherwise
specified encoding is used

You should specify "default encoding" explicitly, if you really want to use runtime environment default encoding.

Parameters:
contentType - of page(s)
encoding - of InputStream for page(s)
Method Detail

open

public java.lang.Object open(java.lang.String location,
                             java.util.Locale locale)
                      throws java.io.IOException
Return specified location as descriptor object.

This implementation treat 'location' as descriptor object, and ignores specified locale.

Specified by:
open in interface Page
Parameters:
location - to symbolize target page
locale - of target page
Returns:
'location' as descriptor object

close

public void close(java.lang.Object descriptor)
           throws java.io.IOException
Does nothing because no resource requires release.
Specified by:
close in interface Page
Parameters:
descriptor - of page

getLocation

public java.lang.String getLocation(java.lang.Object descriptor)
                             throws java.io.IOException
Return resource location of page.
Specified by:
getLocation in interface Page
Parameters:
descriptor - of page
Returns:
location of page as resource location

getContentType

public java.lang.String getContentType(java.lang.Object descriptor)
                                throws java.io.IOException
Return fixed content type specified at construction time.
Specified by:
getContentType in interface Page
Parameters:
descriptor - of page
Returns:
fixed value as content type of page

getEncoding

public java.lang.String getEncoding(java.lang.Object descriptor)
                             throws java.io.IOException
Return fixed encoding specified at construction time.
Specified by:
getEncoding in interface Page
Parameters:
descriptor - of page
Returns:
fixed value as encoding of InputStream to read page data in

putPageEntry

public void putPageEntry(java.lang.Object descriptor,
                         PageEntry entry)
                  throws java.io.IOException
Store specified entry into "Map" with location of page as key.
Specified by:
putPageEntry in interface Page
Parameters:
descriptor - of page
entry - to store

getPageEntry

public PageEntry getPageEntry(java.lang.Object descriptor)
                       throws java.io.IOException
Get page entry stored with location of page as key from "Map".
Specified by:
getPageEntry in interface Page
Parameters:
descriptor - of page
Returns:
entry identified by location of page

expire

public void expire(long limit)
Expire old page entries.

This expire page entries, whose last accessing timestamp is earlier than specified one, from "Map".

Specified by:
expire in interface Page
Parameters:
limit - milliseconds of last access timestamp

PageMixer API - 3.1