org.apache.commons.jelly.expression.Expression类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.apache.commons.jelly.expression.Expression类的一些代码示例,展示了Expression类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Expression类的具体详情如下:
包路径:org.apache.commons.jelly.expression.Expression
类名称:Expression

Expression介绍

[英]Expression represents an arbitrary expression using some pluggable expression language.
[中]Expression表示使用某种可插入表达式语言的任意表达式。

代码示例

代码示例来源:origin: jenkinsci/jenkins

private Object evalAttribute(String name, JellyContext context) {
  ExpressionAttribute e = attributes.get(name);
  if (e==null)    return null;
  return e.exp.evaluate(context);
}

代码示例来源:origin: jenkinsci/jenkins

actual.addAttribute("",name,name,"CDATA",expression.evaluateAsString(context));
  output.endElement(tagName);
} catch (SAXException x) {
  throw new JellyTagException(x);

代码示例来源:origin: org.hudsonci.stapler/commons-jelly

public void run(JellyContext context, XMLOutput output) throws JellyTagException {
  String var = getAttribute("var").evaluateAsString(context);
  Object target = getAttribute("target").evaluate(context);
  String property = getAttribute("property").evaluateAsString(context);
      throw new JellyTagException("The 'target' and 'property' attributes cannot be used in combination with the 'var' attribute");
      throw new JellyTagException("Either a 'var' or a 'target' attribute must be defined for this tag");
      throw new JellyTagException("The 'target' attribute requires the 'property' attribute");
    answer = value.exp.evaluate(context);
    ExpressionAttribute defaultValue = attributes.get("defaultValue");
      answer = defaultValue.exp.evaluate(context);
    answer = getBodyText(context,getAttribute("encode").evaluateAsBoolean(context));
    String scope = getAttribute("scope").evaluateAsString(context);
    if (scope != null) {
      context.setVariable(var, scope, answer);
    } else {
      context.setVariable(var, answer);

代码示例来源:origin: commons-jelly/commons-jelly

/** Evaluates the body of a tag */
  public void run(JellyContext context, XMLOutput output) throws JellyTagException {
    Object result = expression.evaluate(context);
    if ( result != null ) {

      try {
       output.objectData(result);
      } catch (SAXException e) {
        throw new JellyTagException("Could not write to XMLOutput",e);
      }

    }
  }
}

代码示例来源:origin: commons-jelly/commons-jelly-tags-fmt

/**
 * Evaluates this tag after all the tags properties have been initialized.
 *
 */
public void doTag(XMLOutput output) throws JellyTagException {
  Object basenameInput = null;
  if (this.basename != null) {
    basenameInput = this.basename.evaluate(context);
  }
  LocalizationContext locCtxt = BundleTag.getLocalizationContext(
    context, (String) basenameInput);
  String varname = (var != null) ? var : Config.FMT_LOCALIZATION_CONTEXT;
  if (scope != null) {
    context.setVariable(varname, scope, locCtxt);
  }
  else {
    context.setVariable(varname, locCtxt);
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

public Object evaluate(JellyContext context) {
  Object answer = jexlExpression.evaluate(context);
  if ( answer == null ) {
    answer = context.getVariable(text);
  }
  return answer;
}

代码示例来源:origin: commons-jelly/commons-jelly

public void doTag(XMLOutput output) throws BreakException {
  boolean broken = false;
  if (test == null || test.evaluateAsBoolean(context)) {
    broken = true;
  }
  if ( var != null ) {
    context.setVariable( this.var, String.valueOf(broken));
  }
  if ( broken ) {
    throw new BreakException();
  }
}

代码示例来源:origin: org.jenkins-ci/commons-jelly

Iterator iter = items.evaluateAsIterator(context);
  Integer statusStep = (step == 1) ? null : new Integer(step);
  status = new LoopStatus(statusBegin, statusEnd, statusStep);
  context.setVariable(statusVar, status);
  Object value = iter.next();
  if (var != null) {
    context.setVariable(var, value);
    context.setVariable(indexVar, new Integer(index));

代码示例来源:origin: org.jenkins-ci/commons-jelly

URL rootURL = context.getRootURL();
URL currentURL = context.getCurrentURL();
final Object oldParent=context.getVariables().get(PARENT_TAG);
try {
  Tag tag = getTag(context);
        value = expression.evaluateRecurse(context);
        value = expression.evaluateRecurse(context);

代码示例来源:origin: stapler/stapler

/**
   * Adds {@link XMLOutput} to the context.
   */
  public void run(JellyContext context, XMLOutput output) throws JellyTagException {
    context.setVariable(getAttribute("var").evaluateAsString(context),output);
  }
};

代码示例来源:origin: stapler/stapler

@Override
  protected Script resolveDefinition(JellyContext context) throws JellyTagException {
    Object it = expr.evaluate(context);
    if (it==null)
      throw new JellyTagException("'"+ expr.getExpressionText() +"' evaluated to null");
    try {
      WebApp webApp = WebApp.getCurrent();
      MetaClass c = webApp.getMetaClass(it instanceof Class ? Klass.java((Class)it):  webApp.getKlass(it));
      // prefer 'foo.jellytag' to avoid tags from showing up as views,
      // but for backward compatibility, support the plain .jelly extension as well.
      Script tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jellytag");
      if (tag==null)
        tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jelly");
      if (tag ==null)
        throw new JellyTagException("No such tag file "+tagName+".jellytag in "+c);
      return tag;
    } catch (JellyException e) {
      throw new JellyTagException("Failed to load "+tagName+".jellytag from "+it,e);
    }
  }
};

代码示例来源:origin: commons-jelly/commons-jelly

public void doTag(XMLOutput output) throws JellyTagException {
  ChooseTag tag = (ChooseTag) findAncestorWithClass( ChooseTag.class );
  if ( tag == null ) {
    throw new JellyTagException( "This tag must be enclosed inside a <choose> tag" );
  }
  if ( ! tag.isBlockEvaluated() && test != null ) {
    if ( test.evaluateAsBoolean( context ) ) {
      tag.setBlockEvaluated(true);
      invokeBody(output);
    }
  }
}

代码示例来源:origin: org.jvnet.hudson/commons-jelly

public void doTag(XMLOutput output) throws MissingAttributeException {
  if (var != null) {
    context.removeVariable( var.evaluateAsString(context) );
  }
  else {
    throw new MissingAttributeException("var");
  }
}

代码示例来源:origin: org.jvnet.hudson/commons-jelly

public String evaluateAsString(JellyContext context) {
  StringBuffer buffer = new StringBuffer();
  for (Iterator iter = expressions.iterator(); iter.hasNext(); ) {
    Expression expression = (Expression) iter.next();
    String value = expression.evaluateAsString(context);
    if ( value != null ) {
      buffer.append( value );
    }
  }
  return buffer.toString();
}

代码示例来源:origin: commons-jelly/commons-jelly

public void doTag(XMLOutput output) throws JellyTagException {
  if (test == null && xpath == null) {
    throw new MissingAttributeException( "test" );
  }
  if (test != null) {
    if (! test.evaluateAsBoolean(context)) {
      fail( getBodyText(), "evaluating test: "+ test.getExpressionText() );
    }
  }
  else {
    try {
      Object xpathContext = getXPathContext();
      if (! xpath.booleanValueOf(xpathContext)) {
        fail( getBodyText(), "evaluating xpath: "+ xpath );
      }
    } catch (JaxenException anException) {
      throw new JellyTagException("Error evaluating xpath", anException);
    }
  }
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

public Object evaluate(JellyContext context) {
    context = new CustomJellyContext(context);
    context.setVariables(resourceLiterals);
    return innerExpression.evaluate(context);
  }
}

代码示例来源:origin: commons-jelly/commons-jelly

public void doTag(XMLOutput output) throws JellyTagException {
  String message = getBodyText();
  Object expectedValue = expected.evaluate(context);
  Object actualValue = actual.evaluate(context);
  if (expectedValue == null && actualValue == null) {
    return;
  }
  if (actualValue != null && expectedValue.equals(actualValue)) {
    return;
  }
  String expressions = "\nExpected expression: "
    + expected.getExpressionText()
    + "\nActual expression: "
    + actual.getExpressionText();
  failNotEquals(message, expectedValue, actualValue, expressions);
}

代码示例来源:origin: commons-jelly/commons-jelly

public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
  if (test != null) {
    if (test.evaluateAsBoolean(context)) {
      invokeBody(output);
    }
  }
  else {
    throw new MissingAttributeException( "test" );
  }
}

代码示例来源:origin: org.hudsonci.stapler/commons-jelly

public String getExpressionText() {
  return base.getExpressionText();
}

代码示例来源:origin: commons-jelly/commons-jelly

public Object evaluateRecurse(JellyContext context) {
  Object value = evaluate(context);
  if (value instanceof Expression) {
    Expression expression = (Expression) value;
    return expression.evaluateRecurse(context);
  }
  return value;
}

相关文章