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.meta;
10:
11: import com.completex.objective.util.PropertyMap;
12:
13: import java.util.LinkedHashMap;
14: import java.util.Map;
15:
16: /**
17: * @author Gennady Krizhevsky
18: */
19: public class MetaDelegateFactory {
20: /*
21: delegateFactory = {
22: className = com.completex.objective.components.persistency.core.impl.CompoundDelegateFactoryImpl
23: delegatePersistentObjects = [ Product Car Sedan ]
24: delegateValues = [ "product" "car" "sedan" ]
25: discriminatorColumnName = "NAME"
26: transformer = NULL
27: }
28: */
29:
30: private String className;
31: private String[] delegatePersistentObjects;
32: private String[] delegateValues;
33: private String discriminatorColumnName;
34: private MetaDelegateTransformer transformer;
35: public static final String TAG_CLASS_NAME = "className";
36: public static final String TAG_DELEGATE_PERSISTENT_OBJECTS = "delegatePersistentObjects";
37: public static final String TAG_DELEGATE_VALUES = "delegateValues";
38: public static final String TAG_DISCRIMINATOR_COLUMN_NAME = "discriminatorColumnName";
39: public static final String TAG_TRANSFORMER = "transformer";
40:
41: public MetaDelegateFactory(Map map) {
42: fromMap(map);
43: }
44:
45: public String getClassName() {
46: return className;
47: }
48:
49: public String[] getDelegatePersistentObjects() {
50: return delegatePersistentObjects;
51: }
52:
53: public String[] getDelegateValues() {
54: return delegateValues;
55: }
56:
57: public String getDiscriminatorColumnName() {
58: return discriminatorColumnName;
59: }
60:
61: public MetaDelegateTransformer getTransformer() {
62: return transformer;
63: }
64:
65: public Map toMap() {
66: Map map = new LinkedHashMap();
67: map.put(TAG_CLASS_NAME, className);
68: map.put(TAG_DELEGATE_PERSISTENT_OBJECTS,
69: delegatePersistentObjects);
70: map.put(TAG_DELEGATE_VALUES, delegateValues);
71: map.put(TAG_DISCRIMINATOR_COLUMN_NAME, discriminatorColumnName);
72: map.put(TAG_TRANSFORMER, transformer == null ? null
73: : transformer.toMap());
74: return map;
75: }
76:
77: public void fromMap(Map map) {
78: PropertyMap propertyMap = PropertyMap.toPropertyMap(map);
79: className = propertyMap.getProperty(TAG_CLASS_NAME, true);
80: delegatePersistentObjects = (String[]) propertyMap.getList(
81: TAG_DELEGATE_PERSISTENT_OBJECTS, true).toArray(
82: new String[0]);
83: delegateValues = (String[]) propertyMap.getList(
84: TAG_DELEGATE_VALUES, true).toArray(new String[0]);
85: discriminatorColumnName = propertyMap
86: .getProperty(TAG_DISCRIMINATOR_COLUMN_NAME);
87: Map transformerMap = propertyMap
88: .getPropertyMap(TAG_TRANSFORMER);
89: }
90:
91: }
|