Exemplo n.º 1
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(rrset);
   sb.append(" cl = ");
   sb.append(credibility);
   return sb.toString();
 }
Exemplo n.º 2
0
  private String positionToString(long value, char pos, char neg) {
    StringBuffer sb = new StringBuffer();
    char direction;

    long temp = value - (1L << 31);
    if (temp < 0) {
      temp = -temp;
      direction = neg;
    } else direction = pos;

    sb.append(temp / (3600 * 1000)); /* degrees */
    temp = temp % (3600 * 1000);
    sb.append(" ");

    sb.append(temp / (60 * 1000)); /* minutes */
    temp = temp % (60 * 1000);
    sb.append(" ");

    sb.append(w3.format(((double) temp) / 1000)); /* seconds */
    sb.append(" ");

    sb.append(direction);

    return sb.toString();
  }
Exemplo n.º 3
0
 /** Converts the NameSet to a String */
 public String toString() {
   StringBuffer sb = new StringBuffer();
   Iterator it = data.values().iterator();
   while (it.hasNext()) {
     TypeMap nameInfo = (TypeMap) it.next();
     Object[] elements = nameInfo.getAll();
     if (elements == null) continue;
     for (int i = 0; i < elements.length; i++) {
       sb.append(elements[i]);
       sb.append("\n");
     }
   }
   return sb.toString();
 }
Exemplo n.º 4
0
 /** Converts rdata to a String */
 String rrToString() {
   StringBuffer sb = new StringBuffer();
   if (options != null) {
     sb.append(options);
     sb.append(" ");
   }
   sb.append(" ; payload ");
   sb.append(getPayloadSize());
   sb.append(", xrcode ");
   sb.append(getExtendedRcode());
   sb.append(", version ");
   sb.append(getVersion());
   sb.append(", flags ");
   sb.append(getFlags());
   return sb.toString();
 }
Exemplo n.º 5
0
 /** Converts rdata to a String */
 String rrToString() {
   StringBuffer sb = new StringBuffer();
   sb.append(certType);
   sb.append(" ");
   sb.append(keyTag);
   sb.append(" ");
   sb.append(alg);
   if (cert != null) {
     if (Options.check("multiline")) {
       sb.append(" (\n");
       sb.append(Base64.formatString(cert, 64, "\t", true));
     } else {
       sb.append(" ");
       sb.append(Base64.toString(cert));
     }
   }
   return sb.toString();
 }
Exemplo n.º 6
0
 /** Converts a byte array into a String. */
 protected static String byteArrayToString(byte[] array, boolean quote) {
   StringBuffer sb = new StringBuffer();
   if (quote) sb.append('"');
   for (int i = 0; i < array.length; i++) {
     int b = array[i] & 0xFF;
     if (b < 0x20 || b >= 0x7f) {
       sb.append('\\');
       sb.append(byteFormat.format(b));
     } else if (b == '"' || b == ';' || b == '\\') {
       sb.append('\\');
       sb.append((char) b);
     } else sb.append((char) b);
   }
   if (quote) sb.append('"');
   return sb.toString();
 }
Exemplo n.º 7
0
 /** Converts a byte array into the unknown RR format. */
 protected static String unknownToString(byte[] data) {
   StringBuffer sb = new StringBuffer();
   sb.append("\\# ");
   sb.append(data.length);
   sb.append(" ");
   sb.append(base16.toString(data));
   return sb.toString();
 }
Exemplo n.º 8
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   if (type == 0) sb.append("NXDOMAIN " + name);
   else sb.append("NXRRSET " + name + " " + Type.string(type));
   sb.append(" cl = ");
   sb.append(credibility);
   return sb.toString();
 }
Exemplo n.º 9
0
  static String formatDate(Date d) {
    Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    StringBuffer sb = new StringBuffer();
    NumberFormat w4 = new DecimalFormat();
    w4.setMinimumIntegerDigits(4);
    w4.setGroupingUsed(false);
    NumberFormat w2 = new DecimalFormat();
    w2.setMinimumIntegerDigits(2);

    c.setTime(d);
    sb.append(w4.format(c.get(c.YEAR)));
    sb.append(w2.format(c.get(c.MONTH) + 1));
    sb.append(w2.format(c.get(c.DAY_OF_MONTH)));
    sb.append(w2.format(c.get(c.HOUR_OF_DAY)));
    sb.append(w2.format(c.get(c.MINUTE)));
    sb.append(w2.format(c.get(c.SECOND)));
    return sb.toString();
  }
Exemplo n.º 10
0
 /**
  * Reads a line using the master file format. Removes all data following a semicolon and uses
  * parentheses as line continuation markers.
  *
  * @param br The BufferedReader supplying the data
  * @return A String representing the normalized line
  */
 public static String readExtendedLine(BufferedReader br) throws IOException {
   String s = stripTrailing(br.readLine());
   if (s == null) return null;
   if (!s.endsWith("(")) return s;
   StringBuffer sb = new StringBuffer(s.substring(0, s.length() - 1));
   while (true) {
     s = stripTrailing(br.readLine().trim());
     if (s == null) return sb.toString();
     sb.append(" ");
     if (s.endsWith(")")) {
       sb.append(s.substring(0, s.length() - 1));
       break;
     } else sb.append(s);
   }
   return sb.toString();
 }
Exemplo n.º 11
0
 /** Converts rdata to a String */
 public String rdataToString() {
   StringBuffer sb = new StringBuffer();
   if (signature != null) {
     sb.append(Type.string(covered));
     sb.append(" ");
     sb.append(alg);
     sb.append(" ");
     sb.append(labels);
     sb.append(" ");
     sb.append(origttl);
     sb.append(" (\n\t");
     sb.append(formatDate(expire));
     sb.append(" ");
     sb.append(formatDate(timeSigned));
     sb.append(" ");
     sb.append((int) footprint & 0xFFFF);
     sb.append(" ");
     sb.append(signer);
     sb.append("\n");
     sb.append(base64.formatString(signature, 64, "\t", true));
   }
   return sb.toString();
 }
Exemplo n.º 12
0
 /** Converts to a String */
 public String toString() {
   StringBuffer sb = toStringNoData();
   if (key != null || (flags & (FLAG_NOKEY)) == (FLAG_NOKEY)) {
     if (!Options.check("nohex")) {
       sb.append("0x");
       sb.append(Integer.toHexString(flags & 0xFFFF));
     } else sb.append(flags & 0xFFFF);
     sb.append(" ");
     sb.append(proto);
     sb.append(" ");
     sb.append(alg);
     if (key != null) {
       sb.append(" (\n");
       sb.append(base64.formatString(key, 64, "\t", true));
       sb.append(" ; key_tag= ");
       sb.append(getFootprint());
     }
   }
   return sb.toString();
 }
Exemplo n.º 13
0
 /** Converts a Record into a String representation */
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(name);
   if (sb.length() < 8) sb.append("\t");
   if (sb.length() < 16) sb.append("\t");
   sb.append("\t");
   if (Options.check("BINDTTL")) sb.append(TTL.format(ttl));
   else sb.append(ttl);
   sb.append("\t");
   if (dclass != DClass.IN || !Options.check("noPrintIN")) {
     sb.append(DClass.string(dclass));
     sb.append("\t");
   }
   sb.append(Type.string(type));
   String rdata = rrToString();
   if (!rdata.equals("")) {
     sb.append("\t");
     sb.append(rdata);
   }
   return sb.toString();
 }
Exemplo n.º 14
0
  /** Convert to a String */
  String rrToString() {
    StringBuffer sb = new StringBuffer();
    long temp;
    char direction;

    /* Latitude */
    sb.append(positionToString(latitude, 'N', 'S'));
    sb.append(" ");

    /* Latitude */
    sb.append(positionToString(longitude, 'E', 'W'));
    sb.append(" ");

    /* Altitude */
    sb.append(w2.format((double) (altitude - 10000000) / 100));
    sb.append("m ");

    /* Size */
    sb.append(w2.format((double) size / 100));
    sb.append("m ");

    /* Horizontal precision */
    sb.append(w2.format((double) hPrecision / 100));
    sb.append("m ");

    /* Vertical precision */
    sb.append(w2.format((double) vPrecision / 100));
    sb.append("m");

    return sb.toString();
  }
Exemplo n.º 15
0
 /** Converts the RRSIG/SIG Record to a String */
 public String rdataToString() {
   StringBuffer sb = new StringBuffer();
   if (signature != null) {
     sb.append(Type.string(covered));
     sb.append(" ");
     sb.append(alg);
     sb.append(" ");
     sb.append(labels);
     sb.append(" ");
     sb.append(origttl);
     sb.append(" ");
     if (Options.check("multiline")) sb.append("(\n\t");
     sb.append(FormattedTime.format(expire));
     sb.append(" ");
     sb.append(FormattedTime.format(timeSigned));
     sb.append(" ");
     sb.append(footprint);
     sb.append(" ");
     sb.append(signer);
     if (Options.check("multiline")) {
       sb.append("\n");
       sb.append(base64.formatString(signature, 64, "\t", true));
     } else {
       sb.append(" ");
       sb.append(base64.toString(signature));
     }
   }
   return sb.toString();
 }
Exemplo n.º 16
0
 /** Converts this Record to the String "unknown format" */
 public String toString() {
   StringBuffer sb = toStringNoData();
   if (data != null) sb.append("<unknown format>");
   return sb.toString();
 }