01: /*
02: * JBoss, Home of Professional Open Source
03: * Copyright 2005, JBoss Inc., and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jbpm.context.exe;
23:
24: import java.io.Serializable;
25: import java.util.Map;
26:
27: import org.jbpm.graph.exe.Token;
28:
29: /**
30: * is a jbpm-internal map of variableInstances related to one {@link Token}.
31: * Each token has it's own map of variableInstances, thereby creating
32: * hierarchy and scoping of process variableInstances.
33: */
34: public class TokenVariableMap extends VariableContainer implements
35: Serializable {
36:
37: private static final long serialVersionUID = 1L;
38:
39: long id = 0;
40: int version = 0;
41: protected Token token = null;
42: protected ContextInstance contextInstance = null;
43:
44: public TokenVariableMap() {
45: }
46:
47: public TokenVariableMap(Token token, ContextInstance contextInstance) {
48: this .token = token;
49: this .contextInstance = contextInstance;
50: }
51:
52: public void addVariableInstance(VariableInstance variableInstance) {
53: super .addVariableInstance(variableInstance);
54: variableInstance.setTokenVariableMap(this );
55: }
56:
57: public String toString() {
58: return "TokenVariableMap"
59: + ((token != null) && (token.getName() != null) ? "["
60: + token.getName() + "]" : Integer
61: .toHexString(System.identityHashCode(this )));
62: }
63:
64: // protected ////////////////////////////////////////////////////////////////
65:
66: protected VariableContainer getParentVariableContainer() {
67: Token parentToken = token.getParent();
68: if (parentToken == null) {
69: return null;
70: }
71: return contextInstance.getTokenVariableMap(parentToken);
72: }
73:
74: // getters and setters //////////////////////////////////////////////////////
75:
76: public ContextInstance getContextInstance() {
77: return contextInstance;
78: }
79:
80: public Token getToken() {
81: return token;
82: }
83:
84: public Map getVariableInstances() {
85: return variableInstances;
86: }
87:
88: // private static final Log log = LogFactory.getLog(TokenVariableMap.class);
89: }
|