Package net.java.ao
Class Common
java.lang.Object
net.java.ao.Common
WARNING: Not part of the public API. This class is public only
to allow its use within other packages in the ActiveObjects library.
- Author:
- Daniel Spiewak
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseQuietly(Connection connection) Deprecated.static voidcloseQuietly(ResultSet resultSet) Deprecated.static voidcloseQuietly(Statement statement) Deprecated.static Stringconvert(FieldNameConverter fnc, String column) static StringconvertDowncaseName(String name) static StringconvertSimpleClassName(String name) static <T extends RawEntity<K>,K>
TcreatePeer(EntityManager manager, Class<T> type, K key) static booleanfuzzyCompare(TypeManager typeManager, Object a, Object b) static booleanfuzzyTypeCompare(int typeA, int typeB) static AnnotationDelegategetAnnotationDelegate(FieldNameConverter converter, Method method) Deprecated.static Class<?>getAttributeTypeFromMethod(Method method) static StringgetCallingClassName(int depth) static String[]getMappingFields(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) Deprecated.static String[]getPolymorphicFieldNames(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) Deprecated.static <K> Class<K>getPrimaryKeyClassType(Class<? extends RawEntity<K>> type) static StringgetPrimaryKeyField(Class<? extends RawEntity<?>> type, FieldNameConverter converter) static <K> TypeInfo<K>getPrimaryKeyType(TypeManager typeManager, Class<? extends RawEntity<K>> type) static <K> KgetPrimaryKeyValue(RawEntity<K> entity) getSearchableFields(EntityManager manager, Class<? extends RawEntity<?>> type) getValueFieldsMethods(Class<? extends RawEntity<?>> entity, FieldNameConverter converter) Gets all the methods of an entity that correspond to a value field.static com.google.common.collect.ImmutableSet<String>getValueFieldsNames(EntityInfo<? extends RawEntity<?>, ?> entityInfo, FieldNameConverter converter) Gets all the names of fields of an entity that correspond to a value field.static booleanisAccessor(Method method) static booleanisAnnotatedAsRelational(Method method) static booleanisAnnotatedMutator(Method method) static booleanstatic booleanisMutatorOrAccessor(Method method) static StringExtracts a part of the string that remains unchanged during shortening process.preloadValue(Preload preload, FieldNameConverter fnc) static StringShortens a string to the given length if necessary.static <K> voidvalidatePrimaryKey(FieldInfo<K> primaryKeyInfo, Object value) static Stringwhere(ManyToMany manyToMany, FieldNameConverter fnc) static Stringwhere(OneToMany oneToMany, FieldNameConverter fnc) static Stringwhere(OneToOne oneToOne, FieldNameConverter fnc)
-
Constructor Details
-
Common
public Common()
-
-
Method Details
-
createPeer
public static <T extends RawEntity<K>,K> T createPeer(EntityManager manager, Class<T> type, K key) throws SQLException - Throws:
SQLException
-
convertSimpleClassName
-
convertDowncaseName
-
getMappingFields
@Deprecated public static String[] getMappingFields(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) Deprecated.- See Also:
-
getPolymorphicFieldNames
@Deprecated public static String[] getPolymorphicFieldNames(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) Deprecated.- See Also:
-
getAnnotationDelegate
@Deprecated public static AnnotationDelegate getAnnotationDelegate(FieldNameConverter converter, Method method) Deprecated.All annotation information should be resolved upfront usingEntityInfoNote: this method leads to the creation and quick discard of large numbers ofAnnotationDelegateobjects. Need to do some research to determine whether or not this is actually a problem. -
isMutator
-
isAnnotatedMutator
-
isAccessor
-
isMutatorOrAccessor
-
isAnnotatedAsRelational
-
getAttributeTypeFromMethod
-
getCallingClassName
-
getSearchableFields
public static List<String> getSearchableFields(EntityManager manager, Class<? extends RawEntity<?>> type) -
getPrimaryKeyField
public static String getPrimaryKeyField(Class<? extends RawEntity<?>> type, FieldNameConverter converter) -
getPrimaryKeyType
public static <K> TypeInfo<K> getPrimaryKeyType(TypeManager typeManager, Class<? extends RawEntity<K>> type) -
getPrimaryKeyClassType
-
getPrimaryKeyValue
-
validatePrimaryKey
-
fuzzyCompare
-
fuzzyTypeCompare
public static boolean fuzzyTypeCompare(int typeA, int typeB) -
getValueFieldsMethods
public static Set<Method> getValueFieldsMethods(Class<? extends RawEntity<?>> entity, FieldNameConverter converter) Gets all the methods of an entity that correspond to a value field. This means fields that are stored as values in the database as opposed to fields (IDs) that define a relationship to another table in the database. Note that the values are retrieved based on the relationship annotations, at the field level, which the user may not have entered.- Parameters:
entity- the entity to look up the methods fromconverter- the field name converter currently in use for entities- Returns:
- the set of method found
-
getValueFieldsNames
public static com.google.common.collect.ImmutableSet<String> getValueFieldsNames(EntityInfo<? extends RawEntity<?>, ?> entityInfo, FieldNameConverter converter) Gets all the names of fields of an entity that correspond to a value field. This means fields that are stored as values in the database as opposed to fields (IDs) that define a relationship to another table in the database.- Parameters:
entityInfo- the entity to look up the methods from- Returns:
- the set of names found
-
preloadValue
-
where
-
where
-
where
-
convert
-
closeQuietly
Deprecated.Closes theResultSetin anullsafe manner and quietly, i.e without throwing nor logging any exception- Parameters:
resultSet- the result set to close
-
closeQuietly
Deprecated.Closes theStatementin anullsafe manner and quietly, i.e without throwing nor logging any exception- Parameters:
statement- the statement to close
-
closeQuietly
Deprecated.Closes theConnectionin anullsafe manner and quietly, i.e without throwing nor logging any exception- Parameters:
connection- the connection to close, can benull
-
shorten
Shortens a string to the given length if necessary. The process of shortening is stable.Strings shorter than length will not be shortened. For longer strings the first
length - length/3 - 1characters remain unchanged. The remaining space is filled with string's lastlength/3hashCode characters.- Parameters:
string- to be shortened.length- to which string will be shortened.- Returns:
- a shortened string.
-
prefix
Extracts a part of the string that remains unchanged during shortening process.For strings shorter than specified length the string itself is returned. For longer strings the first
length - length/3 - 1characters are returned.- Parameters:
string- for which the prefix will be extracted.length- used inshorten(java.lang.String, int)ing process.- Returns:
- part of the string that remains unchanged during shortening process.
- See Also:
-
EntityInfo