str._formatter_parser() returns, which
is an iterator returning successive 4-tuples, the sequence being equivalent to the original
string.
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| pack-priv static class | MarkupIterator.
Class used locally to assign indexes to the automatically-numbered arguments (see String Formatting section of the Python Standard Library). |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | bytes
True if originally given a PyString (so must return PyString not PyUnicode). |
| private int | index
How far along that string we are. |
| private final String | markup
The UTF-16 string from which elements are being returned. |
| private final MarkupIterator. | numbering
A counter used to auto-number fields when not explicitly numbered in the format. |
| public static final PyType |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MarkupIterator(MarkupIterator enclosingIterator, String subMarkup)
Variant constructor used when formats are nested. |
| Modifier and Type | Method and Description |
|---|---|
| public PyObject | __iter__()
Overrides org. Return an iterator that is used to iterate the element of this sequence. |
| public PyObject | __iternext__()
Overrides org. Return the next element of the sequence that this is an iterator for. |
| pack-priv final PyObject | |
| pack-priv final PyObject | Returns: PyTuple chunk or nullReturn the next "chunk" of the format (or return null if ended). |
| private int | |
| public final boolean | Returns: true if originally given a PyStringIf originally given a PyString, string elements in the returned tuples must be PyString not PyUnicode. |
| public MarkupIterator. | |
| private void | parseField(MarkupIterator.
destination chunk result,specifying a replacement field, possibly with nesting fieldMarkup)Parse a "replacement field" consisting of a name, conversion and format specification. |
| private String | |
| private PyObject | Returns: object for tupleto wrap as a PyObject or null if value, String defaultValue should be wrapped.to return or defaultValue)null if default return is None.Convenience method for populating the return tuple, returning a |
| bytes | back to summary |
|---|---|
| private final boolean bytes True if originally given a PyString (so must return PyString not PyUnicode). | |
| index | back to summary |
|---|---|
| private int index How far along that string we are. | |
| markup | back to summary |
|---|---|
| private final String markup The UTF-16 string from which elements are being returned. | |
| numbering | back to summary |
|---|---|
| private final MarkupIterator. A counter used to auto-number fields when not explicitly numbered in the format. | |
| TYPE | back to summary |
|---|---|
| public static final PyType TYPE | |
| MarkupIterator | back to summary |
|---|---|
| public MarkupIterator(PyString markupObject) Constructor used at top-level to enumerate a format. | |
| MarkupIterator | back to summary |
|---|---|
| public MarkupIterator(MarkupIterator enclosingIterator, String subMarkup) Variant constructor used when formats are nested. | |
| __iter__ | back to summary |
|---|---|
| public PyObject __iter__() Overrides org. Doc from org. 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 something with item
}
| |
| __iternext__ | back to summary |
|---|---|
| public PyObject __iternext__() Overrides org. Doc from org. Return the next element of the sequence that this is an iterator for. Returns null when the end of the sequence is reached.
| |
| formatteriterator___iter__ | back to summary |
|---|---|
pack-priv final PyObject formatteriterator___iter__()
| |
| formatteriterator___iternext__ | back to summary |
|---|---|
| pack-priv final PyObject formatteriterator___iternext__() Return the next "chunk" of the format (or return null if ended). A chunk is a 4-tuple describing
| |
| indexOfFirst | back to summary |
|---|---|
| private int indexOfFirst(String s, int start, char c1, char c2) Find the first of two characters, or return -1. | |
| isBytes | back to summary |
|---|---|
| public final boolean isBytes() If originally given a PyString, string elements in the returned tuples must be PyString not PyUnicode.
| |
| nextChunk | back to summary |
|---|---|
| public MarkupIterator. Return the next
| |
| parseField | back to summary |
|---|---|
| private void parseField(MarkupIterator. Parse a "replacement field" consisting of a name, conversion and format specification. According to the Python Standard Library documentation, a replacement field has the structure:
replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
field_name ::= arg_name ("." attribute_name | "[" element_index "]")*
arg_name ::= [identifier | integer]
attribute_name ::= identifier
element_index ::= integer | index_string
except at this point, we have already discarded the outer braces.
| |
| unescapeBraces | back to summary |
|---|---|
| private String unescapeBraces(String substring) | |
| wrap | back to summary |
|---|---|
| private PyObject wrap(String value, String defaultValue) Convenience method for populating the return tuple, returning a
object for tuple | |
| Modifier and Type | Field and Description |
|---|---|
| public String | conversion
Conversion to be applied, e.g. |
| public String | fieldName
The field name or number (as a string) for accessing the value. |
| public String | formatSpec
The format specifier such as |
| public boolean | formatSpecNeedsExpanding
Signals the |
| public String | literalText
The text leading up to the next format field. |
| Access | Constructor and Description |
|---|---|
| public |
| conversion | back to summary |
|---|---|
| public String conversion Conversion to be applied, e.g. | |
| fieldName | back to summary |
|---|---|
| public String fieldName The field name or number (as a string) for accessing the value. | |
| formatSpec | back to summary |
|---|---|
| public String formatSpec The format specifier such as | |
| formatSpecNeedsExpanding | back to summary |
|---|---|
| public boolean formatSpecNeedsExpanding Signals the | |
| literalText | back to summary |
|---|---|
| public String literalText The text leading up to the next format field. | |
| Chunk | back to summary |
|---|---|
| public Chunk() | |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv String | Returns: index as stringGenerate a numeric argument index automatically, or raise an error if already started numbering manually. |
| pack-priv void | useManualFieldNumbering()
Remember we are numbering manually, and raise an error if already started numbering automatically. |
| automaticFieldNumber | back to summary |
|---|---|
| private int automaticFieldNumber | |
| manualFieldNumberSpecified | back to summary |
|---|---|
| private boolean manualFieldNumberSpecified | |
| FieldNumbering | back to summary |
|---|---|
| pack-priv FieldNumbering() | |
| nextAutomaticFieldNumber | back to summary |
|---|---|
| pack-priv String nextAutomaticFieldNumber() Generate a numeric argument index automatically, or raise an error if already started numbering manually.
| |
| useManualFieldNumbering | back to summary |
|---|---|
| pack-priv void useManualFieldNumbering() Remember we are numbering manually, and raise an error if already started numbering automatically. | |