001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: FlowLink.java 3701 2007-03-18 12:24:23Z gbevin $
007: */
008: package com.uwyn.rife.engine;
009:
010: public class FlowLink {
011: private String mExit = null;
012: private ElementInfo mTarget = null;
013: private boolean mSnapback = false;
014: private boolean mCancelInheritance = false;
015: private boolean mCancelEmbedding = false;
016: private boolean mRedirect = false;
017: private boolean mCancelContinuations = false;
018:
019: FlowLink(String exit, ElementInfo target, boolean snapback,
020: boolean cancelInheritance, boolean cancelEmbedding,
021: boolean redirect, boolean cancelContinuations) {
022: assert exit != null;
023: assert exit.length() > 0;
024: assert target != null || snapback;
025: assert null == target || !snapback;
026:
027: mExit = exit;
028: mTarget = target;
029: mSnapback = snapback;
030: mCancelInheritance = cancelInheritance;
031: mCancelEmbedding = cancelEmbedding;
032: mRedirect = redirect;
033: mCancelContinuations = cancelContinuations;
034: }
035:
036: public String getExitName() {
037: return mExit;
038: }
039:
040: public ElementInfo getExitTarget(RequestState state) {
041: if (mSnapback) {
042: return state.getSnapback();
043: }
044:
045: return mTarget;
046: }
047:
048: public ElementInfo getTarget() {
049: return mTarget;
050: }
051:
052: public boolean isSnapback() {
053: return mSnapback;
054: }
055:
056: public boolean cancelInheritance() {
057: return mCancelInheritance;
058: }
059:
060: public boolean cancelEmbedding() {
061: return mCancelEmbedding;
062: }
063:
064: public boolean isRedirect() {
065: return mRedirect;
066: }
067:
068: public boolean cancelContinuations() {
069: return mCancelContinuations;
070: }
071:
072: public int hashCode() {
073: int target = 1;
074: int snapback = 1;
075: int cancel_inheritance = 1;
076: int cancel_embedding = 1;
077: int redirect = 1;
078: int cancel_continuations = 1;
079:
080: if (mTarget != null) {
081: target = mTarget.hashCode();
082: }
083: if (mSnapback) {
084: snapback = 2;
085: }
086: if (mCancelInheritance) {
087: cancel_inheritance = 2;
088: }
089: if (mCancelEmbedding) {
090: cancel_embedding = 2;
091: }
092: if (mRedirect) {
093: redirect = 2;
094: }
095: if (mCancelContinuations) {
096: cancel_continuations = 2;
097: }
098: return mExit.hashCode() * target * snapback
099: * cancel_inheritance * cancel_embedding * redirect
100: * cancel_continuations;
101: }
102:
103: public boolean equals(Object other) {
104: if (this == other) {
105: return true;
106: }
107:
108: if (null == other) {
109: return false;
110: }
111:
112: if (!(other instanceof FlowLink)) {
113: return false;
114: }
115:
116: FlowLink other_flowlink = (FlowLink) other;
117: if (!other_flowlink.getExitName().equals(getExitName())) {
118: return false;
119: }
120: if (!other_flowlink.getTarget().equals(getTarget())) {
121: return false;
122: }
123: if (other_flowlink.isSnapback() != isSnapback()) {
124: return false;
125: }
126: if (other_flowlink.cancelInheritance() != cancelInheritance()) {
127: return false;
128: }
129: if (other_flowlink.cancelEmbedding() != cancelEmbedding()) {
130: return false;
131: }
132: if (other_flowlink.isRedirect() != isRedirect()) {
133: return false;
134: }
135:
136: return true;
137: }
138: }
|