Interface IonContainer

All Superinterfaces:
Cloneable, IonValue, Iterable<IonValue>
All Known Subinterfaces:
_Private_IonContainer, _Private_IonDatagram, IonDatagram, IonList, IonSequence, IonSexp, IonStruct

public interface IonContainer extends IonValue, Iterable<IonValue>
Common functionality of Ion struct, list, and sexp types.

WARNING: This interface should not be implemented or extended by code outside of this library.

  • Method Details

    • size

      int size()
      Returns the number of elements in this container.
      Returns:
      the number of elements, zero if this.isNullValue().
    • iterator

      Iterator<IonValue> iterator()
      Creates an iterator providing the (direct) elements of this container. If this is an Ion null value, then this method returns an empty iterator.

      Note that iteration over a IonStruct has unspecified ordering, while iteration over an IonSequence (IonList or IonSexp) must return elements in order of their appearance in the Ion representation.

      Specified by:
      iterator in interface Iterable<IonValue>
      Returns:
      a new iterator, not null.
    • remove

      boolean remove(IonValue element)
      Removes the given element from this container. If this is an Ion null value, then this method returns false.

      Note that, unlike Collection.remove(Object), this method uses object identity, not Object.equals(Object), to find the element. That is, the given instance is removed, not other similarly "equal" instances.

      Parameters:
      element - the element to be removed from this container, if present.
      Returns:
      true if this container contained the specified element.
      Throws:
      NullPointerException - if the element is null.
    • isEmpty

      boolean isEmpty() throws NullValueException
      Checks if this container is empty.
      Returns:
      true if this container has no contents
      Throws:
      NullValueException - if this container is an Ion null value
    • clear

      void clear()
      Clears the contents of this container (if any) and set it to empty. If this container is an Ion null value, set it to empty.

      Use makeNull() to make this container null rather than empty.

      WARNING: This method is not support for instances of IonDatagram.

    • makeNull

      void makeNull()
      Sets the contents of this container to an Ion null value.

      Use clear() to make this container empty rather than null.

    • clone

      Description copied from interface: IonValue
      Creates a copy of this value and all of its children. The cloned value may use the same shared symbol tables, but it will have an independent local symbol table if necessary. The cloned value will be modifiable regardless of whether this instance IonValue.isReadOnly().

      The cloned value will be created in the context of the same ValueFactory as this instance; if you want a copy using a different factory, then use ValueFactory.clone(IonValue) instead.

      Specified by:
      clone in interface IonValue
      Throws:
      UnknownSymbolException - if any part of this value has unknown text but known Sid for its field name, annotation or symbol.