java.util.NoSuchElementException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中java.util.NoSuchElementException.getMessage()方法的一些代码示例,展示了NoSuchElementException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NoSuchElementException.getMessage()方法的具体详情如下:
包路径:java.util.NoSuchElementException
类名称:NoSuchElementException
方法名:getMessage

NoSuchElementException.getMessage介绍

暂无

代码示例

代码示例来源:origin: stagemonitor/stagemonitor

public static Integer getMajorVersion(String version) {
  if (version != null) {
    StringTokenizer stringTokenizer = new StringTokenizer(version, ".");
    try {
      Integer majorVersion = Integer.valueOf(stringTokenizer.nextToken());
      logger.debug(String.format("Parsed version: %s, got major version: %d ", version, majorVersion));
      return majorVersion;
    } catch (NumberFormatException nfe) {
      logger.error(nfe.getMessage(), nfe);
    } catch (NoSuchElementException nsee) {
      logger.error(nsee.getMessage(), nsee);
    }
  }
  return null;
}

代码示例来源:origin: apache/hive

throw new EOFException(e.getMessage());

代码示例来源:origin: Sable/soot

/**
 * {@inheritDoc}
 *
 */
@Override
final public boolean contains(Object o) {
 if (o == null) {
  return false;
 }
 try {
  if (o.equals(peek())) {
   return true;
  }
  return contains(getOrdinal(o));
 } catch (NoSuchElementException e) {
  logger.debug("" + e.getMessage());
 }
 return false;
}

代码示例来源:origin: Sable/soot

/**
 * {@inheritDoc}
 *
 */
@Override
final public boolean remove(Object o) {
 if (o == null || isEmpty()) {
  return false;
 }
 try {
  if (o.equals(peek())) {
   remove(min);
   return true;
  }
  return remove(getOrdinal(o));
 } catch (NoSuchElementException e) {
  logger.debug("" + e.getMessage());
 }
 return false;
}

代码示例来源:origin: apache/hbase

public void testAdvanceTwiceOnEmptyCell() throws IOException {
 Result r = Result.create(new Cell[0]);
 assertFalse(r.advance());
 try {
  r.advance();
  fail("NoSuchElementException should have been thrown!");
 } catch (NoSuchElementException ex) {
  LOG.debug("As expected: " + ex.getMessage());
 }
}

代码示例来源:origin: DV8FromTheWorld/JDA

public void createOverridesPass(AbstractChannelImpl<?> channel, JSONArray overrides)
{
  for (int i = 0; i < overrides.length(); i++)
  {
    try
    {
      createPermissionOverride(overrides.getJSONObject(i), channel);
    }
    catch (NoSuchElementException e)
    {
      //Caused by Discord not properly clearing PermissionOverrides when a Member leaves a Guild.
      LOG.debug("{}. Ignoring PermissionOverride.", e.getMessage());
    }
    catch (IllegalArgumentException e)
    {
      //Missing handling for a type
      LOG.warn("{}. Ignoring PermissionOverride.", e.getMessage());
    }
  }
}

代码示例来源:origin: OfficeDev/ews-java-api

throw new DnsException("NumberFormatException " + ne.getMessage());
} catch (NoSuchElementException ne) {
 throw new DnsException("NoSuchElementException " + ne.getMessage());

代码示例来源:origin: geotools/geotools

LOGGER.log(
      Level.WARNING,
      "Out of connections: " + e.getMessage() + ". Config: " + this.config);
  throw new UnavailableConnectionException(config.getMaxConnections(), this.config);
} catch (SeException se) {

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonRDBMS> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize ? available : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonMongo> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize ? available : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  Iterator<CassandraPrimeUser> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize?available:fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonHBase> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize ? available : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  Iterator<PrimeUser> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize != null && fetchSize == 0 ? 0:available);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int expectedCount)
{
  query.setFetchSize(fetchSize);
  int counter = 0;
  Iterator<PersonCouchDB> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || expectedCount < fetchSize ? expectedCount : fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  try
  {
  Iterator<PersonCassandra> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize != null && fetchSize == 0 ? 0:available);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
  }catch(UnsupportedOperationException e)
  { 
    Assert.assertEquals("Iteration not supported over native queries",e.getMessage());
  }
  
}

代码示例来源:origin: Impetus/Kundera

private void assertOnFetch(Query query, Integer fetchSize, int available)
{
  query.setFetchSize(fetchSize);
  int counter=0;
  try
  {
  Iterator<PersonCassandra> iter = query.iterate();
  while (iter.hasNext())
  {
    Assert.assertNotNull(iter.next());
    counter++;
  }
  Assert.assertEquals(counter, fetchSize == null || available < fetchSize?available:fetchSize);
  try
  {
    iter.next();
    Assert.fail();
  }
  catch (NoSuchElementException nsex)
  {
    Assert.assertNotNull(nsex.getMessage());
  }
  }catch(UnsupportedOperationException e)
  { 
    Assert.assertEquals("Iteration not supported over native queries",e.getMessage());
  }
  
}

代码示例来源:origin: Impetus/Kundera

Assert.assertNotNull(nsex.getMessage());

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testDidntFindNetworkThrowsNSEEWithReasonableMessage() {
 Supplier<Set<? extends Location>> supplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
    .<Location> of(provider, region));
 FirstNetwork fn = new FirstNetwork(supplier);
 try {
   fn.get();
   fail("Expected NoSuchElementException");
 } catch (NoSuchElementException e) {
   assertEquals(e.getMessage(), "none of the locations are scope NETWORK: [servo:PROVIDER, servo-r:REGION]");
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testDidntFindRegionThrowsNSEEWithReasonableMessage() {
 Supplier<Set<? extends Location>> supplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
    .<Location> of(provider, zone));
 FirstRegion fn = new FirstRegion(supplier);
 try {
   fn.get();
   fail("Expected NoSuchElementException");
 } catch (NoSuchElementException e) {
   assertEquals(e.getMessage(), "none to of the locations are scope REGION: [servo:PROVIDER, servo-z:ZONE]");
 }
}

代码示例来源:origin: org.apache.hbase/hbase-server

public void testAdvanceTwiceOnEmptyCell() throws IOException {
 Result r = Result.create(new Cell[0]);
 assertFalse(r.advance());
 try {
  r.advance();
  fail("NoSuchElementException should have been thrown!");
 } catch (NoSuchElementException ex) {
  LOG.debug("As expected: " + ex.getMessage());
 }
}

相关文章