org.codehaus.groovy.runtime
Class GroovyCategorySupport

java.lang.Object
  extended by org.codehaus.groovy.runtime.GroovyCategorySupport

public class GroovyCategorySupport
extends java.lang.Object

Author:
sam, Paul King

Nested Class Summary
private static class GroovyCategorySupport.CategoryMethod
           
 
Field Summary
private static int categoriesInUse
           
private static java.lang.ThreadLocal LOCAL
           
 
Constructor Summary
GroovyCategorySupport()
           
 
Method Summary
private static java.util.Map copyMapOfList(java.util.Map m)
           
private static void endScope()
           
static java.util.List getCategoryMethods(java.lang.Class categorizedClass)
          This method is used to pull all the new methods out of the local thread context.
static java.util.List getCategoryMethods(java.lang.Class categorizedClass, java.lang.String name)
          This method is used to pull all the new methods out of the local thread context with a particular name.
static java.lang.Object getClosestMatchingCategoryMethod(java.lang.Class sender, MetaMethod orig, MetaMethod element)
           
private static java.util.Map getMetaMethods(java.util.Map properties, java.lang.Class metaClass)
           
private static java.util.List getMethodList(java.util.Map metaMethodsMap, java.lang.String name)
           
private static java.util.Map getProperties()
           
static boolean hasCategoryInAnyThread()
           
private static void newScope()
           
private static void use(java.lang.Class categoryClass)
          Delegated to from the global use(CategoryClass) method.
static java.lang.Object use(java.lang.Class categoryClass, Closure closure)
          Create a scope based on given categoryClass and invoke closure within that scope.
static java.lang.Object use(java.util.List categoryClasses, Closure closure)
          Create a scope based on given categoryClasses and invoke closure within that scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

categoriesInUse

private static int categoriesInUse

LOCAL

private static final java.lang.ThreadLocal LOCAL
Constructor Detail

GroovyCategorySupport

public GroovyCategorySupport()
Method Detail

getCategoryMethods

public static java.util.List getCategoryMethods(java.lang.Class categorizedClass,
                                                java.lang.String name)
This method is used to pull all the new methods out of the local thread context with a particular name.

Parameters:
categorizedClass - a class subject to the category methods in the thread context
name - the method name of interest
Returns:
the list of methods

getCategoryMethods

public static java.util.List getCategoryMethods(java.lang.Class categorizedClass)
This method is used to pull all the new methods out of the local thread context.

Parameters:
categorizedClass - a class subject to the category methods in the thread context
Returns:
the list of methods

getClosestMatchingCategoryMethod

public static java.lang.Object getClosestMatchingCategoryMethod(java.lang.Class sender,
                                                                MetaMethod orig,
                                                                MetaMethod element)

use

public static java.lang.Object use(java.lang.Class categoryClass,
                                   Closure closure)
Create a scope based on given categoryClass and invoke closure within that scope.

Parameters:
categoryClass - the class containing category methods
closure - the closure during which to make the category class methods available
Returns:
the value returned from the closure

use

public static java.lang.Object use(java.util.List categoryClasses,
                                   Closure closure)
Create a scope based on given categoryClasses and invoke closure within that scope.

Parameters:
categoryClasses - the list of classes containing category methods
closure - the closure during which to make the category class methods available
Returns:
the value returned from the closure

use

private static void use(java.lang.Class categoryClass)
Delegated to from the global use(CategoryClass) method. It scans the Category class for static methods that take 1 or more parameters. The first parameter is the class you are adding the category method to, additional parameters are those parameters needed by that method. A use statement cannot be undone and is valid only for the current thread.

Parameters:
categoryClass - the class containing category methods

newScope

private static void newScope()

endScope

private static void endScope()

copyMapOfList

private static java.util.Map copyMapOfList(java.util.Map m)

getProperties

private static java.util.Map getProperties()

hasCategoryInAnyThread

public static boolean hasCategoryInAnyThread()

getMethodList

private static java.util.List getMethodList(java.util.Map metaMethodsMap,
                                            java.lang.String name)

getMetaMethods

private static java.util.Map getMetaMethods(java.util.Map properties,
                                            java.lang.Class metaClass)


Copyright © ${year} The Codehaus. All Rights Reserved.