Package be.ugent.rml
Class Utils
- java.lang.Object
-
- be.ugent.rml.Utils
-
public class Utils extends Object
General static utility functions
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
Modifier and Type Method Description static StringencodeURI(String url)static StringfileToString(File file)static StringgetBaseDirectiveTurtle(File file)static StringgetBaseDirectiveTurtle(InputStream is)static StringgetBaseDirectiveTurtle(String turtle)static FilegetFile(String path)static FilegetFile(String path, File basePath)static intgetFreePortNumber()static intgetHash(String query)static intgetHashOfString(String str)static InputStreamgetInputStreamFromFile(File file)static InputStreamgetInputStreamFromFileOrContentString(String s)Get an InputStream from a string.static InputStreamgetInputStreamFromLocation(String location)static InputStreamgetInputStreamFromLocation(String location, File basePath, String contentType)static InputStreamgetInputStreamFromURL(URL url)static InputStreamgetInputStreamFromURL(URL url, String contentType)static List<Term>getList(QuadStore store, Term first)static List<Term>getList(QuadStore store, Term first, List<Term> list)static List<String>getLiteralObjectsFromQuads(List<Quad> quads)static List<Term>getObjectsFromQuads(List<Quad> quads)static ReadergetReaderFromFile(File file)static ReadergetReaderFromLocation(String location)static ReadergetReaderFromLocation(String location, File basePath, String contentType)static ReadergetReaderFromURL(URL url)static ReadergetReaderFromURL(URL url, String contentType)static List<Term>getSubjectsFromQuads(List<Quad> quads)static StringgetURLParamsString(Map<String,String> params)static StringhashCode(String s)static booleanisRelativeIRI(String iri)This method returns true if a string is a relative IRI.static booleanisRemoteFile(String location)static booleanisValidIRI(String iri)This method returns true if a string is valid IRI.static booleanisValidrrLanguage(String s)Check if conforming to https://tools.ietf.org/html/bcp47#section-2.2.9static voidntriples2hdt(String rdfInputPath, String hdtOutputPath)static List<Extractor>parseTemplate(String template, boolean ignoreDoubleQuotes)This method parse the generic template and returns a list of Extractors that can later be used by the executor to get the data values from the records.static StringrandomString(int len)static StringreadFile(String path, Charset encoding)static intselectedColumnHash(String query)static StringtransformDatatypeString(String input, String datatype)
-
-
-
Method Detail
-
getReaderFromLocation
public static Reader getReaderFromLocation(String location) throws IOException
- Throws:
IOException
-
getReaderFromLocation
public static Reader getReaderFromLocation(String location, File basePath, String contentType) throws IOException
- Throws:
IOException
-
getInputStreamFromLocation
public static InputStream getInputStreamFromLocation(String location) throws IOException
- Throws:
IOException
-
getInputStreamFromLocation
public static InputStream getInputStreamFromLocation(String location, File basePath, String contentType) throws IOException
- Throws:
IOException
-
getInputStreamFromFileOrContentString
public static InputStream getInputStreamFromFileOrContentString(String s)
Get an InputStream from a string. This string is either a path (local or remote) to an RDF file, or a raw RDF text.- Parameters:
s- input, either RDF file path or raw RDF text- Returns:
- input stream
-
getFile
public static File getFile(String path) throws IOException
- Throws:
IOException
-
getFile
public static File getFile(String path, File basePath) throws IOException
- Throws:
IOException
-
getReaderFromURL
public static Reader getReaderFromURL(URL url) throws IOException
- Throws:
IOException
-
getReaderFromURL
public static Reader getReaderFromURL(URL url, String contentType) throws IOException
- Throws:
IOException
-
getReaderFromFile
public static Reader getReaderFromFile(File file) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getInputStreamFromURL
public static InputStream getInputStreamFromURL(URL url) throws IOException
- Throws:
IOException
-
getInputStreamFromURL
public static InputStream getInputStreamFromURL(URL url, String contentType)
-
getInputStreamFromFile
public static InputStream getInputStreamFromFile(File file) throws FileNotFoundException
- Throws:
FileNotFoundException
-
isRemoteFile
public static boolean isRemoteFile(String location)
-
isValidrrLanguage
public static boolean isValidrrLanguage(String s)
Check if conforming to https://tools.ietf.org/html/bcp47#section-2.2.9- Parameters:
s- language tag- Returns:
- True if valid language tag according to BCP 47
-
fileToString
public static String fileToString(File file) throws IOException
- Throws:
IOException
-
selectedColumnHash
public static int selectedColumnHash(String query)
-
getHash
public static int getHash(String query)
-
readFile
public static String readFile(String path, Charset encoding) throws IOException
- Throws:
IOException
-
getURLParamsString
public static String getURLParamsString(Map<String,String> params) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
getFreePortNumber
public static int getFreePortNumber() throws IOException- Throws:
IOException
-
parseTemplate
public static List<Extractor> parseTemplate(String template, boolean ignoreDoubleQuotes)
This method parse the generic template and returns a list of Extractors that can later be used by the executor to get the data values from the records.- Parameters:
template- template string- Returns:
- list of extractors
-
randomString
public static String randomString(int len)
-
isValidIRI
public static boolean isValidIRI(String iri)
This method returns true if a string is valid IRI.- Parameters:
iri- the IRI to validate.- Returns:
- true if the IRI is valid, else false.
-
isRelativeIRI
public static boolean isRelativeIRI(String iri)
This method returns true if a string is a relative IRI.- Parameters:
iri- the IRI to check.- Returns:
- true if the IRI is relative, else false.
-
getBaseDirectiveTurtle
public static String getBaseDirectiveTurtle(InputStream is)
-
transformDatatypeString
public static String transformDatatypeString(String input, String datatype)
-
getHashOfString
public static int getHashOfString(String str)
-
-