Top Description Inners Fields Constructors Methods
org.python.core

public abstract Class BaseBytes

extends PySequence
implements List<PyInteger>
Class Inheritance
All Implemented Interfaces
java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
org.python.core.PyByteArray
Annotations
@Untraversable
Imports
java.util.AbstractList, .Arrays, .Collection, .Iterator, .LinkedList, .List, .ListIterator

Base class for Jython bytearray (and bytes in due course) that provides most of the Java API, including Java List behaviour. Attempts to modify the contents through this API will throw a TypeError if the actual type of the object is not mutable. It is possible for a Java client to treat this class as a List<PyInteger>, obtaining equivalent functionality to the Python interface in a Java paradigm.

Subclasses must define (from PySequence):

each returning an appropriate concrete type. Mutable subclasses should override: since the default implementations will otherwise throw an exception.

Many of the methods implemented here are inherited or thinly wrapped by PyByteArray, which offers them as Java API, or exposes them as Python methods. These prototype Python methods mostly accept a PyObject as argument, where you might have expected a byte[] or BaseBytes, in order to accommodate the full range of types accepted by the Python equivalent: usually, any PyObject that implements BufferProtocol, providing a one-dimensional array of bytes, is an acceptable argument. In the documentation, the reader will often see the terms "byte array" or "object viewable as bytes" instead of BaseBytes when this broader scope is intended.

Where the methods return a BaseBytes, this is will normally be an instance of the class of the object on which the method was actually called. For example capitalize(), defined in BaseBytes to return a BaseBytes, actually returns a PyByteArray when applied to a bytearray. Or it may be that the method returns a PyList of instances of the target type, for example rpartition(PyObject). This is achieved by the sub-class defining getslice(int, int, int) and getResult(Builder) to return instances of its own type. See the documentation of the particular methods for more information.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
BaseBytes.Builder

A Builder holds a buffer of bytes to which new bytes may be appended while constructing the value of byte array, even when the type ultimately constructed is immutable.

protected static class
BaseBytes.ByteSet

Class for quickly determining whether a given byte is a member of a defined set.

protected static class
BaseBytes.Finder

This class implements the Boyer-Moore-Horspool Algorithm for finding a pattern in text, applied to byte arrays.

protected static class
BaseBytes.Fragment

Intended as a fragment of temporary storage for use we do not know how many bytes of allocate, and we are reading in some kind of iterable stream.

protected static class
BaseBytes.FragmentList

A container of temporary storage when we do not know how many bytes to allocate, and we are reading in some kind of iterable stream.

private class
BaseBytes.IndexDelegate

Class defining the behaviour of bytearray with respect to slice assignment, etc., which differs from the default (list) behaviour in small ways.

protected static class
BaseBytes.ReverseFinder

This class is the complement of Finder and implements the Boyer-Moore-Horspool Algorithm adapted for right-to-left search for a pattern in byte arrays.

Field Summary

Modifier and TypeField and Description
private static final byte
private static final byte
private static final byte[]
private static final byte
protected static final byte[]
emptyStorage

Empty storage constant

protected final List<PyInteger>
listDelegate

Access to the byte array as a java.util.List.

private static final byte
protected int
offset

Index of first byte used in storage array.

private static PyString
protected int
size

Number of bytes actually used in storage array.

private static final byte
protected byte[]
storage

Storage array.

private static final int
private static final byte
Inherited from org.python.core.PySequence:
delegator

Constructor Summary

AccessConstructor and Description
public
BaseBytes(PyType
explicit Jython type
type
)

Constructs a zero-length BaseBytes of explicitly-specified sub-type.

public
BaseBytes(PyType
explicit Jython type
type
,
int
required
size
)

Constructs a zero-filled array of defined size and type.

public
BaseBytes(PyType
explicit Jython type
type
,
int[]
source of values (and size)
value
)

Constructs a byte array of defined type by copying values from int[].

protected
BaseBytes(PyType
explicit Jython type
type
,
String
source of characters
value
)

Constructs a byte array of defined type by copying character values from a String.

Method Summary

Modifier and TypeMethod and Description
public int
__len__()

Overrides org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method.

public PyObject

Returns:

PyTuple that is first stage in pickling byte array
__reduce__
()

Overrides org.python.core.PyObject.__reduce__.

Support for pickling byte arrays: reduce a byte array to the actual type, arguments for (re-)construction of the object, and the dictionary of any user-defined sub-class.

public boolean
add(PyInteger
element to be appended to this list
o
)

Implements java.util.List.add.

Appends the specified element to the end of this list (optional operation).

public void
add(int
index at which the specified element is to be inserted
index
,
PyInteger
element to be inserted
element
)

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).

public boolean
addAll(Collection<? extends PyInteger>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

public boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<? extends PyInteger>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).

private static final void
appendHexEscape(StringBuilder
destination for characters
buf
,
int
curren (maybe unprintable) character
c
)

Helper for __repr__()

public synchronized String

Returns:

the byte array as a String
asString
()

Overrides org.python.core.PyObject.asString.

Present the bytes of a byte array, with no decoding, as a Java String.

protected final synchronized boolean

Returns:

true iff found
basebytes___contains__
(PyObject
byte value to search for
target
)

Search for the target in this byte array, returning true if found and false if not.

pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
basebytes___eq__
(PyObject
Python object to compare with
other
)

Implementation of __eq__ (equality) operator, capable of comparison with another byte array.

pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
basebytes___ge__
(PyObject
Python object to compare with
other
)

Implementation of __ge__ (greater than or equal to) operator, capable of comparison with another byte array.

pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
basebytes___gt__
(PyObject
Python object to compare with
other
)

Implementation of __gt__ (greater than) operator, capable of comparison with another byte array.

pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
basebytes___le__
(PyObject
Python object to compare with
other
)

Implementation of __le__ (less than or equal to) operator, capable of comparison with another byte array.

pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
basebytes___lt__
(PyObject
Python object to compare with
other
)

Implementation of __lt__ (less than) operator, capable of comparison with another byte array.

pack-priv final PyObject

Returns:

Python boolean result or null if not implemented for the other type.
basebytes___ne__
(PyObject
Python object to compare with
other
)

Implementation of __ne__ (not equals) operator, capable of comparison with another byte array.

pack-priv final PyTuple

Returns:

required tuple of type, arguments needed by init, and any user-added attributes.
basebytes___reduce__
()

Ready-to-expose implementation of Python __reduce__() method used in pickle (persistence) of Python objects.

pack-priv final BaseBytes

Returns:

a copy of the array with its first character capitalized and the rest lowercased.
basebytes_capitalize
()

Ready-to-expose implementation of Python capitalize().

pack-priv final BaseBytes

Returns:

(possibly new) byte array containing the result
basebytes_center
(int
desired
width
,
String
one-byte String to fill with, or null implying space
fillchar
)

A ready-to-expose implementation of Python center(width [, fillchar]): return the bytes centered in an array of length width.

private synchronized int

Returns:

1, 0 or -1 as this>b, this==b, or this<b respectively, or -2 if the comparison is not implemented
basebytes_cmp
(PyObject b)

Comparison function between byte array types and any other object.

private synchronized int

Returns:

0 if this==b, or +1 or -1 if this!=b, or -2 if the comparison is not implemented
basebytes_cmpeq
(PyObject b)

Fail-fast comparison function between byte array types and any other object, for when the test is only for equality.

pack-priv final int

Returns:

count of occurrences of sub within this byte array
basebytes_count
(PyObject
bytes to find
sub
,
PyObject
of slice to search
ostart
,
PyObject
of slice to search
oend
)

Ready-to-expose implementation of Python count( sub [, start [, end ]] ).

protected final PyObject

Returns:

object containing the decoded characters
basebytes_decode
(PyObject[]
Python argument list
args
,
String[]
Assocaited keywords
keywords
)

Ready-to-expose implementation of decode( [ encoding [, errors ]] )

pack-priv final BaseBytes

Returns:

copy of this byte array with tabs expanded
basebytes_expandtabs
(int
number of character positions between tab stops
tabsize
)

Ready-to-expose 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.

pack-priv final int

Returns:

index of start of occurrence of sub within this byte array
basebytes_find
(PyObject
bytes to find
sub
,
PyObject
of slice to search
ostart
,
PyObject
of slice to search
oend
)

Ready-to-expose implementation of Python find( sub [, start [, end ]] ).

pack-priv static void
basebytes_fromhex(BaseBytes
to receive the decoded values
result
,
String
specification of the bytes
hex
)

Almost ready-to-expose implementation of Python class method fromhex(string).

pack-priv final boolean

Returns:

true if all bytes in the array are code points for alphanumerics and there is at least one byte, false otherwise.
basebytes_isalnum
()

Ready-to-expose implementation of Python isalnum().

pack-priv final boolean

Returns:

true if all bytes in the array are alphabetic and there is at least one byte, false otherwise
basebytes_isalpha
()

Ready-to-expose implementation of Python isalpha().

pack-priv final boolean

Returns:

true if all bytes in the array are code points for digits and there is at least one byte, false otherwise.
basebytes_isdigit
()

Ready-to-expose implementation of Python isdigit().

pack-priv final boolean

Returns:

true if all cased bytes in the array are code points for lowercase characters and there is at least one cased byte, false otherwise.
basebytes_islower
()

Ready-to-expose implementation of Python islower().

pack-priv final boolean

Returns:

true if all the bytes in the array are code points for whitespace characters and there is at least one byte, false otherwise.
basebytes_isspace
()

Ready-to-expose implementation of Python isspace().

pack-priv final boolean

Returns:

true if the string is a titlecased string and there is at least one cased byte, for example uppercase characters may only follow uncased bytes and lowercase characters only cased ones. Return false otherwise.
basebytes_istitle
()

Ready-to-expose implementation of Python istitle().

pack-priv final boolean

Returns:

true if all cased bytes in the array are code points for uppercase characters and there is at least one cased byte, false otherwise.
basebytes_isupper
()

Ready-to-expose implementation of Python isupper().

pack-priv final synchronized PyByteArray

Returns:

the byte array that is their join
basebytes_join
(Iterable<? extends PyObject>
iterable of objects capable of being regarded as byte arrays
iter
)

Almost ready-to-expose implementation of Python join(iterable).

pack-priv final BaseBytes

Returns:

(possibly new) byte array containing the result
basebytes_ljust
(int
desired
width
,
String
one-byte String to fill with, or null implying space
fillchar
)

A ready-to-expose implementation of Python ljust(width [, fillchar]): return the bytes left-justified in an array of length width.

pack-priv final BaseBytes

Returns:

a copy of the array with all the cased characters converted to lowercase.
basebytes_lower
()

Ready-to-expose implementation of Python lower().

pack-priv final synchronized PyTuple

Returns:

a tuple of (head, separator, tail)
basebytes_partition
(PyObject
the separator on which to partition this byte array
sep
)

Ready-to-expose implementation of Python partition(sep).

pack-priv final synchronized PyByteArray

Returns:

result of replacement as a new PyByteArray
basebytes_replace
(PyObject
sequence to find
oldB
,
PyObject
relacement sequence
newB
,
int
maximum occurrences are replaced or < 0 for all
maxcount
)

An almost ready-to-expose implementation of Python replace( old, new [, count ] ), returning a PyByteArray with all occurrences of sequence oldB replaced by newB.

pack-priv final synchronized String

Returns:

string representation: before + "'" + String(this) + "'" + after
basebytes_repr
(String
String to insert before the quoted text
before
,
String
String to insert after the quoted text
after
)

Almost ready-to-expose Python __repr__(), based on treating the bytes as point codes.

pack-priv final int

Returns:

index of start of occurrence of sub within this byte array
basebytes_rfind
(PyObject
bytes to find
sub
,
PyObject
of slice to search
ostart
,
PyObject
of slice to search
oend
)

Ready-to-expose implementation of Python rfind( sub [, start [, end ]] ).

pack-priv final BaseBytes

Returns:

(possibly new) byte array containing the result
basebytes_rjust
(int
desired
width
,
String
one-byte String to fill with, or null implying space
fillchar
)

A ready-to-expose implementation of Python rjust(width [, fillchar]): return the bytes right-justified in an array of length width.

pack-priv final synchronized PyTuple

Returns:

a tuple of (head, separator, tail)
basebytes_rpartition
(PyObject
the separator on which to partition this byte array
sep
)

Ready-to-expose implementation of Python rpartition(sep).

pack-priv final PyList

Returns:

PyList of byte arrays that result from the split
basebytes_rsplit
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
,
int
maximum number of splits
maxsplit
)

Ready-to-expose implementation of Python rsplit(sep, maxsplit), that returns a list of the words in the byte array, using sep as the delimiter.

pack-priv final synchronized PyList

Returns:

PyList of byte arrays that result from the split
basebytes_rsplit_explicit
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
,
int
maximum number of splits
maxsplit
)

Implementation of Python rsplit(sep, maxsplit), that returns a list of the words in the byte array, using sep (which is not null) as the delimiter.

pack-priv final synchronized PyList

Returns:

PyList of byte arrays that result from the split
basebytes_rsplit_whitespace
(int
maximum number of splits
maxsplit
)

Implementation of Python rsplit(None, maxsplit), that returns a list of the words in the byte array, using whitespace as the delimiter.

pack-priv final PyList

Returns:

PyList of byte arrays that result from the split
basebytes_split
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
,
int
maximum number of splits
maxsplit
)

Ready-to-expose implementation of Python split(sep, maxsplit), that returns a list of the words in the byte array, using sep as the delimiter.

pack-priv final synchronized PyList

Returns:

PyList of byte arrays that result from the split
basebytes_split_explicit
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
,
int
maximum number of splits
maxsplit
)

Implementation of Python split(sep, maxsplit), that returns a list of the words in the byte array, using sep (which is not null) as the delimiter.

pack-priv final synchronized PyList

Returns:

PyList of byte arrays that result from the split
basebytes_split_whitespace
(int
maximum number of splits
maxsplit
)

Implementation of Python split(None, maxsplit), that returns a list of the words in the byte array, using whitespace as the delimiter.

protected final synchronized PyList

Returns:

List of segments
basebytes_splitlines
(boolean
if true, include the end of line bytes(s)
keepends
)

Ready-to-expose implementation of Python splitlines(keepends), returning a list of the lines in the array, breaking at line boundaries.

protected final synchronized boolean

Returns:

true if and only if this byte array ends with (one of) target.
basebytes_starts_or_endswith
(PyObject
prefix or suffix sequence to find (of a type viewable as a byte sequence) or a tuple of those.
target
,
PyObject
of slice to search.
ostart
,
PyObject
of slice to search.
oend
,
boolean
true if we are doing endswith, false if startswith.
endswith
)

Almost ready-to-expose implementation serving both Python startswith( prefix [, start [, end ]] ) and endswith( suffix [, start [, end ]] ).

pack-priv final BaseBytes

Returns:

a copy of the array with uppercase characters converted to lowercase and vice versa.
basebytes_swapcase
()

Ready-to-expose implementation of Python swapcase().

pack-priv final BaseBytes

Returns:

a titlecased version of the array where words start with an uppercase character and the remaining characters are lowercase.
basebytes_title
()

Ready-to-expose implementation of Python title().

pack-priv final BaseBytes

Returns:

a copy of the array with all the cased characters converted to uppercase.
basebytes_upper
()

Ready-to-expose implementation of Python upper().

pack-priv final BaseBytes

Returns:

left-filled byte array
basebytes_zfill
(int
desired
width
)

Ready-to-expose implementation of Python zfill(width): return the numeric string left filled with zeros in a byte array of length width.

private final synchronized byte

Returns:

the byte at the given index
byteAt
(int index)

No range check access to byte[index].

protected static final byte
byteCheck(int
to convert.
value
)

Check that an integer is suitable for storage in a (Python) byte array, and convert it to the Java byte value that can be stored there.

protected static final byte
byteCheck(PyInteger
to convert.
value
)

Check that the value of an PyInteger is suitable for storage in a (Python) byte array, and convert it to the Java byte value that can be stored there.

protected static final byte
byteCheck(PyObject
to convert.
value
)

Check that the type and value of a PyObject is suitable for storage in a (Python) byte array, and convert it to the Java byte value that can be stored there.

public BaseBytes

Returns:

a copy of the array with its first character capitalized and the rest lowercased.
capitalize
()

Java API equivalent of Python capitalize().

protected static final int

Returns:

the length of the separator
checkForEmptySeparator
(PyBuffer
view to test
separator
)

Convenience routine producing a ValueError for "empty separator" if the PyBuffer is of an object with zero length, and returning the length otherwise.

public void
clear()

Implements java.util.List.clear.

Removes all of the elements from this list (optional operation).

private static int

Returns:

1, 0 or -1 as a>b, a==b, or a<b respectively
compare
(BaseBytes
left-hand array in the comparison
a
,
PyBuffer
right-hand wrapped object in the comparison
b
)

Comparison function between a byte array and a buffer of bytes exported by some other object, such as a String, presented as a PyBuffer, returning 1, 0 or -1 as a>b, a==b, or a<b respectively.

pack-priv static PyException

Returns:

PyException (TypeError) as detailed
ConcatenationTypeError
(PyType type, PyType toType)

Convenience method to create a TypeError PyException with the message "can't concat {type} to {toType}"

public boolean
contains(Object
element whose presence in this list is to be tested
o
)

Implements java.util.List.contains.

Returns true if this list contains the specified value.

public boolean
containsAll(Collection<?>
collection to be checked for containment in this list
c
)

Implements java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.

public PyObject

Returns:

object containing the decoded characters
decode
()

Decode the byte array to a Unicode string according to the default encoding.

public PyObject

Returns:

object containing the decoded characters
decode
(String
the name of the codec (uses default codec if null)
encoding
)

Decode the byte array to a Unicode string according to the specified encoding and default error policy.

public PyObject

Returns:

object containing the decoded characters
decode
(String
the name of the codec (uses default codec if null)
encoding
,
String
the name of the error policy (uses 'strict' if null)
errors
)

Decode the byte array to a Unicode string according to the specified encoding and error policy.

protected static String

Returns:

encoded string
encode
(PyString
primary argument from which value is taken
arg
,
String
name of optional encoding
encoding
,
String
name of optional errors policy
errors
)

Helper for setslice(int, int, int, PyObject), for __new__ and __init__ and the Java API constructor from a text string with the specified encoding in subclasses.

public boolean

Returns:

true if and only if this byte array is equal (in value) to other
equals
(Object
object to compare this byte array to
other
)

Overrides org.python.core.PyObject.equals.

Implements java.util.List.equals.

Test for the equality of (the value of) this byte array to the object other.

protected static byte

Returns:

the (checked) single fill byte
fillByteCheck
(String
name
function
,
String
or null
fillchar
)

Helper to check the fill byte for basebytes_rjust(int, String), basebytes_ljust(int, String) and basebytes_center(int, String), which is required to be a single character string, treated as a byte.

private final int

Returns:

index of start of occurrence of sub within this byte array
find
(BaseBytes.Finder
for the bytes to find, sometime forwards, sometime backwards
finder
,
PyObject
of slice to search
ostart
,
PyObject
of slice to search
oend
)

Common code for Python find( sub [, start [, end ]] ) and rfind( sub [, start [, end ]] ).

public PyInteger
get(int
index of the element to return
index
)

Implements java.util.List.get.

Returns the element at the specified position in this list.

private static final PyString
getPickleEncoding()

Name the encoding effectively used in __reduce__() suport for pickling: this choice is hard-coded in CPython as "latin-1".

protected abstract BaseBytes

Returns:

a new object of the correct sub-class
getResult
(BaseBytes.Builder
containing the result
b
)

Every sub-class of BaseBytes overrides this method to access a Builder and return that class' particular type, possibly without copying.

protected abstract BaseBytes
getslice(int
the position of the first element.
start
,
int
one more than the position of the last element.
stop
,
int
the step size.
step
)

Implements abstract org.python.core.PySequence.getslice.

Returns a range of elements from the sequence.

protected BaseBytes

Returns:

a subclass instance of BaseBytes corresponding the the given range of elements.
getslice
(int
the position of the first element.
start
,
int
one more than the position of the last element.
stop
)

Specialisation of getslice(int, int, int) to contiguous slices (of step size 1) for brevity and efficiency.

protected static PyBuffer

Returns:

byte-oriented view or null
getView
(PyObject
object to wrap
b
)

Return a buffer exported by the argument, or return null if it does not bear the buffer API.

protected static PyBuffer

Returns:

byte-oriented view
getViewOrError
(PyObject
object to wrap
b
)

Return a buffer exported by the argument or raise an exception if it does not bear the buffer API.

public int
hashCode()

Overrides org.python.core.PyObject.hashCode.

Implements java.util.List.hashCode.

Returns the hash code value for this list.

private static int

Returns:

value 0-15
hexDigit
(char
to translate
c
)

Translate one character to its hexadecimal value.

protected int

Returns:

index in the byte array (0..size-1) or -1 if not found
index
(byte
byte to search for
b
)

The very simplest kind of find operation: return the index in the byte array of the first occurrence of the byte value

protected final void
indexCheck(int
to check
index
)

Check that an index is within the range of the array, that is 0<=index<size.

public int
indexOf(Object
element to search for
o
)

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

private int[]

Returns:

[ start, end, 1, end-start ]
indicesEx
(PyObject
of slice to define.
ostart
,
PyObject
of slice to define.
oend
)

Helper to convert [ostart:oend] to integers with slice semantics relative to this byte array.

protected void
init(PyObject
primary argument from which value is taken
arg
)

Helper for __new__ and __init__ and the Java API constructor from PyObject in subclasses.

protected void
init(PyString
primary argument from which value is taken
arg
,
PyObject
name of optional encoding (must be a string type)
encoding
,
PyObject
name of optional errors policy (must be a string type)
errors
)

Helper for __new__ and __init__ and the Java API constructor from a text string with the specified encoding in subclasses.

protected void
init(PyString
primary argument from which value is taken
arg
,
String
name of optional encoding
encoding
,
String
name of optional errors policy
errors
)

Helper for __new__ and __init__ and the Java API constructor from a text string with the specified encoding in subclasses.

protected void
init(int
size of zero-filled array
n
)

Helper for __new__ and __init__ and the Java API constructor from int in subclasses.

protected void
init(BufferProtocol
an object bearing the Buffer API and consistent with the slice assignment
value
)

Helper for __new__ and __init__ and the Java API constructor from objects supporting the Jython implementation of PEP 3118 (Buffer API) in subclasses.

protected void
init(BaseBytes
bytearray (or bytes) to copy
source
)

Helper for __new__ and __init__ and the Java API constructor from bytearray or bytes in subclasses.

protected void
init(Iterable<? extends PyObject>
iterable source of values to enter in the array
iter
)

Helper for __new__ and __init__ and the Java API constructor from an arbitrary iterable Python type in subclasses.

private boolean

Returns:

true iff value allows the getBuffer
initFromBuffer
(PyObject
an object possibly bearing the Buffer API
value
)

Helper for __new__ and __init__ from objects that might support the Jython Buffer API.

public synchronized int

Returns:

the integer value at the index
intAt
(int
of value in byte array
index
)

Return the Python byte (in range 0 to 255 inclusive) at the given index.

pack-priv static final boolean

Returns:

'A'<= b <='Z' or 'a'<= b <='z' or '0'<= b <='9'.
isalnum
(byte b)

public boolean

Returns:

true if all bytes in the array are code points for alphanumerics and there is at least one byte, false otherwise.
isalnum
()

Java API equivalent of Python isalnum().

pack-priv static final boolean

Returns:

'A'<= b <='Z' or 'a'<= b <='z'.
isalpha
(byte b)

public boolean

Returns:

true if all bytes in the array are alphabetic and there is at least one byte, false otherwise
isalpha
()

Java API equivalent of Python isalpha().

pack-priv static final boolean

Returns:

'0'<= b <='9'.
isdigit
(byte b)

public boolean

Returns:

true if all bytes in the array are code points for digits and there is at least one byte, false otherwise.
isdigit
()

Java API equivalent of Python isdigit().

public boolean
isEmpty()

Implements java.util.List.isEmpty.

Returns true if this list contains no elements.

pack-priv static final boolean

Returns:

'a'<= b <='z'.
islower
(byte b)

public boolean

Returns:

true if all cased bytes in the array are code points for lowercase characters and there is at least one cased byte, false otherwise.
islower
()

Java API equivalent of Python islower().

pack-priv static final boolean

Returns:

b in ' \t\n\v\f\r'
isspace
(byte b)

public boolean

Returns:

true if all the bytes in the array are code points for whitespace characters and there is at least one byte, false otherwise.
isspace
()

Java API equivalent of Python isspace().

public boolean

Returns:

true if the string is a titlecased string and there is at least one cased byte, for example uppercase characters may only follow uncased bytes and lowercase characters only cased ones. Return false otherwise.
istitle
()

Java API equivalent of Python istitle().

pack-priv static final boolean

Returns:

'A'<= b <='Z'.
isupper
(byte b)

public boolean

Returns:

true if all cased bytes in the array are code points for uppercase characters and there is at least one cased byte, false otherwise.
isupper
()

Java API equivalent of Python isupper().

public Iterator<PyInteger>
iterator()

Implements java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

public int
lastIndexOf(Object
element to search for
o
)

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

public ListIterator<PyInteger>
listIterator()

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

public ListIterator<PyInteger>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.

public BaseBytes

Returns:

a copy of the array with all the cased characters converted to lowercase.
lower
()

Java API equivalent of Python lower().

protected int

Returns:

index of first unstrippable byte
lstripIndex
(BaseBytes.ByteSet
set of byte values to skip over
byteSet
)

Return the index [0..size-1] of the leftmost byte not matching any in byteSet, or size if they are all strippable.

protected int

Returns:

index of first non-whitespace byte
lstripIndex
()

Return the index [0..size-1] of the leftmost non-whitespace byte, or size if they are all whitespace.

private boolean

Returns:

true if and only if the slice this[pos:pos+n] matches the given target
match
(PyObject
pattern to match
target
,
int
at which to start the comparison
pos
,
int n, boolean endswith)

Test whether the slice [pos:pos+n] of this byte array matches the given target object (accessed as a PyBuffer) at one end or the other.

protected void
newStorage(int
becomes the new value of this.size
needed
)

Allocate fresh, zero-filled storage for the requested number of bytes and make that the size.

private BaseBytes

Returns:

(possibly new) byte array containing the result
padHelper
(byte
byte to fill with
pad
,
int
padding requested
left
,
int
padding requested
right
)

Helper function to construct the return value for rjust(String), ljust(String) and center(String).

public PyTuple

Returns:

a tuple of (head, separator, tail)
partition
(PyObject
the separator on which to partition this byte array
sep
)

Implementation of Python partition(sep), returning a 3-tuple of byte arrays (of the same type as this).

private PyTuple

Returns:

([0:p], [p:q], [q:])
partition
(int
start of separator
p
,
int
start of tail
q
)

Construct return value for implementation of Python partition(sep) or rpartition(sep), returns [0:p], [p:q], [q:]

The elements of the PyTuple returned by this method are instances of the same actual type as this.

protected PyInteger
pyget(int
index of element to return.
index
)

Implements abstract org.python.core.PySequence.pyget.

Returns the element of the sequence at the given index.

public void
pyinsert(int
to insert at
index
,
PyObject
to insert (by value)
element
)

Insert the element (interpreted as a Python byte value) at the given index.

public boolean
remove(Object
element to be removed from this list, if present
o
)

Implements java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).

public PyInteger
remove(int
the index of the element to be removed
index
)

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).

public boolean
removeAll(Collection<?>
collection containing elements to be removed from this list
c
)

Implements java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

protected abstract BaseBytes
repeat(int
the number of times to repeat the sequence.
count
)

Implements abstract org.python.core.PySequence.repeat.

Returns a (concrete subclass of) PySequence that repeats the given sequence, as in the implementation of __mul__ for strings.

private PyByteArray

Returns:

the result as a new PyByteArray
replace_delete_substring
(PyBuffer
byte-string to find and delete
from
,
int
maximum number of deletions to make
maxcount
)

Helper for basebytes_replace(PyObject, PyObject, int) implementing the special case of byte-string replacement when the new string has zero length, i.e. deletion.

private PyByteArray
replace_interleave(PyBuffer
the replacement bytes as a byte-oriented view
to
,
int
upper limit on number of insertions
maxcount
)

Handle the interleaving case b'hello'.replace(b'', b'..') = b'..h..e..l..l..o..' At the call site we are guaranteed: size>=1, to.getLen()>=1, maxcount>=1

private PyByteArray

Returns:

the result as a new PyByteArray
replace_substring
(PyBuffer
byte-string to find and replace
from
,
PyBuffer
replacement byte-string
to
,
int
maximum number of replacements to make
maxcount
)

Helper for basebytes_replace(PyObject, PyObject, int) implementing the general case of byte-string replacement when the new and old strings have different lengths.

private PyByteArray

Returns:

the result as a new PyByteArray
replace_substring_in_place
(PyBuffer
byte-string to find and replace
from
,
PyBuffer
replacement byte-string
to
,
int
maximum number of replacements to make
maxcount
)

Helper for basebytes_replace(PyObject, PyObject, int) implementing the special case of byte-string replacement when the new and old strings have the same length.

public boolean
retainAll(Collection<?>
collection containing elements to be retained in this list
c
)

Implements java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).

protected static final int

Returns:

n ≥ size a recommended storage array size
roundUp
(int
of storage actually needed
size
)

Choose a size appropriate to store the given number of bytes, with some room for growth, when allocating storage for mutable types or Builder.

public PyTuple

Returns:

a tuple of (head, separator, tail)
rpartition
(PyObject
the separator on which to partition this byte array
sep
)

Implementation of Python rpartition(sep), returning a 3-tuple of byte arrays (of the same type as this).

public PyList

Returns:

PyList of byte arrays that result from the split
rsplit
()

Implementation of Python rsplit(), that returns a list of the words in the byte array, using whitespace as the delimiter.

public PyList

Returns:

PyList of byte arrays that result from the split
rsplit
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
)

Implementation of Python rsplit(sep), that returns a list of the words in the byte array, using sep as the delimiter.

public PyList

Returns:

PyList of byte arrays that result from the split
rsplit
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
,
int
maximum number of splits
maxsplit
)

Implementation of Python rsplit(sep, maxsplit), that returns a list of the words in the byte array, using sep as the delimiter.

protected int

Returns:

index of strippable tail
rstripIndex
(BaseBytes.ByteSet
set of byte values to strip
byteSet
)

Return the index [0..size-1] such that all bytes from here to the right match one in byteSet, that is, the index of the matching tail, or size if there is no matching tail byte.

protected int

Returns:

index of strippable tail
rstripIndex
()

Return the index [0..size-1] such that all bytes from here to the right are whitespace, that is, the index of the whitespace tail, or size if there is no whitespace tail.

public PyInteger
set(int
index of the element to replace
index
,
PyInteger
element to be stored at the specified position
element
)

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

protected void
setBytes(int
index in this byte array at which the first character code lands
start
,
String
source of characters
value
)

Fill a defined section of a byte array by copying character values from a String.

protected void
setBytes(int
index in this byte array at which the first character code lands
start
,
int step, String
source of characters
value
)

Fill a strided slice of a byte array by copying character values from a String.

protected void
setStorage(byte[]
byte array allocated by client
storage
,
int
number of bytes actually used
size
,
int
index of first byte used
offset
)

Helper for constructors and methods that manipulate the storage in mutable subclasses.

protected void
setStorage(byte[]
byte array allocated by client
storage
,
int
number of bytes actually used
size
)

Helper for constructors and methods that manipulate the storage in mutable subclasses in the case where the storage should consist of the first part of the given array.

protected void
setStorage(byte[]
byte array allocated by client
storage
)

Helper for constructors and methods that manipulate the storage in mutable subclasses in the case where the storage should consist of exactly the whole of the given array.

public int

Returns:

Number of bytes in byte array.
size
()

Implements java.util.List.size.

Number of bytes in bytearray (or bytes) object.

public PyList

Returns:

PyList of byte arrays that result from the split
split
()

Implementation of Python split(), that returns a list of the words in the byte array, using whitespace as the delimiter.

public PyList

Returns:

PyList of byte arrays that result from the split
split
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
)

Implementation of Python split(sep), that returns a list of the words in the byte array, using sep as the delimiter.

public PyList

Returns:

PyList of byte arrays that result from the split
split
(PyObject
bytes, or object viewable as bytes, defining the separator
sep
,
int
maximum number of splits
maxsplit
)

Implementation of Python split(sep, maxsplit), that returns a list of the words in the byte array, using sep as the delimiter.

public PyList

Returns:

List of segments
splitlines
()

Implementation of Python splitlines(), returning a list of the lines in the byte array, breaking at line boundaries.

public PyList

Returns:

PyList of segments
splitlines
(boolean
if true, include the end of line bytes(s)
keepends
)

Implementation of Python splitlines(keepends), returning a list of the lines in the string, breaking at line boundaries.

public List<PyInteger>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

public BaseBytes

Returns:

a copy of the array with uppercase characters converted to lowercase and vice versa.
swapcase
()

Java API equivalent of Python swapcase().

public BaseBytes

Returns:

a titlecased version of the array where words start with an uppercase character and the remaining characters are lowercase.
title
()

Java API equivalent of Python title().

public Object[]
toArray()

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

public <T> T[]
toArray(T[]
the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

public BaseBytes

Returns:

a copy of the array with all the cased characters converted to uppercase.
upper
()

Java API equivalent of Python upper().

Inherited from org.python.core.PySequence:
__delitem____delslice____eq____finditem____finditem____ge____getitem____getslice____gt____iter____le____lt____ne____nonzero____setitem____setitem____setslice____tojava__boundToSequencecmpdeldelRangedelslicefastSequenceisMappingTypeisNumberTypeisSequenceTypeisSubTypepysetrunsupportedopMessageseq___delitem__seq___delslice__seq___eq__seq___finditem__seq___finditem__seq___ge__seq___getitem__seq___getslice__seq___gt__seq___iter__seq___le__seq___lt__seq___ne__seq___nonzero__seq___setitem__seq___setslice__setslicesliceLengthunsupportedopMessage