public class PreferencesReader extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private boolean |
defaults |
private java.io.File |
file |
private javax.xml.stream.XMLStreamReader |
parser |
private java.io.Reader |
reader |
private java.util.SortedMap<java.lang.String,Setting<?>> |
settings |
private int |
version |
private static java.lang.String |
XSI_NS |
| Constructor and Description |
|---|
PreferencesReader(java.io.File file,
boolean defaults)
Constructs a new
PreferencesReader. |
PreferencesReader(java.io.Reader reader,
boolean defaults)
Constructs a new
PreferencesReader. |
| Modifier and Type | Method and Description |
|---|---|
private void |
doParse() |
java.util.SortedMap<java.lang.String,Setting<?>> |
getSettings()
Return the parsed preferences as a settings map
|
int |
getVersion()
Return the version from the XML root element.
|
private boolean |
isNil()
Check if the current element is nil (meaning the value of the setting is null).
|
private void |
jumpToEnd() |
void |
parse() |
private java.util.List<java.lang.String> |
parseInnerList() |
private java.util.Map<java.lang.String,java.lang.String> |
parseMap() |
private void |
parseRoot() |
private void |
parseToplevelList() |
private void |
throwException(java.lang.String msg)
Throw RuntimeException with line and column number.
|
static void |
validateXML(java.io.File f)
Validate the XML.
|
static void |
validateXML(java.io.Reader in)
Validate the XML.
|
private static final java.lang.String XSI_NS
private javax.xml.stream.XMLStreamReader parser
private int version
private java.io.Reader reader
private java.io.File file
private final boolean defaults
public PreferencesReader(java.io.File file, boolean defaults) throws java.io.IOException, javax.xml.stream.XMLStreamException
PreferencesReader.file - the filedefaults - true when reading from the cache file for default preferences,
false for the regular preferences config filejava.io.IOException - if any I/O error occursjavax.xml.stream.XMLStreamException - if any XML stream error occurspublic PreferencesReader(java.io.Reader reader, boolean defaults) throws javax.xml.stream.XMLStreamException
PreferencesReader.reader - the Readerdefaults - true when reading from the cache file for default preferences,
false for the regular preferences config filejavax.xml.stream.XMLStreamException - if any XML stream error occurspublic static void validateXML(java.io.File f) throws java.io.IOException, org.xml.sax.SAXException
f - the filejava.io.IOException - if any I/O error occursorg.xml.sax.SAXException - if any SAX error occurspublic static void validateXML(java.io.Reader in) throws java.io.IOException, org.xml.sax.SAXException
in - the Readerjava.io.IOException - if any I/O error occursorg.xml.sax.SAXException - if any SAX error occurspublic java.util.SortedMap<java.lang.String,Setting<?>> getSettings()
public int getVersion()
public void parse() throws javax.xml.stream.XMLStreamException, java.io.IOException
javax.xml.stream.XMLStreamExceptionjava.io.IOExceptionprivate void doParse() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprivate void parseRoot() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprivate void jumpToEnd() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprivate void parseToplevelList() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprivate java.util.List<java.lang.String> parseInnerList() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprivate java.util.Map<java.lang.String,java.lang.String> parseMap() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprivate boolean isNil()
private void throwException(java.lang.String msg)
msg - the error message