001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.diff;
034:
035: import java.util.*;
036:
037: import com.jeantessier.classreader.*;
038:
039: public class MockDifferenceStrategy extends DifferenceStrategyDecorator {
040: private int packageDifferentCount = 0;
041: private int classDifferentCount = 0;
042: private int fieldDifferentCount = 0;
043: private int constantValueDifferentCount = 0;
044: private int methodDifferentCount = 0;
045: private int codeDifferentCount = 0;
046:
047: public MockDifferenceStrategy(DifferenceStrategy delegate) {
048: super (delegate);
049: }
050:
051: public int getPackageDifferentCount() {
052: return packageDifferentCount;
053: }
054:
055: public int getClassDifferentCount() {
056: return classDifferentCount;
057: }
058:
059: public int getFieldDifferentCount() {
060: return fieldDifferentCount;
061: }
062:
063: public int getConstantValueDifferentCount() {
064: return constantValueDifferentCount;
065: }
066:
067: public int getMethodDifferentCount() {
068: return methodDifferentCount;
069: }
070:
071: public int getCodeDifferentCount() {
072: return codeDifferentCount;
073: }
074:
075: public boolean isPackageDifferent(Map oldPackage, Map newPackage) {
076: packageDifferentCount++;
077:
078: return super .isPackageDifferent(oldPackage, newPackage);
079: }
080:
081: public boolean isClassDifferent(Classfile oldClass,
082: Classfile newClass) {
083: classDifferentCount++;
084:
085: return super .isClassDifferent(oldClass, newClass);
086: }
087:
088: public boolean isFieldDifferent(Field_info oldFeature,
089: Field_info newFeature) {
090: fieldDifferentCount++;
091:
092: return super .isFieldDifferent(oldFeature, newFeature);
093: }
094:
095: public boolean isConstantValueDifferent(
096: ConstantValue_attribute oldValue,
097: ConstantValue_attribute newValue) {
098: constantValueDifferentCount++;
099:
100: return super .isConstantValueDifferent(oldValue, newValue);
101: }
102:
103: public boolean isMethodDifferent(Method_info oldMethod,
104: Method_info newMethod) {
105: methodDifferentCount++;
106:
107: return super .isMethodDifferent(oldMethod, newMethod);
108: }
109:
110: public boolean isCodeDifferent(Code_attribute oldCode,
111: Code_attribute newCode) {
112: codeDifferentCount++;
113:
114: return super.isCodeDifferent(oldCode, newCode);
115: }
116: }
|