Class Allocator
java.lang.Object
org.apache.commons.imaging.common.Allocator
Checks inputs for meeting allocation limits and allocates arrays.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> Tapply(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 intcheck(int request) Checks a request for meeting allocation limits.static intcheck(int request, int elementSize) Checks a request for meeting allocation limits.static intcheck(long request, int elementSize) Checks a request for meeting allocation limits.static intcheckByteArray(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- 
Allocatorpublic Allocator()
 
- 
- 
Method Details- 
applyAllocates 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:
 
- 
arrayAllocates 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:
 
- 
arrayListAllocates 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:
 
- 
byteArrayAllocates 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:
 
- 
byteArrayAllocates 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:
 
- 
charArrayAllocates 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:
 
- 
checkChecks 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.
 
- 
checkChecks 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.
 
- 
checkChecks 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.
 
- 
checkByteArrayChecks that allocating a byte array of the requested size is within the limit.- Parameters:
- request- The byte array size.
- Returns:
- The input request.
 
- 
doubleArrayAllocates 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:
 
- 
floatArrayAllocates 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:
 
- 
intArrayAllocates 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:
 
- 
longArrayAllocates 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:
 
- 
shortArrayAllocates 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:
 
 
-