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: ObjectFilter.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
022: //=====================================================================
023: //
024: //(history at end)
025: //
026:
027: package ch.ethz.prose.filter;
028:
029: import ch.ethz.jvmai.JoinPointKinds;
030: import ch.ethz.prose.engine.JoinPointRequest;
031: import ch.ethz.jvmai.CodeJoinPoint;
032:
033: /** An abstract class that uses an "ObjectExtractor"
034: * to get an object from a join-point and filter
035: * (dynamically) the event.
036: */
037: abstract class ObjectFilter extends PointCutter implements
038: JoinPointKinds {
039:
040: {
041: acceptMask = MASK_ALL_JP;
042: mayFilterStaticallyMask = 0;
043: canFilterStaticallyMask = 0;
044: }
045:
046: public static int TARGET_ARGS_OBJECT = 0x01;
047: public static int THIS_OBJECT = 0x02;
048: protected int objectExtractionMode = 0;
049:
050: protected ObjectFilter(int targetType) {
051: objectExtractionMode = targetType;
052: }
053:
054: /** Undefined for all requests */
055: protected boolean doIsSpecialRequest(JoinPointRequest r) {
056: throw new Error(
057: "the AbstractCrosscuSpecialier should not allow requests in ObjectFilters");
058: }
059:
060: /** Extracts an object from <code>ev</code> and then filters
061: * ev according to the abstract <code>doIsSpecialEvent</code>.
062: */
063: protected boolean doIsSpecialEvent(CodeJoinPoint ev) {
064: if (objectExtractionMode == ObjectFilter.TARGET_ARGS_OBJECT)
065: return doIsSpecialObject(ev.getTarget());
066:
067: if (objectExtractionMode == ObjectFilter.THIS_OBJECT)
068: return doIsSpecialObject(ev.getThis());
069:
070: throw new Error(
071: "ObjectFilter.isSpecialEvent: Object filter was initialized with illegal value");
072: }
073:
074: protected abstract boolean doIsSpecialObject(Object target);
075:
076: }
077:
078: //====================================================================
079: //
080: //$Log: ObjectFilter.java,v $
081: //Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
082: //Imported from ETH Zurich
083: //
084: //Revision 1.2 2003/05/06 15:51:42 popovici
085: //Mozilla-ification
086: //
087: //Revision 1.1 2003/05/05 13:58:04 popovici
088: //renaming from runes to prose
089: //
090: //Revision 1.6 2003/04/27 13:08:44 popovici
091: //Specializers renamed to PointCutter
092: //
093: //Revision 1.5 2003/04/17 12:49:34 popovici
094: //Refactoring of the crosscut package
095: // ExceptionCut renamed to ThrowCut
096: // McutSignature is now SignaturePattern
097: //
098: //Revision 1.4 2003/04/17 08:47:51 popovici
099: //Important functionality additions
100: // - Cflow specializers
101: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
102: // - Transactional capabilities
103: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
104: // between static and dynamic specializers.
105: // - Functionality pulled up in abstract classes
106: // - Uniformization of advice methods patterns and names
107: //
108: //Revision 1.3 2003/03/05 10:48:52 popovici
109: //Adapted tot the IKS template form
110: //
111: //
|