JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page
Class FontFileLookup

java.lang.Object
  |
  +--com.klg.jclass.page.FontFileLookup

public class FontFileLookup
extends Object

Internal use only. Encapsulates the necessary information related to looking up a particular file. Currently supports opening files by absolute path, path relative to classpath, path relative to servlet context and full URL. Also supports the creation of resource bundles from property files specified by absolute path, path relative to classpath, path relative to servlet context, full URL and URL representing a file.


Field Summary
static int AFM_FILE
          AFM font file.
static int FILE_FULL
          File with full (absolute) path.
static int FILE_REL_CLASSPATH
          File relative to classpath.
protected  long fileLength
          Length of the file encapsulated by this object.
 int fileType
           
 URL fileURL
           
 String location
           
 int lookupType
          Type of file lookup encapsulated by this class.
static int NONE
          No type.
static int PROPERTIES_FILE
          Resource Bundle properties file.
 String propertiesFileName
           
static int TTF_FILE
          TrueType font file.
protected  com.klg.jclass.page.ttf.TTFFontNames ttfFontNames
          Stores optional TTFFontNames object containing possible names for TrueType font file.
static int URL_FILE
          URL representing a file (note: this does not have to be an URL that begins with "file:", just that the last part of the URL represents a concrete file).
static int URL_STREAM
          URL representing a the location of something that returns a byte stream, such as a servlet.
 
Constructor Summary
FontFileLookup()
          Empty constructor.
FontFileLookup(int lookupType, String location, int fileType)
          Constructor for FILE_FULL and FILE_REL_CLASSPATH lookup types for .afm and .ttf files.
FontFileLookup(int lookupType, String location, String name, int fileType)
          Constructor for FILE_FULL and FILE_REL_CLASSPATH lookup types for resource bundle .properties files.
FontFileLookup(int lookupType, URL fileURL, int fileType)
          Constructor for URL_FILE or URL_STREAM lookup types for .afm and .ttf files.
FontFileLookup(int lookupType, URL fileURL, String name, int fileType)
          Constructor for URL_FILE and URL_STREAM lookup types for resource bundle .properties files.
 
Method Summary
protected static List calculateBundleSuffixes(String baseName)
          Apply a list of potential suffixes for use in searching for resource bundles (derived from the default locale) to the passed base name.
 boolean equals(Object o)
          Test equality.
 long getFileLength()
          Get the length of the file encapsulated by this object.
 ResourceBundle getResourceBundle()
          Open a resource bundle .properties file based on the information encapsulated by this class.
 com.klg.jclass.page.ttf.TTFFontNames getTTFFontNames()
          Return optional TTFFontNames object containing possible names for TrueType file.
 InputStream openInputStream()
          Open an input stream on the file encapsulated by this class.
 void setTTFFontNames(com.klg.jclass.page.ttf.TTFFontNames ttfFontNames)
          Store optional TTFFontNames object containing possible names for TrueType file.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
No type.

See Also:
Constant Field Values

FILE_FULL

public static final int FILE_FULL
File with full (absolute) path.

See Also:
Constant Field Values

URL_FILE

public static final int URL_FILE
URL representing a file (note: this does not have to be an URL that begins with "file:", just that the last part of the URL represents a concrete file).

See Also:
Constant Field Values

URL_STREAM

public static final int URL_STREAM
URL representing a the location of something that returns a byte stream, such as a servlet.

See Also:
Constant Field Values

FILE_REL_CLASSPATH

public static final int FILE_REL_CLASSPATH
File relative to classpath.

See Also:
Constant Field Values

AFM_FILE

public static final int AFM_FILE
AFM font file.

See Also:
Constant Field Values

TTF_FILE

public static final int TTF_FILE
TrueType font file.

See Also:
Constant Field Values

PROPERTIES_FILE

public static final int PROPERTIES_FILE
Resource Bundle properties file.

See Also:
Constant Field Values

lookupType

public int lookupType
Type of file lookup encapsulated by this class. One of NONE, FILE_FULL, URL_FILE, URL_STREAM, FILE_REL_CLASSPATH or FILE_REL_SERVLET.


location

public String location

propertiesFileName

public String propertiesFileName

fileURL

public URL fileURL

fileType

public int fileType

fileLength

protected long fileLength
Length of the file encapsulated by this object. This is only set once the file has been opened. A length of -1 indicates that either the length has not yet been determined or, if the file has already been opened, that it can't be determined.


ttfFontNames

protected com.klg.jclass.page.ttf.TTFFontNames ttfFontNames
Stores optional TTFFontNames object containing possible names for TrueType font file.

Constructor Detail

FontFileLookup

public FontFileLookup()
Empty constructor. Don't use is unless you know exactly what you're doing.


FontFileLookup

public FontFileLookup(int lookupType,
                      String location,
                      int fileType)
Constructor for FILE_FULL and FILE_REL_CLASSPATH lookup types for .afm and .ttf files.

Parameters:
lookupType - one of FILE_FULL or FILE_REL_CLASSPATH.
location - if FILE_FULL, the absolute path location of the desired file; if FILE_REL_CLASSPATH, the location of the desired file relative to the classpath.
fileType - one of AFM_FILE or TTF_FILE.

FontFileLookup

public FontFileLookup(int lookupType,
                      URL fileURL,
                      int fileType)
Constructor for URL_FILE or URL_STREAM lookup types for .afm and .ttf files.

Parameters:
lookupType - URL_FILE or URL_STREAM.
fileURL - the location of the desired file specified as an URL object.
fileType - one of AFM_FILE or TTF_FILE.

FontFileLookup

public FontFileLookup(int lookupType,
                      String location,
                      String name,
                      int fileType)
Constructor for FILE_FULL and FILE_REL_CLASSPATH lookup types for resource bundle .properties files.

Parameters:
lookupType - one of FILE_FULL or FILE_REL_CLASSPATH.
location - if FILE_FULL, the absolute path location of the directory containing the .propertiues file; if FILE_REL_CLASSPATH, the location of this directory relative to the classpath.
name - the name portion of the .properties file, the bit before the locale information or .propeties extension. For example, a file called "user_en_US.properties" would have a name of "user".
fileType - PROPERTIES_FILE.

FontFileLookup

public FontFileLookup(int lookupType,
                      URL fileURL,
                      String name,
                      int fileType)
Constructor for URL_FILE and URL_STREAM lookup types for resource bundle .properties files.

Parameters:
lookupType - one of URL_FILE or URL_STREAM.
fileURL - if lookupType is URL_FILE, this is an URL specifying the directory the desired properties file will be found in. If lookupType is URL_STREAM, this is an URL specifying the exact location of an entity that returns a byte stream containing a properties file.
name - if lookupType is URL_FILE, this is the name portion of the .properties file, the bit before the locale information or .propeties extension. For example, a file called "user_en_US.properties" would have a name of "user". If lookupType is URL_STREAM, this parameter is ignored.
fileType - PROPERTIES_FILE.
Method Detail

setTTFFontNames

public void setTTFFontNames(com.klg.jclass.page.ttf.TTFFontNames ttfFontNames)
Store optional TTFFontNames object containing possible names for TrueType file.


getTTFFontNames

public com.klg.jclass.page.ttf.TTFFontNames getTTFFontNames()
Return optional TTFFontNames object containing possible names for TrueType file.


openInputStream

public InputStream openInputStream()
                            throws IOException
Open an input stream on the file encapsulated by this class. Should not be used for .properties resource bundle files.

Returns:
an open InputStream object representing the file encapsulated by this class. If the stream could not be opened, this will be null.
IOException

getFileLength

public long getFileLength()
Get the length of the file encapsulated by this object. Note: this value is only set once the file has been opened with a call to openInputStream(), and even then it may not be determinable. A length of -1 indicates that the length of the file is unknown.


getResourceBundle

public ResourceBundle getResourceBundle()
                                 throws IOException
Open a resource bundle .properties file based on the information encapsulated by this class. Unless otherwise specified, the default locale should be taken into account when deriving the .properties file name. For example, for a bundle named "user" in the North American English locale, this method would first search for a file named "user_en_US.properties", then "user_en.properties" and finally "user.properties".

Returns:
a ResourceBundle derived from the .properties file encapsulated by this class
IOException

calculateBundleSuffixes

protected static List calculateBundleSuffixes(String baseName)
Apply a list of potential suffixes for use in searching for resource bundles (derived from the default locale) to the passed base name.

Parameters:
baseName - name of resource bundle before locale information is added.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Test equality.

Overrides:
equals in class Object

Copyright © 2004 Quest Software Inc..
All rights reserved.