public class PyByteArray extends BaseBytes implements BufferProtocol
List<PyInteger>
implementation for the Java APImemoryview
interface either for access or a a
source for its constructors although the signatures are present. The rich set of string-like
operations due a bytearray
is not implemented.PyObject.ConversionException
Constructor and Description |
---|
PyByteArray()
Create a zero-length Python bytearray.
|
PyByteArray(BaseBytes value)
Create a new array filled exactly by a copy of the contents of the source, which is a
bytearray (or bytes).
|
PyByteArray(BufferProtocol value)
Create a new array filled exactly by a copy of the contents of the source, which is an
object supporting the Jython version of the PEP 3118 buffer API.
|
PyByteArray(int size)
Create zero-filled Python bytearray of specified size.
|
PyByteArray(int[] value)
Construct bytearray by copying values from int[].
|
PyByteArray(java.lang.Iterable<? extends PyObject> value)
Create a new array filled from an iterable of PyObject.
|
PyByteArray(PyObject arg)
Create a new bytearray object from an arbitrary Python object according to the same rules as
apply in Python to the bytearray() constructor:
bytearray() Construct a zero-length bytearray (arg is null).
|
PyByteArray(PyString arg)
Create a new array by encoding a PyString argument to bytes.
|
PyByteArray(PyString arg,
PyObject encoding,
PyObject errors)
Create a new array by encoding a PyString argument to bytes.
|
PyByteArray(PyString arg,
java.lang.String encoding,
java.lang.String errors)
Create a new array by encoding a PyString argument to bytes.
|
PyByteArray(PyType type)
Create a zero-length Python bytearray of explicitly-specified sub-type
|
Modifier and Type | Method and Description |
---|---|
PyObject |
__add__(PyObject o)
Equivalent to the standard Python __add__ method
|
int |
__alloc__()
Returns the number of bytes actually allocated.
|
boolean |
__contains__(PyObject o)
Implement to the standard Python __contains__ method, which in turn implements the
in operator. |
PyObject |
__eq__(PyObject other)
Equivalent to the standard Python __eq__ method.
|
PyObject |
__ge__(PyObject other)
Equivalent to the standard Python __ge__ method.
|
PyObject |
__gt__(PyObject other)
Equivalent to the standard Python __gt__ method.
|
PyObject |
__iadd__(PyObject o)
Equivalent to the standard Python __iadd__ method
|
PyObject |
__imul__(PyObject n)
Equivalent to the standard Python
__imul__ method, that for a byte array returns
a new byte array containing the same thing n times. |
PyObject |
__le__(PyObject other)
Equivalent to the standard Python __le__ method.
|
PyObject |
__lt__(PyObject other)
Equivalent to the standard Python __lt__ method.
|
PyObject |
__mul__(PyObject n)
Equivalent to the standard Python
__mul__ method, that for a byte array returns
a new byte array containing the same thing n times. |
PyObject |
__ne__(PyObject other)
Equivalent to the standard Python __ne__ method.
|
PyObject |
__rmul__(PyObject n)
Equivalent to the standard Python
__rmul__ method, that for a byte array returns
a new byte array containing the same thing n times. |
PyString |
__str__()
An overriding of the
PyObject.__str__() method, returning PyString ,
where in the characters are simply those with a point-codes given in this byte array. |
void |
append(byte element)
Append a single byte to the end of the array.
|
void |
append(PyObject element)
Append a single element to the end of the array, equivalent to:
s[len(s):len(s)] = o . |
PyByteArray |
center(int width)
Java API equivalent of Python
center(width) : return the bytes centered in an
array of length width , padded by spaces. |
PyByteArray |
center(int width,
java.lang.String fillchar)
Java API equivalent of Python
center(width [, fillchar]) : return the bytes
centered in an array of length width . |
int |
count(PyObject sub)
Implementation of Python
count(sub) . |
int |
count(PyObject sub,
PyObject start)
Implementation of Python
count( sub [, start ] ) . |
int |
count(PyObject sub,
PyObject start,
PyObject end)
Implementation of Python
count( sub [, start [, end ]] ) . |
boolean |
endswith(PyObject suffix)
Implementation of Python
endswith(suffix) . |
boolean |
endswith(PyObject suffix,
PyObject start)
Implementation of Python
endswith( suffix [, start ] ) . |
boolean |
endswith(PyObject suffix,
PyObject start,
PyObject end)
Implementation of Python
endswith( suffix [, start [, end ]] ) . |
PyByteArray |
expandtabs()
Implementation of Python
expandtabs() : return a copy of the byte array where all
tab characters are replaced by one or more spaces, as expandtabs(int) with a tab
size of 8 characters. |
PyByteArray |
expandtabs(int tabsize)
Implementation of Python
expandtabs(tabsize) : return a copy of the byte array
where all tab characters are replaced by one or more spaces, depending on the current column
and the given tab size. |
void |
extend(PyObject o)
Append the elements in the argument sequence to the end of the array, equivalent to:
s[len(s):len(s)] = o . |
int |
find(PyObject sub)
Implementation of Python
find(sub) . |
int |
find(PyObject sub,
PyObject start)
Implementation of Python
find( sub [, start ] ) . |
int |
find(PyObject sub,
PyObject start,
PyObject end)
Implementation of Python
find( sub [, start [, end ]] ) . |
PyBuffer |
getBuffer(int flags)
Method by which the consumer requests the buffer from the exporter.
|
int |
hashCode()
This type is not hashable.
|
int |
index(PyObject sub)
Implementation of Python
index(sub) . |
int |
index(PyObject sub,
PyObject start)
Implementation of Python
index( sub [, start ] ) . |
int |
index(PyObject sub,
PyObject start,
PyObject end)
Implementation of Python
index( sub [, start [, end ]] ) . |
void |
insert(PyObject index,
PyObject value)
Insert the argument element into the byte array at the specified index.
|
PyByteArray |
join(PyObject iterable)
Implementation of Python
join(iterable) . |
PyByteArray |
ljust(int width)
Java API equivalent of Python
ljust(width) : return the bytes left justified in
an array of length width , padded by spaces. |
PyByteArray |
ljust(int width,
java.lang.String fillchar)
Java API equivalent of Python
ljust(width [, fillchar]) : return the bytes
left-justified in an array of length width . |
PyByteArray |
lstrip()
Implementation of Python
lstrip() . |
PyByteArray |
lstrip(PyObject bytes)
Implementation of Python
lstrip(bytes)
Return a copy of the byte array with the leading characters removed. |
PyInteger |
pop()
Removes and return the last element in the byte array.
|
PyInteger |
pop(int i)
Remove and return the
n th byte element in the array. |
void |
pyinsert(int index,
PyObject element)
Insert the element (interpreted as a Python byte value) at the given index.
|
void |
pyset(int index,
PyObject value)
Sets the indexed element of the bytearray to the given value.
|
void |
remove(PyObject o)
Remove the first occurrence of an element from the array, equivalent to:
del s[s.index(x)] , although x must be convertable to a single byte value. |
PyByteArray |
replace(PyObject oldB,
PyObject newB)
An implementation of Python
replace( old, new ) , returning a
PyByteArray with all occurrences of sequence oldB replaced by
newB . |
PyByteArray |
replace(PyObject oldB,
PyObject newB,
int maxcount)
An implementation of Python
replace( old, new [, count ] ) , returning a
PyByteArray with all occurrences of sequence oldB replaced by
newB . |
void |
reverse()
Reverses the contents of the byte array in place.
|
int |
rfind(PyObject sub)
Implementation of Python
rfind(sub) . |
int |
rfind(PyObject sub,
PyObject start)
Implementation of Python
rfind( sub [, start ] ) . |
int |
rfind(PyObject sub,
PyObject start,
PyObject end)
Implementation of Python
rfind( sub [, start [, end ]] ) . |
int |
rindex(PyObject sub)
Implementation of Python
rindex(sub) . |
int |
rindex(PyObject sub,
PyObject start)
Implementation of Python
rindex( sub [, start ] ) . |
int |
rindex(PyObject sub,
PyObject start,
PyObject end)
Implementation of Python
rindex( sub [, start [, end ]] ) . |
PyByteArray |
rjust(int width)
Java API equivalent of Python
rjust(width) : return the bytes right justified in
an array of length width , padded by spaces. |
PyByteArray |
rjust(int width,
java.lang.String fillchar)
Java API equivalent of Python
rjust(width [, fillchar]) : return the bytes
right-justified in an array of length width . |
PyByteArray |
rstrip()
Implementation of Python
rstrip() . |
PyByteArray |
rstrip(PyObject bytes)
Implementation of Python
rstrip(bytes)
Return a copy of the byte array with the trailing characters removed. |
static PyException |
SliceSizeError(java.lang.String valueType,
int valueSize,
int sliceSize)
Convenience method to build (but not throw) a
ValueError PyException with the
message "attempt to assign {type} of size {valueSize} to extended slice of size {sliceSize}" |
boolean |
startswith(PyObject prefix)
Implementation of Python
startswith(prefix) . |
boolean |
startswith(PyObject prefix,
PyObject start)
Implementation of Python
startswith( prefix [, start ] ) . |
boolean |
startswith(PyObject prefix,
PyObject start,
PyObject end)
Implementation of Python
startswith( prefix [, start [, end ]] ) . |
PyByteArray |
strip()
Implementation of Python
strip() . |
PyByteArray |
strip(PyObject bytes)
Implementation of Python
strip(bytes)
Return a copy of the byte array with the leading and trailing characters removed. |
java.lang.String |
toString()
An overriding of the standard Java
toString() method, returning a printable
expression of this byte array in the form bytearray(b'hello') , where in the
"inner string", any special characters are escaped to their well-known backslash equivalents
or a hexadecimal escape. |
PyByteArray |
translate(PyObject table)
Implementation of Python
translate(table). |
PyByteArray |
translate(PyObject table,
PyObject deletechars)
Implementation of Python
translate(table[, deletechars]). |
PyByteArray |
zfill(int width)
Implementation of Python
zfill(width): return the numeric string left filled
with zeros in a byte array of length width . |
__len__, __reduce__, add, add, addAll, addAll, asString, capitalize, clear, contains, containsAll, decode, decode, decode, equals, get, indexOf, intAt, isalnum, isalpha, isdigit, isEmpty, islower, isspace, istitle, isupper, iterator, lastIndexOf, listIterator, listIterator, lower, partition, remove, remove, removeAll, retainAll, rpartition, rsplit, rsplit, rsplit, set, size, split, split, split, splitlines, splitlines, subList, swapcase, title, toArray, toArray, upper
__delitem__, __delslice__, __finditem__, __finditem__, __getitem__, __getslice__, __iter__, __nonzero__, __setitem__, __setitem__, __setslice__, __tojava__, isMappingType, isNumberType, isSequenceType
__abs__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __cmp__, __coerce__, __coerce_ex__, __complex__, __delattr__, __delattr__, __delete__, __delitem__, __delslice__, __dir__, __div__, __divmod__, __findattr__, __findattr__, __findattr_ex__, __finditem__, __float__, __floordiv__, __format__, __get__, __getattr__, __getattr__, __getitem__, __getnewargs__, __getslice__, __hash__, __hex__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __index__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iternext__, __itruediv__, __ixor__, __long__, __lshift__, __mod__, __neg__, __not__, __oct__, __or__, __pos__, __pow__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __reduce_ex__, __reduce_ex__, __repr__, __rfloordiv__, __rlshift__, __rmod__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setslice__, __sub__, __truediv__, __trunc__, __unicode__, __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, asDouble, asIndex, asIndex, asInt, asInt, asIterable, asLong, asLong, asName, asName, asString, asStringOrNull, asStringOrNull, bit_length, conjugate, delDict, delType, dispatch__init__, fastGetClass, fastGetDict, getDict, getType, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, noAttributeError, object___subclasshook__, readonlyAttributeError, setDict, setType
public static final PyType TYPE
public PyByteArray(PyType type)
type
- explicit Jython typepublic PyByteArray()
public PyByteArray(int size)
size
- of bytearraypublic PyByteArray(int[] value)
value
- source of the bytes (and size)public PyByteArray(BaseBytes value)
value
- source of the bytes (and size)public PyByteArray(BufferProtocol value)
value
- source of the bytes (and size)public PyByteArray(java.lang.Iterable<? extends PyObject> value)
value
- source of the bytes (and size)public PyByteArray(PyString arg, PyObject encoding, PyObject errors)
arg
- primary argument from which value is takenencoding
- name of optional encoding (must be a string type)errors
- name of optional errors policy (must be a string type)public PyByteArray(PyString arg, java.lang.String encoding, java.lang.String errors)
arg
- primary argument from which value is takenencoding
- name of optional encoding (may be null to select the default for this
installation)errors
- name of optional errors policypublic PyByteArray(PyString arg)
arg
- primary argument from which value is takenpublic PyByteArray(PyObject arg) throws PyException
bytearray(string, encoding[, errors])
, use the constructor
PyByteArray(PyString, String, String)
. If the PyString is actually a PyUnicode, an
encoding must be specified, and using this constructor will throw an exception about that.arg
- primary argument from which value is taken (may be null)PyException
- in the same circumstances as bytearray(arg), TypeError for non-iterable,
non-integer argument type, and ValueError if iterables do not yield byte [0..255]
values.public PyBuffer getBuffer(int flags)
PyBuffer.release()
on the buffer it
obtained, since some objects alter their behaviour while buffers are exported.
The PyBuffer
returned from this method is a one-dimensional array of single byte
items that allows modification of the object state. The existence of this export prohibits
resizing the byte array. This prohibition is not only on the consumer of the view but
extends to any other operations, such as any kind or insertion or deletion.
getBuffer
in interface BufferProtocol
flags
- specifying features demanded and the navigational capabilities of the consumerpublic void pyset(int index, PyObject value) throws PyException
PySequence.__setitem__(int, org.python.core.PyObject)
It is guaranteed by
PySequence that the index is within the bounds of the array. Any other clients calling
pyset(int) must make the same guarantee.index
- index of the element to set.value
- the value to set this element to.PyException(AttributeError)
- if value cannot be converted to an integerPyException(ValueError)
- if value<0 or value>255PyException
public void pyinsert(int index, PyObject element)
public static PyException SliceSizeError(java.lang.String valueType, int valueSize, int sliceSize)
ValueError
PyException with the
message "attempt to assign {type} of size {valueSize} to extended slice of size {sliceSize}"valueType
- valueSize
- size of sequence being assigned to slicesliceSize
- size of slice expected to receivepublic 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 __ge__(PyObject other)
PyObject
__ge__
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 __add__(PyObject o)
PyObject
public int __alloc__()
public PyObject __imul__(PyObject n)
__imul__
method, that for a byte array returns
a new byte array containing the same thing n times.public PyObject __mul__(PyObject n)
__mul__
method, that for a byte array returns
a new byte array containing the same thing n times.public PyObject __rmul__(PyObject n)
__rmul__
method, that for a byte array returns
a new byte array containing the same thing n times.public void append(byte element)
element
- the byte to append.public void append(PyObject element)
s[len(s):len(s)] = o
. The argument must be a PyInteger, PyLong or string of
length 1.element
- the item to append.PyException(ValueError)
- if element<0 or element>255public boolean __contains__(PyObject o)
in
operator.__contains__
in class PyObject
o
- the element to search for in this bytearray.public PyByteArray center(int width)
center(width)
: return the bytes centered in an
array of length width
, padded by spaces. A copy of the original byte array is
returned if width is less than this.size()
.width
- desiredpublic PyByteArray center(int width, java.lang.String fillchar)
center(width [, fillchar])
: return the bytes
centered in an array of length width
. Padding is done using the specified
fillchar (default is a space). A copy of the original byte array is returned if
width
is less than this.size()
.width
- desiredfillchar
- one-byte String to fill with, or null implying spacepublic int count(PyObject sub)
count(sub)
. Return the number of non-overlapping
occurrences of sub
in this byte array.sub
- sequence to find (of a type viewable as a byte sequence)public int count(PyObject sub, PyObject start)
count( sub [, start ] )
. Return the number of
non-overlapping occurrences of sub
in the range [start:].sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchpublic int count(PyObject sub, PyObject start, PyObject end)
count( sub [, start [, end ]] )
. Return the number of
non-overlapping occurrences of sub
in the range [start, end]. Optional arguments
start
and end
(which may be null
or
Py.None
) are interpreted as in slice notation.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchend
- of slice to searchpublic boolean endswith(PyObject suffix)
endswith(suffix)
.
When suffix
is of a type that may be treated as an array of bytes, return
true
if and only if this bytearray ends with the suffix
.
suffix
can also be a tuple of suffixes to look for.suffix
- byte array to match, or object viewable as such, or a tuple of thempublic boolean endswith(PyObject suffix, PyObject start)
endswith( suffix [, start ] )
.
When suffix
is of a type that may be treated as an array of bytes, return
true
if and only if this bytearray ends with the suffix
.
suffix
can also be a tuple of suffixes to look for. With optional
start
(which may be null
or Py.None
), define the
effective bytearray to be the slice [start:]
of this bytearray.suffix
- byte array to match, or object viewable as such, or a tuple of themstart
- of slice in this bytearray to matchpublic boolean endswith(PyObject suffix, PyObject start, PyObject end)
endswith( suffix [, start [, end ]] )
.
When suffix
is of a type that may be treated as an array of bytes, return
true
if and only if this bytearray ends with the suffix
.
suffix
can also be a tuple of suffixes to look for. With optional
start
and end
(which may be null
or
Py.None
), define the effective bytearray to be the slice
[start:end]
of this bytearray.suffix
- byte array to match, or object viewable as such, or a tuple of themstart
- of slice in this bytearray to matchend
- of slice in this bytearray to matchpublic PyByteArray expandtabs()
expandtabs()
: return a copy of the byte array where all
tab characters are replaced by one or more spaces, as expandtabs(int)
with a tab
size of 8 characters.public PyByteArray expandtabs(int tabsize)
expandtabs(tabsize)
: return a copy of the byte array
where all tab characters are replaced by one or more spaces, depending on the current column
and the given tab size. The column number is reset to zero after each newline occurring in
the array. This treats other non-printing characters or escape sequences as regular
characters.tabsize
- number of character positions between tab stopspublic void extend(PyObject o)
s[len(s):len(s)] = o
. The argument must be a subclass of BaseBytes or an
iterable type returning elements compatible with byte assignment.o
- the sequence of items to append to the list.public int find(PyObject sub)
find(sub)
. Return the lowest index in the byte array
where byte sequence sub
is found. Return -1 if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)public int find(PyObject sub, PyObject start)
find( sub [, start ] )
. Return the lowest index in the
byte array where byte sequence sub
is found, such that sub
is
contained in the slice [start:]
. Return -1 if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchpublic int find(PyObject sub, PyObject start, PyObject end)
find( sub [, start [, end ]] )
. Return the lowest index
in the byte array where byte sequence sub
is found, such that sub
is contained in the slice [start:end]
. Arguments start
and
end
(which may be null
or Py.None
) are interpreted as
in slice notation. Return -1 if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchend
- of slice to searchpublic PyObject __iadd__(PyObject o)
PyObject
public int index(PyObject sub)
index(sub)
. Like find(PyObject)
but raise
Py.ValueError
if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)public int index(PyObject sub, PyObject start)
index( sub [, start ] )
. Like
find(PyObject,PyObject)
but raise Py.ValueError
if sub
is not
found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchpublic int hashCode()
public int index(PyObject sub, PyObject start, PyObject end) throws PyException
index( sub [, start [, end ]] )
. Like
find(PyObject,PyObject,PyObject)
but raise Py.ValueError
if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchend
- of slice to searchPyException
- ValueError if sub not found in byte arraypublic void insert(PyObject index, PyObject value)
s[index:index] = [o] if index >= 0
.index
- the position where the element will be inserted.value
- the element to insert.public PyByteArray join(PyObject iterable)
join(iterable)
. Return a bytearray which is the
concatenation of the byte arrays in the iterable iterable
. The separator between
elements is the byte array providing this method.iterable
- of byte array objects, or objects viewable as such.public PyByteArray ljust(int width)
ljust(width)
: return the bytes left justified in
an array of length width
, padded by spaces. A copy of the original byte array is
returned if width is less than this.size()
.width
- desiredpublic PyByteArray ljust(int width, java.lang.String fillchar)
ljust(width [, fillchar])
: return the bytes
left-justified in an array of length width
. Padding is done using the specified
fillchar (default is a space). A copy of the original byte array is returned if
width
is less than this.size()
.width
- desiredfillchar
- one-byte String to fill with, or null implying spacepublic PyByteArray lstrip()
lstrip()
. Return a copy of the byte array with the leading
whitespace characters removed.public PyByteArray lstrip(PyObject bytes)
lstrip(bytes)
Return a copy of the byte array with the leading characters removed. The bytes
argument is an object specifying the set of characters to be removed. If null or None, the
bytes argument defaults to removing whitespace. The bytes argument is not a prefix;
rather, all combinations of its values are stripped.bytes
- treated as a set of bytes defining what values to strippublic PyInteger pop()
public PyInteger pop(int i)
n
th byte element in the array.i
- the index of the byte to remove and return.public void remove(PyObject o) throws PyException
del s[s.index(x)]
, although x must be convertable to a single byte value. The
argument must be a PyInteger, PyLong or string of length 1.o
- the value to remove from the list.PyException
- ValueError if o not found in bytearraypublic PyByteArray replace(PyObject oldB, PyObject newB)
replace( old, new )
, returning a
PyByteArray
with all occurrences of sequence oldB
replaced by
newB
.oldB
- sequence to findnewB
- relacement sequencepublic PyByteArray replace(PyObject oldB, PyObject newB, int maxcount)
replace( old, new [, count ] )
, returning a
PyByteArray
with all occurrences of sequence oldB
replaced by
newB
. If the optional argument count
is given, only the first
count
occurrences are replaced.oldB
- sequence to findnewB
- relacement sequencemaxcount
- maximum occurrences are replaced or all if maxcount < 0
public void reverse()
public int rfind(PyObject sub)
rfind(sub)
. Return the highest index in the byte array
where byte sequence sub
is found. Return -1 if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)public int rfind(PyObject sub, PyObject start)
rfind( sub [, start ] )
. Return the highest index in
the byte array where byte sequence sub
is found, such that sub
is
contained in the slice [start:]
. Return -1 if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchpublic int rfind(PyObject sub, PyObject start, PyObject end)
rfind( sub [, start [, end ]] )
. Return the highest
index in the byte array where byte sequence sub
is found, such that
sub
is contained in the slice [start:end]
. Arguments
start
and end
(which may be null
or
Py.None
) are interpreted as in slice notation. Return -1 if sub
is
not found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchend
- of slice to searchpublic int rindex(PyObject sub)
rindex(sub)
. Like find(PyObject)
but raise
Py.ValueError
if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)public int rindex(PyObject sub, PyObject start)
rindex( sub [, start ] )
. Like
find(PyObject,PyObject)
but raise Py.ValueError
if sub
is not
found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchpublic PyByteArray rjust(int width)
rjust(width)
: return the bytes right justified in
an array of length width
, padded by spaces. A copy of the original byte array is
returned if width is less than this.size()
.width
- desiredpublic PyByteArray rjust(int width, java.lang.String fillchar)
rjust(width [, fillchar])
: return the bytes
right-justified in an array of length width
. Padding is done using the specified
fillchar (default is a space). A copy of the original byte array is returned if
width
is less than this.size()
.width
- desiredfillchar
- one-byte String to fill with, or null implying spacepublic int rindex(PyObject sub, PyObject start, PyObject end)
rindex( sub [, start [, end ]] )
. Like
find(PyObject,PyObject,PyObject)
but raise Py.ValueError
if sub
is not found.sub
- sequence to find (of a type viewable as a byte sequence)start
- of slice to searchend
- of slice to searchpublic PyByteArray rstrip()
rstrip()
. Return a copy of the byte array with the trailing whitespace characters removed.public PyByteArray rstrip(PyObject bytes)
rstrip(bytes)
Return a copy of the byte array with the trailing characters removed. The bytes
argument is an object specifying the set of characters to be removed. If null or None, the
bytes argument defaults to removing whitespace. The bytes argument is not a suffix;
rather, all combinations of its values are stripped.bytes
- treated as a set of bytes defining what values to strippublic boolean startswith(PyObject prefix)
startswith(prefix)
.
When prefix
is of a type that may be treated as an array of bytes, return
true
if and only if this bytearray starts with the prefix
.
prefix
can also be a tuple of prefixes to look for.prefix
- byte array to match, or object viewable as such, or a tuple of thempublic boolean startswith(PyObject prefix, PyObject start)
startswith( prefix [, start ] )
.
When prefix
is of a type that may be treated as an array of bytes, return
true
if and only if this bytearray starts with the prefix
.
prefix
can also be a tuple of prefixes to look for. With optional
start
(which may be null
or Py.None
), define the
effective bytearray to be the slice [start:]
of this bytearray.prefix
- byte array to match, or object viewable as such, or a tuple of themstart
- of slice in this bytearray to matchpublic boolean startswith(PyObject prefix, PyObject start, PyObject end)
startswith( prefix [, start [, end ]] )
.
When prefix
is of a type that may be treated as an array of bytes, return
true
if and only if this bytearray starts with the prefix
.
prefix
can also be a tuple of prefixes to look for. With optional
start
and end
(which may be null
or
Py.None
), define the effective bytearray to be the slice
[start:end]
of this bytearray.prefix
- byte array to match, or object viewable as such, or a tuple of themstart
- of slice in this bytearray to matchend
- of slice in this bytearray to matchpublic PyByteArray strip()
strip()
. Return a copy of the byte array with the leading
and trailing whitespace characters removed.public PyByteArray strip(PyObject bytes)
strip(bytes)
Return a copy of the byte array with the leading and trailing characters removed. The bytes
argument is anbyte arrayt specifying the set of characters to be removed. If null or None, the
bytes argument defaults to removing whitespace. The bytes argument is not a prefix or suffix;
rather, all combinations of its values are stripped.bytes
- treated as a set of bytes defining what values to strippublic java.lang.String toString()
toString()
method, returning a printable
expression of this byte array in the form bytearray(b'hello')
, where in the
"inner string", any special characters are escaped to their well-known backslash equivalents
or a hexadecimal escape. The built-in function repr()
is expected to call this
method, and wraps the result in a Python str
.public PyString __str__()
PyObject.__str__()
method, returning PyString
,
where in the characters are simply those with a point-codes given in this byte array. The
built-in function str()
is expected to call this method.public PyByteArray translate(PyObject table)
translate(table).
Return a copy of the byte array where all bytes occurring in the optional argument
deletechars
are removed, and the remaining bytes have been mapped through the given
translation table, which must be of length 256.table
- length 256 translation table (of a type that may be regarded as a byte array)public PyByteArray translate(PyObject table, PyObject deletechars)
translate(table[, deletechars]).
Return a copy of the byte array where all bytes occurring in the optional argument
deletechars
are removed, and the remaining bytes have been mapped through the given
translation table, which must be of length 256.
You can use the maketrans() helper function in the string module to create a translation
table. For string objects, set the table argument to None for translations that only delete
characters:table
- length 256 translation table (of a type that may be regarded as a byte array)deletechars
- object that may be regarded as a byte array, defining bytes to deletepublic PyByteArray zfill(int width)
zfill(width):
return the numeric string left filled
with zeros in a byte array of length width
. A sign prefix is handled correctly
if it is in the first byte. A copy of the original is returned if width is less than the
current size of the array.width
- desired