Example usage for java.util NoSuchElementException NoSuchElementException

List of usage examples for java.util NoSuchElementException NoSuchElementException

Introduction

In this page you can find the example usage for java.util NoSuchElementException NoSuchElementException.

Prototype

public NoSuchElementException() 

Source Link

Document

Constructs a NoSuchElementException with null as its error message string.

Usage

From source file:com.opengamma.util.timeseries.fast.integer.FastArrayIntDoubleTimeSeries.java

public double getDataPointFast(final int time) {
    final int index = Arrays.binarySearch(_times, time);
    if (index >= 0) {
        return _values[index];
    } else {/*from   ww w  .j  a  v a  2  s  .co  m*/
        throw new NoSuchElementException();
    }
}

From source file:com.opengamma.util.timeseries.fast.integer.object.FastArrayIntObjectTimeSeries.java

public T getDataPointFast(final int time) {
    final int index = Arrays.binarySearch(_times, time);
    if (index >= 0) {
        return _values[index];
    } else {//from w  w w  .jav  a 2  s  .  c  o m
        throw new NoSuchElementException();
    }
}

From source file:com.predic8.membrane.core.interceptor.authentication.session.LDAPUserDataProvider.java

/**
 * @throws NoSuchElementException if no user could be found with the given login
 * @throws AuthenticationException if the password does not match
 * @throws CommunicationException e.g. on server timeout
 * @throws NamingException on any other LDAP error
 *//* w  w w  . ja  v a 2 s .  c om*/
private HashMap<String, String> auth(String login, String password) throws NamingException {
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);
    env.put("com.sun.jndi.ldap.read.timeout", timeout);
    env.put("com.sun.jndi.ldap.connect.timeout", connectTimeout);
    if (binddn != null) {
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_PRINCIPAL, binddn);
        env.put(Context.SECURITY_CREDENTIALS, bindpw);
    }

    HashMap<String, String> userAttrs = new HashMap<String, String>();
    String uid;

    DirContext ctx = new InitialDirContext(env);
    try {
        uid = searchUser(login, userAttrs, ctx);
    } finally {
        ctx.close();
    }

    if (passwordAttribute != null) {
        if (!userAttrs.containsKey("_pass"))
            throw new NoSuchElementException();
        String pass = userAttrs.get("_pass");
        if (pass == null || !pass.startsWith("{x-plain}"))
            throw new NoSuchElementException();
        log.debug("found password");
        pass = pass.substring(9);
        if (!pass.equals(password))
            throw new NoSuchElementException();
        userAttrs.remove("_pass");
    } else {
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_PRINCIPAL, uid + "," + base);
        env.put(Context.SECURITY_CREDENTIALS, password);
        DirContext ctx2 = new InitialDirContext(env);
        try {
            if (readAttributesAsSelf)
                searchUser(login, userAttrs, ctx2);
        } finally {
            ctx2.close();
        }
    }
    return userAttrs;
}

From source file:com.opengamma.util.timeseries.fast.longint.object.FastArrayLongObjectTimeSeries.java

public T getDataPointFast(final long time) {
    final int index = Arrays.binarySearch(_times, time);
    if (index >= 0) {
        return _values[index];
    } else {/* w  ww. j a  va  2s.c om*/
        throw new NoSuchElementException();
    }
}

From source file:CSVTokenizer.java

/**
 * Returns the next token from this string tokenizer.
 *
 * @return the next token from this string tokenizer.
 * @throws NoSuchElementException   if there are no more tokens in this tokenizer's string.
 * @throws IllegalArgumentException if given parameter string format was wrong
 *///  w  ww.  java2 s . com
public String nextToken() throws NoSuchElementException, IllegalArgumentException {

    if (!this.hasMoreTokens()) {
        throw new NoSuchElementException();
    }

    if (beforeStart == false) {
        currentIndex += this.separator.length();
    } else {
        beforeStart = false;
    }

    if (this.record.startsWith(this.quate, this.currentIndex)) {
        final StringBuffer token = new StringBuffer();
        String rec = this.record.substring(this.currentIndex + this.quate.length());

        while (true) {
            final int end = rec.indexOf(this.quate);
            if (end < 0) {
                throw new IllegalArgumentException("Illegal format");
            }

            if (!rec.startsWith(this.quate, end + 1)) {
                token.append(rec.substring(0, end));
                break;
            }
            token.append(rec.substring(0, end + 1));
            rec = rec.substring(end + this.quate.length() * 2);
            this.currentIndex++;
        }

        this.currentIndex += (token.length() + this.quate.length() * 2);
        return token.toString();
    }

    final int end = this.record.indexOf(this.separator, this.currentIndex);
    if (end >= 0) {
        final int start = this.currentIndex;
        final String token = this.record.substring(start, end);
        this.currentIndex = end;
        return token;
    } else {
        final int start = this.currentIndex;
        final String token = this.record.substring(start);
        this.currentIndex = this.record.length();
        return token;
    }
}

From source file:BoundedPriorityQueue.java

/**
 * Returns the lowest scoring object in the priority queue,
 * or <code>null</code> if the queue is empty.
 *
 * @return Lowest scoring object in the queue.
 *//*from  w ww. jav  a 2  s . co m*/
public E last() {
    if (isEmpty())
        throw new NoSuchElementException();
    return mQueue.last().mObject;
}

From source file:com.amazon.carbonado.repo.indexed.IndexedCursor.java

public S next() throws FetchException {
    try {/*from ww w .  j av a 2  s  .  c o  m*/
        if (hasNext()) {
            S next = mNext;
            mNext = null;
            return next;
        }
    } catch (FetchException e) {
        try {
            close();
        } catch (Exception e2) {
            // Don't care.
        }
        throw e;
    }
    throw new NoSuchElementException();
}

From source file:io.druid.data.input.impl.prefetch.PrefetchSqlFirehoseFactory.java

@Override
public Firehose connect(InputRowParser<Map<String, Object>> firehoseParser, @Nullable File temporaryDirectory)
        throws IOException {
    if (objects == null) {
        objects = ImmutableList.copyOf(Preconditions.checkNotNull(initObjects(), "objects"));
    }/*from w w  w  . j a  v  a  2 s.  co  m*/
    if (cacheManager.isEnabled() || prefetchConfig.getMaxFetchCapacityBytes() > 0) {
        Preconditions.checkNotNull(temporaryDirectory, "temporaryDirectory");
        Preconditions.checkArgument(temporaryDirectory.exists(), "temporaryDirectory[%s] does not exist",
                temporaryDirectory);
        Preconditions.checkArgument(temporaryDirectory.isDirectory(),
                "temporaryDirectory[%s] is not a directory", temporaryDirectory);
    }

    LOG.info("Create a new firehose for [%d] queries", objects.size());

    // fetchExecutor is responsible for background data fetching
    final ExecutorService fetchExecutor = Execs.singleThreaded("firehose_fetch_%d");
    final Fetcher<T> fetcher = new SqlFetcher<>(cacheManager, objects, fetchExecutor, temporaryDirectory,
            prefetchConfig, new ObjectOpenFunction<T>() {
                @Override
                public InputStream open(T object, File outFile) throws IOException {
                    return openObjectStream(object, outFile);
                }

                @Override
                public InputStream open(T object) throws IOException {
                    final File outFile = File.createTempFile("sqlresults_", null, temporaryDirectory);
                    return openObjectStream(object, outFile);
                }
            });

    return new SqlFirehose(new Iterator<JsonIterator<Map<String, Object>>>() {
        @Override
        public boolean hasNext() {
            return fetcher.hasNext();
        }

        @Override
        public JsonIterator<Map<String, Object>> next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            try {
                TypeReference<Map<String, Object>> type = new TypeReference<Map<String, Object>>() {
                };
                final OpenedObject<T> openedObject = fetcher.next();
                final InputStream stream = openedObject.getObjectStream();
                return new JsonIterator<>(type, stream, openedObject.getResourceCloser(), objectMapper);
            } catch (Exception ioe) {
                throw new RuntimeException(ioe);
            }
        }
    }, firehoseParser, () -> {
        fetchExecutor.shutdownNow();
        try {
            Preconditions.checkState(
                    fetchExecutor.awaitTermination(prefetchConfig.getFetchTimeout(), TimeUnit.MILLISECONDS));
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new ISE("Failed to shutdown fetch executor during close");
        }
    });
}

From source file:com.opengamma.util.timeseries.fast.longint.FastArrayLongDoubleTimeSeries.java

public double getDataPointFast(final long time) {
    final int index = Arrays.binarySearch(_times, time);
    if (index >= 0) {
        return _values[index];
    } else {/*  w w  w  .  ja va  2  s .  c o  m*/
        throw new NoSuchElementException();
    }
}

From source file:com.telefonica.euro_iaas.sdc.pupperwrapper.services.tests.ActionsServiceTest.java

@Test(expected = NoSuchElementException.class)
public void uninstallSoftNotExists2() {

    when(catalogManagerMongo.getNode("nodenoexists")).thenThrow(new NoSuchElementException());

    actionsService.action(Action.UNINSTALL, "testGroup", "nodenoexists", "softnoexists", "1.0.0",
            attributeList);/*from   w w w .ja  v a2  s  .  c om*/
}