Package jmri.jmrit.symbolicprog
Class NameFile
- java.lang.Object
-
- jmri.jmrit.XmlFile
-
- jmri.jmrit.symbolicprog.NameFile
-
public class NameFile extends XmlFile
Represents a set of standard names and aliases in memory.This class doesn't provide tools for defining the names and aliases; that's done manually, or at least not done here, to create the file.
This automatically initializes from the default file if requested from the InstanceManager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NameFile.Initializer
-
Nested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<java.lang.String,org.jdom2.Element>
_nameHash
(package private) static java.lang.String
fileLocation
(package private) static java.lang.String
nameFileName
-
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation
-
-
Constructor Summary
Constructors Constructor Description NameFile()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkName(java.lang.String name)
Check to see if a name is present in the file.protected static java.lang.String
defaultNameFilename()
Get the filename for the default file, including location.org.jdom2.Element
elementFromName(java.lang.String name)
java.util.Set<java.lang.String>
names()
(package private) void
readFile(java.lang.String name)
Read the contents of a NameFile XML file into this object.(package private) void
readNames(org.jdom2.Element root)
(package private) void
storeDefinition(org.jdom2.Element el)
-
Methods inherited from class jmri.jmrit.XmlFile
addDefaultInfo, backupFileName, checkFile, createFileNameWithDate, dumpElement, findFile, getBuilder, getDefaultDtdLocation, getDefaultValidate, getDtdLocation, getProcessingInstructionHRef, getProcessingInstructionType, getRoot, getValidate, makeBackupFile, makeBackupFile, newDocument, newDocument, revertBackupFile, rootFromFile, rootFromInputStream, rootFromName, rootFromURL, setDefaultDtdLocation, setDefaultValidate, setDtdLocation, setValidate, userFileChooser, userFileChooser, writeXML, xmlDir
-
-
-
-
Field Detail
-
_nameHash
protected java.util.HashMap<java.lang.String,org.jdom2.Element> _nameHash
-
fileLocation
static java.lang.String fileLocation
-
nameFileName
static java.lang.String nameFileName
-
-
Constructor Detail
-
NameFile
public NameFile()
-
-
Method Detail
-
names
public java.util.Set<java.lang.String> names()
-
elementFromName
public org.jdom2.Element elementFromName(java.lang.String name)
-
checkName
public boolean checkName(java.lang.String name)
Check to see if a name is present in the file.- Parameters:
name
- the name to check- Returns:
- true if present; false otherwise
-
readFile
void readFile(java.lang.String name) throws org.jdom2.JDOMException, java.io.IOException
Read the contents of a NameFile XML file into this object. Note that this does not clear any existing entries.- Parameters:
name
- File name to read- Throws:
org.jdom2.JDOMException
- if the file can't be parsedjava.io.IOException
- from underlying IO operations
-
readNames
void readNames(org.jdom2.Element root)
-
storeDefinition
void storeDefinition(org.jdom2.Element el)
-
defaultNameFilename
protected static java.lang.String defaultNameFilename()
Get the filename for the default file, including location. This is here to allow easy override in tests.- Returns:
- the default filename
-
-