Package com.peterphi.std.io
Class PropertyFile
java.lang.Object
com.peterphi.std.io.PropertyFile
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classprotected classprotected classprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected List<PropertyFile.Entry>protected Fileprotected booleanprotected booleanprotected Map<String,PropertyFile.NameValuePair> -
Constructor Summary
ConstructorsConstructorDescriptionPropertyFile(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 booleanprotected Stringprotected Stringprotected voidprotected Stringvoidclear()booleancontainsKey(String name) static PropertyFilefind()static PropertyFilefind(ClassLoader classloader, String... fileNames) Find a property filestatic PropertyFilestatic PropertyFile[]findAll(ClassLoader loader, String name) Find all property files by the namenameby searching the specified classloaderstatic PropertyFile[]Find all property files by the namenameby searching the classloader that owns PropertyFilestatic PropertyFilefromString(String contents) static PropertyFilefromString(String contents, String filename) booleanintlongbooleangetBoolean(String name, boolean defaultValue) booleangetFile()booleanintintprotected voidhook_added(String name, String newValue) protected voidhook_changed(String name, String oldValue, String newValue) protected voidprotected voidprotected voidhook_removed(String name) protected voidkeySet()voidload()voidvoidload(InputStream is) voidvoidvoidload(Properties p) voidMake this PropertyFile object read-onlystatic PropertyFileopenResource(ClassLoader classloader, URL resource, String fileName) static PropertyFileCreates a read-only version of a property file
Fails if the file does not exist.voidvoidsave()voidvoidsave(OutputStream os) voidvoidsave(String comment, OutputStream os) voidvoidvoidsetForceNameValueDelimiterWhitespace(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 namenameby searching the classloader that owns PropertyFile- Parameters:
name-- Returns:
-
findAll
Find all property files by the namenameby 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
-