FileDocCategorySizeDatePackage
PropertiesStringSource.javaAPI DocGlassfish v2 API6097Fri May 04 22:34:10 BST 2007com.sun.enterprise.admin.util

PropertiesStringSource

public class PropertiesStringSource extends Object implements IStringSource
This class implements IStringSource for the case where the Strings are kept in a properties file. The file is read when instantiated and cached for later usage. There are numerous ways to specify a Properties file:

Filename
File Object
Properties Object
see
IStringSource

Fields Summary
private Properties
mProperties
Constructors Summary
public PropertiesStringSource(Properties p)
Create an instance from an existing Properties object

param
p A Properties object to use as the source of Strings

        initialize(p);
    
public PropertiesStringSource(InputStream is)

        initialize(is);
    
public PropertiesStringSource(File f)
Create an instance from a Properties file.

param
f The File object.
throws
IOException The file probably doesn't exist.

        initialize(f);
    
public PropertiesStringSource(String filename)
Create an instance from the named Properties file

param
filename The name of the Properties file
throws
IOException The file probably doesn't exist

        initialize(filename);
    
protected PropertiesStringSource()
Do-nothing constructor. This is protected so that derived classes can start with an empty instance -- and then call initialize() methods in a do-it-yourself fashion

		/** This is protected so that derived classes can start with an
		 * empty instance -- and then call initialize() methods in a do-it-yourself
		 * fashion
		 */
	
Methods Summary
public java.lang.StringgetString(java.lang.String key)
Get a string referenced by the designated key.

param
key the key to lookup the string
return
the string, or null if string cannot be found

		Assert.assertit((mProperties!=null), "invalid state:  mProperties is null");
		
		//ArgChecker.check(key, "key");
		
		return mProperties.getProperty(key);
	
protected voidinitialize(java.io.InputStream is)
Load the Properties object from a file.

param
filename The name of the Properties file

		//ArgChecker.check(filename, "filename");
		mProperties = new Properties();
		mProperties.load(is);
    
protected voidinitialize(java.util.Properties properties)
Use the Properties arguments as the source of Strings

param
p A Properties object to use as the source of Strings

        //ArgChecker.check(properties, "properties");
        mProperties = properties;
    
protected voidinitialize(java.io.File file)
Load the Properties object from a file.

param
f The File object
throws
IOException The file probably doesn't exist

        //ArgChecker.check(file != null && file.exists(), 
		//	"File object doesn't point to an existing file: " + file.getPath());

		//ArgChecker.check(file.canRead(), 
		//	"File object can't be read: " + file.getPath());
		
		//ArgChecker.check(!file.isDirectory(), 
		//	"File object is a directory: " + file.getPath());
        FileInputStream fis = new FileInputStream(file);
        initialize(fis);
    
protected voidinitialize(java.lang.String filename)
Load the Properties object from a file.

param
filename The name of the Properties file

		//ArgChecker.check(filename, "filename");
        initialize(new File(filename));