Package burp.api.montoya.core
Interface ByteArray
-
- All Superinterfaces:
java.lang.Iterable<java.lang.Byte>
public interface ByteArray extends java.lang.Iterable<java.lang.Byte>This interface provides access to various methods for querying and manipulating byte arrays.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidappend(byte b)This method appends the provided byte.voidappend(byte[] bytes)This method appends the provided bytes.voidappend(ByteArray byteArray)This method appends the provided bytes.voidappend(java.lang.String text)This method appends the provided text as UTF-8 encoded bytes.static ByteArraybyteArray()Create a newByteArraystatic ByteArraybyteArray(byte[] bytes)Create a newByteArraythat wraps the provided byte arraystatic ByteArraybyteArray(java.lang.String text)Create a newByteArrayfrom the provided UTF-8 encoded text.ByteArraycopy()Create a deep copy of theByteArraydefault intcountMatches(byte[] searchTerm)This method searches the data in the ByteArray and counts all matches for a specified term.default intcountMatches(byte[] searchTerm, boolean caseSensitive)This method searches the data in the ByteArray and counts all matches for a specified term.intcountMatches(byte[] searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray and counts all matches for a specified term.default intcountMatches(java.lang.String searchTerm)This method searches the data in the ByteArray and counts all matches for a specified term.default intcountMatches(java.lang.String searchTerm, boolean caseSensitive)This method searches the data in the ByteArray and counts all matches for a specified term.intcountMatches(java.lang.String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray and counts all matches for a specified term.bytegetByte(int index)This method returns a byte stored at the provided index.byte[]getBytes()This method returns all bytes.byte[]getBytes(int startIndexInclusive, int endIndexExclusive)This method returns all bytes between the start index (inclusive) and the end index (exclusive).byte[]getBytes(Range range)This method returns all bytes in the specified range.default intindexOf(byte[] searchTerm)This method searches the data in the ByteArray for the first occurrence of a specified term.default intindexOf(byte[] searchTerm, boolean caseSensitive)This method searches the data in the ByteArray for the first occurrence of a specified term.intindexOf(byte[] searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray for the first occurrence of a specified term.default intindexOf(java.lang.String searchTerm)This method searches the data in the ByteArray for the first occurrence of a specified term.default intindexOf(java.lang.String searchTerm, boolean caseSensitive)This method searches the data in the ByteArray for the first occurrence of a specified term.intindexOf(java.lang.String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray for the first occurrence of a specified term.intlength()This method returns the number of bytes stored in theByteArray.voidsetByte(int index, byte b)This method sets the byte at the provided index to the provided byte.voidsetBytes(int index, byte[] bytes)This method sets bytes starting at the specified index to the provided bytes.voidsetBytes(int index, ByteArray byteArray)This method sets bytes starting at the specified index to the provided bytes.java.lang.StringtoString()This method can be used to convert the bytes of the ByteArray into UTF-8 encoded String form.
-
-
-
Method Detail
-
byteArray
static ByteArray byteArray()
Create a newByteArray- Returns:
- New empty
ByteArray.
-
byteArray
static ByteArray byteArray(byte[] bytes)
Create a newByteArraythat wraps the provided byte array- Parameters:
bytes- Byte array to wrap.- Returns:
- New
ByteArraywrapping the provided byte array.
-
byteArray
static ByteArray byteArray(java.lang.String text)
Create a newByteArrayfrom the provided UTF-8 encoded text.- Parameters:
text- UTF-8 encoded text.- Returns:
- New
ByteArrayholding a copy of the text as UTF-8 encoded bytes.
-
getByte
byte getByte(int index)
This method returns a byte stored at the provided index.- Parameters:
index- Index of the byte to be retrieved.- Returns:
- The byte at the index.
-
setByte
void setByte(int index, byte b)This method sets the byte at the provided index to the provided byte.- Parameters:
index- Index of the byte to be set.b- The byte to be set.
-
getBytes
byte[] getBytes()
This method returns all bytes.- Returns:
- All bytes.
-
getBytes
byte[] getBytes(int startIndexInclusive, int endIndexExclusive)This method returns all bytes between the start index (inclusive) and the end index (exclusive).- Parameters:
startIndexInclusive- The inclusive start index of retrieved range.endIndexExclusive- The exclusive end index of retrieved range.- Returns:
- All bytes in the specified range.
-
getBytes
byte[] getBytes(Range range)
This method returns all bytes in the specified range.- Parameters:
range- TheRangeof bytes to be returned.- Returns:
- All bytes in the specified range.
-
setBytes
void setBytes(int index, byte[] bytes)This method sets bytes starting at the specified index to the provided bytes.- Parameters:
index- The index of the first byte to set.bytes- The bytes to be set.
-
setBytes
void setBytes(int index, ByteArray byteArray)This method sets bytes starting at the specified index to the provided bytes.- Parameters:
index- The index of the first byte to set.byteArray- TheByteArrayobject holding the provided bytes.
-
append
void append(byte b)
This method appends the provided byte.- Parameters:
b- The byte to be appended.
-
append
void append(byte[] bytes)
This method appends the provided bytes.- Parameters:
bytes- The bytes to append.
-
append
void append(java.lang.String text)
This method appends the provided text as UTF-8 encoded bytes.- Parameters:
text- The UTF-8 encoded string to append.
-
append
void append(ByteArray byteArray)
This method appends the provided bytes.- Parameters:
byteArray- The bytes to append.
-
length
int length()
This method returns the number of bytes stored in theByteArray.- Returns:
- Length of the
ByteArray.
-
copy
ByteArray copy()
Create a deep copy of theByteArray- Returns:
- New
ByteArraywith a deep copy of the wrapped bytes.
-
indexOf
default int indexOf(byte[] searchTerm)
This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java methodString.indexOf(String)works on String-based data.- Parameters:
searchTerm- The value to be searched for.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
indexOf
default int indexOf(java.lang.String searchTerm)
This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java methodString.indexOf(String)works on String-based data.- Parameters:
searchTerm- The value to be searched for.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
indexOf
default int indexOf(byte[] searchTerm, boolean caseSensitive)This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java methodString.indexOf(String)works on String-based data.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
indexOf
default int indexOf(java.lang.String searchTerm, boolean caseSensitive)This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java methodString.indexOf(String)works on String-based data.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
indexOf
int indexOf(byte[] searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java methodString.indexOf(String)works on String-based data.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.startIndexInclusive- The inclusive start index for the search.endIndexExclusive- The exclusive end index for the search.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
indexOf
int indexOf(java.lang.String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java methodString.indexOf(String)works on String-based data.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.startIndexInclusive- The inclusive start index for the search.endIndexExclusive- The exclusive end index for the search.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
countMatches
default int countMatches(byte[] searchTerm)
This method searches the data in the ByteArray and counts all matches for a specified term.- Parameters:
searchTerm- The value to be searched for.- Returns:
- The count of all matches of the pattern
-
countMatches
default int countMatches(java.lang.String searchTerm)
This method searches the data in the ByteArray and counts all matches for a specified term.- Parameters:
searchTerm- The value to be searched for.- Returns:
- The count of all matches of the pattern
-
countMatches
default int countMatches(byte[] searchTerm, boolean caseSensitive)This method searches the data in the ByteArray and counts all matches for a specified term.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.- Returns:
- The count of all matches of the pattern
-
countMatches
default int countMatches(java.lang.String searchTerm, boolean caseSensitive)This method searches the data in the ByteArray and counts all matches for a specified term.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.- Returns:
- The count of all matches of the pattern
-
countMatches
int countMatches(byte[] searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray and counts all matches for a specified term.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.startIndexInclusive- The inclusive start index for the search.endIndexExclusive- The exclusive end index for the search.- Returns:
- The count of all matches of the pattern within the specified bounds
-
countMatches
int countMatches(java.lang.String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)This method searches the data in the ByteArray and counts all matches for a specified term.- Parameters:
searchTerm- The value to be searched for.caseSensitive- Flags whether the search is case-sensitive.startIndexInclusive- The inclusive start index for the search.endIndexExclusive- The exclusive end index for the search.- Returns:
- The count of all matches of the pattern within the specified bounds
-
toString
java.lang.String toString()
This method can be used to convert the bytes of the ByteArray into UTF-8 encoded String form.- Overrides:
toStringin classjava.lang.Object- Returns:
- The converted data in UTF-8 encoding.
-
-