Tabnine Logo
Jelly
Code IndexAdd Tabnine to your IDE (free)

How to use
Jelly
in
org.apache.commons.jelly

Best Java code snippets using org.apache.commons.jelly.Jelly (Showing top 20 results out of 315)

origin: org.jvnet.hudson/commons-jelly

System.err.println("Jelly " + Jelly.getJellyVersion());
System.err.println(" compiled: " + Jelly.getJellyBuildDate());
System.err.println("");
System.exit(1);
    XMLOutput.createXMLOutput(System.out);
Jelly jelly = new Jelly();
jelly.setScript(scriptFile);
final Script script = jelly.compileScript();
final JellyContext context = jelly.getJellyContext();
context.setVariable("args", args);
context.setVariable("commandLine", cmdLine);
origin: commons-jelly/commons-jelly

public void setUp(String scriptName) throws Exception {
  this.context = new JellyContext();
  this.xmlOutput = XMLOutput.createDummyXMLOutput();
  this.jelly = new Jelly();
  String script = scriptName;
  URL url = this.getClass().getResource(script);
  if ( url == null ) {
    throw new Exception(
      "Could not find Jelly script: " + script
      + " in package of class: " + this.getClass().getName()
    );
  }
  this.jelly.setUrl(url);
}
origin: org.jenkins-ci/commons-jelly

/**
 * The context to use
 */
public JellyContext getJellyContext() throws MalformedURLException {
  if (context == null) {
    // take off the name off the URL
    String text = getUrl().toString();
    int idx = text.lastIndexOf('/');
    text = text.substring(0, idx + 1);
    context = new JellyContext(getRootContext(), new URL(text));
  }
  return context;
}
origin: org.hudsonci.stapler/commons-jelly

/** 
 * Sets the script URL to use as an absolute URL or a relative filename
 */
public void setScript(String script) throws MalformedURLException {
  setUrl(resolveURL(script));
}
 
origin: commons-jelly/commons-jelly

public void testInvalidXML1Validation() throws Exception {
  // with validation
  setUp("invalidScript1.jelly");
  jelly.setValidateXML(true);
  try {
    Script script = jelly.compileScript();
    fail("Invalid scripts should throw JellyException on parse");
  } catch (JellyException e) {
  }
}
origin: commons-jelly/commons-jelly

/**
 * A script should fail to parse if it declares tags that don't exist.
 */
public void testNonexistentTags() throws Exception {
  setUp("nonexistentTags1.jelly");
  try {
    Script script = jelly.compileScript();
    fail("Scripts should throw JellyException when it declares a nonexistent tag.");
  } catch (JellyException e) {
  }
}
origin: commons-jelly/commons-jelly

if (! loadedProperties) {
  loadedProperties = true;
  loadJellyProperties();
  parser.setContext(getJellyContext());
} catch (MalformedURLException e) {
  throw new JellyException(e.toString());
  parser.setDefaultNamespaceURI(this.defaultNamespaceURI);
  parser.setValidating(this.validateXML);
  script = parser.parse(getUrl());
  script = script.compile();
  if (log.isDebugEnabled()) {
    log.debug("Compiled script: " + getUrl());
origin: commons-jelly/commons-jelly

/**
 * CDATA sections should be retained in the output.
 *
 * @throws Exception
 */
public void testCData() throws Exception {
  Jelly jelly = new Jelly();
  jelly.setScript("file:src/test/org/apache/commons/jelly/test/xml/testCData.jelly");
  Script script = jelly.compileScript();
  JellyContext context = new JellyContext();
  script.run(context, XMLOutput.createDummyXMLOutput());
  String output = (String) context.getVariable("foo");
  assertTrue("'foo' is not null", output != null);
  String golden = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  golden += "<!DOCTYPE foo [\n";
  golden += "  <!ELEMENT foo (#PCDATA)>\n";
  golden += "]><foo></foo>";
  assertEquals("output should contain the CDATA section", golden, output);
}
origin: org.jenkins-ci/commons-jelly

public void setUp() throws Exception {
  super.setUp();
  jelly = new Jelly();
  context = new JellyContext();
  xmlOutput = XMLOutput.createDummyXMLOutput();
}
origin: commons-jelly/commons-jelly

protected void setUpScript(String scriptname) throws Exception {
  URL url = this.getClass().getResource(scriptname);
  if(null == url) {
    throw new Exception(
      "Could not find Jelly script: " + scriptname
      + " in package of class: " + getClass().getName()
    );
  }
  jelly.setUrl(url);
  String exturl = url.toExternalForm();
  int lastSlash = exturl.lastIndexOf("/");
  String extBase = exturl.substring(0,lastSlash+1);
  URL baseurl = new URL(extBase);
  context.setCurrentURL(baseurl);
}
origin: commons-jelly/commons-jelly

public void testNamespaceDefined() throws Exception {
  jelly.setDefaultNamespaceURI("jelly:core");
  Script script = jelly.compileScript();
  script.run(context,xmlOutput);
  assertTrue("should have set 'usedDefaultNamespace' variable",
        context.getVariable("usedDefaultNamespace") != null);
}
origin: commons-jelly/commons-jelly

  /**
   * Loads the properties from the given input stream 
   */    
  protected void loadProperties(InputStream is) throws IOException {
    JellyContext theContext = getJellyContext();
    Properties props = new Properties();
    props.load(is);
    Enumeration propsEnum = props.propertyNames();
    while (propsEnum.hasMoreElements()) {
      String key = (String) propsEnum.nextElement();
      String value = props.getProperty(key);
      
      // @todo we should parse the value in case its an Expression
      theContext.setVariable(key, value);
    }
  }
}
origin: commons-jelly/commons-jelly

  public void testNamespaceNotDefined() throws Exception {
    Script script = jelly.compileScript();
    script.run(context,xmlOutput);
    assertTrue("should not have set 'usedDefaultNamespace' variable",
          context.getVariable("usedDefaultNamespace") == null);
  }
}
origin: org.jvnet.hudson/commons-jelly

if (! loadedProperties) {
  loadedProperties = true;
  loadJellyProperties();
  parser.setContext(getJellyContext());
} catch (MalformedURLException e) {
  throw new JellyException(e.toString());
  parser.setDefaultNamespaceURI(this.defaultNamespaceURI);
  parser.setValidating(this.validateXML);
  script = parser.parse(getUrl());
  script = script.compile();
  if (log.isDebugEnabled()) {
    log.debug("Compiled script: " + getUrl());
origin: commons-jelly/commons-jelly

/** 
 * Sets the script URL to use as an absolute URL or a relative filename
 */
public void setScript(String script) throws MalformedURLException {
  setUrl(resolveURL(script));
}

origin: commons-jelly/commons-jelly

public void testParserCache1() throws Exception {
  // without validation, should
  // not fail because validation is disabled
  setUp("invalidScript1.jelly");
  jelly.setValidateXML(false);
  Script script = jelly.compileScript();
  script.run(context,xmlOutput);
  assertTrue("should have set 'foo' variable to 'bar'",
        context.getVariable("foo").equals("bar"));
  // if I enable xml validation, the script should fail
  // despite the cache
  jelly.setValidateXML(true);
  try {
    script = jelly.compileScript();
    fail("Invalid scripts should throw JellyException on parse, despite the cache");
  } catch (JellyException e) {
  }
}
origin: commons-jelly/commons-jelly

public void setUp() throws Exception {
  super.setUp();
  jelly = new Jelly();
  context = new JellyContext();
  xmlOutput = XMLOutput.createDummyXMLOutput();
}
origin: org.jvnet.hudson/commons-jelly

protected void setUpScript(String scriptname) throws Exception {
  URL url = this.getClass().getResource(scriptname);
  if(null == url) {
    throw new Exception(
      "Could not find Jelly script: " + scriptname
      + " in package of class: " + getClass().getName()
    );
  }
  jelly.setUrl(url);
  String exturl = url.toExternalForm();
  int lastSlash = exturl.lastIndexOf("/");
  String extBase = exturl.substring(0,lastSlash+1);
  URL baseurl = new URL(extBase);
  context.setCurrentURL(baseurl);
}
origin: commons-jelly/commons-jelly

  public void testParserCache2() throws Exception {
    // no default namespace
    setUp("nsFilterTest.jelly");
    Script script = jelly.compileScript();
    script.run(context,xmlOutput);
    assertTrue("should have no var when default namspace is not set",
          context.getVariable("usedDefaultNamespace") == null);

    // now we have a default namespace, so we
    // should see a variable, despite the XMLParser cache
    jelly.setDefaultNamespaceURI("jelly:core");
    script = jelly.compileScript();
    script.run(context,xmlOutput);
    assertTrue("should have var when default namspace is set",
          context.getVariable("usedDefaultNamespace").equals("true"));
  }
}
origin: org.jenkins-ci/commons-jelly

  /**
   * Loads the properties from the given input stream 
   */    
  protected void loadProperties(InputStream is) throws IOException {
    JellyContext theContext = getJellyContext();
    Properties props = new Properties();
    props.load(is);
    Enumeration propsEnum = props.propertyNames();
    while (propsEnum.hasMoreElements()) {
      String key = (String) propsEnum.nextElement();
      String value = props.getProperty(key);
      
      // @todo we should parse the value in case its an Expression
      theContext.setVariable(key, value);
    }
  }
}
org.apache.commons.jellyJelly

Javadoc

Jelly is a helper class which is capable of running a Jelly script. This class can be used from the command line or can be used as the basis of an Ant task.

Command line usage is as follows:
 
jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval] 

Most used methods

  • <init>
  • compileScript
    Compiles the script
  • setScript
    Sets the script URL to use as an absolute URL or a relative filename
  • setUrl
    Sets the script URL to use
  • getJellyBuildDate
  • getJellyContext
    The context to use
  • getJellyVersion
  • getRootContext
    Gets the root context
  • getUrl
  • loadJellyProperties
    Attempts to load jelly.properties from the current directory, the users home directory or from the c
  • loadProperties
    Loads the properties from the given input stream
  • readBuildTimestampResource
  • loadProperties,
  • readBuildTimestampResource,
  • resolveURL,
  • setDefaultNamespaceURI,
  • setValidateXML

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getResourceAsStream (ClassLoader)
  • addToBackStack (FragmentTransaction)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Kernel (java.awt.image)
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Table (org.hibernate.mapping)
    A relational table
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now