public class PyString extends PyBaseString implements BufferProtocol
PySequence.DefaultIndexDelegate
PyObject.ConversionException
Modifier and Type | Field and Description |
---|---|
protected boolean |
interned |
protected java.lang.String |
string |
static PyType |
TYPE |
delegator
attributes, gcMonitorGlobal, objtype
Modifier | Constructor and Description |
---|---|
|
PyString() |
|
PyString(char c) |
|
PyString(PyType subType,
java.lang.String string)
Fundamental constructor for
PyString objects when the client provides a Java
String , necessitating that we range check the characters. |
protected |
PyString(PyType subType,
java.lang.String string,
boolean isBytes) |
|
PyString(java.lang.String string) |
Modifier and Type | Method and Description |
---|---|
PyObject |
__add__(PyObject other)
Equivalent to the standard Python __add__ method.
|
int |
__cmp__(PyObject other)
Equivalent to the standard Python __cmp__ method.
|
PyComplex |
__complex__()
Equivalent to the standard Python __complex__ method.
|
boolean |
__contains__(PyObject o)
Equivalent to the standard Python __contains__ method.
|
PyObject |
__eq__(PyObject other)
Equivalent to the standard Python __eq__ method.
|
PyFloat |
__float__()
Equivalent to the standard Python __float__ method.
|
PyObject |
__format__(PyObject formatSpec) |
PyObject |
__ge__(PyObject other)
Equivalent to the standard Python __ge__ method.
|
PyTuple |
__getnewargs__() |
PyObject |
__gt__(PyObject other)
Equivalent to the standard Python __gt__ method.
|
PyObject |
__int__()
Equivalent to the standard Python __int__ method.
|
PyObject |
__invert__()
Equivalent to the standard Python __invert__ method.
|
PyObject |
__le__(PyObject other)
Equivalent to the standard Python __le__ method.
|
int |
__len__()
Equivalent to the standard Python __len__ method.
|
PyObject |
__long__()
Equivalent to the standard Python __long__ method.
|
PyObject |
__lt__(PyObject other)
Equivalent to the standard Python __lt__ method.
|
PyObject |
__mod__(PyObject other)
Equivalent to the standard Python __mod__ method
|
PyObject |
__mul__(PyObject o)
Equivalent to the standard Python __mul__ method.
|
PyObject |
__ne__(PyObject other)
Equivalent to the standard Python __ne__ method.
|
PyObject |
__neg__()
Equivalent to the standard Python __neg__ method.
|
PyObject |
__pos__()
Equivalent to the standard Python __pos__ method.
|
PyString |
__repr__()
Equivalent to the standard Python
__repr__ method. |
PyObject |
__rmul__(PyObject o)
Equivalent to the standard Python __rmul__ method.
|
PyString |
__str__()
Equivalent to the standard Python __str__ method.
|
java.lang.Object |
__tojava__(java.lang.Class<?> c)
Equivalent to the Jython __tojava__ method.
|
PyUnicode |
__unicode__() |
protected int |
_count(java.lang.String sub,
PyObject startObj,
PyObject endObj)
Helper common to the Python and Java API returning the number of occurrences of a substring.
|
protected int |
_find(java.lang.String sub,
PyObject startObj,
PyObject endObj)
Helper common to the Python and Java API returning the index of the substring or -1 for not
found.
|
protected int |
_findLeft(int right)
Helper for
strip , lstrip implementation, when stripping whitespace. |
protected int |
_findRight()
Helper for
strip , rstrip implementation, when stripping whitespace. |
protected java.lang.String |
_lstrip()
Implementation of Python
str.lstrip() common to exposed and Java API, when
stripping whitespace. |
protected java.lang.String |
_lstrip(java.lang.String stripChars)
Implementation of Python
str.lstrip() common to exposed and Java API. |
protected PyString |
_replace(java.lang.String oldPiece,
java.lang.String newPiece,
int count)
Helper common to the Python and Java API for
str.replace , returning a new string
equal to this string with ocurrences of oldPiece replaced by
newPiece , up to a maximum of count occurrences, or all of them. |
protected int |
_rfind(java.lang.String sub,
PyObject startObj,
PyObject endObj)
Helper common to the Python and Java API returning the last index of the substring or -1 for
not found.
|
protected PyList |
_rsplit(java.lang.String sep,
int maxsplit)
Implementation of Python
str.rsplit() common to exposed and Java API returning a
PyList of PyString s. |
protected java.lang.String |
_rstrip()
Implementation of Python
str.rstrip() common to exposed and Java API, when
stripping whitespace. |
protected java.lang.String |
_rstrip(java.lang.String stripChars)
Implementation of Python
str.rstrip() common to exposed and Java API. |
protected PyList |
_split(java.lang.String sep,
int maxsplit)
Implementation of Python str.split() common to exposed and Java API returning a
PyList of PyString s. |
protected java.lang.String |
_strip()
Implementation of Python
str.strip() common to exposed and Java API, when
stripping whitespace. |
protected java.lang.String |
_strip(java.lang.String stripChars)
Implementation of Python
str.strip() common to exposed and Java API. |
double |
asDouble()
Convert this object into a double.
|
int |
asInt()
Convert this object into an int.
|
long |
asLong()
Convert this object into a long.
|
java.lang.String |
asName(int index) |
java.lang.String |
asString() |
java.lang.String |
asString(int index) |
protected static java.lang.String |
asU16BytesOrError(PyObject obj)
Return a String equivalent to the argument.
|
double |
atof()
Convert this PyString to a floating-point value according to Python rules.
|
int |
atoi() |
int |
atoi(int base) |
PyLong |
atol() |
PyLong |
atol(int base) |
protected java.lang.String |
buildFormattedString(PyObject[] args,
java.lang.String[] keywords,
MarkupIterator enclosingIterator,
java.lang.String value)
Implements PEP-3101 {}-formatting methods
str.format() and
unicode.format() . |
java.lang.String |
capitalize() |
java.lang.String |
center(int width) |
char |
charAt(int index) |
protected int |
checkIndex(int index)
A little helper for converting str.find to str.index that will raise
ValueError("substring not found") if the argument is negative, otherwise passes
the argument through. |
int |
count(PyObject sub)
Return the number of non-overlapping occurrences of substring
sub . |
int |
count(PyObject sub,
PyObject start)
Return the number of non-overlapping occurrences of substring
sub in the range
[start:] . |
int |
count(PyObject sub,
PyObject start,
PyObject end)
Return the number of non-overlapping occurrences of substring
sub in the range
[start:end] . |
int |
count(java.lang.String sub)
Equivalent to
count(PyObject) specialized to String . |
int |
count(java.lang.String sub,
PyObject start)
Equivalent to
count(PyObject, PyObject) specialized to String . |
int |
count(java.lang.String sub,
PyObject start,
PyObject end)
Equivalent to
count(PyObject, PyObject, PyObject) specialized to String
. |
PyString |
createInstance(java.lang.String str)
Create an instance of the same type as this object, from the Java String given as argument.
|
protected PyString |
createInstance(java.lang.String str,
boolean isBasic)
Create an instance of the same type as this object, from the Java String given as argument.
|
static java.lang.String |
decode_UnicodeEscape(java.lang.String str,
int start,
int end,
java.lang.String errors,
boolean unicode) |
PyObject |
decode() |
PyObject |
decode(java.lang.String encoding) |
PyObject |
decode(java.lang.String encoding,
java.lang.String errors) |
static java.lang.String |
encode_UnicodeEscape(java.lang.String str,
boolean use_quotes) |
java.lang.String |
encode() |
java.lang.String |
encode(java.lang.String encoding) |
java.lang.String |
encode(java.lang.String encoding,
java.lang.String errors) |
boolean |
endswith(PyObject suffix)
Equivalent to the Python
str.endswith method, testing whether a string ends with
a specified suffix. |
boolean |
endswith(PyObject suffix,
PyObject start)
Equivalent to the Python
str.endswith method, testing whether a string ends with
a specified suffix, where a sub-range is specified by [start:] . |
boolean |
endswith(PyObject suffix,
PyObject start,
PyObject end)
Equivalent to the Python
str.endswith method, testing whether a string ends with
a specified suffix, where a sub-range is specified by [start:end] . |
java.lang.String |
expandtabs() |
java.lang.String |
expandtabs(int tabsize) |
int |
find(PyObject sub)
Return the lowest index in the string where substring
sub is found. |
int |
find(PyObject sub,
PyObject start)
Return the lowest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:] . |
int |
find(PyObject sub,
PyObject start,
PyObject end)
Return the lowest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:end] . |
int |
find(java.lang.String sub)
Equivalent to
find(PyObject) specialized to String . |
int |
find(java.lang.String sub,
PyObject start)
Equivalent to
find(PyObject, PyObject) specialized to String . |
int |
find(java.lang.String sub,
PyObject start,
PyObject end)
Equivalent to
find(PyObject, PyObject, PyObject) specialized to String . |
static PyString |
fromInterned(java.lang.String interned)
Creates a
PyString from an already interned String representing bytes. |
protected PyString |
fromSubstring(int begin,
int end)
Return a new object of the same type as this one equal to the slice
[begin:end] . |
PyBuffer |
getBuffer(int flags)
Return a read-only buffer view of the contents of the string, treating it as a sequence of
unsigned bytes.
|
int |
getInt(int i) |
protected PyObject |
getslice(int start,
int stop,
int step)
Returns a range of elements from the sequence.
|
java.lang.String |
getString() |
int |
hashCode() |
int |
index(PyObject sub)
Return the lowest index in the string where substring
sub is found. |
int |
index(PyObject sub,
PyObject start)
Return the lowest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:] . |
int |
index(PyObject sub,
PyObject start,
PyObject end)
Return the lowest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:end] . |
int |
index(java.lang.String sub)
Equivalent to
index(PyObject) specialized to String . |
int |
index(java.lang.String sub,
PyObject start)
Equivalent to
index(PyObject, PyObject) specialized to String . |
int |
index(java.lang.String sub,
PyObject start,
PyObject end)
Equivalent to
index(PyObject, PyObject, PyObject) specialized to String
. |
java.lang.String |
internedString() |
boolean |
isalnum() |
boolean |
isalpha() |
boolean |
isBasicPlane()
Determine whether the string consists entirely of basic-plane characters.
|
boolean |
isdecimal() |
boolean |
isdigit() |
boolean |
islower() |
boolean |
isnumeric() |
boolean |
isspace() |
boolean |
istitle() |
boolean |
isunicode() |
boolean |
isupper() |
PyString |
join(PyObject seq) |
int |
length() |
java.lang.String |
ljust(int width) |
java.lang.String |
ljust(int width,
java.lang.String padding) |
java.lang.String |
lower() |
java.lang.String |
lstrip()
Equivalent of Python
str.lstrip() with no argument, meaning strip whitespace. |
PyObject |
lstrip(PyObject stripChars)
Equivalent of Python
str.lstrip() . |
java.lang.String |
lstrip(java.lang.String stripChars)
Equivalent of Python
str.lstrip() . |
PyTuple |
partition(PyObject sepObj)
Equivalent to Python
str.partition() , splits the PyString at the
first occurrence of sepObj returning a PyTuple containing the part
before the separator, the separator itself, and the part after the separator. |
protected PyObject |
pyget(int i)
Returns the element of the sequence at the given index.
|
protected PyObject |
repeat(int count)
Returns a (concrete subclass of) PySequence that repeats the given sequence, as in the
implementation of
__mul__ for strings. |
PyString |
replace(PyObject oldPiece,
PyObject newPiece)
Equivalent to Python str.replace(old, new), returning a copy of the string with all
occurrences of substring old replaced by new.
|
PyString |
replace(PyObject oldPiece,
PyObject newPiece,
int count)
Equivalent to Python str.replace(old, new[, count]), returning a copy of the string with all
occurrences of substring old replaced by new.
|
int |
rfind(PyObject sub)
Return the highest index in the string where substring
sub is found. |
int |
rfind(PyObject sub,
PyObject start)
Return the highest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:] . |
int |
rfind(PyObject sub,
PyObject start,
PyObject end)
Return the highest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:end] . |
int |
rfind(java.lang.String sub)
Equivalent to
find(PyObject) specialized to String . |
int |
rfind(java.lang.String sub,
PyObject start)
Equivalent to
find(PyObject, PyObject) specialized to String . |
int |
rfind(java.lang.String sub,
PyObject start,
PyObject end)
Equivalent to
find(PyObject, PyObject, PyObject) specialized to String . |
int |
rindex(PyObject sub)
Return the highest index in the string where substring
sub is found. |
int |
rindex(PyObject sub,
PyObject start)
Return the highest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:] . |
int |
rindex(PyObject sub,
PyObject start,
PyObject end)
Return the highest index in the string where substring
sub is found, such that
sub is contained in the slice s[start:end] . |
int |
rindex(java.lang.String sub)
Equivalent to
rindex(PyObject) specialized to String . |
int |
rindex(java.lang.String sub,
PyObject start)
Equivalent to
rindex(PyObject, PyObject) specialized to String . |
int |
rindex(java.lang.String sub,
PyObject start,
PyObject end)
Equivalent to
rindex(PyObject, PyObject, PyObject) specialized to
String . |
java.lang.String |
rjust(int width) |
PyTuple |
rpartition(PyObject sepObj)
Equivalent to Python
str.rpartition() , splits the PyString at the
last occurrence of sepObj returning a PyTuple containing the part before
the separator, the separator itself, and the part after the separator. |
PyList |
rsplit()
Equivalent to Python
str.rsplit() , splitting on runs of whitespace. |
PyList |
rsplit(PyObject sep)
|
PyList |
rsplit(PyObject sep,
int maxsplit)
As
rsplit(PyObject) but if maxsplit >=0 and there are more feasible
splits than maxsplit the last element of the list contains the rest of the
string. |
PyList |
rsplit(java.lang.String sep)
Equivalent to Python
str.rsplit() , splitting on a specified string. |
PyList |
rsplit(java.lang.String sep,
int maxsplit)
Equivalent to Python
str.rsplit() , splitting on a specified string. |
protected PyList |
rsplitfields(int maxsplit)
Helper function for
.rsplit , in str and (when overridden) in
unicode , splitting on white space and returning a list of the separated parts. |
java.lang.String |
rstrip()
Equivalent of Python
str.rstrip() with no argument, meaning strip whitespace. |
PyObject |
rstrip(PyObject stripChars)
Equivalent of Python
str.rstrip() . |
java.lang.String |
rstrip(java.lang.String stripChars)
Equivalent of Python
str.rstrip() . |
PyList |
split()
Equivalent to Python
str.split() , splitting on runs of whitespace. |
PyList |
split(PyObject sep)
|
PyList |
split(PyObject sep,
int maxsplit)
As
split(PyObject) but if maxsplit >=0 and there are more feasible
splits than maxsplit , the last element of the list contains the rest of the
string. |
PyList |
split(java.lang.String sep)
Equivalent to Python
str.split() , splitting on a specified string. |
PyList |
split(java.lang.String sep,
int maxsplit)
Equivalent to Python
str.split() , splitting on a specified string. |
protected PyList |
splitfields(int maxsplit)
Helper function for
.split , in str and (when overridden) in
unicode , splitting on white space and returning a list of the separated parts. |
PyList |
splitlines() |
PyList |
splitlines(boolean keepends) |
boolean |
startswith(PyObject prefix)
Equivalent to the Python
str.startswith method testing whether a string starts
with a specified prefix. |
boolean |
startswith(PyObject prefix,
PyObject start)
Equivalent to the Python
str.startswith method, testing whether a string starts
with a specified prefix, where a sub-range is specified by [start:] . |
boolean |
startswith(PyObject prefix,
PyObject start,
PyObject end)
Equivalent to the Python
str.startswith method, testing whether a string starts
with a specified prefix, where a sub-range is specified by [start:end] . |
PyObject |
str___mod__(PyObject other) |
java.lang.String |
strip()
Equivalent of Python
str.strip() with no argument, meaning strip whitespace. |
PyObject |
strip(PyObject stripChars)
Equivalent of Python
str.strip() . |
java.lang.String |
strip(java.lang.String stripChars)
Equivalent of Python
str.strip() . |
java.lang.CharSequence |
subSequence(int start,
int end) |
java.lang.String |
substring(int start,
int end)
Return a substring of this object as a Java String.
|
java.lang.String |
swapcase() |
java.lang.String |
title() |
byte[] |
toBytes() |
int[] |
toCodePoints() |
java.lang.String |
toString() |
java.lang.String |
translate(PyObject table)
Equivalent to Python
str.translate returning a copy of this string where the
characters have been mapped through the translation table . |
java.lang.String |
translate(PyObject table,
PyObject deletechars)
Equivalent to Python
str.translate returning a copy of this string where all
characters (bytes) occurring in the argument deletechars are removed (if it is
not null ), and the remaining characters have been mapped through the translation
table . |
java.lang.String |
translate(java.lang.String table)
Equivalent to
translate(PyObject) specialized to String . |
java.lang.String |
translate(java.lang.String table,
java.lang.String deletechars)
Equivalent to
translate(PyObject, PyObject) specialized to String . |
protected int[] |
translateIndices(PyObject startObj,
PyObject endObj)
Many of the string methods deal with slices specified using Python slice semantics:
endpoints, which are
PyObject s, may be null or None
(meaning default to one end or the other) or may be negative (meaning "from the end"). |
protected java.lang.String |
unsupportedopMessage(java.lang.String op,
PyObject o2)
Return sequence-specific error messages suitable for substitution.
|
java.lang.String |
upper() |
java.lang.String |
zfill(int width) |
__delitem__, __delslice__, __finditem__, __finditem__, __getitem__, __getslice__, __iter__, __nonzero__, __setitem__, __setitem__, __setslice__, boundToSequence, cmp, del, delRange, delslice, fastSequence, isMappingType, isNumberType, isSequenceType, isSubType, pyset, runsupportedopMessage, setslice, sliceLength
__abs__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __coerce__, __coerce_ex__, __delattr__, __delattr__, __delete__, __delitem__, __delslice__, __dir__, __div__, __divmod__, __ensure_finalizer__, __findattr__, __findattr__, __findattr_ex__, __finditem__, __floordiv__, __get__, __getattr__, __getattr__, __getitem__, __getslice__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __index__, __ior__, __ipow__, __irshift__, __isub__, __iternext__, __itruediv__, __ixor__, __lshift__, __not__, __oct__, __or__, __pow__, __pow__, __radd__, __rand__, __rawdir__, __rdiv__, __rdivmod__, __reduce__, __reduce_ex__, __reduce_ex__, __rfloordiv__, __rlshift__, __rmod__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setslice__, __sub__, __truediv__, __trunc__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _iadd, _iand, _idiv, _idivmod, _ifloordiv, _ilshift, _imod, _imul, _in, _ior, _ipow, _irshift, _is, _isnot, _isub, _itruediv, _ixor, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _unsupportedop, _xor, adaptToCoerceTuple, asIndex, asIndex, asInt, asIterable, asLong, asName, asStringOrNull, asStringOrNull, bit_length, conjugate, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, finalize, getDict, getJavaProxy, getType, impAttr, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, isInteger, mergeClassDict, mergeDictAttr, mergeListAttr, noAttributeError, object___subclasshook__, readonlyAttributeError, setDict, setType
public static final PyType TYPE
protected java.lang.String string
protected transient boolean interned
public PyString()
protected PyString(PyType subType, java.lang.String string, boolean isBytes)
public PyString(PyType subType, java.lang.String string)
PyString
objects when the client provides a Java
String
, necessitating that we range check the characters.subType
- the actual type being constructedstring
- a Java String to be wrappedpublic PyString(java.lang.String string)
public PyString(char c)
public java.lang.String getString()
public static PyString fromInterned(java.lang.String interned)
PyString
from an already interned String
representing bytes. The
caller guarantees that the character codes are all < 256. (The method is used frequently
from compiled code, and with identifiers, where this is guaranteed.) Just means it won't be
re-interned if used in a place that requires interned Strings.interned
- String
representing bytesPyString
for those bytespublic boolean isBasicPlane()
PyString
, of course, it is always true
, but this is useful in cases
where either a PyString
or a PyUnicode
is acceptable.public int[] toCodePoints()
public PyBuffer getBuffer(int flags)
flags
argument (see the constants in interface PyBUF
for an
explanation). The method may return the same PyBuffer object to more than one consumer.getBuffer
in interface BufferProtocol
flags
- consumer requirementspublic java.lang.String substring(int start, int end)
start
- the beginning index, inclusive.end
- the ending index, exclusive.public PyString __str__()
PyObject
PyObject
) calls PyObject.__repr__()
, making it unnecessary to override
__str__
in sub-classes of PyObject
where both forms are the same. A
common choice is to provide the same implementation to __str__
and
toString
, for consistency in the printed form of objects between Python and
Java.public PyUnicode __unicode__()
__unicode__
in class PyObject
public int __len__()
PyObject
public java.lang.String toString()
public java.lang.String internedString()
public PyString __repr__()
PyObject
__repr__
method. Each sub-class of
PyObject
is likely to re-define this method to provide for its own reproduction.public static java.lang.String encode_UnicodeEscape(java.lang.String str, boolean use_quotes)
public static java.lang.String decode_UnicodeEscape(java.lang.String str, int start, int end, java.lang.String errors, boolean unicode)
public int __cmp__(PyObject other)
PyObject
public PyObject __eq__(PyObject other)
PyObject
__eq__
in class PySequence
other
- the object to compare this with.public PyObject __ne__(PyObject other)
PyObject
__ne__
in class PySequence
other
- the object to compare this with.public PyObject __lt__(PyObject other)
PyObject
__lt__
in class PySequence
other
- the object to compare this with.public PyObject __le__(PyObject other)
PyObject
__le__
in class PySequence
other
- the object to compare this with.public PyObject __gt__(PyObject other)
PyObject
__gt__
in class PySequence
other
- the object to compare this with.public PyObject __ge__(PyObject other)
PyObject
__ge__
in class PySequence
other
- the object to compare this with.public byte[] toBytes()
public java.lang.Object __tojava__(java.lang.Class<?> c)
PyObject
Py.NoConversion
if this
PyObject
can not be converted to the desired Java class.__tojava__
in class PySequence
c
- the Class to convert this PyObject
to.protected PyObject pyget(int i)
PySequence
PySequence.__getitem__(org.python.core.PyObject)
It is guaranteed by PySequence that
when it calls pyget(int)
the index is within the bounds of the array. Any other
clients must make the same guarantee.pyget
in class PySequence
i
- index of element to return.public int getInt(int i)
protected PyObject getslice(int start, int stop, int step)
PySequence
getslice
in class PySequence
start
- the position of the first element.stop
- one more than the position of the last element.step
- the step size.public PyString createInstance(java.lang.String str)
str
- to wrapstr
protected PyString createInstance(java.lang.String str, boolean isBasic)
str
- Java string representing the characters (as Java UTF-16).isBasic
- is ignored in PyString
(effectively true).str
protected static java.lang.String asU16BytesOrError(PyObject obj) throws PyException
unicode
.obj
- to coerce to a StringPyException
- TypeError
if the coercion fails (including unicode
)public boolean __contains__(PyObject o)
PyObject
__contains__
in class PyObject
o
- the element to search for in this container.protected PyObject repeat(int count)
PySequence
__mul__
for strings.repeat
in class PySequence
count
- the number of times to repeat the sequence.public PyObject __mul__(PyObject o)
PyObject
public PyObject __rmul__(PyObject o)
PyObject
public PyTuple __getnewargs__()
__getnewargs__
in class PyObject
public PyObject __mod__(PyObject other)
PyObject
public PyObject __int__()
PyObject
public PyObject __long__()
PyObject
public PyFloat __float__()
PyObject
public PyObject __pos__()
PyObject
public PyObject __neg__()
PyObject
public PyObject __invert__()
PyObject
__invert__
in class PyObject
public PyComplex __complex__()
PyObject
__complex__
in class PyObject
public java.lang.String lower()
public java.lang.String upper()
public java.lang.String title()
public java.lang.String swapcase()
public java.lang.String strip()
str.strip()
with no argument, meaning strip whitespace. Any
whitespace byte/character will be discarded from either end of this str
.public java.lang.String strip(java.lang.String stripChars)
str.strip()
.stripChars
- characters to strip from either end of this str/bytes, or nullpublic PyObject strip(PyObject stripChars)
str.strip()
. Any byte/character matching one of those in
stripChars
will be discarded from either end of this str
. If
stripChars == null
, whitespace will be stripped. If stripChars
is a
PyUnicode
, the result will also be a PyUnicode
.stripChars
- characters to strip from either end of this str/bytes, or nullPyString
(or PyUnicode
), stripped of the specified
characters/bytesprotected final java.lang.String _strip()
str.strip()
common to exposed and Java API, when
stripping whitespace. Any whitespace byte/character will be discarded from either end of this
str
.
Implementation note: although a str
contains only bytes, this method is also
called by PyUnicode.unicode_strip(PyObject)
when this is a basic-plane string.
protected final java.lang.String _strip(java.lang.String stripChars)
str.strip()
common to exposed and Java API. Any
byte/character matching one of those in stripChars
will be discarded from either
end of this str
. If stripChars == null
, whitespace will be
stripped.
Implementation note: although a str
contains only bytes, this method is also
called by PyUnicode.unicode_strip(PyObject)
when both arguments are basic-plane
strings.
stripChars
- characters to strip or nullprotected int _findLeft(int right)
strip
, lstrip
implementation, when stripping whitespace.right
- rightmost extent of string searchright
if they all are.protected int _findRight()
strip
, rstrip
implementation, when stripping whitespace.public java.lang.String lstrip()
str.lstrip()
with no argument, meaning strip whitespace.
Any whitespace byte/character will be discarded from the left of this str
.public java.lang.String lstrip(java.lang.String stripChars)
str.lstrip()
.stripChars
- characters to strip from the left end of this str/bytes, or nullpublic PyObject lstrip(PyObject stripChars)
str.lstrip()
. Any byte/character matching one of those in
stripChars
will be discarded from the left end of this str
. If
stripChars == null
, whitespace will be stripped. If stripChars
is a
PyUnicode
, the result will also be a PyUnicode
.stripChars
- characters to strip from the left end of this str/bytes, or nullPyString
(or PyUnicode
), stripped of the specified
characters/bytesprotected final java.lang.String _lstrip()
str.lstrip()
common to exposed and Java API, when
stripping whitespace. Any whitespace byte/character will be discarded from the left end of
this str
.
Implementation note: although a str contains only bytes, this method is also called by
PyUnicode.unicode_lstrip(PyObject)
when this is a basic-plane string.
protected final java.lang.String _lstrip(java.lang.String stripChars)
str.lstrip()
common to exposed and Java API. Any
byte/character matching one of those in stripChars
will be discarded from the
left end of this str
. If stripChars == null
, whitespace will be
stripped.
Implementation note: although a str
contains only bytes, this method is also
called by PyUnicode.unicode_lstrip(PyObject)
when both arguments are basic-plane
strings.
stripChars
- characters to strip or nullpublic java.lang.String rstrip()
str.rstrip()
with no argument, meaning strip whitespace.
Any whitespace byte/character will be discarded from the right end of this str
.public java.lang.String rstrip(java.lang.String stripChars)
str.rstrip()
.stripChars
- characters to strip from either end of this str/bytes, or nullpublic PyObject rstrip(PyObject stripChars)
str.rstrip()
. Any byte/character matching one of those in
stripChars
will be discarded from the right end of this str
. If
stripChars == null
, whitespace will be stripped. If stripChars
is a
PyUnicode
, the result will also be a PyUnicode
.stripChars
- characters to strip from the right end of this str/bytes, or nullPyString
(or PyUnicode
), stripped of the specified
characters/bytesprotected final java.lang.String _rstrip()
str.rstrip()
common to exposed and Java API, when
stripping whitespace. Any whitespace byte/character will be discarded from the right end of
this str
.
Implementation note: although a str
contains only bytes, this method is also
called by PyUnicode.unicode_rstrip(PyObject)
when this is a basic-plane string.
protected final java.lang.String _rstrip(java.lang.String stripChars)
str.rstrip()
common to exposed and Java API. Any
byte/character matching one of those in stripChars
will be discarded from the
right end of this str
. If stripChars == null
, whitespace will be
stripped.
Implementation note: although a str
contains only bytes, this method is also
called by PyUnicode.unicode_strip(PyObject)
when both arguments are basic-plane
strings.
stripChars
- characters to strip or nullpublic PyList split()
str.split()
, splitting on runs of whitespace.public PyList split(java.lang.String sep)
str.split()
, splitting on a specified string.sep
- string to use as separator (or null
if to split on whitespace)public PyList split(java.lang.String sep, int maxsplit)
str.split()
, splitting on a specified string.sep
- string to use as separator (or null
if to split on whitespace)maxsplit
- maximum number of splits to make (there may be maxsplit+1
parts).public PyList split(PyObject sep)
str.split()
returning a PyList
of
PyString
s (or PyUnicode
s). The str
will be split at
each occurrence of sep
. If sep == null
, whitespace will be used as
the criterion. If sep
has zero length, a Python ValueError
is
raised.sep
- string to use as separator (or null
if to split on whitespace)public PyList split(PyObject sep, int maxsplit)
split(PyObject)
but if maxsplit
>=0 and there are more feasible
splits than maxsplit
, the last element of the list contains the rest of the
string.sep
- string to use as separator (or null
if to split on whitespace)maxsplit
- maximum number of splits to make (there may be maxsplit+1
parts).protected final PyList _split(java.lang.String sep, int maxsplit)
PyList
of PyString
s. The str
will be split at each
occurrence of sep
. If sep == null
, whitespace will be used as the
criterion. If sep
has zero length, a Python ValueError
is raised.
If maxsplit
>=0 and there are more feasible splits than maxsplit
the last element of the list contains the what is left over after the last split.
Implementation note: although a str contains only bytes, this method is also called by
PyUnicode.unicode_split(PyObject, int)
.
sep
- string to use as separator (or null
if to split on whitespace)maxsplit
- maximum number of splits to make (there may be maxsplit+1
parts).protected PyList splitfields(int maxsplit)
.split
, in str
and (when overridden) in
unicode
, splitting on white space and returning a list of the separated parts.
If there are more than maxsplit
feasible splits the last element of the list is
the remainder of the original (this) string.maxsplit
- limit on the number of splits (if >=0)PyList
of split sectionspublic PyList rsplit()
str.rsplit()
, splitting on runs of whitespace.public PyList rsplit(java.lang.String sep)
str.rsplit()
, splitting on a specified string.sep
- string to use as separator (or null
if to split on whitespace)public PyList rsplit(java.lang.String sep, int maxsplit)
str.rsplit()
, splitting on a specified string.sep
- string to use as separator (or null
if to split on whitespace)maxsplit
- maximum number of splits to make (there may be maxsplit+1
parts).public PyList rsplit(PyObject sep)
str.rsplit()
returning a PyList
of
PyString
s (or PyUnicode
s). The str
will be split at
each occurrence of sep
, working from the right. If sep == null
,
whitespace will be used as the criterion. If sep
has zero length, a Python
ValueError
is raised.sep
- string to use as separator (or null
if to split on whitespace)public PyList rsplit(PyObject sep, int maxsplit)
rsplit(PyObject)
but if maxsplit
>=0 and there are more feasible
splits than maxsplit
the last element of the list contains the rest of the
string.sep
- string to use as separator (or null
if to split on whitespace)maxsplit
- maximum number of splits to make (there may be maxsplit+1
parts).protected final PyList _rsplit(java.lang.String sep, int maxsplit)
str.rsplit()
common to exposed and Java API returning a
PyList
of PyString
s. The str
will be split at each
occurrence of sep
, working from the right. If sep == null
,
whitespace will be used as the criterion. If sep
has zero length, a Python
ValueError
is raised. If maxsplit
>=0 and there are more
feasible splits than maxsplit
the first element of the list contains the what is
left over after the last split.
Implementation note: although a str contains only bytes, this method is also called by
PyUnicode.unicode_rsplit(PyObject, int)
.
sep
- string to use as separator (or null
if to split on whitespace)maxsplit
- maximum number of splits to make (there may be maxsplit+1
parts).protected PyList rsplitfields(int maxsplit)
.rsplit
, in str
and (when overridden) in
unicode
, splitting on white space and returning a list of the separated parts.
If there are more than maxsplit
feasible splits the first element of the list is
the remainder of the original (this) string.maxsplit
- limit on the number of splits (if >=0)PyList
of split sectionspublic PyTuple partition(PyObject sepObj)
str.partition()
, splits the PyString
at the
first occurrence of sepObj
returning a PyTuple
containing the part
before the separator, the separator itself, and the part after the separator.sepObj
- str, unicode or object implementing BufferProtocol
public PyTuple rpartition(PyObject sepObj)
str.rpartition()
, splits the PyString
at the
last occurrence of sepObj
returning a PyTuple
containing the part before
the separator, the separator itself, and the part after the separator.sepObj
- str, unicode or object implementing BufferProtocol
public PyList splitlines()
public PyList splitlines(boolean keepends)
protected PyString fromSubstring(int begin, int end)
[begin:end]
. (Python end-relative indexes etc. are not supported.) Subclasses (
PyUnicode.fromSubstring(int, int)
) override this to return their own type.)begin
- first included character.end
- first excluded character.public int index(PyObject sub)
sub
is found. Raises
ValueError
if the substring is not found.sub
- substring to find.sub
in this object.PyException
- ValueError
if not found.public int index(PyObject sub, PyObject start) throws PyException
sub
is found, such that
sub
is contained in the slice s[start:]
. Raises
ValueError
if the substring is not found.sub
- substring to find.start
- start of slice.sub
in this object.PyException
- ValueError
if not found.public int index(PyObject sub, PyObject start, PyObject end) throws PyException
sub
is found, such that
sub
is contained in the slice s[start:end]
. Arguments
start
and end
are interpreted as in slice notation, with null or
Py.None
representing "missing". Raises ValueError
if the substring is
not found.sub
- substring to find.start
- start of slice.end
- end of slice.sub
in this object.PyException
- ValueError
if not found.public int index(java.lang.String sub)
index(PyObject)
specialized to String
.public int index(java.lang.String sub, PyObject start)
index(PyObject, PyObject)
specialized to String
.public int index(java.lang.String sub, PyObject start, PyObject end)
index(PyObject, PyObject, PyObject)
specialized to String
.public int rindex(PyObject sub)
sub
is found. Raises
ValueError
if the substring is not found.sub
- substring to find.sub
in this object.PyException
- ValueError
if not found.public int rindex(PyObject sub, PyObject start) throws PyException
sub
is found, such that
sub
is contained in the slice s[start:]
. Raises
ValueError
if the substring is not found.sub
- substring to find.start
- start of slice.sub
in this object.PyException
- ValueError
if not found.public int rindex(PyObject sub, PyObject start, PyObject end) throws PyException
sub
is found, such that
sub
is contained in the slice s[start:end]
. Arguments
start
and end
are interpreted as in slice notation, with null or
Py.None
representing "missing". Raises ValueError
if the substring is
not found.sub
- substring to find.start
- start of slice.end
- end of slice.sub
in this object.PyException
- ValueError
if not found.public int rindex(java.lang.String sub)
rindex(PyObject)
specialized to String
.public int rindex(java.lang.String sub, PyObject start)
rindex(PyObject, PyObject)
specialized to String
.public int rindex(java.lang.String sub, PyObject start, PyObject end)
rindex(PyObject, PyObject, PyObject)
specialized to
String
.protected final int checkIndex(int index) throws PyException
ValueError("substring not found")
if the argument is negative, otherwise passes
the argument through.index
- to checkindex
if non-negativePyException
- ValueError
if not foundpublic int count(PyObject sub)
sub
.sub
- substring to find.public int count(PyObject sub, PyObject start)
sub
in the range
[start:]
.sub
- substring to find.start
- start of slice.public int count(PyObject sub, PyObject start, PyObject end)
sub
in the range
[start:end]
. Optional arguments start
and end
are
interpreted as in slice notation.sub
- substring to find.start
- start of slice.end
- end of slice.public int count(java.lang.String sub)
count(PyObject)
specialized to String
.public int count(java.lang.String sub, PyObject start)
count(PyObject, PyObject)
specialized to String
.public int count(java.lang.String sub, PyObject start, PyObject end)
count(PyObject, PyObject, PyObject)
specialized to String
.protected final int _count(java.lang.String sub, PyObject startObj, PyObject endObj)
None
or end-relative (negative).
This method also supports PyUnicode.unicode_count(PyObject, PyObject, PyObject)
.sub
- substring to find.startObj
- start of slice.endObj
- end of slice.public int find(PyObject sub)
sub
is found.sub
- substring to find.sub
in this object or -1 if not found.public int find(PyObject sub, PyObject start)
sub
is found, such that
sub
is contained in the slice s[start:]
.sub
- substring to find.start
- start of slice.sub
in this object or -1 if not found.public int find(PyObject sub, PyObject start, PyObject end)
sub
is found, such that
sub
is contained in the slice s[start:end]
. Arguments
start
and end
are interpreted as in slice notation, with null or
Py.None
representing "missing".sub
- substring to find.start
- start of slice.end
- end of slice.sub
in this object or -1 if not found.public int find(java.lang.String sub)
find(PyObject)
specialized to String
.public int find(java.lang.String sub, PyObject start)
find(PyObject, PyObject)
specialized to String
.public int find(java.lang.String sub, PyObject start, PyObject end)
find(PyObject, PyObject, PyObject)
specialized to String
.protected final int _find(java.lang.String sub, PyObject startObj, PyObject endObj)
None
or end-relative
(negative). This method also supports
PyUnicode.unicode_find(PyObject, PyObject, PyObject)
.sub
- substring to find.startObj
- start of slice.endObj
- end of slice.sub
in this object or -1 if not found.public int rfind(PyObject sub)
sub
is found.sub
- substring to find.sub
in this object or -1 if not found.public int rfind(PyObject sub, PyObject start)
sub
is found, such that
sub
is contained in the slice s[start:]
.sub
- substring to find.start
- start of slice.sub
in this object or -1 if not found.public int rfind(PyObject sub, PyObject start, PyObject end)
sub
is found, such that
sub
is contained in the slice s[start:end]
. Arguments
start
and end
are interpreted as in slice notation, with null or
Py.None
representing "missing".sub
- substring to find.start
- start of slice.end
- end of slice.sub
in this object or -1 if not found.public int rfind(java.lang.String sub)
find(PyObject)
specialized to String
.public int rfind(java.lang.String sub, PyObject start)
find(PyObject, PyObject)
specialized to String
.public int rfind(java.lang.String sub, PyObject start, PyObject end)
find(PyObject, PyObject, PyObject)
specialized to String
.protected final int _rfind(java.lang.String sub, PyObject startObj, PyObject endObj)
None
or end-relative
(negative). This method also supports
PyUnicode.unicode_rfind(PyObject, PyObject, PyObject)
.sub
- substring to find.startObj
- start of slice.endObj
- end of slice.sub
in this object or -1 if not found.public double atof()
public int atoi()
public int atoi(int base)
public PyLong atol()
public PyLong atol(int base)
public java.lang.String ljust(int width)
public java.lang.String ljust(int width, java.lang.String padding)
public java.lang.String rjust(int width)
public java.lang.String center(int width)
public java.lang.String zfill(int width)
public java.lang.String expandtabs()
public java.lang.String expandtabs(int tabsize)
public java.lang.String capitalize()
public PyString replace(PyObject oldPiece, PyObject newPiece)
PyUnicode
(or
this object is), the result will be a PyUnicode
.oldPiece
- to replace where found.newPiece
- replacement text.public PyString replace(PyObject oldPiece, PyObject newPiece, int count)
count
is nonnegative,
only the first count
occurrences are replaced. If either argument is a
PyUnicode
(or this object is), the result will be a PyUnicode
.oldPiece
- to replace where found.newPiece
- replacement text.count
- maximum number of replacements to make, or -1 meaning all of them.protected final PyString _replace(java.lang.String oldPiece, java.lang.String newPiece, int count)
str.replace
, returning a new string
equal to this string with ocurrences of oldPiece
replaced by
newPiece
, up to a maximum of count
occurrences, or all of them.
This method also supports PyUnicode.unicode_replace(PyObject, PyObject, int)
, in
which context it returns a PyUnicode
oldPiece
- to replace where found.newPiece
- replacement text.count
- maximum number of replacements to make, or -1 meaning all of them.public boolean startswith(PyObject prefix)
str.startswith
method testing whether a string starts
with a specified prefix. prefix
can also be a tuple of prefixes to look for.prefix
- string to check for (or a PyTuple
of them).true
if this string slice starts with a specified prefix, otherwise
false
.public boolean startswith(PyObject prefix, PyObject start)
str.startswith
method, testing whether a string starts
with a specified prefix, where a sub-range is specified by [start:]
.
start
is interpreted as in slice notation, with null or Py.None
representing "missing". prefix
can also be a tuple of prefixes to look for.prefix
- string to check for (or a PyTuple
of them).start
- start of slice.true
if this string slice starts with a specified prefix, otherwise
false
.public boolean startswith(PyObject prefix, PyObject start, PyObject end)
str.startswith
method, testing whether a string starts
with a specified prefix, where a sub-range is specified by [start:end]
.
Arguments start
and end
are interpreted as in slice notation, with
null or Py.None
representing "missing". prefix
can also be a tuple of
prefixes to look for.prefix
- string to check for (or a PyTuple
of them).start
- start of slice.end
- end of slice.true
if this string slice starts with a specified prefix, otherwise
false
.public boolean endswith(PyObject suffix)
str.endswith
method, testing whether a string ends with
a specified suffix. suffix
can also be a tuple of suffixes to look for.suffix
- string to check for (or a PyTuple
of them).true
if this string slice ends with a specified suffix, otherwise
false
.public boolean endswith(PyObject suffix, PyObject start)
str.endswith
method, testing whether a string ends with
a specified suffix, where a sub-range is specified by [start:]
.
start
is interpreted as in slice notation, with null or Py.None
representing "missing". suffix
can also be a tuple of suffixes to look for.suffix
- string to check for (or a PyTuple
of them).start
- start of slice.true
if this string slice ends with a specified suffix, otherwise
false
.public boolean endswith(PyObject suffix, PyObject start, PyObject end)
str.endswith
method, testing whether a string ends with
a specified suffix, where a sub-range is specified by [start:end]
. Arguments
start
and end
are interpreted as in slice notation, with null or
Py.None
representing "missing". suffix
can also be a tuple of suffixes
to look for.suffix
- string to check for (or a PyTuple
of them).start
- start of slice.end
- end of slice.true
if this string slice ends with a specified suffix, otherwise
false
.protected int[] translateIndices(PyObject startObj, PyObject endObj)
PyObject
s, may be null
or None
(meaning default to one end or the other) or may be negative (meaning "from the end").
Meanwhile, the implementation methods need integer indices, both within the array, and
0<=start<=end<=N
the length of the array.
This method first translates the Python slice startObj
and endObj
according to the slice semantics for null and negative values, and stores these in elements 2
and 3 of the result. Then, since the end points of the range may lie outside this sequence's
bounds (in either direction) it reduces them to the nearest points satisfying
0<=start<=end<=N
, and stores these in elements [0] and [1] of the
result.
startObj
- Python start of sliceendObj
- Python end of slicepublic java.lang.String translate(PyObject table)
str.translate
returning a copy of this string where the
characters have been mapped through the translation table
. table
must be equivalent to a string of length 256 (if it is not null
).table
- of character (byte) translations (or null
)public java.lang.String translate(PyObject table, PyObject deletechars)
str.translate
returning a copy of this string where all
characters (bytes) occurring in the argument deletechars
are removed (if it is
not null
), and the remaining characters have been mapped through the translation
table
. table
must be equivalent to a string of length 256 (if it is
not null
).table
- of character (byte) translations (or null
)deletechars
- set of characters to remove (or null
)public java.lang.String translate(java.lang.String table)
translate(PyObject)
specialized to String
.public java.lang.String translate(java.lang.String table, java.lang.String deletechars)
translate(PyObject, PyObject)
specialized to String
.public boolean islower()
public boolean isupper()
public boolean isalpha()
public boolean isalnum()
public boolean isdecimal()
public boolean isdigit()
public boolean isnumeric()
public boolean istitle()
public boolean isspace()
public boolean isunicode()
public java.lang.String encode()
public java.lang.String encode(java.lang.String encoding)
public java.lang.String encode(java.lang.String encoding, java.lang.String errors)
public PyObject decode()
public PyObject decode(java.lang.String encoding)
public PyObject decode(java.lang.String encoding, java.lang.String errors)
protected java.lang.String buildFormattedString(PyObject[] args, java.lang.String[] keywords, MarkupIterator enclosingIterator, java.lang.String value)
str.format()
and
unicode.format()
. When called with enclosingIterator == null
, this
method takes this object as its formatting string. The method is also called (calls itself)
to deal with nested formatting specifications. In that case, enclosingIterator
is a MarkupIterator
on this object and value
is a substring of this
object needing recursive translation.args
- to be interpolated into the stringkeywords
- for the trailing argsenclosingIterator
- when used nested, null if subject is this PyString
value
- the format string when enclosingIterator
is not nullpublic PyObject __format__(PyObject formatSpec)
__format__
in class PyObject
public java.lang.String asString(int index) throws PyObject.ConversionException
asString
in class PyObject
PyObject.ConversionException
public int asInt()
PyObject
public long asLong()
PyObject
public double asDouble()
PyObject
public java.lang.String asName(int index) throws PyObject.ConversionException
asName
in class PyObject
PyObject.ConversionException
protected java.lang.String unsupportedopMessage(java.lang.String op, PyObject o2)
PySequence
unsupportedopMessage
in class PySequence
public char charAt(int index)
charAt
in interface java.lang.CharSequence
charAt
in class PyBaseString
public int length()
length
in interface java.lang.CharSequence
length
in class PyBaseString
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
subSequence
in class PyBaseString