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: NegatingPointCutter.java,v 1.3 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 NegaintPointCuter negates a PointCutter.
037: * It returns a <code>memberPointFilters()</code>
038: * collection with only one member (the argument to the constructor) and
039: * negates only active filters. (That is, if the filter is not doing dynamic
040: * filtering, the result is undefined).
041: *
042: * @version $Revision: 1.3 $
043: * @author Andrei Popovici
044: */
045: public class NegatingPointCutter extends PointCutter {
046:
047: private static final long serialVersionUID = 3689911773301978934L;
048: PointCutter spec1;
049:
050: /** Create a PointCutter that negates the filtering behavior of
051: * s1. <code>s1</code> is the only member PointCutter.
052: */
053: public NegatingPointCutter(PointCutter s1) {
054: if (s1 == null)
055: throw new IllegalArgumentException(
056: "NegatingPointCutter.<init>: s1 is null");
057:
058: this .acceptMask = s1.acceptMask;
059: this .mayFilterStaticallyMask = s1.mayFilterStaticallyMask;
060: this .canFilterStaticallyMask = s1.canFilterStaticallyMask;
061: spec1 = s1;
062: }
063:
064: /** Returns the inner PointCutter, passed to the constructor. */
065: public List memberPointFilters() {
066: Vector result = new Vector();
067: result.add(spec1);
068: return result;
069: }
070:
071: /** Negates the <code>isSpecialRequest</code> of the member PointFilter
072: * <em>if the PointFilter is doing static filtering</em>.
073: *
074: * @return <code>!r1.isSpecialRequest(r1)</code>, if spec1 is
075: * doing static filtering (see <code>filterType</code>). If
076: * spec1 is not doing static filtering, the result is undefined.
077: */
078: protected boolean doIsSpecialRequest(JoinPointRequest r1) {
079: // we get here if and only if we accept this request
080: // and it is clear that we MAY filter this. Well,
081: return !spec1.isSpecialRequest(r1);
082: }
083:
084: /** Negates the <code>isSpecialEvent</code> of e1.
085: *
086: * @return <code>!spec1.isSpecialRequest(e1)</code>, if spec1 is
087: * doing dynamic filtering (see <code>filterType</code>). If
088: * spec1 is not doing dynamic filtering, the result is undefined.
089: *
090: */
091: protected boolean doIsSpecialEvent(CodeJoinPoint e1) {
092: // we get here if we are accepting this event,
093: // AND we cannot filter statically. The olny
094: // sensible thing is to ask..
095: return !spec1.isSpecialEvent(e1);
096: }
097:
098: public String toString() {
099: return "(!" + spec1.toString() + ")";
100: }
101:
102: }
103:
104: //======================================================================
105: //
106: // $Log: NegatingPointCutter.java,v $
107: // Revision 1.3 2003/07/17 13:11:08 apopovic
108: // refactorization: from PointFilter.memberSpecializers to PointFilter.memberPointFilters;
109: // improved documentation (removed references to specializers)
110: //
111: // Revision 1.2 2003/07/11 12:24:04 apopovic
112: // Added 'toString' to NegatingSpec
113: //
114: // Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
115: // Imported from ETH Zurich
116: //
117: // Revision 1.2 2003/05/06 15:51:40 popovici
118: // Mozilla-ification
119: //
120: // Revision 1.1 2003/05/05 13:57:56 popovici
121: // renaming from runes to prose
122: //
123: // Revision 1.1 2003/04/27 13:08:50 popovici
124: // Specializers renamed to PointCutter
125: //
126: // Revision 1.6 2003/04/17 12:49:35 popovici
127: // Refactoring of the crosscut package
128: // ExceptionCut renamed to ThrowCut
129: // McutSignature is now SignaturePattern
130: //
131: // Revision 1.5 2003/04/17 08:47:50 popovici
132: // Important functionality additions
133: // - Cflow specializers
134: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
135: // - Transactional capabilities
136: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
137: // between static and dynamic specializers.
138: // - Functionality pulled up in abstract classes
139: // - Uniformization of advice methods patterns and names
140: //
141: // Revision 1.4 2003/03/04 18:24:14 popovici
142: // Refactoring of the specializer. De-obfuscation
143: // by exposing the inner classes of the factory methods
144: // The specializer implementations now end in 'filter',
145: // whereas the old factory methods 'xxxS' remain
146: // pure bootstrap objects.
147: //
148: // Revision 1.3 2003/03/04 11:27:23 popovici
149: // Important refactorization step (march):
150: // - removal of 'JoinPointEvents'; JoinPoints now have the same function as events
151: // - reimplementation of the JVMAIDebuggerAspectInterface (better performance, coding conventions, removal of ProseVM
152: // structures
153: //
154: // Revision 1.2 2002/05/28 15:52:55 popovici
155: // Bug fix. The constructor used the uninitialized spec1 private variable
156: //
157: // Revision 1.1 2002/05/07 10:46:58 popovici
158: // Reorganization of the Specializer package. All specializer related classes
159: // moved to ch.ethz.inf.crossucut.spec; Classes ORingPointCutter, ANDspecializer and NOTspecializer is
160: // introduced, the static analysis of filtering simplified, because now specializers
161: // contain a field 'filterType' which is propagated to the root of composite specializers. junit packages updated accordingly
162: //
|