1 16 package org.springframework.webflow.engine; 17 18 import java.io.Serializable ; 19 20 import org.springframework.core.style.ToStringCreator; 21 import org.springframework.util.Assert; 22 import org.springframework.webflow.execution.RequestContext; 23 import org.springframework.webflow.execution.ScopeType; 24 25 32 public abstract class FlowVariable extends AnnotatedObject implements Serializable { 33 34 37 private String name; 38 39 42 private ScopeType scope; 43 44 49 public FlowVariable(String name, ScopeType scope) { 50 Assert.hasText(name, "The variable name is required"); 51 Assert.notNull(scope, "The variable scope type is required"); 52 this.name = name; 53 this.scope = scope; 54 } 55 56 59 public String getName() { 60 return name; 61 } 62 63 66 public ScopeType getScope() { 67 return scope; 68 } 69 70 72 public boolean equals(Object o) { 73 if (!(o instanceof FlowVariable)) { 74 return false; 75 } 76 FlowVariable other = (FlowVariable)o; 77 return name.equals(other.name) && scope.equals(other.scope); 78 } 79 80 public int hashCode() { 81 return name.hashCode() + scope.hashCode(); 82 } 83 84 88 public final void create(RequestContext context) { 89 scope.getScope(context).put(name, createVariableValue(context)); 90 } 91 92 99 protected abstract Object createVariableValue(RequestContext context); 100 101 public String toString() { 102 return new ToStringCreator(this).append("name", name).append("scope", scope).toString(); 103 } 104 } | Popular Tags |