private static void addDigest(MessageDigest digest, Annotation []annList)
  {
    if (annList == null)
      return;

    for (Annotation ann : annList)
      addDigest(digest, ann);
  }
  
  /**
   * Adds the annotations to the digest using a UTF8 encoding.
   */
  private static void addDigest(MessageDigest digest, Annotation ann)
  {
    addDigest(digest, ann.annotationType().getName());
  }
  
  /**
   * Adds the int to the digest.
   */
  private static void addDigest(MessageDigest digest, int v)
  {
    digest.update((byte) (v >> 24));
    digest.update((byte) (v >> 16));
    digest.update((byte) (v >> 8));
    digest.update((byte) v);
  }
  
  /**
   * Adds the string to the digest using a UTF8 encoding.
   */
  private static void addDigest(MessageDigest digest, String string)
  {
    if (string == null)
      return;
    
    int len = string.length();
    for (int i = 0; i < len; i++) {
      int ch = string.charAt(i);
      if (ch < 0x80)
        digest.update((byte) ch);
      else if (ch < 0x800) {
        digest.update((byte) (0xc0 + (ch >> 6)));
        digest.update((byte) (0x80 + (ch & 0x3f)));
      }
      else {
        digest.update((byte) (0xe0 + (ch >> 12)));
        digest.update((byte) (0x80 + ((ch >> 6) & 0x3f)));
        digest.update((byte) (0x80 + (ch & 0x3f)));
      }
    }
  }
  
  private String digestToBase64(byte []digest, int len)
  {
    StringBuilder cb = new StringBuilder();

    Base64Util.encode(cb, digest, 0, len);

    return cb.toString();
  }

  public boolean isEqual(Object o)
  {
    if (o == this)
      return true;
    
    if (! (o instanceof JClassDependency))
      return false;

    JClassDependency depend = (JClassDependency) o;

    return _className.equals(depend._className);
  }

  static class FieldComparator implements Comparator<Field> {
    public int compare(Field a, Field b)
    {
      if (a == b)
        return 0;
      else if (a == null)
        return -1;
      else if (b == null)
        return 1;
      else if (a.equals(b))
        return 0;

      int cmp = a.getName().compareTo(b.getName());
      if (cmp != 0)
        return cmp;
      
      cmp = a.getDeclaringClass().getName().compareTo(b.getDeclaringClass().getName());
      if (cmp != 0)
        return cmp;
      
      return a.getType().getName().compareTo(b.getType().getName());
    }
  }

  static class MethodComparator implements Comparator<Method> {
    public int compare(Method a, Method b)
    {
      if (a == b)
        return 0;
      else if (a == null)
        return -1;
      else if (b == null)
        return 1;
      else if (a.equals(b))
        return 0;

      int cmp = a.getName().compareTo(b.getName());
      if (cmp != 0)
        return cmp;

      Class []paramA = a.getParameterTypes();
      Class []paramB = b.getParameterTypes();

      if (paramA.length < paramB.length)
        return -1;
      else if (paramB.length < paramA.length)
        return 1;

      for (int i = 0; i < paramA.length; i++) {
        cmp = paramA[i].getName().compareTo(paramB[i].getName());
        if (cmp != 0)
          return cmp;
      }
      
      cmp = a.getDeclaringClass().getName().compareTo(b.getDeclaringClass().getName());
      if (cmp != 0)
        return cmp;
      
      return a.getReturnType().getName().compareTo(b.getReturnType().getName());
    }
  }
}
private static void addDigest ( MessageDigest digest , Annotation [ ] annList ) { if ( annList == null ) return ; for ( Annotation ann : annList ) addDigest ( digest , ann ) ; } private static void addDigest ( MessageDigest digest , Annotation ann ) { addDigest ( digest , ann . annotationType ( ) . getName ( ) ) ; } private static void addDigest ( MessageDigest digest , int v ) { digest . update ( ( byte ) ( v > > 24 ) ) ; digest . update ( ( byte ) ( v > > 16 ) ) ; digest . update ( ( byte ) ( v > > 8 ) ) ; digest . update ( ( byte ) v ) ; } private static void addDigest ( MessageDigest digest , String string ) { if ( string == null ) return ; int len = string . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { int ch = string . charAt ( i ) ; if ( ch < 0x80 ) digest . update ( ( byte ) ch ) ; else if ( ch < 0x800 ) { digest . update ( ( byte ) ( 0xc0 + ( ch > > 6 ) ) ) ; digest . update ( ( byte ) ( 0x80 + ( ch & 0x3f ) ) ) ; } else { digest . update ( ( byte ) ( 0xe0 + ( ch > > 12 ) ) ) ; digest . update ( ( byte ) ( 0x80 + ( ( ch > > 6 ) & 0x3f ) ) ) ; digest . update ( ( byte ) ( 0x80 + ( ch & 0x3f ) ) ) ; } } } private String digestToBase64 ( byte [ ] digest , int len ) { StringBuilder cb = new StringBuilder ( ) ; Base64Util . encode ( cb , digest , 0 , len ) ; return cb . toString ( ) ; } public boolean isEqual ( Object o ) { if ( o == this ) return true ; if ( ! ( o instanceof JClassDependency ) ) return false ; JClassDependency depend = ( JClassDependency ) o ; return _className . equals ( depend . _className ) ; } static class FieldComparator implements Comparator < Field > { public int compare ( Field a , Field b ) { if ( a == b ) return 0 ; else if ( a == null ) return - 1 ; else if ( b == null ) return 1 ; else if ( a . equals ( b ) ) return 0 ; int cmp = a . getName ( ) . compareTo ( b . getName ( ) ) ; if ( cmp != 0 ) return cmp ; cmp = a . getDeclaringClass ( ) . getName ( ) . compareTo ( b . getDeclaringClass ( ) . getName ( ) ) ; if ( cmp != 0 ) return cmp ; return a . getType ( ) . getName ( ) . compareTo ( b . getType ( ) . getName ( ) ) ; } } static class MethodComparator implements Comparator < Method > { public int compare ( Method a , Method b ) { if ( a == b ) return 0 ; else if ( a == null ) return - 1 ; else if ( b == null ) return 1 ; else if ( a . equals ( b ) ) return 0 ; int cmp = a . getName ( ) . compareTo ( b . getName ( ) ) ; if ( cmp != 0 ) return cmp ; Class [ ] paramA = a . getParameterTypes ( ) ; Class [ ] paramB = b . getParameterTypes ( ) ; if ( paramA . length < paramB . length ) return - 1 ; else if ( paramB . length < paramA . length ) return 1 ; for ( int i = 0 ; i < paramA . length ; i ++ ) { cmp = paramA [ i ] . getName ( ) . compareTo ( paramB [ i ] . getName ( ) ) ; if ( cmp != 0 ) return cmp ; } cmp = a . getDeclaringClass ( ) . getName ( ) . compareTo ( b . getDeclaringClass ( ) . getName ( ) ) ; if ( cmp != 0 ) return cmp ; return a . getReturnType ( ) . getName ( ) . compareTo ( b . getReturnType ( ) . getName ( ) ) ; } } }
Adds the annotations to the digest using a UTF8 encoding.