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


Java Util类代码示例

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


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


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