Class PaperClipsUtil
java.lang.Object
org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil
public class PaperClipsUtil
extends java.lang.Object
Convenience methods specific to PaperClips
-
Method Summary
Modifier and Type Method Description static int[]
copy(int[] array)
Returns a copy of the array.static int[][]
copy(int[][] array)
Returns a deep copy of the array.static void
dispose(java.util.List<PrintPiece> pages)
Disposes the print pieces in the list.static void
dispose(PrintPiece piece)
Disposes the print piece if not null.static void
dispose(PrintPiece[] pieces)
Disposes the print pieces that are not null.static void
dispose(PrintPiece[] pages, int start, int end)
Disposes the print pieces in the array from start (inclusive) to end (exclusive).static void
dispose(PrintPiece p1, PrintPiece p2)
Disposes the arguments that are not null.static void
dispose(PrintPiece piece, PrintPiece[] pieces)
Disposes the print pieces that are not null.static int
firstMatch(int value, int[] masks, int defaultMask)
Returns the first element in masks where (value & mask[index]) == mask[index].static int
sum(int[] array)
Returns the sum of all elements in the array.static int
sum(int[] array, int start, int count)
Returns the sum of all elements in the array in the range[start, start+count)
.static int
sumByIndex(int[] array, int[] indices)
Returns the sum of all elements in the array at the given indices.static int[]
toIntArray(java.util.List<java.lang.Integer> list)
Converts the argument to an int[] array.static int[][]
toIntIntArray(java.util.List<int[]> 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
public static int[] toIntArray(java.util.List<java.lang.Integer> list)Converts the argument to an int[] array.- Parameters:
list
- a List of Integers.- Returns:
- a primitive int[] array.
-
toIntIntArray
public static int[][] toIntIntArray(java.util.List<int[]> list)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 & 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.
-