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

Direct Known Subclasses:
  PyStringDerived, PyUnicode, SyspathArchive

    public class PyString
    extends PyBaseString

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
`static PyType` `TYPE`

### Constructor Summary

Constructors
Constructor and Description
`PyString()`
`PyString(char c)`
`PyString(PyType subType, java.lang.String string)`
`PyString(java.lang.String string)`

### Method Summary

Methods
`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` `__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__()`
`double` `asDouble()` Convert this object into a double.
`int` `asInt()` Convert this object into an int.
`long` `asLong()` Convert this object longo an long.
`java.lang.String` `asName(int index)`
`java.lang.String` `asString()`
`java.lang.String` `asString(int index)`
`double` `atof()`
`int` `atoi()`
`int` `atoi(int base)`
`PyLong` `atol()`
`PyLong` `atol(int base)`
`java.lang.String` `capitalize()`
`java.lang.String` `center(int width)`
`int` `count(java.lang.String sub)`
`int` `count(java.lang.String sub, int start)`
`int` `count(java.lang.String sub, int start, int end)`
`PyString` `createInstance(java.lang.String str)`
`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)`
`boolean` `endswith(PyObject suffix, int start)`
`boolean` `endswith(PyObject suffix, int start, int end)`
`java.lang.String` `expandtabs()`
`java.lang.String` `expandtabs(int tabsize)`
`int` `find(java.lang.String sub)`
`int` `find(java.lang.String sub, int start)`
`int` `find(java.lang.String sub, int start, int end)`
`static PyString` `fromInterned(java.lang.String interned)` Creates a PyString from an already interned String.
`java.lang.String` `getString()`
`int` `hashCode()`
`int` `index(java.lang.String sub)`
`int` `index(java.lang.String sub, int start)`
`int` `index(java.lang.String sub, int start, int end)`
`java.lang.String` `internedString()`
`boolean` `isalnum()`
`boolean` `isalpha()`
`boolean` `isdecimal()`
`boolean` `isdigit()`
`boolean` `islower()`
`boolean` `isnumeric()`
`boolean` `isspace()`
`boolean` `istitle()`
`boolean` `isunicode()`
`boolean` `isupper()`
`PyString` `join(PyObject seq)`
`java.lang.String` `ljust(int width)`
`java.lang.String` `ljust(int width, java.lang.String padding)`
`java.lang.String` `lower()`
`java.lang.String` `lstrip()`
`java.lang.String` `lstrip(java.lang.String sep)`
`PyTuple` `partition(PyObject sepObj)`
`int` `rfind(java.lang.String sub)`
`int` `rfind(java.lang.String sub, int start)`
`int` `rfind(java.lang.String sub, int start, int end)`
`int` `rindex(java.lang.String sub)`
`int` `rindex(java.lang.String sub, int start)`
`int` `rindex(java.lang.String sub, int start, int end)`
`java.lang.String` `rjust(int width)`
`PyTuple` `rpartition(PyObject sepObj)`
`PyList` `rsplit()`
`PyList` `rsplit(java.lang.String sep)`
`PyList` `rsplit(java.lang.String sep, int maxsplit)`
`java.lang.String` `rstrip(java.lang.String sep)`
`PyList` `split()`
`PyList` `split(java.lang.String sep)`
`PyList` `split(java.lang.String sep, int maxsplit)`
`PyList` `splitlines()`
`PyList` `splitlines(boolean keepends)`
`boolean` `startswith(PyObject prefix)`
`boolean` `startswith(PyObject prefix, int offset)`
`boolean` `startswith(PyObject prefix, int start, int end)`
`PyObject` `str___mod__(PyObject other)`
`java.lang.String` `strip()`
`java.lang.String` `strip(java.lang.String sep)`
`java.lang.String` `substring(int start, int end)`
`java.lang.String` `swapcase()`
`java.lang.String` `title()`
`byte[]` `toBytes()`
`int[]` `toCodePoints()`
`java.lang.String` `toString()`
`java.lang.String` `translate(PyObject table)`
`java.lang.String` `translate(java.lang.String table)`
`java.lang.String` `translate(java.lang.String table, java.lang.String deletechars)`
`java.lang.String` `upper()`
`java.lang.String` `zfill(int width)`

### Methods inherited from class org.python.core.PySequence

`__delitem__, __delslice__, __finditem__, __finditem__, __getitem__, __getslice__, __iter__, __nonzero__, __setitem__, __setitem__, __setslice__, isMappingType, isNumberType, isSequenceType`

### Methods inherited from class org.python.core.PyObject

`__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__, __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__, __rdiv__, __rdivmod__, __reduce__, __reduce_ex__, __reduce_ex__, __rfloordiv__, __rlshift__, __rmod__, __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, _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, _xor, asIndex, asIndex, asInt, asIterable, asLong, asName, asStringOrNull, asStringOrNull, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, getDict, getType, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, noAttributeError, readonlyAttributeError, setDict, setType`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### TYPE

    public static final PyType TYPE

### 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

#### getString

    public java.lang.String getString()

#### fromInterned

    public static PyString fromInterned(java.lang.String interned)

Creates a PyString from an already interned String. Just means it won't be reinterned if used in a place that requires interned Strings.

#### toCodePoints

    public int[] toCodePoints()

#### substring

    public java.lang.String substring(int start,
                             int end)

#### __str__

    public PyString __str__()

Description copied from class: `PyObject`
Equivalent to the standard Python __str__ method. This method should not typically need to be overridden. The easiest way to configure the string representation of a `PyObject` is to override the standard Java `toString` method.

Overrides:
  `__str__` in class `PyObject`

#### __unicode__

    public PyUnicode __unicode__()

Overrides:
  `__unicode__` in class `PyObject`

#### __len__

    public int __len__()

Description copied from class: `PyObject`
Equivalent to the standard Python __len__ method. Part of the mapping discipline.

Overrides:
  `__len__` in class `PyObject`
Returns:
  the length of the object

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `PyObject`

#### internedString

    public java.lang.String internedString()

#### __repr__

    public PyString __repr__()

Description copied from class: `PyObject`
Equivalent to the standard Python __repr__ method. This method should not typically need to be overrriden. The easiest way to configure the string representation of a `PyObject` is to override the standard Java `toString` method.

Overrides:
  `__repr__` in class `PyObject`

#### encode_UnicodeEscape

    public static java.lang.String encode_UnicodeEscape(java.lang.String str,
                                        boolean use_quotes)

#### decode_UnicodeEscape

    public static java.lang.String decode_UnicodeEscape(java.lang.String str,
                                        int start,
                                        int end,
                                        java.lang.String errors,
                                        boolean unicode)

#### __cmp__

    public int __cmp__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __cmp__ method.

Overrides:
  `__cmp__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  -1 if this < o; 0 if this == o; +1 if this > o; -2 if no comparison is implemented

#### __eq__

    public PyObject __eq__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __eq__ method.

Overrides:
  `__eq__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

#### __ne__

    public PyObject __ne__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __ne__ method.

Overrides:
  `__ne__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

#### __lt__

    public PyObject __lt__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __lt__ method.

Overrides:
  `__lt__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

#### __le__

    public PyObject __le__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __le__ method.

Overrides:
  `__le__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

#### __gt__

    public PyObject __gt__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __gt__ method.

Overrides:
  `__gt__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

#### __ge__

    public PyObject __ge__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __ge__ method.

Overrides:
  `__ge__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `PyObject`

#### 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.

#### __tojava__

    public java.lang.Object __tojava__(java.lang.Class<?> c)

Description copied from class: `PyObject`
Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object `Py.NoConversion` if this `PyObject` can not be converted to the desired Java class.

Overrides:
  `__tojava__` in class `PySequence`
Parameters:
  `c` - the Class to convert this `PyObject` to.

#### createInstance

    public PyString createInstance(java.lang.String str)

#### __contains__

    public boolean __contains__(PyObject o)

Description copied from class: `PyObject`
Equivalent to the standard Python __contains__ method.

Overrides:
  `__contains__` in class `PyObject`
Parameters:
  `o` - the element to search for in this container.
Returns:
  the result of the search.

#### __mul__

    public PyObject __mul__(PyObject o)

Description copied from class: `PyObject`
Equivalent to the standard Python __mul__ method

Overrides:
  `__mul__` in class `PyObject`
Parameters:
  `o` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the mul, or null if this operation is not defined

#### __rmul__

    public PyObject __rmul__(PyObject o)

Description copied from class: `PyObject`
Equivalent to the standard Python __rmul__ method

Overrides:
  `__rmul__` in class `PyObject`
Parameters:
  `o` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the mul, or null if this operation is not defined.

#### __add__

    public PyObject __add__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __add__ method

Overrides:
  `__add__` in class `PyObject`
Parameters:
  `other` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the add, or null if this operation is not defined

#### __getnewargs__

    public PyTuple __getnewargs__()

Overrides:
  `__getnewargs__` in class `PyObject`

#### __mod__

    public PyObject __mod__(PyObject other)

Description copied from class: `PyObject`
Equivalent to the standard Python __mod__ method

Overrides:
  `__mod__` in class `PyObject`
Parameters:
  `other` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the mod, or null if this operation is not defined

#### str___mod__

    public PyObject str___mod__(PyObject other)

#### __int__

    public PyObject __int__()

Description copied from class: `PyObject`
Equivalent to the standard Python __int__ method. Should only be overridden by numeric objects that can be reasonably coerced into an integer.

Overrides:
  `__int__` in class `PyObject`
Returns:
  an integer corresponding to the value of this object.

#### __long__

    public PyObject __long__()

Description copied from class: `PyObject`
Equivalent to the standard Python __long__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python long.

Overrides:
  `__long__` in class `PyObject`
Returns:
  a PyLong or PyInteger corresponding to the value of this object.

#### __float__

    public PyFloat __float__()

Description copied from class: `PyObject`
Equivalent to the standard Python __float__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python float.

Overrides:
  `__float__` in class `PyObject`
Returns:
  a float corresponding to the value of this object.

#### __pos__

    public PyObject __pos__()

Description copied from class: `PyObject`
Equivalent to the standard Python __pos__ method.

Overrides:
  `__pos__` in class `PyObject`
Returns:
  +this.

#### __neg__

    public PyObject __neg__()

Description copied from class: `PyObject`
Equivalent to the standard Python __neg__ method.

Overrides:
  `__neg__` in class `PyObject`
Returns:
  -this.

#### __invert__

    public PyObject __invert__()

Description copied from class: `PyObject`
Equivalent to the standard Python __invert__ method.

Overrides:
  `__invert__` in class `PyObject`
Returns:
  ~this.

#### __complex__

    public PyComplex __complex__()

Description copied from class: `PyObject`
Equivalent 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 class `PyObject`
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(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)

#### rsplit

    public PyList rsplit()

#### rsplit

    public PyList rsplit(java.lang.String sep)

#### rsplit

    public PyList rsplit(java.lang.String sep,
                int maxsplit)

#### partition

    public PyTuple partition(PyObject sepObj)

#### rpartition

    public PyTuple rpartition(PyObject sepObj)

#### 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)

#### ljust

    public java.lang.String ljust(int width,
                         java.lang.String padding)

#### 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 PyString join(PyObject seq)

#### startswith

    public boolean startswith(PyObject prefix)

#### startswith

    public boolean startswith(PyObject prefix,
                     int offset)

#### startswith

    public boolean startswith(PyObject prefix,
                     int start,
                     int end)

#### endswith

    public boolean endswith(PyObject suffix)

#### endswith

    public boolean endswith(PyObject suffix,
                   int start)

#### endswith

    public boolean endswith(PyObject 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 PyObject decode()

#### decode

    public PyObject decode(java.lang.String encoding)

#### decode

    public PyObject decode(java.lang.String encoding,
                  java.lang.String errors)

#### asString

    public java.lang.String asString(int index)
                              throws PyObject.ConversionException

Overrides:
  `asString` in class `PyObject`
Throws:
  `PyObject.ConversionException`

#### asString

    public java.lang.String asString()

Overrides:
  `asString` in class `PyObject`

#### asInt

    public int asInt()

Description copied from class: `PyObject`
Convert this object into an int. Throws a PyException on failure.

Overrides:
  `asInt` in class `PyObject`
Returns:
  an int value

#### asLong

    public long asLong()

Description copied from class: `PyObject`
Convert this object longo an long. Throws a PyException on failure.

Overrides:
  `asLong` in class `PyObject`
Returns:
  an long value

#### asDouble

    public double asDouble()

Description copied from class: `PyObject`
Convert this object into a double. Throws a PyException on failure.

Overrides:
  `asDouble` in class `PyObject`
Returns:
  a double value

#### asName

    public java.lang.String asName(int index)
                            throws PyObject.ConversionException

Overrides:
  `asName` in class `PyObject`
Throws:
  `PyObject.ConversionException`