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

public Class GroovyCategorySupport

extends Object
Class Inheritance
Imports
groovy.lang.Closure, org.apache.groovy.util.BeanUtils, org.codehaus.groovy.reflection.CachedClass, .CachedMethod, .ReflectionCache, org.codehaus.groovy.runtime.metaclass.DefaultMetaClassInfo, .NewInstanceMetaMethod, org.codehaus.groovy.vmplugin.VMPluginFactory, java.lang.ref.SoftReference, java.util.ArrayList, .Collections, .HashMap, .Iterator, .LinkedList, .List, .Map, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger

Support methods for Groovy category usage

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
private static class
public static class

Field Summary

Modifier and TypeField and Description
private static int
private static final GroovyCategorySupport.MyThreadLocal

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static GroovyCategorySupport.CategoryMethodList

Returns:

the list of methods
getCategoryMethods
(String
the method name of interest
name
)

This method is used to pull all the new methods out of the local thread context with a particular name.

public static AtomicInteger
public static String
public static String
public static boolean
public static boolean
public static <T> T

Returns:

the value returned from the closure
use
(Class<T>
the class containing category methods
categoryClass
,
Closure<T>
the closure during which to make the category class methods available
closure
)

Create a scope based on given categoryClass and invoke closure within that scope.

public static <T> T

Returns:

the value returned from the closure
use
(List<Class<T>>
the list of classes containing category methods
categoryClasses
,
Closure<T>
the closure during which to make the category class methods available
closure
)

Create a scope based on given categoryClasses and invoke closure within that scope.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

categoriesInUseback to summary
private static int categoriesInUse
THREAD_INFOback to summary
private static final GroovyCategorySupport.MyThreadLocal THREAD_INFO

Constructor Detail

GroovyCategorySupportback to summary
public GroovyCategorySupport()

Method Detail

getCategoryMethodsback to summary
public static GroovyCategorySupport.CategoryMethodList getCategoryMethods(String name)

This method is used to pull all the new methods out of the local thread context with a particular name.

Parameters
name:String

the method name of interest

Returns:GroovyCategorySupport.CategoryMethodList

the list of methods

getCategoryNameUsageback to summary
public static AtomicInteger getCategoryNameUsage(String name)
getPropertyCategoryGetterNameback to summary
public static String getPropertyCategoryGetterName(String propertyName)
getPropertyCategorySetterNameback to summary
public static String getPropertyCategorySetterName(String propertyName)
hasCategoryInAnyThreadback to summary
public static boolean hasCategoryInAnyThread()
Annotations
@Deprecated
hasCategoryInCurrentThreadback to summary
public static boolean hasCategoryInCurrentThread()
useback to summary
public static <T> T use(Class<T> categoryClass, Closure<T> closure)

Create a scope based on given categoryClass and invoke closure within that scope.

Parameters
categoryClass:Class<T>

the class containing category methods

closure:Closure<T>

the closure during which to make the category class methods available

Returns:T

the value returned from the closure

useback to summary
public static <T> T use(List<Class<T>> categoryClasses, Closure<T> closure)

Create a scope based on given categoryClasses and invoke closure within that scope.

Parameters
categoryClasses:List<Class<T>>

the list of classes containing category methods

closure:Closure<T>

the closure during which to make the category class methods available

Returns:T

the value returned from the closure

org.codehaus.groovy.runtime back to summary

public Class GroovyCategorySupport.CategoryMethod

extends NewInstanceMetaMethod
implements Comparable
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Field Summary

Modifier and TypeField and Description
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
CategoryMethod(CachedMethod metaMethod, Class<T> metaClass)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final Object
the object to compare against
that
)

Implements java.lang.Comparable.compareTo.

Sort by most specific to least specific.
public boolean
isCacheable()

Overrides groovy.lang.MetaMethod.isCacheable.

Returns whether this object is cacheable
Inherited from org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod:
getModifiersinvokeisStatic

Field Detail

metaClassback to summary
private final Class<T> metaClass

Constructor Detail

CategoryMethodback to summary
public CategoryMethod(CachedMethod metaMethod, Class<T> metaClass)

Method Detail

compareToback to summary
public int compareTo(final Object that)

Implements java.lang.Comparable.compareTo.

Sort by most specific to least specific.

Parameters
that:Object

the object to compare against

Returns:int

Doc from java.lang.Comparable.compareTo.

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
isCacheableback to summary
public boolean isCacheable()

Overrides groovy.lang.MetaMethod.isCacheable.

Doc from groovy.lang.MetaMethod.isCacheable.

Returns whether this object is cacheable

org.codehaus.groovy.runtime back to summary

public Class GroovyCategorySupport.CategoryMethodList

extends ArrayList<GroovyCategorySupport.CategoryMethod>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public final int
pack-priv final GroovyCategorySupport.CategoryMethodList
private static final long
pack-priv final AtomicInteger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(GroovyCategorySupport.CategoryMethod
element to be appended to this list
o
)

Overrides java.util.ArrayList.add.

Implements java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this list.
Inherited from java.util.ArrayList:
addaddAlladdAlladdFirstaddLastclearclonecontainsensureCapacityequalsforEachgetgetFirstgetLasthashCodeindexOfisEmptyiteratorlastIndexOflistIteratorlistIteratorremoveremoveremoveAllremoveFirstremoveIfremoveLastremoveRangereplaceAllretainAllsetsizesortspliteratorsubListtoArraytoArraytrimToSize

Field Detail

levelback to summary
public final int level
previousback to summary
pack-priv final GroovyCategorySupport.CategoryMethodList previous
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.ArrayList.serialVersionUID.

usageback to summary
pack-priv final AtomicInteger usage

Constructor Detail

CategoryMethodListback to summary
public CategoryMethodList(String name, int level, GroovyCategorySupport.CategoryMethodList previous)

Method Detail

addback to summary
public boolean add(GroovyCategorySupport.CategoryMethod o)

Overrides java.util.ArrayList.add.

Implements java.util.List.add, java.util.Collection.add.

Doc from java.util.ArrayList.add.

Appends the specified element to the end of this list.

Parameters
o:GroovyCategorySupport.CategoryMethod

element to be appended to this list

Returns:boolean

true (as specified by Collection#add)

org.codehaus.groovy.runtime back to summary

private Class GroovyCategorySupport.MyThreadLocal

extends ThreadLocal<SoftReference<T>>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final ConcurrentHashMap<String, AtomicInteger>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public GroovyCategorySupport.ThreadCategoryInfo
public GroovyCategorySupport.ThreadCategoryInfo
public AtomicInteger
Inherited from java.lang.ThreadLocal:
getinitialValueremovesetwithInitial

Field Detail

usageback to summary
pack-priv final ConcurrentHashMap<String, AtomicInteger> usage

Constructor Detail

MyThreadLocalback to summary
private MyThreadLocal()

Method Detail

getInfoback to summary
public GroovyCategorySupport.ThreadCategoryInfo getInfo()
getInfoNullableback to summary
public GroovyCategorySupport.ThreadCategoryInfo getInfoNullable()
getUsageback to summary
public AtomicInteger getUsage(String name)
org.codehaus.groovy.runtime back to summary

public Class GroovyCategorySupport.ThreadCategoryInfo

extends HashMap<String, GroovyCategorySupport.CategoryMethodList>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
private static final Object
private Map<String, String>
private Map<String, String>
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
applyUse(CachedClass cachedClass)

private void
private void
public GroovyCategorySupport.CategoryMethodList
pack-priv String
pack-priv String
private void
private Map<String, String>
putPropertyAccessor(int prefixLength, String accessorName, Map<String, String> map)

private <T> T
use(Class<T> categoryClass, Closure<T> closure)

public <T> T
use(List<Class<T>> categoryClasses, Closure<T> closure)

private void
use(Class<T> categoryClass)

Inherited from java.util.HashMap:
clearclonecomputecomputeIfAbsentcomputeIfPresentcontainsKeycontainsValueentrySetforEachgetgetOrDefaultisEmptykeySetmergenewHashMapputputAllputIfAbsentremoveremovereplacereplacereplaceAllsizevalues

Field Detail

levelback to summary
pack-priv int level
LOCKback to summary
private static final Object LOCK
propertyGetterMapback to summary
private Map<String, String> propertyGetterMap
propertySetterMapback to summary
private Map<String, String> propertySetterMap
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.HashMap.serialVersionUID.

Constructor Detail

ThreadCategoryInfoback to summary
public ThreadCategoryInfo()

Method Detail

applyUseback to summary
private void applyUse(CachedClass cachedClass)
cachePropertyAccessorback to summary
private void cachePropertyAccessor(GroovyCategorySupport.CategoryMethod method)
endScopeback to summary
private void endScope()
getCategoryMethodsback to summary
public GroovyCategorySupport.CategoryMethodList getCategoryMethods(String name)
getPropertyCategoryGetterNameback to summary
pack-priv String getPropertyCategoryGetterName(String propertyName)
getPropertyCategorySetterNameback to summary
pack-priv String getPropertyCategorySetterName(String propertyName)
newScopeback to summary
private void newScope()
putPropertyAccessorback to summary
private Map<String, String> putPropertyAccessor(int prefixLength, String accessorName, Map<String, String> map)
useback to summary
private <T> T use(Class<T> categoryClass, Closure<T> closure)
useback to summary
public <T> T use(List<Class<T>> categoryClasses, Closure<T> closure)
useback to summary
private void use(Class<T> categoryClass)