Class MarkupIterator

  • All Implemented Interfaces:
    java.io.Serializable

    public class MarkupIterator
    extends PyObject
    Provides an implementation of the object that str._formatter_parser() returns, which is an iterator returning successive 4-tuples, the sequence being equivalent to the original string.
    See Also:
    Serialized Form
    • Field Detail

      • TYPE

        public static final PyType TYPE
    • Constructor Detail

      • MarkupIterator

        public MarkupIterator​(PyString markupObject)
        Constructor used at top-level to enumerate a format.
      • MarkupIterator

        public MarkupIterator​(MarkupIterator enclosingIterator,
                              java.lang.String subMarkup)
        Variant constructor used when formats are nested.
    • Method Detail

      • __iter__

        public PyObject __iter__()
        Description copied from class: PyObject
        Return an iterator that is used to iterate the element of this sequence. From version 2.2, this method is the primary protocol for looping over sequences.

        If a PyObject subclass should support iteration based in the __finditem__() method, it must supply an implementation of __iter__() like this:

         public PyObject __iter__() {
             return new PySequenceIter(this);
         }
         
        When iterating over a python sequence from java code, it should be done with code like this:
         for (PyObject item : seq.asIterable()) {
             // Do somting with item
         }
         
        Overrides:
        __iter__ in class PyObject
      • __iternext__

        public PyObject __iternext__()
        Description copied from class: PyObject
        Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.
        Overrides:
        __iternext__ in class PyObject
      • nextChunk

        public MarkupIterator.Chunk nextChunk()
        Return the next MarkupIterator.Chunk from the iterator, which is a structure containing parsed elements of the replacement field (if any), and its preceding text. This is the Java equivalent of the tuple returned by __iternext__(). This finds use in the implementation of str.format and unicode.format.
        Returns:
        the chunk
      • isBytes

        public final boolean isBytes()
        If originally given a PyString, string elements in the returned tuples must be PyString not PyUnicode.
        Returns:
        true if originally given a PyString