List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:Main.java
public static void endElement(XMLStreamWriter writer) throws XMLStreamException { writer.writeEndElement(); writer.flush();//from w ww .j ava 2s .c om }
From source file:Main.java
public static void writeValue(XMLStreamWriter writer, String name, String value) throws XMLStreamException { writer.writeStartElement(name);//from ww w. j a v a2 s. c om writer.writeCharacters(value); writer.writeEndElement(); }
From source file:Main.java
/** * write xml element start tag, data and end tag into XmlStreamWriter * * @param writer//from w ww . j a va2s.co m * @param element * @param value * @throws XMLStreamException */ public static void writeSimpleDataElement(XMLStreamWriter writer, String element, String value) throws XMLStreamException { writer.writeStartElement(element); writer.writeCharacters(value); writer.writeEndElement(); }
From source file:Main.java
public static void writeElement(XMLStreamWriter writer, String elementName, String characterData) throws XMLStreamException { writer.writeStartElement(elementName); writer.writeCharacters(characterData); writer.writeEndElement(); }
From source file:Main.java
public static XMLStreamWriter CreateSimpleTagAndContent(XMLStreamWriter serializer, String tag, String content, boolean allow_empty) throws XMLStreamException { if (!allow_empty && content.equals("")) return serializer; serializer.writeStartElement(tag);// w w w . j ava2 s . com serializer.writeCharacters(content); serializer.writeEndElement(); // end simple tag return serializer; }
From source file:Main.java
public static void writeTag(XMLStreamWriter xmlWriter, String tag, Object value) throws XMLStreamException { if (value == null) { xmlWriter.writeEmptyElement(tag); } else {//from ww w .jav a2 s .co m xmlWriter.writeStartElement(tag); xmlWriter.writeCData(value.toString()); xmlWriter.writeEndElement(); } }
From source file:com.flexive.shared.FxXMLUtils.java
/** * Write a "simple" tag//ww w. j a v a 2s . co m * * @param writer xml writer * @param tag tag name * @param value value * @param asCData use CDData? * @throws javax.xml.stream.XMLStreamException * on errors */ public static void writeSimpleTag(XMLStreamWriter writer, String tag, Object value, boolean asCData) throws XMLStreamException { writer.writeStartElement(tag); if (asCData) writer.writeCData(String.valueOf(value)); else writer.writeCharacters(String.valueOf(value)); writer.writeEndElement(); }
From source file:com.norconex.jefmon.model.ConfigurationDAO.java
public static void saveConfig(JEFMonConfig config) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Saving JEF config to: " + CONFIG_FILE); }/* www. j a va 2 s . c o m*/ if (!CONFIG_FILE.exists()) { File configDir = new File(FilenameUtils.getFullPath(CONFIG_FILE.getAbsolutePath())); if (!configDir.exists()) { LOG.debug("Creating JEF Monitor config directory for: " + CONFIG_FILE); configDir.mkdirs(); } } OutputStream out = new FileOutputStream(CONFIG_FILE); XMLOutputFactory factory = XMLOutputFactory.newInstance(); try { XMLStreamWriter xml = factory.createXMLStreamWriter(out); xml.writeStartDocument(); xml.writeStartElement("jefmon-config"); xml.writeStartElement("instance-name"); xml.writeCharacters(config.getInstanceName()); xml.writeEndElement(); xml.writeStartElement("default-refresh-interval"); xml.writeCharacters(Integer.toString(config.getDefaultRefreshInterval())); xml.writeEndElement(); saveRemoteUrls(xml, config.getRemoteInstanceUrls()); saveMonitoredPaths(xml, config.getMonitoredPaths()); saveJobActions(xml, config.getJobActions()); xml.writeEndElement(); xml.writeEndDocument(); xml.flush(); xml.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } out.close(); }
From source file:com.norconex.jefmon.model.ConfigurationDAO.java
private static void saveRemoteUrls(XMLStreamWriter xml, String[] remoteUrls) throws XMLStreamException { if (remoteUrls == null) { return;// w ww. j a v a 2 s. c o m } xml.writeStartElement("remote-instances"); for (String url : remoteUrls) { xml.writeStartElement("url"); xml.writeCharacters(url); xml.writeEndElement(); } xml.writeEndElement(); }
From source file:com.norconex.jefmon.model.ConfigurationDAO.java
private static void saveMonitoredPaths(XMLStreamWriter xml, File[] monitoredPaths) throws XMLStreamException { if (monitoredPaths == null) { return;//from w w w. j a va 2 s . co m } xml.writeStartElement("monitored-paths"); for (File path : monitoredPaths) { xml.writeStartElement("path"); xml.writeCharacters(path.getAbsolutePath()); xml.writeEndElement(); } xml.writeEndElement(); }