com.apama.correlator.memstore
Class DefaultRowKeyValueConverter<K,V>

java.lang.Object
  extended by com.apama.correlator.memstore.DefaultRowKeyValueConverter<K,V>
Type Parameters:
K - The type parameter used by the table for keys - typically String or Object
V - The type parameter used by the table for values - typically RowValue or Object
All Implemented Interfaces:
RowKeyValueConverter<K,V>

public class DefaultRowKeyValueConverter<K,V>
extends java.lang.Object
implements RowKeyValueConverter<K,V>

Helper class for implementing RowKeyValueConverter using String for the keys and RowValue for the values.

This class may be a useful starting point for creating converter subclasses that use an application-specific class for row values, but still use String for keys. It could also be used by a table class with Object,Object generic type parameters where some table instances need to use application-specific converter classes, but others will consist entirely of String,RowValue pairs and should use this default converter instead. ConcurrentMapAdapter subclasses that do not use any application-specific key/value types do not need this class.

Note that although the generic K,V type parameters of this class are unbound (so it can be used in Object,Object tables as well as String,RowValue tables), the default implementation of each method assumes that all keys are of String type and values are of the RowValue type so errors will be raised if an unmodified instance of this class is used in a table that contains application-specific K,V classes.


Constructor Summary
DefaultRowKeyValueConverter()
           
 
Method Summary
 V fromRowValue(RowValue o)
          Converts a RowValue object to the custom application-specific object that should be used for values in this table.
 K fromStringKey(java.lang.String o)
          Converts a string to the application-specific object that should be used for keys in this table.
 RowValue toRowValue(V o)
          Converts an application-specific row value object to a RowValue.
 java.lang.String toStringKey(K o)
          Converts an application-specific key object to a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRowKeyValueConverter

public DefaultRowKeyValueConverter()
Method Detail

fromRowValue

public V fromRowValue(RowValue o)
Description copied from interface: RowKeyValueConverter
Converts a RowValue object to the custom application-specific object that should be used for values in this table.

Specified by:
fromRowValue in interface RowKeyValueConverter<K,V>
Parameters:
o - the row value to convert
Returns:
must be null if value is null

toRowValue

public RowValue toRowValue(V o)
Description copied from interface: RowKeyValueConverter
Converts an application-specific row value object to a RowValue.

Specified by:
toRowValue in interface RowKeyValueConverter<K,V>
Parameters:
o - the row value to convert
Returns:
must be null if value is null

fromStringKey

public K fromStringKey(java.lang.String o)
Description copied from interface: RowKeyValueConverter
Converts a string to the application-specific object that should be used for keys in this table.

Most maps use String or Object so there is usually nothing to do but a cast.

Specified by:
fromStringKey in interface RowKeyValueConverter<K,V>
Parameters:
o - the string representation of the key
Returns:
application-specific object representing the key

toStringKey

public java.lang.String toStringKey(K o)
Description copied from interface: RowKeyValueConverter
Converts an application-specific key object to a string.

If the map is keyed by strings, this should simply return the argument cast to a String.

Specified by:
toStringKey in interface RowKeyValueConverter<K,V>
Parameters:
o - the key to convert
Returns:
String representation of the key; must return null if input key is null


Submit a bug or feature
Copyright (c) 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG