protected InvalidReferenceException newNullPropertyException( String propertyName, TemplateModel tm, Environment env) { if (env.getFastInvalidReferenceExceptions()) { return InvalidReferenceException.FAST_INSTANCE; } else { return new InvalidReferenceException( new _ErrorDescriptionBuilder( "The exteneded hash (of class ", tm.getClass().getName(), ") has returned null for its \"", propertyName, "\" property. This is maybe a bug. The extended hash was returned by this expression:") .blame(target), env, this); } }
errDescBuilder.tip(TIP); return new InvalidReferenceException(errDescBuilder, env, blamed); } else { return new InvalidReferenceException(env);
/** * Used for assignments that use operators like {@code +=}, when the target variable was null/missing. */ static InvalidReferenceException getInstance(int scope, String missingAssignedVarName, String assignmentOperator, Environment env) { if (env != null && env.getFastInvalidReferenceExceptions()) { return FAST_INSTANCE; } else { final _ErrorDescriptionBuilder errDescBuilder = new _ErrorDescriptionBuilder( "The target variable of the assignment, ", new _DelayedJQuote(missingAssignedVarName), ", was null or missing in the " + Assignment.scopeAsString(scope) + ", and the \"", assignmentOperator, "\" operator must get its value from there before assigning to it." ); if (missingAssignedVarName.startsWith("$")) { errDescBuilder.tips(TIP_NO_DOLLAR, TIP_MISSING_ASSIGNMENT_TARGET); } else { errDescBuilder.tip(TIP_MISSING_ASSIGNMENT_TARGET); } return new InvalidReferenceException(errDescBuilder, env, null); } }
throw InvalidReferenceException.getInstance(exp, env); } else { throw new InvalidReferenceException( "Null/missing value (no more informatoin avilable)", env);
static void assertNonNull(TemplateModel model, Expression exp, Environment env) throws InvalidReferenceException { if (model == null) { throw new InvalidReferenceException( "Expression " + exp + " is undefined " + exp.getStartLocation() + ".", env); } }
static Number getNumber(TemplateModel model, Expression expr, Environment env) throws TemplateException { if(model instanceof TemplateNumberModel) { return getNumber((TemplateNumberModel)model, expr, env); } else if(model == null) { throw new InvalidReferenceException(expr + " is undefined.", env); } else { throw new NonNumericalException(expr + " is not a number, it is " + model.getClass().getName(), env); } }
protected InvalidReferenceException newNullPropertyException( String propertyName, TemplateModel tm, Environment env) { if (env.getFastInvalidReferenceExceptions()) { return InvalidReferenceException.FAST_INSTANCE; } else { return new InvalidReferenceException( new _ErrorDescriptionBuilder( "The exteneded hash (of class ", tm.getClass().getName(), ") has returned null for its \"", propertyName, "\" property. This is maybe a bug. The extended hash was returned by this expression:") .blame(target), env, this); } }
protected InvalidReferenceException newNullPropertyException( String propertyName, TemplateModel tm, Environment env) { if (env.getFastInvalidReferenceExceptions()) { return InvalidReferenceException.FAST_INSTANCE; } else { return new InvalidReferenceException( new _ErrorDescriptionBuilder( "The exteneded hash (of class ", tm.getClass().getName(), ") has returned null for its \"", propertyName, "\" property. This is maybe a bug. The extended hash was returned by this expression:") .blame(target), env, this); } }
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException { TemplateModel model = target.getAsTemplateModel(env); if (model instanceof TemplateDateModel) { TemplateDateModel tdm = (TemplateDateModel) model; return calculateResult(EvaluationUtil.getDate(tdm, target, env), tdm.getDateType(), env); } else { if(model == null) { throw new InvalidReferenceException(target + " is undefined.", env); } throw new NonDateException( target + " should be a date, time, or date+time, but it's a(n) " + model.getClass().getName(), env); } }
private TemplateModel getNodeProcessor(final String nodeName, final String nsURI, int startIndex) throws TemplateException { TemplateModel result = null; int i; for (i = startIndex; i<nodeNamespaces.size(); i++) { Namespace ns = null; try { ns = (Namespace) nodeNamespaces.get(i); } catch (ClassCastException cce) { throw new InvalidReferenceException("A using clause should contain a sequence of namespaces or strings that indicate the location of importable macro libraries.", this); } result = getNodeProcessor(ns, nodeName, nsURI); if (result != null) break; } if (result != null) { this.nodeNamespaceIndex = i+1; this.currentNodeName = nodeName; this.currentNodeNS = nsURI; } return result; }
throw new InvalidReferenceException(this.getStartLocation() + " " + nameExp + " not found.", env); } else {
String msg = "Error " + getStartLocation() + "The expression " + templateName + " is undefined."; throw new InvalidReferenceException(msg, env);
errDescBuilder.tip(TIP); return new InvalidReferenceException(errDescBuilder, env, blamed); } else { return new InvalidReferenceException(env);
errDescBuilder.tip(TIP); return new InvalidReferenceException(errDescBuilder, env, blamed); } else { return new InvalidReferenceException(env);
/** * Used for assignments that use operators like {@code +=}, when the target variable was null/missing. */ static InvalidReferenceException getInstance(int scope, String missingAssignedVarName, String assignmentOperator, Environment env) { if (env != null && env.getFastInvalidReferenceExceptions()) { return FAST_INSTANCE; } else { final _ErrorDescriptionBuilder errDescBuilder = new _ErrorDescriptionBuilder( "The target variable of the assignment, ", new _DelayedJQuote(missingAssignedVarName), ", was null or missing in the " + Assignment.scopeAsString(scope) + ", and the \"", assignmentOperator, "\" operator must get its value from there before assigning to it." ); if (missingAssignedVarName.startsWith("$")) { errDescBuilder.tips(TIP_NO_DOLLAR, TIP_MISSING_ASSIGNMENT_TARGET); } else { errDescBuilder.tip(TIP_MISSING_ASSIGNMENT_TARGET); } return new InvalidReferenceException(errDescBuilder, env, null); } }
/** * Used for assignments that use operators like {@code +=}, when the target variable was null/missing. */ static InvalidReferenceException getInstance(int scope, String missingAssignedVarName, String assignmentOperator, Environment env) { if (env != null && env.getFastInvalidReferenceExceptions()) { return FAST_INSTANCE; } else { final _ErrorDescriptionBuilder errDescBuilder = new _ErrorDescriptionBuilder( "The target variable of the assignment, ", new _DelayedJQuote(missingAssignedVarName), ", was null or missing in the " + Assignment.scopeAsString(scope) + ", and the \"", assignmentOperator, "\" operator must get its value from there before assigning to it." ); if (missingAssignedVarName.startsWith("$")) { errDescBuilder.tips(TIP_NO_DOLLAR, TIP_MISSING_ASSIGNMENT_TARGET); } else { errDescBuilder.tip(TIP_MISSING_ASSIGNMENT_TARGET); } return new InvalidReferenceException(errDescBuilder, env, null); } }
TemplateModel _getAsTemplateModel(Environment env) throws TemplateException { TemplateModel tm = target.getAsTemplateModel(env); String classname = null; try { classname = ((TemplateScalarModel) tm).getAsString(); } catch (ClassCastException cce) { invalidTypeException(tm, target, env, "string"); } catch (NullPointerException npe) { throw new InvalidReferenceException(getStartLocation() + "\nCould not resolve expression: " + target, env); } return new ConstructorFunction(classname, env, target.getTemplate()); }
throw new InvalidReferenceException(getStartLocation() + "\nInvalid reference to namespace: " + namespaceExp, env); +"\n" + value + " is undefined." +"\nIt cannot be assigned to " + variableName; throw new InvalidReferenceException(msg, env);
String msg = "Error " + getStartLocation() + "The expression " + includedTemplateName + " is undefined."; throw new InvalidReferenceException(msg, env);
throw InvalidReferenceException.getInstance(exp, env); } else { throw new InvalidReferenceException( "Null/missing value (no more informatoin avilable)", env);