Class Utils
java.lang.Object
org.apache.commons.crypto.utils.Utils
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckArgument(boolean expression) Ensures the truth of an expression involving one or more parameters to the calling method.static voidcheckArgument(boolean expression, Object errorMessage) Checks the truth of an expression.static <T> TcheckNotNull(T reference) Deprecated.static voidcheckState(boolean expression) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static voidcheckState(boolean expression, String message) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static CryptoCiphergetCipherInstance(String transformation, Properties properties) Helper method to create a CryptoCipher instance and throws only IOException.static PropertiesGets a properties instance that defaults to the System Properties plus any other properties found in the fileSYSTEM_PROPERTIES_FILEstatic PropertiesgetProperties(Properties newProp) Gets the properties merged with default properties.splitClassNames(String clazzNames, String separator) Splits class names sequence into substrings, Trim each substring into an entry,and returns an list of the entries.
-
Method Details
-
checkArgument
Ensures the truth of an expression involving one or more parameters to the calling method.- Parameters:
expression- a boolean expression.- Throws:
IllegalArgumentException- if expression is false.
-
checkArgument
Checks the truth of an expression.- Parameters:
expression- a boolean expression.errorMessage- the exception message to use if the check fails; will be converted to a string usingString .valueOf(Object).- Throws:
IllegalArgumentException- if expression is false.
-
checkNotNull
Deprecated.Ensures that an object reference passed as a parameter to the calling method is not null.- Type Parameters:
T- the type of the object reference to be checked.- Parameters:
reference- an object reference.- Returns:
- the non-null reference that was validated.
- Throws:
NullPointerException- if reference is null.
-
checkState
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
expression- a boolean expression.- Throws:
IllegalStateException- if expression is false.
-
checkState
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
expression- a boolean expression.message- Error message for the exception when the expression is false.- Throws:
IllegalStateException- if expression is false.
-
getCipherInstance
public static CryptoCipher getCipherInstance(String transformation, Properties properties) throws IOException Helper method to create a CryptoCipher instance and throws only IOException.- Parameters:
transformation- the name of the transformation, e.g., AES/CBC/PKCS5Padding. See the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard transformation names.properties- ThePropertiesclass represents a set of properties.- Returns:
- the CryptoCipher instance.
- Throws:
IOException- if an I/O error occurs.
-
getDefaultProperties
Gets a properties instance that defaults to the System Properties plus any other properties found in the fileSYSTEM_PROPERTIES_FILE- Returns:
- a Properties instance with defaults
-
getProperties
Gets the properties merged with default properties.- Parameters:
newProp- User-defined properties- Returns:
- User-defined properties with the default properties
-
splitClassNames
Splits class names sequence into substrings, Trim each substring into an entry,and returns an list of the entries.- Parameters:
clazzNames- a string consist of a list of the entries joined by a delimiter, may be null or empty in which case an empty list is returned.separator- a delimiter for the input string.- Returns:
- a list of class entries.
-
Objects.requireNonNull(Object).