本文整理汇总了Java中org.jdom.CDATA类的典型用法代码示例。如果您正苦于以下问题:Java CDATA类的具体用法?Java CDATA怎么用?Java CDATA使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CDATA类属于org.jdom包,在下文中一共展示了CDATA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPropertiesElementTo
import org.jdom.CDATA; //导入依赖的package包/类
private void addPropertiesElementTo(Element element) {
Element properties = new Element(PROPERTIES);
element.addContent(properties);
Browser browser = browserResult.getBrowser();
if (browser != null) {
addProperty(properties, BROWSER_FILE_NAME, browser.getFileName());
addProperty(properties, BROWSER_ID, String.valueOf(browserResult.getBrowser().getId()));
}
if (browserResult.completedTestRun()) {
addProperty(properties, JSUNIT_VERSION, browserResult.getJsUnitVersion());
addProperty(properties, USER_AGENT, browserResult.getUserAgent());
addProperty(properties, REMOTE_ADDRESS, browserResult.getRemoteAddress());
addProperty(properties, URL, browserResult.getBaseURL());
}
if (browserResult.hasServerSideExceptionStackTrace()) {
Element stackTrace = createPropertyElement(SERVER_SIDE_EXCEPTION_STACK_TRACE);
stackTrace.addContent(new CDATA(browserResult.getServerSideExceptionStackTrace()));
properties.addContent(stackTrace);
}
}
示例2: testCrashingRemoteURLs
import org.jdom.CDATA; //导入依赖的package包/类
public void testCrashingRemoteURLs() throws Exception {
action.setRemoteRunnerHitter(new BlowingUpRemoteServerHitter());
action.execute();
Element rootElement = action.getXmlRenderable().asXml();
List<CDATA> stackTraceElements = getCDATAExceptionStackTracesUnder(rootElement);
assertEquals(2, stackTraceElements.size());
for (CDATA stackTraceElement : stackTraceElements)
stackTraceElement.detach();
String xml = XmlUtility.asString(rootElement);
assertEquals(
"<remoteConfigurations>" +
"<remoteConfiguration remoteMachineURL=\"" + DummyConfigurationSource.REMOTE_URL_1 + "\">" +
"<configuration failedToConnect=\"true\" />" +
"</remoteConfiguration>" +
"<remoteConfiguration remoteMachineURL=\"" + DummyConfigurationSource.REMOTE_URL_2 + "\">" +
"<configuration failedToConnect=\"true\" />" +
"</remoteConfiguration>" +
"</remoteConfigurations>",
xml
);
}
示例3: execute
import org.jdom.CDATA; //导入依赖的package包/类
public String execute() throws Exception {
result = new Element("remoteConfigurations");
for (URL url : server.getConfiguration().getRemoteMachineURLs()) {
URL configurationURL = new URL(url.toString() + "/config");
Element configurationElement;
try {
Document document = hitter.hitURL(configurationURL);
configurationElement = document.getRootElement();
configurationElement.detach();
} catch (IOException e) {
configurationElement = new Element("configuration");
configurationElement.setAttribute("failedToConnect", String.valueOf(true));
configurationElement.addContent(new CDATA(e.toString()));
}
addRemoteConfigurationElementToResult(url, configurationElement);
}
return SUCCESS;
}
示例4: init
import org.jdom.CDATA; //导入依赖的package包/类
void init(Token tok, Lexer lex)
throws IOException, SyntaxException {
if (tok.getValue().equals(CDATA)) {
isCDATA = true;
int startingIndent = tok.getIndent();
tok = lex.next(startingIndent);
}
if (!(tok instanceof QuotedToken)) {
logCat.warn("TokenNotAllowedException");
throw new TokenNotAllowedException(lex.getSourceIdent(),
tok,
"Quoted String");
}
s = tok.getValue();
}
示例5: addParameter
import org.jdom.CDATA; //导入依赖的package包/类
private void addParameter(Element parentElement, String key, String value, boolean useCDATA) {
Element parameterElement = new Element("parameter");
parentElement.addContent(parameterElement);
Element keyElement = new Element("key");
keyElement.addContent(key);
parameterElement.addContent(keyElement);
Element valueElement = new Element("value");
if (useCDATA) {
CDATA cdata = new CDATA(value);
valueElement.addContent(cdata);
} else {
valueElement.addContent(value);
}
parameterElement.addContent(valueElement);
}
示例6: setDatasetTitle
import org.jdom.CDATA; //导入依赖的package包/类
public void setDatasetTitle(String string) {
Element group = new Element(ELEMENT_ANNOTATION_GROUP);
group.setAttribute("type", "data");
Element ann = new Element(ELEMENT_ANNOTATION);
ann.setAttribute("type", "dataset_title");
Element value = new Element(ELEMENT_VALUE);
CDATA text = new CDATA(string);
value.addContent(text);
ann.addContent(value);
group.addContent(ann);
getRootElement().addContent(group);
}
示例7: getState
import org.jdom.CDATA; //导入依赖的package包/类
public final Element getState() {
final Element e = new Element("injection");
e.setAttribute("language", myInjectedLanguageId);
e.setAttribute("injector-id", mySupportId);
e.addContent(new Element("display-name").setText(getDisplayName()));
if (StringUtil.isNotEmpty(myPrefix)) {
e.addContent(new Element("prefix").setText(myPrefix));
}
if (StringUtil.isNotEmpty(mySuffix)) {
e.addContent(new Element("suffix").setText(mySuffix));
}
if (StringUtil.isNotEmpty(myValuePattern)) {
e.addContent(new Element("value-pattern").setText(myValuePattern));
}
if (mySingleFile) {
e.addContent(new Element("single-file"));
}
Arrays.sort(myPlaces, new Comparator<InjectionPlace>() {
public int compare(final InjectionPlace o1, final InjectionPlace o2) {
return Comparing.compare(o1.getText(), o2.getText());
}
});
for (InjectionPlace place : myPlaces) {
final Element child = new Element("place").setContent(new CDATA(place.getText()));
if (!place.isEnabled()) child.setAttribute("disabled", "true");
e.addContent(child);
}
writeExternalImpl(e);
return e;
}
示例8: renderCDATAElement
import org.jdom.CDATA; //导入依赖的package包/类
public Element renderCDATAElement(Element parent, String elementName, String data) {
Element element = null;
if (data != null) {
element = renderElement(parent, elementName);
element.addContent(new CDATA(data));
}
return element;
}
示例9: saveDependencies
import org.jdom.CDATA; //导入依赖的package包/类
private void saveDependencies(Element rootElement) {
String dependencies = dto.getDependencies();
if(dependencies == null)return;
if(dependencies.isEmpty())return;
Element dependenciesElement = new Element("dependencies");
dependenciesElement.addContent(new CDATA(dependencies));
rootElement.addContent(dependenciesElement);
}
示例10: getTextStringValue
import org.jdom.CDATA; //导入依赖的package包/类
public String getTextStringValue(Object obj)
{
if ( obj instanceof Text )
{
return ((Text)obj).getText();
}
if ( obj instanceof CDATA )
{
return ((CDATA)obj).getText();
}
return "";
}
示例11: getElementStringValue
import org.jdom.CDATA; //导入依赖的package包/类
public String getElementStringValue(Object obj)
{
Element elem = (Element) obj;
StringBuffer buf = new StringBuffer();
List content = elem.getContent();
Iterator contentIter = content.iterator();
Object each = null;
while ( contentIter.hasNext() )
{
each = contentIter.next();
if ( each instanceof Text )
{
buf.append( ((Text)each).getText() );
}
else if ( each instanceof CDATA )
{
buf.append( ((CDATA)each).getText() );
}
else if ( each instanceof Element )
{
buf.append( getElementStringValue( each ) );
}
}
return buf.toString();
}
示例12: getCDATAExceptionStackTracesUnder
import org.jdom.CDATA; //导入依赖的package包/类
private List<CDATA> getCDATAExceptionStackTracesUnder(Element rootElement) {
Iterator it = rootElement.getDescendants(new Filter() {
public boolean matches(Object arg0) {
return arg0 instanceof CDATA;
}
});
List<CDATA> stackTraceElements = new ArrayList<CDATA>();
while (it.hasNext()) {
CDATA next = (CDATA) it.next();
stackTraceElements.add(next);
}
return stackTraceElements;
}
示例13: outputTXT
import org.jdom.CDATA; //导入依赖的package包/类
public void outputTXT(Outputter out) {
if (isCDATA) {
out.output(CDATA);
out.output(" ");
}
out.output(fqs(s));
out.newline();
}
示例14: processXMLContent
import org.jdom.CDATA; //导入依赖的package包/类
void processXMLContent(org.jdom.Element e)
throws SyntaxException {
if (logCat.isDebugEnabled())
logCat.debug("processXMLContent(" +
e +
")");
try {
for (Iterator it = e.getContent().listIterator();
it.hasNext();) {
Object o = it.next();
if (logCat.isDebugEnabled())
logCat.debug("processXMLContent factory is " +
factory);
if (o instanceof org.jdom.Element) {
addChild(factory.getStatement((org.jdom.Element)o));
} else if (o instanceof org.jdom.Text) {
addChild(factory.getStatement(((org.jdom.Text)o).getText()));
} else if (o instanceof String) {
addChild(factory.getStatement((String)o));
} else if (o instanceof org.jdom.Comment) {
addChild(factory.getStatement((org.jdom.Comment)o));
} else if (o instanceof CDATA) {
addChild(factory.getStatement((CDATA)o));
} else {
logCat.warn("Could not convert " + o.getClass().getName());
}
}
} catch (SyntaxException se) {
se.setContainingStatement(getXMLLocalName());
throw se;
}
}
示例15: toXML
import org.jdom.CDATA; //导入依赖的package包/类
/**
* Output an xml representation of this statement descriptor.
* @param name the name of the token recognized for this statement
* @param root the element to which the representation should
* be added.
*/
void toXML(String name, Element root) {
Element e = new Element("statement");
addElement(e, "txtName", name);
addElement(e, "elementName", getXMLName());
if (requiredFields.size() > 0) {
Element req = new Element("requiredFields");
addFields(req, requiredFields);
e.addContent(req);
}
if (optionalFields.size() > 0) {
Element opt = new Element("optionalFields");
addFields(opt, optionalFields);
e.addContent(opt);
}
String ex = getExample();
if (ex != null) {
Element example = new Element("example");
example.addContent(new CDATA(ex));
e.addContent(example);
}
root.addContent(e);
}