Class Filters
java.lang.Object
org.apache.openjpa.kernel.Filters
Helper methods for dealing with query filters.
- Author:
- Abe White
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectAdd the given values.static List<ClassMetaData> addAccessPathMetaDatas(List<ClassMetaData> metas, ClassMetaData[] path) Add the given access path metadatas to the full path list, making sure to maintain only base metadatas in the list.static booleancanConvert(Class<?> c1, Class<?> c2, boolean strict) Return whether an instance of the first class can be converted to an instance of the second.static StringRemoves the first and last string if they are the terminal sequence in the given string.static Objectstatic ObjectConvert the given value to the given type.static ObjectconvertToMatchMethodArgument(Object o, Method method) Convert the given value to match the given (presumably a setter) method argument type.static ObjectDivide the given values.static ObjectgetDefaultForNull(Class<?> nType) static AggregateListenerhintToAggregateListener(Object hint, ClassLoader loader) Convert the user-given hint value to an aggregate listener.static AggregateListener[]hintToAggregateListeners(Object hint, ClassLoader loader) Convert the user-given hint value to an array of aggregate listeners.static FilterListenerhintToFilterListener(Object hint, ClassLoader loader) Convert the user-given hint value to a filter listener.static FilterListener[]hintToFilterListeners(Object hint, ClassLoader loader) Convert the user-given hint value to an array of filter listeners.static ObjecthintToGetter(Object target, String hintKey) Return the value of the property named by the hint key.static voidhintToSetter(Object target, String hintKey, Object value) Set the value of the property named by the hint key.static booleanAffirms if the given String is enclosed in {}.static booleanisTemporalType(Class<?> c) Affirms if the given class is Data, Time or Timestamp.static ObjectMod the given values.static ObjectMultiply the given values.parseDeclaration(String dec, char split, String decType) Parses the given declarations into a list of type, name, type, name...static ObjectParses the given string assuming it is a JDBC key expression.static ObjectPower the base to the exponentstatic Class<?> Given two types, return type they should both be converted to before performing any operations between them.static Class<?> promoteArithmetic(Class<?> c1, Class<?> c2) Given the types of the two operands of an arithmetic operation, return the type of its result, which both operands are converted to before the operation.static Class<?> promoteForComparison(Class<?> c1, Class<?> c2) Given the types of two values that are compared, return the type they should both be converted to before the comparison.static ObjectsplitExpressions(String str, char split, int expected) Split the given expression list into distinct expressions.static ObjectSubtract the given values.static DateTheDateof the day of the given date in the default time zone, normalized to the start of that day as JDBC requires.static Class<?> Return the correct primitive type for the given class, if it is a wrapper.static Class<?> Return the correct wrapper type for the given class.
-
Constructor Details
-
Filters
public Filters()
-
-
Method Details
-
wrap
-
unwrap
-
promote
-
promoteArithmetic
Given the types of the two operands of an arithmetic operation, return the type of its result, which both operands are converted to before the operation. This ispromote(Class, Class), except that, as the numeric promotion rules of the specification require, an operation on a BigDecimal or BigInteger and a Double or Float has the floating point type: Double if an operand is Double, else Float, BigDecimal, BigInteger, Long and Integer, in that order. -
promoteForComparison
Given the types of two values that are compared, return the type they should both be converted to before the comparison. This ispromote(Class, Class), except that a java.time value compared to a java.util.Date is compared as the java.time type, and two different java.util.Date types are compared as timestamps if one of them is a timestamp and as plain dates otherwise. -
canConvert
-
convertToMatchMethodArgument
Convert the given value to match the given (presumably a setter) method argument type.- Parameters:
o- given valuemethod- a presumably setter method- Returns:
- the same value if the method does not have one and only one input argument.
-
convert
-
convert
-
toSqlDate
-
add
-
subtract
-
multiply
-
divide
-
mod
-
power
-
round
-
parseDeclaration
Parses the given declarations into a list of type, name, type, name... Returns null if no declarations. Assumes declaration is not an empty string and is already trimmed (valid assumptions given the checks made in our setters).- Parameters:
decType- the type of declaration being parsed, for use in error messages
-
splitExpressions
-
addAccessPathMetaDatas
public static List<ClassMetaData> addAccessPathMetaDatas(List<ClassMetaData> metas, ClassMetaData[] path) Add the given access path metadatas to the full path list, making sure to maintain only base metadatas in the list. The given list may be null. -
hintToAggregateListener
Convert the user-given hint value to an aggregate listener. The hint can be an aggregate listener instance or class name. -
hintToAggregateListeners
Convert the user-given hint value to an array of aggregate listeners. The hint can be an aggregate listener, aggregate listener array, collection, or comma-separated class names. -
hintToFilterListener
Convert the user-given hint value to a filter listener. The hint can be a filter listener instance or class name. -
hintToFilterListeners
Convert the user-given hint value to an array of filter listeners. The hint can be a filter listener, filter listener array, collection, or comma-separated class names. -
hintToGetter
-
hintToSetter
-
parseJDBCTemporalSyntax
-
isJDBCTemporalSyntax
Affirms if the given String is enclosed in {}. -
clip
Removes the first and last string if they are the terminal sequence in the given string.- Parameters:
s- a string to be examinedfirst- the characters in the beginning of the given stringlast- the characters in the end of the given stringfail- if true throws exception if the given string does not have the given terminal sequences.- Returns:
- the string with terminal sequences removed.
-
isTemporalType
Affirms if the given class is Data, Time or Timestamp. -
getDefaultForNull
-