Package org.lightcouch
Class CouchDbUtil
java.lang.Object
org.lightcouch.CouchDbUtil
Provides various utility methods, for internal use.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertNotEmpty(Object object, String prefix) static voidassertNull(Object object, String prefix) static voidCloses a resource.static voidclose(org.apache.http.HttpResponse response) Closes the response input stream.static Stringstatic intstatic longstatic StringgetAsString(com.google.gson.JsonObject j, String e) static InputStreamgetStream(org.apache.http.HttpResponse response) static <T> TJsonToObject(com.google.gson.Gson gson, com.google.gson.JsonElement elem, String key, Class<T> classType) listResources(String path) List directory contents for a resource folder.static Stringstatic StringremoveExtension(String fileName) static String
-
Field Details
-
LINE_SEP
-
SPRING_BOOT_DIR
- See Also:
-
-
Constructor Details
-
CouchDbUtil
private CouchDbUtil()
-
-
Method Details
-
assertNotEmpty
- Throws:
IllegalArgumentException
-
assertNull
- Throws:
IllegalArgumentException
-
generateUUID
-
JsonToObject
-
getAsString
- Returns:
- A JSON element as a String, or null if not found.
-
getAsLong
- Returns:
- A JSON element as
long, or0if not found.
-
getAsInt
- Returns:
- A JSON element as
int, or0if not found.
-
listResources
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
-
getStream
- Returns:
InputStreamofHttpResponse
-
removeExtension
-
streamToString
-
close
public static void close(org.apache.http.HttpResponse response) Closes the response input stream.- Parameters:
response- TheHttpResponse
-
close
Closes a resource.- Parameters:
c- TheCloseableresource.
-