当前位置: 首页>>代码示例>>Java>>正文


Java StringBuilderPrinter类代码示例

本文整理汇总了Java中android.util.StringBuilderPrinter的典型用法代码示例。如果您正苦于以下问题:Java StringBuilderPrinter类的具体用法?Java StringBuilderPrinter怎么用?Java StringBuilderPrinter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringBuilderPrinter类属于android.util包,在下文中一共展示了StringBuilderPrinter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHttpResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getHttpResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  HttpDesc desc = (HttpDesc) parameters;
  printer.println("[HTTP]");
  printer.println("URL: " + desc.url);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    int headerLen = Integer.parseInt(values.get("headers_len"));
    int bodyLen = Integer.parseInt(values.get("body_len"));
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("");
    printer.println("Downloaded " + (headerLen + bodyLen) + " bytes in " + time + " ms");
    printer.println("Bandwidth: " + (headerLen + bodyLen) * 8 / time + " Kbps");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Http paused!");
  } else {
    printer.println("Http download failed, status code " + values.get("code"));
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:22,代码来源:MeasurementResult.java

示例2: getDnsResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getDnsResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  DnsLookupDesc desc = (DnsLookupDesc) parameters;
  printer.println("[DNS Lookup]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    String ipAddress = removeQuotes(values.get("address"));
    if (ipAddress == null) {
      ipAddress = "Unknown";
    }
    printer.println("\nAddress: " + ipAddress);
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("Lookup time: " + time + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("DNS look up paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:22,代码来源:MeasurementResult.java

示例3: getHttpResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getHttpResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  HttpDesc desc = (HttpDesc) measurementDesc;
  printer.println("[HTTP]");
  printer.println("URL: " + desc.url);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    int headerLen = Integer.parseInt(values.get("headers_len"));
    int bodyLen = Integer.parseInt(values.get("body_len"));
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("");
    printer.println("Downloaded " + (headerLen + bodyLen) + " bytes in " + time + " ms");
    printer.println("Bandwidth: " + (headerLen + bodyLen) * 8 / time + " Kbps");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Http paused!");
  } else {
    printer.println("Http download failed, status code " + values.get("code"));
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:22,代码来源:MeasurementResult.java

示例4: getDnsResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getDnsResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  DnsLookupDesc desc = (DnsLookupDesc) measurementDesc;
  printer.println("[DNS Lookup]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    String ipAddress = removeQuotes(values.get("address"));
    if (ipAddress == null) {
      ipAddress = "Unknown";
    }
    printer.println("\nAddress: " + ipAddress);
    int time = Integer.parseInt(values.get("time_ms"));
    printer.println("Lookup time: " + time + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("DNS look up paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:22,代码来源:MeasurementResult.java

示例5: queueSize

import android.util.StringBuilderPrinter; //导入依赖的package包/类
public int queueSize() {
    StringBuilder sb = new StringBuilder();
    mServiceLooper.dump(new StringBuilderPrinter(sb), "");

    String[] lines = sb.toString().split("\n");
    return lines.length - 2;
}
 
开发者ID:efidroid,项目名称:android_app_efidroidmanager,代码行数:8,代码来源:IntentServiceEx.java

示例6: getEditorInfoDebugString

import android.util.StringBuilderPrinter; //导入依赖的package包/类
/**
 * @param editorInfo The EditorInfo
 * @return Debug string for the given {@EditorInfo}.
 */
static String getEditorInfoDebugString(EditorInfo editorInfo) {
    StringBuilder builder = new StringBuilder();
    StringBuilderPrinter printer = new StringBuilderPrinter(builder);
    editorInfo.dump(printer, "");
    return builder.toString();
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:ImeUtils.java

示例7: getPingResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getPingResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  PingDesc desc = (PingDesc) parameters;
  printer.println("[Ping]");
  printer.println("Target: " + desc.target);
  String ipAddress = removeQuotes(values.get("target_ip"));
  // TODO: internationalize 'Unknown'.
  if (ipAddress == null) {
    ipAddress = "Unknown";
  }
  printer.println("IP address: " + ipAddress);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    float packetLoss = Float.parseFloat(values.get("packet_loss"));
    int count = Integer.parseInt(values.get("packets_sent"));
    printer.println("\n" + count + " packets transmitted, " + (int) (count * (1 - packetLoss))
      + " received, " + (packetLoss * 100) + "% packet loss");

    float value = Float.parseFloat(values.get("mean_rtt_ms"));
    printer.println("Mean RTT: " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("min_rtt_ms"));
    printer.println("Min RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("max_rtt_ms"));
    printer.println("Max RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("stddev_rtt_ms"));
    printer.println("Std dev:  " + String.format("%.1f", value) + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Ping paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:37,代码来源:MeasurementResult.java

示例8: getUDPBurstResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getUDPBurstResult(StringBuilderPrinter printer, HashMap<String, String> values) {
    UDPBurstDesc desc = (UDPBurstDesc) parameters;
    if (desc.dirUp) {
      printer.println("[UDPBurstUp]");
    } else {
      printer.println("[UDPBurstDown]");
    }
    printer.println("Target: " + desc.target);
    printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
    printIPTestResult(printer);

    if (taskProgress == TaskProgress.COMPLETED) {
      printer.println("IP addr: " + values.get("target_ip"));
      printIPTestResult(printer);
//      printer.println("Packet size: " + desc.packetSizeByte + "B");
//      printer.println("Number of packets to be sent: " + desc.udpBurstCount);
//      printer.println("Interval between packets: " + desc.udpInterval + "ms");

      String lossRatio = String.format("%.2f", Double.parseDouble(values.get("loss_ratio")) * 100);
      String outOfOrderRatio =
          String.format("%.2f", Double.parseDouble(values.get("out_of_order_ratio")) * 100);
      printer.println("\nLoss ratio: " + lossRatio + "%");
      printer.println("Out of order ratio: " + outOfOrderRatio + "%");
      printer.println("Jitter: " + values.get("jitter") + "ms");
    } else if (taskProgress == TaskProgress.PAUSED) {
      printer.println("UDP Burst paused!");
    } else {
      printer.println("Error: " + values.get("error"));
    }
  }
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:31,代码来源:MeasurementResult.java

示例9: getRRCResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getRRCResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  printer.println("[RRC Inference]");
  if (taskProgress == TaskProgress.COMPLETED) {
    printer.println("Succeed!");
  }
  else {
    printer.println("Failed!");
  }
  printer.println("Results uploaded to server");
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:11,代码来源:MeasurementResult.java

示例10: getPingResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getPingResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  PingDesc desc = (PingDesc) measurementDesc;
  printer.println("[Ping]");
  printer.println("Target: " + desc.target);
  String ipAddress = removeQuotes(values.get("target_ip"));
  // TODO: internationalize 'Unknown'.
  if (ipAddress == null) {
    ipAddress = "Unknown";
  }
  printer.println("IP address: " + ipAddress);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    float packetLoss = Float.parseFloat(values.get("packet_loss"));
    int count = Integer.parseInt(values.get("packets_sent"));
    printer.println("\n" + count + " packets transmitted, " + (int) (count * (1 - packetLoss))
      + " received, " + (packetLoss * 100) + "% packet loss");

    float value = Float.parseFloat(values.get("mean_rtt_ms"));
    printer.println("Mean RTT: " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("min_rtt_ms"));
    printer.println("Min RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("max_rtt_ms"));
    printer.println("Max RTT:  " + String.format("%.1f", value) + " ms");

    value = Float.parseFloat(values.get("stddev_rtt_ms"));
    printer.println("Std dev:  " + String.format("%.1f", value) + " ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Ping paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:37,代码来源:MeasurementResult.java

示例11: getUDPBurstResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getUDPBurstResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  UDPBurstDesc desc = (UDPBurstDesc) measurementDesc;
  if (desc.dirUp) {
    printer.println("[UDPBurstUp]");
  } else {
    printer.println("[UDPBurstDown]");
  }
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    printer.println("IP addr: " + values.get("target_ip"));
    printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
    printIPTestResult(printer);
    printer.println("Packet size: " + desc.packetSizeByte + "B");
    printer.println("Number of packets to be sent: " + desc.udpBurstCount);
    printer.println("Interval between packets: " + desc.udpInterval + "ms");

    String lossRatio = String.format("%.2f", Double.parseDouble(values.get("loss_ratio")) * 100);
    String outOfOrderRatio =
        String.format("%.2f", Double.parseDouble(values.get("out_of_order_ratio")) * 100);
    printer.println("\nLoss ratio: " + lossRatio + "%");
    printer.println("Out of order ratio: " + outOfOrderRatio + "%");
    printer.println("Jitter: " + values.get("jitter") + "ms");
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("UDP Burst paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobiperf-Library,代码行数:32,代码来源:MeasurementResult.java

示例12: printSpans

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void printSpans(Spanned spanned) {
    StringBuilder builder = new StringBuilder();
    builder.append(spanned.toString());
    TextUtils.dumpSpans(spanned, new StringBuilderPrinter(builder), "");
    System.out.println(builder.toString());
}
 
开发者ID:Stocard,项目名称:markdown-to-spanned,代码行数:7,代码来源:SpanTests.java

示例13: describe

import android.util.StringBuilderPrinter; //导入依赖的package包/类
/**
 * Transforms an arbitrary view into a string with (hopefully) enough debug info.
 *
 * @param v nullable view
 * @return a string for human consumption.
 */
public static String describe(View v) {
    if (null == v) {
        return "null";
    }
    ToStringHelper helper = Objects.toStringHelper(v).add("id", v.getId());
    if (v.getId() != -1 && v.getResources() != null) {
        try {
            helper.add("res-name", v.getResources().getResourceEntryName(v.getId()));
        } catch (Resources.NotFoundException ignore) {
            // Do nothing.
        }
    }
    if (null != v.getContentDescription()) {
        helper.add("desc", v.getContentDescription());
    }

    switch (v.getVisibility()) {
        case View.GONE:
            helper.add("visibility", "GONE");
            break;
        case View.INVISIBLE:
            helper.add("visibility", "INVISIBLE");
            break;
        case View.VISIBLE:
            helper.add("visibility", "VISIBLE");
            break;
        default:
            helper.add("visibility", v.getVisibility());
    }

    helper.add("width", v.getWidth())
            .add("height", v.getHeight())
            .add("has-focus", v.hasFocus())
            .add("has-focusable", v.hasFocusable())
            .add("has-window-focus", v.hasWindowFocus())
            .add("is-clickable", v.isClickable())
            .add("is-enabled", v.isEnabled())
            .add("is-focused", v.isFocused())
            .add("is-focusable", v.isFocusable())
            .add("is-layout-requested", v.isLayoutRequested())
            .add("is-selected", v.isSelected());

    if (null != v.getRootView()) {
        // pretty much only true in unit-tests.
        helper.add("root-is-layout-requested", v.getRootView().isLayoutRequested());
    }

    EditorInfo ei = new EditorInfo();
    InputConnection ic = v.onCreateInputConnection(ei);
    boolean hasInputConnection = ic != null;
    helper.add("has-input-connection", hasInputConnection);
    if (hasInputConnection) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        Printer p = new StringBuilderPrinter(sb);
        ei.dump(p, "");
        sb.append("]");
        helper.add("editor-info", sb.toString().replace("\n", " "));
    }

    if (Build.VERSION.SDK_INT > 10) {
        helper.add("x", v.getX()).add("y", v.getY());
    }

    if (v instanceof TextView) {
        innerDescribe((TextView) v, helper);
    }
    if (v instanceof Checkable) {
        innerDescribe((Checkable) v, helper);
    }
    if (v instanceof ViewGroup) {
        innerDescribe((ViewGroup) v, helper);
    }
    return helper.toString();
}
 
开发者ID:DocuSignDev,项目名称:android-test-kit,代码行数:82,代码来源:HumanReadables.java

示例14: displayResults

import android.util.StringBuilderPrinter; //导入依赖的package包/类
public void displayResults(StringBuilderPrinter printer) {
  String DEL = "\t", toprint = DEL + DEL;
  for (int i = 1; i <= times.length; i++) {
    toprint += DEL + " | state" + i;
  }
  toprint += " |";
  int oneLineLen = toprint.length();
  toprint += "\n";
  // seperator
  for (int i = 0; i < oneLineLen; i++) {
    toprint += "-";
  }
  toprint += "\n";
  if (HTTP) {
    toprint += "HTTP (ms)" + DEL;
    for (int i = 0; i < httpTest.length; i++) {
      toprint += DEL + " | " + Integer.toString(httpTest[i]);
    }
    toprint += " |\n";
    for (int i = 0; i < oneLineLen; i++) {
      toprint += "-";
    }
    toprint += "\n";
  }

  if (DNS) {
    toprint += "DNS (ms)" + DEL;
    for (int i = 0; i < dnsTest.length; i++) {
      toprint += DEL + " | " + Integer.toString(dnsTest[i]);
    }
    toprint += " |\n";
    for (int i = 0; i < oneLineLen; i++) {
      toprint += "-";
    }
    toprint += "\n";
  }

  if (TCP) {
    toprint += "TCP (ms)" + DEL;
    for (int i = 0; i < tcpTest.length; i++) {
      toprint += DEL + " | " + Integer.toString(tcpTest[i]);
    }
    toprint += " |\n";
    for (int i = 0; i < oneLineLen; i++) {
      toprint += "-";
    }
    toprint += "\n";
  }

  toprint += "Timers (s)";
  for (int i = 0; i < times.length; i++) {
    double curTime = (double) times[i] * (double) GRANULARITY / 1000.0;
    toprint += DEL + " | " + String.format("%.2f", curTime);
  }
  toprint += " |\n";
  printer.println(toprint);
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:58,代码来源:RRCTask.java

示例15: getTracerouteResult

import android.util.StringBuilderPrinter; //导入依赖的package包/类
private void getTracerouteResult(StringBuilderPrinter printer, HashMap<String, String> values) {
  TracerouteDesc desc = (TracerouteDesc) parameters;
  printer.println("[Traceroute]");
  printer.println("Target: " + desc.target);
  printer.println("Timestamp: " + Util.getTimeStringFromMicrosecond(properties.timestamp));
  printIPTestResult(printer);

  if (taskProgress == TaskProgress.COMPLETED) {
    // Manually inject a new line
    printer.println(" ");

    int hops = Integer.parseInt(values.get("num_hops"));
    int hop_str_len = String.valueOf(hops + 1).length();
    for (int i = 0; i < hops; i++) {
      String key = "hop_" + i + "_addr_1";
      String ipAddress = removeQuotes(values.get(key));
      if (ipAddress == null) {
        ipAddress = "Unknown";
      }
      String hop_str = String.valueOf(i + 1);
      String hopInfo = hop_str;
      for (int j = 0; j < hop_str_len + 1 - hop_str.length(); ++j) {
        hopInfo += " ";
      }
      hopInfo += ipAddress;
      // Maximum IP address length is 15.
      for (int j = 0; j < 16 - ipAddress.length(); ++j) {
        hopInfo += " ";
      }

      key = "hop_" + i + "_rtt_ms";
      // The first and last character of this string are double
      // quotes.
      String timeStr = removeQuotes(values.get(key));
      if (timeStr == null) {
        timeStr = "Unknown";
      }

      float time = Float.parseFloat(timeStr);
      printer.println(hopInfo + String.format("%6.2f", time) + " ms");
    }
  } else if (taskProgress == TaskProgress.PAUSED) {
    printer.println("Traceroute paused!");
  } else {
    printer.println("Error: " + values.get("error"));
  }
}
 
开发者ID:laoyaosniper,项目名称:Mobilyzer,代码行数:48,代码来源:MeasurementResult.java


注:本文中的android.util.StringBuilderPrinter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。