示例#1
0
  public static void printSection(String name, char sectionCharacter) {

    String header = " " + name + " ";
    int remainingCharacters = PRINTING_LINE_WIDTH - header.length();
    int leftPart = remainingCharacters / 2;
    int rightPart = remainingCharacters - leftPart;
    for (int i = 0; i < leftPart; i++) {
      TTY.print(sectionCharacter);
    }

    TTY.print(header);

    for (int i = 0; i < rightPart; i++) {
      TTY.print(sectionCharacter);
    }

    TTY.println();
  }
示例#2
0
 public static void printField(final Field field, boolean tabbed) {
   final String fieldName = String.format("%35s", field.getName());
   try {
     String prefix = tabbed ? "" : "    " + fieldName + " = ";
     String postfix = tabbed ? "\t" : "\n";
     if (field.getType() == int.class) {
       TTY.print(prefix + field.getInt(null) + postfix);
     } else if (field.getType() == boolean.class) {
       TTY.print(prefix + field.getBoolean(null) + postfix);
     } else if (field.getType() == float.class) {
       TTY.print(prefix + field.getFloat(null) + postfix);
     } else if (field.getType() == String.class) {
       TTY.print(prefix + field.get(null) + postfix);
     } else if (field.getType() == Map.class) {
       Map<?, ?> m = (Map<?, ?>) field.get(null);
       TTY.print(prefix + printMap(m) + postfix);
     } else {
       TTY.print(prefix + field.get(null) + postfix);
     }
   } catch (IllegalAccessException e) {
     // do nothing.
   }
 }