Class CouchDbUtil

java.lang.Object
org.lightcouch.CouchDbUtil

final class CouchDbUtil extends Object
Provides various utility methods, for internal use.
  • Field Details

  • Constructor Details

    • CouchDbUtil

      private CouchDbUtil()
  • Method Details

    • assertNotEmpty

      public static void assertNotEmpty(Object object, String prefix) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • assertNull

      public static void assertNull(Object object, String prefix) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • generateUUID

      public static String generateUUID()
    • JsonToObject

      public static <T> T JsonToObject(com.google.gson.Gson gson, com.google.gson.JsonElement elem, String key, Class<T> classType)
    • getAsString

      public static String getAsString(com.google.gson.JsonObject j, String e)
      Returns:
      A JSON element as a String, or null if not found.
    • getAsLong

      public static long getAsLong(com.google.gson.JsonObject j, String e)
      Returns:
      A JSON element as long, or 0 if not found.
    • getAsInt

      public static int getAsInt(com.google.gson.JsonObject j, String e)
      Returns:
      A JSON element as int, or 0 if not found.
    • listResources

      public static List<String> listResources(String path)
      List directory contents for a resource folder. Not recursive. This is basically a brute-force implementation. Works for regular files and also JARs.
      Parameters:
      path - Should end with "/", but not start with one.
      Returns:
      Just the name of each member item, not the full paths.
    • readFile

      public static String readFile(String path)
    • getStream

      public static InputStream getStream(org.apache.http.HttpResponse response)
      Returns:
      InputStream of HttpResponse
    • removeExtension

      public static String removeExtension(String fileName)
    • streamToString

      public static String streamToString(InputStream in)
    • close

      public static void close(org.apache.http.HttpResponse response)
      Closes the response input stream.
      Parameters:
      response - The HttpResponse
    • close

      public static void close(Closeable c)
      Closes a resource.
      Parameters:
      c - The Closeable resource.