boolean throwException(ParseException exception) throws ParseBypassException { throw new ParseBypassException(exception); }
public static JtwigDocument parse (JtwigResource input) throws ParseException { try { ReportingParseRunner<Object> runner = new ReportingParseRunner<Object>(createParser(JtwigParser.class).start()); ParsingResult<Object> result = runner.run(FileUtils.readAllText(input.retrieve(), Charset.defaultCharset())); return (JtwigDocument) result.resultValue; } catch (ParserRuntimeException e) { if (e.getCause() instanceof ParseBypassException) { ParseException innerException = ((ParseBypassException) e.getCause()).getInnerException(); innerException.setExpression(e.getMessage()); throw innerException; } else throw new ParseException(e); } catch (ResourceException e) { throw new ParseException(e); } }
public static JtwigDocument parse (JtwigResource input) throws ParseException { try { ReportingParseRunner<Object> runner = new ReportingParseRunner<Object>(createParser(JtwigParser.class).start()); ParsingResult<Object> result = runner.run(FileUtils.readAllText(input.retrieve(), Charset.defaultCharset())); return (JtwigDocument) result.resultValue; } catch (ParserRuntimeException e) { if (e.getCause() instanceof ParseBypassException) { ParseException innerException = ((ParseBypassException) e.getCause()).getInnerException(); innerException.setExpression(e.getMessage()); throw innerException; } else throw new ParseException(e); } catch (ResourceException e) { throw new ParseException(e); } }
boolean throwException(ParseException exception) throws ParseBypassException { throw new ParseBypassException(exception); }
boolean throwException(ParseException exception) throws ParseBypassException { throw new ParseBypassException(exception); }
boolean throwException(ParseException exception) throws ParseBypassException { throw new ParseBypassException(exception); }
public static ValueList create(Constant init, Constant end) { ValueList valueList = new ValueList(); if (init.isInstanceOf(Integer.class)) { if (!end.isInstanceOf(Integer.class)) throw new ParseBypassException(new ParseException("Expected an integer for the end of the comprehension list")); int initValue = Integer.class.cast(init.getValue()); //(int) init.as(Integer.class); int endValue = Integer.class.cast(end.getValue()); //(int) end.as(Integer.class); if (initValue < endValue) { for (int i = initValue; i <= endValue; i++) valueList.add(new Constant<Integer>(i)); } else { for (int i = endValue; i >= initValue; i--) valueList.add(new Constant<Integer>(i)); } } else if (init.isInstanceOf(Character.class)) { if (!end.isInstanceOf(Character.class)) throw new ParseBypassException(new ParseException("Expected a character for the end of the comprehension list")); char initValue = Character.class.cast(init.getValue()); //(char) init.as(Character.class); char endValue = Character.class.cast(end.getValue()); //(char) end.as(Character.class); if (initValue < endValue) { for (char i = initValue; i <= endValue; i++) valueList.add(new Constant<Character>(i)); } else { for (char i = endValue; i >= initValue; i--) valueList.add(new Constant<Character>(i)); } } else throw new ParseBypassException(new ParseException("Only integers and characters are allowed in comprehension lists")); return valueList; }
public static ValueList create(Constant init, Constant end) { ValueList valueList = new ValueList(); if (init.isInstanceOf(Integer.class)) { if (!end.isInstanceOf(Integer.class)) throw new ParseBypassException(new ParseException("Expected an integer for the end of the comprehension list")); int initValue = Integer.class.cast(init.getValue()); //(int) init.as(Integer.class); int endValue = Integer.class.cast(end.getValue()); //(int) end.as(Integer.class); if (initValue < endValue) { for (int i = initValue; i <= endValue; i++) valueList.add(new Constant<Integer>(i)); } else { for (int i = endValue; i >= initValue; i--) valueList.add(new Constant<Integer>(i)); } } else if (init.isInstanceOf(Character.class)) { if (!end.isInstanceOf(Character.class)) throw new ParseBypassException(new ParseException("Expected a character for the end of the comprehension list")); char initValue = Character.class.cast(init.getValue()); //(char) init.as(Character.class); char endValue = Character.class.cast(end.getValue()); //(char) end.as(Character.class); if (initValue < endValue) { for (char i = initValue; i <= endValue; i++) valueList.add(new Constant<Character>(i)); } else { for (char i = endValue; i >= initValue; i--) valueList.add(new Constant<Character>(i)); } } else throw new ParseBypassException(new ParseException("Only integers and characters are allowed in comprehension lists")); return valueList; }