Rabbit Escape  2017-01-14_18:33:47_+0000__(tag:_v0.10.1)
Classes | Static Public Member Functions | Static Private Member Functions | List of all members
rabbitescape.engine.util.Util Class Reference

Classes

interface  Function
 
class  IdxObj
 
class  MissingResource
 
class  ReaderIterator
 
class  ReadingResourceFailed
 
class  UntilNullIterator
 

Static Public Member Functions

static void reAssert (boolean assertion)
 
static void reAssert (boolean assertion, String message)
 
static< T > T getNth (Iterable< T > input, int n)
 
static< T, R > Iterable< R > map (Function< T, R > function, Iterable< T > iterable)
 
static< T, R > Iterable< R > map (Function< T, R > function, T[] input)
 
static< T, R > R[] map (Function< T, R > function, T[] input, R[] retType)
 
static< T > List< T > list (Iterable< T > input)
 
static< T > List< T > list (T[] input)
 
static< T > List< T > list (Iterator< T > input)
 
static< T > List< T > filterIn (Iterable< T > i, Class<?extends T > filter)
 
static< T > List< T > filterOut (Iterable< T > i, Class<?extends T > filter)
 
static String[] stringArray (List< String > list)
 
static String[] stringArray (Iterable< String > items)
 
static Character[] characterArray (List< Character > list)
 
static Character[] characterArray (Iterable< Character > items)
 
static Integer[] integerArray (List< Integer > list)
 
static Integer[] integerArray (Iterable< Integer > items)
 
static Map< String, Object > newMap (String...keysAndValues)
 
static< T > Set< T > newSet (T...items)
 
static Iterable< Character > asChars (final String str)
 
static String stringFromChars (Iterable< Character > chars)
 
static String[] wrap (String s, int maxChar)
 Split a long string into lines. More...
 
static String wrapToNewline (String s, int maxChar)
 
static String join (String glue, Object[] items)
 
static String join (String glue, String[] items)
 
static< T > String join (String glue, Iterable< T > items)
 
static String[] split (String input, String delimiter)
 
static String[] split (String input, String delimiter, int maxSplits)
 
static Iterable< Integer > range (final int max)
 
static< T > Iterable< T > chain (final Iterable<?extends T >...itArray)
 
static< T > Iterable< T > filter (final Function< T, Boolean > predicate, final Iterable< T > input)
 
static Function< String, String > stripLast (final int i)
 
static Function< String, Boolean > endsWith (final String suffix)
 
static< T > Iterable< T > sorted (Iterable< T > input)
 
static Iterable< String > streamLines (InputStream input)
 
static Iterable< String > resourceLines (String name)
 
static< T > T[] concat (T[] a, T[] b, T[] c, T[] d)
 
static< T > T[] concat (T[] a, T[] b, T[] c)
 
static< T > T[] concat (T[] a, T[] b)
 
static< T > boolean equalsOrBothNull (T left, T right)
 
static boolean isEmpty (String str)
 
static< T > List< String > toStringList (T[] values)
 
static< T > Iterable< IdxObj< T > > enumerate1 (final T[] array)
 
static< T > Iterable< IdxObj< T > > enumerate (final T[] array)
 
static< T > Iterable< IdxObj< T > > enumerate1 (final Iterable< T > i)
 
static< T > Iterable< IdxObj< T > > enumerate (final Iterable< T > i)
 
static String regexRemovePreserveGroup (String s, String regex, int patternFlags)
 Replace all matches, but preserves the first capturing group. Compare to String.replaceAll, which replaces the whole match. More...
 
static String regexRemovePreserveGroup (String s, String regex)
 
static String regexReplace (String s, String regex, String replacement)
 

Static Private Member Functions

static Iterable< String > streamLines (final String name, final InputStream input)
 
static< T > Iterable< IdxObj< T > > enumerateN (final Iterable< T > i, final int startAtIndex)
 

Member Function Documentation

static Iterable<Character> rabbitescape.engine.util.Util.asChars ( final String  str)
static
static <T> Iterable<T> rabbitescape.engine.util.Util.chain ( final Iterable<?extends T >...  itArray)
static

This can be used to chain objects of different types (unlike concat). The returned Iterable will be of the first common superclass.

Iterator of Iterators

The current sub-Iterator

static Character [] rabbitescape.engine.util.Util.characterArray ( List< Character >  list)
static
static Character [] rabbitescape.engine.util.Util.characterArray ( Iterable< Character >  items)
static
static <T> T [] rabbitescape.engine.util.Util.concat ( T[]  a,
T[]  b,
T[]  c,
T[]  d 
)
static
static <T> T [] rabbitescape.engine.util.Util.concat ( T[]  a,
T[]  b,
T[]  c 
)
static
static <T> T [] rabbitescape.engine.util.Util.concat ( T[]  a,
T[]  b 
)
static

Use chain instead for arguments of different classes.

static Function<String, Boolean> rabbitescape.engine.util.Util.endsWith ( final String  suffix)
static
static <T> Iterable<IdxObj<T> > rabbitescape.engine.util.Util.enumerate ( final T[]  array)
static
static <T> Iterable<IdxObj<T> > rabbitescape.engine.util.Util.enumerate ( final Iterable< T >  i)
static
static <T> Iterable<IdxObj<T> > rabbitescape.engine.util.Util.enumerate1 ( final T[]  array)
static
static <T> Iterable<IdxObj<T> > rabbitescape.engine.util.Util.enumerate1 ( final Iterable< T >  i)
static
static <T> Iterable<IdxObj<T> > rabbitescape.engine.util.Util.enumerateN ( final Iterable< T >  i,
final int  startAtIndex 
)
staticprivate
static <T> boolean rabbitescape.engine.util.Util.equalsOrBothNull ( left,
right 
)
static
static <T> Iterable<T> rabbitescape.engine.util.Util.filter ( final Function< T, Boolean >  predicate,
final Iterable< T >  input 
)
static
static <T> List<T> rabbitescape.engine.util.Util.filterIn ( Iterable< T >  i,
Class<?extends T >  filter 
)
static
static <T> List<T> rabbitescape.engine.util.Util.filterOut ( Iterable< T >  i,
Class<?extends T >  filter 
)
static
static <T> T rabbitescape.engine.util.Util.getNth ( Iterable< T >  input,
int  n 
)
static
static Integer [] rabbitescape.engine.util.Util.integerArray ( List< Integer >  list)
static
static Integer [] rabbitescape.engine.util.Util.integerArray ( Iterable< Integer >  items)
static
static boolean rabbitescape.engine.util.Util.isEmpty ( String  str)
static

Use in preference to String.isEmpty since that is not available in Android 2.2.

static String rabbitescape.engine.util.Util.join ( String  glue,
Object[]  items 
)
static
static String rabbitescape.engine.util.Util.join ( String  glue,
String[]  items 
)
static
static <T> String rabbitescape.engine.util.Util.join ( String  glue,
Iterable< T >  items 
)
static
static <T> List<T> rabbitescape.engine.util.Util.list ( Iterable< T >  input)
static
static <T> List<T> rabbitescape.engine.util.Util.list ( T[]  input)
static
static <T> List<T> rabbitescape.engine.util.Util.list ( Iterator< T >  input)
static
static <T, R> Iterable<R> rabbitescape.engine.util.Util.map ( Function< T, R >  function,
Iterable< T >  iterable 
)
static
static <T, R> Iterable<R> rabbitescape.engine.util.Util.map ( Function< T, R >  function,
T[]  input 
)
static
static <T, R> R [] rabbitescape.engine.util.Util.map ( Function< T, R >  function,
T[]  input,
R[]  retType 
)
static
static Map<String, Object> rabbitescape.engine.util.Util.newMap ( String...  keysAndValues)
static
static <T> Set<T> rabbitescape.engine.util.Util.newSet ( T...  items)
static
static Iterable<Integer> rabbitescape.engine.util.Util.range ( final int  max)
static
static void rabbitescape.engine.util.Util.reAssert ( boolean  assertion)
static

Always assert something, without needing -ea set on the JVM.

static void rabbitescape.engine.util.Util.reAssert ( boolean  assertion,
String  message 
)
static

As reAssert( boolean assertion ), but with an explanation.

static String rabbitescape.engine.util.Util.regexRemovePreserveGroup ( String  s,
String  regex,
int  patternFlags 
)
static

Replace all matches, but preserves the first capturing group. Compare to String.replaceAll, which replaces the whole match.

Parameters
patternFlagsThe flags from java.util.regex.Pattern.
static String rabbitescape.engine.util.Util.regexRemovePreserveGroup ( String  s,
String  regex 
)
static
static String rabbitescape.engine.util.Util.regexReplace ( String  s,
String  regex,
String  replacement 
)
static
static Iterable<String> rabbitescape.engine.util.Util.resourceLines ( String  name)
static
static <T> Iterable<T> rabbitescape.engine.util.Util.sorted ( Iterable< T >  input)
static
static String [] rabbitescape.engine.util.Util.split ( String  input,
String  delimiter 
)
static

Split input by finding all occurrences of delimiter. Works like a sane version of String.split, but with no regular expressions.

Parameters
delimiteris not a regular expression, just a string.
Returns
An array of strings that is always n + 1 long, where n is the number of times the string delimiter appears in input.
static String [] rabbitescape.engine.util.Util.split ( String  input,
String  delimiter,
int  maxSplits 
)
static

Split input by finding all occurrences of delimiter. Works like a sane version of String.split, but with no regular expressions.

Parameters
delimiteris not a regular expression, just a string.
maxSplitsthe maximum number of times the string should be split, or -1 for as many as possible.
Returns
An array of strings that is always 1 + min(n, maxSplits) long, where n is the number of times the string delimiter appears in input.
static Iterable<String> rabbitescape.engine.util.Util.streamLines ( InputStream  input)
static
static Iterable<String> rabbitescape.engine.util.Util.streamLines ( final String  name,
final InputStream  input 
)
staticprivate
static String [] rabbitescape.engine.util.Util.stringArray ( List< String >  list)
static
static String [] rabbitescape.engine.util.Util.stringArray ( Iterable< String >  items)
static
static String rabbitescape.engine.util.Util.stringFromChars ( Iterable< Character >  chars)
static
static Function<String, String> rabbitescape.engine.util.Util.stripLast ( final int  i)
static
static <T> List<String> rabbitescape.engine.util.Util.toStringList ( T[]  values)
static
static String [] rabbitescape.engine.util.Util.wrap ( String  s,
int  maxChar 
)
static

Split a long string into lines.

Parameters
sThe string to split.
maxCharThe maximum requested line length.
Returns
Each line is an element in the array. Lines will be split at spaces. Words will never be split.
static String rabbitescape.engine.util.Util.wrapToNewline ( String  s,
int  maxChar 
)
static

As wrap(), but returns a single string with newlines.


The documentation for this class was generated from the following file: