01: package com.completex.objective.components.persistency.ocache.impl;
02:
03: import com.completex.objective.components.ocache.OdalKeyFactory;
04: import com.completex.objective.components.persistency.key.impl.SimpleNaturalKeyFactoryImpl;
05: import com.completex.objective.components.persistency.PersistentObject;
06: import com.completex.objective.util.StringUtil;
07:
08: /**
09: * Creates key out of PersistentObject instance by set of column indices
10: *
11: * @author Gennady Krizhevsky
12: */
13: public class PoStringSimpleKeyFactory extends PoSimpleKeyFactory {
14:
15: private String prefix = "";
16:
17: public PoStringSimpleKeyFactory(int[] keyIndeces) {
18: super (keyIndeces);
19: }
20:
21: public PoStringSimpleKeyFactory(int[] keyIndeces, String prefix) {
22: super (keyIndeces);
23: setPrefix(prefix);
24: }
25:
26: /**
27: * Returns Stringified key
28: *
29: * @see PoSimpleKeyFactory#key(Object)
30: * @param value PersistentObject object
31: * @return Stringified key
32: */
33: public Object key(Object value) {
34: return prefix + StringUtil.toString(super .key(value));
35: }
36:
37: /**
38: * @param prefix Prefix that is prepended to all keys. if it is null then nothig gets prepended.
39: */
40: public void setPrefix(String prefix) {
41: if (prefix != null) {
42: this .prefix = prefix;
43: }
44: }
45:
46: /**
47: * Returns Prefix that is prepended to all keys. if it is null then nothig gets prepended.
48: *
49: * @return Prefix that is prepended to all keys. if it is null then nothig gets prepended.
50: */
51: public String getPrefix() {
52: return prefix;
53: }
54:
55: }
|