List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:org.eclipse.gyrex.logback.config.model.Appender.java
private void writeEncoder(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("encoder"); writer.writeStartElement("pattern"); String text = getPattern();//from ww w . j a v a2 s . c om if (StringUtils.isBlank(text)) { text = preferShortPattern() ? "${PATTERN_SHORT}" : "${PATTERN_LONG}"; } else if (StringUtils.containsIgnoreCase(text, "PATTERN_LONG")) { text = "${PATTERN_LONG}"; } else if (StringUtils.containsIgnoreCase(text, "PATTERN_SHORT")) { text = "${PATTERN_SHORT}"; } writer.writeCharacters(text); writer.writeEndElement(); writer.writeEndElement(); }
From source file:org.eclipse.gyrex.logback.config.model.FileAppender.java
@Override protected void writeAppenderContent(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("file"); writer.writeCharacters(String.format("${BASE_PATH}/%s", getFileName())); writer.writeEndElement(); writeRotation(writer);/*from w ww . j av a 2 s. c om*/ }
From source file:org.eclipse.gyrex.logback.config.model.FileAppender.java
private void writeSizeBasedRotation(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("rollingPolicy"); writer.writeAttribute("class", FixedWindowRollingPolicy.class.getName()); {/*w ww .j a v a 2 s.co m*/ writer.writeStartElement("fileNamePattern"); writer.writeCharacters(StringUtils.substringBeforeLast(getFileName(), ".")); writer.writeCharacters(".%i"); final String extension = StringUtils.substringAfter(getFileName(), "."); if (StringUtils.isNotBlank(extension)) { writer.writeCharacters("."); writer.writeCharacters(extension); } if (isCompressRotatedLogs()) { writer.writeCharacters(".gz"); } writer.writeEndElement(); writer.writeStartElement("minIndex"); writer.writeCharacters("1"); writer.writeEndElement(); writer.writeStartElement("maxIndex"); writer.writeCharacters("3"); writer.writeEndElement(); } writer.writeEndElement(); writer.writeStartElement("triggeringPolicy"); writer.writeAttribute("class", SizeBasedTriggeringPolicy.class.getName()); { String maxFileSize = getMaxFileSize(); if (StringUtils.isBlank(maxFileSize)) { maxFileSize = "1MB"; } writer.writeStartElement("maxFileSize"); writer.writeCharacters(maxFileSize); writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.eclipse.gyrex.logback.config.model.FileAppender.java
private void writeTimeBasedRotation(final XMLStreamWriter writer, final RotationPolicy policy) throws XMLStreamException { writer.writeStartElement("rollingPolicy"); writer.writeAttribute("class", TimeBasedRollingPolicy.class.getName()); {/*from www . java 2 s. co m*/ writer.writeStartElement("fileNamePattern"); writer.writeCharacters(StringUtils.substringBeforeLast(getFileName(), ".")); switch (policy) { case MONTHLY: writer.writeCharacters(".%d{yyyyMM}"); break; case WEEKLY: writer.writeCharacters(".%d{yyyyww}"); break; case DAILY: default: writer.writeCharacters(".%d{yyyyMMdd}"); break; } final String extension = StringUtils.substringAfter(getFileName(), "."); if (StringUtils.isNotBlank(extension)) { writer.writeCharacters("."); writer.writeCharacters(extension); } if (isCompressRotatedLogs()) { writer.writeCharacters(".gz"); } writer.writeEndElement(); writer.writeStartElement("maxHistory"); String maxHistory = getMaxHistory(); if (StringUtils.isBlank(maxHistory)) { maxHistory = policy == RotationPolicy.DAILY ? "30" : policy == RotationPolicy.WEEKLY ? "52" : "12"; } writer.writeCharacters(maxHistory); writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.eclipse.gyrex.logback.config.model.LogbackConfig.java
/** * Serializes the Logback configuration to the specified XML writer. * <p>/*from ww w.j a va2s. co m*/ * The XML is expected to be readable by Logback. As such, it depends * heavily on Logback and may be bound to different evolution/compatibility * rules. * </p> * * @param writer * the stream writer * @throws XMLStreamException */ @Override public void toXml(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartDocument(); writer.writeStartElement("configuration"); writer.writeAttribute("scan", "true"); writer.writeAttribute("scanPeriod", "2 minutes"); writeCommonProperties(writer); writeJulLevelChangePropagator(writer); for (final Appender appender : getAppenders().values()) { appender.toXml(writer); } for (final Logger logger : getLoggers().values()) { logger.toXml(writer); } writeRootLogger(writer); writer.writeEndElement(); writer.writeEndDocument(); }
From source file:org.eclipse.gyrex.logback.config.model.LogbackConfig.java
private void writeJulLevelChangePropagator(final XMLStreamWriter writer) throws XMLStreamException { writer.writeComment("propagate log level changes to JUL"); writer.writeStartElement("contextListener"); writer.writeAttribute("class", LevelChangePropagator.class.getName()); {//from w w w .j a v a 2s . c o m writer.writeStartElement("resetJUL"); writer.writeCData("true"); writer.writeEndElement(); } writer.writeEndElement(); }
From source file:org.eclipse.gyrex.logback.config.model.LogbackConfig.java
private void writeRootLogger(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("root"); writer.writeAttribute("level", getDefaultLevel().toString()); for (final String appenderRef : getDefaultAppenders()) { writer.writeEmptyElement("appender-ref"); writer.writeAttribute("ref", appenderRef); }/*from w ww .jav a 2 s. c o m*/ writer.writeEndElement(); }
From source file:org.eclipse.koneki.protocols.omadm.client.basic.DMBasicSession.java
private void writeMessage(final OutputStream out) throws XMLStreamException { final XMLStreamWriter writer = this.dmClient.createXMLStreamWriter(out, ENCODING); writer.writeStartDocument(ENCODING, "1.0"); //$NON-NLS-1$ // CHECKSTYLE:OFF (imbricated blocks) {//from w w w . j a v a 2s . c o m writer.writeStartElement("SyncML"); //$NON-NLS-1$ writer.writeAttribute("xmlns", "SYNCML:SYNCML1.2"); //$NON-NLS-1$//$NON-NLS-2$ { writer.writeStartElement("SyncHdr"); //$NON-NLS-1$ { writer.writeStartElement("VerDTD"); //$NON-NLS-1$ writer.writeCharacters("1.2"); //$NON-NLS-1$ writer.writeEndElement(); writer.writeStartElement("VerProto"); //$NON-NLS-1$ writer.writeCharacters("DM/1.2"); //$NON-NLS-1$ writer.writeEndElement(); writer.writeStartElement("SessionID"); //$NON-NLS-1$ writer.writeCharacters(this.sessionId); writer.writeEndElement(); writer.writeStartElement("MsgID"); //$NON-NLS-1$ writer.writeCharacters(String.valueOf(this.idGenerator.nextMsgID())); writer.writeEndElement(); writer.writeStartElement("Target"); //$NON-NLS-1$ { writer.writeStartElement("LocURI"); //$NON-NLS-1$ writer.writeCharacters(this.server.toString()); writer.writeEndElement(); } writer.writeEndElement(); writer.writeStartElement("Source"); //$NON-NLS-1$ { writer.writeStartElement("LocURI"); //$NON-NLS-1$ writer.writeCharacters(this.client.toString()); writer.writeEndElement(); } writer.writeEndElement(); /* * Add basic authentication */ writer.writeStartElement("Cred"); //$NON-NLS-1$ { writer.writeStartElement("Meta"); //$NON-NLS-1$ { writer.writeStartElement("Format"); //$NON-NLS-1$ writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$ writer.writeCharacters("b64"); //$NON-NLS-1$ writer.writeEndElement(); writer.writeStartElement("Type"); //$NON-NLS-1$ writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$ writer.writeCharacters("syncml:auth-basic"); //$NON-NLS-1$ writer.writeEndElement(); } writer.writeEndElement(); writer.writeStartElement("Data"); //$NON-NLS-1$ writer.writeCharacters(userAuth); writer.writeEndElement(); } writer.writeEndElement(); /* * End authentication */ } writer.writeEndElement(); writer.writeStartElement("SyncBody"); //$NON-NLS-1$ { writeStatus(writer); if (!this.isClientAuthenticated) { writeAlert(writer, "1201"); //$NON-NLS-1$ writeGenericAlert(writer, this.genericAlerts); writeReplace(writer, this.devInfoNodes); } writer.writeStartElement("Final"); //$NON-NLS-1$ writer.writeEndElement(); } writer.writeEndElement(); } writer.writeEndElement(); } // CHECKSTYLE:ON writer.writeEndDocument(); writer.flush(); writer.close(); }
From source file:org.eclipse.koneki.protocols.omadm.client.basic.DMBasicSession.java
private void writeStatus(final XMLStreamWriter writer) throws XMLStreamException { while (this.statusManager.isValidStatus()) { // CHECKSTYLE:OFF (imbricated blocks) writer.writeStartElement("Status"); //$NON-NLS-1$ {//from w ww.ja va 2 s .co m writer.writeStartElement("CmdID"); //$NON-NLS-1$ writer.writeCharacters(String.valueOf(this.idGenerator.nextCmdID())); writer.writeEndElement(); writer.writeStartElement("MsgRef"); //$NON-NLS-1$ writer.writeCharacters(this.statusManager.getMsgRef()); writer.writeEndElement(); writer.writeStartElement("CmdRef"); //$NON-NLS-1$ writer.writeCharacters(this.statusManager.getCmdRef()); writer.writeEndElement(); writer.writeStartElement("Cmd"); //$NON-NLS-1$ writer.writeCharacters(this.statusManager.getCmd()); writer.writeEndElement(); for (final String targetRef : this.statusManager.getTargetRef()) { writer.writeStartElement("TargetRef"); //$NON-NLS-1$ writer.writeCharacters(targetRef); writer.writeEndElement(); } for (final String sourceRef : this.statusManager.getSourceRef()) { writer.writeStartElement("SourceRef"); //$NON-NLS-1$ writer.writeCharacters(sourceRef); writer.writeEndElement(); } writer.writeStartElement("Data"); //$NON-NLS-1$ writer.writeCharacters(this.statusManager.getStatusCode()); writer.writeEndElement(); } writer.writeEndElement(); if (!this.statusManager.getResults().isEmpty()) { writer.writeStartElement("Results"); //$NON-NLS-1$ { writer.writeStartElement("CmdID"); //$NON-NLS-1$ writer.writeCharacters(String.valueOf(this.idGenerator.nextCmdID())); writer.writeEndElement(); writer.writeStartElement("MsgRef"); //$NON-NLS-1$ writer.writeCharacters(this.statusManager.getMsgRef()); writer.writeEndElement(); writer.writeStartElement("CmdRef"); //$NON-NLS-1$ writer.writeCharacters(this.statusManager.getCmdRef()); writer.writeEndElement(); // final String globalFormat = this.statusManager.getGlobalFormat(); // final String globalType = this.statusManager.getGlobalType(); // if (globalFormat != null || globalType != null) { // writer.writeStartElement("Meta"); // { // if (globalFormat != null) { // writer.writeStartElement("Format"); // writer.writeAttribute("xmlns", "syncml:metinf"); // writer.writeCharacters(globalFormat); // writer.writeEndElement(); // } // if (globalType != null) { // writer.writeStartElement("Type"); // writer.writeAttribute("xmlns", "syncml:metinf"); // writer.writeCharacters(globalType); // writer.writeEndElement(); // } // } // writer.writeEndElement(); // } for (final Results results : this.statusManager.getResults()) { writer.writeStartElement("Item"); //$NON-NLS-1$ { writer.writeStartElement("Source"); //$NON-NLS-1$ { writer.writeStartElement("LocURI"); //$NON-NLS-1$ writer.writeCharacters(results.getSourceURI()); writer.writeEndElement(); } writer.writeEndElement(); // if (globalFormat == null || globalType == null) { writer.writeStartElement("Meta"); //$NON-NLS-1$ { // if (globalFormat == null) { writer.writeStartElement("Format"); //$NON-NLS-1$ writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$ writer.writeCharacters(results.getFormat()); writer.writeEndElement(); // } // if (globalType == null) { writer.writeStartElement("Type"); //$NON-NLS-1$ writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$ writer.writeCharacters(results.getType()); writer.writeEndElement(); // } } writer.writeEndElement(); // } writer.writeStartElement("Data"); //$NON-NLS-1$ writer.writeCharacters(results.getData()); writer.writeEndElement(); } writer.writeEndElement(); } } writer.writeEndElement(); } // CHECKSTYLE:ON this.statusManager.nextStatus(); } }
From source file:org.eclipse.koneki.protocols.omadm.client.basic.DMBasicSession.java
private void writeAlert(final XMLStreamWriter writer, final String statusCode) throws XMLStreamException { writer.writeStartElement("Alert"); //$NON-NLS-1$ // CHECKSTYLE:OFF (imbricated blocks) {/* w w w .j av a 2 s . co m*/ writer.writeStartElement("CmdID"); //$NON-NLS-1$ writer.writeCharacters(String.valueOf(this.idGenerator.nextCmdID())); writer.writeEndElement(); writer.writeStartElement("Data"); //$NON-NLS-1$ writer.writeCharacters(statusCode); writer.writeEndElement(); } // CHECKSTYLE:ON writer.writeEndElement(); }