Class ByteSearch
java.lang.Object
org.apache.axiom.attachments.utils.ByteSearch
Deprecated.
This class was part of the MIME parser in Axiom versions before 1.2.13 and is no
longer used. It will be removed in Axiom 1.3. Please note that the code in this class
is known to have issues; see AXIOM-449 and AXIOM-450 for more
information.
Various byte array searching utilities. This includes a "skip search", which is an optimized
search for finding a byte pattern in a large byte array.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic short[]
getSkipArray
(byte[] pattern, boolean direction) Deprecated.skipArray Builds a skip array for this pattern and direction.static boolean
isEqual
(byte[] pattern, byte[] buffer, int start, int end) Deprecated.isEqualstatic int
search
(byte[] search, byte[] bytes, int start, int end, boolean direction) Deprecated.search Look for the search bytes in the bytes array using a straight search.static int
skipSearch
(byte[] pattern, boolean direction, byte[] buffer, int start, int end, short[] skip) Deprecated.Search a byte sequence for a given pattern.
-
Constructor Details
-
ByteSearch
public ByteSearch()Deprecated.
-
-
Method Details
-
skipSearch
public static int skipSearch(byte[] pattern, boolean direction, byte[] buffer, int start, int end, short[] skip) Deprecated.Search a byte sequence for a given pattern. The method uses the skip search algorithm. The search can be performed in forward or backward direction, i.e. beginning from the start or end of the byte sequence.- Parameters:
pattern
- byte[]direction
- true if forward, false if backwardbuffer
- byte[] to searchstart
- index to start searchend
- index to end search (end index is not within the search)skip
- short[256] A skipArray generated from a call to generateSkipArray.- Returns:
- index or -1 if not found
-
getSkipArray
public static short[] getSkipArray(byte[] pattern, boolean direction) Deprecated.skipArray Builds a skip array for this pattern and direction. The skipArray is used in the optimized skipSearch- Parameters:
pattern
-direction
-- Returns:
- short[256]
-
isEqual
public static boolean isEqual(byte[] pattern, byte[] buffer, int start, int end) Deprecated.isEqual- Parameters:
pattern
-buffer
-start
- indexend
- index- Returns:
- true if the bytes in buffer[start] equal pattern
-
search
public static int search(byte[] search, byte[] bytes, int start, int end, boolean direction) Deprecated.search Look for the search bytes in the bytes array using a straight search. Use the skip search if the number of bytes to search is large or if this search is performed frequently.- Parameters:
search
- byte[]bytes
- byte[] to searchstart
- starting indexend
- end index (exclusivedirection
- boolean (true indicates forward search, false is backwards search- Returns:
- index or -1
-