Class Allocator
java.lang.Object
org.apache.commons.imaging.common.Allocator
Checks inputs for meeting allocation limits and allocates arrays.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
apply
(int request, IntFunction<T> factory) Allocates an Object of type T of the requested size.static <T> T[]
array
(int request, IntFunction<T[]> factory, int eltShallowByteSize) Allocates an array of type T of the requested size.static <T> ArrayList
<T> arrayList
(int request) Allocates an Object array of type T of the requested size.static byte[]
byteArray
(int request) Allocates a byte array of the requested size.static byte[]
byteArray
(long request) Allocates a byte array of the requested size.static char[]
charArray
(int request) Allocates a char array of the requested size.static int
check
(int request) Checks a request for meeting allocation limits.static int
check
(int request, int elementSize) Checks a request for meeting allocation limits.static int
check
(long request, int elementSize) Checks a request for meeting allocation limits.static int
checkByteArray
(int request) Checks that allocating a byte array of the requested size is within the limit.static double[]
doubleArray
(int request) Allocates a double array of the requested size.static float[]
floatArray
(int request) Allocates a float array of the requested size.static int[]
intArray
(int request) Allocates a int array of the requested size.static long[]
longArray
(int request) Allocates a long array of the requested size.static short[]
shortArray
(int request) Allocates a short array of the requested size.
-
Constructor Details
-
Allocator
public Allocator()
-
-
Method Details
-
apply
Allocates an Object of type T of the requested size.- Type Parameters:
T
- The return array type- Parameters:
request
- The requested size.factory
- The array factory.- Returns:
- a new byte array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
array
Allocates an array of type T of the requested size.- Type Parameters:
T
- The return array type- Parameters:
request
- The requested size.factory
- The array factory.eltShallowByteSize
- The shallow byte size of an element.- Returns:
- a new byte array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
arrayList
Allocates an Object array of type T of the requested size.- Type Parameters:
T
- The return array type- Parameters:
request
- The requested size.- Returns:
- a new byte array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
byteArray
Allocates a byte array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new byte array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
byteArray
Allocates a byte array of the requested size.- Parameters:
request
- The requested size is cast down to an int.- Returns:
- a new byte array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
charArray
Allocates a char array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new char array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
check
Checks a request for meeting allocation limits.The default limit is
#DEFAULT
, override with the system property "org.apache.commons.imaging.common.mylzw.AllocationChecker".- Parameters:
request
- an allocation request.- Returns:
- the request.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.
-
check
Checks a request for meeting allocation limits.The default limit is
#DEFAULT
, override with the system property "org.apache.commons.imaging.common.mylzw.AllocationChecker".- Parameters:
request
- an allocation request count.elementSize
- The element size.- Returns:
- the request.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.
-
check
Checks a request for meeting allocation limits.The default limit is
#DEFAULT
, override with the system property "org.apache.commons.imaging.common.mylzw.AllocationChecker".- Parameters:
request
- an allocation request count is cast down to an int.elementSize
- The element size.- Returns:
- the request.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.
-
checkByteArray
Checks that allocating a byte array of the requested size is within the limit.- Parameters:
request
- The byte array size.- Returns:
- The input request.
-
doubleArray
Allocates a double array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new double array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
floatArray
Allocates a float array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new float array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
intArray
Allocates a int array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new int array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
longArray
Allocates a long array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new long array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-
shortArray
Allocates a short array of the requested size.- Parameters:
request
- The requested size.- Returns:
- a new short array.
- Throws:
AllocationRequestException
- Thrown when the request exceeds the limit.- See Also:
-