List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute
public void writeAttribute(String localName, String value) throws XMLStreamException;
From source file:com.norconex.committer.core.impl.MultiCommitter.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {//from ww w . ja v a2s . c o m XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("committer"); writer.writeAttribute("class", getClass().getCanonicalName()); for (ICommitter committer : committers) { writer.flush(); if (!(committer instanceof IXMLConfigurable)) { LOG.error("Cannot save committer to XML as it does not " + "implement IXMLConfigurable: " + committer); } ((IXMLConfigurable) committer).saveToXML(out); } writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.predic8.membrane.core.interceptor.balancer.Node.java
@Override public void write(XMLStreamWriter out) throws XMLStreamException { out.writeStartElement("node"); out.writeAttribute("host", host); out.writeAttribute("port", "" + port); out.writeEndElement();/*from w w w. j a v a 2 s . c o m*/ }
From source file:com.norconex.collector.core.filter.impl.RegexMetadataFilter.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {//from w w w.j ava 2 s. c o m XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("filter"); writer.writeAttribute("class", getClass().getCanonicalName()); super.saveToXML(writer); writer.writeAttribute("caseSensitive", Boolean.toString(caseSensitive)); writer.writeAttribute("field", field); writer.writeCharacters(regex == null ? "" : regex); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.norconex.collector.http.robot.impl.DefaultRobotsMetaProvider.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {//from w w w . ja va2 s. co m XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("robotsMeta"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("headersPrefix"); if (headersPrefix != null) { writer.writeCharacters(headersPrefix); } writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.norconex.jef4.log.FileLogManager.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {//from w w w. j a v a2 s .c om XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("logManager"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("logDir"); writer.writeCharacters(new File(logdir).getAbsolutePath()); writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.predic8.membrane.core.http.xml.Response.java
@Override public void write(XMLStreamWriter out) throws XMLStreamException { out.writeStartElement("http", ELEMENT_NAME, Constants.HTTP_NS); out.writeNamespace("http", Constants.HTTP_NS); out.writeStartElement("status"); out.writeAttribute("code", "" + statusCode); out.writeCharacters(statusMessage);//from www .jav a 2 s .c o m out.writeEndElement(); writeIfNotNull(headers, out); if (body != null) { out.writeStartElement("body"); body.write(out); out.writeEndElement(); } out.writeEndElement(); }
From source file:com.norconex.committer.core.impl.FileSystemCommitter.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {/* www . j a v a 2 s . co m*/ XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("committer"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("directory"); writer.writeCharacters(directory); writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.norconex.collector.http.fetch.impl.DefaultDocumentFetcher.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {/*w ww . j a va 2 s.com*/ XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("httpDocumentFetcher"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("validStatusCodes"); if (validStatusCodes != null) { writer.writeCharacters(StringUtils.join(validStatusCodes)); } writer.writeEndElement(); writer.writeStartElement("headersPrefix"); if (headersPrefix != null) { writer.writeCharacters(headersPrefix); } writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }
From source file:com.norconex.collector.http.url.impl.DefaultURLExtractor.java
@Override public void saveToXML(Writer out) throws IOException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); try {/*w w w. ja v a2s . com*/ XMLStreamWriter writer = factory.createXMLStreamWriter(out); writer.writeStartElement("urlExtractor"); writer.writeAttribute("class", getClass().getCanonicalName()); writer.writeStartElement("maxURLLength"); writer.writeCharacters(Integer.toString(maxURLLength)); writer.writeEndElement(); writer.writeEndElement(); writer.flush(); writer.close(); } catch (XMLStreamException e) { throw new IOException("Cannot save as XML.", e); } }