@Override public void parse(IParserCallback parserCallback, String spearatorSymbol) throws IOException { InputStreamReader inputStreamReader = null; BufferedReader bufferedReader = null; try { inputStreamReader = new InputStreamReader(inputStream, charset ); bufferedReader = new BufferedReader(inputStreamReader); findStatement(parserCallback, bufferedReader); } finally { if (bufferedReader!=null) bufferedReader.close(); if (inputStreamReader!=null) inputStreamReader.close(); if (closeInputStream && inputStream!=null) inputStream.close(); } }
@Override public void parse(IParserCallback parserCallback) throws IOException { parse(parserCallback, ";"); }
private void checkend(IParserCallback parserCallback, StringBuilder StringBuilder, String line, GenericWrapper<Integer> apostrophesWrapper ) { String trimmedline = line.trim(); if ( !trimmedline.isEmpty() && !trimmedline.startsWith("--") ) { if ( line.contains(";") ) { String[] splitted = line.split(";"); int position = 0; for (int i=0 ; i<splitted.length; i++) { int apostrophes = apostrophesWrapper.getValue(); String token = splitted[i]; position += token.length() + 1; apostrophes += countApostrophes(token); apostrophesWrapper.setValue(apostrophes); if ( apostrophes % 2 == 1) { StringBuilder.append(token + ";"); } else { StringBuilder.append(token); parserCallback.parseAction(StringBuilder.toString()); StringBuilder.setLength(0); apostrophesWrapper.setValue(0); line = line.substring(position, line.length() ); checkend(parserCallback, StringBuilder, line, apostrophesWrapper); break; } } } else { StringBuilder.append(line + "\n"); } } }
@Override public void execute(final InputStream scriptStream, final Charset charset) throws IOException, OrmException { this.logger.info("Begin script execution"); //$NON-NLS-1$ Parser parser = new StreamParser(scriptStream, true, charset); SessionParserCallback spc = new SessionParserCallback(this.session); parser.parse(spc); this.logger.info("End script execution"); //$NON-NLS-1$ }
private boolean findStatement(IParserCallback parserCallback, BufferedReader bufferedReader) throws IOException { StringBuilder StringBuilder = new StringBuilder(); String line = null; GenericWrapper<Integer> apostrophes = new GenericWrapper<Integer>(0); while (true) { if ( ! ((line = bufferedReader.readLine()) != null )) { return false; } checkend(parserCallback, StringBuilder, line, apostrophes); } }
private void checkend(final ParserCallback parserCallback, final StringBuilder StringBuilder, final String line, final GenericWrapper<Integer> apostrophesWrapper ) { String trimmedline = line.trim(); if ( !trimmedline.isEmpty() && !trimmedline.startsWith("--") ) { //$NON-NLS-1$ if ( line.contains(";") ) { //$NON-NLS-1$ String tempLine = line; String[] splitted = tempLine.split(";"); //$NON-NLS-1$ int position = 0; for (String token : splitted) { int apostrophes = apostrophesWrapper.getValue(); position += token.length() + 1; apostrophes += countApostrophes(token); apostrophesWrapper.setValue(apostrophes); if ( (apostrophes % 2) == 1) { StringBuilder.append(token + ";"); //$NON-NLS-1$ } else { StringBuilder.append(token); parserCallback.parseAction(StringBuilder.toString()); StringBuilder.setLength(0); apostrophesWrapper.setValue(0); tempLine = tempLine.substring(position, tempLine.length() ); checkend(parserCallback, StringBuilder, tempLine, apostrophesWrapper); break; } } } else { StringBuilder.append(line + "\n"); //$NON-NLS-1$ } } }
@Override public void execute(InputStream scriptStream, Charset charset) throws IOException, OrmException { logger.info("execute", "Begin script execution"); IParser parser = new StreamParser(scriptStream, true, charset); SessionParserCallback spc = new SessionParserCallback(session); parser.parse(spc); logger.debug("execute", "End script execution"); }
private boolean findStatement(final ParserCallback parserCallback, final BufferedReader bufferedReader) throws IOException { StringBuilder StringBuilder = new StringBuilder(); String line = null; GenericWrapper<Integer> apostrophes = new GenericWrapper<Integer>(0); while (true) { if ( ! ((line = bufferedReader.readLine()) != null )) { return false; } checkend(parserCallback, StringBuilder, line, apostrophes); } }
@Override public void parse(final ParserCallback parserCallback) throws IOException { parse(parserCallback, ";"); //$NON-NLS-1$ }
@Override public void parse(final ParserCallback parserCallback, final String spearatorSymbol) throws IOException { InputStreamReader inputStreamReader = null; BufferedReader bufferedReader = null; try { inputStreamReader = new InputStreamReader(inputStream, charset ); bufferedReader = new BufferedReader(inputStreamReader); findStatement(parserCallback, bufferedReader); } finally { if (bufferedReader!=null) { bufferedReader.close(); } if (inputStreamReader!=null) { inputStreamReader.close(); } if (closeInputStream && (inputStream!=null)) { inputStream.close(); } } }