Class Body

  • Direct Known Subclasses:
    SourceElementBody

    public class Body
    extends java.lang.Object
    Holds cached structure and properties for an IElement.

    This implementation is thread-safe under the condition that mutator methods are not invoked concurrently. If multiple threads access a body concurrently, and at most one of them modifies the body, which is the typical usage pattern, external synchronization is not required.

    Clients can use this class as it stands or subclass it as circumstances warrant.

    See Also:
    IBodyCache
    • Constructor Summary

      Constructors 
      Constructor Description
      Body()  
    • Constructor Detail

      • Body

        public Body()
    • Method Detail

      • getChildren

        public IElement[] getChildren()
        Returns the child elements for this body.

        This implementation returns an array of exactly the same runtime type as the array given in the most recent call to setChildren.

        Returns:
        the child elements for this body (never null). Clients must not modify the returned array.
      • setChildren

        public void setChildren​(IElement[] children)
        Sets the child elements for this body. Clients must not modify the given array afterwards.
        Parameters:
        children - not null, must not contain null elements
      • addChild

        public void addChild​(IElement child)
        Adds the given child element to this body if it is not already present. Throws a runtime exception if the class of the given element prevents it from being added.
        Parameters:
        child - not null
      • removeChild

        public void removeChild​(IElement child)
        Removes the given child element from this body if it is present.
        Parameters:
        child - may be null
      • findContentChange

        public void findContentChange​(Body oldBody,
                                      IElement element,
                                      IElementDeltaBuilder builder)
        Finds whether this body has had a content change.

        Implementations can compare this body and the given old body and, if there are differences (excepting children), insert an appropriate change delta (such as F_CONTENT) for the given element into the delta tree being built. Implementations should not take changes in children into account.

        Parameters:
        oldBody - the old version of the body (not null)
        element - the element this body corresponds to (not null)
        builder - represents the delta tree being built (not null)