===================================================================== Found a 151 line (744 tokens) duplication in the following files: Starting at line 76 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Allow.java Starting at line 76 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Imply.java private Imply() {} public static final boolean compute( final Object o1, final Object o2) { if (o1 instanceof Op) { return compute((Op)o1, o2); } throw new IllegalArgumentException( "Not an Op: "+o1); } public static final boolean compute( final Op o1, final Object o2) { if (o2 instanceof Op) { return compute(o1, (Op)o2); } throw new IllegalArgumentException( "Not an Op: "+o2); } public static final boolean compute( final Op o1, final Op o2) { switch (o1.getID()) { // constant case CONSTANT_ID: return compute((ConstantOp)o1, o2); case GET_ID: return compute((GetOp)o1, o2); // list case ALL_ID: return compute((AllOp)o1, o2); case EMPTY_ID: return compute((EmptyOp)o1, o2); case EXISTS_ID: return compute((ExistsOp)o1, o2); // logical case AND_ID: return compute((AndOp)o1, o2); case FALSE_ID: return compute((FalseOp)o1, o2); case NOT_ID: return compute((NotOp)o1, o2); case OR_ID: return compute((OrOp)o1, o2); case TRUE_ID: return compute((TrueOp)o1, o2); // reflect case APPLY_ID: return compute((ApplyOp)o1, o2); case FIELD_ID: return compute((FieldOp)o1, o2); case INSTANCEOF_ID: return compute((InstanceOfOp)o1, o2); case METHOD_ID: return compute((MethodOp)o1, o2); case REFLECT_ID: throw new UnsupportedOperationException( "ReflectOps should be parsed to MethodOps/FieldOps!"); case THIS_ID: return compute((ThisOp)o1, o2); default: throw new RuntimeException( "Unknown Op: "+o1); } } protected static final boolean compute( final ConstantOp o1, final Op o2) { return (o1.equals(o2)); } protected static final boolean compute( final GetOp o1, final Op o2) { return (o1.equals(o2)); } protected static final boolean compute( final AllOp o1, final Op o2) { int o2ID = o2.getID(); if (o2ID == ALL_ID) { // compare the operators of the alls return compute((o1.u), (((AllOp)o2).u)); } else if (o2ID == INSTANCEOF_ID) { // allOps only accept collections return (((Type)o2).impliedBy(false, Collection.class)); } else { return false; } } protected static final boolean compute( final EmptyOp o1, final Op o2) { if (o1 == o2) { // single EmptyOP return true; } else if (o2.getID() == INSTANCEOF_ID) { // emptyOps only accept collections return (((Type)o2).impliedBy(false, Collection.class)); } else { return false; } } protected static final boolean compute( final ExistsOp o1, final Op o2) { int o2ID = o2.getID(); if (o2ID == EXISTS_ID) { // compare the operators of the exists return compute((o1.u), (((ExistsOp)o2).u)); } else if (o2ID == INSTANCEOF_ID) { // existsOps only accept collections return (((Type)o2).impliedBy(false, Collection.class)); } else { return false; } } protected static final boolean compute( final AndOp o1, final AndOp o2) { // and1 implies and2 if all the elements of and2 are implied by some // element of and1 Op[] ops = o1.ops; Op[] xops = o2.ops; int nops = ops.length; int nxops = xops.length; // for all and2 elements for (int j = 0; j < nxops; j++) { Op uj = xops[j]; // for all and1 elements for (int i = 0; ; i++) { if (i >= nops) { // and2[j] isn't implied by any element of and1[] return false; } Op ui = ops[i]; if (compute(ui, uj)) { // and1[i] implies and2[j] break; } } } // all elements of and2 are implied by some and2 element, // so and1 implies and2 return true; } protected static final boolean compute( final AndOp o1, final InstanceOfOp o2) { // andOp implies typeOp if some element of andOp implies the typeOp Op[] ops = o1.ops; int nops = ops.length; ===================================================================== Found a 91 line (440 tokens) duplication in the following files: Starting at line 352 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Allow.java Starting at line 346 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Imply.java return false; } } // orOp implies op return true; } protected static final boolean compute( final TrueOp o1, final Op o2) { // single TrueOp return (o1 == o2); } protected static final boolean compute( final ApplyOp o1, final Op o2) { if (o2.getID() == APPLY_ID) { // apply1 is equal to apply2 if their arguments are equal ApplyOp x = (ApplyOp)o2; Op u1 = o1.u1; Op xu1 = x.u1; // test if the operators are the same if (!(u1.equals(xu1))) { return false; } Op u2 = o1.u2; Op xu2 = x.u2; // test if the operators imply return (compute(u2, xu2)); } else { return false; } } protected static final boolean compute( final FieldOp o1, final Op o2) { return (o1.equals(o2)); } protected static final boolean compute( final InstanceOfOp o1, final Op o2) { int o2ID = o2.getID(); if (o2ID == INSTANCEOF_ID) { // test the type implications of the two instanceOfOps return (((Type)o1).implies((Type)o2)); } else if (o2ID == AND_ID) { // see if this typeOp implies all the elements of the andOp Op[] ops = ((AndOp)o2).ops; int nops = ops.length; // for all andOp elements for (int i = 0; i < nops; i++) { Op ui = ops[i]; if (!(compute(o1, ui))) { return false; } } return true; } else if (o2ID == OR_ID) { // see if this typeOp implies any element of the orOp Op[] ops = ((OrOp)o2).ops; int nops = ops.length; // for all orOp elements for (int i = 0; i < nops; i++) { Op ui = ops[i]; if (compute(o1, ui)) { return true; } } return false; } else { return false; } } protected static final boolean compute( final MethodOp o1, final Op o2) { int o2ID = o2.getID(); if (o2ID == METHOD_ID) { // see if the methods are equal return (o1.equals(o2)); } else if (o2ID == INSTANCEOF_ID) { // see if method is non-static, e.g. "String.equals", and // if it implies the given type, e.g. "is:String" Method meth = o1.meth; if ((meth.getModifiers() & Modifier.STATIC) == 0) { Type t2 = (Type)o2; Class mclass = meth.getDeclaringClass(); return (t2.impliedBy(false, mclass)); } else { return false; } } else if (o2ID == AND_ID) { ===================================================================== Found a 69 line (274 tokens) duplication in the following files: Starting at line 281 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Allow.java Starting at line 276 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Imply.java break; } } } else { // andOp doesn't imply o2 return false; } } } // andOp implies the given op return true; } protected static final boolean compute( final FalseOp o1, final Op o2) { // single FalseOP return (o1 == o2); } protected static final boolean compute( final NotOp o1, final Op o2) { if (o2.getID() == NOT_ID) { // compare the operator of the nots return compute((o1.u1), (((NotOp)o2).u1)); } else { return false; } } protected static final boolean compute( final OrOp o1, final OrOp o2) { // or1 implies or2 if any or1 element implies any or2 element Op[] ops = o1.ops; Op[] xops = o2.ops; int nops = ops.length; int nxops = xops.length; // for all or1 elements for (int i = 0; i < nops; i++) { Op ui = ops[i]; // for all or2 elements for (int j = 0; j < nxops; j++) { Op uj = xops[j]; // compare the elements if (compute(ui, uj)) { // (or1[i] implies or2[j]), so (or1 implies or2) return true; } } } // none of the or1 elements imply any or2 element return false; } protected static final boolean compute( final OrOp o1, final Op o2) { if (o2.getID() == OR_ID) { // compute two ors return compute(o1, (OrOp)o2); } // compare the orOp with a non-orOp // // an orOp implies an op if all element of the orOp imply the op Op[] ops = o1.ops; int nops = ops.length; // for all orOp elements for (int i = 0; i < nops; i++) { Op ui = ops[i]; // compare orOp[i] with op if (!(compute(ui, o2))) { ===================================================================== Found a 51 line (257 tokens) duplication in the following files: Starting at line 93 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Allow.java Starting at line 58 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Equal.java false); } public static final boolean compute( final Op o1, final Op o2) { switch (o1.getID()) { // constant case CONSTANT_ID: return compute((ConstantOp)o1, o2); case GET_ID: return compute((GetOp)o1, o2); // list case ALL_ID: return compute((AllOp)o1, o2); case EMPTY_ID: return compute((EmptyOp)o1, o2); case EXISTS_ID: return compute((ExistsOp)o1, o2); // logical case AND_ID: return compute((AndOp)o1, o2); case FALSE_ID: return compute((FalseOp)o1, o2); case NOT_ID: return compute((NotOp)o1, o2); case OR_ID: return compute((OrOp)o1, o2); case TRUE_ID: return compute((TrueOp)o1, o2); // reflect case APPLY_ID: return compute((ApplyOp)o1, o2); case FIELD_ID: return compute((FieldOp)o1, o2); case INSTANCEOF_ID: return compute((InstanceOfOp)o1, o2); case METHOD_ID: return compute((MethodOp)o1, o2); case REFLECT_ID: throw new UnsupportedOperationException( "ReflectOps should be parsed to MethodOps/FieldOps!"); case THIS_ID: return compute((ThisOp)o1, o2); default: throw new RuntimeException( "Unknown Op: "+o1); } } protected static final boolean compute( final ConstantOp o1, final Op o2) { ===================================================================== Found a 38 line (170 tokens) duplication in the following files: Starting at line 240 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Allow.java Starting at line 237 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/compare/Imply.java return false; } protected static final boolean compute( final AndOp o1, final Op o2) { int o2ID = o2.getID(); if (o2ID == AND_ID) { // compute two ands return compute(o1, (AndOp)o2); } else if (o2ID == INSTANCEOF_ID) { // compute and with type return compute(o1, (InstanceOfOp)o2); } // compare the andOp with a non-andOp/instanceOfOp // // see if all the elements of the andOp imply the given op Op[] ops = o1.ops; int nops = ops.length; // for all andOp elements for (int i = 0; i < nops; i++) { Op ui = ops[i]; // compare andOp[i] with o2 if (!(compute(ui, o2))) { // andOp[i] doesn't imply o2 if (ui.getID() == INSTANCEOF_ID) { // see if the andOp is something like (and (isX) (X.method)), // where "X.method" is non-static. The "is:X" in that case // is a redundant check. // // for (int j = 0; ; j++) { if (j >= nops) { // no matching "X.method", so (!(andOp implies o2)) return false; } Op uj = ops[j]; if ((uj.getID() != INSTANCEOF_ID) && (compute(uj, ui))) { ===================================================================== Found a 11 line (109 tokens) duplication in the following files: Starting at line 75 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/cache/MethodCache.java Starting at line 122 of /usr/local/dashboard/working/contract/src/org/cougaar/lib/contract/lang/cache/MethodCache.java Method[] allMeths = c.getMethods(); for (int i = allMeths.length-1; i >= 0; i--) { Method m = allMeths[i]; // must have same name if (name.equals(m.getName())) { int mmods = m.getModifiers(); // must be PUBLIC, and must meet STATIC/NON_STATIC requirements if (((mmods & Modifier.PUBLIC) != 0) && (IS_STATIC_EXPLICIT ? (isStatic == ((mmods & Modifier.STATIC) != 0)) : (isStatic ? ((mmods & Modifier.STATIC) != 0) : true))) {