Search in sources :

Example 6 with Content

use of com.google.api.ads.admanager.axis.v202202.Content in project pom-manipulation-ext by release-engineering.

the class PomIO method write.

private void write(final Project project, final File pom, final Model model) throws ManipulationException {
    try {
        final String manifestInformation = project.isInheritanceRoot() ? ManifestUtils.getManifestInformation() : null;
        MavenJDOMWriter mjw = new MavenJDOMWriter(model);
        // We possibly could store the EOL type in the Project when we first read
        // the file but we would then have to do a dual read, then write as opposed
        // to a read, then read + write now.
        LineSeparator ls = determineEOL(pom);
        mjw.setLineSeparator(ls);
        mjw.write(model, pom, new DocumentModifier() {

            @Override
            public void postProcess(final Document doc) {
                // Only add the modified by to the top level pom.
                if (project.isExecutionRoot()) {
                    final Iterator<Content> it = doc.getContent(new ContentFilter(ContentFilter.COMMENT)).iterator();
                    while (it.hasNext()) {
                        final Comment c = (Comment) it.next();
                        if (c.toString().contains(MODIFIED_BY)) {
                            it.remove();
                        }
                    }
                    doc.addContent(Collections.<Content>singletonList(new Comment("\nModified by POM Manipulation Extension for Maven " + manifestInformation + "\n")));
                }
            }
        });
    } catch (final IOException e) {
        throw new ManipulationException("Failed to read POM for rewrite: %s. Reason: %s", e, pom, e.getMessage());
    } catch (final JDOMException e) {
        throw new ManipulationException("Failed to parse POM for rewrite: %s. Reason: %s", e, pom, e.getMessage());
    }
}
Also used : Comment(org.jdom2.Comment) IOException(java.io.IOException) MavenJDOMWriter(org.apache.maven.model.io.jdom.MavenJDOMWriter) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException) LineSeparator(org.jdom2.output.LineSeparator) ContentFilter(org.jdom2.filter.ContentFilter) DocumentModifier(org.apache.maven.io.util.DocumentModifier) Content(org.jdom2.Content) Iterator(java.util.Iterator) ManipulationException(org.commonjava.maven.ext.common.ManipulationException)

Example 7 with Content

use of com.google.api.ads.admanager.axis.v202202.Content in project mycore by MyCoRe-Org.

the class MCRMetaXML method createXML.

/**
 * This method create a XML stream for all data in this class, defined by
 * the MyCoRe XML MCRMetaLangText definition for the given subtag.
 *
 * @exception MCRException
 *                if the content of this class is not valid
 * @return a JDOM Element with the XML MCRMetaLangText part
 */
@Override
public org.jdom2.Element createXML() throws MCRException {
    Element elm = super.createXML();
    List<Content> addedContent = new ArrayList<>(content.size());
    cloneListContent(addedContent, content);
    elm.addContent(addedContent);
    return elm;
}
Also used : Content(org.jdom2.Content) JsonElement(com.google.gson.JsonElement) Element(org.jdom2.Element) ArrayList(java.util.ArrayList)

Example 8 with Content

use of com.google.api.ads.admanager.axis.v202202.Content in project mycore by MyCoRe-Org.

the class MCRSwapElements method swap.

public static MCRChangeData swap(Element parent, int posA, int posB) {
    Content a = parent.getContent().get(posA);
    Content b = parent.getContent().get(posB);
    return swap(parent, posA, a, posB, b);
}
Also used : Content(org.jdom2.Content)

Example 9 with Content

use of com.google.api.ads.admanager.axis.v202202.Content 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 10 with Content

use of com.google.api.ads.admanager.axis.v202202.Content in project jspwiki by apache.

the class MarkdownTheadDecorator method decorate.

/**
 * {@inheritDoc}
 */
@Override
public void decorate(final Element element) throws JDOMException {
    super.decorate(element);
    final Content cNestedTr = element.getContent().get(0);
    if (cNestedTr instanceof Element) {
        final Element nestedTr = (Element) cNestedTr;
        final int ths = nestedTr.getContent().size();
        if (ths > 0) {
            for (int i = 0; i < ths; i++) {
                out.print("|---");
            }
        }
        out.println();
    }
}
Also used : Content(org.jdom2.Content) Element(org.jdom2.Element)

Aggregations

Content (org.jdom2.Content)12 Element (org.jdom2.Element)8 ArrayList (java.util.ArrayList)3 Document (org.jdom2.Document)3 Text (org.jdom2.Text)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)2 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)2 Content (com.google.api.ads.admanager.axis.v202108.Content)2 ContentPage (com.google.api.ads.admanager.axis.v202108.ContentPage)2 ContentServiceInterface (com.google.api.ads.admanager.axis.v202108.ContentServiceInterface)2 Content (com.google.api.ads.admanager.axis.v202111.Content)2 ContentPage (com.google.api.ads.admanager.axis.v202111.ContentPage)2 ContentServiceInterface (com.google.api.ads.admanager.axis.v202111.ContentServiceInterface)2 Content (com.google.api.ads.admanager.axis.v202202.Content)2 ContentPage (com.google.api.ads.admanager.axis.v202202.ContentPage)2 ContentServiceInterface (com.google.api.ads.admanager.axis.v202202.ContentServiceInterface)2 JsonElement (com.google.gson.JsonElement)2 Random (java.util.Random)2 AdUnitTargeting (com.google.api.ads.admanager.axis.v202202.AdUnitTargeting)1