Top Description Inners Fields Constructors Methods
org.python.core.stringlib

public Class FieldNameIterator

extends Object
implements CraftedPyObject
Class Inheritance
All Implemented Interfaces
org.python.core.CraftedPyObject
Imports
java.lang.invoke.MethodHandles, org.python.base.MissingFeature, org.python.core.CraftedPyObject, .PyTuple, .PyType

This class is an implementation of the iterator object returned by string.formatter_field_name_split(). The function formatter_field_name_split() returns a pair (tuple) consisting of a head element and an instance of this iterator. The constructor of this class effectively implements that function, since as well as being the iterator (second member), the object has an extra method head() to return the required first member of the pair.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final boolean
bytes

True if originally given a PyString (so must return PyString not PyUnicode).

private Object
private int
index

How far along that string we are.

private final String
markup

The UTF-16 string from which elements are being returned.

public static final PyType
TYPE

The Python type fieldnameiterator of this class.

Constructor Summary

AccessConstructor and Description
public
FieldNameIterator(String
the field name as UTF-16
fieldName
,
boolean
true if elements returned should be bytes
bytes
)

Create an iterator for the parts of this field name (and extract the head name field, which may be an empty string).

public
FieldNameIterator(String
to parse
fieldName
)

Create an iterator for the parts of this field name (and extract the head name field, which may be an empty string).

Method Summary

Modifier and TypeMethod and Description
private final Object
private final Object
public PyType
getType()

Implements org.python.core.CraftedPyObject.getType.

The Python type of this object.
public Object

Returns:

the isolated head object from the field name.
head
()

Return the head object from the field name, as int or str.

public FieldNameIterator.Chunk

Returns:

next element of the field name
nextChunk
()

Return the next "chunk" of the field name (or return null if ended).

private int
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bytesback to summary
private final boolean bytes

True if originally given a PyString (so must return PyString not PyUnicode).

indexback to summary
private int index

How far along that string we are.

markupback to summary
private final String markup

The UTF-16 string from which elements are being returned.

TYPEback to summary
public static final PyType TYPE

The Python type fieldnameiterator of this class.

Constructor Detail

FieldNameIteratorback to summary
public FieldNameIterator(String fieldName, boolean bytes)

Create an iterator for the parts of this field name (and extract the head name field, which may be an empty string). According to the Python Standard Library documentation, a replacement field name has the structure:

field_name        ::=  arg_name ("." attribute_name | "[" element_index "]")*
arg_name          ::=  [identifier | integer]
attribute_name    ::=  identifier
element_index     ::=  integer | index_string
The object is used from PyUnicode and from PyString, and we have to signal which it is, so that returned values may match in type.
Parameters
fieldName:String

the field name as UTF-16

bytes:boolean

true if elements returned should be bytes

FieldNameIteratorback to summary
public FieldNameIterator(String fieldName)

Create an iterator for the parts of this field name (and extract the head name field, which may be an empty string).

Parameters
fieldName:String

to parse

Method Detail

__iter__back to summary
private final Object __iter__()
Annotations
@SuppressWarnings:unused
__next__back to summary
private final Object __next__()
Annotations
@SuppressWarnings:unused
getTypeback to summary
public PyType getType()

Implements org.python.core.CraftedPyObject.getType.

Doc from org.python.core.CraftedPyObject.getType.

The Python type of this object.

Returns:PyType

type of this object

Annotations
@Override

headback to summary
public Object head()

Return the head object from the field name, as int or str.

Returns:Object

the isolated head object from the field name.

nextChunkback to summary
public FieldNameIterator.Chunk nextChunk()

Return the next "chunk" of the field name (or return null if ended). A chunk is a 2-tuple describing:

  1. whether the chunk is an attribute name,
  2. the name or number (as a String or Integer) for accessing the value.
Returns:FieldNameIterator.Chunk

next element of the field name

nextDotOrBracketback to summary
private int nextDotOrBracket(String markup)
parseAttrChunkback to summary
private void parseAttrChunk(FieldNameIterator.Chunk chunk)
parseItemChunkback to summary
private void parseItemChunk(FieldNameIterator.Chunk chunk)
org.python.core.stringlib back to summary

public Class FieldNameIterator.Chunk

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public boolean
public Object
value

Integer or String.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

is_attrback to summary
public boolean is_attr
valueback to summary
public Object value

Integer or String.

Constructor Detail

Chunkback to summary
public Chunk()