/** * Set the content data of this MaryData object from the given String. For XML data ({@link * MaryDataType#isXMLType()}), parse the String representation of the data into a DOM tree. * * @param dataString string representation of the input data. * @throws ParserConfigurationException ParserConfigurationException * @throws IOException IOException * @throws SAXException SAXException * @throws IllegalArgumentException if this method is called for MaryDataTypes that are neither * text nor XML. */ public void setData(String dataString) throws ParserConfigurationException, SAXException, IOException { // First, some data cleanup: dataString = StringUtils.purgeNonBreakingSpaces(dataString); // Now, deal with it. if (type.isXMLType()) { logger.debug( "Parsing XML input (" + (doValidate ? "" : "non-") + "validating): " + dataString); xmlDocument = DomUtils.parseDocument(dataString, doValidate); } else if (type.isTextType()) { logger.debug("Setting text input: " + dataString); plainText = dataString; } else { throw new IllegalArgumentException("Cannot set data of type " + type + " from a string"); } }