org.apache.openjpa.persistence
Class JPAProperties

java.lang.Object
  extended by org.apache.openjpa.persistence.JPAProperties

public class JPAProperties
extends Object

Enumerates configuration property keys defined in JPA 2.0 Specification.
Provides static utility functions to read their values from supplied map of properties.
Provides static utility functions to convert them to values that are fit for OpenJPA implementation.

Since:
2.0.0
Author:
Pinaki Poddar

Field Summary
static String CACHE_MODE
           
static String CACHE_RETRIEVE_MODE
           
static String CACHE_STORE_MODE
           
static String DATASOURCE
           
static String DATASOURCE_JTA
           
static String DATASOURCE_NONJTA
           
static String JDBC_DRIVER
           
static String JDBC_PASSWORD
           
static String JDBC_URL
           
static String JDBC_USER
           
static String LOCK_SCOPE
           
static String LOCK_TIMEOUT
           
static String PREFIX
           
static String PROVIDER
           
static String QUERY_TIMEOUT
           
static String TRANSACTION_TYPE
           
static String VALIDATE_FACTORY
           
static String VALIDATE_GROUP_DEFAULT
           
static String VALIDATE_MODE
           
static String VALIDATE_PRE_PERSIST
           
static String VALIDATE_PRE_REMOVE
           
static String VALIDATE_PRE_UPDATE
           
 
Constructor Summary
JPAProperties()
           
 
Method Summary
static
<T> T
convertToKernelValue(Class<T> resultType, String key, Object value)
          Convert the given user value to a value consumable by OpenJPA kernel constructs.
static Object convertToUserValue(String key, Object value)
          Convert the given kernel value to a value visible to the user.
static String getBeanProperty(String key)
          Gets a bean-style property name from the given key.
static
<E extends Enum<E>>
E
getEnumValue(Class<E> type, E[] values, Object val)
          Gets a enum value of the given type from the given value.
static
<E extends Enum<E>>
E
getEnumValue(Class<E> type, E[] values, String key, Map<String,Object> prop)
          Gets a enum value of the given type from the given properties looking up with the given key.
static
<E extends Enum<E>>
E
getEnumValue(Class<E> type, Object val)
          Gets a enum value of the given type from the given value.
static
<E extends Enum<E>>
E
getEnumValue(Class<E> type, String key, Map<String,Object> prop)
          Get the value of the given key from the given properties after converting it to the given enumerated value.
(package private) static String getUserName(String beanProperty)
          Gets the original JPA Property name corresponding to the kernel property key (which is a bean property name without any suffix).
static boolean isValidKey(String key)
          Is the given key appears to be a valid JPA specification defined key?
(package private) static void record(String kernel, String user)
          Record the given kernel property key (which is a bean property name without any suffix) corresponding to the given original JPA/OpenJPA property used by the user to set the values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

public static final String PREFIX
See Also:
Constant Field Values

PROVIDER

public static final String PROVIDER
See Also:
Constant Field Values

TRANSACTION_TYPE

public static final String TRANSACTION_TYPE
See Also:
Constant Field Values

DATASOURCE

public static final String DATASOURCE
See Also:
Constant Field Values

DATASOURCE_JTA

public static final String DATASOURCE_JTA
See Also:
Constant Field Values

DATASOURCE_NONJTA

public static final String DATASOURCE_NONJTA
See Also:
Constant Field Values

JDBC_DRIVER

public static final String JDBC_DRIVER
See Also:
Constant Field Values

JDBC_URL

public static final String JDBC_URL
See Also:
Constant Field Values

JDBC_USER

public static final String JDBC_USER
See Also:
Constant Field Values

JDBC_PASSWORD

public static final String JDBC_PASSWORD
See Also:
Constant Field Values

LOCK_SCOPE

public static final String LOCK_SCOPE
See Also:
Constant Field Values

LOCK_TIMEOUT

public static final String LOCK_TIMEOUT
See Also:
Constant Field Values

QUERY_TIMEOUT

public static final String QUERY_TIMEOUT
See Also:
Constant Field Values

CACHE_MODE

public static final String CACHE_MODE
See Also:
Constant Field Values

CACHE_STORE_MODE

public static final String CACHE_STORE_MODE
See Also:
Constant Field Values

CACHE_RETRIEVE_MODE

public static final String CACHE_RETRIEVE_MODE
See Also:
Constant Field Values

VALIDATE_FACTORY

public static final String VALIDATE_FACTORY
See Also:
Constant Field Values

VALIDATE_MODE

public static final String VALIDATE_MODE
See Also:
Constant Field Values

VALIDATE_PRE_PERSIST

public static final String VALIDATE_PRE_PERSIST
See Also:
Constant Field Values

VALIDATE_PRE_REMOVE

public static final String VALIDATE_PRE_REMOVE
See Also:
Constant Field Values

VALIDATE_PRE_UPDATE

public static final String VALIDATE_PRE_UPDATE
See Also:
Constant Field Values

VALIDATE_GROUP_DEFAULT

public static final String VALIDATE_GROUP_DEFAULT
See Also:
Constant Field Values
Constructor Detail

JPAProperties

public JPAProperties()
Method Detail

record

static void record(String kernel,
                   String user)
Record the given kernel property key (which is a bean property name without any suffix) corresponding to the given original JPA/OpenJPA property used by the user to set the values.


getUserName

static String getUserName(String beanProperty)
Gets the original JPA Property name corresponding to the kernel property key (which is a bean property name without any suffix).


isValidKey

public static boolean isValidKey(String key)
Is the given key appears to be a valid JPA specification defined key?

Returns:
true if the given string merely prefixed with javax.persistence.. Does not really check all the keys defined in the specification.

getBeanProperty

public static String getBeanProperty(String key)
Gets a bean-style property name from the given key.

Parameters:
key - must begin with JPA property prefix javax.persistence
Returns:
concatenates each part of the string leaving out javax.persistence. prefix. Part of string is what appears between DOT character.

convertToKernelValue

public static <T> T convertToKernelValue(Class<T> resultType,
                                         String key,
                                         Object value)
Convert the given user value to a value consumable by OpenJPA kernel constructs.

Returns:
the same value if the given key is not a valid JPA property key or the value is null.

convertToUserValue

public static Object convertToUserValue(String key,
                                        Object value)
Convert the given kernel value to a value visible to the user.

Returns:
the same value if the given key is not a valid JPA property key or the value is null.

getEnumValue

public static <E extends Enum<E>> E getEnumValue(Class<E> type,
                                                 String key,
                                                 Map<String,Object> prop)
Get the value of the given key from the given properties after converting it to the given enumerated value.


getEnumValue

public static <E extends Enum<E>> E getEnumValue(Class<E> type,
                                                 E[] values,
                                                 String key,
                                                 Map<String,Object> prop)
Gets a enum value of the given type from the given properties looking up with the given key. Converts the original value from a String or ordinal number, if necessary. Conversion from an integral number to enum value is only attempted if the allowed enum values are provided as non-null, non-empty array.

Returns:
null if the key does not exist in the given properties.

getEnumValue

public static <E extends Enum<E>> E getEnumValue(Class<E> type,
                                                 Object val)
Gets a enum value of the given type from the given value. Converts the original value from a String, if necessary.

Returns:
null if the key does not exist in the given properties.

getEnumValue

public static <E extends Enum<E>> E getEnumValue(Class<E> type,
                                                 E[] values,
                                                 Object val)
Gets a enum value of the given type from the given value. Converts the original value from a String or ordinal number, if necessary. Conversion from an integral number to enum value is only attempted if the allowed enum values are provided as non-null, non-empty array.

Returns:
null if the key does not exist in the given properties.


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.