Search in sources :

Example 1 with IMicroContainer

use of com.helger.xml.microdom.IMicroContainer in project ph-commons by phax.

the class MicroHelper method getAllOriginalChildrenAsContainer.

/**
 * Create a micro container with all children of the passed node. If the
 * passed node has no children, an empty object is returned. The resulting
 * container contains the original child nodes so that they no longer belong
 * to the original object. THis implies that the original object is modified!
 *
 * @param aParent
 *        The parent node to get the children from. May not be
 *        <code>null</code>.
 * @return The micro container and never <code>null</code> but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
public static IMicroContainer getAllOriginalChildrenAsContainer(@Nonnull final IMicroNode aParent) {
    final IMicroContainer ret = new MicroContainer();
    aParent.forAllChildren(aChildNode -> ret.appendChild(aChildNode.detachFromParent()));
    return ret;
}
Also used : MicroContainer(com.helger.xml.microdom.MicroContainer) IMicroContainer(com.helger.xml.microdom.IMicroContainer) IMicroContainer(com.helger.xml.microdom.IMicroContainer) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 2 with IMicroContainer

use of com.helger.xml.microdom.IMicroContainer in project ph-commons by phax.

the class MicroHelper method getAllChildrenAsContainer.

/**
 * Create a micro container with all children of the passed node. If the
 * passed node has no children, an empty object is returned. The resulting
 * container contains a clone of each child node so that the original objects
 * is not modified.
 *
 * @param aParent
 *        The parent node to get the children from. May not be
 *        <code>null</code>.
 * @return The micro container and never <code>null</code> but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
public static IMicroContainer getAllChildrenAsContainer(@Nonnull final IMicroNode aParent) {
    final IMicroContainer ret = new MicroContainer();
    aParent.forAllChildren(aChildNode -> ret.appendChild(aChildNode.getClone()));
    return ret;
}
Also used : MicroContainer(com.helger.xml.microdom.MicroContainer) IMicroContainer(com.helger.xml.microdom.IMicroContainer) IMicroContainer(com.helger.xml.microdom.IMicroContainer) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Aggregations

ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)2 IMicroContainer (com.helger.xml.microdom.IMicroContainer)2 MicroContainer (com.helger.xml.microdom.MicroContainer)2 Nonnull (javax.annotation.Nonnull)2