Package com.easypost.easyvcr.internal
Class Utilities
java.lang.Object
com.easypost.easyvcr.internal.Utilities
Internal tools for EasyVCR.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamcopyInputStream(InputStream stream)Make a copy of an input stream (resetting the position to 0).static InputStreamcreateInputStream(String string)Create an input stream from a string.static OutputStreamcreateOutputStream(String string)Create an output stream from a string.static StringextractPathFromUri(URI uri)Extract the path from a URI.static FileGet a File object from a path.static StringgetFilePath(String folderPath, String fileName)Get a file path from a folder-file pair.static booleanisDictionary(Object obj)Check if the object is a dictionary.static booleanCheck if the object is a list.static List<ApachePatch.NameValuePair>mapToQueryParameters(Map<String,String> map)Convert a map to a query parameters string.queryParametersToMap(URI uri)Convert a URI's query parameters to a Map.static StringreadFromInputStream(InputStream stream)Read the contents of an input stream into a string.static StringremoveJsonElements(String json, List<CensorElement> elements)Remove elements from a JSON string.static voidsimulateDelay(HttpInteraction interaction, AdvancedSettings advancedSettings)Sleep the current thread for a specified number of milliseconds.static StringtoBase64String(String input)Get the base64 representation of a string.
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
getFile
Get a File object from a path.- Parameters:
filePath- The path to the file.- Returns:
- The File object.
-
getFilePath
Get a file path from a folder-file pair.- Parameters:
folderPath- The folder path.fileName- The file name.- Returns:
- The file path.
-
toBase64String
Get the base64 representation of a string.- Parameters:
input- The string to encode.- Returns:
- The base64 representation of the string.
-
createInputStream
Create an input stream from a string.- Parameters:
string- The string to create the input stream from.- Returns:
- The input stream.
-
createOutputStream
Create an output stream from a string.- Parameters:
string- The string to create the output stream from.- Returns:
- The output stream.
- Throws:
IOException
-
copyInputStream
Make a copy of an input stream (resetting the position to 0).- Parameters:
stream- The input stream to copy.- Returns:
- A copy of the input stream.
-
readFromInputStream
Read the contents of an input stream into a string.- Parameters:
stream- The input stream to read.- Returns:
- The contents of the input stream as a string.
-
mapToQueryParameters
Convert a map to a query parameters string.- Parameters:
map- The map to convert.- Returns:
- The query parameters string.
-
queryParametersToMap
Convert a URI's query parameters to a Map.- Parameters:
uri- The URI.- Returns:
- The Map of query parameters.
-
simulateDelay
public static void simulateDelay(HttpInteraction interaction, AdvancedSettings advancedSettings) throws InterruptedExceptionSleep the current thread for a specified number of milliseconds.- Parameters:
interaction- The interaction used to determine the number of milliseconds to sleep.advancedSettings- The advanced settings used to determine the number of milliseconds to sleep.- Throws:
InterruptedException- If the thread is interrupted.
-
isDictionary
Check if the object is a dictionary.- Parameters:
obj- The object to check.- Returns:
- True if the object is a dictionary.
-
isList
Check if the object is a list.- Parameters:
obj- The object to check.- Returns:
- True if the object is a list.
-
removeJsonElements
Remove elements from a JSON string.- Parameters:
json- The JSON string to remove elements from.elements- The elements to remove.- Returns:
- The JSON string without the elements.
-
extractPathFromUri
Extract the path from a URI.- Parameters:
uri- The URI to extract the path from.- Returns:
- The path.
-