Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamWriter#writeCharacters()

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamWriter#writeCharacters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CamelSubsystemWriter.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    ModelNode node = context.getModelNode();

    if (node.hasDefined(ModelConstants.CONTEXT)) {
        ModelNode properties = node.get(ModelConstants.CONTEXT);
        for (String key : new TreeSet<String>(properties.keys())) {
            String val = properties.get(key).get(ModelConstants.VALUE).asString();
            writer.writeStartElement(Element.CAMEL_CONTEXT.getLocalName());
            writer.writeAttribute(Attribute.ID.getLocalName(), key);
            writer.writeCharacters(val);
            writer.writeEndElement();
        }
    }

    writer.writeEndElement();
}
 
Example 2
Source File: PatchXmlUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static void writeAppliesToVersions(XMLExtendedStreamWriter writer, List<String> appliesTo) throws XMLStreamException {
        for (String version : appliesTo) {
//            writer.writeStartElement(Element.APPLIES_TO_VERSION.name);
            writer.writeCharacters(version);
            writer.writeEndElement();
        }
    }
 
Example 3
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void writeCharacters(XMLExtendedStreamWriter writer, String content) throws XMLStreamException {
    if (content.indexOf('\n') > -1) {
        // Multiline content. Use the overloaded variant that staxmapper will format
        writer.writeCharacters(content);
    } else {
        // Staxmapper will just output the chars without adding newlines if this is used
        char[] chars = content.toCharArray();
        writer.writeCharacters(chars, 0, chars.length);
    }
}
 
Example 4
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void writeCharacters(XMLExtendedStreamWriter writer, String content) throws XMLStreamException {
    if (content.indexOf('\n') > -1) {
        // Multiline content. Use the overloaded variant that staxmapper will format
        writer.writeCharacters(content);
    } else {
        // Staxmapper will just output the chars without adding newlines if this is used
        char[] chars = content.toCharArray();
        writer.writeCharacters(chars, 0, chars.length);
    }
}
 
Example 5
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeAllowedClockSkew(XMLExtendedStreamWriter writer, ModelNode allowedClockSkew) throws XMLStreamException {
    if (!allowedClockSkew.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.ALLOWED_CLOCK_SKEW);
    AllowedClockSkew.ALLOWED_CLOCK_SKEW_UNIT.getAttributeMarshaller().marshallAsAttribute(AllowedClockSkew.ALLOWED_CLOCK_SKEW_UNIT, allowedClockSkew, false, writer);
    ModelNode allowedClockSkewValue = allowedClockSkew.get(Constants.Model.ALLOWED_CLOCK_SKEW_VALUE);
    char[] chars = allowedClockSkewValue.asString().toCharArray();
    writer.writeCharacters(chars, 0, chars.length);
    writer.writeEndElement();
}
 
Example 6
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeAllowedClockSkew(XMLExtendedStreamWriter writer, ModelNode allowedClockSkew) throws XMLStreamException {
    if (!allowedClockSkew.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.ALLOWED_CLOCK_SKEW);
    AllowedClockSkew.ALLOWED_CLOCK_SKEW_UNIT.getAttributeMarshaller().marshallAsAttribute(AllowedClockSkew.ALLOWED_CLOCK_SKEW_UNIT, allowedClockSkew, false, writer);
    ModelNode allowedClockSkewValue = allowedClockSkew.get(Constants.Model.ALLOWED_CLOCK_SKEW_VALUE);
    char[] chars = allowedClockSkewValue.asString().toCharArray();
    writer.writeCharacters(chars, 0, chars.length);
    writer.writeEndElement();
}
 
Example 7
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void writeList(XMLExtendedStreamWriter writer, ModelNode context, AttributeDefinition def, String elementName) throws XMLStreamException {
    if (!context.get(def.getName()).isDefined()) {
        return;
    }

    writer.writeStartElement(def.getXmlName());
    ModelNode modules = context.get(def.getName());
    for (ModelNode module : modules.asList()) {
        writer.writeStartElement(elementName);
        writer.writeCharacters(module.asString());
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
 
Example 8
Source File: WriteUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void writeNewLine(XMLExtendedStreamWriter writer) throws XMLStreamException {
    writer.writeCharacters(NEW_LINE, 0, 1);
}
 
Example 9
Source File: ModuleConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected static void writeNewLine(XMLExtendedStreamWriter writer) throws XMLStreamException {
    writer.writeCharacters(NEW_LINE, 0, 1);
}