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 openingInputStream
s.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ELEMENTS_SCHEMA
static String
FAILED_TO_CREATE_INPUT_STREAM_FOR_PATH
static String
GRAPH_CONFIG
static String
LOG_FAILED_TO_CREATE_INPUT_STREAM_FOR_PATH
static String
SCHEMA
static String
SCHEMA_FOLDER
static String
STORE_PROPERTIES
static String
TYPES_SCHEMA
static String
VIEW
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
closeStreams(InputStream... inputStreams)
Safely close the supplied list ofInputStream
s.static InputStream
elementsSchema(Class clazz)
Open the elements schema file located at the same location as the provided class.static String
formatPathForOpenStream(String path)
Format a path to ensure that it begins with a '/' character.static InputStream
graphConfig(Class clazz)
Open the graph config file located at the same location as the provided class.static InputStream
openStream(Class clazz, String path)
Open the file found at the the specified path under the location of the given class.static InputStream
openStream(URI uri)
Create anInputStream
s 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 ofInputStream
s from the provided list ofURI
s.static InputStream
schema(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 InputStream
storeProps(Class clazz)
Open the store properties file located at the same location as the provided class.static InputStream
typesSchema(Class clazz)
Open the types schema file located at the same location as the provided class.static InputStream
view(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
InputStream
representing 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
InputStream
representing 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
InputStream
s 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
InputStream
representing 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
InputStream
representing 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
InputStream
representing 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
InputStream
representing 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
InputStream
s representing the files found
-
openStreams
public static InputStream[] openStreams(URI... uris) throws IOException
Create an array ofInputStream
s from the provided list ofURI
s.- 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 anInputStream
s 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 ofInputStream
s.- 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
-
-