Package org.python.core
Class PyString
- java.lang.Object
-
- org.python.core.PyObject
-
- org.python.core.PySequence
-
- org.python.core.PyBaseString
-
- org.python.core.PyString
-
- All Implemented Interfaces:
java.io.Serializable,ClassDictInit
- Direct Known Subclasses:
PyStringDerived,PyUnicode,SyspathArchive
public class PyString extends PyBaseString implements ClassDictInit
A builtin python string.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.python.core.PyObject
PyObject.ConversionException
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Stringexposed_name-
Fields inherited from class org.python.core.PyBaseString
exposed_base
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PyObject__add__(PyObject generic_other)Equivalent to the standard Python __add__ methodint__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__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.PyLong__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__ methodPyObject__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.PyObject__reduce__()Used for pickling.PyString__repr__()Equivalent to the standard Python __repr__ 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__()java.lang.StringasName(int index)java.lang.StringasString(int index)doubleatof()intatoi()intatoi(int base)PyLongatol()PyLongatol(int base)java.lang.Stringcapitalize()java.lang.Stringcenter(int width)static voidclassDictInit(PyObject dict)Internal use only.intcount(java.lang.String sub)intcount(java.lang.String sub, int start)intcount(java.lang.String sub, int start, int end)PyStringcreateInstance(java.lang.String str)java.lang.Stringdecode()java.lang.Stringdecode(java.lang.String encoding)java.lang.Stringdecode(java.lang.String encoding, java.lang.String errors)static java.lang.Stringdecode_UnicodeEscape(java.lang.String str, int start, int end, java.lang.String errors, boolean unicode)java.lang.Stringencode()java.lang.Stringencode(java.lang.String encoding)java.lang.Stringencode(java.lang.String encoding, java.lang.String errors)static java.lang.Stringencode_UnicodeEscape(java.lang.String str, boolean use_quotes)static java.lang.Stringencode_UnicodeEscape(java.lang.String str, boolean use_quotes, boolean unicodeDesignatorPresent)booleanendswith(java.lang.String suffix)booleanendswith(java.lang.String suffix, int start)booleanendswith(java.lang.String suffix, int start, int end)booleanequals(java.lang.Object other)Should almost never be overridden.java.lang.Stringexpandtabs()java.lang.Stringexpandtabs(int tabsize)intfind(java.lang.String sub)intfind(java.lang.String sub, int start)intfind(java.lang.String sub, int start, int end)static java.lang.Stringfrom_bytes(byte[] buf)static java.lang.Stringfrom_bytes(byte[] buf, int off, int len)inthashCode()intindex(java.lang.String sub)intindex(java.lang.String sub, int start)intindex(java.lang.String sub, int start, int end)java.lang.StringinternedString()booleanisalnum()booleanisalpha()booleanisdecimal()booleanisdigit()booleanislower()booleanisnumeric()booleanisspace()booleanistitle()booleanisunicode()booleanisupper()java.lang.Stringjoin(PyObject seq)java.lang.Stringljust(int width)java.lang.Stringlower()java.lang.Stringlstrip()java.lang.Stringlstrip(java.lang.String sep)intrfind(java.lang.String sub)intrfind(java.lang.String sub, int start)intrfind(java.lang.String sub, int start, int end)intrindex(java.lang.String sub)intrindex(java.lang.String sub, int start)intrindex(java.lang.String sub, int start, int end)java.lang.Stringrjust(int width)java.lang.Stringrstrip()java.lang.Stringrstrip(java.lang.String sep)java.lang.StringsafeRepr()PyListsplit()PyListsplit(java.lang.String sep)PyListsplit(java.lang.String sep, int maxsplit)PyListsplitlines()PyListsplitlines(boolean keepends)booleanstartswith(java.lang.String prefix)booleanstartswith(java.lang.String prefix, int offset)booleanstartswith(java.lang.String prefix, int start, int end)PyObjectstr___mod__(PyObject other)java.lang.Stringstrip()java.lang.Stringstrip(java.lang.String sep)java.lang.Stringswapcase()java.lang.Stringtitle()static byte[]to_bytes(java.lang.String s)byte[]toBytes()java.lang.StringtoString()java.lang.Stringtranslate(java.lang.String table)java.lang.Stringtranslate(java.lang.String table, java.lang.String deletechars)java.lang.Stringtranslate(PyObject table)static voidtypeSetup(PyObject dict, PyType.Newstyle marker)java.lang.Stringupper()java.lang.Stringzfill(int width)-
Methods inherited from class org.python.core.PySequence
__delitem__, __delslice__, __finditem__, __finditem__, __getitem__, __getslice__, __iter__, __nonzero__, __setitem__, __setitem__, __setslice__, isMappingType, isNumberType
-
Methods inherited from class org.python.core.PyObject
__abs__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __coerce__, __coerce_ex__, __delattr__, __delattr__, __delete__, __delitem__, __delslice__, __dir__, __div__, __divmod__, __findattr__, __findattr__, __finditem__, __floordiv__, __get__, __getattr__, __getattr__, __getitem__, __getslice__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __ior__, __ipow__, __irshift__, __isub__, __iternext__, __itruediv__, __ixor__, __lshift__, __mul__, __not__, __oct__, __or__, __pow__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setslice__, __sub__, __truediv__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _in, _is, _isnot, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _xor, asInt, asLong, asStringOrNull, delDict, delType, dispatch__init__, fastGetClass, fastGetDict, getDict, getDoc, getType, implementsDescrDelete, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isSequenceType, noAttributeError, readonlyAttributeError, setDict, setType
-
-
-
-
Field Detail
-
exposed_name
public static final java.lang.String exposed_name
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PyString
public PyString()
-
PyString
public PyString(PyType subType, java.lang.String string)
-
PyString
public PyString(java.lang.String string)
-
PyString
public PyString(char c)
-
-
Method Detail
-
typeSetup
public static void typeSetup(PyObject dict, PyType.Newstyle marker)
-
classDictInit
public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag
Internal use only. Do not call this method explicit.- Throws:
PyIgnoreMethodTag
-
safeRepr
public java.lang.String safeRepr() throws PyIgnoreMethodTag- Overrides:
safeReprin classPyObject- Throws:
PyIgnoreMethodTag
-
__str__
public PyString __str__()
Description copied from class:PyObjectEquivalent to the standard Python __str__ method. This method should not typically need to be overridden. The easiest way to configure the string representation of aPyObjectis to override the standard JavatoStringmethod.
-
__unicode__
public PyUnicode __unicode__()
- Overrides:
__unicode__in classPyObject
-
__len__
public int __len__()
Description copied from class:PyObjectEquivalent to the standard Python __len__ method. Part of the mapping discipline.
-
internedString
public java.lang.String internedString()
-
__repr__
public PyString __repr__()
Description copied from class:PyObjectEquivalent to the standard Python __repr__ method. This method should not typically need to be overrriden. The easiest way to configure the string representation of aPyObjectis to override the standard JavatoStringmethod.
-
encode_UnicodeEscape
public static java.lang.String encode_UnicodeEscape(java.lang.String str, boolean use_quotes)
-
encode_UnicodeEscape
public static java.lang.String encode_UnicodeEscape(java.lang.String str, boolean use_quotes, boolean unicodeDesignatorPresent)
-
decode_UnicodeEscape
public static java.lang.String decode_UnicodeEscape(java.lang.String str, int start, int end, java.lang.String errors, boolean unicode)
-
equals
public boolean equals(java.lang.Object other)
Description copied from class:PyObjectShould almost never be overridden. If overridden, it is the subclasses responsibility to ensure thata.equals(b) == trueiffcmp(a,b) == 0
-
__cmp__
public int __cmp__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __cmp__ method.
-
__eq__
public PyObject __eq__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __eq__ method.- Overrides:
__eq__in classPySequence- Parameters:
other- the object to compare this with.- Returns:
- the result of the comparison.
-
__ne__
public PyObject __ne__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __ne__ method.- Overrides:
__ne__in classPySequence- Parameters:
other- the object to compare this with.- Returns:
- the result of the comparison.
-
__lt__
public PyObject __lt__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __lt__ method.- Overrides:
__lt__in classPySequence- Parameters:
other- the object to compare this with.- Returns:
- the result of the comparison.
-
__le__
public PyObject __le__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __le__ method.- Overrides:
__le__in classPySequence- Parameters:
other- the object to compare this with.- Returns:
- the result of the comparison.
-
__gt__
public PyObject __gt__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __gt__ method.- Overrides:
__gt__in classPySequence- Parameters:
other- the object to compare this with.- Returns:
- the result of the comparison.
-
__ge__
public PyObject __ge__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __ge__ method.- Overrides:
__ge__in classPySequence- Parameters:
other- the object to compare this with.- Returns:
- the result of the comparison.
-
toBytes
public byte[] toBytes()
- Returns:
- a byte array with one byte for each char in this object's underlying String. Each byte contains the low-order bits of its corresponding char.
-
to_bytes
public static byte[] to_bytes(java.lang.String s)
- Returns:
- a byte array with one byte for each char in s. Each byte contains the low-order bits of its corresponding char.
-
from_bytes
public static java.lang.String from_bytes(byte[] buf)
- Returns:
- A String with chars corresponding to the bytes in buf
-
from_bytes
public static java.lang.String from_bytes(byte[] buf, int off, int len)- Returns:
- A String of len buff with chars corresponding to buf from off to off + len
-
__tojava__
public java.lang.Object __tojava__(java.lang.Class c)
Description copied from class:PyObjectEquivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special objectPy.NoConversionif thisPyObjectcan not be converted to the desired Java class.- Overrides:
__tojava__in classPySequence- Parameters:
c- the Class to convert thisPyObjectto.
-
createInstance
public PyString createInstance(java.lang.String str)
-
__contains__
public boolean __contains__(PyObject o)
Description copied from class:PyObjectEquivalent to the standard Python __contains__ method.- Overrides:
__contains__in classPyObject- Parameters:
o- the element to search for in this container.- Returns:
- the result of the search.
-
__add__
public PyObject __add__(PyObject generic_other)
Description copied from class:PyObjectEquivalent to the standard Python __add__ method
-
__reduce__
public PyObject __reduce__()
Used for pickling.- Overrides:
__reduce__in classPyObject- Returns:
- a tuple of (class, tuple)
-
__getnewargs__
public PyTuple __getnewargs__()
- Overrides:
__getnewargs__in classPyObject
-
__mod__
public PyObject __mod__(PyObject other)
Description copied from class:PyObjectEquivalent to the standard Python __mod__ method
-
__int__
public PyObject __int__()
Description copied from class:PyObjectEquivalent to the standard Python __int__ method. Should only be overridden by numeric objects that can be reasonably coerced into an integer.
-
__long__
public PyLong __long__()
Description copied from class:PyObjectEquivalent to the standard Python __long__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python long.
-
__float__
public PyFloat __float__()
Description copied from class:PyObjectEquivalent to the standard Python __float__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python float.
-
__pos__
public PyObject __pos__()
Description copied from class:PyObjectEquivalent to the standard Python __pos__ method.
-
__neg__
public PyObject __neg__()
Description copied from class:PyObjectEquivalent to the standard Python __neg__ method.
-
__invert__
public PyObject __invert__()
Description copied from class:PyObjectEquivalent to the standard Python __invert__ method.- Overrides:
__invert__in classPyObject- Returns:
- ~this.
-
__complex__
public PyComplex __complex__()
Description copied from class:PyObjectEquivalent to the standard Python __complex__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python complex number.- Overrides:
__complex__in classPyObject- Returns:
- a complex number corresponding to the value of this object.
-
lower
public java.lang.String lower()
-
upper
public java.lang.String upper()
-
title
public java.lang.String title()
-
swapcase
public java.lang.String swapcase()
-
strip
public java.lang.String strip()
-
strip
public java.lang.String strip(java.lang.String sep)
-
lstrip
public java.lang.String lstrip()
-
lstrip
public java.lang.String lstrip(java.lang.String sep)
-
rstrip
public java.lang.String rstrip()
-
rstrip
public java.lang.String rstrip(java.lang.String sep)
-
split
public PyList split()
-
split
public PyList split(java.lang.String sep)
-
split
public PyList split(java.lang.String sep, int maxsplit)
-
splitlines
public PyList splitlines()
-
splitlines
public PyList splitlines(boolean keepends)
-
index
public int index(java.lang.String sub)
-
index
public int index(java.lang.String sub, int start)
-
index
public int index(java.lang.String sub, int start, int end)
-
rindex
public int rindex(java.lang.String sub)
-
rindex
public int rindex(java.lang.String sub, int start)
-
rindex
public int rindex(java.lang.String sub, int start, int end)
-
count
public int count(java.lang.String sub)
-
count
public int count(java.lang.String sub, int start)
-
count
public int count(java.lang.String sub, int start, int end)
-
find
public int find(java.lang.String sub)
-
find
public int find(java.lang.String sub, int start)
-
find
public int find(java.lang.String sub, int start, int end)
-
rfind
public int rfind(java.lang.String sub)
-
rfind
public int rfind(java.lang.String sub, int start)
-
rfind
public int rfind(java.lang.String sub, int start, int end)
-
atof
public double atof()
-
atoi
public int atoi()
-
atoi
public int atoi(int base)
-
atol
public PyLong atol()
-
atol
public PyLong atol(int base)
-
ljust
public java.lang.String ljust(int width)
-
rjust
public java.lang.String rjust(int width)
-
center
public java.lang.String center(int width)
-
zfill
public java.lang.String zfill(int width)
-
expandtabs
public java.lang.String expandtabs()
-
expandtabs
public java.lang.String expandtabs(int tabsize)
-
capitalize
public java.lang.String capitalize()
-
join
public java.lang.String join(PyObject seq)
-
startswith
public boolean startswith(java.lang.String prefix)
-
startswith
public boolean startswith(java.lang.String prefix, int offset)
-
startswith
public boolean startswith(java.lang.String prefix, int start, int end)
-
endswith
public boolean endswith(java.lang.String suffix)
-
endswith
public boolean endswith(java.lang.String suffix, int start)
-
endswith
public boolean endswith(java.lang.String suffix, int start, int end)
-
translate
public java.lang.String translate(java.lang.String table)
-
translate
public java.lang.String translate(java.lang.String table, java.lang.String deletechars)
-
translate
public java.lang.String translate(PyObject table)
-
islower
public boolean islower()
-
isupper
public boolean isupper()
-
isalpha
public boolean isalpha()
-
isalnum
public boolean isalnum()
-
isdecimal
public boolean isdecimal()
-
isdigit
public boolean isdigit()
-
isnumeric
public boolean isnumeric()
-
istitle
public boolean istitle()
-
isspace
public boolean isspace()
-
isunicode
public boolean isunicode()
-
encode
public java.lang.String encode()
-
encode
public java.lang.String encode(java.lang.String encoding)
-
encode
public java.lang.String encode(java.lang.String encoding, java.lang.String errors)
-
decode
public java.lang.String decode()
-
decode
public java.lang.String decode(java.lang.String encoding)
-
decode
public java.lang.String decode(java.lang.String encoding, java.lang.String errors)
-
asString
public java.lang.String asString(int index) throws PyObject.ConversionException- Overrides:
asStringin classPyObject- Throws:
PyObject.ConversionException
-
asName
public java.lang.String asName(int index) throws PyObject.ConversionException- Overrides:
asNamein classPyObject- Throws:
PyObject.ConversionException
-
-