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: FieldsWithModifierFilter.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: // used packages
030: import ch.ethz.jvmai.JoinPointKinds;
031: import ch.ethz.jvmai.CodeJoinPoint;
032: import ch.ethz.prose.engine.JoinPointRequest;
033: import ch.ethz.prose.engine.FieldAccessRequest;
034: import ch.ethz.prose.engine.FieldModificationRequest;
035:
036: /**
037: * Class FieldsWithModifierFilter XXX
038: *
039: * @version $Revision: 1.1.1.1 $
040: * @author Andrei Popovici
041: */
042: public class FieldsWithModifierFilter extends PointCutter implements
043: JoinPointKinds {
044:
045: private static final long serialVersionUID = 4121133628022601265L;
046: int theModifier;
047:
048: public FieldsWithModifierFilter(int modifier) {
049: acceptMask = MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP
050: | MASK_FIELD_JP;
051: mayFilterStaticallyMask = MASK_FIELD_ACCESS_JP
052: | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
053: canFilterStaticallyMask = MASK_FIELD_ACCESS_JP
054: | MASK_FIELD_MODIFICATION_JP | MASK_FIELD_JP;
055: theModifier = modifier;
056: }
057:
058: protected boolean doIsSpecialRequest(JoinPointRequest jpr) {
059: // only for field accesses and field modifications
060: int jprType = jpr.getMask()
061: & (MASK_FIELD_ACCESS_JP | MASK_FIELD_MODIFICATION_JP);
062: int crtModifier;
063: switch (jprType) {
064: case MASK_FIELD_ACCESS_JP:
065: crtModifier = ((FieldAccessRequest) jpr).getField()
066: .getModifiers();
067: break;
068: case MASK_FIELD_MODIFICATION_JP:
069: crtModifier = ((FieldModificationRequest) jpr).getField()
070: .getModifiers();
071: break;
072: default:
073: throw new Error("cannot get unrequested request");
074: }
075:
076: return (crtModifier & theModifier) == theModifier;
077: }
078:
079: protected boolean doIsSpecialEvent(CodeJoinPoint jp) {
080: throw new Error("The PointCutter contract is not correct");
081: }
082:
083: }
084:
085: //======================================================================
086: //
087: // $Log: FieldsWithModifierFilter.java,v $
088: // Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
089: // Imported from ETH Zurich
090: //
091: // Revision 1.2 2003/05/06 15:51:39 popovici
092: // Mozilla-ification
093: //
094: // Revision 1.1 2003/05/05 13:57:54 popovici
095: // renaming from runes to prose
096: //
097: // Revision 1.3 2003/04/27 13:08:47 popovici
098: // Specializers renamed to PointCutter
099: //
100: // Revision 1.2 2003/04/17 12:49:31 popovici
101: // Refactoring of the crosscut package
102: // ExceptionCut renamed to ThrowCut
103: // McutSignature is now SignaturePattern
104: //
105: // Revision 1.1 2003/04/17 08:47:47 popovici
106: // Important functionality additions
107: // - Cflow specializers
108: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
109: // - Transactional capabilities
110: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
111: // between static and dynamic specializers.
112: // - Functionality pulled up in abstract classes
113: // - Uniformization of advice methods patterns and names
114: //
|