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:io.druid.data.input.impl.AbstractTextFilesFirehoseFactory.java

@Override
public Firehose connect(StringInputRowParser firehoseParser, File temporaryDirectory) throws IOException {
    if (objects == null) {
        objects = ImmutableList.copyOf(Preconditions.checkNotNull(initObjects(), "initObjects"));
    }//from   ww  w. j  a va 2s  . c  o  m
    final Iterator<T> iterator = objects.iterator();
    return new FileIteratingFirehose(new Iterator<LineIterator>() {
        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public LineIterator next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            final T object = iterator.next();
            try {
                return IOUtils.lineIterator(wrapObjectStream(object, openObjectStream(object)), Charsets.UTF_8);
            } catch (Exception e) {
                LOG.error(e, "Exception reading object[%s]", object);
                throw Throwables.propagate(e);
            }
        }
    }, firehoseParser);
}

From source file:ArrayEnumeration.java

/**
 * Returns the next element in the enumeration.
 *//*  ww  w .  j a va  2  s .  c o  m*/

public Object nextElement() {
    if (!hasMoreElements())
        throw new NoSuchElementException();

    Object item = arr[curIndex];
    arr[curIndex++] = null; // We don't want to keep a reference to it any longer than we have to.
    if (!hasMoreElements())
        arr = null; // Neither do we need this any more.
    return item;
}

From source file:FilteringEnumeration.java

/**
 * Returns the next element in the delegate enumeration which passes the
 * <code>accept</code> method.
 *///from   w  ww  .j  a  v a2  s  .  c  o  m

public Object nextElement() throws NoSuchElementException {
    findNext();

    if (next == null)
        throw new NoSuchElementException();

    Object result = next;
    next = null;
    return result;
}

From source file:org.zalando.github.spring.pagination.PagingIterator.java

@Override
public E next() {
    fetchFromGithub();// w  w w  . j  a  v  a  2s .  c om
    E r = next;
    if (r == null) {
        throw new NoSuchElementException();
    }
    next = null;
    return r;
}

From source file:com.sun.syndication.propono.atom.client.EntryIterator.java

/**
 * Get next entry in collection.//w  w  w  .ja v  a2  s  .co m
 */
public Object next() {
    if (hasNext()) {
        Entry romeEntry = (Entry) members.next();
        try {
            if (!romeEntry.isMediaEntry()) {
                return new ClientEntry(null, collection, romeEntry, true);
            } else {
                return new ClientMediaEntry(null, collection, romeEntry, true);
            }
        } catch (ProponoException e) {
            throw new RuntimeException("Unexpected exception creating ClientEntry or ClientMedia", e);
        }
    }
    throw new NoSuchElementException();
}

From source file:com.ning.metrics.action.hdfs.data.RowFileContentsIterator.java

@Override
public Row next() {
    hasNext();//  w w  w  .  jav a2  s . c  o m

    final Row returnRow = row;
    row = null;

    if (returnRow == null) {
        throw new NoSuchElementException();
    }

    return returnRow;
}

From source file:com.bmd.android.collection.internal.SupportLongSparseArrayReverseIterator.java

@Override
protected LongSparseArrayEntry<E> getElementAt(final int position) {

    try {/*from   w  w  w  .j  a v  a2  s. c  o  m*/

        mValue = mSparseArray.valueAt(position);

    } catch (final IndexOutOfBoundsException e) {

        throw new NoSuchElementException();
    }

    mPosition = position;

    return this;
}

From source file:org.onebusaway.webapp.actions.where.ServiceAlertAction.java

@Override
@Actions({ @Action(value = "/where/standard/service-alert"), @Action(value = "/where/iphone/service-alert"),
        @Action(value = "/where/text/service-alert") })
public String execute() {

    _situation = _transitDataService.getServiceAlertForId(_id);
    if (_situation == null)
        throw new NoSuchElementException();

    if (!CollectionsLibrary.isEmpty(_situation.getDescriptions())) {
        for (NaturalLanguageStringBean desc : _situation.getDescriptions()) {
            if (desc.getValue() != null) {
                String value = desc.getValue();
                value = htmlify(value);//  w w w .  j  a  va 2s . c  o  m
                desc.setValue(value);
            }
        }
    }

    _currentUserService.markServiceAlertAsRead(_situation.getId(), System.currentTimeMillis(), true);

    return SUCCESS;
}

From source file:com.rometools.propono.atom.client.EntryIterator.java

/**
 * Get next entry in collection.//from w ww.j  av a  2s .c om
 */
@Override
public ClientEntry next() {
    if (hasNext()) {
        final Entry romeEntry = members.next();
        try {
            if (!romeEntry.isMediaEntry()) {
                return new ClientEntry(null, collection, romeEntry, true);
            } else {
                return new ClientMediaEntry(null, collection, romeEntry, true);
            }
        } catch (final ProponoException e) {
            throw new RuntimeException("Unexpected exception creating ClientEntry or ClientMedia", e);
        }
    }
    throw new NoSuchElementException();
}

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

@Override
public Map<String, String> verify(Map<String, String> postData) {
    String username = postData.get("username");
    if (username == null)
        throw new NoSuchElementException();
    if (username.equals("error"))
        throw new RuntimeException();
    User userAttributes;//  w w w.j  a  va2 s. com
    userAttributes = getUsersByName().get(username);
    if (userAttributes == null)
        throw new NoSuchElementException();
    String pw = null;
    String postDataPassword = postData.get("password");
    if (isHashedPassword(userAttributes.getPassword())) {
        String userHash = userAttributes.getPassword();
        if (userHash == null)
            throw new NoSuchElementException();
        String[] userHashSplit = userHash.split(Pattern.quote("$"));
        String algo = userHashSplit[1];
        String salt = userHashSplit[2];
        try {
            pw = createPasswdCompatibleHash(algo, postDataPassword, salt);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e.getMessage());
        }
    } else
        pw = postDataPassword;
    String pw2;
    pw2 = userAttributes.getPassword();
    if (pw2 == null || !pw2.equals(pw))
        throw new NoSuchElementException();
    return userAttributes.getAttributes();
}