Top Description Fields Constructors Methods
org.codehaus.groovy.runtime

public Class DefaultGroovyMethodsSupport

extends Object
Class Inheritance
Known Direct Subclasses
org.codehaus.groovy.runtime.IOGroovyMethods, org.codehaus.groovy.runtime.ProcessGroovyMethods, org.codehaus.groovy.runtime.ResourceGroovyMethods, org.codehaus.groovy.runtime.SocketGroovyMethods, org.codehaus.groovy.runtime.StringGroovyMethods, org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods, org.codehaus.groovy.vmplugin.v8.PluginDefaultGroovyMethods, org.codehaus.groovy.runtime.DateGroovyMethods, org.codehaus.groovy.runtime.DefaultGroovyMethods
Imports
groovy.lang.EmptyRange, .IntRange, .NumberRange, .Range, org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation, java.io.Closeable, .IOException, .OutputStream, .Writer, java.lang.reflect.Array, java.nio.charset.Charset, java.util.ArrayDeque, .ArrayList, .Collection, .Comparator, .Hashtable, .IdentityHashMap, .LinkedHashMap, .LinkedHashSet, .LinkedList, .List, .Map, .PriorityQueue, .Properties, .Queue, .Set, .SortedMap, .SortedSet, .Stack, .TreeMap, .TreeSet, .Vector, .WeakHashMap, java.util.concurrent.ArrayBlockingQueue, .ConcurrentHashMap, .ConcurrentLinkedQueue, .ConcurrentSkipListMap, .ConcurrentSkipListSet, .CopyOnWriteArrayList, .CopyOnWriteArraySet, .DelayQueue, .LinkedBlockingDeque, .LinkedBlockingQueue, .PriorityBlockingQueue, .SynchronousQueue, java.util.logging.Logger

Support methods for DefaultGroovyMethods and PluginDefaultMethods.

Field Summary

Modifier and TypeField and Description
private static final Object[]
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Object
protected static <T> Collection<T>
cloneSimilarCollection(Collection<T> orig, int newCapacity)

protected static <K, V> Map<K, V>
cloneSimilarMap(Map<K, V> orig)

public static void
closeQuietly(Closeable
the thing to close
c
)

Close the Closeable.

public static void
closeWithWarning(Closeable
the thing to close
closeable
)

Close the Closeable.

protected static <T> T[]
createSimilarArray(T[] orig, int newCapacity)

protected static <T> Collection<T>
protected static <T> Collection<T>
protected static <T> Collection<T>
createSimilarCollection(Collection<T> orig, int newCapacity)

protected static <T> List<T>
createSimilarList(List<T> orig, int newCapacity)

protected static <K, V> Map<K, V>
createSimilarMap(Map<K, V> orig)

protected static Collection<E>
protected static <T> Queue<T>
protected static <T> Set<T>
protected static int

Returns:

the normalised index
normaliseIndex
(int
the unnormalized index
i
,
int
the array size
size
)

This converts a possibly negative index to a real index into the array.

protected static boolean

Returns:

true if the collections are all of the same type
sameType
(Collection<E>[]
an array of collections
cols
)

Determines if all items of this array are of the same type.

protected static RangeInfo
subListBorders(int size, Range<T extends Comparable<T>> range)

protected static RangeInfo
subListBorders(int size, EmptyRange<T extends Comparable<T>> range)

pack-priv static Throwable

Returns:

throwable Exception from the close method, else null
tryClose
(AutoCloseable
the thing to close
closeable
,
boolean
if true will log a warning if an exception occurs
logWarning
)

Attempts to close the closeable returning rather than throwing any Exception that may occur.

private static void
writeUtf16Bom(OutputStream stream, boolean bigEndian)

private static void
writeUtf16Bom(Writer writer, boolean bigEndian)

protected static void
writeUTF16BomIfRequired(final Writer writer, final String charset)

protected static void
writeUTF16BomIfRequired(final Writer writer, final Charset charset)

protected static void
writeUTF16BomIfRequired(final OutputStream stream, final String charset)

protected static void
writeUTF16BomIfRequired(final OutputStream stream, final Charset charset)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_OBJECT_ARRAYback to summary
private static final Object[] EMPTY_OBJECT_ARRAY
LOGback to summary
private static final Logger LOG

Constructor Detail

DefaultGroovyMethodsSupportback to summary
public DefaultGroovyMethodsSupport()

Method Detail

cloneObjectback to summary
private static Object cloneObject(Object orig)
cloneSimilarCollectionback to summary
protected static <T> Collection<T> cloneSimilarCollection(Collection<T> orig, int newCapacity)
Annotations
@SuppressWarnings:unchecked
cloneSimilarMapback to summary
protected static <K, V> Map<K, V> cloneSimilarMap(Map<K, V> orig)
Annotations
@SuppressWarnings:unchecked
closeQuietlyback to summary
public static void closeQuietly(Closeable c)

Close the Closeable. Ignore any problems that might occur.

Parameters
c:Closeable

the thing to close

closeWithWarningback to summary
public static void closeWithWarning(Closeable closeable)

Close the Closeable. Logging a warning if any problems occur.

Parameters
closeable:Closeable

the thing to close

createSimilarArrayback to summary
protected static <T> T[] createSimilarArray(T[] orig, int newCapacity)
Annotations
@SuppressWarnings:unchecked
createSimilarCollectionback to summary
protected static <T> Collection<T> createSimilarCollection(Iterable<T> iterable)
createSimilarCollectionback to summary
protected static <T> Collection<T> createSimilarCollection(Collection<T> collection)
createSimilarCollectionback to summary
protected static <T> Collection<T> createSimilarCollection(Collection<T> orig, int newCapacity)
createSimilarListback to summary
protected static <T> List<T> createSimilarList(List<T> orig, int newCapacity)
createSimilarMapback to summary
protected static <K, V> Map<K, V> createSimilarMap(Map<K, V> orig)
Annotations
@SuppressWarnings:unchecked
createSimilarOrDefaultCollectionback to summary
protected static Collection<E> createSimilarOrDefaultCollection(Object object)
createSimilarQueueback to summary
protected static <T> Queue<T> createSimilarQueue(Queue<T> orig)
Annotations
@SuppressWarnings:unchecked
createSimilarSetback to summary
protected static <T> Set<T> createSimilarSet(Set<T> orig)
Annotations
@SuppressWarnings:unchecked
normaliseIndexback to summary
protected static int normaliseIndex(int i, int size)

This converts a possibly negative index to a real index into the array.

Parameters
i:int

the unnormalized index

size:int

the array size

Returns:int

the normalised index

sameTypeback to summary
protected static boolean sameType(Collection<E>[] cols)

Determines if all items of this array are of the same type.

Parameters
cols:Collection<E>[]

an array of collections

Returns:boolean

true if the collections are all of the same type

Annotations
@SuppressWarnings:unchecked
subListBordersback to summary
protected static RangeInfo subListBorders(int size, Range<T extends Comparable<T>> range)
subListBordersback to summary
protected static RangeInfo subListBorders(int size, EmptyRange<T extends Comparable<T>> range)
tryCloseback to summary
pack-priv static Throwable tryClose(AutoCloseable closeable, boolean logWarning)

Attempts to close the closeable returning rather than throwing any Exception that may occur.

Parameters
closeable:AutoCloseable

the thing to close

logWarning:boolean

if true will log a warning if an exception occurs

Returns:Throwable

throwable Exception from the close method, else null

writeUtf16Bomback to summary
private static void writeUtf16Bom(OutputStream stream, boolean bigEndian) throws IOException
writeUtf16Bomback to summary
private static void writeUtf16Bom(Writer writer, boolean bigEndian) throws IOException
writeUTF16BomIfRequiredback to summary
protected static void writeUTF16BomIfRequired(final Writer writer, final String charset) throws IOException
writeUTF16BomIfRequiredback to summary
protected static void writeUTF16BomIfRequired(final Writer writer, final Charset charset) throws IOException
writeUTF16BomIfRequiredback to summary
protected static void writeUTF16BomIfRequired(final OutputStream stream, final String charset) throws IOException
writeUTF16BomIfRequiredback to summary
protected static void writeUTF16BomIfRequired(final OutputStream stream, final Charset charset) throws IOException