com.ca.jcs.converter.meta
Class NullValueClassConverter
java.lang.Object
com.ca.jcs.cfg.Vetoable
com.ca.jcs.converter.meta.ClassConverter
com.ca.jcs.converter.meta.NullValueClassConverter
- Direct Known Subclasses:
- NullValueClassConverter
public class NullValueClassConverter
- extends ClassConverter
ClassConverter that handles providing a configured "nullValue" for all marked attributes
when no explicit value is provided for them. This is particularly useful in the case of mapping
to a DB table where all string columns are fixed width
and are required to be not null. So setting the value of each such column to a single space is considered
to be a "nullValue".
To make use of this Converter make the following changes to the metadata of each attribute that
should behave this way.
- Set "isRequired" to "false".
- Add a new boolean metadata "useSpecialNullValue" with value "true".
- Add an entry into your class plugin config of your connector.xml (this is already
done in the bundled jdbc connector). Change the nullValue in the config
bean, if a single space doesn't suit your need.
<property name="classPluginConfigs">
<list>
<bean class="com.ca.jcs.cfg.MetaPluginConfig">
<property name="pluginClass">
<value>com.ca.jcs.converter.meta.NullValueClassConverter</value>
</property>
<property name="pluginConfig">
<bean class="com.ca.jcs.converter.meta.NullValueClassConverter$NullValueConverterConfig">
<property name="nullValue">
<value> </value>
</property>
</bean>
</property>
<property name="metadataPropNames">
<list>
<value>useSpecialNullValue</value>
</list>
</property>
</bean>
</list>
</property>
|
Method Summary |
void |
convertFromConnector(Attributes attrs)
Find any a "nullValue"s on metadata-flagged attributes coming back from the database
and remove the attribute. |
void |
convertToConnector(Attributes attrs)
Change any empty or null metadata-flagged attribute values into the specified "nullValue" so that
the endpoint database can handle storing the attribute. |
ModificationItem[] |
convertToConnector(ModificationItem[] modItems)
Change any empty or null metadata-flagged attribute values into the specified "nullValue" so that
the endpoint database can handle storing the attribute. |
boolean |
isStructural()
Returns true if the converter performs a change to the structure of an attribute's values, rather then just transforming individual values themselves. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NullValueClassConverter
public NullValueClassConverter(NullValueClassConverter.NullValueConverterConfig config,
MetaObjectClassMapping classMap)
isStructural
public boolean isStructural()
- Description copied from class:
ClassConverter
- Returns true if the converter performs a change to the structure of an attribute's values, rather then just transforming individual values themselves.
For instance changing Attributes representations into an alternative representation such as JSON is an example of a structural conversion.
- Specified by:
isStructural in class ClassConverter
convertFromConnector
public void convertFromConnector(Attributes attrs)
throws NamingException
- Find any a "nullValue"s on metadata-flagged attributes coming back from the database
and remove the attribute. Also trim the value on this attributes coming back from the
database.
- Specified by:
convertFromConnector in class ClassConverter
- Throws:
NamingException
convertToConnector
public void convertToConnector(Attributes attrs)
throws NamingException
- Change any empty or null metadata-flagged attribute values into the specified "nullValue" so that
the endpoint database can handle storing the attribute.
- Specified by:
convertToConnector in class ClassConverter
- Throws:
NamingException
convertToConnector
public ModificationItem[] convertToConnector(ModificationItem[] modItems)
throws NamingException
- Change any empty or null metadata-flagged attribute values into the specified "nullValue" so that
the endpoint database can handle storing the attribute.
- Specified by:
convertToConnector in class ClassConverter
- Throws:
NamingException
Created 2011-07-14 13:27 EST