Example usage for org.apache.commons.jelly.expression ConstantExpression ConstantExpression

List of usage examples for org.apache.commons.jelly.expression ConstantExpression ConstantExpression

Introduction

In this page you can find the example usage for org.apache.commons.jelly.expression ConstantExpression ConstantExpression.

Prototype

public ConstantExpression(Object value) 

Source Link

Document

Convenience constructor sets value property.

Usage

From source file:hudson.util.HyperlinkingOutTagTest.java

private void assertOutput(String in, String out) throws Exception {
    StringWriter w = new StringWriter();
    XMLOutput xmlo = XMLOutput.createXMLOutput(w);
    HyperlinkingOutTag tag = new HyperlinkingOutTag();
    tag.setValue(new ConstantExpression(in));
    tag.doTag(xmlo);//from  w w  w . ja v a2  s  . c  om
    assertEquals(out, w.toString());
}

From source file:org.kohsuke.stapler.jelly.groovy.JellyBuilder.java

/**
 * Create a tag script if the given QName is a taglib invocation, or return null
 * to handle it like a literal static tag.
 *//*  w w w  . ja  v a 2 s .  c  o m*/
private TagScript createTagScript(QName n, Map<?, ?> attributes) throws JellyException {
    TagLibrary lib = context.getTagLibrary(n.getNamespaceURI());
    if (lib != null) {
        String localName = n.getLocalPart();

        TagScript tagScript = lib.createTagScript(localName, null/*this parameter appears to be unused.*/);
        if (tagScript == null)
            tagScript = lib.createTagScript(localName.replace('_', '-'), null);

        if (tagScript != null) {
            if (attributes != null) {
                for (Entry e : attributes.entrySet()) {
                    Object v = e.getValue();
                    if (v != null)
                        tagScript.addAttribute(e.getKey().toString(), new ConstantExpression(v));
                }
            }

            return tagScript;
        }
    }

    // otherwise treat it as a literal.
    return null;
}

From source file:org.kohsuke.stapler.jelly.groovy.JellyBuilder.java

/**
 * Obtains the value from the map entry in the right type.
 *//*from ww w  . j  a va 2 s . com*/
private Object getValue(Entry entry, Class type) {
    Object value = entry.getValue();
    if (type == Expression.class)
        value = new ConstantExpression(entry.getValue());
    return value;
}