String[] setMethodNames={"FirstName","LastName","Street"}; Class cls = Class.forName("<qualifiedname>Contestant"); Class parameterTypes = String.class; for(String s:setMethodNames){ do{ try{ flag=false; System.out.println("Please enter your "+s+" :"); String inp=scanner.nextLine(); cls.getDeclaredMethod("set"+s, parameterTypes ).invoke(contestant1, inp); }catch(InvalidInputException e){ System.out.println(e.getMessage()); flag = true; } }while(flag); }
List<String> labels = Arrays.asList( "Please enter your first name.", "Please enter your last name.", "Please enter your street number." ); Function<String, Void> setters = Arrays.asList( contestant1::setName, contestant1::setLastName, contestant1::setStreetNumber ); Iterator<String> label = labels.iterator(); for(Function<String, Void> setter : setters) { do { try { flag = false; System.out.println(label.next()); String value = Scanner.nextLine(); setter.apply(value); } catch (InvalidInputException e) { System.out.println(e.getMessage()); flag = true; } } while (flag); }
callSetFunction(contestant1,s,inp); }catch(InvalidInputException e){ System.out.println(e.getMessage()); flag = true;
/** * Reads the next token. * @param ignoreComments If set, comments will be overread. * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ private int readNextWithEOF(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread. * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ private int readNextWithEOF(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread. * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ private int readNextWithEOF(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); if (curr == ITerminalSymbols.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); if (curr == ITerminalSymbols.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= fScanner.getNextToken(); if (curr == ITerminalSymbols.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
/** * Reads the next token. * @param ignoreComments If set, comments will be overread * @return Return the token id. * @exception CoreException Thrown when the end of the file has been reached (code END_OF_FILE) * or a lexical error was detected while scanning (code LEXICAL_ERROR) */ public int readNext(boolean ignoreComments) throws CoreException { int curr= 0; do { try { curr= this.scanner.getNextToken(); if (curr == TerminalTokens.TokenNameEOF) { throw new CoreException(createError(END_OF_FILE, "End Of File", null)); //$NON-NLS-1$ } } catch (InvalidInputException e) { throw new CoreException(createError(LEXICAL_ERROR, e.getMessage(), e)); } } while (ignoreComments && isComment(curr)); return curr; }
private int getLastSimpleNameStart(String reference) { fScanner.setSource(reference.toCharArray()); int lastIdentifierStart= -1; try { int tokenType= fScanner.getNextToken(); while (tokenType != ITerminalSymbols.TokenNameEOF) { if (tokenType == ITerminalSymbols.TokenNameIdentifier) { lastIdentifierStart= fScanner.getCurrentTokenStartPosition(); } tokenType= fScanner.getNextToken(); } } catch (InvalidInputException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return lastIdentifierStart; } }
} catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true; } catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true;
} catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true; } catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true;
} catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true; } catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true;
} catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true; } catch(InvalidInputException e){ if (!this.hasReportedError){ problemReporter().scannerError(this, e.getMessage()); this.hasReportedError = true;