Search in sources :

Example 11 with Text

use of org.geotoolkit.swe.xml.v101.Text in project CodenameOne by codenameone.

the class JDomContentHelper method isMultiNewLine.

/**
 * Check if content is a multiline text, i.e. \n\n (or more).<br>
 * * Maybe followed by an empty string.
 *
 * @param content the content to check
 * @return boolean
 */
static boolean isMultiNewLine(Content content) {
    if (content instanceof Text) {
        Text text = (Text) content;
        String value = text.getValue();
        return StringUtils.countMatches(value, "\n") > 1 && value.trim().length() == 0;
    }
    return false;
}
Also used : Text(org.jdom2.Text)

Example 12 with Text

use of org.geotoolkit.swe.xml.v101.Text in project CodenameOne by codenameone.

the class JDomConfiguration method recAddChild.

private void recAddChild(Element parent, Xpp3Dom child) {
    Element targetChild = insertNewElement(child.getName(), parent);
    targetChild.setContent(new Text(child.getValue()));
    for (String attrName : child.getAttributeNames()) {
        targetChild.setAttribute(attrName, child.getAttribute(attrName));
    }
    for (Xpp3Dom grandChild : child.getChildren()) {
        recAddChild(targetChild, grandChild);
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) JDomUtils.insertNewElement(org.apache.maven.model.jdom.util.JDomUtils.insertNewElement) Element(org.jdom2.Element) Text(org.jdom2.Text)

Example 13 with Text

use of org.geotoolkit.swe.xml.v101.Text in project CodenameOne by codenameone.

the class JDomModules method add.

@Override
public boolean add(String module) {
    Element newModule = new Element(POM_ELEMENT_MODULE, jdomElement.getNamespace());
    newModule.setText(module);
    jdomElement.addContent(jdomElement.getContentSize() - 1, asList(new Text("\n" + detectIndentation(jdomElement)), newModule));
    return super.add(module);
}
Also used : Element(org.jdom2.Element) Text(org.jdom2.Text)

Example 14 with Text

use of org.geotoolkit.swe.xml.v101.Text in project jspwiki by apache.

the class CreoleRenderer method renderElement.

/**
 * Renders an element into the StringBuilder given
 * @param ce element to render
 * @param sb stringbuilder holding the element render
 */
private void renderElement(final Element ce, final StringBuilder sb) {
    String endEl = EMPTY_STRING;
    for (int i = 0; i < ELEMENTS.length; i += 3) {
        if (ELEMENTS[i].equals(ce.getName())) {
            sb.append(ELEMENTS[i + 1]);
            endEl = ELEMENTS[i + 2];
        }
    }
    if (UL.equals(ce.getName())) {
        m_listCount++;
        m_listChar = '*';
    } else if (OL.equals(ce.getName())) {
        m_listCount++;
        m_listChar = '#';
    } else if (LI.equals(ce.getName())) {
        for (int i = 0; i < m_listCount; i++) sb.append(m_listChar);
        sb.append(ONE_SPACE);
    } else if (A.equals(ce.getName())) {
        final String href = ce.getAttributeValue(HREF_ATTRIBUTE);
        final String text = ce.getText();
        if (href.equals(text)) {
            sb.append(HREF_START).append(href).append(HREF_END);
        } else {
            sb.append(HREF_START).append(href).append(HREF_DELIMITER).append(text).append(HREF_END);
        }
        // Do not render anything else
        return;
    } else if (PRE.equals(ce.getName())) {
        sb.append(PRE_START);
        sb.append(ce.getText());
        sb.append(PRE_END);
        return;
    }
    // Go through the children
    for (final Content c : ce.getContent()) {
        if (c instanceof PluginContent) {
            final PluginContent pc = (PluginContent) c;
            if (pc.getPluginName().equals(PLUGIN_IMAGE)) {
                sb.append(IMG_START).append(pc.getParameter(PARAM_SRC)).append(IMG_END);
            } else {
                m_plugins.add(pc);
                sb.append(PLUGIN_START).append(pc.getPluginName()).append(ONE_SPACE).append(m_plugins.size()).append(PLUGIN_END);
            }
        } else if (c instanceof Text) {
            sb.append(((Text) c).getText());
        } else if (c instanceof Element) {
            renderElement((Element) c, sb);
        }
    }
    if (UL.equals(ce.getName()) || OL.equals(ce.getName())) {
        m_listCount--;
    } else if (P.equals(ce.getName())) {
        sb.append(LINEBREAK);
    }
    sb.append(endEl);
}
Also used : PluginContent(org.apache.wiki.parser.PluginContent) Content(org.jdom2.Content) Element(org.jdom2.Element) Text(org.jdom2.Text) PluginContent(org.apache.wiki.parser.PluginContent)

Example 15 with Text

use of org.geotoolkit.swe.xml.v101.Text in project mule-migration-assistant by mulesoft.

the class AbstractResponseBuilderMigrationStepTestCase method assertBasicStructure.

protected Text assertBasicStructure(Element element) {
    assertThat(element.getName(), is(SET_RESPONSE_TAG_NAME));
    assertThat(element.getNamespace(), is(HTTP_TRANSFORM_NAMESPACE));
    assertThat(element.getAttributes().size(), is(1));
    assertThat(element.getContentSize(), is(1));
    Element headersElement = (Element) element.getContent().get(0);
    assertThat(headersElement.getName(), is(HEADERS_TAG_NAME));
    assertThat(headersElement.getNamespace(), is(HTTP_TRANSFORM_NAMESPACE));
    assertThat(headersElement.getContentSize(), is(1));
    return (Text) headersElement.getContent().get(0);
}
Also used : Element(org.jdom2.Element) Text(org.jdom2.Text)

Aggregations

Text (org.jdom2.Text)70 Element (org.jdom2.Element)57 Test (org.junit.Test)27 ErrorResponseBuilderMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.http.ErrorResponseBuilderMigrationStep)11 ResponseBuilderMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.http.ResponseBuilderMigrationStep)11 Content (org.jdom2.Content)7 ArrayList (java.util.ArrayList)5 Document (org.jdom2.Document)5 StringWriter (java.io.StringWriter)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 URL (java.net.URL)3 Map (java.util.Map)3 AnyScalarPropertyType (org.geotoolkit.swe.xml.v101.AnyScalarPropertyType)3 DataArrayType (org.geotoolkit.swe.xml.v101.DataArrayType)3 XMLOutputter (org.jdom2.output.XMLOutputter)3 BaseText (com.adobe.cq.wcm.core.components.it.seljup.util.components.text.BaseText)2 Text (com.adobe.cq.wcm.core.components.it.seljup.util.components.text.v1.Text)2 Text (com.adobe.cq.wcm.core.components.it.seljup.util.components.text.v2.Text)2 IString (io.usethesource.vallang.IString)2 IOException (java.io.IOException)2