use of org.omegat.filters3.Text in project jspwiki by apache.
the class CleanTextRenderer method getString.
/**
* {@inheritDoc}
*/
public String getString() throws IOException {
StringBuilder sb = new StringBuilder();
try {
XPath xp = XPath.newInstance(ALL_TEXT_NODES);
List nodes = xp.selectNodes(m_document.getDocument());
for (Iterator i = nodes.iterator(); i.hasNext(); ) {
Object el = i.next();
if (el instanceof Text) {
sb.append(((Text) el).getValue());
}
}
} catch (JDOMException e) {
log.error("Could not parse XPATH expression");
throw new IOException(e.getMessage());
}
return sb.toString();
}
use of org.omegat.filters3.Text 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 org.omegat.filters3.Text in project ldapchai by ldapchai.
the class ChaiResponseSet method challengeToXml.
private static Element challengeToXml(final Challenge loopChallenge, final Answer answer, final String elementName) throws ChaiOperationException {
final Element responseElement = new Element(elementName);
responseElement.addContent(new Element(XML_NODE_CHALLENGE).addContent(new Text(loopChallenge.getChallengeText())));
final Element answerElement = answer.toXml();
responseElement.addContent(answerElement);
responseElement.setAttribute(XML_ATTRIBUTE_ADMIN_DEFINED, String.valueOf(loopChallenge.isAdminDefined()));
responseElement.setAttribute(XML_ATTRIBUTE_REQUIRED, String.valueOf(loopChallenge.isRequired()));
responseElement.setAttribute(XNL_ATTRIBUTE_MIN_LENGTH, String.valueOf(loopChallenge.getMinLength()));
responseElement.setAttribute(XNL_ATTRIBUTE_MAX_LENGTH, String.valueOf(loopChallenge.getMaxLength()));
return responseElement;
}
use of org.omegat.filters3.Text in project pwm by pwm-project.
the class StoredConfigurationImpl method writeConfigProperty.
@Override
public void writeConfigProperty(final ConfigurationProperty propertyName, final String value) {
domModifyLock.writeLock().lock();
try {
final XPathExpression xp = XPathBuilder.xpathForConfigProperty(propertyName);
final List<Element> propertyElements = xp.evaluate(document);
for (final Element propertyElement : propertyElements) {
propertyElement.detach();
}
final Element propertyElement = new Element(XML_ELEMENT_PROPERTY);
propertyElement.setAttribute(new Attribute(XML_ATTRIBUTE_KEY, propertyName.getKey()));
propertyElement.setContent(new Text(value));
if (null == XPathBuilder.xpathForConfigProperties().evaluateFirst(document)) {
final Element configProperties = new Element(XML_ELEMENT_PROPERTIES);
configProperties.setAttribute(new Attribute(XML_ATTRIBUTE_TYPE, XML_ATTRIBUTE_VALUE_CONFIG));
document.getRootElement().addContent(configProperties);
}
final XPathExpression xp2 = XPathBuilder.xpathForConfigProperties();
final Element propertiesElement = (Element) xp2.evaluateFirst(document);
propertyElement.setAttribute(XML_ATTRIBUTE_MODIFY_TIME, JavaHelper.toIsoDate(Instant.now()));
propertiesElement.setAttribute(XML_ATTRIBUTE_MODIFY_TIME, JavaHelper.toIsoDate(Instant.now()));
propertiesElement.addContent(propertyElement);
} finally {
domModifyLock.writeLock().unlock();
}
}
use of org.omegat.filters3.Text in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class TextIT method setupBeforeEach.
@BeforeEach
public void setupBeforeEach() throws ClientException {
setComponentResources();
text = new Text();
setup();
}
Aggregations