List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException(String s)
From source file:de.codecentric.multitool.db.DBUnitLibrary.java
/** * Liest einen Einzelwert aus einer Tabellenabfrage * /* w w w. j av a 2 s. co m*/ * Beispiel: | ${value} = | Read Single Value From Table | ACSD_FULL | * MYTABLE | STATUS | id = 5 | */ public String readSingleValueFromTable(String dsName, String table, String column, String whereStatment) throws IllegalArgumentException, SQLException { Statement statement = null; ResultSet rs = null; try { statement = getConnection(dsName).createStatement(); String sql = "SELECT " + column + " FROM " + table + (StringUtils.isNotEmpty(whereStatment) ? " WHERE " + whereStatment : ""); statement.execute(sql); rs = statement.getResultSet(); if (rs.next()) { if (rs.getObject(1) == null) return null; else return rs.getObject(1).toString(); } throw new NoSuchElementException(sql); } finally { if (rs != null) { rs.close(); } if (statement != null) { statement.close(); } } }
From source file:com.examples.with.different.packagename.concolic.MathRuntimeException.java
/** * Constructs a new <code>NoSuchElementException</code> with specified formatted detail message. * Message formatting is delegated to {@link java.text.MessageFormat}. * @param pattern format specifier/*from w ww . ja v a 2 s. co m*/ * @param arguments format arguments * @return built exception */ public static NoSuchElementException createNoSuchElementException(final String pattern, final Object... arguments) { return new NoSuchElementException(buildMessage(Locale.US, pattern, arguments)) { /** Serializable version identifier. */ private static final long serialVersionUID = 7304273322489425799L; /** {@inheritDoc} */ @Override public String getLocalizedMessage() { return buildMessage(Locale.getDefault(), pattern, arguments); } }; }
From source file:localdomain.localhost.CasInitializer.java
@ManagedOperation public void changeUserPassword(@NotNull String username, @NotNull String clearTextPassword) { Connection cnn = null;/*from w w w .j a v a 2 s . c om*/ PreparedStatement stmt = null; try { cnn = dataSource.getConnection(); cnn.setAutoCommit(false); stmt = cnn.prepareStatement( "update `" + tableUsers + "` set `" + fieldPassword + "` = ? where `" + fieldUser + "` like ?"); stmt.setString(1, passwordEncoder.encode(clearTextPassword)); stmt.setString(2, username); int rowCount = stmt.executeUpdate(); if (rowCount == 0) { throw new NoSuchElementException("No user '" + username + "' found"); } else if (rowCount == 1) { logger.info("Password of user '" + username + "' was updated"); } else { new IllegalArgumentException( "More (" + rowCount + ") than 1 row deleted for username '" + username + "', rollback"); } logger.info("User '" + username + "' deleted"); cnn.commit(); } catch (RuntimeException e) { rollbackQuietly(cnn); String msg = "Exception changing password for user '" + username + "': " + e; logger.warn(msg, e); throw new RuntimeException(msg); } catch (SQLException e) { rollbackQuietly(cnn); String msg = "Exception changing password for user '" + username + "': " + e; logger.warn(msg, e); throw new RuntimeException(msg); } finally { closeQuietly(cnn, stmt); } }
From source file:com.opengamma.util.timeseries.fast.integer.FastArrayIntDoubleTimeSeries.java
@Override public FastIntDoubleTimeSeries tailFast(final int numItems) { if (numItems <= _times.length) { final int[] times = new int[numItems]; final double[] values = new double[numItems]; System.arraycopy(_times, _times.length - numItems, times, 0, numItems); System.arraycopy(_values, _values.length - numItems, values, 0, numItems); return new FastArrayIntDoubleTimeSeries(getEncoding(), times, values); } else {/*from w ww .java 2 s .c o m*/ throw new NoSuchElementException("Not enough elements"); } }
From source file:com.opengamma.util.timeseries.fast.integer.object.FastArrayIntObjectTimeSeries.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public FastIntObjectTimeSeries<T> tailFast(final int numItems) { if (numItems <= _times.length) { final int[] times = new int[numItems]; final T[] values = (T[]) new Object[numItems]; System.arraycopy(_times, _times.length - numItems, times, 0, numItems); System.arraycopy(_values, _values.length - numItems, values, 0, numItems); return new FastArrayIntObjectTimeSeries(getEncoding(), times, values); } else {/*from www . j av a2s . co m*/ throw new NoSuchElementException("Not enough elements"); } }
From source file:com.github.xbn.regexutil.RegexGroupExtractor.java
/** <p>Get the list containing all groups in the next iteration.</p> /*from w w w .j ava 2 s . com*/ * @see #nextAsJoined(String) nextAsJoined(s) * @exception NoSuchElementException If {@link #hasNext() hasNext}{@code ()} is {@code false}. */ public List<String> next() { if (!hasNext()) { throw new NoSuchElementException("hasNext() is false. Must search(s)."); } List<String> lg2Ret = alGroups; alGroups = null; if (m.find()) { addGroupsToNewList(); } return lg2Ret; }
From source file:com.opengamma.util.timeseries.fast.longint.object.FastArrayLongObjectTimeSeries.java
@SuppressWarnings("unchecked") public FastLongObjectTimeSeries<T> tail(final int numItems) { if (numItems <= _times.length) { final long[] times = new long[numItems]; final T[] values = (T[]) new Object[numItems]; System.arraycopy(_times, _times.length - numItems, times, 0, numItems); System.arraycopy(_values, _values.length - numItems, values, 0, numItems); return new FastArrayLongObjectTimeSeries<T>(getEncoding(), times, values); } else {/*w w w . j a v a 2 s .com*/ throw new NoSuchElementException("Not enough elements"); } }
From source file:com.opengamma.util.timeseries.fast.longint.FastArrayLongDoubleTimeSeries.java
@Override public FastLongDoubleTimeSeries tail(final int numItems) { if (numItems <= _times.length) { final long[] times = new long[numItems]; final double[] values = new double[numItems]; System.arraycopy(_times, _times.length - numItems, times, 0, numItems); System.arraycopy(_values, _values.length - numItems, values, 0, numItems); return new FastArrayLongDoubleTimeSeries(getEncoding(), times, values); } else {// w ww.j a v a 2 s . c om throw new NoSuchElementException("Not enough elements"); } }
From source file:de.codesourcery.jasm16.emulator.EmulationOptions.java
public DefaultFloppyDrive getFloppyDrive(IEmulator emulator) { List<IDevice> result = emulator.getDevicesByDescriptor(DefaultFloppyDrive.DESC); if (result.isEmpty()) { throw new NoSuchElementException("Internal error, found no floppy drive?"); }//from w w w . j a v a 2s. co m if (result.size() > 1) { throw new RuntimeException("Internal error, found more than one floppy drive?"); } return (DefaultFloppyDrive) result.get(0); }
From source file:com.github.xbn.text.StringUtil.java
public Character next() { if (!hasNext()) { throw new NoSuchElementException( "The length of the str_obj is " + q.length() + ". The str_obj: \"" + q + "\""); }//from ww w. j a va 2 s . com return q.charAt(ix++); }