Package org.eclipse.rdf4j.console
Class Util
java.lang.Object
org.eclipse.rdf4j.console.Util
Helper class
- Author:
- Bart Hanssens
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatToWidth
(int width, String padding, String str, String separator) Deprecated.static Resource
getContext
(Repository repository, String ctxID) Get context IRI from string representationstatic Resource[]
getContexts
(String[] tokens, int pos, Repository repository) Get context IRIs from a series of tokens, starting from (zero-based) position within the series.static Path
getNormalizedPath
(Path workDir, String file) Get path from file string if it's absolute, or from working directory if the file is relative.static Path
Deprecated.static String
getPrefixedValue
(Value value, Map<String, String> namespaces) Get string representation for a value.static boolean
isHttpOrFile
(String str) Check if a string looks like a HTTP, HTTPS or file URI.
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
getContext
Get context IRI from string representation- Parameters:
repository
- repositoryctxID
- context as string- Returns:
- context IRI
-
getContexts
public static Resource[] getContexts(String[] tokens, int pos, Repository repository) throws IllegalArgumentException Get context IRIs from a series of tokens, starting from (zero-based) position within the series.- Parameters:
tokens
- command as series of tokenspos
- position to start fromrepository
- repository- Returns:
- array of contexts or null for default context
- Throws:
IllegalArgumentException
-
getPath
Deprecated.Get path from file or URI- Parameters:
file
- file name- Returns:
- path or null
-
isHttpOrFile
Check if a string looks like a HTTP, HTTPS or file URI.- Parameters:
str
- string- Returns:
- true if
-
getNormalizedPath
Get path from file string if it's absolute, or from working directory if the file is relative.- Parameters:
workDir
- working dirfile
- file name- Returns:
- path normalized path
-
getPrefixedValue
Get string representation for a value. If the value is an IRI and is part of a known namespace, the prefix will be used to shorten it.- Parameters:
value
- valuenamespaces
- mapping (uri,prefix)- Returns:
- string representation
-
formatToWidth
@Deprecated public static String formatToWidth(int width, String padding, String str, String separator) Deprecated.Format a string of values, starting new line(s) when the joined values exceed the width. Primarily used for displaying formatted help (e.g namespaces, config files) to the console. To be replaced by a commons text method- Parameters:
width
- maximum column widthpadding
- left paddingstr
- joined stringseparator
- value separator- Returns:
- list of values as a formatted string, or empty
-