Package com.peterphi.std.io
Class PropertyFile
java.lang.Object
com.peterphi.std.io.PropertyFile
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected class
protected class
protected class
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected List<PropertyFile.Entry>
protected File
protected boolean
protected boolean
protected Map<String,
PropertyFile.NameValuePair> -
Constructor Summary
ConstructorDescriptionPropertyFile
(File fileName) PropertyFile
(File fileName, boolean caseSensitive) PropertyFile
(InputStream is, boolean caseSensitive) PropertyFile
(Reader r, boolean caseSensitive) PropertyFile
(URL url) PropertyFile
(Map<String, String> map) PropertyFile
(Properties p, boolean caseSensitive) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
_clear()
protected boolean
protected String
protected String
protected void
protected String
void
clear()
boolean
containsKey
(String name) static PropertyFile
find()
static PropertyFile
find
(ClassLoader classloader, String... fileNames) Find a property filestatic PropertyFile
static PropertyFile[]
findAll
(ClassLoader loader, String name) Find all property files by the namename
by searching the specified classloaderstatic PropertyFile[]
Find all property files by the namename
by searching the classloader that owns PropertyFilestatic PropertyFile
fromString
(String contents) static PropertyFile
fromString
(String contents, String filename) boolean
int
long
boolean
getBoolean
(String name, boolean defaultValue) boolean
getFile()
boolean
int
int
protected void
hook_added
(String name, String newValue) protected void
hook_changed
(String name, String oldValue, String newValue) protected void
protected void
protected void
hook_removed
(String name) protected void
keySet()
void
load()
void
void
load
(InputStream is) void
void
void
load
(Properties p) void
Make this PropertyFile object read-onlystatic PropertyFile
openResource
(ClassLoader classloader, URL resource, String fileName) static PropertyFile
Creates a read-only version of a property file
Fails if the file does not exist.void
void
save()
void
void
save
(OutputStream os) void
void
save
(String comment, OutputStream os) void
void
void
setForceNameValueDelimiterWhitespace
(boolean value) toMap()
Converts the name/value pairs stored in this PropertyFile to a Map of key/value pairsConverts the name/value pairs stored in this PropertyFile to the Java Properties propertyfile type
-
Field Details
-
f
-
readOnly
protected boolean readOnly -
caseSensitive
protected boolean caseSensitive -
forceNameValueDelimiterWhitespace
protected boolean forceNameValueDelimiterWhitespace -
entries
-
vars
-
dirty
protected boolean dirty
-
-
Constructor Details
-
PropertyFile
- Throws:
IOException
-
PropertyFile
- Throws:
IOException
-
PropertyFile
public PropertyFile() -
PropertyFile
- Throws:
IOException
-
PropertyFile
- Throws:
IOException
-
PropertyFile
- Throws:
IOException
-
PropertyFile
- Throws:
IOException
-
PropertyFile
- Throws:
IOException
-
PropertyFile
-
PropertyFile
-
PropertyFile
-
-
Method Details
-
find
-
find
-
find
Find a property file- Parameters:
classloader
-fileNames
-- Returns:
-
fromString
-
fromString
-
openResource
-
findAll
Find all property files by the namename
by searching the classloader that owns PropertyFile- Parameters:
name
-- Returns:
-
findAll
Find all property files by the namename
by searching the specified classloader- Parameters:
loader
-name
-- Returns:
-
toProperties
Converts the name/value pairs stored in this PropertyFile to the Java Properties propertyfile type- Returns:
- a Properties representing the data (but not the comments, etc) in this file
-
toMap
Converts the name/value pairs stored in this PropertyFile to a Map of key/value pairs- Returns:
- a Map representing the data (but not the comments, etc) in this file
-
getCaseSensitive
public boolean getCaseSensitive() -
getFile
-
setFile
-
setForceNameValueDelimiterWhitespace
public void setForceNameValueDelimiterWhitespace(boolean value) -
getForceNameValueDelimiterWhitespace
public boolean getForceNameValueDelimiterWhitespace() -
load
- Throws:
IOException
-
load
-
load
-
load
- Throws:
IOException
-
load
- Throws:
IOException
-
save
- Throws:
IOException
-
save
- Throws:
IOException
-
save
- Throws:
IOException
-
save
- Throws:
IOException
-
save
- Throws:
IOException
-
makeReadOnly
public void makeReadOnly()Make this PropertyFile object read-only -
containsKey
-
get
-
get
-
get
-
get
-
get
-
getBoolean
-
getURI
-
set
-
set
-
set
-
remove
-
clear
public void clear() -
keySet
-
keyIterator
-
getLineCount
public int getLineCount() -
getVariableCount
public int getVariableCount() -
hook_changed
-
hook_added
-
hook_removed
-
hook_cleared
protected void hook_cleared() -
hook_loaded
protected void hook_loaded() -
hook_saved
protected void hook_saved() -
load
- Throws:
IOException
-
save
- Throws:
IOException
-
_clear
protected void _clear() -
_set
-
_get
-
_get_core
-
_contains
-
_rm
-
readOnly
Creates a read-only version of a property file
Fails if the file does not exist.- Parameters:
filename
- the filename to load- Returns:
- Throws:
IOException
- if the file cannot be loaded
-