use of com.google.api.ads.admanager.axis.v202108.Content in project jspwiki by apache.
the class CreoleRenderer method renderElement.
/**
* Renders an element into the StringBuilder given
* @param ce
* @param sb
*/
private void renderElement(Element ce, 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())) {
String href = ce.getAttributeValue(HREF_ATTRIBUTE);
String text = ce.getText();
if (href.equals(text)) {
sb.append(HREF_START + href + HREF_END);
} else {
sb.append(HREF_START + href + HREF_DELIMITER + text + 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;
}
//
for (Iterator<Content> i = ce.getContent().iterator(); i.hasNext(); ) {
Content c = i.next();
if (c instanceof PluginContent) {
PluginContent pc = (PluginContent) c;
if (pc.getPluginName().equals(PLUGIN_IMAGE)) {
sb.append(IMG_START + pc.getParameter(PARAM_SRC) + IMG_END);
} else {
m_plugins.add(pc);
sb.append(PLUGIN_START + pc.getPluginName() + ONE_SPACE + m_plugins.size() + 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);
}
use of com.google.api.ads.admanager.axis.v202108.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());
}
}
use of com.google.api.ads.admanager.axis.v202108.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;
}
use of com.google.api.ads.admanager.axis.v202108.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);
}
use of com.google.api.ads.admanager.axis.v202108.Content in project googleads-java-lib by googleads.
the class GetRecentlyModifiedContent method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the ContentService.
ContentServiceInterface contentService = adManagerServices.get(session, ContentServiceInterface.class);
// Create a statement to get recently modified content based on lastModifiedDateTime.
// Changes to content bundle associations will update the lastModifiedDateTime, but
// CMS metadata changes may not change the lastModifiedDateTime.
StatementBuilder statementBuilder = new StatementBuilder().where("lastModifiedDateTime > :lastModifiedDateTime").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("lastModifiedDateTime", DateTimes.toDateTime(Instant.now().minus(Duration.standardDays(1L)), "America/New_York"));
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get content by statement.
ContentPage page = contentService.getContentByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Content content : page.getResults()) {
String contentBundleIds = content.getContentBundleIds() == null ? "[]" : Arrays.toString(content.getContentBundleIds());
System.out.printf("%d) Content with ID %d and name '%s' belonging to bundle IDs %s was found.%n", i++, content.getId(), content.getName(), contentBundleIds);
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Aggregations