01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.completex.objective.components.persistency.ocache.impl;
10:
11: import com.completex.objective.util.StringUtil;
12:
13: /**
14: * Creates string key out of AbstractPersistentObject instance by its toKey() method
15: *
16: * @author Gennady Krizhevsky
17: */
18: public class PoStringKeyFactory extends PoKeyFactory {
19:
20: private String prefix = "";
21:
22: public PoStringKeyFactory() {
23: }
24:
25: /**
26: *
27: * @param prefix Prefix that is prepended to all keys. if it is null then nothig gets prepended.
28: */
29: public PoStringKeyFactory(String prefix) {
30: setPrefix(prefix);
31: }
32:
33: /**
34: * Returns Stringified key
35: *
36: * @see PoKeyFactory#key(Object)
37: * @param value AbstractPersistentObject object
38: * @return Stringified key
39: */
40: public Object key(Object value) {
41: return prefix + StringUtil.toString(super .key(value));
42: }
43:
44: /**
45: * @param prefix Prefix that is prepended to all keys. if it is null then nothig gets prepended.
46: */
47: public void setPrefix(String prefix) {
48: if (prefix != null) {
49: this .prefix = prefix;
50: }
51: }
52:
53: /**
54: * Returns Prefix that is prepended to all keys. if it is null then nothig gets prepended.
55: *
56: * @return Prefix that is prepended to all keys. if it is null then nothig gets prepended.
57: */
58: public String getPrefix() {
59: return prefix;
60: }
61: }
|