77 package adInterfaceMCC.util;
78 import java.util.List;
80 import java.io.FileNotFoundException;
81 import java.io.IOException;
82 import java.util.ArrayList;
83 import java.util.HashSet;
84 import java.util.Iterator;
87 import javax.xml.parsers.ParserConfigurationException;
88 import javax.xml.parsers.SAXParser;
89 import javax.xml.parsers.SAXParserFactory;
90 import org.xml.sax.SAXException;
91 import org.xml.sax.Attributes;
92 import org.xml.sax.helpers.DefaultHandler;
114 final String boardnumber,
115 final String channelnumber,
116 final String channelgain,
117 final String channelvalue,
118 final String channeloptions,
119 final String applicationtag)
218 ParserConfigurationException, SAXException, IOException
220 final ArrayList<ADInterfaceMCCObjectType> ad_objs =
new ArrayList<ADInterfaceMCCObjectType>();
221 File f =
new File(s);
222 if (f.exists() !=
true)
223 throw new FileNotFoundException(
"Configuration file '" + s
224 +
"' could not be found.");
226 SAXParserFactory factory = SAXParserFactory.newInstance();
227 SAXParser saxParser = factory.newSAXParser();
228 DefaultHandler handler =
new DefaultHandler() {
230 public void startElement(String uri, String localName,
231 String qName, Attributes attributes)
232 throws SAXException {
233 if (qName.equals(
"Object")) {
235 currentAD_obj.setBoardNumber(attributes.getValue(
"BoardNumber")) ;
236 currentAD_obj.setChannelNumber(attributes.getValue(
"ChannelNumber"));
237 currentAD_obj.setChannelGain(attributes.getValue(
"ChannelGain"));
238 currentAD_obj.setChannelOptions(attributes.getValue(
"ChannelOptions"));
239 currentAD_obj.setChannelNumber(attributes.getValue(
"ChannelNumber"));
240 currentAD_obj.setApplicationTag(attributes.getValue(
"ApplicationTag").toUpperCase());
241 currentAD_obj.setChannelValue(
"0");
242 ad_objs.add(currentAD_obj);
246 saxParser.parse(s, handler);
247 }
catch (SAXException e) {
248 String em =
"SAXException when parsing file '" + s +
"'.";
249 throw new SAXException(em + e.getMessage());
250 }
catch (ParserConfigurationException e) {
251 String em =
"SAXParser error in parsing file '" + s +
"'.";
252 throw new ParserConfigurationException(em + e.getMessage());
253 }
catch (IOException e) {
254 String em =
"I/O error occurs when parsing configuration file '"
256 throw new IOException(em + e.getMessage());
280 private final static String
LS = System.getProperty(
"line.separator");
This class reads the XML configuration file and stores the data in the ADInterfaceMCCObjectType data ...
void setChannelNumber(String channelNumber)
Set the adinterface channel number.
String channelOptions
Channel options.
String getChannelOptions()
Get the adinterface channel options.
void setChannelGain(String channelGain)
Set the adinterface channel gain.
static final String LS
System-dependent line separator.
String getChannelNumber()
Get the adinterface channel number.
String boardNumber
Board number.
static ArrayList< ADInterfaceMCCObjectType > readADInterfaceMCCObjects(final String s)
Read adInterfaceMCC object types from the xml configuration.
String getChannelValue()
Get the adinterface present channel value.
String channelNumber
Channel number.
void setBoardNumber(String boardNumber)
Set the adinterface boardnumber.
void setChannelOptions(String channelOptions)
Set the adinterface channel options.
String channelGain
Channel gain.
String getApplicationTag()
Get the adinterface application Tag.
String getChannelGain()
Get the adinterface channel gain.
String channelValue
Channel value.
ADInterfaceMCCObjectType(final String boardnumber, final String channelnumber, final String channelgain, final String channelvalue, final String channeloptions, final String applicationtag)
Construct an instance of ADInterfaceMCC object.
String applicationTag
Application tag.
ADInterfaceMCCObjectType()
Empty constructor.
void setChannelValue(String channelValue)
Sett the adinterface channel value.
void setApplicationTag(String applicationTag)
Set the adinterface application tag.
String getBoardNumber()
Get the adinterface boardnumber.