str object is implemented by both
PyUnicode and Java String. All operations will
produce the same result for Python, whichever representation is
used. Both types are treated as an array of code points in
Python.
Most strings used as names (keys) and text are quite
satisfactorily represented by Java String. Java
Strings are compact, but where they contain non-BMP
characters, these are represented by a pair of code units. That
makes certain operations (such as indexing or slicing) relatively
expensive compared to Java. Accessing the code points of a
String sequentially is still cheap.
By contrast, a PyUnicode is time-efficient, but each
character occupies one int.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv abstract static class | PyUnicode.CodepointDelegate
A base class for the delegate of either a |
| pack-priv static interface | PyUnicode.CodepointIterator
A |
| private static class | PyUnicode.StrFormatter
A |
| pack-priv static class | PyUnicode.StringAdapter
Wrap a Java |
| pack-priv class | PyUnicode.UnicodeAdapter
A class to act as the delegate implementing |
| Modifier and Type | Field and Description |
|---|---|
| private static String | |
| private static Pattern | complexPattern
Access only through |
| private PyUnicode. | delegate
Helper to implement |
| private static Pattern | floatPattern
Access only through |
| private int | hash
Cached hash of the |
| private static char[] | |
| private static final int | |
| private static final String | |
| private static ucnhashAPI | |
| public static final PyType | TYPE
The type |
| protected PyType | type
The actual Python type of this |
| private static final String | UF_RE
Regular expression for an unsigned Python float, accepting also any sequence of the letters that belong to "NaN" or "Infinity" in whatever case. |
| private final int[] | value
The implementation holds a Java |
| Access | Constructor and Description |
|---|---|
| private | PyUnicode(PyType
actual type the instance should have type, boolean if iPromiseNotToModify, int[] true, the array becomes the
implementation array, otherwise the constructor takes a copy.the array of code points codePoints)Construct an instance of |
| protected | |
| protected | PyUnicode(int...
the array of code points codePoints)Construct an instance of |
| protected | PyUnicode(IntArrayBuilder
from which to take the code points value)Construct an instance of |
| protected | PyUnicode(IntArrayReverseBuilder
from which to take the code points value)Construct an instance of |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private Object | |
| private static Object | |
| private boolean | |
| private static boolean | |
| pack-priv static final Object | |
| private Object | |
| private static Object | |
| private PyTuple | |
| private static PyTuple | |
| private int | |
| private static int | |
| private int | |
| private static int | |
| pack-priv static Object | |
| private Object | |
| private static Object | |
| private Object | |
| private static Object | |
| private static Object | |
| private Object | |
| private static Object | |
| private Object | |
| private static Object | |
| public Object | |
| private final String | Returns: transformed stringof character translations (or table, String null)set of characters to remove (or deletechars)null)Helper common to the Python and Java API implementing |
| pack-priv static PyUnicode. | |
| pack-priv static PyUnicode. | Returns: new StringAdapter(v)to wrap v)Short-cut |
| pack-priv PyUnicode. | Returns: the delegate for sequence operations on thisstrShort-cut |
| private static int | |
| pack-priv static PyUnicode. | Returns: adapted to a sequencein which encountered method, Object alleged string replacement)Adapt a Python |
| pack-priv static PyUnicode. | Returns: adapted to a sequencein which encountered method, Object alleged separator sep)Adapt a Python |
| pack-priv static Set | Returns: null or characters adapted to a setin which encountered method, Object characters defining the set (or chars)None or
null)Adapt a Python |
| pack-priv static PyUnicode. | Returns: adapted to a sequencein which encountered method, Object alleged string sub)Adapt a Python |
| private static BigInteger | |
| public PySequence. | |
| public static String | |
| public static < type of exception to throw E extends PyException> String | |
| pack-priv String | Returns: thisPyUnicode as a Java StringConvert this |
| private PyComplex | |
| public double | |
| public static double | |
| private static double | Returns: non-numeric result (if valid)to convert s)Conversion for non-numeric floats, accepting signed or unsigned "inf" and "nan", in any case. |
| public int | |
| public int | |
| public static int | |
| public PyLong | |
| public PyLong | |
| public static PyLong | |
| private String | Returns: the formatted string based on the argumentsto be interpolated into the string args, String[] for the trailing args keywords, MarkupIterator when used nested, null if subject is this enclosingIterator, String PyStringthe format string when value)enclosingIterator is not nullImplements PEP-3101 {}-formatting method |
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: capitalised stringthe sself stringInner implementation of |
| pack-priv Object | |
| pack-priv static Object | |
| public static String | |
| protected final int | Returns: index if non-negativeto check index)A little helper for converting str.find to str.index that will raise
|
| private static void | checkIndexRange(int
e.g. the start position of na iterator. index, int first in range start, int first beyond range (i.e. non-inclusive bound) end, int of sequence len)Assert that 0 ≤ start ≤index ≤ end ≤ len or if not, throw an exception. |
| private static final int | Returns: index if non-negativeto check index)A little helper for converting str.find to str.index that will
raise |
| pack-priv static < type of exception to throw E extends PyException> String | Returns: arg as a Stringto coerce arg, Supplier<E> supplier for actual exception exc)Coerce a Python |
| private static Object | |
| private static PyUnicode | Returns: the concatenationv + wfirst string to concatenate v, IntStream second string to concatenate w)Concatenate two streams of code points into a |
| private static boolean | |
| pack-priv static String | Returns: converted toStringto convert v)Convert a Python |
| pack-priv int | |
| pack-priv static int | |
| private static int | |
| private static int | Returns: count of occurrencessubstring to find. s,start of slice. p,end of slice. sliceThe inner implementation of |
| public static String | |
| pack-priv Object | |
| pack-priv Object | |
| pack-priv Object | |
| public static String | |
| pack-priv static String | Returns: encoded string (possibly the same string if unchanged)to process str, char '"' or '\'' use that, '?' = let Python choose, 0 or anything = no quotes quote)The inner logic of the string __repr__ producing an ASCII representation of the target string, optionally in quotations. |
| private String | Returns: a valid decimal as an encoded String
Deprecated
Encode unicode into a valid decimal String.
|
| private String | Returns: a valid decimal as an encoded StringEncode unicode in the basic plane into a valid decimal String. |
| pack-priv Object | Returns: true if this string slice ends with a specified
suffix, otherwise false.string to check for (or a suffix, Object PyTuple of them).start of slice. start, Object end of slice. end)Equivalent to the Python |
| pack-priv static Object | |
| private static boolean | |
| private static boolean | |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Implements org. str, or a
PyDict.
|
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: tab-expanded stringthe s,self stringnumber of spaces to tab to tabsize)Inner implementation of |
| pack-priv int | |
| pack-priv static int | |
| private static int | |
| private static int | Returns: the index of the occurrence or-1to be searched s,the substring to look for p,of slices in which to searchInner implementation of Python |
| private static int | Returns: index of leftmost non-space character ors.length() if entirely spaces.Helper for |
| private static int | Returns: index of leftmost non-p character or
s.length() if entirely found in p.specifies set of characters to strip p)Helper for |
| private static int | Returns: index of rightmost non-space character or-1 if
entirely spaces.Helper for |
| private static int | Returns: index of rightmost non-p character or -1
if entirely found in p.specifies set of characters to strip p)Helper for |
| pack-priv final Object | |
| pack-priv static PyTuple | Returns: a tuple of the first field name component and the restto split into components fieldName)Implementation of |
| pack-priv static Object | Returns: an iterator of formattuplesto parse formatString)Implementation of |
| public static Object | Returns: a Pythonstrto code point convert cp)Return a Python |
| pack-priv static PyUnicode | Returns: formatted stringformat string (Java semantics) fmt, Object... arguments args)
Deprecated
Create a str from a format and arguments.
|
| public static PyUnicode | Returns: a Pythonstrto convert s)Return a Python |
| private static synchronized Pattern | |
| private Object | Returns: the object designated ornull.to interpret. fieldName, boolean true if the field name is from a PyString, false for PyUnicode. bytes, Object[] argument list (positional then keyword arguments). args, String[] naming the keyword arguments. keywords)Return the object referenced by a given field name, interpreted in the context of the given argument list, containing positional and keyword arguments. |
| private static synchronized Pattern | getFloatPattern()
Return the (lazily) compiled regular expression that matches all valid a Python float() arguments, in which Group 1 captures the number, stripped of white space. |
| private static PySlice. | Returns: indices of the slicesequence being sliced s,first index included start, Object first index not included end)Convert slice end indices to a |
| public PyType | |
| public int | hashCode()
Overrides java. Implements org. PyUnicode is the same as that of a Java
String equal to it.
|
| private static int | hexescape(StringBuilder partialDecode, String errors, int digits, int hexDigitStart, String str, int size, String errorMessage)
|
| pack-priv int | Returns: index ofsub in this object or -1 if not found.substring to find. sub, Object start of slice. start, Object end of slice. end)As |
| pack-priv static int | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| public boolean | |
| public static boolean | |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| private static boolean | isPythonLineSeparator(int cp)
Define what characters are to be treated as a line separator according to Python 3. |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv final boolean | |
| pack-priv static boolean | |
| private static boolean | |
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: capitalised stringthe s,self string (separator)of strings iterable)Inner implementation of |
| private static TypeError | |
| pack-priv Object | |
| pack-priv static Object | |
| pack-priv PyUnicode | |
| pack-priv static String | |
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: the str strippedrepresenting s,selfto remove, or chars)null or NoneInner implementation of Python |
| private PyUnicode | Returns: transformed stringthe operation op)Apply a unary operation to every character of a string and return them as a string. |
| private static String | Returns: transformed stringthe operation op)Apply a unary operation to every character of a string and return them as a string. |
| private static NoSuchElementException | |
| private static Object | Returns: the padded string (ors.principal())whether to pad at the left left, PyUnicode.the s,self stringwhether to pad at the right right, int the minimum width to attain width, int the code point value to use as the fill fill) |
| pack-priv PyTuple | |
| pack-priv static PyTuple | |
| private static PyTuple | Returns: tuple of parts ornullto be split s,the separator to look for sep)Inner implementation of Python |
| private void | renderField(Object
to format. fieldObj, String specification to apply. formatSpec, StringBuilder to which the result will be appended. result)Append to a formatting result, the presentation of one object, according to a given format
specification and the object's |
| pack-priv Object | Returns: self string after replacements.to replace where found. old, Object replacement text. rep, int maximum number of replacements to make, or -1
meaning all of them. count)Python |
| pack-priv static Object | |
| private static Object | |
| private static Object | Returns: string interleaved with the replacementdelegate presenting self as code points s,delegate representing the replacement string r,limit on the number of replacements count)Implementation of Python |
| private static Object | Returns: string with the replacementsdelegate presenting self as code points s,delegate representing the string to replace p,delegate representing the replacement string r,limit on the number of replacements count)Implementation of Python |
| pack-priv int | |
| pack-priv static int | |
| private static int | |
| private static int | Returns: the index of the occurrence or-1to be searched s,the substring to look for p,of slices in which to searchInner implementation of Python |
| pack-priv int | Returns: index ofsub in this object or -1 if not found.substring to find. sub, Object start of slice. start, Object end of slice. end)As |
| pack-priv static int | |
| pack-priv Object | |
| pack-priv static Object | |
| pack-priv PyTuple | Returns: tuple of partson which to split the string sep)Python |
| pack-priv static PyTuple | |
| private static PyTuple | Returns: tuple of parts ornullto be split s,the separator to look for sep)Helper to Python |
| pack-priv PyList | |
| pack-priv static PyList | |
| private static PyList | |
| private static PyList | Returns: PyList of split sectionsdelegate presenting self as code points s,at occurrences of which p,s should be splitlimit on the number of splits (if not <=0) maxsplit)Implementation of Python |
| private static PyList | Returns: PyList of split sectionsdelegate presenting self as code points s,limit on the number of splits (if >=0) maxsplit)Implementation of |
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: the str strippedrepresenting s,selfto remove, or chars)null or NoneInner implementation of Python |
| pack-priv PyList | |
| pack-priv static PyList | |
| private static PyList | |
| private static PyList | Returns: PyList of split sectionsdelegate presenting self as code points s,at occurrences of which p,s should be splitlimit on the number of splits (if not <=0) maxsplit)Implementation of Python |
| private static PyList | Returns: PyList of split sectionsdelegate presenting self as code points s,limit on the number of splits (if >=0) maxsplit)Implementation of |
| pack-priv PyList | Returns: the list of linesthe lines in the list retain the separator that
caused the split keepends)Python |
| pack-priv static PyList | |
| private static PyList | |
| pack-priv Object | Returns: true if this string slice starts with a specified
prefix, otherwise false.string to check for (or a prefix, Object PyTuple of them).start of slice. start, Object end of slice. end)Equivalent to the Python |
| pack-priv static Object | |
| private static boolean | |
| private static boolean | |
| private static boolean | |
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: thestr strippedrepresenting s,selfto remove, or chars)null or NoneInner implementation of Python |
| pack-priv PyUnicode | |
| pack-priv static String | |
| private static int | |
| pack-priv PyUnicode | |
| pack-priv static PyUnicode | |
| private static PyUnicode | |
| private static double | Returns: value of sto interpret s)Helper for interpreting each part (real and imaginary) of a complex number expressed as a
string in |
| public String | toString()
Overrides java. |
| pack-priv final Object | |
| pack-priv static Object | |
| pack-priv PyUnicode | |
| pack-priv static String | |
| private static PyUnicode | Returns: thestrto wrap as a codePoints)strUnsafely wrap an array of code points as a |
| public static PyUnicode | Returns: thestrto wrap as a codePoints)strSafely wrap the contents of an |
| pack-priv Object | |
| pack-priv static Object | |
| private static Object | Returns: the filled stringthe s,self stringthe achieve by inserting zeros width)Inner implementation of |