Package net.sf.paperclips.internal
Class PaperClipsUtil
java.lang.Object
net.sf.paperclips.internal.PaperClipsUtil
Convenience methods specific to PaperClips
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]copy(int[] array) Returns a copy of the array.static int[][]copy(int[][] array) Returns a deep copy of the array.static voidDisposes the print pieces in the list.static voiddispose(PrintPiece piece) Disposes the print piece if not null.static voiddispose(PrintPiece[] pieces) Disposes the print pieces that are not null.static voiddispose(PrintPiece[] pages, int start, int end) Disposes the print pieces in the array from start (inclusive) to end (exclusive).static voiddispose(PrintPiece p1, PrintPiece p2) Disposes the arguments that are not null.static voiddispose(PrintPiece piece, PrintPiece[] pieces) Disposes the print pieces that are not null.static intfirstMatch(int value, int[] masks, int defaultMask) Returns the first element in masks where (value invalid input: '&' mask[index]) == mask[index].static intsum(int[] array) Returns the sum of all elements in the array.static intsum(int[] array, int start, int count) Returns the sum of all elements in the array in the range[start, start+count).static intsumByIndex(int[] array, int[] indices) Returns the sum of all elements in the array at the given indices.static int[]toIntArray(List list) Converts the argument to an int[] array.static int[][]toIntIntArray(List list) Converts the argument to an int[][] array.
-
Method Details
-
dispose
Disposes the print piece if not null.- Parameters:
piece- the print piece to dispose.
-
dispose
Disposes the arguments that are not null.- Parameters:
p1- print piece to disposep2- print piece to dispose
-
dispose
Disposes the print pieces that are not null.- Parameters:
pieces- array of print pieces to dispose.
-
dispose
Disposes the print pieces in the array from start (inclusive) to end (exclusive).- Parameters:
pages- array of print pieces to dispose.start- the start index.end- the end index.
-
dispose
Disposes the print pieces in the list.- Parameters:
pages- list of print pieces to dispose.
-
dispose
Disposes the print pieces that are not null.- Parameters:
piece- a print piece to disposepieces- array of print pieces to dispose
-
copy
public static int[] copy(int[] array) Returns a copy of the array.- Parameters:
array- the array to copy- Returns:
- a copy of the array.
-
copy
public static int[][] copy(int[][] array) Returns a deep copy of the array.- Parameters:
array- the array to copy- Returns:
- a copy of the array.
-
sum
public static int sum(int[] array) Returns the sum of all elements in the array.- Parameters:
array- the array- Returns:
- the sum of all elements in the array.
-
sum
public static int sum(int[] array, int start, int count) Returns the sum of all elements in the array in the range[start, start+count).- Parameters:
array- the array containing the elements to add up.start- the index of the first element to add.count- the number of elements to add.- Returns:
- the sum of all elements in the array in the specified range.
-
sumByIndex
public static int sumByIndex(int[] array, int[] indices) Returns the sum of all elements in the array at the given indices.- Parameters:
array- the array of elements to add up.indices- the indices of the elements in the array to add up.- Returns:
- the sum of all elements in the array at the given indices.
-
toIntArray
Converts the argument to an int[] array.- Parameters:
list- a List of Integers.- Returns:
- a primitive int[] array.
-
toIntIntArray
Converts the argument to an int[][] array.- Parameters:
list- a List of int[] arrays.- Returns:
- a primitive int[][] array.
-
firstMatch
public static int firstMatch(int value, int[] masks, int defaultMask) Returns the first element in masks where (value invalid input: '&' mask[index]) == mask[index].- Parameters:
value- the value to matchmasks- the possible values.defaultMask- the value to return if no match is found.- Returns:
- the first value in possibleValues which is a bitwise match to value, or 0 if none is found.
-