public class PropertyFile
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected class |
PropertyFile.BlankLine |
protected class |
PropertyFile.Comment |
protected class |
PropertyFile.Entry |
protected class |
PropertyFile.NameValuePair |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
caseSensitive |
protected boolean |
dirty |
protected java.util.List<PropertyFile.Entry> |
entries |
protected java.io.File |
f |
protected boolean |
forceNameValueDelimiterWhitespace |
protected boolean |
readOnly |
protected java.util.Map<java.lang.String,PropertyFile.NameValuePair> |
vars |
| Constructor and Description |
|---|
PropertyFile() |
PropertyFile(java.io.File fileName) |
PropertyFile(java.io.File fileName,
boolean caseSensitive) |
PropertyFile(java.io.InputStream is) |
PropertyFile(java.io.InputStream is,
boolean caseSensitive) |
PropertyFile(java.util.Properties p) |
PropertyFile(java.util.Properties p,
boolean caseSensitive) |
PropertyFile(java.io.Reader r) |
PropertyFile(java.io.Reader r,
boolean caseSensitive) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_clear() |
protected boolean |
_contains(java.lang.String name) |
protected java.lang.String |
_get_core(java.lang.String name,
java.lang.String defaultValue) |
protected java.lang.String |
_get(java.lang.String name,
java.lang.String defaultValue) |
protected void |
_rm(java.lang.String name) |
protected java.lang.String |
_set(java.lang.String name,
java.lang.String value) |
void |
clear() |
boolean |
containsKey(java.lang.String name) |
static PropertyFile |
find() |
static PropertyFile |
find(java.lang.ClassLoader classloader,
java.lang.String... fileNames)
Find a property file
|
static PropertyFile |
find(java.lang.String fileName) |
static PropertyFile[] |
findAll(java.lang.ClassLoader loader,
java.lang.String name)
Find all property files by the name
name by searching the specified classloader |
static PropertyFile[] |
findAll(java.lang.String name)
Find all property files by the name
name by searching the classloader that owns PropertyFile |
java.lang.String |
get(java.lang.String name) |
boolean |
get(java.lang.String name,
boolean defaultValue) |
int |
get(java.lang.String name,
int defaultValue) |
long |
get(java.lang.String name,
long defaultValue) |
java.lang.String |
get(java.lang.String name,
java.lang.String defaultValue) |
byte[] |
getBase64(java.lang.String name)
Get a value which is Base64 encoded
|
byte[] |
getBase64(java.lang.String name,
byte[] defaultValue) |
boolean |
getBoolean(java.lang.String name,
boolean defaultValue) |
boolean |
getCaseSensitive() |
java.lang.Class<?> |
getClass(java.lang.String name,
java.lang.Class<?> defaultValue) |
java.io.File |
getFile() |
boolean |
getForceNameValueDelimiterWhitespace() |
byte[] |
getHex(java.lang.String name)
Get a value which has been encoded in hexidecimal; The encoding may optionally include : delimiters, but no other non-hex
characters are permitted
|
int |
getInteger(java.lang.String name,
int defaultValue) |
java.net.InetAddress |
getIP(java.lang.String name,
java.net.InetAddress defaultValue) |
int |
getLineCount() |
long |
getLong(java.lang.String name,
long defaultValue) |
java.net.URI |
getURI(java.lang.String name,
java.lang.String defaultValue) |
int |
getVariableCount() |
protected void |
hook_added(java.lang.String name,
java.lang.String newValue) |
protected void |
hook_changed(java.lang.String name,
java.lang.String oldValue,
java.lang.String newValue) |
protected void |
hook_cleared() |
protected void |
hook_loaded() |
protected void |
hook_merge_begin() |
protected void |
hook_merge_complete() |
protected void |
hook_removed(java.lang.String name) |
protected void |
hook_saved() |
java.util.Iterator<java.lang.String> |
keyIterator() |
java.util.Set<java.lang.String> |
keySet() |
void |
load() |
void |
load(java.io.File file) |
void |
load(java.io.InputStream is) |
void |
load(java.util.Properties p) |
void |
load(java.io.Reader r) |
void |
makeReadOnly()
Make this PropertyFile object read-only
|
void |
merge(java.util.Properties other)
Merges another PropertyFile into this PropertyFile, overwriting any conflicting properties with the value from
other |
void |
merge(java.util.Properties other,
IMergeConflictResolver conflictResolver)
Merges another PropertyFile into this PropertyFile, using an optional merge conflict resolver
If no merge conflict resolver is specified then the default will be that the properties from other will
overwrite the local properties |
void |
merge(PropertyFile other)
Merges another PropertyFile into this PropertyFile, overwriting any conflicting properties with the value from
other |
void |
merge(PropertyFile other,
IMergeConflictResolver conflictResolver)
Merges another PropertyFile into this PropertyFile, using an optional merge conflict resolver
If no merge conflict resolver is specified then the default will be that the properties from other will
overwrite the local properties |
static PropertyFile |
openResource(java.lang.ClassLoader classloader,
java.net.URL resource,
java.lang.String fileName) |
static PropertyFile |
readOnly(java.io.File filename)
Creates a read-only version of a property file
Fails if the file does not exist. |
static PropertyFile |
readOnlyUnion(java.io.File... filenames)
Creates a read-only union of a number of property files
If any property file is null or the file it points to does not exist then it is ignored |
static PropertyFile |
readOnlyUnion(PropertyFile... files)
Construct a new read-only PropertyFile which merges the contents of a number of other PropertyFile objects
Null PropertyFiles are ignored. |
void |
remove(java.lang.String name) |
void |
save() |
void |
save(java.io.File f,
java.lang.String comment) |
void |
save(java.io.OutputStream os) |
void |
save(java.lang.String comment) |
void |
save(java.lang.String comment,
java.io.OutputStream os) |
void |
save(java.lang.String comment,
java.io.Writer w) |
java.lang.String |
set(java.lang.String name,
int value) |
java.lang.String |
set(java.lang.String name,
long value) |
java.lang.String |
set(java.lang.String name,
java.lang.String value) |
java.lang.String |
setBase64(java.lang.String name,
byte[] value) |
void |
setFile(java.io.File file) |
void |
setForceNameValueDelimiterWhitespace(boolean value) |
java.lang.String |
setHex(java.lang.String name,
byte[] value) |
java.util.Properties |
toProperties()
Converts the name/value pairs stored in this PropertyFile to the Java Properties propertyfile type
|
protected java.io.File f
protected boolean readOnly
protected boolean caseSensitive
protected boolean forceNameValueDelimiterWhitespace
protected java.util.List<PropertyFile.Entry> entries
protected java.util.Map<java.lang.String,PropertyFile.NameValuePair> vars
protected boolean dirty
public PropertyFile(java.io.File fileName)
throws java.io.IOException
java.io.IOExceptionpublic PropertyFile(java.io.File fileName,
boolean caseSensitive)
throws java.io.IOException
java.io.IOExceptionpublic PropertyFile()
public PropertyFile(java.io.InputStream is,
boolean caseSensitive)
throws java.io.IOException
java.io.IOExceptionpublic PropertyFile(java.io.Reader r)
throws java.io.IOException
java.io.IOExceptionpublic PropertyFile(java.io.Reader r,
boolean caseSensitive)
throws java.io.IOException
java.io.IOExceptionpublic PropertyFile(java.io.InputStream is)
throws java.io.IOException
java.io.IOExceptionpublic PropertyFile(java.util.Properties p)
public PropertyFile(java.util.Properties p,
boolean caseSensitive)
public static PropertyFile find()
public static PropertyFile find(java.lang.String fileName)
public static PropertyFile find(java.lang.ClassLoader classloader, java.lang.String... fileNames)
classloader - fileName - public static PropertyFile openResource(java.lang.ClassLoader classloader, java.net.URL resource, java.lang.String fileName)
public static PropertyFile[] findAll(java.lang.String name)
name by searching the classloader that owns PropertyFilename - public static PropertyFile[] findAll(java.lang.ClassLoader loader, java.lang.String name)
name by searching the specified classloaderloader - name - public java.util.Properties toProperties()
public boolean getCaseSensitive()
public java.io.File getFile()
public void setFile(java.io.File file)
public void setForceNameValueDelimiterWhitespace(boolean value)
public boolean getForceNameValueDelimiterWhitespace()
public void load()
throws java.io.IOException
java.io.IOExceptionpublic void load(java.util.Properties p)
public void load(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic void load(java.io.InputStream is)
throws java.io.IOException
java.io.IOExceptionpublic void save()
throws java.io.IOException
java.io.IOExceptionpublic void save(java.io.File f,
java.lang.String comment)
throws java.io.IOException
java.io.IOExceptionpublic void save(java.io.OutputStream os)
throws java.io.IOException
java.io.IOExceptionpublic void save(java.lang.String comment)
throws java.io.IOException
java.io.IOExceptionpublic void save(java.lang.String comment,
java.io.OutputStream os)
throws java.io.IOException
java.io.IOExceptionpublic void merge(PropertyFile other)
otherother - the other property filepublic void merge(PropertyFile other, IMergeConflictResolver conflictResolver)
other will
overwrite the local propertiesother - the other property fileconflictResolver - public void merge(java.util.Properties other)
otherother - public void merge(java.util.Properties other,
IMergeConflictResolver conflictResolver)
other will
overwrite the local propertiesother - the other property fileconflictResolver - public void makeReadOnly()
public boolean containsKey(java.lang.String name)
public java.lang.String get(java.lang.String name)
public java.lang.String get(java.lang.String name,
java.lang.String defaultValue)
public java.net.InetAddress getIP(java.lang.String name,
java.net.InetAddress defaultValue)
public int get(java.lang.String name,
int defaultValue)
public long get(java.lang.String name,
long defaultValue)
public boolean get(java.lang.String name,
boolean defaultValue)
public int getInteger(java.lang.String name,
int defaultValue)
public boolean getBoolean(java.lang.String name,
boolean defaultValue)
public long getLong(java.lang.String name,
long defaultValue)
public java.net.URI getURI(java.lang.String name,
java.lang.String defaultValue)
public java.lang.Class<?> getClass(java.lang.String name,
java.lang.Class<?> defaultValue)
public byte[] getBase64(java.lang.String name)
name - public byte[] getBase64(java.lang.String name,
byte[] defaultValue)
public byte[] getHex(java.lang.String name)
name - public java.lang.String set(java.lang.String name,
java.lang.String value)
public java.lang.String setBase64(java.lang.String name,
byte[] value)
public java.lang.String setHex(java.lang.String name,
byte[] value)
public java.lang.String set(java.lang.String name,
long value)
public java.lang.String set(java.lang.String name,
int value)
public void remove(java.lang.String name)
public void clear()
public java.util.Set<java.lang.String> keySet()
public java.util.Iterator<java.lang.String> keyIterator()
public int getLineCount()
public int getVariableCount()
protected void hook_changed(java.lang.String name,
java.lang.String oldValue,
java.lang.String newValue)
protected void hook_added(java.lang.String name,
java.lang.String newValue)
protected void hook_removed(java.lang.String name)
protected void hook_cleared()
protected void hook_merge_begin()
protected void hook_merge_complete()
protected void hook_loaded()
protected void hook_saved()
public void load(java.io.Reader r)
throws java.io.IOException
java.io.IOExceptionpublic void save(java.lang.String comment,
java.io.Writer w)
throws java.io.IOException
java.io.IOExceptionprotected void _clear()
protected java.lang.String _set(java.lang.String name,
java.lang.String value)
protected java.lang.String _get(java.lang.String name,
java.lang.String defaultValue)
protected java.lang.String _get_core(java.lang.String name,
java.lang.String defaultValue)
protected boolean _contains(java.lang.String name)
protected void _rm(java.lang.String name)
public static PropertyFile readOnlyUnion(java.io.File... filenames) throws java.io.IOException
filenames - java.io.IOException - if an unexpected error occurs while loading a filepublic static PropertyFile readOnlyUnion(PropertyFile... files)
files - public static PropertyFile readOnly(java.io.File filename) throws java.io.IOException
filename - the filename to loadjava.io.IOException - if the file cannot be loadedCopyright © 2014. All Rights Reserved.