In package com.eden.orchid.utilities

public final class OrchidUtils extends Object

public final

Constructors

OrchidUtils() public

Methods

String applyBaseUrl(OrchidContext context, String url) static public

Parameters:
String getRelativeFilename(String sourcePath, String baseDir) static public

Removes the base directory from a file path. Leading slashes are also removed from the resulting file path.

Parameters:
  • String sourcePath

    The original file path
  • String baseDir

    the base directory that should be removed from the original file path
String normalizePath(String path) static public

Replaces a string's OS-dependant file path-separator characters (File.separator) with '/', and also strips any slashes from the beginning and end of the string. This allows us to do path operations using the standard forward slash, bypassing any potential regex-related issues, and also makes it easy to split a path into its exact parts.

Parameters:
  • String path

    The path to normalize
Map<K, V> parseCommandLineArgs(String args) static public

Parse input in the forms of an array of key-arg mappings, such as `['-key1 val1', '-key2 val1 val2 val3']`, and converts it to its mapped form, like {'-key1': ['-key1', 'val1'], '-key2': ['-key2', 'val1', 'val2', 'val3']}. The keys are retained as the first item in the value arrays, and the key retains the dash at its start.

Parameters:
  • String args
Map<K, V> parseCommandArgs(String args, String paramKeys) static public

Parse input as entered on the command palette or in the Orchid interactive shell. The command input consists of two parts: the first is an ordered input, and the keys for the ordered values are given by `paramKeys`. The second consists of named key-arg mappings in the same format as used for the command-line flags. The resulting values for the named args do not retain the key in the value array, and the dash is stripped from the key. In addition, single values are lifted out an the array into single values. The two sections are separated by `--`. As as example: `val1 -- -key2 val1 val2 val3`, when parsed with paramKeys as `['key1']`, results in a mapped form like `{'key1': 'val1', 'key2': ['val1', 'val2', 'val3']}`.

Parameters:
  • String args

    the raw input text
  • String paramKeys

    the key names used for the ordered parameters
String toSlug(String pathPiece) static public

Converts a String to a URL-safe, or 'slug' version. This converts the input to lowercase and replaces all characters with dashes (-) except for alphaneumerics, dashes (-), underscores (_), and forward slashes (/).

Parameters:
  • String pathPiece

    the input to 'slugify'
void isExternal(String fileName) static public

Returns true if the input filename represents an external resource. Currently supports http:// and https://

Parameters:
  • String fileName

    the input to check if external
Object first(List<E> items) static public

Returns the first item in a list if possible, returning null otherwise.

Type Parameters:
Type Parameters
T the type of items in the list
Parameters:
  • List items

    the list
Object first(Stream<T> items) static public

Type Parameters:
Type Parameters
Parameters:
  • Stream items
void addExtraAssetsTo(OrchidContext context, String extraCss, String extraJs, AssetHolder holder, Object source, String sourceKey) static public

Parameters:
void addComponentAssets(OrchidPage containingPage, ComponentHolder componentHolders, List<E> assets, Function<T, R> getter) static public

Parameters:
Predicate<T> not(Predicate<T> t) static public

Type Parameters:
Type Parameters
Parameters:
  • Predicate t
Object firstBy(Stream<T> stream, Function<T, R> mapper) static public

Type Parameters:
Type Parameters
Parameters:
  • Stream stream
  • Function mapper
Object firstBy(Object items, Function<T, R> mapper) static public

Type Parameters:
Type Parameters
Parameters:
  • Object items
  • Function mapper
Object firstBy(Collection<E> items, Function<T, R> mapper) static public

Type Parameters:
Type Parameters
Parameters:
  • Collection items
  • Function mapper
void inArray(Object item, Object items, BiPredicate<T, U> condition) static public

Type Parameters:
Type Parameters
Parameters:
  • Object item
  • Object items
  • BiPredicate condition
Object transform(Object input, List<E> transformations) static public

Type Parameters:
Type Parameters
Parameters:
  • Object input
  • List transformations
String sha1(File file) static public

Parameters:
  • File file
String sha1(String text) static public

Parameters:
  • String text
String sha1(InputStream stream) static public

Parameters:
  • InputStream stream
Path getTempDir(String dirName) static public

Parameters:
  • String dirName
Path getTempDir(String baseDir, String dirName) static public

Parameters:
  • String baseDir
  • String dirName
Path getTempDir(String baseDir, String dirName, boolean asSiblingToBase) static public

Parameters:
  • String baseDir
  • String dirName
  • asSiblingToBase
void elementIsObject(JSONElement el) static public

Parameters:
void elementIsArray(JSONElement el) static public

Parameters:
void elementIsString(JSONElement el) static public

Parameters:
JSONObject merge(JSONObject sources) static public

Parameters:
  • JSONObject sources
String camelcaseToTitleCase(String camelcase) static public

Parameters:
  • String camelcase