/** * Prints entries of a given <code>Properties</code> object as XML elements to a given * <code>PrintWriter</code>, maintaining a given indentation level. * * @param elements * The given <code>Properties</code> object. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level. * @throws IOException * if any I/O exception occurred. */ public static void printAllXMLElements(Properties elements, PrintWriter oWriter, int level) throws IOException { printAllXMLElements(elements, null, oWriter, level); }
/** * XML parser warning handler. */ public void warning(SAXParseException ex) throws SAXException { XMLUtil.printError("Warning", ex); } }
/** * Prints a given XML element, which contains only given attributes, to a given * <code>PrintWriter</code>, maintaining a given indentation level. * * @param tag * The given XML tag. * @param attributes * The given XML element attributes. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level (number of marginal '\t' symbols). * @throws IOException * if any I/O exception occurred. */ public static void printXMLElement(String tag, Properties attributes, PrintWriter oWriter, int level) throws IOException { printXMLElement(tag, attributes, null, oWriter, level); }
XMLUtil.printXMLTag(ROOT_TAG, oWriter, false, 0); oWriter.println(); XMLUtil.printXMLTag(OS_TAG, oWriter, false, 1); oWriter.println(); tagOrder[0] = NAME_TAG; if (insdObject.getOSSpecs().size() > 0) XMLUtil.printAllXMLElements(insdObject.getOSSpecs(), InstallationDescriptor.PROPERTY_DELIMITER, tagOrder, oWriter, 2); XMLUtil.printXMLTag(OS_TAG, oWriter, true, 1); oWriter.println(); XMLUtil.printXMLTag(TOOLKITS_TAG, oWriter, false, 1); oWriter.println(); XMLUtil.printAllXMLElements(insdObject.getToolkitsSpecs(), InstallationDescriptor.PROPERTY_DELIMITER, null, oWriter, 2); XMLUtil.printXMLTag(TOOLKITS_TAG, oWriter, true, 1); oWriter.println(); XMLUtil.printXMLTag(UIMA_FRAMEWORK_TAG, oWriter, false, 1); oWriter.println(); XMLUtil.printAllXMLElements(insdObject.getFrameworkSpecs(), InstallationDescriptor.PROPERTY_DELIMITER, null, oWriter, 2);
throws IOException { printXMLTag(tag, attributes, oWriter, false, level); if (useNewLine4Value) { oWriter.println(); printXMLElementValue(elemValue, putInCdataSection, oWriter, level); oWriter.println(); printXMLTag(tag, oWriter, true, level); } else { printXMLElementValue(elemValue, putInCdataSection, oWriter, 0); printXMLTag(tag, oWriter, true, 0);
printXMLElements(tag, eValue, valueDelimiter, oWriter, level); else { printXMLElement(tag, eValue, oWriter, level); printXMLElements(tag, eValue, valueDelimiter, oWriter, level); else { printXMLElement(tag, eValue, oWriter, level);
/** * Starts parsing XML content from a given input stream. * * @param xmlStream * The given XML input stream. * @throws IOException * if any I/O exception occurred. * @throws SAXException * Any SAX exception, possibly wrapping another exception. */ public synchronized void parse(InputStream xmlStream) throws IOException, SAXException { if (_parser == null) _parser = XMLUtil.createSAXParser(); _insdObject = new InstallationDescriptor(); _insdLoaded = false; _parser.parse(xmlStream, this); }
/** * Prints a given element value to a given <code>PrintWriter</code>, maintaining a given * indentation level. By default, prints the element value 'as is' - not using the * <code>CDATA</code> section. * * @param elemValue * The given element value. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level. * @throws IOException * if any I/O exception occurred. */ public static void printXMLElementValue(String elemValue, PrintWriter oWriter, int level) throws IOException { printXMLElementValue(elemValue, false, oWriter, level); }
/** * Prints a given XML tag to a given <code>PrintWriter</code>, maintaining a given indentation * level. * * @param tag * The given XML tag. * @param oWriter * The given <code>PrintWriter</code> object. * @param tagEnd * If <code>false</code> prints the XML tag beginning brackets, otherwise prints the * the XML tag ending brackets. * @param level * The given indentation level (number of marginal '\t' symbols). * @throws IOException * if any I/O exception occurred. */ public static void printXMLTag(String tag, PrintWriter oWriter, boolean tagEnd, int level) throws IOException { printXMLTag(tag, null, oWriter, tagEnd, level); }
if (".xml".equalsIgnoreCase(fileExt)) { String xmlEncoding = XMLUtil.detectXmlFileEncoding(textFile); if (xmlEncoding != null) { encoding = xmlEncoding;
try { if (!isValidXmlFile(xmlFile)) { return null;
try { iStream = new FileInputStream(xmlFile); SAXParser parser = createSAXParser(); parser.parse(iStream, new DefaultHandler()); } catch (IOException exc) {
/** * Prints a given XML element, which contains only a given string value, to a given * <code>PrintWriter</code>, maintaining a given indentation level. The string element value is * printed 'as-is' without the CDATA block. * * @param tag * The given XML tag. * @param elemValue * The given XML element value. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level (number of marginal '\t' symbols). * @throws IOException * if any I/O exception occurred. */ public static void printXMLElement(String tag, String elemValue, PrintWriter oWriter, int level) throws IOException { printXMLElement(tag, null, elemValue, oWriter, level); }
/** * XML parser fatal error handler. */ public void fatalError(SAXParseException ex) throws SAXException { XMLUtil.printError("Fatal Error", ex); throw ex; }
/** * Starts parsing a given XML file. After parsing is completed, the application may access parsing * results using convenient methods. * * @param xmlFile * The given XML file. * @exception java.io.IOException * Any I/O exception. * @exception org.xml.sax.SAXException * Any SAX exception, possibly wrapping another exception. */ public synchronized void parse(File xmlFile) throws IOException, SAXException { if (_parser == null) _parser = XMLUtil.createSAXParser(); _insdObject = new InstallationDescriptor(xmlFile); _insdLoaded = false; _parser.parse(xmlFile, this); }
/** * Prints entries of a given <code>Properties</code> object as XML elements to a given * <code>PrintWriter</code>, maintaining a specified tag order and a given indentation level. * * @param elements * The given <code>Properties</code> object. * @param tagOrder * The <code>String</code> array that specifies the tag order. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level. * @throws IOException * if any I/O exception occurred. */ public static void printAllXMLElements(Properties elements, String[] tagOrder, PrintWriter oWriter, int level) throws IOException { printAllXMLElements(elements, null, tagOrder, oWriter, level); }
/** * Prints a given XML element, which contains given attributes and a given string value, to a * given <code>PrintWriter</code>, maintaining a given indentation level. The string element * value (if exists) is printed 'as is' - without a CDATA section. * * @param tag * The given XML element tag. * @param attributes * The given XML element attributes. * @param elemValue * The given XML element value. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level (number of marginal '\t' symbols). * @throws IOException * if any I/O exception occurred. */ public static void printXMLElement(String tag, Properties attributes, String elemValue, PrintWriter oWriter, int level) throws IOException { printXMLElement(tag, attributes, elemValue, false, oWriter, level, false); }
/** * XML parser error handler. */ public void error(SAXParseException ex) throws SAXException { XMLUtil.printError("Error", ex); }
/** * Prints a given XML element, which contains only a given string value, to a given * <code>PrintWriter</code>, maintaining a given indentation level. The string element value * (if exists) is put into the CDATA block, if a given <code>boolean</code> flag is * <code>true</code>. * * @param tag * The given XML tag. * @param elemValue * The given XML element value. * @param putInCdataSection * If <code>true</code>, puts the element value in the <code>CDATA</code> section, * otherwise prints the element value without the <code>CDATA</code> section. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level (number of marginal '\t' symbols). * @throws IOException * if any I/O exception occurred. */ public static void printXMLElement(String tag, String elemValue, boolean putInCdataSection, PrintWriter oWriter, int level) throws IOException { printXMLElement(tag, null, elemValue, putInCdataSection, oWriter, level); }
/** * Prints a given XML element, which contains given attributes and a given string value, to a * given <code>PrintWriter</code>, maintaining a given indentation level. The string element * value (if exists) is printed within or without the CDATA section, depending on a given * <code>boolean</code> flag value. * * @param tag * The given XML element tag. * @param attributes * The given XML element tag. * @param elemValue * The given XML element value. * @param putInCdataSection * If <code>true</code>, puts the element value in the <code>CDATA</code> section, * otherwise prints the element value without the <code>CDATA</code> section. * @param oWriter * The given <code>PrintWriter</code> object. * @param level * The given indentation level (number of marginal '\t' symbols). * @throws IOException * if any I/O exception occurred. */ public static void printXMLElement(String tag, Properties attributes, String elemValue, boolean putInCdataSection, PrintWriter oWriter, int level) throws IOException { printXMLElement(tag, attributes, elemValue, putInCdataSection, oWriter, level, false); }