|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.annotations.helpers.AnnotationHelper
public class AnnotationHelper
Helper class to process fields annotated with Parsed
| Method Summary | ||
|---|---|---|
static boolean |
allFieldsIndexBasedForParsing(Class<?> beanClass)
Runs through all annotations of a given class to identify whether all annotated fields and methods (with the Parsed annotation) are mapped to a column by index. |
|
static boolean |
allFieldsIndexBasedForWriting(Class<?> beanClass)
Runs through all annotations of a given class to identify whether all annotated fields and methods (with the Parsed annotation) are mapped to a column by index. |
|
static boolean |
allFieldsNameBasedForParsing(Class<?> beanClass)
Runs through all annotations of a given class to identify whether all annotated fields and methods (with the Parsed annotation) are mapped to a column by name. |
|
static boolean |
allFieldsNameBasedForWriting(Class<?> beanClass)
Runs through all annotations of a given class to identify whether all annotated fields and methods (with the Parsed annotation) are mapped to a column by name. |
|
static void |
applyFormatSettings(Object formatter,
String[] propertiesAndValues)
Applied the configuration of a formatter object ( SimpleDateFormat, NumberFormat and others). |
|
static String[] |
deriveHeaderNamesFromFields(Class<?> beanClass,
MethodFilter filter)
Runs through all Parsed annotations of a given class to identify all header names associated with its fields |
|
static List<Annotation> |
findAllAnnotationsInPackage(AnnotatedElement annotatedElement,
Package aPackage)
Returns all annotations applied to an element, excluding the ones not in a given package. |
|
static
|
findAnnotation(AnnotatedElement annotatedElement,
Class<A> annotationType)
Searches for an annotation of a given type that's been applied to an element either directly (as a regular annotation) or indirectly (as a meta-annotations, i.e. |
|
static Headers |
findHeadersAnnotation(Class<?> beanClass)
Searches for the Headers annotation in the hierarchy of a class |
|
static Map<Field,PropertyWrapper> |
getAllFields(Class<?> beanClass)
Returns all fields available from a given class. |
|
static List<Method> |
getAnnotatedMethods(Class<?> beanClass,
MethodFilter filter)
Returns all methods available from a given class that have an annotation. |
|
static Conversion |
getConversion(AnnotatedElement target,
Annotation annotation)
Identifies the proper conversion for a given Field and an annotation from the package com.univocity.parsers.annotations |
|
static Conversion |
getConversion(Class classType,
Annotation annotation)
Identifies the proper conversion for a given type and an annotation from the package com.univocity.parsers.annotations |
|
static Class<?> |
getDeclaringClass(AnnotatedElement element)
|
|
static Conversion |
getDefaultConversion(AnnotatedElement target)
Returns the default Conversion that should be applied to the field based on its type. |
|
static Conversion |
getDefaultConversion(Class fieldType,
Parsed parsed)
Identifies the proper conversion for a given type |
|
static Object |
getDefaultPrimitiveValue(Class type)
Returns Java's default value for a given type, in a primitive type wrapper. |
|
static List<TransformedHeader> |
getFieldSequence(Class beanClass,
boolean processNested,
HeaderTransformer transformer,
MethodFilter filter)
Returns a list of fields with Parsed annotations in the sequence they should be processed for parsing
or writing. |
|
static String |
getName(AnnotatedElement element)
|
|
static Integer[] |
getSelectedIndexes(Class<?> beanClass,
MethodFilter filter)
Runs through all Parsed annotations of a given class to identify all indexes associated with its fields |
|
static Class<?> |
getType(AnnotatedElement element)
|
|
static
|
newInstance(Class parent,
Class<T> type,
String[] args)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Conversion getConversion(AnnotatedElement target,
Annotation annotation)
com.univocity.parsers.annotations
target - The field or method to have conversions applied toannotation - the annotation from com.univocity.parsers.annotations that identifies a Conversion instance.
Conversion that should be applied to the field
public static Conversion getConversion(Class classType,
Annotation annotation)
com.univocity.parsers.annotations
classType - the type to have conversions applied toannotation - the annotation from com.univocity.parsers.annotations that identifies a Conversion instance.
Conversion that should be applied to the type
public static <T> T newInstance(Class parent,
Class<T> type,
String[] args)
public static Conversion getDefaultConversion(Class fieldType,
Parsed parsed)
fieldType - The type of field to have conversions applied to.parsed - the Parsed annotation from com.univocity.parsers.annotations.
Conversion that should be applied to the field typepublic static Conversion getDefaultConversion(AnnotatedElement target)
Conversion that should be applied to the field based on its type.
target - The field or method whose values must be converted from a given parsed String.
Conversion applied to the given field.
public static void applyFormatSettings(Object formatter,
String[] propertiesAndValues)
SimpleDateFormat, NumberFormat and others).
formatter - the formatter instancepropertiesAndValues - a sequence of key-value pairs, where the key is a property of the formatter
object to be set to the following value via reflectionpublic static boolean allFieldsIndexBasedForParsing(Class<?> beanClass)
Parsed annotation) are mapped to a column by index.
beanClass - a class whose Parsed annotations will be processed.
true if every field and method annotated with Parsed in the given class maps to an index, otherwise false.public static boolean allFieldsNameBasedForParsing(Class<?> beanClass)
Parsed annotation) are mapped to a column by name.
beanClass - a class whose Parsed annotations will be processed.
true if every field and method annotated with Parsed in the given class maps to a header name, otherwise false.public static boolean allFieldsIndexBasedForWriting(Class<?> beanClass)
Parsed annotation) are mapped to a column by index.
beanClass - a class whose Parsed annotations will be processed.
true if every field and method annotated with Parsed in the given class maps to an index, otherwise false.public static boolean allFieldsNameBasedForWriting(Class<?> beanClass)
Parsed annotation) are mapped to a column by name.
beanClass - a class whose Parsed annotations will be processed.
true if every field and method annotated with Parsed in the given class maps to a header name, otherwise false.
public static Integer[] getSelectedIndexes(Class<?> beanClass,
MethodFilter filter)
Parsed annotations of a given class to identify all indexes associated with its fields
beanClass - a class whose Parsed annotations will be processed.filter - filter to apply over annotated methods when the class is being used for reading data from beans (to write values to an output)
or when writing values into beans (while parsing). It is used to choose either a "get" or a "set"
method annotated with Parsed, when both methods target the same field.
public static String[] deriveHeaderNamesFromFields(Class<?> beanClass,
MethodFilter filter)
Parsed annotations of a given class to identify all header names associated with its fields
beanClass - a class whose Parsed annotations will be processed.filter - a filter to exclude annotated methods that won't be used for parsing or writing
public static Headers findHeadersAnnotation(Class<?> beanClass)
Headers annotation in the hierarchy of a class
beanClass - the class whose hierarchy will be searched
Headers annotation of the given class or its most immediate parent, or null if not found.public static Class<?> getType(AnnotatedElement element)
public static Class<?> getDeclaringClass(AnnotatedElement element)
public static String getName(AnnotatedElement element)
public static List<TransformedHeader> getFieldSequence(Class beanClass,
boolean processNested,
HeaderTransformer transformer,
MethodFilter filter)
Parsed annotations in the sequence they should be processed for parsing
or writing. The sequence is ordered taking into account their original order in the annotated class, unless
Parsed.index() is set to a non-negative number.
beanClass - the class whose field sequence will be returned.processNested - flag indicating whether Nested annotations should be processedtransformer - a HeaderTransformer instance to be used for transforming headers of a given Nested attribute.filter - filter to apply over annotated methods when the class is being used for reading data from beans (to write values to an output)
or when writing values into beans (while parsing). It is used to choose either a "get" or a "set"
method annotated with Parsed, when both methods target the same field.
public static Map<Field,PropertyWrapper> getAllFields(Class<?> beanClass)
beanClass - a class whose fields will be returned.
Field and the corresponding PropertyWrapper
public static List<Method> getAnnotatedMethods(Class<?> beanClass,
MethodFilter filter)
beanClass - a class whose methods will be returned.filter - filter to apply over annotated methods when the class is being used for reading data from beans (to write values to an output)
or when writing values into beans (while parsing). It is used to choose either a "get" or a "set"
method annotated with Parsed, when both methods target the same field.
Method and the corresponding PropertyWrapper
public static <A extends Annotation> A findAnnotation(AnnotatedElement annotatedElement,
Class<A> annotationType)
A - the type of the annotation being searched forannotatedElement - the element whose annotations will be searchedannotationType - the type of annotation to search for
null if not found.
public static List<Annotation> findAllAnnotationsInPackage(AnnotatedElement annotatedElement,
Package aPackage)
annotatedElement - the element (method, field, etc) whose annotations will be extractedaPackage - the package of the annotations that should be returned
public static final Object getDefaultPrimitiveValue(Class type)
type - the primitive type whose default value will be returned.
null if the type is not primitive.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||