• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Util类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: executeSQL

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public Database.ExecuteSQLResponse executeSQL(String databaseName, String query, ExecuteResultHandler<Database.ExecuteSQLResponse> handler)
        throws SQLiteException {
    Util.throwIfNull(query);
    Util.throwIfNull(handler);
    SQLiteDatabase database = openDatabase(databaseName);
    try {
        String firstWordUpperCase = getFirstWord(query).toUpperCase();
        switch (firstWordUpperCase) {
            case "UPDATE":
            case "DELETE":
                return executeUpdateDelete(database, query, handler);
            case "INSERT":
                return executeInsert(database, query, handler);
            case "SELECT":
            case "PRAGMA":
            case "EXPLAIN":
                return executeSelect(database, query, handler);
            default:
                return executeRawQuery(database, query, handler);
        }
    } finally {
        database.close();
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:25,代码来源:RongDatabaseDriver.java


示例2: doKill

import com.facebook.stetho.common.Util; //导入依赖的package包/类
private void doKill(DumperContext dumpContext, Iterator<String> argsIter) throws DumpException {
  String signal = ArgsHelper.nextOptionalArg(argsIter, OPTION_KILL_DEFAULT);
  try {
    Process kill = new ProcessBuilder()
        .command("/system/bin/kill", "-" + signal, String.valueOf(android.os.Process.myPid()))
        .redirectErrorStream(true)
        .start();

    // Handle kill command output gracefully in the event that the signal delivered didn't
    // actually take out our process...
    try {
      InputStream in = kill.getInputStream();
      Util.copy(in, dumpContext.getStdout(), new byte[1024]);
    } finally {
      kill.destroy();
    }
  } catch (IOException e) {
    throw new DumpException("Failed to invoke kill: " + e);
  }
}
 
开发者ID:facebook,项目名称:stetho,代码行数:21,代码来源:CrashDumperPlugin.java


示例3: handlePipeOutput

import com.facebook.stetho.common.Util; //导入依赖的package包/类
private void handlePipeOutput(OutputStream output) throws DumpException {
  File hprofFile = mContext.getFileStreamPath("hprof-dump.hprof");
  try {
    writeHprof(hprofFile);
    try {
      InputStream input = new FileInputStream(hprofFile);
      try {
        Util.copy(input, output, new byte[2048]);
      } finally {
        input.close();
      }
    } catch (IOException e) {
      throw new DumpException("Failure copying " + hprofFile + " to dumper output");
    }
  } finally {
    if (hprofFile.exists()) {
      hprofFile.delete();
    }
  }
}
 
开发者ID:facebook,项目名称:stetho,代码行数:21,代码来源:HprofDumperPlugin.java


示例4: bindToSocket

import com.facebook.stetho.common.Util; //导入依赖的package包/类
@Nonnull
private static LocalServerSocket bindToSocket(String address) throws IOException {
  int retries = MAX_BIND_RETRIES;
  IOException firstException = null;
  do {
    try {
      if (LogUtil.isLoggable(Log.DEBUG)) {
        LogUtil.d("Trying to bind to @" + address);
      }
      return new LocalServerSocket(address);
    } catch (BindException be) {
      LogUtil.w(be, "Binding error, sleep " + TIME_BETWEEN_BIND_RETRIES_MS + " ms...");
      if (firstException == null) {
        firstException = be;
      }
      Util.sleepUninterruptibly(TIME_BETWEEN_BIND_RETRIES_MS);
    }
  } while (retries-- > 0);

  throw firstException;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:22,代码来源:LocalSocketServer.java


示例5: readFile

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public ResponseBodyData readFile(String requestId) throws IOException {
  InputStream in = mContext.openFileInput(getFilename(requestId));
  try {
    int firstByte = in.read();
    if (firstByte == -1) {
      throw new EOFException("Failed to read base64Encode byte");
    }
    ResponseBodyData bodyData = new ResponseBodyData();
    bodyData.base64Encoded = firstByte != 0;

    AsyncPrettyPrinter asyncPrettyPrinter = mRequestIdMap.get(requestId);
    if (asyncPrettyPrinter != null) {
      // TODO: this line blocks for up to 10 seconds and create problems as described
      // in issue #243 allow asynchronous dispatch for MethodDispatcher
      bodyData.data = prettyPrintContentWithTimeOut(asyncPrettyPrinter, in);
    } else {
      bodyData.data = Util.readAsUTF8(in);
    }
    return bodyData;

  } finally {
    in.close();
  }
}
 
开发者ID:facebook,项目名称:stetho,代码行数:25,代码来源:ResponseBodyFileManager.java


示例6: registerDescriptor

import com.facebook.stetho.common.Util; //导入依赖的package包/类
@Override
public DescriptorMap registerDescriptor(Class<?> elementClass, Descriptor descriptor) {
  Util.throwIfNull(elementClass);
  Util.throwIfNull(descriptor);
  Util.throwIf(descriptor.isInitialized());
  Util.throwIfNot(mIsInitializing);

  // Cannot register two descriptors for one class
  if (mMap.containsKey(elementClass)) {
    throw new UnsupportedOperationException();
  }

  // Cannot reuse one descriptor for two classes
  if (mMap.containsValue(descriptor)) {
    throw new UnsupportedOperationException();
  }

  mMap.put(elementClass, descriptor);
  return this;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:21,代码来源:DescriptorMap.java


示例7: endInit

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public DescriptorMap endInit() {
  Util.throwIfNot(mIsInitializing);
  Util.throwIfNull(mHost);

  mIsInitializing = false;

  for (final Class<?> elementClass : mMap.keySet()) {
    final Descriptor descriptor = mMap.get(elementClass);

    if (descriptor instanceof ChainedDescriptor) {
      final ChainedDescriptor chainedDescriptor = (ChainedDescriptor) descriptor;
      Class<?> superClass = elementClass.getSuperclass();
      Descriptor superDescriptor = getImpl(superClass);
      chainedDescriptor.setSuper(superDescriptor);
    }

    descriptor.initialize(mHost);
  }

  return this;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:22,代码来源:DescriptorMap.java


示例8: invokeMethod

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public void invokeMethod(String method, Object paramsObject,
    @Nullable PendingRequestCallback callback)
    throws NotYetConnectedException {
  Util.throwIfNull(method);

  Long requestId = (callback != null) ? preparePendingRequest(callback) : null;

  // magic, can basically convert anything for some amount of runtime overhead...
  JSONObject params = mObjectMapper.convertValue(paramsObject, JSONObject.class);

  JsonRpcRequest message = new JsonRpcRequest(requestId, method, params);
  String requestString;
  JSONObject jsonObject = mObjectMapper.convertValue(message, JSONObject.class);
  requestString = jsonObject.toString();
  mPeer.sendText(requestString);
}
 
开发者ID:facebook,项目名称:stetho,代码行数:17,代码来源:JsonRpcPeer.java


示例9: buildDispatchTable

import com.facebook.stetho.common.Util; //导入依赖的package包/类
private static Map<String, MethodDispatchHelper> buildDispatchTable(
    ObjectMapper objectMapper,
    Iterable<ChromeDevtoolsDomain> domainHandlers) {
  Util.throwIfNull(objectMapper);
  HashMap<String, MethodDispatchHelper> methods = new HashMap<String, MethodDispatchHelper>();
  for (ChromeDevtoolsDomain domainHandler : Util.throwIfNull(domainHandlers)) {
    Class<?> handlerClass = domainHandler.getClass();
    String domainName = handlerClass.getSimpleName();

    for (Method method : handlerClass.getDeclaredMethods()) {
      if (isDevtoolsMethod(method)) {
        MethodDispatchHelper dispatchHelper = new MethodDispatchHelper(
            objectMapper,
            domainHandler,
            method);
        methods.put(domainName + "." + method.getName(), dispatchHelper);
      }
    }
  }
  return Collections.unmodifiableMap(methods);
}
 
开发者ID:facebook,项目名称:stetho,代码行数:22,代码来源:MethodDispatcher.java


示例10: decorateRssItemsWithLinkImages

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public List<ApodItem> decorateRssItemsWithLinkImages(List<RssItem> rssItems) {
  ArrayList<ApodItem> apodItems = new ArrayList<>(rssItems.size());
  final CountDownLatch fetchLinkLatch = new CountDownLatch(rssItems.size());
  for (RssItem rssItem : rssItems) {
    final ApodItem apodItem = new ApodItem();
    apodItem.rssItem = rssItem;
    fetchLinkPage(rssItem.link, new PageScrapedCallback() {
      @Override
      public void onPageScraped(@Nullable List<String> imageUrls) {
        apodItem.largeImageUrl = imageUrls != null && !imageUrls.isEmpty()
            ? imageUrls.get(0)
            : null;
        fetchLinkLatch.countDown();
      }
    });
    apodItems.add(apodItem);
  }

  // Wait for all link fetches to complete, despite running them in parallel...
  Util.awaitUninterruptibly(fetchLinkLatch);

  return apodItems;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:24,代码来源:APODRssFetcher.java


示例11: decorateRssItemsWithLinkImages

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public List<ApodItem> decorateRssItemsWithLinkImages(List<RssItem> rssItems) {
    ArrayList<ApodItem> apodItems = new ArrayList<>(rssItems.size());
    final CountDownLatch fetchLinkLatch = new CountDownLatch(rssItems.size());
    for (RssItem rssItem : rssItems) {
        final ApodItem apodItem = new ApodItem();
        apodItem.rssItem = rssItem;
        fetchLinkPage(rssItem.link, new PageScrapedCallback() {
            @Override
            public void onPageScraped(@Nullable List<String> imageUrls) {
                apodItem.largeImageUrl = imageUrls != null && !imageUrls.isEmpty() ? imageUrls.get(0) : null;
                fetchLinkLatch.countDown();
            }
        });
        apodItems.add(apodItem);
    }

    // Wait for all link fetches to complete, despite running them in parallel...
    Util.awaitUninterruptibly(fetchLinkLatch);

    return apodItems;
}
 
开发者ID:BruceHurrican,项目名称:asstudydemo,代码行数:22,代码来源:APODRssFetcher.java


示例12: RIAndroidDocumentProviderFactory

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public RIAndroidDocumentProviderFactory(
    Application application,
    List<DescriptorProvider> descriptorProviders) {
  mApplication = Util.throwIfNull(application);
  mDescriptorProviders = Util.throwIfNull(descriptorProviders);
  mHandler = new Handler(Looper.getMainLooper());
}
 
开发者ID:nekocode,项目名称:ResourceInspector,代码行数:8,代码来源:RIAndroidDocumentProviderFactory.java


示例13: RIAndroidDocumentProvider

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public RIAndroidDocumentProvider(
        Application application,
        List<DescriptorProvider> descriptorProviders,
        ThreadBound enforcer) {
    super(enforcer);

    mApplication = Util.throwIfNull(application);
    mDocumentRoot = new RIAndroidDocumentRoot();

    mDescriptorMap = new DescriptorMap()
            .beginInit()
            .registerDescriptor(RIAndroidDocumentRoot.class, mDocumentRoot)
            .registerDescriptor(Activity.class, new ActivityDescriptor())
            .registerDescriptor(Window.class, new WindowDescriptor())
            .registerDescriptor(Dialog.class, new DialogDescriptor())
            .registerDescriptor(View.class, new RIViewDescriptor())
            .registerDescriptor(ViewGroup.class, new ViewGroupDescriptor())
            .registerDescriptor(RINoActivatedActivityDescriptor.class, new RINoActivatedActivityDescriptor())
            .registerDescriptor(Object.class, new ObjectDescriptor());

    DialogFragmentDescriptor.register(mDescriptorMap);
    RIFragmentDescriptor.register(mDescriptorMap);

    for (int i = 0, size = descriptorProviders.size(); i < size; ++i) {
        final DescriptorProvider descriptorProvider = descriptorProviders.get(i);
        descriptorProvider.registerDescriptor(mDescriptorMap);
    }

    mDescriptorMap.setHost(this).endInit();

    mHighlighter = ViewHighlighter.newInstance();
    mInspectModeHandler = new InspectModeHandler();
}
 
开发者ID:nekocode,项目名称:ResourceInspector,代码行数:34,代码来源:RIAndroidDocumentProvider.java


示例14: DumperContext

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public DumperContext(
    InputStream stdin,
    PrintStream stdout,
    PrintStream stderr,
    CommandLineParser parser,
    List<String> args) {
  mStdin = Util.throwIfNull(stdin);
  mStdout = Util.throwIfNull(stdout);
  mStderr = Util.throwIfNull(stderr);
  mParser = Util.throwIfNull(parser);
  mArgs = Util.throwIfNull(args);
}
 
开发者ID:facebook,项目名称:stetho,代码行数:13,代码来源:DumperContext.java


示例15: LocalSocketServer

import com.facebook.stetho.common.Util; //导入依赖的package包/类
/**
 * @param friendlyName identifier to help debug this server, used for naming threads and such.
 * @param address the local socket address to listen on.
 * @param socketHandler functional handler once a socket is accepted.
 */
public LocalSocketServer(
    String friendlyName,
    String address,
    SocketHandler socketHandler) {
  mFriendlyName = Util.throwIfNull(friendlyName);
  mAddress = Util.throwIfNull(address);
  mSocketHandler = socketHandler;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:14,代码来源:LocalSocketServer.java


示例16: DOM

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public DOM(Document document) {
  mObjectMapper = new ObjectMapper();
  mDocument = Util.throwIfNull(document);
  mSearchResults = Collections.synchronizedMap(
    new HashMap<String, List<Integer>>());
  mResultCounter = new AtomicInteger(0);
  mPeerManager = new ChromePeerManager();
  mPeerManager.setListener(new PeerManagerListener());
  mListener = new DocumentUpdateListener();
}
 
开发者ID:facebook,项目名称:stetho,代码行数:11,代码来源:DOM.java


示例17: flattenRows

import com.facebook.stetho.common.Util; //导入依赖的package包/类
/**
 * Flatten all columns and all rows of a cursor to a single array.  The array cannot be
 * interpreted meaningfully without the number of columns.
 *
 * @param cursor
 * @param limit Maximum number of rows to process.
 * @return List of Java primitives matching the value type of each column, converted to
 *      strings.
 */
private static ArrayList<String> flattenRows(Cursor cursor, int limit) {
  Util.throwIfNot(limit >= 0);
  ArrayList<String> flatList = new ArrayList<>();
  final int numColumns = cursor.getColumnCount();
  for (int row = 0; row < limit && cursor.moveToNext(); row++) {
    for (int column = 0; column < numColumns; column++) {
      switch (cursor.getType(column)) {
        case Cursor.FIELD_TYPE_NULL:
          flatList.add(null);
          break;
        case Cursor.FIELD_TYPE_INTEGER:
          flatList.add(String.valueOf(cursor.getLong(column)));
          break;
        case Cursor.FIELD_TYPE_FLOAT:
          flatList.add(String.valueOf(cursor.getDouble(column)));
          break;
        case Cursor.FIELD_TYPE_BLOB:
          flatList.add(blobToString(cursor.getBlob(column)));
          break;
        case Cursor.FIELD_TYPE_STRING:
        default:
          flatList.add(cursor.getString(column));
          break;
      }
    }
  }
  if (!cursor.isAfterLast()) {
    for (int column = 0; column < numColumns; column++) {
      flatList.add("{truncated}");
    }
  }
  return flatList;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:43,代码来源:Database.java


示例18: call

import com.facebook.stetho.common.Util; //导入依赖的package包/类
@Override
public Void call() throws IOException {
  GZIPInputStream in = new GZIPInputStream(mIn);
  try {
    Util.copy(in, mOut, new byte[1024]);
  } finally {
    in.close();
    mOut.close();
  }
  return null;
}
 
开发者ID:facebook,项目名称:stetho,代码行数:12,代码来源:GunzippingOutputStream.java


示例19: call

import com.facebook.stetho.common.Util; //导入依赖的package包/类
@Override
public String call() throws IOException {
  HttpURLConnection connection = (HttpURLConnection)url.openConnection();
  int statusCode = connection.getResponseCode();
  if (statusCode != 200) {
    throw new IOException("Got status code: " + statusCode + " while downloading " +
        "schema with url: " + url.toString());
  }
  InputStream urlStream = connection.getInputStream();
  try {
    return Util.readAsUTF8(urlStream);
  } finally {
    urlStream.close();
  }
}
 
开发者ID:facebook,项目名称:stetho,代码行数:16,代码来源:DownloadingAsyncPrettyPrinterFactory.java


示例20: AndroidDocumentProvider

import com.facebook.stetho.common.Util; //导入依赖的package包/类
public AndroidDocumentProvider(
    Application application,
    List<DescriptorProvider> descriptorProviders,
    ThreadBound enforcer) {
  super(enforcer);

  mApplication = Util.throwIfNull(application);
  mDocumentRoot = new AndroidDocumentRoot(application);

  mDescriptorMap = new DescriptorMap()
      .beginInit()
      .registerDescriptor(Activity.class, new ActivityDescriptor())
      .registerDescriptor(AndroidDocumentRoot.class, mDocumentRoot)
      .registerDescriptor(Application.class, new ApplicationDescriptor())
      .registerDescriptor(Dialog.class, new DialogDescriptor())
      .registerDescriptor(Object.class, new ObjectDescriptor())
      .registerDescriptor(TextView.class, new TextViewDescriptor())
      .registerDescriptor(View.class, new ViewDescriptor())
      .registerDescriptor(ViewGroup.class, new ViewGroupDescriptor())
      .registerDescriptor(Window.class, new WindowDescriptor());

  DialogFragmentDescriptor.register(mDescriptorMap);
  FragmentDescriptor.register(mDescriptorMap);

  for (int i = 0, size = descriptorProviders.size(); i < size; ++i) {
    final DescriptorProvider descriptorProvider = descriptorProviders.get(i);
    descriptorProvider.registerDescriptor(mDescriptorMap);
  }

  mDescriptorMap.setHost(this).endInit();

  mHighlighter = ViewHighlighter.newInstance();
  mInspectModeHandler = new InspectModeHandler();
}
 
开发者ID:facebook,项目名称:stetho,代码行数:35,代码来源:AndroidDocumentProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LayerCape类代码示例发布时间:2022-05-23
下一篇:
Java DoubleProperty类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap