Class Arrays
java.lang.Object
org.apache.catalina.tribes.util.Arrays
Utility class for array operations in the Tribes clustering framework.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringManagerString manager for this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic intadd(int[] data) Sums all elements of an integer array.static booleancontains(byte[] source, int srcoffset, byte[] key, int keyoffset, int length) Checks if a byte array contains a key at a given offset.static byte[]Converts a string to a byte array using ISO-8859-1 encoding.static Member[]diff(Membership complete, Membership local, Member ignore) Returns members in the complete set that are not in the local set.static booleanequals(byte[] o1, byte[] o2) Compares two byte arrays for equality.static booleanCompares two object arrays for equality.static Member[]Removes specified members from an array.static voidfill(Membership mbrship, Member[] m) Adds all members from an array to a Membership.static byte[]fromString(String value) Parses a byte array from its string representation.static UniqueIdgetUniqudId(byte[] data) Creates a UniqueId from a byte array.static UniqueIdExtracts a UniqueId from a ChannelMessage.static inthashCode(byte[] a) Computes a hash code for a byte array.static intFinds the index of a member in an array.static Member[]Merges two member arrays, removing duplicates.static intFinds the index of the next member after the given one.static Member[]Removes a single member from an array.static booleansameMembers(Member[] m1, Member[] m2) Checks if two member arrays contain the same members.static StringtoNameString(Member[] data) Converts a member array to a string of member names.static StringtoNameString(Member[] data, int offset, int length) Converts a portion of a member array to a string of member names.static StringtoString(byte[] data) Converts a byte array to a string representation.static StringtoString(byte[] data, int offset, int length) Converts a portion of a byte array to a string representation.static StringtoString(byte[] data, int offset, int length, boolean unsigned) Converts a portion of a byte array to a string representation, optionally treating bytes as unsigned.static StringConverts an object array to a string representation.static StringConverts a portion of an object array to a string representation.
-
Field Details
-
sm
String manager for this class.
-
-
Method Details
-
contains
public static boolean contains(byte[] source, int srcoffset, byte[] key, int keyoffset, int length) Checks if a byte array contains a key at a given offset.- Parameters:
source- the source byte arraysrcoffset- the offset in the source arraykey- the key byte array to search forkeyoffset- the offset in the key arraylength- the length of the data to compare- Returns:
trueif the key is found at the given offset
-
toString
Converts a byte array to a string representation.- Parameters:
data- the byte array- Returns:
- the string representation
-
toString
Converts a portion of a byte array to a string representation.- Parameters:
data- the byte arrayoffset- the starting offsetlength- the number of elements- Returns:
- the string representation
-
toString
Converts a portion of a byte array to a string representation, optionally treating bytes as unsigned.- Parameters:
data- the byte arrayoffset- the starting offsetlength- the number of elementsunsigned-trueto treat bytes as unsigned- Returns:
- the string representation
-
toString
-
toString
-
toNameString
-
toNameString
-
add
public static int add(int[] data) Sums all elements of an integer array.- Parameters:
data- the integer array- Returns:
- the sum of all elements
-
getUniqudId
Extracts a UniqueId from a ChannelMessage.- Parameters:
msg- the channel message- Returns:
- the unique ID
-
getUniqudId
Creates a UniqueId from a byte array.- Parameters:
data- the byte array- Returns:
- the unique ID
-
equals
public static boolean equals(byte[] o1, byte[] o2) Compares two byte arrays for equality.- Parameters:
o1- the first byte arrayo2- the second byte array- Returns:
trueif the arrays are equal
-
equals
-
sameMembers
-
merge
-
fill
Adds all members from an array to a Membership.- Parameters:
mbrship- the membership to add members tom- the member array
-
diff
Returns members in the complete set that are not in the local set.- Parameters:
complete- the complete membershiplocal- the local membershipignore- the member to ignore- Returns:
- the difference as a member array
-
remove
-
extract
-
indexOf
-
nextIndex
-
hashCode
public static int hashCode(byte[] a) Computes a hash code for a byte array.- Parameters:
a- the byte array- Returns:
- the hash code
-
fromString
Parses a byte array from its string representation.- Parameters:
value- the string representation- Returns:
- the byte array
-
convert
Converts a string to a byte array using ISO-8859-1 encoding.- Parameters:
s- the string to convert- Returns:
- the byte array
-