本文整理汇总了Java中org.apache.velocity.runtime.parser.node.Node.jjtGetChild方法的典型用法代码示例。如果您正苦于以下问题:Java Node.jjtGetChild方法的具体用法?Java Node.jjtGetChild怎么用?Java Node.jjtGetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.velocity.runtime.parser.node.Node
的用法示例。
在下文中一共展示了Node.jjtGetChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
// get the bean
ValueStack stack = (ValueStack) ctx.get("stack");
HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
Component bean = getBean(stack, req, res);
Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
container.inject(bean);
// get the parameters
Map params = createPropertyMap(ctx, node);
bean.copyParams(params);
//bean.addAllParameters(params);
bean.start(writer);
if (getType() == BLOCK) {
Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1);
body.render(ctx, writer);
}
bean.end(writer, "");
return true;
}
示例2: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer,
Node node) throws IOException, ResourceNotFoundException,
ParseErrorException, MethodInvocationException
{
int argsNum = node.jjtGetNumChildren();
for(int step = 0 ; step < argsNum; step++)
{
SimpleNode simpleNode = (SimpleNode) node.jjtGetChild(step);
Object argObject = simpleNode.value(context);
//传入参数
if(argObject instanceof String)
{
System.out.println((String)argObject);
writer.write((String)argObject);
writer.flush();
}
}
return true;
}
示例3: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException {
String block = "";
TypeDef clazz = null;
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
if (node.jjtGetChild(i) != null) {
if (!(node.jjtGetChild(i) instanceof ASTBlock)) {
//reading and casting inline parameters
if (i == 0) {
clazz = (TypeDef) node.jjtGetChild(i).value(context);
} else {
break;
}
} else {
//reading block content and rendering it
StringWriter blockContent = new StringWriter();
node.jjtGetChild(i).render(context, blockContent);
block = blockContent.toString();
break;
}
}
}
writeClazz(writer, clazz, block);
return true;
}
示例4: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
Object value = node.jjtGetChild(0).value(context);
boolean isEmpty = false ;
if(value == null){
isEmpty = true ;
}else{
if(value instanceof String){
isEmpty = StringUtil.isEmpty((String) value) ;
}else if(value instanceof Collection){
isEmpty = ((Collection) value).isEmpty() ;
}else if(value.getClass().isArray()){
isEmpty = Array.getLength(value) > 0 ;
}
}
if (isEmpty) {
Node content = node.jjtGetChild(1);
content.render(context, writer);
}
return true;
}
示例5: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
Object value = node.jjtGetChild(0).value(context);
boolean isEmpty = false ;
if(value == null){
isEmpty = true ;
}else{
if(value instanceof String){
isEmpty = StringUtil.isEmpty((String) value) ;
}else if(value instanceof Collection){
isEmpty = ((Collection) value).isEmpty() ;
}else if(value.getClass().isArray()){
isEmpty = Array.getLength(value) > 0 ;
}
}
if (!isEmpty) {
Node content = node.jjtGetChild(1);
content.render(context, writer);
}
return true;
}
示例6: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
//setting default params
String moneyValue = null;
//reading params
if (node.jjtGetChild(0) != null) {
moneyValue = node.jjtGetChild(0).value(context) == null ? null : String.valueOf(node.jjtGetChild(0).value(context));
}
//truncate and write result to writer
writer.write(moneyUAH(moneyValue));
return true;
}
示例7: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
//setting default params
String ukrValue = null;
//reading params
if (node.jjtGetChild(0) != null) {
ukrValue = node.jjtGetChild(0).value(context) == null ? null : String.valueOf(node.jjtGetChild(0).value(context));
}
if (ukrValue == null) {
return false;
}
//truncate and write result to writer
writer.write(UkrainianToLatin.generateLat(ukrValue));
return true;
}
示例8: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
//setting default params
String moneyValue = null;
//reading params
if (node.jjtGetChild(0) != null) {
moneyValue = String.valueOf(node.jjtGetChild(0).value(context));
}
//truncate and write result to writer
writer.write(moneyToStrUAH(moneyValue));
return true;
}
示例9: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
public boolean render(InternalContextAdapter context, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
//setting default params
String dateValue = null;
//reading params
if (node.jjtGetChild(0) != null) {
dateValue = String.valueOf(node.jjtGetChild(0).value(context));
}
//truncate and write result to writer
writer.write(date(dateValue));
return true;
}
示例10: getParams
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
protected Params getParams(InternalContextAdapter context, Node node) throws IOException {
final Params params = new Params();
params.setPrefix("WHERE");
params.setPrefixOverrides("AND |OR |AND\n|OR\n|AND\r|OR\r");
if (node.jjtGetNumChildren() == 1) {
final Node child = node.jjtGetChild(0);
if (child instanceof ASTBlock) {
StringWriter blockContent = new StringWriter();
child.render(context, blockContent);
params.setBody(blockContent.toString().trim());
return params;
}
}
return null;
}
示例11: init
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) {
super.init(rs, context, node);
final int n = node.jjtGetNumChildren() - 1;
for (int i = 1; i < n; i++) {
Node child = node.jjtGetChild(i);
if (i == 1) {
if (child.getType() == ParserTreeConstants.JJTREFERENCE) {
this.var = ((ASTReference) child).getRootString();
}
else {
throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
}
}
else if (child.getType() == ParserTreeConstants.JJTSTRINGLITERAL) {
String value = (String) ((ASTStringLiteral) child).value(context);
if (i == 2) {
this.column = value;
}
}
else {
throw new TemplateInitException("Syntax error", getTemplateName(), getLine(), getColumn());
}
}
this.uberInfo = new Info(this.getTemplateName(), getLine(), getColumn());
}
示例12: getParams
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
protected Params getParams(InternalContextAdapter context, Node node) throws IOException {
final Params params = new Params();
params.setPrefix("SET");
params.setSuffixOverrides(",");
if (node.jjtGetNumChildren() == 1) {
final Node child = node.jjtGetChild(0);
if (child instanceof ASTBlock) {
StringWriter blockContent = new StringWriter();
child.render(context, blockContent);
params.setBody(blockContent.toString().trim());
return params;
}
}
return null;
}
示例13: createPropertyMap
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
/**
* <p>
* Create a Map of properties that the user has passed in. For example:
* </p>
*
* <pre>
* #xxx("name=hello" "value=world" "template=foo")
* </pre>
*
* <p>
* would yield a params that contains {["name", "hello"], ["value", "world"], ["template", "foo"]}
* </p>
* @param contextAdapter the context adapter
* @param node the Node passed in to the render method
* @return a Map of the user specified properties
* @throws org.apache.velocity.exception.ParseErrorException
* if the was an error in the format of the property
*/
protected Map createPropertyMap(InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException {
Map propertyMap;
int children = node.jjtGetNumChildren();
if (getType() == BLOCK) {
children--;
}
// Velocity supports an on-the-fly Map-definition syntax that leads
// to more readable and faster code:
//
// #url({'id':'url', 'action':'MyAction'})
//
// We support this syntax by checking for a single Map argument
// to any directive and using that as the property map instead
// of building one from individual name-value pair strings.
Node firstChild = null;
Object firstValue = null;
if(children == 1
&& null != (firstChild = node.jjtGetChild(0))
&& null != (firstValue = firstChild.value(contextAdapter))
&& firstValue instanceof Map) {
propertyMap = (Map)firstValue;
} else {
propertyMap = new HashMap();
for (int index = 0, length = children; index < length; index++) {
this.putProperty(propertyMap, contextAdapter, node.jjtGetChild(index));
}
}
return propertyMap;
}
示例14: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException {
String block = "";
Property field = null;
//reading params
if (node.jjtGetChild(0) != null) {
field = (Property) node.jjtGetChild(0).value(context);
}
writeField(writer, field, block);
return true;
}
示例15: render
import org.apache.velocity.runtime.parser.node.Node; //导入方法依赖的package包/类
@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException {
String block = "";
Method method = null;
Boolean isInterface = false;
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
if (node.jjtGetChild(i) != null) {
if (!(node.jjtGetChild(i) instanceof ASTBlock)) {
//reading and casting inline parameters
if (i == 0) {
method = (Method) node.jjtGetChild(i).value(context);
} else if (i == 1) {
isInterface = (Boolean) node.jjtGetChild(i).value(context);
} else {
break;
}
} else {
//reading block content and rendering it
StringWriter blockContent = new StringWriter();
node.jjtGetChild(i).render(context, blockContent);
block = blockContent.toString();
break;
}
}
}
writeMethod(writer, method, block, isInterface);
return true;
}