cascading.util
Class Util

java.lang.Object
  extended by cascading.util.Util

public class Util
extends Object

Class Util provides reusable operations.


Nested Class Summary
static interface Util.RetryOperator<T>
           
 
Field Summary
static int ID_LENGTH
           
 
Constructor Summary
Util()
           
 
Method Summary
static Set<Class<? extends Exception>> asClasses(String classNames, String warningMessage)
          Converts a given comma separated String of Exception names into a List of classes.
static String captureDebugTrace(Class type)
          Deprecated. see TraceUtil.captureDebugTrace(Object)
static String cleansePathName(String name)
           
static boolean containsNull(Object[] values)
           
static boolean containsWhitespace(String string)
           
static
<T> T[]
copy(T[] source)
           
static String createID(byte[] bytes)
          Method CreateID returns a HEX hash of the given bytes with length 32 characters long.
static String createID(String rawID)
           
static Object createProtectedObject(Class type, Object[] parameters, Class[] parameterTypes)
           
static String createUniqueID()
           
static String findName(String path)
           
static String findVersion(String path)
           
static String formatTrace(Operation operation, String message)
          Deprecated. see TraceUtil.formatTrace(cascading.operation.Operation, String)
static String formatTrace(Pipe pipe, String message)
          Deprecated. 
static String formatTrace(Scheme scheme, String message)
          Deprecated. see TraceUtil.formatTrace(cascading.scheme.Scheme, String)
static String formatTrace(Tap tap, String message)
          Deprecated. see TraceUtil.formatTrace(cascading.tap.Tap, String)
static String getSimpleTypeName(Type type)
           
static long getSinkModified(Object config, Collection<Tap> sinks)
           
static long getSourceModified(Object confCopy, Iterator<Tap> values, long sinkModified)
           
static String getTypeName(Type type)
           
static boolean hasClass(String typeString)
           
static
<T> T
invokeConstructor(Class<T> target, Object[] parameters, Class[] parameterTypes)
           
static Object invokeConstructor(String className, Object[] parameters, Class[] parameterTypes)
           
static Object invokeInstanceMethod(Object target, String methodName, Object[] parameters, Class[] parameterTypes)
           
static Object invokeStaticMethod(Class type, String methodName, Object[] parameters, Class[] parameterTypes)
           
static Object invokeStaticMethod(String typeString, String methodName, Object[] parameters, Class[] parameterTypes)
           
static boolean isEmpty(String string)
           
static String join(Collection collection)
          This method joins each value in the collection with a tab character as the delimiter.
static String join(Collection collection, String delim)
          This method joins each valuein the collection with the given delimiter.
static String join(Collection collection, String delim, boolean printNull)
           
static String join(int[] list, String delim)
          This method joins the values in the given list with the delim String value.
static String join(int[] list, String delim, boolean printNull)
           
static String join(Iterable iterable, String delim, boolean printNull)
           
static String join(Object[] list, String delim)
          This method joins the values in the given list with the delim String value.
static String join(Object[] list, String delim, boolean printNull)
           
static String join(Object[] list, String delim, boolean printNull, int beginAt)
           
static String join(Object[] list, String delim, boolean printNull, int beginAt, int length)
           
static String join(String delim, boolean printNull, String... strings)
           
static void join(StringBuffer buffer, Collection collection, String delim)
          This method joins each value in the collection with the given delimiter.
static void join(StringBuffer buffer, Collection collection, String delim, boolean printNull)
           
static String join(String delim, String... strings)
           
static String makePath(String prefix, String name)
           
static String makeTempPath(String name)
          Deprecated. 
static
<T> T
newInstance(Class<T> target, Object... parameters)
           
static
<T> T
newInstance(String className, Object... parameters)
           
static String normalizeUrl(String url)
          This method attempts to remove duplicate consecutive forward slashes from the given url.
static String print(Collection collection, String delim)
           
static void print(StringBuffer buffer, Collection collection, String delim)
           
static void printGraph(PrintStream out, org.jgrapht.graph.SimpleDirectedGraph graph)
           
static String printGraph(org.jgrapht.graph.SimpleDirectedGraph graph)
           
static void printGraph(String filename, org.jgrapht.graph.SimpleDirectedGraph graph)
           
static void printMatrix(PrintStream out, org.jgrapht.graph.SimpleDirectedGraph<FlowElement,Scope> graph)
           
static Collection<String> quote(Collection<String> collection, String quote)
           
static void removeAllNulls(List list)
          This method removes all nulls from the given List.
static String[] removeNulls(String... strings)
           
static
<T> T
retry(org.slf4j.Logger logger, int retries, int secondsDelay, String message, Util.RetryOperator<T> operator)
           
static
<R> R
returnInstanceFieldIfExists(Object target, String fieldName)
           
static
<R> R
returnInstanceFieldIfExistsSafe(Object target, String fieldName)
           
static void safeSleep(long durationMillis)
           
static String sanitizeUrl(String url)
          This method attempts to remove any username and password from the given url String.
static
<R> void
setInstanceFieldIfExists(Object target, String fieldName, R value)
           
static void setTrace(Object object, String trace)
          Deprecated. see TraceUtil.setTrace(Object, String)
static String[] simpleTypeNames(Type[] types)
           
static String toNull(Object object)
          This method returns the Object.toString() of the given object, or an empty String if the object is null.
static String truncate(String string, int maxSize)
          This method truncates the given String value to the given size, but appends an ellipse ("...") if the String is larger than maxSize.
static String[] typeNames(Type[] types)
           
static String unique(String value, String delim)
           
static void writeDOT(Writer writer, org.jgrapht.graph.SimpleDirectedGraph graph, org.jgrapht.ext.IntegerNameProvider vertexIdProvider, org.jgrapht.ext.VertexNameProvider vertexNameProvider, org.jgrapht.ext.EdgeNameProvider edgeNameProvider)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_LENGTH

public static int ID_LENGTH
Constructor Detail

Util

public Util()
Method Detail

createUniqueID

public static String createUniqueID()

createID

public static String createID(String rawID)

createID

public static String createID(byte[] bytes)
Method CreateID returns a HEX hash of the given bytes with length 32 characters long.

Parameters:
bytes - the bytes
Returns:
string

copy

public static <T> T[] copy(T[] source)

unique

public static String unique(String value,
                            String delim)

join

public static String join(int[] list,
                          String delim)
This method joins the values in the given list with the delim String value.

Parameters:
list -
delim -
Returns:
String

join

public static String join(int[] list,
                          String delim,
                          boolean printNull)

join

public static String join(String delim,
                          String... strings)

join

public static String join(String delim,
                          boolean printNull,
                          String... strings)

join

public static String join(Object[] list,
                          String delim)
This method joins the values in the given list with the delim String value.

Parameters:
list -
delim -
Returns:
a String

join

public static String join(Object[] list,
                          String delim,
                          boolean printNull)

join

public static String join(Object[] list,
                          String delim,
                          boolean printNull,
                          int beginAt)

join

public static String join(Object[] list,
                          String delim,
                          boolean printNull,
                          int beginAt,
                          int length)

join

public static String join(Iterable iterable,
                          String delim,
                          boolean printNull)

join

public static String join(Collection collection)
This method joins each value in the collection with a tab character as the delimiter.

Parameters:
collection -
Returns:
a String

join

public static String join(Collection collection,
                          String delim)
This method joins each valuein the collection with the given delimiter.

Parameters:
collection -
delim -
Returns:
a String

join

public static String join(Collection collection,
                          String delim,
                          boolean printNull)

join

public static void join(StringBuffer buffer,
                        Collection collection,
                        String delim)
This method joins each value in the collection with the given delimiter. All results are appended to the given StringBuffer instance.

Parameters:
buffer -
collection -
delim -

join

public static void join(StringBuffer buffer,
                        Collection collection,
                        String delim,
                        boolean printNull)

removeNulls

public static String[] removeNulls(String... strings)

quote

public static Collection<String> quote(Collection<String> collection,
                                       String quote)

print

public static String print(Collection collection,
                           String delim)

print

public static void print(StringBuffer buffer,
                         Collection collection,
                         String delim)

sanitizeUrl

public static String sanitizeUrl(String url)
This method attempts to remove any username and password from the given url String.

Parameters:
url -
Returns:
a String

normalizeUrl

public static String normalizeUrl(String url)
This method attempts to remove duplicate consecutive forward slashes from the given url.

Parameters:
url -
Returns:
a String

toNull

public static String toNull(Object object)
This method returns the Object.toString() of the given object, or an empty String if the object is null.

Parameters:
object -
Returns:
a String

truncate

public static String truncate(String string,
                              int maxSize)
This method truncates the given String value to the given size, but appends an ellipse ("...") if the String is larger than maxSize.

Parameters:
string -
maxSize -
Returns:
a String

printGraph

public static String printGraph(org.jgrapht.graph.SimpleDirectedGraph graph)

printGraph

public static void printGraph(PrintStream out,
                              org.jgrapht.graph.SimpleDirectedGraph graph)

printGraph

public static void printGraph(String filename,
                              org.jgrapht.graph.SimpleDirectedGraph graph)

printMatrix

public static void printMatrix(PrintStream out,
                               org.jgrapht.graph.SimpleDirectedGraph<FlowElement,Scope> graph)

removeAllNulls

public static void removeAllNulls(List list)
This method removes all nulls from the given List.

Parameters:
list -

setTrace

@Deprecated
public static void setTrace(Object object,
                                       String trace)
Deprecated. see TraceUtil.setTrace(Object, String)

Allows for custom trace fields on Pipe, Tap, and Scheme types


captureDebugTrace

@Deprecated
public static String captureDebugTrace(Class type)
Deprecated. see TraceUtil.captureDebugTrace(Object)


formatTrace

@Deprecated
public static String formatTrace(Pipe pipe,
                                            String message)
Deprecated. 


formatTrace

@Deprecated
public static String formatTrace(Tap tap,
                                            String message)
Deprecated. see TraceUtil.formatTrace(cascading.tap.Tap, String)


formatTrace

@Deprecated
public static String formatTrace(Scheme scheme,
                                            String message)
Deprecated. see TraceUtil.formatTrace(cascading.scheme.Scheme, String)


formatTrace

@Deprecated
public static String formatTrace(Operation operation,
                                            String message)
Deprecated. see TraceUtil.formatTrace(cascading.operation.Operation, String)


writeDOT

public static void writeDOT(Writer writer,
                            org.jgrapht.graph.SimpleDirectedGraph graph,
                            org.jgrapht.ext.IntegerNameProvider vertexIdProvider,
                            org.jgrapht.ext.VertexNameProvider vertexNameProvider,
                            org.jgrapht.ext.EdgeNameProvider edgeNameProvider)

isEmpty

public static boolean isEmpty(String string)

findVersion

public static String findVersion(String path)

findName

public static String findName(String path)

getSourceModified

public static long getSourceModified(Object confCopy,
                                     Iterator<Tap> values,
                                     long sinkModified)
                              throws IOException
Throws:
IOException

getSinkModified

public static long getSinkModified(Object config,
                                   Collection<Tap> sinks)
                            throws IOException
Throws:
IOException

getTypeName

public static String getTypeName(Type type)

getSimpleTypeName

public static String getSimpleTypeName(Type type)

typeNames

public static String[] typeNames(Type[] types)

simpleTypeNames

public static String[] simpleTypeNames(Type[] types)

containsNull

public static boolean containsNull(Object[] values)

safeSleep

public static void safeSleep(long durationMillis)

asClasses

public static Set<Class<? extends Exception>> asClasses(String classNames,
                                                        String warningMessage)
Converts a given comma separated String of Exception names into a List of classes. ClassNotFound exceptions are ignored if no warningMessage is given, otherwise logged as a warning.

Parameters:
classNames - A comma separated String of Exception names.
Returns:
List of Exception classes.

retry

public static <T> T retry(org.slf4j.Logger logger,
                          int retries,
                          int secondsDelay,
                          String message,
                          Util.RetryOperator<T> operator)
               throws Exception
Throws:
Exception

createProtectedObject

public static Object createProtectedObject(Class type,
                                           Object[] parameters,
                                           Class[] parameterTypes)

hasClass

public static boolean hasClass(String typeString)

newInstance

public static <T> T newInstance(String className,
                                Object... parameters)

newInstance

public static <T> T newInstance(Class<T> target,
                                Object... parameters)

invokeStaticMethod

public static Object invokeStaticMethod(String typeString,
                                        String methodName,
                                        Object[] parameters,
                                        Class[] parameterTypes)

invokeStaticMethod

public static Object invokeStaticMethod(Class type,
                                        String methodName,
                                        Object[] parameters,
                                        Class[] parameterTypes)

invokeInstanceMethod

public static Object invokeInstanceMethod(Object target,
                                          String methodName,
                                          Object[] parameters,
                                          Class[] parameterTypes)

returnInstanceFieldIfExistsSafe

public static <R> R returnInstanceFieldIfExistsSafe(Object target,
                                                    String fieldName)

invokeConstructor

public static Object invokeConstructor(String className,
                                       Object[] parameters,
                                       Class[] parameterTypes)

invokeConstructor

public static <T> T invokeConstructor(Class<T> target,
                                      Object[] parameters,
                                      Class[] parameterTypes)

returnInstanceFieldIfExists

public static <R> R returnInstanceFieldIfExists(Object target,
                                                String fieldName)

setInstanceFieldIfExists

public static <R> void setInstanceFieldIfExists(Object target,
                                                String fieldName,
                                                R value)

makeTempPath

@Deprecated
public static String makeTempPath(String name)
Deprecated. 


makePath

public static String makePath(String prefix,
                              String name)

cleansePathName

public static String cleansePathName(String name)

containsWhitespace

public static boolean containsWhitespace(String string)


Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.