本文整理汇总了Java中org.codehaus.groovy.runtime.GroovyCategorySupport类的典型用法代码示例。如果您正苦于以下问题:Java GroovyCategorySupport类的具体用法?Java GroovyCategorySupport怎么用?Java GroovyCategorySupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroovyCategorySupport类属于org.codehaus.groovy.runtime包,在下文中一共展示了GroovyCategorySupport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createPojoMetaClassGetPropertySite
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
private CallSite createPojoMetaClassGetPropertySite(Object receiver) {
final MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
CallSite site;
if (metaClass.getClass() != MetaClassImpl.class || GroovyCategorySupport.hasCategoryInCurrentThread()) {
site = new PojoMetaClassGetPropertySite(this);
} else {
final MetaProperty effective = ((MetaClassImpl) metaClass).getEffectiveGetMetaProperty(receiver.getClass(), receiver, name, false);
if (effective != null) {
if (effective instanceof CachedField)
site = new GetEffectivePojoFieldSite(this, (MetaClassImpl) metaClass, (CachedField) effective);
else
site = new GetEffectivePojoPropertySite(this, (MetaClassImpl) metaClass, effective);
} else {
site = new PojoMetaClassGetPropertySite(this);
}
}
array.array[index] = site;
return site;
}
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AbstractCallSite.java
示例2: createPogoMetaClassGetPropertySite
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
private CallSite createPogoMetaClassGetPropertySite(GroovyObject receiver) {
MetaClass metaClass = receiver.getMetaClass();
CallSite site;
if (metaClass.getClass() != MetaClassImpl.class || GroovyCategorySupport.hasCategoryInCurrentThread()) {
site = new PogoMetaClassGetPropertySite(this, metaClass);
} else {
final MetaProperty effective = ((MetaClassImpl) metaClass).getEffectiveGetMetaProperty(this.array.owner, receiver, name, false);
if (effective != null) {
if (effective instanceof CachedField)
site = new GetEffectivePogoFieldSite(this, metaClass, (CachedField) effective);
else
site = new GetEffectivePogoPropertySite(this, metaClass, effective);
} else {
site = new PogoMetaClassGetPropertySite(this, metaClass);
}
}
array.array[index] = site;
return site;
}
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AbstractCallSite.java
示例3: getMethodWithCachingInternal
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
private MetaMethod getMethodWithCachingInternal (Class sender, CallSite site, Class [] params) {
if (GroovyCategorySupport.hasCategoryInCurrentThread())
return getMethodWithoutCaching(sender, site.getName (), params, false);
final MetaMethodIndex.Entry e = metaMethodIndex.getMethods(sender, site.getName());
if (e == null) {
return null;
}
MetaMethodIndex.CacheEntry cacheEntry;
final Object methods = e.methods;
if (methods == null)
return null;
cacheEntry = e.cachedMethod;
if (cacheEntry != null && (sameClasses(cacheEntry.params, params))) {
return cacheEntry.method;
}
cacheEntry = new MetaMethodIndex.CacheEntry (params, (MetaMethod) chooseMethod(e.name, methods, params));
e.cachedMethod = cacheEntry;
return cacheEntry.method;
}
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:MetaClassImpl.java
示例4: createMetaMethodAndMetaProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
private Tuple2<MetaMethod, MetaProperty> createMetaMethodAndMetaProperty(final Class senderForMP, final Class senderForCMG, final String name, final boolean useSuper, final boolean isStatic) {
MetaMethod method = null;
MetaProperty mp = getMetaProperty(senderForMP, name, useSuper, isStatic);
if (mp != null) {
if (mp instanceof MetaBeanProperty) {
MetaBeanProperty mbp = (MetaBeanProperty) mp;
method = mbp.getGetter();
mp = mbp.getField();
}
}
// check for a category method named like a getter
if (!useSuper && !isStatic && GroovyCategorySupport.hasCategoryInCurrentThread()) {
String getterName = GroovyCategorySupport.getPropertyCategoryGetterName(name);
if (getterName != null) {
MetaMethod categoryMethod = getCategoryMethodGetter(senderForCMG, getterName, false);
if (categoryMethod != null)
method = categoryMethod;
}
}
return new Tuple2<MetaMethod, MetaProperty>(method, mp);
}
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:MetaClassImpl.java
示例5: getCategoryMethodGetter
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
private static MetaMethod getCategoryMethodGetter(Class sender, String name, boolean useLongVersion) {
List possibleGenericMethods = GroovyCategorySupport.getCategoryMethods(name);
if (possibleGenericMethods != null) {
for (Iterator iter = possibleGenericMethods.iterator(); iter.hasNext();) {
MetaMethod mmethod = (MetaMethod) iter.next();
if (!mmethod.getDeclaringClass().getTheClass().isAssignableFrom(sender))
continue;
CachedClass[] paramTypes = mmethod.getParameterTypes();
if (useLongVersion) {
if (paramTypes.length == 1 && paramTypes[0].getTheClass() == String.class) {
return mmethod;
}
} else {
if (paramTypes.length == 0) return mmethod;
}
}
}
return null;
}
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:MetaClassImpl.java
示例6: getCategoryMethodSetter
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
private static MetaMethod getCategoryMethodSetter(Class sender, String name, boolean useLongVersion) {
List possibleGenericMethods = GroovyCategorySupport.getCategoryMethods(name);
if (possibleGenericMethods != null) {
for (Iterator iter = possibleGenericMethods.iterator(); iter.hasNext();) {
MetaMethod mmethod = (MetaMethod) iter.next();
if (!mmethod.getDeclaringClass().getTheClass().isAssignableFrom(sender))
continue;
CachedClass[] paramTypes = mmethod.getParameterTypes();
if (useLongVersion) {
if (paramTypes.length == 2 && paramTypes[0].getTheClass() == String.class) {
return mmethod;
}
} else {
if (paramTypes.length == 1) return mmethod;
}
}
}
return null;
}
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:MetaClassImpl.java
示例7: createPogoCallSite
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createPogoCallSite(CallSite site, Object[] args) {
if (!GroovyCategorySupport.hasCategoryInCurrentThread() && !(this instanceof AdaptingMetaClass)) {
Class [] params = MetaClassHelper.convertToTypeArray(args);
CallSite tempSite = site;
if (site.getName().equals("call") && GeneratedClosure.class.isAssignableFrom(theClass)) {
// here, we want to point to a method named "doCall" instead of "call"
// but we don't want to replace the original call site name, otherwise
// we loose the fact that the original method name was "call" so instead
// we will point to a metamethod called "doCall"
// see GROOVY-5806 for details
tempSite = new AbstractCallSite(site.getArray(),site.getIndex(),"doCall");
}
MetaMethod metaMethod = getMethodWithCachingInternal(theClass, tempSite, params);
if (metaMethod != null)
return PogoMetaMethodSite.createPogoMetaMethodSite(site, this, metaMethod, params, args);
}
return new PogoMetaClassSite(site, this);
}
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:MetaClassImpl.java
示例8: asListOfRows
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public static List<Row> asListOfRows(Parameters existsParameters, Closure<?> tableData) {
context.set(new ArrayList<Row>());
tableData.setDelegate(new ShareDataAwardDelegate(existsParameters));
tableData.setResolveStrategy(Closure.DELEGATE_FIRST);
GroovyCategorySupport.use(TableParser.class, tableData);
List<Row> rows = context.get();
if (rows.size() <= 1)
throw new DslException("table requires at least 2 rows, first row for column names, the rest for the data.");
if (rows.size() > 0){
for (int i = 0; i < rows.size(); i++){
rows.get(i).setRowHeader(rows.get(0));
}
}
rows.remove(0);
return rows;
}
开发者ID:detectiveframework,项目名称:detective,代码行数:21,代码来源:TableParser.java
示例9: run
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
/** for testing only */
public Outcome run(final int max) {
return GroovyCategorySupport.use(Continuable.categories, new Closure<Outcome>(null) {
@Override
public Outcome call() {
int remaining = max;
List<String> functions = new ArrayList<String>();
Next n = Next.this;
while(n.yield==null) {
functions.add(n.f.getClass().getCanonicalName());
if (--remaining == 0) {
int len = functions.size();
throw new AssertionError("Did not terminate; ran " + len + " steps ending with: " + functions.subList(len - 20, len));
}
n = n.step();
}
return n.yield;
}
});
}
开发者ID:cloudbees,项目名称:groovy-cps,代码行数:21,代码来源:Next.java
示例10: run0
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
/**
* Resumes this program by either returning the value from {@link Continuable#suspend(Object)} or
* throwing an exception
*/
public Outcome run0(final Outcome cn, List<Class> categories) {
return GroovyCategorySupport.use(categories, new Closure<Outcome>(null) {
@Override
public Outcome call() {
Next n = cn.resumeFrom(e,k);
while(n.yield==null) {
if (interrupt!=null) {
// TODO: correctly reporting a source location requires every block to have the line number
n = new Next(new ThrowBlock(UNKNOWN, new ConstantBlock(interrupt), true),n.e,n.k);
interrupt = null;
}
n = n.step();
}
e = n.e;
k = n.k;
return n.yield;
}
});
}
开发者ID:cloudbees,项目名称:groovy-cps,代码行数:27,代码来源:Continuable.java
示例11: acceptGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final CallSite acceptGetProperty(Object receiver) {
// if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject)receiver).getMetaClass() != metaClass) {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || receiver==null || receiver.getClass() != metaClass.getTheClass()
|| version != metaClass.getVersion()) { // metaClass is invalid
return createGetPropertySite(receiver);
} else {
return this;
}
}
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:GetEffectivePojoPropertySite.java
示例12: callGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final Object callGetProperty (Object receiver) throws Throwable {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject) receiver).getMetaClass() != metaClass) {
return createGetPropertySite(receiver).getProperty(receiver);
} else {
return getProperty(receiver);
}
}
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java
示例13: acceptGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final CallSite acceptGetProperty(Object receiver) {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject)receiver).getMetaClass() != metaClass) {
return createGetPropertySite(receiver);
} else {
return this;
}
}
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java
示例14: callGroovyObjectGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final Object callGroovyObjectGetProperty (Object receiver) throws Throwable {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || ((GroovyObject) receiver).getMetaClass() != metaClass) {
return createGroovyObjectGetPropertySite(receiver).getProperty(receiver);
} else {
return getProperty(receiver);
}
}
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java
示例15: acceptGroovyObjectGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final CallSite acceptGroovyObjectGetProperty(Object receiver) {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject)receiver).getMetaClass() != metaClass) {
return createGroovyObjectGetPropertySite(receiver);
} else {
return this;
}
}
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java
示例16: callGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final Object callGetProperty (Object receiver) throws Throwable {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject) receiver).getMetaClass() != metaClass) {
return createGetPropertySite(receiver).getProperty(receiver);
} else {
try {
return effective.getProperty(receiver);
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
}
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:GetEffectivePogoPropertySite.java
示例17: callGroovyObjectGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final Object callGroovyObjectGetProperty (Object receiver) throws Throwable {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject) receiver).getMetaClass() != metaClass) {
return createGetPropertySite(receiver).getProperty(receiver);
} else {
try {
return effective.getProperty(receiver);
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
}
}
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:GetEffectivePogoPropertySite.java
示例18: acceptGetProperty
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public final CallSite acceptGetProperty(Object receiver) {
if (GroovyCategorySupport.hasCategoryInCurrentThread() || receiver.getClass() != metaClass.getTheClass()
|| version != metaClass.getVersion()) { // metaClass is invalid
return createGetPropertySite(receiver);
} else {
return this;
}
}
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:GetEffectivePojoFieldSite.java
示例19: getMethodWithCaching
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
public MetaMethod getMethodWithCaching(Class sender, String methodName, Object[] arguments, boolean isCallToSuper) {
// let's try use the cache to find the method
if (!isCallToSuper && GroovyCategorySupport.hasCategoryInCurrentThread()) {
return getMethodWithoutCaching(sender, methodName, MetaClassHelper.convertToTypeArray(arguments), isCallToSuper);
} else {
final MetaMethodIndex.Entry e = metaMethodIndex.getMethods(sender, methodName);
if (e == null)
return null;
return isCallToSuper ? getSuperMethodWithCaching(arguments, e) : getNormalMethodWithCaching(arguments, e);
}
}
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:MetaClassImpl.java
示例20: createPogoCallCurrentSite
import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入依赖的package包/类
/**
* Create a CallSite
*/
public CallSite createPogoCallCurrentSite(CallSite site, Class sender, Object[] args) {
if (!GroovyCategorySupport.hasCategoryInCurrentThread() && !(this instanceof AdaptingMetaClass)) {
Class [] params = MetaClassHelper.convertToTypeArray(args);
MetaMethod metaMethod = getMethodWithCachingInternal(sender, site, params);
if (metaMethod != null)
return PogoMetaMethodSite.createPogoMetaMethodSite(site, this, metaMethod, params, args);
}
return new PogoMetaClassSite(site, this);
}
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:MetaClassImpl.java
注:本文中的org.codehaus.groovy.runtime.GroovyCategorySupport类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论