use of java.io.StringReader in project openhab1-addons by openhab.
the class FrontierSiliconRadioApiResult method getXmlDocFromString.
/**
* converts the string we got from the radio to a parsable XML document
*
* @param xmlString
* the XML string read from the radio
* @return the parsed XML document
* @throws ParserConfigurationException
* @throws SAXException
* @throws IOException
*/
private Document getXmlDocFromString(String xmlString) throws ParserConfigurationException, SAXException, IOException {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document xmlDocument = builder.parse(new InputSource(new StringReader(xmlString)));
return xmlDocument;
}
use of java.io.StringReader in project openhab1-addons by openhab.
the class SonosXMLParser method getMetaDataFromXML.
public static SonosMetaData getMetaDataFromXML(String xml) throws SAXException {
XMLReader reader = XMLReaderFactory.createXMLReader();
// logger.debug("getTrackFromXML {}",xml);
MetaDataHandler handler = new MetaDataHandler();
reader.setContentHandler(handler);
try {
reader.parse(new InputSource(new StringReader(xml)));
} catch (IOException e) {
// This should never happen - we're not performing I/O!
logger.error("Could not parse AV Transport Event: {}", e);
}
return handler.getMetaData();
}
use of java.io.StringReader in project openhab1-addons by openhab.
the class SonosXMLParser method getZoneGroupFromXML.
/**
* @param controller
* @param xml
* @return zone group from the given xml
* @throws IOException
* @throws SAXException
*/
public static List<SonosZoneGroup> getZoneGroupFromXML(String xml) throws SAXException {
XMLReader reader = XMLReaderFactory.createXMLReader();
ZoneGroupHandler handler = new ZoneGroupHandler();
reader.setContentHandler(handler);
try {
reader.parse(new InputSource(new StringReader(xml)));
} catch (IOException e) {
// This should never happen - we're not performing I/O!
logger.error("Could not parse ZoneGroup from String {}", xml);
}
return handler.getGroups();
}
use of java.io.StringReader in project openhab1-addons by openhab.
the class SonosXMLParser method getEntriesFromString.
/**
* @param xml
* @return a list of Entrys from the given xml string.
* @throws IOException
* @throws SAXException
*/
public static List<SonosEntry> getEntriesFromString(String xml) throws SAXException {
XMLReader reader = XMLReaderFactory.createXMLReader();
EntryHandler handler = new EntryHandler();
reader.setContentHandler(handler);
try {
reader.parse(new InputSource(new StringReader(xml)));
} catch (IOException e) {
logger.error("Could not parse Entries from String {}", xml);
}
return handler.getArtists();
}
use of java.io.StringReader in project openhab1-addons by openhab.
the class SonosXMLParser method getAVTransportFromXML.
public static Map<String, StateVariableValue> getAVTransportFromXML(String xml) throws SAXException {
XMLReader reader = XMLReaderFactory.createXMLReader();
AVTransportEventHandler handler = new AVTransportEventHandler();
reader.setContentHandler(handler);
try {
reader.parse(new InputSource(new StringReader(xml)));
} catch (IOException e) {
// This should never happen - we're not performing I/O!
logger.error("Could not parse AV Transport Event: {}", e);
}
return handler.getChanges();
}
Aggregations