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: AbstractLogicLinkDeclaration.java 3701 2007-03-18 12:24:23Z gbevin $
007: */
008: package com.uwyn.rife.engine;
009:
010: abstract class AbstractLogicLinkDeclaration {
011: private String mSrcExit = null;
012: private String mDestId = 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: private SiteBuilder mSiteBuilder = null;
020:
021: AbstractLogicLinkDeclaration(SiteBuilder siteBuilder,
022: String srcExit, String destId, boolean snapback,
023: boolean cancelInheritance, boolean cancelEmbedding,
024: boolean redirect, boolean cancelContinuations) {
025: assert siteBuilder != null;
026: assert srcExit != null;
027: assert srcExit.length() > 0;
028:
029: mSiteBuilder = siteBuilder;
030: mSrcExit = srcExit;
031: mDestId = destId;
032: mSnapback = snapback;
033: mCancelInheritance = cancelInheritance;
034: mCancelEmbedding = cancelEmbedding;
035: mRedirect = redirect;
036: mCancelContinuations = cancelContinuations;
037: }
038:
039: SiteBuilder getSiteBuilder() {
040: return mSiteBuilder;
041: }
042:
043: String getSrcExit() {
044: return mSrcExit;
045: }
046:
047: void makeAbsoluteDestId(SiteBuilder builder) {
048: if (mDestId != null) {
049: mDestId = builder.makeAbsoluteElementId(mDestId);
050: mDestId = Site.getCanonicalId(mDestId);
051: }
052: }
053:
054: String getDestId() {
055: return mDestId;
056: }
057:
058: boolean isSnapback() {
059: return mSnapback;
060: }
061:
062: boolean cancelInheritance() {
063: return mCancelInheritance;
064: }
065:
066: boolean cancelEmbedding() {
067: return mCancelEmbedding;
068: }
069:
070: boolean isRedirect() {
071: return mRedirect;
072: }
073:
074: boolean cancelContinuations() {
075: return mCancelContinuations;
076: }
077:
078: public int hashCode() {
079: int srcexit = 1;
080: int destid = 1;
081: int snapback = 1;
082: int cancelinheritance = 1;
083: int cancelembedded = 1;
084: int redirect = 1;
085: int cancelcontinuations = 1;
086:
087: if (mSrcExit != null) {
088: srcexit = mSrcExit.hashCode();
089: }
090: if (mDestId != null) {
091: destid = mDestId.hashCode();
092: }
093: if (mSnapback) {
094: snapback = 2;
095: }
096: if (mCancelInheritance) {
097: cancelinheritance = 2;
098: }
099: if (mCancelEmbedding) {
100: cancelembedded = 2;
101: }
102: if (mRedirect) {
103: redirect = 2;
104: }
105: if (mCancelContinuations) {
106: cancelcontinuations = 2;
107: }
108:
109: return srcexit * destid * snapback * cancelinheritance
110: * cancelembedded * redirect * cancelcontinuations;
111: }
112:
113: public boolean equals(Object other) {
114: if (this == other) {
115: return true;
116: }
117:
118: if (null == other) {
119: return false;
120: }
121:
122: if (!(other instanceof AbstractLogicLinkDeclaration)) {
123: return false;
124: }
125:
126: AbstractLogicLinkDeclaration other_logiclink = (AbstractLogicLinkDeclaration) other;
127: if (other_logiclink.getSrcExit() != null
128: || getSrcExit() != null) {
129: if (null == other_logiclink.getSrcExit()
130: || null == getSrcExit()) {
131: return false;
132: } else if (!other_logiclink.getSrcExit().equals(
133: getSrcExit())) {
134: return false;
135: }
136: }
137: if (!other_logiclink.getDestId().equals(getDestId())) {
138: return false;
139: }
140: if (other_logiclink.isSnapback() != isSnapback()) {
141: return false;
142: }
143: if (other_logiclink.cancelInheritance() != cancelInheritance()) {
144: return false;
145: }
146: if (other_logiclink.cancelEmbedding() != cancelEmbedding()) {
147: return false;
148: }
149: if (other_logiclink.isRedirect() != isRedirect()) {
150: return false;
151: }
152:
153: return true;
154: }
155: }
|