本文整理匯總了Java中org.jdom.Element.getContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getContent方法的具體用法?Java Element.getContent怎麽用?Java Element.getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom.Element
的用法示例。
在下文中一共展示了Element.getContent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseContent
import org.jdom.Element; //導入方法依賴的package包/類
private Content parseContent(Element e) {
String value = null;
String src = e.getAttributeValue("src");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
type = (type!=null) ? type : Content.TEXT;
if (type.equals(Content.TEXT)) {
// do nothing XML Parser took care of this
value = e.getText();
}
else if (type.equals(Content.HTML)) {
value = e.getText();
}
else if (type.equals(Content.XHTML)) {
XMLOutputter outputter = new XMLOutputter();
List eContent = e.getContent();
Iterator i = eContent.iterator();
while (i.hasNext()) {
org.jdom.Content c = (org.jdom.Content) i.next();
if (c instanceof Element) {
Element eC = (Element) c;
if (eC.getNamespace().equals(getAtomNamespace())) {
((Element)c).setNamespace(Namespace.NO_NAMESPACE);
}
}
}
value = outputter.outputString(eContent);
}
Content content = new Content();
content.setSrc(src);
content.setType(type);
content.setValue(value);
return content;
}
示例2: parseContent
import org.jdom.Element; //導入方法依賴的package包/類
private Content parseContent(Element e) {
String value = null;
String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
type = (type!=null) ? type : "text/plain";
String mode = e.getAttributeValue("mode");//getAtomNamespace())); DONT KNOW WHY DOESN'T WORK
if (mode == null) {
mode = Content.XML; // default to xml content
}
if (mode.equals(Content.ESCAPED)) {
// do nothing XML Parser took care of this
value = e.getText();
}
else
if (mode.equals(Content.BASE64)) {
value = Base64.decode(e.getText());
}
else
if (mode.equals(Content.XML)) {
XMLOutputter outputter = new XMLOutputter();
List eContent = e.getContent();
Iterator i = eContent.iterator();
while (i.hasNext()) {
org.jdom.Content c = (org.jdom.Content) i.next();
if (c instanceof Element) {
Element eC = (Element) c;
if (eC.getNamespace().equals(getAtomNamespace())) {
((Element)c).setNamespace(Namespace.NO_NAMESPACE);
}
}
}
value = outputter.outputString(eContent);
}
Content content = new Content();
content.setType(type);
content.setMode(mode);
content.setValue(value);
return content;
}
示例3: updateElement
import org.jdom.Element; //導入方法依賴的package包/類
/**
* Method updateElement.
*
* @param counter
* @param shouldExist
* @param name
* @param parent
* @return Element
*/
protected Element updateElement(Counter counter, Element parent, String name, boolean shouldExist)
{
Element element = parent.getChild(name, parent.getNamespace());
if (element != null && shouldExist) {
counter.increaseCount();
}
if (element == null && shouldExist) {
element = factory.element(name, parent.getNamespace());
insertAtPreferredLocation(parent, element, counter);
counter.increaseCount();
}
if (!shouldExist && element != null) {
int index = parent.indexOf(element);
if (index > 0) {
Content previous = parent.getContent(index - 1);
if (previous instanceof Text) {
Text txt = (Text)previous;
if (txt.getTextTrim().length() == 0) {
parent.removeContent(txt);
}
}
}
parent.removeContent(element);
}
return element;
}
示例4: updateElement
import org.jdom.Element; //導入方法依賴的package包/類
/**
* Method updateElement
*
* @param counter
* @param shouldExist
* @param name
* @param parent
*/
protected Element updateElement( Counter counter, Element parent, String name, boolean shouldExist )
{
Element element = parent.getChild( name, parent.getNamespace() );
if ( element != null && shouldExist )
{
counter.increaseCount();
}
if ( element == null && shouldExist )
{
element = factory.element( name, parent.getNamespace() );
insertAtPreferredLocation( parent, element, counter );
counter.increaseCount();
}
if ( !shouldExist && element != null )
{
int index = parent.indexOf( element );
if ( index > 0 )
{
Content previous = parent.getContent( index - 1 );
if ( previous instanceof Text )
{
Text txt = (Text) previous;
if ( txt.getTextTrim().length() == 0 )
{
parent.removeContent( txt );
}
}
}
parent.removeContent( element );
}
return element;
}