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: FieldsNamedFilter.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 FieldsNamedFilter XXX
038: *
039: * @version $Revision: 1.1.1.1 $
040: * @author Andrei Popovici
041: */
042: public class FieldsNamedFilter extends PointCutter implements
043: JoinPointKinds {
044:
045: private static final long serialVersionUID = 3689353229985460273L;
046: NameExpression regexp;
047:
048: public FieldsNamedFilter(String name) {
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: regexp = new NameExpression(name);
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: switch (jprType) {
063: case MASK_FIELD_ACCESS_JP:
064: return regexp
065: .memberMatchesRegexp(((FieldAccessRequest) jpr)
066: .getField());
067: case MASK_FIELD_MODIFICATION_JP:
068: return regexp
069: .memberMatchesRegexp(((FieldModificationRequest) jpr)
070: .getField());
071: default:
072: throw new Error("cannot get unrequested request");
073: }
074:
075: }
076:
077: protected boolean doIsSpecialEvent(CodeJoinPoint e) {
078: throw new Error("The PointCutter contract is not correct");
079: }
080:
081: }
082:
083: //======================================================================
084: //
085: // $Log: FieldsNamedFilter.java,v $
086: // Revision 1.1.1.1 2003/07/02 15:30:52 apopovic
087: // Imported from ETH Zurich
088: //
089: // Revision 1.2 2003/05/06 15:51:39 popovici
090: // Mozilla-ification
091: //
092: // Revision 1.1 2003/05/05 13:58:03 popovici
093: // renaming from runes to prose
094: //
095: // Revision 1.3 2003/04/27 13:08:48 popovici
096: // Specializers renamed to PointCutter
097: //
098: // Revision 1.2 2003/04/17 12:49:35 popovici
099: // Refactoring of the crosscut package
100: // ExceptionCut renamed to ThrowCut
101: // McutSignature is now SignaturePattern
102: //
103: // Revision 1.1 2003/04/17 08:47:46 popovici
104: // Important functionality additions
105: // - Cflow specializers
106: // - Restructuring of the MethodCut, SetCut, ThrowCut, and GetCut (they are much smaller)
107: // - Transactional capabilities
108: // - Total refactoring of Specializer evaluation, which permits fine-grained distinction
109: // between static and dynamic specializers.
110: // - Functionality pulled up in abstract classes
111: // - Uniformization of advice methods patterns and names
112: //
|