Java Code Examples for org.jdom.Element#removeContent()

The following examples show how to use org.jdom.Element#removeContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextConfigurator.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void clearPropertyValue(String id, String propertyName) {
	Element element = xml.getChild("bean", "id", id);
	if (element == null)
		return;
	List poperties = element.getChildren("property", element.getNamespace());
	for (Iterator iter = poperties.iterator(); iter.hasNext();) {
		Element property = (Element) iter.next();
		if (propertyName.equals(property.getAttribute("name").getValue())) {
			property.removeContent();
			return;
		}
	}
}
 
Example 2
Source File: NetbeansBuildActionJDOMWriter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: Utils.java    From pom-manipulation-ext with Apache License 2.0 5 votes vote down vote up
/**
 * Method updateElement.
 * 
 * @param counter
 * @param shouldExist
 * @param name
 * @param parent
 * @return Element
 */
public static Element updateElement( final IndentationCounter counter, final Element parent, final String name,
                                     final boolean shouldExist )
{
    Element element = parent.getChild( name, parent.getNamespace() );
    if ( shouldExist )
    {
        if ( element == null )
        {
            element = factory.element( name, parent.getNamespace() );
            insertAtPreferredLocation( parent, element, counter );
        }
        counter.increaseCount();
    }
    else if ( element != null )
    {
        final int index = parent.indexOf( element );
        if ( index > 0 )
        {
            final Content previous = parent.getContent( index - 1 );
            if ( previous instanceof Text )
            {
                final Text txt = (Text) previous;
                if ( txt.getTextTrim().length() == 0 )
                {
                    parent.removeContent( txt );
                }
            }
        }
        parent.removeContent( element );
    }
    return element;
}
 
Example 4
Source File: UnknownBeforeRunTaskProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(Element element) {
  if (myConfig != null) {
    element.removeContent();
    final List attributes = myConfig.getAttributes();
    for (Object attribute : attributes) {
     element.setAttribute((Attribute)((Attribute)attribute).clone());
    }
    for (Object child : myConfig.getChildren()) {
      element.addContent((Element)((Element)child).clone());
    }
  }
}