List of usage examples for org.jdom2 CDATA CDATA
public CDATA(final String string)
CDATA
node, with the supplied string value as its character content. From source file:org.polago.deployconf.task.AbstractTask.java
License:Open Source License
/** * Create a JDOM CDATA Element with the given name and possibly text. * * @param name the element name// w w w. j a v a2 s . c o m * @param text the element text or null * @return a JDOM Element instance */ protected Element createJDOMCDATAElement(String name, String text) { Element result = new Element(name); if (text != null) { result.addContent(new CDATA(text)); } return result; }
From source file:org.rascalmpl.library.lang.xml.DOM.java
License:Open Source License
private Content nodeToContent(IConstructor n) { if (n.getConstructorType() == Factory.Node_element) { return nodeToElement(n); }/*w w w . ja v a 2 s.co m*/ if (n.getConstructorType() == Factory.Node_pi) { IString target = (IString) n.get(0); IString data = (IString) n.get(1); return new ProcessingInstruction(target.getValue(), data.getValue()); } if (n.getConstructorType() == Factory.Node_charRef) { IInteger code = (IInteger) n.get(0); int c = java.lang.Integer.parseInt(code.getStringRepresentation()); return new Text(new java.lang.String(Character.toChars(c))); } if (n.getConstructorType() == Factory.Node_entityRef) { return new EntityRef(((IString) n.get(0)).getValue()); } java.lang.String text = ((IString) n.get(0)).getValue(); if (n.getConstructorType() == Factory.Node_cdata) { return new CDATA(text); } if (n.getConstructorType() == Factory.Node_charData) { return new Text(text); } if (n.getConstructorType() == Factory.Node_comment) { return new Comment(text); } wellformednessError(); return null; }
From source file:org.rometools.feed.module.content.io.ContentModuleGenerator.java
License:Open Source License
protected Element generateCDATAElement(String name, String value) { Element element = new Element(name, CONTENT_NS); CDATA cdata = new CDATA(value); element.addContent(cdata);//from w ww .j a va 2s. c o m return element; }
From source file:password.pwm.config.stored.StoredConfigurationImpl.java
License:Open Source License
public void writeLocaleBundleMap(final String bundleName, final String keyName, final Map<String, String> localeMap) { ResourceBundle theBundle = null; for (final PwmLocaleBundle bundle : PwmLocaleBundle.values()) { if (bundle.getTheClass().getName().equals(bundleName)) { theBundle = ResourceBundle.getBundle(bundleName); }// ww w . ja v a 2 s . c om } if (theBundle == null) { LOGGER.info("ignoring unknown locale bundle for bundle=" + bundleName + ", key=" + keyName); return; } if (theBundle.getString(keyName) == null) { LOGGER.info("ignoring unknown key for bundle=" + bundleName + ", key=" + keyName); return; } resetLocaleBundleMap(bundleName, keyName); if (localeMap == null || localeMap.isEmpty()) { LOGGER.info("cleared locale bundle map for bundle=" + bundleName + ", key=" + keyName); return; } preModifyActions(); changeLog.updateChangeLog(bundleName, keyName, localeMap); try { domModifyLock.writeLock().lock(); final Element localeBundleElement = new Element("localeBundle"); localeBundleElement.setAttribute("bundle", bundleName); localeBundleElement.setAttribute("key", keyName); for (final String locale : localeMap.keySet()) { final Element valueElement = new Element("value"); if (locale != null && locale.length() > 0) { valueElement.setAttribute("locale", locale); } valueElement.setContent(new CDATA(localeMap.get(locale))); localeBundleElement.addContent(valueElement); } localeBundleElement.setAttribute(XML_ATTRIBUTE_MODIFY_TIME, JavaHelper.toIsoDate(Instant.now())); document.getRootElement().addContent(localeBundleElement); } finally { domModifyLock.writeLock().unlock(); } }
From source file:password.pwm.config.StoredConfiguration.java
License:Open Source License
public void writeLocaleBundleMap(final String bundleName, final String keyName, final Map<String, String> localeMap) { ResourceBundle theBundle = null; for (final PwmLocaleBundle bundle : PwmLocaleBundle.values()) { if (bundle.getTheClass().getName().equals(bundleName)) { theBundle = ResourceBundle.getBundle(bundleName); }/* w w w. j a va 2 s . c o m*/ } if (theBundle == null) { LOGGER.info("ignoring unknown locale bundle for bundle=" + bundleName + ", key=" + keyName); return; } if (theBundle.getString(keyName) == null) { LOGGER.info("ignoring unknown key for bundle=" + bundleName + ", key=" + keyName); return; } resetLocaleBundleMap(bundleName, keyName); if (localeMap == null || localeMap.isEmpty()) { LOGGER.info("cleared locale bundle map for bundle=" + bundleName + ", key=" + keyName); return; } preModifyActions(); changeLog.updateChangeLog(bundleName, keyName, localeMap); try { domModifyLock.writeLock().lock(); final Element localeBundleElement = new Element("localeBundle"); localeBundleElement.setAttribute("bundle", bundleName); localeBundleElement.setAttribute("key", keyName); for (final String locale : localeMap.keySet()) { final Element valueElement = new Element("value"); if (locale != null && locale.length() > 0) { valueElement.setAttribute("locale", locale); } valueElement.setContent(new CDATA(localeMap.get(locale))); localeBundleElement.addContent(valueElement); } localeBundleElement.setAttribute(XML_ATTRIBUTE_MODIFY_TIME, PwmConstants.DEFAULT_DATETIME_FORMAT.format(new Date())); document.getRootElement().addContent(localeBundleElement); } finally { domModifyLock.writeLock().unlock(); } }
From source file:password.pwm.config.value.ChallengeValue.java
License:Open Source License
public List<Element> toXmlValues(final String valueElementName) { final List<Element> returnList = new ArrayList<>(); for (final String locale : values.keySet()) { for (final ChallengeItemBean value : values.get(locale)) { if (value != null) { final Element valueElement = new Element(valueElementName); valueElement.addContent(new CDATA(JsonUtil.serialize(value))); if (locale != null && locale.length() > 0) { valueElement.setAttribute("locale", locale); }// w w w .jav a2s. c o m returnList.add(valueElement); } } } return returnList; }
From source file:password.pwm.config.value.LocalizedStringArrayValue.java
License:Open Source License
public List<Element> toXmlValues(final String valueElementName) { final List<Element> returnList = new ArrayList<>(); for (final String locale : values.keySet()) { for (final String value : values.get(locale)) { final Element valueElement = new Element(valueElementName); valueElement.addContent(new CDATA(value)); if (locale != null && locale.length() > 0) { valueElement.setAttribute("locale", locale); }//from w ww. java2s .c o m returnList.add(valueElement); } } return returnList; }
From source file:password.pwm.config.value.LocalizedStringValue.java
License:Open Source License
public List<Element> toXmlValues(final String valueElementName) { final List<Element> returnList = new ArrayList<>(); for (final String locale : value.keySet()) { final String value = this.value.get(locale); final Element valueElement = new Element(valueElementName); valueElement.addContent(new CDATA(value)); if (locale != null && locale.length() > 0) { valueElement.setAttribute("locale", locale); }//from w w w . j a va 2 s . c om returnList.add(valueElement); } return returnList; }
From source file:password.pwm.config.value.StringArrayValue.java
License:Open Source License
public List<Element> toXmlValues(final String valueElementName) { final List<Element> returnList = new ArrayList<>(); for (final String value : this.values) { final Element valueElement = new Element(valueElementName); valueElement.addContent(new CDATA(value)); returnList.add(valueElement);/* www . j av a 2s . com*/ } return returnList; }
From source file:password.pwm.config.value.StringValue.java
License:Open Source License
public List<Element> toXmlValues(final String valueElementName) { final Element valueElement = new Element(valueElementName); valueElement.addContent(new CDATA(value)); return Collections.singletonList(valueElement); }