org.eclipse.rdf4j.console

## Class Util

- java.lang.Object
- - org.eclipse.rdf4j.console.Util

-     public class Util
      extends Object

  Helper class
  Author:
    Bart Hanssens

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Util()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `formatToWidth(int width, String padding, String str, String separator)` Deprecated.
    `static Resource` | `getContext(Repository repository, String ctxID)` Get context IRI from string representation
    `static 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` | `getPath(String file)` 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Util

          public Util()

  - ### Method Detail

    - #### getContext

          public static Resource getContext(Repository repository,
                                            String ctxID)

      Get context IRI from string representation
      Parameters:
        `repository` - repository
        `ctxID` - 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 tokens
        `pos` - position to start from
        `repository` - repository
      Returns:
        array of contexts or null for default context
      Throws:
        `IllegalArgumentException`

    - #### getPath

          @Deprecated
          public static Path getPath(String file)

      Deprecated.
      Get path from file or URI
      Parameters:
        `file` - file name
      Returns:
        path or null

    - #### isHttpOrFile

          public static boolean isHttpOrFile(String str)

      Check if a string looks like a HTTP, HTTPS or file URI.
      Parameters:
        `str` - string
      Returns:
        true if

    - #### getNormalizedPath

          public 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.
      Parameters:
        `workDir` - working dir
        `file` - file name
      Returns:
        path normalized path

    - #### getPrefixedValue

          public static String getPrefixedValue(Value value,
                                                Map<String,String> namespaces)

      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` - value
        `namespaces` - 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 width
        `padding` - left padding
        `str` - joined string
        `separator` - value separator
      Returns:
        list of values as a formatted string, or empty

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.