Package org.jcsp.net.settings
Class ConfigReader
- java.lang.Object
-
- org.jcsp.net.settings.ConfigReader
-
- All Implemented Interfaces:
XMLConfigConstants
public class ConfigReader extends java.lang.Object implements XMLConfigConstants
Used internally by the JCSP network infrastructure to load a configuration from an XML file.
This is not a full XML reader, and is capable of reading only a subset of XML.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classConfigReader.Tagstatic classConfigReader.XMLValidationExceptionThrown in the event of a semantic error in the parsed XML file.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]attribsprivate JCSPConfigconfigThe config built up.private static intMAX_ATTRIBSprivate intprotocolPosprivate intservicePosprivate java.lang.String[]values-
Fields inherited from interface org.jcsp.net.settings.XMLConfigConstants
DATA_TYPE_INDICATOR_BOOLEAN, DATA_TYPE_INDICATOR_DOUBLE, DATA_TYPE_INDICATOR_INT, DATA_TYPE_INDICATOR_STRING, ELEMENT_ADDRESS, ELEMENT_ADDRESS_SETTING, ELEMENT_ADDRESSES, ELEMENT_CONNECTION_ORIENTED, ELEMENT_LINK_PROFILE, ELEMENT_LINK_PROFILES, ELEMENT_LINK_REQ_MAXPING, ELEMENT_LINK_REQ_MINSPEED, ELEMENT_LINK_REQ_OTHER, ELEMENT_LINK_REQ_PROTOCOL, ELEMENT_LINK_REQS, ELEMENT_MAXSPEED, ELEMENT_MEMORY, ELEMENT_NODE_PROFILE, ELEMENT_NODE_PROFILES, ELEMENT_NODE_REQ_MINMEMORY, ELEMENT_NODE_REQ_MINSPEED, ELEMENT_NODE_REQ_OTHER, ELEMENT_NODE_REQS, ELEMENT_NODE_SPECS, ELEMENT_OTHERSPEC, ELEMENT_PLUGIN, ELEMENT_PLUGINS, ELEMENT_PROTOCOL, ELEMENT_PROTOCOL_SETTING, ELEMENT_PROTOCOL_SETTINGS, ELEMENT_PROTOCOLS, ELEMENT_RELIABLE, ELEMENT_SERVICE, ELEMENT_SERVICES, ELEMENT_SETTING, ELEMENT_SETTINGS, ELEMENT_SPECS, ELEMENT_WIRELESS, REQ_COMPARATOR_EQUALS, REQ_COMPARATOR_GREATER, REQ_COMPARATOR_LESS, REQ_NAME_MAXPING, REQ_NAME_MINMEMORY, REQ_NAME_MINSPEED, REQ_NAME_PROTOCOL, RESERVED_SPEC_NAMES, SPEC_NAME_CONNECTION_ORIENTED, SPEC_NAME_MAXSPEED, SPEC_NAME_MEMORY, SPEC_NAME_PING, SPEC_NAME_PROTOCOL, SPEC_NAME_RELIABLE, SPEC_NAME_WIRELESS, XML_BOOLEAN_FALSE, XML_BOOLEAN_TRUE, XML_TRISTATE_CANBE, XML_TRISTATE_FALSE, XML_TRISTATE_TRUE
-
-
Constructor Summary
Constructors Constructor Description ConfigReader(java.io.InputStream instream)Constructs a new configuration from the given source stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voiddo_template(java.io.Reader in)private voiddoAddress(java.io.Reader in)private voiddoAddresses(java.io.Reader in)private voiddoAddressSpecs(java.io.Reader in)private voiddoJCSP_Config(java.io.Reader in)private voiddoLinkProfile(java.io.Reader in)private voiddoLinkProfiles(java.io.Reader in)private voiddoLinkReqs(java.io.Reader in)private voiddoNodeProfile(java.io.Reader in)private voiddoNodeProfiles(java.io.Reader in)private voiddoNodeReqs(java.io.Reader in)private voiddoNodeSpecs(java.io.Reader in)private voiddoPlugin(java.io.Reader in)private voiddoPlugins(java.io.Reader in)private voiddoProtocol(java.io.Reader in)private voiddoProtocols(java.io.Reader in)private voiddoProtocolSettings(java.io.Reader in)private voiddoProtocolSpecs(java.io.Reader in)private voiddoService(java.io.Reader in)private voiddoServices(java.io.Reader in)private voiddoSettings(java.io.Reader in)JCSPConfiggetConfig()private booleanisSpace(char c)static voidmain(java.lang.String[] args)Diagnostic routine.private charnextChar(java.io.Reader in)private ConfigReader.TagnextTag(java.io.Reader in)
-
-
-
Field Detail
-
config
private JCSPConfig config
The config built up.
-
servicePos
private int servicePos
-
protocolPos
private int protocolPos
-
MAX_ATTRIBS
private static final int MAX_ATTRIBS
- See Also:
- Constant Field Values
-
attribs
private final java.lang.String[] attribs
-
values
private final java.lang.String[] values
-
-
Constructor Detail
-
ConfigReader
public ConfigReader(java.io.InputStream instream) throws java.io.IOExceptionConstructs a new configuration from the given source stream. This will attempt to parse the file using recursive-descent approach.- Parameters:
instream- source of the XML configuration.- Throws:
java.io.IOException- if there is a problem with the stream or the file is improperly formatted.ConfigReader.XMLValidationException- if there is a symantic problem with the configuration.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Diagnostic routine. This can load an XML configuration file and then display the configuration structure constructed. Specify the name of the file as the first command line parameter.
-
do_template
private void do_template(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doJCSP_Config
private void doJCSP_Config(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doSettings
private void doSettings(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doServices
private void doServices(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doService
private void doService(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doPlugins
private void doPlugins(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doPlugin
private void doPlugin(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doProtocols
private void doProtocols(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doProtocol
private void doProtocol(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doProtocolSpecs
private void doProtocolSpecs(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doProtocolSettings
private void doProtocolSettings(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doAddresses
private void doAddresses(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doAddress
private void doAddress(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doAddressSpecs
private void doAddressSpecs(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doNodeSpecs
private void doNodeSpecs(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doLinkProfiles
private void doLinkProfiles(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doLinkProfile
private void doLinkProfile(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doLinkReqs
private void doLinkReqs(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doNodeProfiles
private void doNodeProfiles(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doNodeProfile
private void doNodeProfile(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
doNodeReqs
private void doNodeReqs(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
getConfig
public JCSPConfig getConfig()
-
nextTag
private ConfigReader.Tag nextTag(java.io.Reader in) throws java.io.IOException
- Throws:
java.io.IOException
-
isSpace
private boolean isSpace(char c)
-
nextChar
private char nextChar(java.io.Reader in) throws java.io.IOException- Throws:
java.io.IOException
-
-