Java javax.servlet.jsp.el.VariableResolver 代码实例

作者:无名 - 开发 -

以下是展示如何使用javax.servlet.jsp.el.variableresolver的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳的优秀示例。

实例 1


/**

* convert an object to an expected type according to the conversion

* rules of the expression language.

*/

public static object converttoexpectedtype(xpcontext xpcontext, final object value, class expectedtype )

throws elexception {

expressionevaluator evaluator = xpcontext.getexpressionevaluator();

return evaluator.evaluate( "${result}", expectedtype,

new variableresolver() {

public object resolvevariable( string pname ) {

return value;

}

}, null );

}

实例 2


/**

* returns a variable resolver that will resolve variables by searching through

* the page scope, request scope, session scope and application scope for an

* attribute with a matching name.

*/

public variableresolver getvariableresolver() {

final pagecontext ctx = this;

return new variableresolver() {

public object resolvevariable(string name) throws elexception {

return ctx.findattribute(name);

}

};

}

实例 3


/**

* returns a variable resolver that will resolve variables by searching through

* the page scope, request scope, session scope and application scope for an

* attribute with a matching name.

*/

@override

public variableresolver getvariableresolver() {

final pagecontext ctx = this;

return new variableresolver() {

public object resolvevariable(string name) throws elexception {

return ctx.findattribute(name);

}

};

}

实例 4


public object evaluate(string expression,

class expectedtype,

variableresolver vresolver,

functionmapper fmapper )

throws elexception {

elcontextimpl elcontext;

if (vresolver instanceof variableresolverimpl) {

elcontext = (elcontextimpl) pagecontext.getelcontext();

}

else {

// the provided variable resolver is a custom resolver,

// wrap it with a elresolver

elcontext = new elcontextimpl(new elresolverwrapper(vresolver));

}

javax.el.functionmapper fm = new functionmapperwrapper(fmapper);

elcontext.setfunctionmapper(fm);

expressionfactory fac = new expressionfactoryimpl();

object value;

try {

valueexpression expr = fac.createvalueexpression(

elcontext,

expression,

expectedtype);

value = expr.getvalue(elcontext);

} catch (javax.el.elexception ex) {

throw new elexception(ex);

}

return value;

}

实例 5


public object evaluate(variableresolver vresolver) throws elexception {

elcontext elcontext;

if (vresolver instanceof variableresolverimpl) {

elcontext = pagecontext.getelcontext();

}

else {

// the provided variable resolver is a custom resolver,

// wrap it with a elresolver

elcontext = new elcontextimpl(new elresolverwrapper(vresolver));

}

try {

return valueexpr.getvalue(elcontext);

} catch (javax.el.elexception ex) {

throw new elexception(ex);

}

}

实例 6


@override

public variableresolver getvariableresolver() {

final pagecontext ctx = this;

return new variableresolver() {

public object resolvevariable(string name) throws elexception {

return ctx.findattribute(name);

}

};

}

实例 7


@override

public object evaluate(string expression,

@suppresswarnings("rawtypes") // api does not use generics

class expectedtype,

variableresolver vresolver, functionmapper fmapper)

throws elexception {

return this.parseexpression(expression, expectedtype, fmapper).evaluate(vresolver);

}

实例 8


@override

public object evaluate(string expression,

@suppresswarnings("rawtypes") // api does not use generics

class expectedtype,

variableresolver vresolver, functionmapper fmapper)

throws elexception {

return this.parseexpression(expression, expectedtype, fmapper).evaluate(vresolver);

}

实例 9


@override

public object evaluate(string expression,

@suppresswarnings("rawtypes") class expectedtype,

variableresolver vresolver, functionmapper fmapper)

throws elexception {

return this.parseexpression(expression, expectedtype, fmapper).evaluate(vresolver);

}

实例 10


public expression parseexpression(

final string expression, final class expectedtype, final functionmapper functionmapper)

throws elexception {

return new expression() {

public object evaluate(variableresolver variableresolver) throws elexception {

return doevaluate(expression, expectedtype, functionmapper);

}

};

}

实例 11


public object evaluate(

string expression, class expectedtype, variableresolver variableresolver, functionmapper functionmapper)

throws elexception {

if (variableresolver != null) {

throw new illegalargumentexception("custom variableresolver not supported");

}

return doevaluate(expression, expectedtype, functionmapper);

}

实例 12


@override

public object evaluate(string expression,

@suppresswarnings("rawtypes") // api does not use generics

class expectedtype,

variableresolver vresolver, functionmapper fmapper)

throws elexception {

return this.parseexpression(expression, expectedtype, fmapper).evaluate(vresolver);

}

实例 13


/**

* returns a variable resolver that will resolve variables by searching through

* the page scope, request scope, session scope and application scope for an

* attribute with a matching name.

*/

public variableresolver getvariableresolver() {

final pagecontext ctx = this;

return new variableresolver() {

public object resolvevariable(string name) throws elexception {

return ctx.findattribute(name);

}

};

}

实例 14


/**

* returns a variable resolver that will resolve variables by searching through

* the page scope, request scope, session scope and application scope for an

* attribute with a matching name.

*/

@override

public variableresolver getvariableresolver() {

final pagecontext ctx = this;

return new variableresolver() {

public object resolvevariable(string name) throws elexception {

return ctx.findattribute(name);

}

};

}

实例 15


@override

@suppresswarnings("unchecked")

public lt;tgt; t evaluate (final elvars vars, string expression, classlt;tgt; returntype) throws elevalexception {

variableresolver variableresolver = new variableresolver() {

@override

public object resolvevariable(string name) throws elexception {

object value = constants.get(name);

if (!vars.hasvariable(name)) {

if (value == null amp;amp; !constants.containskey(name)) {

throw new elexception(utils.format("constants/variable '{}' cannot be resolved", name));

}

} else {

value = vars.getvariable(name);

}

return value;

}

};

try {

return (t) evaluator.evaluate(expression, returntype, variableresolver, functionmapper);

} catch (elexception e) {

log.debug("error valuating el '{}': {}", expression, e.tostring(), e);

throwable t = e;

if(e.getrootcause() != null) {

t = e.getrootcause();

}

throw new elevalexception(commonerror.cmn_0104, expression, t.tostring(), e);

}

}



以上就是由(IT人知识库http://www.itpeo.net/389615/4636780.html)本站为大家整理





标签 代码实例

Java net.minecraft.util.IProgressUpdate 代码实例

以下是展示如何使用net.minecraft.util.iprogressupdate的最佳示例。 我们使用了代码质量辨 ...

Java com.google.api.client.http.HttpResponseException 代码实例

以下是展示如何使用com.google.api.client.http.httpresponseexception的最佳 ...

Java retrofit.http.Header 代码实例

以下是展示如何使用retrofit.http.header的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最 ...

Java org.eclipse.jgit.lib.ObjectReader 代码实例

以下是展示如何使用org.eclipse.jgit.lib.objectreader的最佳示例。 我们使用了代码质量辨别 ...

Java org.apache.commons.pool.impl.GenericKeyedObjectPool 代码实例

以下是展示如何使用org.apache.commons.pool.impl.generickeyedobjectpool ...

Java com.sun.source.tree.CompilationUnitTree 代码实例

以下是展示如何使用com.sun.source.tree.compilationunittree的最佳示例。 我们使用了 ...

Java org.elasticsearch.action.count.CountResponse 代码实例

以下是展示如何使用org.elasticsearch.action.count.countresponse的最佳示例。 ...

Python shutil.copys 代码实例

以下是python模块shutil.copy的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源pytho ...

Java com.sun.codemodel.JClass 代码实例

以下是展示如何使用com.sun.codemodel.jclass的最佳示例。 我们使用了代码质量辨别算法从开源项目中提 ...

Python shutil.rmtrees 代码实例

以下是python模块shutil.rmtree的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源pyt ...

Java javax.swing.text.ViewFactory 代码实例

以下是展示如何使用javax.swing.text.viewfactory的最佳示例。 我们使用了代码质量辨别算法从开源 ...

Java com.jcraft.jsch.Channel 代码实例

以下是展示如何使用com.jcraft.jsch.channel的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取 ...

Java javax.el.ELResolver 代码实例

以下是展示如何使用javax.el.elresolver的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳 ...

Java com.google.inject.ProvisionException 代码实例

以下是展示如何使用com.google.inject.provisionexception的最佳示例。 我们使用了代码质 ...

Java uk.co.senab.photoview.PhotoViewAttacher 代码实例

以下是展示如何使用uk.co.senab.photoview.photoviewattacher的最佳示例。 我们使用了 ...

Java org.antlr.v4.runtime.dfa.DFA 代码实例

以下是展示如何使用org.antlr.v4.runtime.dfa.dfa的最佳示例。 我们使用了代码质量辨别算法从开源 ...

Java org.eclipse.ui.IWorkbenchSite 代码实例

以下是展示如何使用org.eclipse.ui.iworkbenchsite的最佳示例。 我们使用了代码质量辨别算法从开 ...

Java org.jfree.chart.plot.Plot 代码实例

以下是展示如何使用org.jfree.chart.plot.plot的最佳示例。 我们使用了代码质量辨别算法从开源项目中 ...

Java org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter 代码实例

以下是展示如何使用org.eclipse.emf.edit.ui.dnd.viewerdragadapter的最佳示例。 ...

Java javax.ws.rs.HEAD 代码实例

以下是展示如何使用javax.ws.rs.head的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳的优秀 ...