/**
  * Checks if the specified variable is already in the stack (list) of variables.
  *
  * @param varName the variable name to check
  * @param priorVariables the list of prior variables
  */
 private void checkCyclicSubstitution(final String varName, final List<String> priorVariables) {
   if (priorVariables.contains(varName) == false) {
     return;
   }
   final StrBuilder buf = new StrBuilder(256);
   buf.append("Infinite loop in property interpolation of ");
   buf.append(priorVariables.remove(0));
   buf.append(": ");
   buf.appendWithSeparators(priorVariables, "->");
   throw new IllegalStateException(buf.toString());
 }
Exemple #2
0
  public static void dumpClass(Class<?> cls) {
    xlog.INSTANCE.d("Dump Class Methods: ", cls.getName());
    StrBuilder sb = new StrBuilder(128);
    Field[] fs = cls.getDeclaredFields();
    Arrays.sort(
        fs,
        new Comparator<Field>() {

          @Override
          public int compare(Field lhs, Field rhs) {
            boolean s1 = Modifier.isStatic(lhs.getModifiers());
            boolean s2 = Modifier.isStatic(rhs.getModifiers());
            if (s1 && !s2) {
              return -1;
            }
            if (!s1 && s2) {
              return 1;
            }
            return lhs.getName().compareTo(rhs.getName());
          }
        });
    Method[] ms = cls.getDeclaredMethods();
    Arrays.sort(
        ms,
        new Comparator<Method>() {

          @Override
          public int compare(Method lhs, Method rhs) {
            boolean s1 = Modifier.isStatic(lhs.getModifiers());
            boolean s2 = Modifier.isStatic(rhs.getModifiers());
            if (s1 && !s2) {
              return -1;
            }
            if (!s1 && s2) {
              return 1;
            }

            return lhs.getName().compareTo(rhs.getName());
          }
        });
    for (Field f : fs) {
      sb.clear();
      int mod = f.getModifiers();
      if (Modifier.isPublic(mod)) {
        sb.append("public ");
      } else if (Modifier.isPrivate(mod)) {
        sb.append("private ");
      } else if (Modifier.isProtected(mod)) {
        sb.append("protected ");
      }
      boolean isStatic = Modifier.isStatic(f.getModifiers());
      if (isStatic) {
        sb.append("static ");
      }
      sb.append(f.getType().getSimpleName(), " ");
      sb.append(f.getName());
      if (isStatic) {
        sb.append(" = ", getStatic(cls, f.getName()));
      }
      xlog.INSTANCE.d(sb.toString());
    }

    for (Method m : ms) {
      sb.clear();
      if (Modifier.isPublic(m.getModifiers())) {
        sb.append("public ");
      }
      if (Modifier.isStatic(m.getModifiers())) {
        sb.append("static ");
      }
      sb.append(m.getReturnType().getSimpleName(), " ");
      sb.append(m.getName());
      sb.append("(");
      boolean first = true;
      for (Class<?> p : m.getParameterTypes()) {
        if (first) {
          first = false;
        } else {
          sb.append(",");
        }
        sb.append(p.getSimpleName());
      }
      sb.append(");");
      xlog.INSTANCE.d(sb.toString());
    }
  }