![JAR search and dependency download from the Maven repository](/logo.png)
org.mvel2.integration.impl.StaticMethodImportResolverFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tbel Show documentation
Show all versions of tbel Show documentation
TBEL is a powerful expression language for ThingsBoard platform user-defined functions.
Original implementation is based on MVEL.
/**
* MVEL 2.0
* Copyright (C) 2007 The Codehaus
* Mike Brock, Dhanji Prasanna, John Graham, Mark Proctor
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mvel2.integration.impl;
import org.mvel2.ParserContext;
import org.mvel2.integration.VariableResolver;
import org.mvel2.util.MethodStub;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* @author Christopher Brock
*/
public class StaticMethodImportResolverFactory extends BaseVariableResolverFactory {
public StaticMethodImportResolverFactory(ParserContext ctx) {
this.variableResolvers = new HashMap();
for (Map.Entry entry : ctx.getImports().entrySet()) {
if (entry.getValue() instanceof Method) {
createVariable(entry.getKey(), entry.getValue());
}
}
}
public StaticMethodImportResolverFactory() {
this.variableResolvers = new HashMap();
}
public VariableResolver createVariable(String name, Object value) {
if (value instanceof Method) value = new MethodStub((Method) value);
StaticMethodImportResolver methodResolver = new StaticMethodImportResolver(name, (MethodStub) value);
this.variableResolvers.put(name, methodResolver);
return methodResolver;
}
public VariableResolver createVariable(String name, Object value, Class> type) {
return null;
}
public boolean isTarget(String name) {
return this.variableResolvers.containsKey(name);
}
public boolean isResolveable(String name) {
return isTarget(name) || isNextResolveable(name);
}
public Map getImportedMethods() {
Map im = new HashMap();
for (Map.Entry e : this.variableResolvers.entrySet()) {
im.put(e.getKey(), (Method) e.getValue().getValue());
}
return im;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy