01: package org.jicengine.operation;
02:
03: /**
04: *
05: * <p>
06: * Copyright (C) 2004 Timo Laitinen
07: * </p>
08: * @author Timo Laitinen
09: * @created 2004-09-20
10: * @since JICE-0.10
11: *
12: */
13:
14: public abstract class AbstractContext implements Context {
15:
16: String name;
17:
18: protected AbstractContext() {
19: name = "unknown";
20: }
21:
22: protected AbstractContext(String name) {
23: this .name = name;
24: }
25:
26: public String getName() {
27: return this .name;
28: }
29:
30: public String toString() {
31: return "{" + getName() + "}";
32: }
33:
34: protected static String getName(Context context, String defaultName) {
35: if (context != null && context instanceof AbstractContext) {
36: return ((AbstractContext) context).getName();
37: } else {
38: return defaultName;
39: }
40: }
41:
42: public Context replicate() {
43: java.util.Map objects = new java.util.HashMap();
44: copyObjectsTo(objects);
45: return new SimpleContext(getName(), objects);
46: }
47:
48: protected abstract void copyObjectsTo(java.util.Map map);
49:
50: }
|