本文整理汇总了Java中org.jdom.Content类的典型用法代码示例。如果您正苦于以下问题:Java Content类的具体用法?Java Content怎么用?Java Content使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Content类属于org.jdom包,在下文中一共展示了Content类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateElement
import org.jdom.Content; //导入依赖的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;
}
示例2: updateElement
import org.jdom.Content; //导入依赖的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;
}
示例3: parseElement
import org.jdom.Content; //导入依赖的package包/类
private void parseElement(Element elt, boolean parseLink) {
if ("content".equals(elt.getName()) && "media".equals(elt.getNamespacePrefix())) {
if (parseLink) {
tempItemLink = elt.getAttribute("url").getValue();
}
List<Content> subElts = elt.getContent();
for (Content subelt : subElts) {
if (subelt instanceof Element) {
parseElement((Element) subelt, false);
}
}
}
if ("thumbnail".equals(elt.getName()) && "media".equals(elt.getNamespacePrefix())
&& tempItemThumbURL == null) {
tempItemThumbURL = elt.getAttribute("url").getValue();
}
if ("image".equals(elt.getName()) && "exInfo".equals(elt.getNamespacePrefix())
&& tempItemThumbURL == null) {
tempItemThumbURL = elt.getValue();
}
}
示例4: loadState
import org.jdom.Content; //导入依赖的package包/类
@Override
public void loadState(Element element) {
if (ELEMENT_ROOT_ITEM_NAME.equals(element.getName())) {
Iterator<Content> iterator = element.getDescendants();
while (iterator.hasNext()) {
Object content = iterator.next();
if (!(content instanceof Element)) {
continue;
}
Element e = (Element) content;
if (ELEMENT_NAME_URL.equals(e.getName())) {
url = e.getText();
} else if (ELEMENT_NAME_MODULE.equals(e.getName())) {
module = e.getText();
} else if (ELEMENT_NAME_PATH.equals(e.getName())) {
path = e.getText();
} else if (ELEMENT_NAME_PARAM.equals(e.getName())) {
String key = e.getAttributeValue(ATTRIBUTE_NAME_KEY);
String value = e.getAttributeValue(ATTRIBUTE_NAME_VAL);
params.put(key, value);
}
}
}
}
示例5: updateBiopax
import org.jdom.Content; //导入依赖的package包/类
protected void updateBiopax(PathwayElement o, Element e) throws ConverterException
{
Document bp = ((BiopaxElement)o).getBiopax();
if(e != null && bp != null) {
List<Content> content = bp.getRootElement().cloneContent();
for(Content c : content) {
if(c instanceof Element) {
Element elm = (Element)c;
if(elm.getNamespace().equals(GpmlFormat.BIOPAX)) {
e.addContent(c);
} else if(elm.getName().equals("RDF") && elm.getNamespace().equals(GpmlFormat.RDF)) {
for(Object ce : elm.getChildren()) {
if(((Element)ce).getNamespace().equals(GpmlFormat.BIOPAX)) {
e.addContent((Element)ce);
}
}
} else {
Logger.log.info("Skipped non-biopax element" + c);
}
}
}
}
}
示例6: getTextValue
import org.jdom.Content; //导入依赖的package包/类
@NotNull
static String getTextValue(@NotNull Element element, @NotNull String defaultText) {
List<Content> content = element.getContent();
int size = content.size();
StringBuilder builder = null;
for (int i = 0; i < size; i++) {
Content child = content.get(i);
if (child instanceof Text) {
String value = child.getValue();
if (builder == null && i == (size - 1)) {
return value;
}
if (builder == null) {
builder = new StringBuilder();
}
builder.append(value);
}
}
return builder == null ? defaultText : builder.toString();
}
示例7: serializeKeyOrValue
import org.jdom.Content; //导入依赖的package包/类
private void serializeKeyOrValue(@NotNull Element entry, @NotNull String attributeName, @Nullable Object value, @Nullable Binding binding, @NotNull SerializationFilter filter) {
if (value == null) {
return;
}
if (binding == null) {
entry.setAttribute(attributeName, XmlSerializerImpl.convertToString(value));
}
else {
Object serialized = binding.serialize(value, entry, filter);
if (serialized != null) {
if (myMapAnnotation != null && !myMapAnnotation.surroundKeyWithTag()) {
entry.addContent((Content)serialized);
}
else {
Element container = new Element(attributeName);
container.addContent((Content)serialized);
entry.addContent(container);
}
}
}
}
示例8: createWrappedStructure
import org.jdom.Content; //导入依赖的package包/类
/** Traverses the initial xml element wrapper and builds hierarchy */
protected void createWrappedStructure(final WrapperFactory factory) {
HierarchyWrapper currentWrapper = null;
for (Content child : castToContentList(elementContent)) {
Wrapper<?> wrapper = factory.create(child);
if (wrapper instanceof SingleNewlineInTextWrapper) {
continue;
}
if (currentWrapper == null) {
currentWrapper = new HierarchyWrapper(wrapper);
children.add(currentWrapper);
} else {
currentWrapper.addContent(wrapper);
}
if (currentWrapper.containsElement()) {
currentWrapper.createWrappedStructure(factory);
currentWrapper = null;
}
}
}
示例9: createTreeNode
import org.jdom.Content; //导入依赖的package包/类
private XMLNode createTreeNode(Content content) {
XMLNode node = new XMLNode(content);
if (content instanceof Parent) {
Parent parent = (Parent) content;
for (Object child : parent.getContent()) {
if (child instanceof Element)
node.add(createTreeNode((Content) child));
else if (textSizeLimit != 0 && child instanceof Text) {
Text text = (Text) child;
if (!text.getTextNormalize().isEmpty())
node.add(createTreeNode(text));
}
}
}
return node;
}
示例10: stripEmptyElements
import org.jdom.Content; //导入依赖的package包/类
private static void stripEmptyElements(Element asXML) {
int childCount = asXML.getContent().size();
int index = 0;
while (index < childCount) {
Content child = asXML.getContent(index);
if (child instanceof Element) {
Element childElement = (Element) child;
if (childElement.getName().equals("port")) {
index++;
} else if (childElement.getDescendants(new ElementFilter("port")).hasNext()) {
stripEmptyElements(childElement);
index++;
} else {
asXML.removeContent(childElement);
childCount--;
}
}
}
}
示例11: encodeXML
import org.jdom.Content; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Content encodeXML(String name, Namespace ns) {
// element in namespace defined by parent element
Element element = new Element(name, ns);
// child element are always in default LLRP namespace
ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);
if (index == null) {
LOGGER.warn(" index not set");
throw new MissingParameterException(" index not set");
} else {
element.addContent(index.encodeXML("Index", ns));
}
if (transmitPowerValue == null) {
LOGGER.warn(" transmitPowerValue not set");
throw new MissingParameterException(" transmitPowerValue not set");
} else {
element.addContent(transmitPowerValue.encodeXML(
"TransmitPowerValue", ns));
}
//parameters
return element;
}
示例12: encodeXML
import org.jdom.Content; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Content encodeXML(String name, Namespace ns) {
// element in namespace defined by parent element
Element element = new Element(name, ns);
// child element are always in default LLRP namespace
ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);
if (inventoryParameterSpecID == null) {
LOGGER.warn(" inventoryParameterSpecID not set");
throw new MissingParameterException(
" inventoryParameterSpecID not set");
} else {
element.addContent(inventoryParameterSpecID.encodeXML(
"InventoryParameterSpecID", ns));
}
//parameters
return element;
}
示例13: encodeXML
import org.jdom.Content; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Content encodeXML(String name, Namespace ns) {
// element in namespace defined by parent element
Element element = new Element(name, ns);
// child element are always in default LLRP namespace
ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);
if (result == null) {
LOGGER.warn(" result not set");
throw new MissingParameterException(" result not set");
} else {
element.addContent(result.encodeXML("Result", ns));
}
if (opSpecID == null) {
LOGGER.warn(" opSpecID not set");
throw new MissingParameterException(" opSpecID not set");
} else {
element.addContent(opSpecID.encodeXML("OpSpecID", ns));
}
//parameters
return element;
}
示例14: encodeXML
import org.jdom.Content; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Content encodeXML(String name, Namespace ns) {
// element in namespace defined by parent element
Element element = new Element(name, ns);
// child element are always in default LLRP namespace
ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);
if (gPOPortNumber == null) {
LOGGER.warn(" gPOPortNumber not set");
throw new MissingParameterException(" gPOPortNumber not set");
} else {
element.addContent(gPOPortNumber.encodeXML("GPOPortNumber", ns));
}
if (gPOData == null) {
LOGGER.warn(" gPOData not set");
throw new MissingParameterException(" gPOData not set");
} else {
element.addContent(gPOData.encodeXML("GPOData", ns));
}
//element.addContent(reserved0.encodeXML("reserved",ns));
//parameters
return element;
}
示例15: encodeXML
import org.jdom.Content; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Content encodeXML(String name, Namespace ns) {
// element in namespace defined by parent element
Element element = new Element(name, ns);
// child element are always in default LLRP namespace
ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);
if (modeIndex == null) {
LOGGER.warn(" modeIndex not set");
throw new MissingParameterException(" modeIndex not set");
} else {
element.addContent(modeIndex.encodeXML("ModeIndex", ns));
}
if (tari == null) {
LOGGER.warn(" tari not set");
throw new MissingParameterException(" tari not set");
} else {
element.addContent(tari.encodeXML("Tari", ns));
}
//parameters
return element;
}