当前位置: 首页>>代码示例>>Java>>正文


Java NoSuchElementException类代码示例

本文整理汇总了Java中java.util.NoSuchElementException的典型用法代码示例。如果您正苦于以下问题:Java NoSuchElementException类的具体用法?Java NoSuchElementException怎么用?Java NoSuchElementException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NoSuchElementException类属于java.util包,在下文中一共展示了NoSuchElementException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: next

import java.util.NoSuchElementException; //导入依赖的package包/类
public Object next() {

            if (hasNext()) {
                removed = false;

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

                counter++;

                return current.data;
            }

            throw new NoSuchElementException();
        }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:Result.java

示例2: getVisitId

import java.util.NoSuchElementException; //导入依赖的package包/类
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;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:19,代码来源:EcrfRowProcessor.java

示例3: getLoadAvg

import java.util.NoSuchElementException; //导入依赖的package包/类
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) {
      }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:LinuxProcFsStatistics.java

示例4: next

import java.util.NoSuchElementException; //导入依赖的package包/类
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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ConcurrentLinkedQueue.java

示例5: addAll

import java.util.NoSuchElementException; //导入依赖的package包/类
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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NameImpl.java

示例6: getHandleIterator

import java.util.NoSuchElementException; //导入依赖的package包/类
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();
      }
    }
  };
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:21,代码来源:CoprocessIterator.java

示例7: next

import java.util.NoSuchElementException; //导入依赖的package包/类
@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;
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:20,代码来源:RepeatedPointIterator.java

示例8: elements

import java.util.NoSuchElementException; //导入依赖的package包/类
/**
 * 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");
		}
	};
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:29,代码来源:CircularEventQueue.java

示例9: parseEdgeMetadata

import java.util.NoSuchElementException; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:29,代码来源:MetadataParser.java

示例10: invokeMethod

import java.util.NoSuchElementException; //导入依赖的package包/类
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);
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:14,代码来源:APIMethod.java

示例11: getNumber

import java.util.NoSuchElementException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:36,代码来源:HalDashboard.java

示例12: next

import java.util.NoSuchElementException; //导入依赖的package包/类
@Override
public T next()
{
    if (hasNext()) {
        T ret = (T)view.get(position);
        lastPosition = position;
        position++;
        return ret;
    }
    throw new NoSuchElementException();
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:12,代码来源:NativeTypedArrayIterator.java

示例13: next

import java.util.NoSuchElementException; //导入依赖的package包/类
@Override
public E next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    element = elements[index++];
    return element;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:9,代码来源:FairBlockingQueue.java

示例14: testSpanTwoRanges

import java.util.NoSuchElementException; //导入依赖的package包/类
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);
      }
    }
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:32,代码来源:TreeRangeMapTest.java

示例15: testOptionalMapOnEmpty

import java.util.NoSuchElementException; //导入依赖的package包/类
@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
    }
}
 
开发者ID:jeffgbutler,项目名称:practical-functional-java,代码行数:16,代码来源:OptionalTest.java


注:本文中的java.util.NoSuchElementException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。