Package burp.api.montoya.core
Interface ByteArray
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteArray
byteArray
(byte... data) Create a newByteArray
with the provided byte data.static ByteArray
byteArray
(int... data) Create a newByteArray
with the provided integers after a narrowing primitive conversion to bytes.static ByteArray
Create a newByteArray
from the provided text using the encoding specified by Burp Suite.static ByteArray
byteArrayOfLength
(int length) Create a newByteArray
with the provided length.copy()
Create a copy of theByteArray
Create a copy of theByteArray
in temporary file.
This method is used to save theByteArray
object to a temporary file, so that it is no longer held in memory.int
countMatches
(ByteArray searchTerm) Searches the data in the ByteArray and counts all matches for a specified term.int
countMatches
(ByteArray searchTerm, boolean caseSensitive) Searches the data in the ByteArray and counts all matches for a specified term.int
countMatches
(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) Searches the data in the ByteArray and counts all matches for a specified term.int
countMatches
(String searchTerm) Searches the data in the ByteArray and counts all matches for a specified term.int
countMatches
(String searchTerm, boolean caseSensitive) Searches the data in the ByteArray and counts all matches for a specified term.int
countMatches
(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) Searches the data in the ByteArray and counts all matches for a specified term.int
countMatches
(Pattern pattern) Searches the data in the ByteArray and counts all matches for a specified pattern.int
countMatches
(Pattern pattern, int startIndexInclusive, int endIndexExclusive) Searches the data in the ByteArray and counts all matches for a specified pattern.byte
getByte
(int index) Access the byte stored at the provided index.byte[]
getBytes()
Copy of all bytesint
Searches the data in the ByteArray for the first occurrence of a specified term.int
Searches the data in the ByteArray for the first occurrence of a specified term.int
indexOf
(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) Searches the data in the ByteArray for the first occurrence of a specified term.int
Searches the data in the ByteArray for the first occurrence of a specified term.int
Searches the data in the ByteArray for the first occurrence of a specified term.int
Searches the data in the ByteArray for the first occurrence of a specified term.int
Searches the data in the ByteArray for the first occurrence of a specified pattern.int
Searches the data in the ByteArray for the first occurrence of a specified pattern.int
length()
Number of bytes stored in theByteArray
.void
setByte
(int index, byte value) Sets the byte at the provided index to the provided byte.void
setByte
(int index, int value) Sets the byte at the provided index to the provided narrowed integer value.void
setBytes
(int index, byte... data) Sets bytes starting at the specified index to the provided bytes.void
setBytes
(int index, int... data) Sets bytes starting at the specified index to the provided integers after narrowing primitive conversion to bytes.void
Sets bytes starting at the specified index to the provided bytes.subArray
(int startIndexInclusive, int endIndexExclusive) New ByteArray with all bytes between the start index (inclusive) and the end index (exclusive).New ByteArray with all bytes in the specified range.toString()
Convert the bytes of the ByteArray into String form using the encoding specified by Burp Suite.withAppended
(byte... data) Create a copy of theByteArray
appended with the provided bytes.withAppended
(int... data) Create a copy of theByteArray
appended with the provided integers after narrowing primitive conversion to bytes.withAppended
(ByteArray byteArray) Create a copy of theByteArray
appended with the provided ByteArray.withAppended
(String text) Create a copy of theByteArray
appended with the provided text as bytes.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getByte
byte getByte(int index) Access the 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 value) Sets the byte at the provided index to the provided byte.- Parameters:
index
- Index of the byte to be set.value
- The byte to be set.
-
setByte
void setByte(int index, int value) Sets the byte at the provided index to the provided narrowed integer value.- Parameters:
index
- Index of the byte to be set.value
- The integer value to be set after a narrowing primitive conversion to a byte.
-
setBytes
void setBytes(int index, byte... data) Sets bytes starting at the specified index to the provided bytes.- Parameters:
index
- The index of the first byte to set.data
- The byte[] or sequence of bytes to be set.
-
setBytes
void setBytes(int index, int... data) Sets bytes starting at the specified index to the provided integers after narrowing primitive conversion to bytes.- Parameters:
index
- The index of the first byte to set.data
- The int[] or the sequence of integers to be set after a narrowing primitive conversion to bytes.
-
setBytes
Sets bytes starting at the specified index to the provided bytes.- Parameters:
index
- The index of the first byte to set.byteArray
- TheByteArray
object holding the provided bytes.
-
length
int length()Number of bytes stored in theByteArray
.- Returns:
- Length of the
ByteArray
.
-
getBytes
byte[] getBytes()Copy of all bytes- Returns:
- Copy of all bytes.
-
subArray
New ByteArray with 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:
- ByteArray containing all bytes in the specified range.
-
subArray
-
copy
ByteArray copy()Create a copy of theByteArray
- Returns:
- New
ByteArray
with a copy of the wrapped bytes.
-
copyToTempFile
ByteArray copyToTempFile()Create a copy of theByteArray
in temporary file.
This method is used to save theByteArray
object to a temporary file, so that it is no longer held in memory. Extensions can use this method to convertByteArray
objects into a form suitable for long-term usage.- Returns:
- A new
ByteArray
instance stored in temporary file.
-
indexOf
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
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
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
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(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) 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(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) 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
Searches the data in the ByteArray for the first occurrence of a specified pattern.- Parameters:
pattern
- The pattern to be matched.- Returns:
- The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
-
indexOf
Searches the data in the ByteArray for the first occurrence of a specified pattern.- Parameters:
pattern
- The pattern to be matched.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
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
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
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
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(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) 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(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive) 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
Searches the data in the ByteArray and counts all matches for a specified pattern.- Parameters:
pattern
- The pattern to be matched.- Returns:
- The count of all matches of the pattern within the specified bounds.
-
countMatches
Searches the data in the ByteArray and counts all matches for a specified pattern.- Parameters:
pattern
- The pattern to be matched.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
-
withAppended
Create a copy of theByteArray
appended with the provided bytes.- Parameters:
data
- The byte[] or sequence of bytes to append.
-
withAppended
Create a copy of theByteArray
appended with the provided integers after narrowing primitive conversion to bytes.- Parameters:
data
- The int[] or sequence of integers to append after narrowing primitive conversion to bytes.
-
withAppended
-
withAppended
-
byteArrayOfLength
Create a newByteArray
with the provided length.- Parameters:
length
- array length.- Returns:
- New
ByteArray
with the provided length.
-
byteArray
Create a newByteArray
with the provided byte data.- Parameters:
data
- byte[] to wrap, or sequence of bytes to wrap.- Returns:
- New
ByteArray
wrapping the provided byte array.
-
byteArray
Create a newByteArray
with the provided integers after a narrowing primitive conversion to bytes.- Parameters:
data
- int[] to wrap or sequence of integers to wrap.- Returns:
- New
ByteArray
wrapping the provided data after a narrowing primitive conversion to bytes.
-
byteArray
-