Package uk.gov.gchq.gaffer.commonutil
Class StreamUtil
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.StreamUtil
-
public final class StreamUtil extends Object
Utility methods for openingInputStreams.
-
-
Field Summary
Fields Modifier and Type Field Description static StringELEMENTS_SCHEMAstatic StringFAILED_TO_CREATE_INPUT_STREAM_FOR_PATHstatic StringGRAPH_CONFIGstatic StringLOG_FAILED_TO_CREATE_INPUT_STREAM_FOR_PATHstatic StringSCHEMAstatic StringSCHEMA_FOLDERstatic StringSTORE_PROPERTIESstatic StringTYPES_SCHEMAstatic StringVIEW
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcloseStreams(InputStream... inputStreams)Safely close the supplied list ofInputStreams.static InputStreamelementsSchema(Class clazz)Open the elements schema file located at the same location as the provided class.static StringformatPathForOpenStream(String path)Format a path to ensure that it begins with a '/' character.static InputStreamgraphConfig(Class clazz)Open the graph config file located at the same location as the provided class.static InputStreamopenStream(Class clazz, String path)Open the file found at the the specified path under the location of the given class.static InputStreamopenStream(URI uri)Create anInputStreams from the providedURI.static InputStream[]openStreams(Class clazz, String folderPath)Open all of the files found in the specified subdirectory of the provided class.static InputStream[]openStreams(URI... uris)Create an array ofInputStreams from the provided list ofURIs.static InputStreamschema(Class clazz)Open the schema file located at the same location as the provided class.static InputStream[]schemas(Class clazz)Open the schema files located at the same location as the provided class.static InputStreamstoreProps(Class clazz)Open the store properties file located at the same location as the provided class.static InputStreamtypesSchema(Class clazz)Open the types schema file located at the same location as the provided class.static InputStreamview(Class clazz)Open the view file located at the same location as the provided class.
-
-
-
Field Detail
-
VIEW
public static final String VIEW
- See Also:
- Constant Field Values
-
SCHEMA_FOLDER
public static final String SCHEMA_FOLDER
- See Also:
- Constant Field Values
-
SCHEMA
public static final String SCHEMA
- See Also:
- Constant Field Values
-
ELEMENTS_SCHEMA
public static final String ELEMENTS_SCHEMA
- See Also:
- Constant Field Values
-
TYPES_SCHEMA
public static final String TYPES_SCHEMA
- See Also:
- Constant Field Values
-
STORE_PROPERTIES
public static final String STORE_PROPERTIES
- See Also:
- Constant Field Values
-
GRAPH_CONFIG
public static final String GRAPH_CONFIG
- See Also:
- Constant Field Values
-
FAILED_TO_CREATE_INPUT_STREAM_FOR_PATH
public static final String FAILED_TO_CREATE_INPUT_STREAM_FOR_PATH
- See Also:
- Constant Field Values
-
LOG_FAILED_TO_CREATE_INPUT_STREAM_FOR_PATH
public static final String LOG_FAILED_TO_CREATE_INPUT_STREAM_FOR_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
graphConfig
public static InputStream graphConfig(Class clazz)
Open the graph config file located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the graph config file- Returns:
- an
InputStreamrepresenting the graph config file
-
view
public static InputStream view(Class clazz)
Open the view file located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the view file- Returns:
- an
InputStreamrepresenting the view file
-
schemas
public static InputStream[] schemas(Class clazz)
Open the schema files located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the schema files- Returns:
- an array of
InputStreams representing the schema files
-
schema
public static InputStream schema(Class clazz)
Open the schema file located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the schema file- Returns:
- an
InputStreamrepresenting the schema file
-
elementsSchema
public static InputStream elementsSchema(Class clazz)
Open the elements schema file located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the elements schema file- Returns:
- an
InputStreamrepresenting the elements schema file
-
typesSchema
public static InputStream typesSchema(Class clazz)
Open the types schema file located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the types schema file- Returns:
- an
InputStreamrepresenting the types schema file
-
storeProps
public static InputStream storeProps(Class clazz)
Open the store properties file located at the same location as the provided class.- Parameters:
clazz- the class determining the location of the store properties file- Returns:
- an
InputStreamrepresenting the store properties file
-
openStreams
public static InputStream[] openStreams(Class clazz, String folderPath)
Open all of the files found in the specified subdirectory of the provided class.- Parameters:
clazz- the class locationfolderPath- the subdirectory in the class location- Returns:
- an array of
InputStreams representing the files found
-
openStreams
public static InputStream[] openStreams(URI... uris) throws IOException
Create an array ofInputStreams from the provided list ofURIs.- Parameters:
uris- the URIs to open as input streams- Returns:
- an array of input streams
- Throws:
IOException- if there was an error opening the streams
-
openStream
public static InputStream openStream(URI uri) throws IOException
Create anInputStreams from the providedURI.- Parameters:
uri- the URI to open as an input stream- Returns:
- an input streams
- Throws:
IOException- if there was an error opening the stream
-
closeStreams
public static int closeStreams(InputStream... inputStreams)
Safely close the supplied list ofInputStreams.- Parameters:
inputStreams- the input streams to close- Returns:
- an integer indicating the number of streams which were successfully closed.
-
openStream
public static InputStream openStream(Class clazz, String path) throws IllegalArgumentException
Open the file found at the the specified path under the location of the given class.- Parameters:
clazz- the class locationpath- the path in the class location- Returns:
- an input stream representating the requested file
- Throws:
IllegalArgumentException- if there was an error opening the stream
-
-