Class PreferencesReader
java.lang.Object
org.openstreetmap.josm.data.preferences.PreferencesReader
Loads preferences from XML.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPreferencesReader(File file, boolean defaults) Constructs a newPreferencesReader.PreferencesReader(Reader reader, boolean defaults) Constructs a newPreferencesReader. -
Method Summary
Modifier and TypeMethodDescriptionprivate voiddoParse()Return the parsed preferences as a settings mapintReturn the version from the XML root element.private booleanisNil()Check if the current element is nil (meaning the value of the setting is null).private voidvoidparse()Parse preferences.parseMap()private voidprivate voidprivate voidthrowException(String msg) Throw XmlStreamParsingException with line and column number.static voidvalidateXML(File f) Validate the XML.static voidvalidateXML(Reader in) Validate the XML.
-
Field Details
-
settings
-
parser
-
version
-
reader
-
file
-
defaults
-
-
Constructor Details
-
PreferencesReader
Constructs a newPreferencesReader.- Parameters:
file- the filedefaults- true when reading from the cache file for default preferences, false for the regular preferences config file
-
PreferencesReader
Constructs a newPreferencesReader.- Parameters:
reader- theReaderdefaults- true when reading from the cache file for default preferences, false for the regular preferences config file
-
-
Method Details
-
validateXML
Validate the XML.- Parameters:
f- the file- Throws:
IOException- if any I/O error occursSAXException- if any SAX error occurs
-
validateXML
Validate the XML.- Parameters:
in- theReader- Throws:
IOException- if any I/O error occursSAXException- if any SAX error occurs
-
getSettings
Return the parsed preferences as a settings map- Returns:
- the parsed preferences as a settings map
-
getVersion
Return the version from the XML root element. (Represents the JOSM version when the file was written.)- Returns:
- the version
-
parse
Parse preferences.- Throws:
XMLStreamException- if any XML parsing error occursIOException- if any I/O error occurs
-
doParse
- Throws:
XMLStreamException
-
parseRoot
- Throws:
XMLStreamException
-
jumpToEnd
- Throws:
XMLStreamException
-
parseToplevelList
- Throws:
XMLStreamException
-
parseInnerList
- Throws:
XMLStreamException
-
parseMap
- Throws:
XMLStreamException
-
isNil
Check if the current element is nil (meaning the value of the setting is null).- Returns:
- true, if the current element is nil
- See Also:
-
throwException
Throw XmlStreamParsingException with line and column number. Only use this for errors that should not be possible after schema validation.- Parameters:
msg- the error message- Throws:
XmlStreamParsingException- always
-