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(String s) 

Source Link

Document

Constructs a NoSuchElementException , saving a reference to the error message string s for later retrieval by the getMessage method.

Usage

From source file:narvis.modules.weather.OwPortal.java

@Override
public double getWindSpeed() throws NoSuchElementException {
    if (this._currentWeather.getWindInstance().hasWindSpeed())
        return this._currentWeather.getWindInstance().getWindSpeed();

    throw new NoSuchElementException("No wind speed found");
}

From source file:org.kurento.repository.internal.repoimpl.mongo.MongoRepository.java

@Override
public RepositoryItem findRepositoryItemById(String id) {

    List<GridFSDBFile> dbFiles = gridFS.find(id);

    if (dbFiles.size() > 0) {

        if (dbFiles.size() > 1) {
            log.warn("There are several files with the same " + "filename and should be only one");
        }/*from   ww  w.jav  a 2  s.c o  m*/

        return createRepositoryItem(dbFiles.get(0));
    }

    throw new NoSuchElementException("The repository item with id \"" + id + "\" does not exist");
}

From source file:de.iew.raspimotion.controllers.MotionJpegController.java

@RequestMapping(value = "image/{imagename:.+}")
public void imageAction(HttpServletResponse response, @PathVariable String imagename) throws Exception {
    Assert.isTrue(validateImagename(imagename));

    FileDescriptor file = this.fileDao.getFileLastCreated(imagename);

    if (file == null) {
        throw new NoSuchElementException("Image was not found");
    }/*w ww  . ja  v a2s.c o  m*/

    sendCachingHeaders(response);
    response.setContentType("image/jpeg");
    response.setContentLength(new Long(file.getFilesize()).intValue());

    sendImageAsJpeg(file, response);
}

From source file:com.frank.search.solr.core.query.result.DelegatingCursor.java

@Override
public T next() {

    validateState();//from w  ww .  j av a  2  s  .  com

    if (!hasNext()) {
        throw new NoSuchElementException("No more elements available for cursor " + getCursorMark() + ".");
    }

    T next = moveNext(delegate);
    position++;
    return next;
}

From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.services.impl.CatalogManagerMongoImpl.java

public Node getNode(String nodeName) {
    Query searchNodeQuery = new Query(Criteria.where("id").is(nodeName));
    Node savedNode = mongoTemplate.findOne(searchNodeQuery, Node.class);
    if (savedNode == null) {
        throw new NoSuchElementException(format("The node {0} could not be found", nodeName));
    }// w ww. ja va  2s . co  m
    return savedNode;
}

From source file:com.kakao.network.response.ResponseBody.java

private Object getOrThrow(String key) {
    Object v = null;//from ww w .  j  av a2  s. c  om
    try {
        v = json.get(key);
    } catch (JSONException ignor) {
    }

    if (v == null) {
        throw new NoSuchElementException(key);
    }

    if (v == JSONObject.NULL) {
        return null;
    }
    return v;
}

From source file:ArrayIterator.java

/**
 * Move to next element in the array.//www .  jav  a 2s  . co m
 *
 * @return The next object in the array.
 */
public Object next() {
    if (pos < size)
        return Array.get(array, pos++);

    /*
     *  we screwed up...
     */

    throw new NoSuchElementException("No more elements: " + pos + " / " + size);
}

From source file:com.kurento.kmf.repository.internal.repoimpl.mongo.MongoRepository.java

@Override
public RepositoryItem findRepositoryItemById(String id) {

    List<GridFSDBFile> dbFiles = gridFS.find(idQuery(id));

    if (dbFiles.size() > 0) {

        if (dbFiles.size() > 1) {
            log.warn("There are several files with the same " + "filename and should be only one");
        }//from ww  w.  j a  v  a2  s  .c om

        return createRepositoryItem(dbFiles.get(0));
    }

    throw new NoSuchElementException("The repository item with id \"" + id + "\" does not exist");
}

From source file:natalia.dymnikova.cluster.scheduler.impl.FlowMerger.java

public Stage createMergeStages(final List<Stage> previous, final StageContainer currentStage,
        final Optional<Address> nextAddress) {
    // TODO: doesn't create two mergers in one host
    final List<Stage> children = new ArrayList<>();
    previous.stream().map(Stage::getAddress).distinct().forEach(address -> children.add(Stage.newBuilder()
            .setOperator(currentStage.remoteBytes).setAddress(address).setType(currentStage.stageType)
            .setId(-previous.stream().filter(s -> s.getAddress().equals(address)).findFirst().get().getId())
            .addAllStages(//w ww .ja  v  a 2  s.  c o m
                    previous.stream().filter(stage -> stage.getAddress().equals(address)).collect(toList()))
            .build()));

    return nextAddress
            .map(addr -> Stage.newBuilder().setOperator(currentStage.remoteBytes).setAddress(addr.toString())
                    .setType(currentStage.stageType).setId(currentStage.id).addAllStages(children).build())
            .orElseThrow(() -> new NoSuchElementException("No candidate for stage " + currentStage.action));
}

From source file:de.dhke.projects.cutil.collections.iterator.MultiMapEntryIterator.java

@Override
public Entry<K, V> next() {
    final Entry<K, V> currentEntry = advance();
    if (currentEntry == null)
        throw new NoSuchElementException("No more multimap entries");
    else/*from   www  .j  ava  2 s  .com*/
        return currentEntry;
}