01: package org.jacorb.orb.portableInterceptor;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1999-2004 Gerald Brose
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Library General Public License for more details.
17: *
18: * You should have received a copy of the GNU Library General Public
19: * License along with this library; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: import org.omg.PortableInterceptor.Interceptor;
25:
26: /**
27: * This class is an iterator over an array
28: * of RequestInterceptors.
29: *
30: * @author Nicolas Noffke
31: * @version $Id: RequestInterceptorIterator.java,v 1.9 2006/07/14 12:02:41 nick.cross Exp $
32: */
33:
34: public abstract class RequestInterceptorIterator extends
35: AbstractInterceptorIterator {
36: private boolean reversed = false;
37: private boolean forward = true;
38:
39: protected short op = -1;
40: protected Exception interceptor_ex = null;
41:
42: public RequestInterceptorIterator(Interceptor[] interceptors) {
43: super (interceptors);
44: }
45:
46: /**
47: * Reverses the direction in which the list is traversed.
48: * The element returned by the next call to nextElement()
49: * is the one previous to that returned by the last
50: * call to nextElement(). <br>
51: * The direction can only be reversed one time and only if
52: * the starting direction was "forward".
53: */
54:
55: protected void reverseDirection() {
56: if (!reversed && forward) {
57: increment *= -1;
58: index += (2 * increment);
59:
60: reversed = true;
61: }
62: }
63:
64: protected void setDirection(boolean forward) {
65: this .forward = forward;
66:
67: if (forward) {
68: index = 0;
69: increment = 1;
70: } else {
71: index = interceptors.length - 1;
72: increment = -1;
73: }
74: }
75: } // RequestInterceptorIterator
|