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.components.ocache.OdalKeyFactory;
12: import com.completex.objective.components.persistency.PersistentObject;
13: import com.completex.objective.components.persistency.key.impl.SimpleNaturalKeyFactoryImpl;
14:
15: /**
16: * Creates key out of PersistentObject instance by set of column indices
17: *
18: * @author Gennady Krizhevsky
19: */
20: public class PoSimpleKeyFactory implements OdalKeyFactory {
21:
22: private int[] keyIndeces;
23:
24: private SimpleNaturalKeyFactoryImpl simpleNaturalKeyFactory = new SimpleNaturalKeyFactoryImpl();
25:
26: public PoSimpleKeyFactory(int[] keyIndeces) {
27: this .keyIndeces = keyIndeces;
28: }
29:
30: /**
31: * Returns SimpleNaturalKey created out of the value object.
32: *
33: * @see com.completex.objective.components.persistency.key.SimpleNaturalKey
34: * @param value PersistentObject object
35: * @return SimpleNaturalKey created out of the value object
36: */
37: public Object key(Object value) {
38: if (value == null) {
39: return null;
40: }
41: PersistentObject persistent = (PersistentObject) value;
42: return simpleNaturalKeyFactory.newSimpleNaturalKey(persistent,
43: keyIndeces);
44: }
45: }
|