001: //
002: // This file is part of the prose package.
003: //
004: // The contents of this file are subject to the Mozilla Public License
005: // Version 1.1 (the "License"); you may not use this file except in
006: // compliance with the License. You may obtain a copy of the License at
007: // http://www.mozilla.org/MPL/
008: //
009: // Software distributed under the License is distributed on an "AS IS" basis,
010: // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: // for the specific language governing rights and limitations under the
012: // License.
013: //
014: // The Original Code is prose.
015: //
016: // The Initial Developer of the Original Code is Andrei Popovici. Portions
017: // created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018: // All Rights Reserved.
019: //
020: // Contributor(s):
021: // $Id: ORingPointCutter.java,v 1.2 2003/07/17 13:11:08 apopovic Exp $
022: // =====================================================================
023: //
024: // (history at end)
025: //
026:
027: package ch.ethz.prose.filter;
028:
029: // used packages
030: import java.util.List;
031: import java.util.Vector;
032: import ch.ethz.jvmai.CodeJoinPoint;
033: import ch.ethz.prose.engine.JoinPointRequest;
034:
035: /**
036: * Class ORingPointCutter composes two sub-PointCuters into a composite
037: * PointCutter using OR semantic.
038: *
039: * @version $Revision: 1.2 $
040: * @author Andrei Popovici
041: */
042:
043: class ORingPointCutter extends PointCutter {
044:
045: private static final long serialVersionUID = 3258134635178637367L;
046: PointCutter spec1;
047: PointCutter spec2;
048:
049: /** Create a composite PointCutter with <code>spec1</code> and <code>spec2</code>
050: * as members, composed using 'OR' semantics.
051: */
052: protected ORingPointCutter(PointCutter spec1, PointCutter spec2) {
053: if (spec1 == null || spec2 == null)
054: throw new IllegalArgumentException(
055: "Null Pointer argument in ANDPointCutter.<init>");
056:
057: this .acceptMask = spec1.acceptMask | spec2.acceptMask;
058: mayFilterStaticallyMask = spec1.mayFilterStaticallyMask
059: | spec2.mayFilterStaticallyMask;
060: canFilterStaticallyMask = spec1.canFilterStaticallyMask
061: & spec2.canFilterStaticallyMask;
062:
063: this .spec1 = spec1;
064: this .spec2 = spec2;
065: }
066:
067: /** Return the two members of this OR PointCutter. */
068: public List memberPointFilters() {
069: Vector result = new Vector();
070: result.add(spec1);
071: result.add(spec2);
072: return result;
073: }
074:
075: /** Retrn true if either of the specializers passed in the crosscut
076: * does static filtering and one of them consider <code>r1</code> as special.
077: *
078: * @return true if either of the sub-specializers agree that r1 is a static
079: * special request.
080: */
081: protected boolean doIsSpecialRequest(JoinPointRequest r1) {
082:
083: // we get here IF AND ONLY IF (spec1.mayFilter | spec2.mayFilter) is fits the r1.mask
084: // in case it 0, then the abstract crosscut specializer has already
085: // said 'yes'.
086: // the following conditions reads as follows:
087: // (if spec1 may filter r1 AND it actually filters it) OR (spec3 may filter ..)
088: return (spec1.isSpecialRequest(r1))
089: || (spec2.isSpecialRequest(r1));
090: }
091:
092: /** Retrn true if either of the memer PointCutters passed in the crosscut
093: * does dynamic filtering and one of them consider <code>e1</code> as special.
094: * undefined.
095: *
096: * @return true if either of the sub-specializers agree that r1 is a dynamic
097: * special event.
098: */
099: protected boolean doIsSpecialEvent(CodeJoinPoint e1) {
100: // we get here IF AND ONLY IF this is an accepted event AND
101: // either of spec1, spec2 cannot filter e1 (spec1.canFilter & spec2.canFilter) & r1.mask == 0
102: // in this case, the following condition reads
103: // as follows: if spec1 can filte said 'yes'.
104: // the following conditions reads as follows:
105: // if spec1 has filtered this event filtered e1 then return true,
106: /// else filter-it with is special event else
107: // if spec2 has filtered this event statically return true else
108: // ask is special event
109: return (spec1.isSpecialEvent(e1)) || (spec2.isSpecialEvent(e1));
110:
111: }
112:
113: public String toString() {
114: return "(" + spec1.toString() + ") OR (" + spec2.toString()
115: + ")";
116: }
117:
118: }
119:
120: //======================================================================
121: //
122: // $Log: ORingPointCutter.java,v $
123: // Revision 1.2 2003/07/17 13:11:08 apopovic
124: // refactorization: from PointFilter.memberSpecializers to PointFilter.memberPointFilters;
125: // improved documentation (removed references to specializers)
126: //
127: // Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
128: // Imported from ETH Zurich
129: //
130: // Revision 1.2 2003/05/06 15:51:41 popovici
131: // Mozilla-ification
132: //
133: // Revision 1.1 2003/05/05 13:57:48 popovici
134: // renaming from runes to prose
135: //
136: // Revision 1.1 2003/04/27 13:08:45 popovici
137: // Specializers renamed to PointCutter
138: //
139: // Revision 1.5 2003/04/17 12:49:35 popovici
140: // Refactoring of the crosscut package
141: // ExceptionCut renamed to ThrowCut
142: // McutSignature is now SignaturePattern
143: //
144: // Revision 1.4 2003/04/17 08:47:50 popovici
145: // Important functionality additions
146: // - Cflow specializers
147: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
148: // - Transactional capabilities
149: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
150: // between static and dynamic specializers.
151: // - Functionality pulled up in abstract classes
152: // - Uniformization of advice methods patterns and names
153: //
154: // Revision 1.3 2003/03/04 18:24:14 popovici
155: // Refactoring of the specializer. De-obfuscation
156: // by exposing the inner classes of the factory methods
157: // The specializer implementations now end in 'filter',
158: // whereas the old factory methods 'xxxS' remain
159: // pure bootstrap objects.
160: //
161: // Revision 1.2 2003/03/04 11:27:23 popovici
162: // Important refactorization step (march):
163: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
164: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
165: // structures
166: //
167: // Revision 1.1 2002/05/07 10:46:59 popovici
168: // Reorganization of the Specializer package. All specializer related classes
169: // moved to ch.ethz.inf.crossucut.spec; Classes ORingPointCutter, ANDspecializer and NOTspecializer is
170: // introduced, the static analysis of filtering simplified, because now specializers
171: // contain a field 'filterType' which is propagated to the root of composite specializers. junit packages updated accordingly
172: //
|