@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Node escapeTypeNode = node.jjtGetChild(0); Object escapeTypeObject = escapeTypeNode.value(context); String escapeTypeString = escapeTypeObject == null ? null : escapeTypeObject.toString(); EscapeType escapeType = EscapeType.getEscapeType(escapeTypeString); if (escapeType == null) { throw new ParseErrorException("Invalid escape type: " + escapeTypeObject + " at " + new Info(escapeTypeNode.getTemplateName(), escapeTypeNode.getColumn(), escapeTypeNode.getLine()) + ". Available escape types: " + EscapeType.getNames()); } return renderWithEscape(escapeType, context, writer, node.jjtGetChild(1)); } }
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Node escapeTypeNode = node.jjtGetChild(0); Object escapeTypeObject = escapeTypeNode.value(context); String escapeTypeString = escapeTypeObject == null ? null : escapeTypeObject.toString(); EscapeType escapeType = EscapeType.getEscapeType(escapeTypeString); if (escapeType == null) { throw new ParseErrorException("Invalid escape type: " + escapeTypeObject + " at " + new Info(escapeTypeNode.getTemplateName(), escapeTypeNode.getColumn(), escapeTypeNode.getLine()) + ". Available escape types: " + EscapeType.getNames()); } return renderWithEscape(escapeType, context, writer, node.jjtGetChild(1)); } }
static String getRequiredArgument(InternalContextAdapter context,Node node,int argumentIndex,String directive) throws ParseErrorException { SimpleNode sn_value = (SimpleNode)node.jjtGetChild(argumentIndex); if ( sn_value == null){ throw new ParseErrorException("required argument is null with directive:#"+directive+"(),argumentIndex="+argumentIndex); } String value = (String)sn_value.value(context); if ( value == null){ throw new ParseErrorException("required argument is null with directive:#"+directive+"(),argumentIndex="+argumentIndex); } return value; }
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException,MethodInvocationException { OverrideNodeWrapper current = (OverrideNodeWrapper)context.get(Utils.OVERRIDE_CURRENT_NODE); if(current == null) { throw new ParseErrorException("#super direction must be child of override"); } OverrideNodeWrapper parent = current.parentNode; if(parent == null) { throw new ParseErrorException("not found parent block for #super "); } return parent.render(context,writer); }
/** * adds a given Node's key/value pair to the propertyMap. For example, if this Node contained the value "rows=20", * then the key, rows, would be added to the propertyMap with the String value, 20. * * @param propertyMap a params containing all the properties that we wish to set * @param node the parameter to set expressed in "name=value" format */ protected void putProperty(Map propertyMap, InternalContextAdapter contextAdapter, Node node) throws ParseErrorException, MethodInvocationException { // node.value uses the WebWorkValueStack to evaluate the directive's value parameter String param = node.value(contextAdapter).toString(); int idx = param.indexOf("="); if (idx != -1) { String property = param.substring(0, idx); String value = param.substring(idx + 1); propertyMap.put(property, value); } else { throw new ParseErrorException("#" + this.getName() + " arguments must include an assignment operator! For example #tag( Component \"template=mytemplate\" ). #tag( TextField \"mytemplate\" ) is illegal!"); } } }
/** * Check for an invalid reference and collect the error or throw an exception * (depending on configuration). * * @param reference the invalid reference * @param info line, column, template name */ private void reportInvalidReference(String reference, Info info) { InvalidReferenceInfo invalidReferenceInfo = new InvalidReferenceInfo(reference, info); invalidReferences.add(invalidReferenceInfo); if (stopOnFirstInvalidReference) { throw new ParseErrorException( "Error in page - invalid reference. ", info, invalidReferenceInfo.getInvalidReference()); } }
/** * Check for an invalid reference and collect the error or throw an exception * (depending on configuration). * * @param reference the invalid reference * @param info line, column, template name */ private void reportInvalidReference(String reference, Info info) { InvalidReferenceInfo invalidReferenceInfo = new InvalidReferenceInfo(reference, info); invalidReferences.add(invalidReferenceInfo); if (stopOnFirstInvalidReference) { throw new ParseErrorException( "Error in page - invalid reference. ", info, invalidReferenceInfo.getInvalidReference()); } }
/** * Check for an invalid reference and collect the error or throw an exception * (depending on configuration). * * @param reference the invalid reference * @param info line, column, template name */ private void reportInvalidReference(String reference, Info info) { InvalidReferenceInfo invalidReferenceInfo = new InvalidReferenceInfo(reference, info); invalidReferences.add(invalidReferenceInfo); if (stopOnFirstInvalidReference) { throw new ParseErrorException( "Error in page - invalid reference. ", info, invalidReferenceInfo.getInvalidReference()); } }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException { String path = node.jjtGetChild(0).value(context).toString(); String pagelet = null; if (path.startsWith("/")) {// 如果是绝对路径 pagelet = path; } else { String templatePath = node.getTemplateName(); pagelet = templatePath.substring(0, templatePath.lastIndexOf('/') + 1) + path; } VelocityHelperImpl velocityHelperImpl = SpringUtil .getBean("velocityHelper"); try { velocityHelperImpl.processTempleate(context, writer, pagelet); } catch (Exception e) { logger.errorMessage(e.getMessage(), e); throw new ParseErrorException(e.getMessage()); } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException { String path = node.jjtGetChild(0).value(context).toString(); String pagelet = null; if (path.startsWith("/")) {// 如果是绝对路径 pagelet = path; } else { String templatePath = node.getTemplateName(); pagelet = templatePath.substring(0, templatePath.lastIndexOf('/') + 1) + path; } VelocityHelperImpl velocityHelperImpl = SpringUtil .getBean("velocityHelper"); try { velocityHelperImpl.processTempleate(context, writer, pagelet); } catch (Exception e) { logger.errorMessage(e.getMessage(), e); throw new ParseErrorException(e.getMessage()); } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException { String path = node.jjtGetChild(0).value(context).toString(); String pagelet = null; if (path.startsWith("/")) {// 如果是绝对路径 pagelet = path; } else { String templatePath = node.getTemplateName(); pagelet = templatePath.substring(0, templatePath.lastIndexOf('/') + 1) + path; } VelocityHelperImpl velocityHelperImpl = SpringUtil .getBean("velocityHelper"); try { velocityHelperImpl .processBigpipeTempleate(context, writer, pagelet); } catch (Exception e) { logger.errorMessage(e.getMessage(), e); throw new ParseErrorException(e.getMessage()); } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException { String path = node.jjtGetChild(0).value(context).toString(); String pagelet = null; if (path.startsWith("/")) {// 如果是绝对路径 pagelet = path; } else { String templatePath = node.getTemplateName(); pagelet = templatePath.substring(0, templatePath.lastIndexOf('/') + 1) + path; } VelocityHelperImpl velocityHelperImpl = SpringUtil .getBean("velocityHelper"); try { velocityHelperImpl .processBigpipeTempleate(context, writer, pagelet); } catch (Exception e) { logger.errorMessage(e.getMessage(), e); throw new ParseErrorException(e.getMessage()); } return true; }
protected Map toIdMap(Object object) throws ParseErrorException { if (object instanceof Persistent) { return ((Persistent) object).getObjectId().getIdSnapshot(); } else if (object instanceof ObjectId) { return ((ObjectId) object).getIdSnapshot(); } else if(object instanceof Map) { return (Map) object; } else if (object != null) { throw new ParseErrorException( "Invalid object parameter, expected Persistent or ObjectId or null: " + object); } else { return null; } }
throw new ParseErrorException("Invalid parameters. " + "Either object has to be set " + "or sqlColumns and idColumns or both."); throw new ParseErrorException( "SQL columns and ID columns arrays have different sizes.");
throw new ParseErrorException(pex.getMessage());
throw new ParseErrorException(pex.getMessage());
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { if(node.jjtGetNumChildren() != 2){ throw new RuntimeException(getName() + " accepts 2 parameters. The first is a boolean value indicating whether or not to add this conditon; the second is a List containing your conditions!") ; } Boolean test = (Boolean) node.jjtGetChild(0).value(context) ; if(Boolean.FALSE.equals(test)){ //ignore this condition. return true ; } Collection conditions = (Collection) node.jjtGetChild(1).value(context) ; BoundaryChain chain = (BoundaryChain) context.get(GuzzBoundaryDirective.BOUNDARY_CONTEXT_NAME) ; if(chain == null){ throw new ParseErrorException(getName() + " must be resided inside a guzzBoundary directive.") ; } chain.addLimitConditions(conditions) ; return true; } public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
/** * @since 3.0 */ protected void render(InternalContextAdapter context, Writer writer, Node node, Object value, String typeString, int scale) throws IOException, ParseErrorException { int jdbcType = TypesMapping.NOT_DEFINED; if (typeString != null) { jdbcType = TypesMapping.getSqlTypeByName(typeString); } else if (value != null) { jdbcType = TypesMapping.getSqlTypeByJava(value.getClass()); } else { // value is null, set JDBC type to NULL jdbcType = TypesMapping.getSqlTypeByName(TypesMapping.SQL_NULL); } if (jdbcType == TypesMapping.NOT_DEFINED) { throw new ParseErrorException("Can't determine JDBC type of binding (" + value + ", " + typeString + ") at line " + node.getLine() + ", column " + node.getColumn()); } render(context, writer, new ParameterBinding(value, jdbcType, scale)); }
throw new ParseErrorException( "Can't determine JDBC type of binding (" + value
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Node escapeTypeNode = node.jjtGetChild(0); Object escapeTypeObject = escapeTypeNode.value(context); String escapeTypeString = escapeTypeObject == null ? null : escapeTypeObject.toString(); EscapeType escapeType = EscapeType.getEscapeType(escapeTypeString); if (escapeType == null) { throw new ParseErrorException("Invalid escape type: " + escapeTypeObject + " at " + new Info(escapeTypeNode.getTemplateName(), escapeTypeNode.getColumn(), escapeTypeNode.getLine()) + ". Available escape types: " + EscapeType.getNames()); } return renderWithEscape(escapeType, context, writer, node.jjtGetChild(1)); } }