Java 类java.util.NoSuchElementException 实例源码

项目:ctsms    文件:EcrfRowProcessor.java   
private Long getVisitId(String visitToken) throws Exception {
    Long visitId = null;
    if (!CommonUtil.isEmptyString(visitToken)) {
        if (!visitIdMap.containsKey(visitToken)) {
            try {
                visitId = visitDao.findByTrialTitleToken(context.getEntityId(), null, visitToken).iterator().next().getId();
            } catch (NoSuchElementException e) {
                VisitOutVO visitVO = createVisit(visitToken);
                visitId = visitVO.getId();
                jobOutput.println("visit '" + visitVO.getUniqueName() + "' created");
            }
            visitIdMap.put(visitToken, visitId);
        } else {
            visitId = visitIdMap.get(visitToken);
        }
    }
    return visitId;
}
项目:parabuild-ci    文件:Result.java   
public Object next() {

            if (hasNext()) {
                removed = false;

                if (counter != 0) {
                    last    = current;
                    current = current.next;
                }

                counter++;

                return current.data;
            }

            throw new NoSuchElementException();
        }
项目:monarch    文件:LinuxProcFsStatistics.java   
private static void getLoadAvg(double[] doubles) {
  InputStreamReader isr = null;
  BufferedReader br = null;
  try {
    isr = new InputStreamReader(new FileInputStream("/proc/loadavg"));
    br = new BufferedReader(isr, 512);
    String line = br.readLine();
    if (line == null) {
      return;
    }
    st.setString(line);
    doubles[LinuxSystemStats.loadAverage1DOUBLE] = st.nextTokenAsDouble();
    doubles[LinuxSystemStats.loadAverage5DOUBLE] = st.nextTokenAsDouble();
    doubles[LinuxSystemStats.loadAverage15DOUBLE] = st.nextTokenAsDouble();
  } catch (NoSuchElementException nsee) {
  } catch (IOException ioe) {
  } finally {
    st.releaseResources();
    if (br != null)
      try {
        br.close();
      } catch (IOException ignore) {
      }
  }
}
项目:openjdk-jdk10    文件:ConcurrentLinkedQueue.java   
public E next() {
    final Node<E> pred = nextNode;
    if (pred == null) throw new NoSuchElementException();
    // assert nextItem != null;
    lastRet = pred;
    E item = null;

    for (Node<E> p = succ(pred), q;; p = q) {
        if (p == null || (item = p.item) != null) {
            nextNode = p;
            E x = nextItem;
            nextItem = item;
            return x;
        }
        // unlink deleted nodes
        if ((q = succ(p)) != null)
            NEXT.compareAndSet(pred, p, q);
    }
}
项目:OpenJSharp    文件:NameImpl.java   
public boolean addAll(Enumeration<String> comps) throws InvalidNameException {
    boolean added = false;
    while (comps.hasMoreElements()) {
        try {
            String comp = comps.nextElement();
            if (size() > 0 && syntaxDirection == FLAT) {
                throw new InvalidNameException(
                    "A flat name can only have a single component");
            }
            components.addElement(comp);
            added = true;
        } catch (NoSuchElementException e) {
            break;  // "comps" has shrunk.
        }
    }
    return added;
}
项目:tikv-client-lib-java    文件:CoprocessIterator.java   
public static CoprocessIterator<Long> getHandleIterator(TiDAGRequest req,
                                                        List<RegionTask> regionTasks,
                                                        TiSession session) {
  return new DAGIterator<Long>(
      req.buildScan(true),
      regionTasks,
      session,
      SchemaInfer.create(req),
      req.getPushDownType()
  ) {
    @Override
    public Long next() {
      if (hasNext()) {
        return rowReader.readRow(handleTypes).getLong(0);
      } else {
        throw new NoSuchElementException();
      }
    }
  };
}
项目:scanning    文件:RepeatedPointIterator.java   
@Override
public IPosition next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }

    if (model.getSleep()>0) {
        try {
            Thread.sleep(model.getSleep());
            if (countSleeps) sleepCount++;
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
    }
    Scalar<Double> point = new Scalar<>(model.getName(), count, model.getValue());
    count++;
    return point;
}
项目:jmt    文件:CircularEventQueue.java   
/**
 * Returns an enumeration of the components of this vector. The
 * returned <tt>Enumeration</tt> object will generate all items in
 * this vector. The first item generated is the item at index <tt>0</tt>,
 * then the item at index <tt>1</tt>, and so on.
 *
 * @return  an enumeration of the components of this vector.
 * @see     Enumeration
 * @see     java.util.Iterator
 */
public Enumeration<SimEvent> elements() {
    return new Enumeration<SimEvent>() {
        int count = start;

        public boolean hasMoreElements() {
            return count < size;
        }

        public SimEvent nextElement() {
            synchronized (CircularEventQueue.this) {
                if (count < size) {
                    return data[count++];
                }
            }
            throw new NoSuchElementException("Vector Enumeration");
        }
    };
}
项目:hygene    文件:MetadataParser.java   
/**
 * Parses the metadata of a link (edge) to an {@link EdgeMetadata} object.
 *
 * @param gfa        string containing the contents of the GFA file
 * @param byteOffset the byte offset where the edge should be located
 * @return an {@link EdgeMetadata} object containing a link's metadata
 * @throws MetadataParseException if the GFA file or given line is invalid
 */
public EdgeMetadata parseEdgeMetadata(final GfaFile gfa, final long byteOffset) throws MetadataParseException {
    final String line = getLine(gfa.getRandomAccessFile(), byteOffset);

    validateLine(line, "L", byteOffset);

    final StringTokenizer st = initializeStringTokenizer(line, byteOffset);

    try {
        st.nextToken();
        st.nextToken();
        final String fromOrient = st.nextToken();
        st.nextToken();
        final String toOrient = st.nextToken();
        final String overlap = st.nextToken();

        return new EdgeMetadata(fromOrient, toOrient, overlap);
    } catch (final NoSuchElementException e) {
        throw new MetadataParseException("Not enough parameters for link at position " + byteOffset, e);
    }
}
项目:mbed-cloud-sdk-java    文件:APIMethod.java   
private Object invokeMethod(Object moduleInstance, Map<String, Map<String, Object>> argsDescription)
        throws NoSuchMethodException, SecurityException, ClassNotFoundException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException, APICallException {
    if (moduleInstance == null) {
        throw new NoSuchElementException();
    }
    Method m = fetchMethod(moduleInstance.getClass());
    if (m == null) {
        throw new NoSuchMethodException();
    }
    Object[] args = fetchArgsValues(argsDescription);
    return (args == null) ? m.invoke(moduleInstance) : m.invoke(moduleInstance, args);
}
项目:Ftc2018RelicRecovery    文件:HalDashboard.java   
/**
 * This method returns the value of the named double data read from the Telemetry class. If the named data does
 * not exist, it is created and assigned the given default value. Then it is sent to the Driver Station.
 *
 * @param key specifies the name associated with the double data.
 * @param defaultValue specifies the default value if it does not exist.
 * @return double data value.
 */
public double getNumber(String key, double defaultValue)
{
    final String funcName = "getNumber";
    double value;

    if (debugEnabled)
    {
        dbgTrace.traceEnter(funcName, TrcDbgTrace.TraceLevel.API, "key=%s,defValue=%f", key, defaultValue);
    }

    try
    {
        value = getNumber(key);
    }
    catch (NoSuchElementException e)
    {
        putNumber(key, defaultValue);
        value = defaultValue;
    }

    if (debugEnabled)
    {
        dbgTrace.traceExit(funcName, TrcDbgTrace.TraceLevel.API, "=%f", value);
    }

    return value;
}
项目:HL4A    文件:NativeTypedArrayIterator.java   
@Override
public T next()
{
    if (hasNext()) {
        T ret = (T)view.get(position);
        lastPosition = position;
        position++;
        return ret;
    }
    throw new NoSuchElementException();
}
项目:apache-tomcat-7.0.73-with-comment    文件:FairBlockingQueue.java   
@Override
public E next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    element = elements[index++];
    return element;
}
项目:googles-monorepo-demo    文件:TreeRangeMapTest.java   
public void testSpanTwoRanges() {
  for (Range<Integer> range1 : RANGES) {
    for (Range<Integer> range2 : RANGES) {
      RangeMap<Integer, Integer> rangeMap = TreeRangeMap.create();
      rangeMap.put(range1, 1);
      rangeMap.put(range2, 2);

      Range<Integer> expected;
      if (range1.isEmpty()) {
        if (range2.isEmpty()) {
          expected = null;
        } else {
          expected = range2;
        }
      } else {
        if (range2.isEmpty()) {
          expected = range1;
        } else {
          expected = range1.span(range2);
        }
      }

      try {
        assertEquals(expected, rangeMap.span());
        assertNotNull(expected);
      } catch (NoSuchElementException e) {
        assertNull(expected);
      }
    }
  }
}
项目:practical-functional-java    文件:OptionalTest.java   
@Test
public void testOptionalMapOnEmpty() {
    Optional<String> emptyName = Optional.empty();  // or Optional.ofNullable(null);

    Optional<String> emptyUpperName = emptyName.map(String::toUpperCase);

    assertThat(emptyUpperName.isPresent()).isFalse();

    try {
        assertThat(emptyUpperName.get()).isEqualTo("FRED");
        fail("found a value on an empty Optional");
    } catch (NoSuchElementException e) {
        // ignore
    }
}
项目:luna    文件:Code.java   
public BasicBlock block(Label label) {
  Objects.requireNonNull(label);
  BasicBlock result = index.get(label);
  if (result != null) {
    return result;
  } else {
    throw new NoSuchElementException("Label not found: " + label);
  }
}
项目:javaide    文件:MixedItemSection.java   
/**
 * Gets an item which was previously interned.
 *
 * @param item {@code non-null;} the item to look for
 * @return {@code non-null;} the equivalent already-interned instance
 */
public <T extends OffsettedItem> T get(T item) {
    throwIfNotPrepared();

    OffsettedItem result = interns.get(item);

    if (result != null) {
        return (T) result;
    }

    throw new NoSuchElementException(item.toString());
}
项目:chromium-for-android-56-debug-video    文件:CustomTabsService.java   
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 *         same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
           IBinder binder = sessionToken.getCallbackBinder();
           DeathRecipient deathRecipient =
                   mDeathRecipientMap.get(binder);
           binder.unlinkToDeath(deathRecipient, 0);
           mDeathRecipientMap.remove(binder);
       }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
项目:RxJava3-preview    文件:FlowableFirstTest.java   
@Test
public void firstOrErrorNoElement() {
    Flowable.empty()
        .firstOrError()
        .test()
        .assertNoValues()
        .assertError(NoSuchElementException.class);
}
项目:JRediClients    文件:Pool.java   
public T getResource() {
    try {
        return internalPool.borrowObject();
    } catch (NoSuchElementException nse) {
        if (null == nse.getCause()) { // The exception was caused by an exhausted pool
            throw new JedisExhaustedPoolException("Could not get a resource since the pool is exhausted", nse);
        }
        // Otherwise, the exception was caused by the implemented activateObject() or
        // ValidateObject()
        throw new JedisException("Could not get a resource from the pool", nse);
    } catch (Exception e) {
        throw new JedisConnectionException("Could not get a resource from the pool", e);
    }
}
项目:guava-mock    文件:IteratorsTest.java   
public void testFind_notPresent() {
  Iterable<String> list = Lists.newArrayList("cool", "pants");
  Iterator<String> iterator = list.iterator();
  try {
    Iterators.find(iterator, Predicates.alwaysFalse());
    fail();
  } catch (NoSuchElementException e) {
  }
  assertFalse(iterator.hasNext());
}
项目:Elasticsearch    文件:BackoffPolicy.java   
@Override
public TimeValue next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    curr++;
    return delay;
}
项目:luna    文件:TypeInfo.java   
public boolean isReified(Var v) {
  Objects.requireNonNull(v);

  Boolean r = vars.get(v);
  if (r != null) {
    return r.booleanValue();
  } else {
    throw new NoSuchElementException("Variable not found: " + v);
  }
}
项目:Logisim    文件:IteratorUtil.java   
@Override
public E next() {
    if (taken)
        throw new NoSuchElementException();
    taken = true;
    return data;
}
项目:monix-forkjoin    文件:LinkedTransferQueue.java   
public final E next() {
    Node p = nextNode;
    if (p == null) throw new NoSuchElementException();
    E e = nextItem;
    advance(p);
    return e;
}
项目:incubator-netbeans    文件:ProxyHighlightsContainer.java   
public @Override int getStartOffset() {
    synchronized (ProxyHighlightsContainer.this.LOCK) {
        if (index1 == -2 && index2 == -2) {
            throw new IllegalStateException("Uninitialized sequence, call moveNext() first."); //NOI18N
        } else if (index1 == -1 || index2 == -1) {
            throw new NoSuchElementException();
        }

        return marks[index1].getPreviousMarkOffset();
    }
}
项目:CraftoDB    文件:Row.java   
/** TODO: Documentation */
public double getDouble(String columnName) throws NoSuchColumnException, NoSuchElementException {
    DBUtil.notNullNotEmpty(columnName, "The columnName must neither be null nor empty: " + columnName);

    Object object = this.pull(columnName);
    if (object == null) { throw new NoSuchElementException("Column has null value: " + columnName); }
    return Double.parseDouble(object.toString());
}
项目:incubator-netbeans    文件:SimpleSearchIterator.java   
/**
 */
@Override
public FileObject next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }

    upToDate = false;
    return nextObject;
}
项目:chipKIT-importer    文件:ChipKitImportWizardIterator.java   
@Override
public void nextPanel() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    index++;
}
项目:mupdf-android-viewer-old    文件:ArrayDeque.java   
/**
 * @throws NoSuchElementException {@inheritDoc}
 */
public E getLast() {
    @SuppressWarnings("unchecked")
    E result = (E) elements[(tail - 1) & (elements.length - 1)];
    if (result == null)
        throw new NoSuchElementException();
    return result;
}
项目:googles-monorepo-demo    文件:QueueRemoveTester.java   
@CollectionFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(ZERO)
public void testRemove_empty() {
  try {
    getQueue().remove();
    fail("emptyQueue.remove() should throw");
  } catch (NoSuchElementException expected) {
  }
  expectUnchanged();
}
项目:rskj    文件:RskWireProtocol.java   
/*************************
 *  Message Processing   *
 *************************/

protected void processStatus(org.ethereum.net.eth.message.StatusMessage msg, ChannelHandlerContext ctx) throws InterruptedException {

    try {
        Genesis genesis = GenesisLoader.loadGenesis(config, config.genesisInfo(), config.getBlockchainConfig().getCommonConstants().getInitialNonce(), true);
        if (!Arrays.equals(msg.getGenesisHash(), genesis.getHash())
                || msg.getProtocolVersion() != version.getCode()) {
            loggerNet.info("Removing EthHandler for {} due to protocol incompatibility", ctx.channel().remoteAddress());
            ethState = EthState.STATUS_FAILED;
            recordEvent(EventType.INCOMPATIBLE_PROTOCOL);
            disconnect(ReasonCode.INCOMPATIBLE_PROTOCOL);
            ctx.pipeline().remove(this); // Peer is not compatible for the 'eth' sub-protocol
            return;
        }

        if (msg.getNetworkId() != config.networkId()) {
            ethState = EthState.STATUS_FAILED;
            recordEvent(EventType.INVALID_NETWORK);
            disconnect(ReasonCode.NULL_IDENTITY);
            return;
        }

        // basic checks passed, update statistics
        channel.getNodeStatistics().ethHandshake(msg);
        ethereumListener.onEthStatusUpdated(channel, msg);

        if (peerDiscoveryMode) {
            loggerNet.debug("Peer discovery mode: STATUS received, disconnecting...");
            disconnect(ReasonCode.REQUESTED);
            ctx.close().sync();
            ctx.disconnect().sync();
            return;
        }
    } catch (NoSuchElementException e) {
        loggerNet.debug("EthHandler already removed");
    }
}
项目:Java-Algorithms-Learning    文件:DoubleLinkedList.java   
/**
 * 返回List前端的元素, 并把该元素从List中删除.(模拟LIFO)
 * @throws NoSuchElementException
 * if the client attempts to remove an item from an empty list
 * @return List前端第一个元素
 */
public Item popFirst() {
    if (getSize() == 0)
        throw new NoSuchElementException("This DoubleLinkedList is empty!");

    return pop(0);
}
项目:guava-mock    文件:MinMaxPriorityQueue.java   
/**
 * Removes and returns the greatest element of this queue.
 *
 * @throws NoSuchElementException if the queue is empty
 */
@CanIgnoreReturnValue
public E removeLast() {
  if (isEmpty()) {
    throw new NoSuchElementException();
  }
  return removeAndGet(getMaxElementIndex());
}
项目:googles-monorepo-demo    文件:SortedSetNavigationTester.java   
@CollectionSize.Require(ZERO)
public void testEmptySetLast() {
  try {
    sortedSet.last();
    fail();
  } catch (NoSuchElementException e) {
  }
}
项目:ChronoBike    文件:CMove.java   
protected Element ExportCustom(Document root)
{
    Element eMove ;
    if (m_bMoveCorresponding)
    {
        eMove = root.createElement("MoveCorresponding") ;
    }
    else
    {
        eMove = root.createElement("Move") ;
    }
    Element eFrom = root.createElement("From") ;
    m_valueFrom.ExportTo(eFrom, root) ;
    eMove.appendChild(eFrom) ;
    ListIterator i = m_arrToIdentifiers.listIterator() ;
    try
    {
        CIdentifier idDest = (CIdentifier)i.next() ;
        while (idDest != null)
        {
            Element dest ;
            if (m_bFillAll)
            {
                dest = root.createElement("Fill") ;
            }
            else
            {
                dest = root.createElement("To") ;
            }
            idDest.ExportTo(dest, root) ;
            eMove.appendChild(dest) ;
            idDest = (CIdentifier)i.next() ;
        }
    }
    catch (NoSuchElementException e)
    {
        // nothing 
    }
    return eMove;
}
项目:guava-mock    文件:AbstractNavigableMap.java   
@Override
public K lastKey() {
  Entry<K, V> entry = lastEntry();
  if (entry == null) {
    throw new NoSuchElementException();
  } else {
    return entry.getKey();
  }
}
项目:mupdf-android-viewer-old    文件:ArrayDeque.java   
public E next() {
    if (cursor == fence)
        throw new NoSuchElementException();
    @SuppressWarnings("unchecked") E result = (E) elements[cursor];
    // This check doesn't catch all possible comodifications,
    // but does catch the ones that corrupt traversal
    if (tail != fence || result == null)
        throw new ConcurrentModificationException();
    lastRet = cursor;
    cursor = (cursor + 1) & (elements.length - 1);
    return result;
}
项目:ditb    文件:RowResultGenerator.java   
public Cell next() {
  if (cache != null) {
    Cell kv = cache;
    cache = null;
    return kv;
  }
  if (valuesI == null) {
    return null;
  }
  try {
    return valuesI.next();
  } catch (NoSuchElementException e) {
    return null;
  }
}
项目:presto-manager    文件:AgentFileUtils.java   
public static String getFileProperty(Path path, String property)
        throws IOException
{
    Properties properties = new Properties();
    try (InputStream inputStream = new FileInputStream(path.toString())) {
        properties.load(inputStream);
    }
    if (!properties.containsKey(property)) {
        throw new NoSuchElementException("Property does not exist");
    }
    return properties.getProperty(property);
}