
com.mitchellbosecke.pebble.node.TextNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pebble Show documentation
Show all versions of pebble Show documentation
Templating engine for Java.
/*******************************************************************************
* This file is part of Pebble.
*
* Copyright (c) 2014 by Mitchell Bösecke
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
******************************************************************************/
package com.mitchellbosecke.pebble.node;
import java.io.IOException;
import java.io.Writer;
import com.mitchellbosecke.pebble.extension.NodeVisitor;
import com.mitchellbosecke.pebble.template.EvaluationContext;
import com.mitchellbosecke.pebble.template.PebbleTemplateImpl;
/**
* Represents static text in a template.
*
* @author mbosecke
*
*/
public class TextNode extends AbstractRenderableNode {
/**
* Most Writers will convert strings to char[] so we might as well store it
* as a char[] to begin with; small performance optimization.
*/
private final char[] data;
public TextNode(String text, int lineNumber) {
super(lineNumber);
int length = text.length();
this.data = new char[text.length()];
text.getChars(0, length, this.data, 0);
}
@Override
public void render(PebbleTemplateImpl self, Writer writer, EvaluationContext context) throws IOException {
writer.write(data);
}
@Override
public void accept(NodeVisitor visitor) {
visitor.visit(this);
}
public char[] getData() {
return data;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy