public class Jets3tProperties
extends java.lang.Object
implements java.io.Serializable
Properties are initially loaded via getInstance methods from a named properties file, which must be available at the root of the classpath, or from an input stream. In either case the properties are cached according to a name, such that subsequent calls to get a properties instance with the same name will return the same properties object.
For more information about JetS3t properties please see: JetS3t Configuration
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JETS3T_PROPERTIES_ID |
Constructor and Description |
---|
Jets3tProperties() |
Modifier and Type | Method and Description |
---|---|
void |
clearAllProperties()
Clears (removes) all the property names and values used internally by
this object.
|
void |
clearProperty(java.lang.String propertyName)
Removes a property name and value.
|
boolean |
containsKey(java.lang.String propertyName) |
boolean |
getBoolProperty(java.lang.String propertyName,
boolean defaultValue) |
static Jets3tProperties |
getInstance(java.io.InputStream inputStream,
java.lang.String propertiesIdentifer)
Return a properties instance based on properties read from an input stream, and stores
the properties object in a cache referenced by the propertiesIdentifier.
|
static Jets3tProperties |
getInstance(java.lang.String propertiesFileName)
Return a properties instance based on properties read from a properties file, and stores
the properties object in a cache referenced by the properties file name.
|
int |
getIntProperty(java.lang.String propertyName,
int defaultValue) |
long |
getLongProperty(java.lang.String propertyName,
long defaultValue) |
java.util.Properties |
getProperties() |
java.lang.String |
getStringProperty(java.lang.String propertyName,
java.lang.String defaultValue) |
boolean |
isLoaded() |
void |
loadAndReplaceProperties(java.io.InputStream inputStream,
java.lang.String propertiesSource)
Reads properties from an InputStream and stores them in this class's properties object.
|
void |
loadAndReplaceProperties(Jets3tProperties properties,
java.lang.String propertiesSource)
Merges properties from another JetS3tProperties object into this instance.
|
void |
loadAndReplaceProperties(java.util.Properties newProperties,
java.lang.String propertiesSource)
Merges properties from another Properties object into this instance.
|
void |
setProperty(java.lang.String propertyName,
java.lang.String propertyValue)
Sets or removes a property value.
|
public static final java.lang.String JETS3T_PROPERTIES_ID
public static Jets3tProperties getInstance(java.io.InputStream inputStream, java.lang.String propertiesIdentifer) throws java.io.IOException
inputStream
- an input stream containing property name/value pairs in a format that can be read by
Properties.load(InputStream)
.propertiesIdentifer
- the name under which the properties are cachedjava.io.IOException
public static Jets3tProperties getInstance(java.lang.String propertiesFileName)
propertiesFileName
- the name of a properties file that exists in the root of the classpath, such that it can
be loaded with the code getClass().getResourceAsStream("/" + propertiesFileName);.public void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
propertyName
- the name of the property to set or remove.propertyValue
- a new value for the property. If this value is null, the named property
will be removed.public void clearProperty(java.lang.String propertyName)
propertyName
- the name of the property to remove.public void clearAllProperties()
loadAndReplaceProperties(Properties, String)
to directly
manage the properties encapsulated in this class.public void loadAndReplaceProperties(java.io.InputStream inputStream, java.lang.String propertiesSource) throws java.io.IOException
inputStream
- an input stream containing property name/value pairs in a format that can be read by
Properties.load(InputStream)
.propertiesSource
- a name for the source of the properties, such as a properties file name or identifier. This
is only used to generate meaningful debug messages when properties are updated, so it is
possible to tell where the updated property value came from.java.io.IOException
public void loadAndReplaceProperties(Jets3tProperties properties, java.lang.String propertiesSource)
properties
- the object containing properties that will be merged into this set of properties.propertiesSource
- a name for the source of the properties, such as a properties file name or identifier. This
is only used to generate meaningful debug messages when properties are updated, so it is
possible to tell where the updated property value came from.public void loadAndReplaceProperties(java.util.Properties newProperties, java.lang.String propertiesSource)
newProperties
- the object containing properties that will be merged into this set of properties.propertiesSource
- a name for the source of the properties, such as a properties file name or identifier. This
is only used to generate meaningful debug messages when properties are updated, so it is
possible to tell where the updated property value came from.public java.util.Properties getProperties()
public java.lang.String getStringProperty(java.lang.String propertyName, java.lang.String defaultValue)
propertyName
- the name of the property to look up.defaultValue
- value to return if named property is not set.public long getLongProperty(java.lang.String propertyName, long defaultValue) throws java.lang.NumberFormatException
propertyName
- the name of the property to look up.defaultValue
- value to return if named property is not set.java.lang.NumberFormatException
public int getIntProperty(java.lang.String propertyName, int defaultValue) throws java.lang.NumberFormatException
propertyName
- the name of the property to look up.defaultValue
- value to return if named property is not set.java.lang.NumberFormatException
public boolean getBoolProperty(java.lang.String propertyName, boolean defaultValue) throws java.lang.IllegalArgumentException
propertyName
- the name of the property to look up.defaultValue
- value to return if named property is not set.java.lang.IllegalArgumentException
public boolean containsKey(java.lang.String propertyName)
propertyName
- the property name to check for.public boolean isLoaded()