Java Code Examples for java.util.NoSuchElementException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project action-core, under directory /src/main/java/com/ning/metrics/action/hdfs/data/.

Source file: RowFileContentsIterator.java

  34 
vote

@Override public Row next(){
  hasNext();
  final Row returnRow=row;
  row=null;
  if (returnRow == null) {
    throw new NoSuchElementException();
  }
  return returnRow;
}
 

Example 2

From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/list/.

Source file: SequenceSet.java

  33 
vote

/** 
 * Removes and returns the first element from this list.
 * @return the first element from this list.
 * @throws NoSuchElementException if this list is empty.
 */
public long removeFirst(){
  if (isEmpty()) {
    throw new NoSuchElementException();
  }
  Sequence rc=removeFirstSequence(1);
  return rc.first;
}
 

Example 3

From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/.

Source file: KernelProxy.java

  32 
vote

private ObjectName assertExists(ObjectName name){
  try {
    if (!server.queryNames(name,null).isEmpty()) {
      return name;
    }
  }
 catch (  IOException handled) {
  }
  throw new NoSuchElementException("No MBeans matching " + name);
}
 

Example 4

From project accounted4, under directory /accounted4/accounted4-money/src/main/java/com/accounted4/money/.

Source file: Split.java

  31 
vote

@Override public Money next(){
  if (!hasNext()) {
    throw new NoSuchElementException("getEqualizedIterator");
  }
  return new Money(splitAmountCalculator.nextAmount(currentIndex++),inputMoney.getCurrency(),inputMoney.getRoundingMode());
}
 

Example 5

From project aether-core, under directory /aether-util/src/main/java/org/eclipse/aether/util/graph/visitor/.

Source file: Stack.java

  31 
vote

@SuppressWarnings("unchecked") public E pop(){
  if (size <= 0) {
    throw new NoSuchElementException();
  }
  return (E)elements[--size];
}
 

Example 6

From project agraph-java-client, under directory /src/com/franz/agraph/http/handler/.

Source file: AGTQRStreamer.java

  31 
vote

@Override public BindingSet next() throws QueryEvaluationException {
  if (hasNext()) {
    BindingSet curr=next;
    next=null;
    return curr;
  }
 else   if (closed) {
    throw new RuntimeException("closed");
  }
 else {
    throw new NoSuchElementException();
  }
}
 

Example 7

From project airlift, under directory /jmx/src/main/java/io/airlift/jmx/.

Source file: GuiceDependencyIterator.java

  31 
vote

@Override public Class<?> next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  Class<?> localClass=currentClass;
  currentClass=null;
  return localClass;
}
 

Example 8

From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/message/.

Source file: BasicHeaderElementIterator.java

  31 
vote

public HeaderElement nextElement() throws NoSuchElementException {
  if (this.currentElement == null) {
    parseNextElement();
  }
  if (this.currentElement == null) {
    throw new NoSuchElementException("No more header elements available");
  }
  HeaderElement element=this.currentElement;
  this.currentElement=null;
  return element;
}
 

Example 9

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/net/poolable/copy/.

Source file: CursorableLinkedList.java

  31 
vote

/** 
 * Returns the element at the beginning of this list.
 */
public Object getFirst(){
  try {
    return _head.next().value();
  }
 catch (  NullPointerException e) {
    throw new NoSuchElementException();
  }
}
 

Example 10

From project and-bible, under directory /AndBible/src/org/apache/commons/lang/time/.

Source file: DateUtils.java

  31 
vote

/** 
 * Return the next calendar in the iteration
 * @return Object calendar for the next date
 */
public Calendar next(){
  if (spot.equals(endFinal)) {
    throw new NoSuchElementException();
  }
  spot.add(Calendar.DATE,1);
  return (Calendar)spot.clone();
}
 

Example 11

From project android_8, under directory /src/com/google/gson/internal/.

Source file: $Gson$Types.java

  31 
vote

private static int indexOf(Object[] array,Object toFind){
  for (int i=0; i < array.length; i++) {
    if (toFind.equals(array[i])) {
      return i;
    }
  }
  throw new NoSuchElementException();
}
 

Example 12

From project android_external_guava, under directory /src/com/google/common/base/.

Source file: Splitter.java

  31 
vote

public final T next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  state=State.NOT_READY;
  return next;
}
 

Example 13

From project android_external_libphonenumber, under directory /java/src/com/android/i18n/phonenumbers/.

Source file: PhoneNumberMatcher.java

  31 
vote

public PhoneNumberMatch next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  PhoneNumberMatch result=lastMatch;
  lastMatch=null;
  state=State.NOT_READY;
  return result;
}
 

Example 14

From project archive-commons, under directory /archive-commons/src/main/java/org/archive/util/iterator/.

Source file: AbstractPeekableIterator.java

  31 
vote

public E next(){
  if (cachedNext == null) {
    if (!hasNext()) {
      throw new NoSuchElementException("Call hasNext!");
    }
  }
  E tmp=cachedNext;
  cachedNext=null;
  return tmp;
}
 

Example 15

From project ardverk-commons, under directory /src/main/java/org/ardverk/collection/.

Source file: ArrayIterator.java

  31 
vote

@Override public T next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  if (index == -1) {
    ++index;
    return first;
  }
  return others[offset + (index++)];
}
 

Example 16

From project ardverk-dht, under directory /components/store/src/main/java/org/ardverk/dht/storage/.

Source file: VclockUtils.java

  31 
vote

public static Vclock valueOf(Key key,Context context) throws IOException {
  Header clientId=context.removeHeader(Constants.CLIENT_ID);
  if (clientId == null) {
    throw new NoSuchElementException(Constants.CLIENT_ID);
  }
  return getOrCreate(key,context).update(clientId.getValue());
}
 

Example 17

From project arquillian-graphene, under directory /graphene-selenium/graphene-selenium-api/src/main/java/org/jboss/arquillian/ajocado/locator/element/.

Source file: AbstractIterableLocator.java

  31 
vote

@Override public T next(){
  if (hasNext()) {
    return get(index++);
  }
 else {
    throw new NoSuchElementException();
  }
}
 

Example 18

From project arquillian-rusheye, under directory /rusheye-api/src/main/java/org/jboss/rusheye/internal/.

Source file: FilterCollection.java

  31 
vote

public E next(){
  if (hasNext()) {
    E result=next;
    next=null;
    return result;
  }
 else {
    throw new NoSuchElementException();
  }
}
 

Example 19

From project as3-commons-jasblocks, under directory /src/main/java/org/as3commons/asblocks/impl/.

Source file: ASTIterator.java

  31 
vote

public LinkedListTree next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  index++;
  return (LinkedListTree)parent.getChild(index);
}
 

Example 20

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/casemodule/.

Source file: AddImageWizardIterator.java

  31 
vote

/** 
 * Moves to the next panel. I.e. increment its index, need not actually change any GUI itself.
 */
@Override public void nextPanel(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  index++;
}
 

Example 21

From project avro, under directory /lang/java/avro/src/main/java/org/apache/avro/file/.

Source file: DataFileStream.java

  31 
vote

/** 
 * Read the next datum from the file.
 * @param reuse an instance to reuse.
 * @throws NoSuchElementException if no more remain in the file.
 */
public D next(D reuse) throws IOException {
  if (!hasNext())   throw new NoSuchElementException();
  D result=reader.read(reuse,datumIn);
  if (0 == --blockRemaining) {
    blockFinished();
  }
  return result;
}
 

Example 22

From project bdb-index, under directory /src/main/java/org/neo4j/index/bdbje/.

Source file: BerkeleyDbIndex.java

  31 
vote

@Override public T getSingle(){
  if (length == 1 && hasNext()) {
    return next();
  }
  throw new NoSuchElementException();
}
 

Example 23

From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/utils/.

Source file: DynamicCollection.java

  31 
vote

public E first(){
synchronized (lock) {
    if (storage.isEmpty()) {
      throw new NoSuchElementException();
    }
 else {
      return storage.get(0);
    }
  }
}
 

Example 24

From project bonecp, under directory /bonecp/src/main/java/jsr166y/.

Source file: LinkedTransferQueue.java

  31 
vote

public final E next(){
  Node p=nextNode;
  if (p == null)   throw new NoSuchElementException();
  E e=nextItem;
  advance(p);
  return e;
}
 

Example 25

From project book, under directory /src/main/java/com/tamingtext/tagrecommender/.

Source file: StackOverflowStream.java

  31 
vote

public StackOverflowPost next(){
  if (hasNext()) {
    nextQueued=false;
    return post;
  }
 else {
    throw new NoSuchElementException();
  }
}
 

Example 26

From project Bukkit-Plugin-Utilties, under directory /src/main/java/de/xzise/collections/.

Source file: ArrayIterator.java

  31 
vote

public T next() throws NoSuchElementException {
  if (hasNext()) {
    return this.array[this.pos++];
  }
 else {
    throw new NoSuchElementException();
  }
}
 

Example 27

From project camel-osgi, under directory /component/src/main/java/org/apache/camel/osgi/service/util/.

Source file: DynamicCollection.java

  31 
vote

public E first(){
synchronized (lock) {
    if (storage.isEmpty()) {
      throw new NoSuchElementException();
    }
 else {
      return storage.get(0);
    }
  }
}
 

Example 28

From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/util/.

Source file: Strings.java

  31 
vote

public static String firstNonEmpty(String... strings){
  for (  String s : strings) {
    if (!isEmpty(s)) {
      return s;
    }
  }
  throw new NoSuchElementException();
}
 

Example 29

From project chromattic, under directory /apt/src/main/java/org/chromattic/apt/.

Source file: PackageNameIterator.java

  31 
vote

public String next(){
  String next=packageName;
  int pos=packageName.lastIndexOf('.');
  if (pos == -1) {
    throw new NoSuchElementException();
  }
  packageName=packageName.substring(0,pos);
  return next;
}
 

Example 30

From project Cilia_1, under directory /framework/core/src/main/java/fr/liglab/adele/cilia/util/concurrent/.

Source file: ConcurrentReaderHashMap.java

  31 
vote

public Object next(){
  if (currentKey == null && !hasNext())   throw new NoSuchElementException();
  Object result=returnValueOfNext();
  lastReturned=entry;
  currentKey=currentValue=null;
  entry=entry.next;
  return result;
}
 

Example 31

From project CircDesigNA, under directory /src/org/apache/commons/math/linear/.

Source file: AbstractRealVector.java

  31 
vote

/** 
 * {@inheritDoc} 
 */
public Entry next(){
  int index=next.getIndex();
  if (index < 0) {
    throw new NoSuchElementException();
  }
  current.setIndex(index);
  advance(next);
  return current;
}
 

Example 32

From project clirr-maven-plugin, under directory /src/main/java/org/codehaus/mojo/clirr/.

Source file: JavaTypeRepository.java

  31 
vote

private JavaType getRecursiveClirrType(String className,JavaType[] typeSet){
  for (  JavaType jt : types) {
    if (jt.getName().equals(className)) {
      return jt;
    }
    return getRecursiveClirrType(className,jt.getInnerClasses());
  }
  throw new NoSuchElementException("No class named '" + className + "' could be found.");
}
 

Example 33

From project clj-ds, under directory /src/main/java/com/trifork/clj_ds/.

Source file: SeqIterator.java

  31 
vote

public T next() throws NoSuchElementException {
  if (seq == null)   throw new NoSuchElementException();
  T ret=(T)RT.first(seq);
  seq=RT.next(seq);
  return ret;
}
 

Example 34

From project clojure, under directory /src/jvm/clojure/lang/.

Source file: SeqIterator.java

  31 
vote

public Object next() throws NoSuchElementException {
  if (seq == null)   throw new NoSuchElementException();
  Object ret=RT.first(seq);
  seq=RT.next(seq);
  return ret;
}
 

Example 35

From project Cloud9, under directory /src/dist/edu/umd/cloud9/util/map/.

Source file: HMapID.java

  31 
vote

final Entry nextEntry(){
  if (modCount != expectedModCount)   throw new ConcurrentModificationException();
  Entry e=next;
  if (e == null)   throw new NoSuchElementException();
  if ((next=e.next) == null) {
    Entry[] t=table;
    while (index < t.length && (next=t[index++]) == null)     ;
  }
  current=e;
  return e;
}
 

Example 36

From project babel, under directory /src/babel/util/misc/.

Source file: FileList.java

  30 
vote

public InputStream nextElement(){
  InputStream in=null;
  if (!hasMoreElements()) {
    throw new NoSuchElementException("No more files.");
  }
 else {
    String nextElement=m_listOfFiles[m_current++];
    try {
      in=new FileInputStream(nextElement);
    }
 catch (    FileNotFoundException e) {
      System.err.println("ListOfFiles: Can't open " + nextElement);
    }
  }
  return in;
}
 

Example 37

From project ballroom, under directory /widgets/src/main/java/org/jboss/ballroom/client/util/.

Source file: StringTokenizer.java

  30 
vote

/** 
 * Returns the next token from this string tokenizer. <p> The current position is set after the token returned.
 * @return the next token from this string tokenizer.
 * @throws NoSuchElementException if there are no more tokens in this tokenizer's string.
 * @since ostermillerutils 1.00.00
 */
public String nextToken(){
  int workingPosition=position;
  boolean workingEmptyReturned=emptyReturned;
  boolean onToken=advancePosition();
  while (position != workingPosition || emptyReturned != workingEmptyReturned) {
    if (onToken) {
      tokenCount--;
      return (emptyReturned ? "" : text.substring(workingPosition,(position != -1) ? position : strLength));
    }
    workingPosition=position;
    workingEmptyReturned=emptyReturned;
    onToken=advancePosition();
  }
  throw new NoSuchElementException();
}
 

Example 38

From project AirCastingAndroidClient, under directory /src/main/java/ioio/lib/api/.

Source file: IOIOFactory.java

  29 
vote

/** 
 * Create a IOIO instance. This specific implementation creates a IOIO instance which works with the actual IOIO board connected via a TCP connection (typically over a wired USB connection).
 * @return The IOIO instance.
 */
public static IOIO create(){
  Collection<IOIOConnectionFactory> factories=IOIOConnectionRegistry.getConnectionFactories();
  try {
    return create(factories.iterator().next().createConnection());
  }
 catch (  NoSuchElementException e) {
    Log.e(TAG,"No connection is available. This shouldn't happen.");
    throw e;
  }
}
 

Example 39

From project akubra, under directory /akubra-rmi/src/test/java/org/akubraproject/rmi/client/.

Source file: ClientIteratorTest.java

  29 
vote

@Test public void testNext(){
  for (  String v : source) {
    assertEquals(v,ci.next());
  }
  try {
    ci.next();
    fail("Failed to get NoSuchElementException");
  }
 catch (  NoSuchElementException e) {
  }
catch (  Exception e) {
    fail("Failed to get NoSuchElementException");
  }
}
 

Example 40

From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/record/.

Source file: SmartPoster.java

  29 
vote

public static SmartPoster parse(NdefRecord[] recordsRaw){
  try {
    Iterable<ParsedNdefRecord> records=NdefMessageParser.getRecords(recordsRaw);
    UriRecord uri=Iterables.getOnlyElement(Iterables.filter(records,UriRecord.class));
    TextRecord title=getFirstIfExists(records,TextRecord.class);
    ImageRecord image=getFirstIfExists(records,ImageRecord.class);
    RecommendedAction action=parseRecommendedAction(recordsRaw);
    String type=parseType(recordsRaw);
    return new SmartPoster(uri,title,image,action,type);
  }
 catch (  NoSuchElementException e) {
    throw new IllegalArgumentException(e);
  }
}
 

Example 41

From project asterisk-java, under directory /src/main/java/org/asteriskjava/util/internal/.

Source file: SocketConnectionFacadeImpl.java

  29 
vote

public String readLine() throws IOException {
  String line;
  try {
    line=scanner.next();
  }
 catch (  IllegalStateException e) {
    if (scanner.ioException() != null) {
      throw scanner.ioException();
    }
 else {
      throw new IOException("No more lines available: " + e.getMessage());
    }
  }
catch (  NoSuchElementException e) {
    if (scanner.ioException() != null) {
      throw scanner.ioException();
    }
 else {
      throw new IOException("No more lines available: " + e.getMessage());
    }
  }
  if (trace != null) {
    trace.received(line);
  }
  return line;
}
 

Example 42

From project astyanax, under directory /src/main/java/com/netflix/astyanax/connectionpool/impl/.

Source file: SmaLatencyScoreStrategyInstanceImpl.java

  29 
vote

@Override public void addSample(long sample){
  if (!latencies.offer(sample)) {
    try {
      latencies.remove();
    }
 catch (    NoSuchElementException e) {
    }
    latencies.offer(sample);
  }
}
 

Example 43

From project baseunits, under directory /src/main/java/jp/xet/baseunits/time/.

Source file: BusinessCalendar.java

  29 
vote

/** 
 * {@link CalendarDate}???????????????????????????@link CalendarDate}????° ???????????@link CalendarDate}????????????????? <p>????°?????????????????????????????????????????????????????????????????? ???????????????  {@link Iterator#next()} ?????????????????</p>
 * @param calendarDays ??????????
 * @return ????????????????
 * @throws IllegalArgumentException ?????@code null}?????????
 * @since 1.0
 */
public Iterator<CalendarDate> businessDaysOnly(final Iterator<CalendarDate> calendarDays){
  Validate.notNull(calendarDays);
  return new ImmutableIterator<CalendarDate>(){
    CalendarDate lookAhead=null;
{
      lookAhead=nextBusinessDate();
    }
    @Override public boolean hasNext(){
      return lookAhead != null;
    }
    @Override public CalendarDate next(){
      if (hasNext() == false) {
        throw new NoSuchElementException();
      }
      CalendarDate next=lookAhead;
      lookAhead=nextBusinessDate();
      return next;
    }
    private CalendarDate nextBusinessDate(){
      CalendarDate result=null;
      do {
        result=calendarDays.hasNext() ? (CalendarDate)calendarDays.next() : null;
      }
 while ((result == null || isBusinessDay(result)) == false);
      return result;
    }
  }
;
}
 

Example 44

From project BioMAV, under directory /Behavior/src/nl/ru/ai/projects/parrot/ea2/client/.

Source file: TaskClient.java

  29 
vote

public synchronized boolean connect(String target){
  disconnect();
  try {
    receiveSocket=new Socket();
    receiveSocket.setSoTimeout(5000);
    receiveSocket.connect(new InetSocketAddress(target,TaskServer.PORT));
    InputStream inStream=receiveSocket.getInputStream();
    Scanner inScanner=new Scanner(inStream);
    String line=inScanner.nextLine().trim();
    if ("None".equals(line)) {
      receiveSocket.close();
      receiveSocket=null;
      return false;
    }
    if (line.matches("^Lines\\s+[0-9]+$")) {
      int lineCount=Integer.parseInt(line.split("\\s+")[1]);
      String inLines="";
      for (int i=0; i < lineCount; i++) {
        inLines+=inScanner.nextLine().replaceAll("[\n\r]","") + "\n";
      }
      connectionParameters=new TaskParameters(inLines);
      socketOutStream=receiveSocket.getOutputStream();
      return true;
    }
    return false;
  }
 catch (  NoSuchElementException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  disconnect();
  return false;
}
 

Example 45

From project blacktie, under directory /jatmibroker-xatmi/src/main/java/org/jboss/narayana/blacktie/jatmibroker/core/tx/.

Source file: ThreadActionData.java

  29 
vote

public static void purgeAction(TransactionImpl act,Thread t,boolean unregister) throws NoSuchElementException {
  if ((act != null) && (unregister)) {
    act.removeChildThread(ThreadUtil.getThreadId(t));
  }
  Stack txs=(Stack)_threadList.get();
  if (txs != null) {
    txs.removeElement(act);
    if (txs.size() == 0) {
      _threadList.set(null);
    }
  }
}
 

Example 46

From project Blitz, under directory /src/com/laxser/blitz/web/impl/thread/.

Source file: ParameteredUriRequest.java

  29 
vote

@Override @SuppressWarnings({"unchecked","rawtypes"}) public Enumeration getParameterNames(){
  final Enumeration<String> requestParamNames=super.getParameterNames();
  return new Enumeration<String>(){
    final Iterator<String> matchResultParamNames=new ArrayList<String>(parameters.keySet()).iterator();
    @Override public boolean hasMoreElements(){
      return matchResultParamNames.hasNext() || requestParamNames.hasMoreElements();
    }
    @Override public String nextElement(){
      if (matchResultParamNames.hasNext()) {
        return matchResultParamNames.next();
      }
      if (requestParamNames.hasMoreElements()) {
        return requestParamNames.nextElement();
      }
      throw new NoSuchElementException();
    }
  }
;
}
 

Example 47

From project capedwarf-green, under directory /server-api/src/main/java/org/jboss/capedwarf/server/api/domain/.

Source file: Version.java

  29 
vote

/** 
 * Create a new VersionImpl.
 * @param version the version as a string
 * @throws IllegalArgumentException for a null version or invalid format
 */
private Version(String version){
  if (version == null)   throw new IllegalArgumentException("Null version");
  int major;
  int minor=0;
  int micro=0;
  String qualifier="";
  try {
    StringTokenizer st=new StringTokenizer(version,SEPARATOR,true);
    major=Integer.parseInt(st.nextToken().trim());
    if (st.hasMoreTokens()) {
      st.nextToken();
      minor=Integer.parseInt(st.nextToken().trim());
      if (st.hasMoreTokens()) {
        st.nextToken();
        micro=Integer.parseInt(st.nextToken().trim());
        if (st.hasMoreTokens()) {
          st.nextToken();
          qualifier=st.nextToken().trim();
          if (st.hasMoreTokens()) {
            throw new IllegalArgumentException("Invalid version format, too many seperators: " + version);
          }
        }
      }
    }
  }
 catch (  NoSuchElementException e) {
    throw new IllegalArgumentException("Invalid version format: " + version);
  }
catch (  NumberFormatException e) {
    throw new IllegalArgumentException("Invalid version format: " + version,e);
  }
  this.major=major;
  this.minor=minor;
  this.micro=micro;
  this.qualifier=qualifier;
  validate();
}
 

Example 48

From project Carnivore, under directory /net/sourceforge/jpcap/util/.

Source file: PropertyHelper.java

  29 
vote

/** 
 * Convert a space delimited color tuple string to a color. <p> Converts a string value like "255 255 0" to a color constant, in this case, yellow.
 * @param key the name of the property
 * @return a Color object equivalent to the provided string contents. Returns white if the string is null or can't be converted.
 */
public static Color getColorProperty(Properties properties,Object key){
  String string=(String)properties.get(key);
  if (string == null) {
    System.err.println("WARN: couldn't find color tuplet under '" + key + "'");
    return Color.white;
  }
  StringTokenizer st=new StringTokenizer(string," ");
  Color c;
  try {
    c=new Color(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()));
  }
 catch (  NoSuchElementException e) {
    c=Color.white;
    System.err.println("WARN: invalid color spec '" + string + "' in property file");
  }
  return c;
}
 

Example 49

From project cascading, under directory /src/hadoop/cascading/flow/hadoop/.

Source file: HadoopCoGroupClosure.java

  29 
vote

public Iterator<Tuple> createIterator(final IndexTuple current,final Iterator<IndexTuple> values){
  return new Iterator<Tuple>(){
    IndexTuple value=current;
    @Override public boolean hasNext(){
      return value != null;
    }
    @Override public Tuple next(){
      if (value == null && !values.hasNext())       throw new NoSuchElementException();
      Tuple result=value.getTuple();
      if (values.hasNext())       value=(IndexTuple)values.next();
 else       value=null;
      return result;
    }
    @Override public void remove(){
    }
  }
;
}
 

Example 50

From project ceylon-runtime, under directory /api/src/main/java/ceylon/modules/api/util/.

Source file: ModuleVersion.java

  29 
vote

/** 
 * Create a new VersionImpl.
 * @param version the version as a string
 * @throws IllegalArgumentException for a null version or invalid format
 */
private ModuleVersion(String version){
  if (version == null)   throw new IllegalArgumentException("Null version");
  int major;
  int minor=0;
  int micro=0;
  String qualifier="";
  try {
    StringTokenizer st=new StringTokenizer(version,SEPARATOR,true);
    major=Integer.parseInt(st.nextToken().trim());
    if (st.hasMoreTokens()) {
      st.nextToken();
      minor=Integer.parseInt(st.nextToken().trim());
      if (st.hasMoreTokens()) {
        st.nextToken();
        micro=Integer.parseInt(st.nextToken().trim());
        if (st.hasMoreTokens()) {
          st.nextToken();
          qualifier=st.nextToken().trim();
          if (st.hasMoreTokens()) {
            throw new IllegalArgumentException("Invalid version format, too many seperators: " + version);
          }
        }
      }
    }
  }
 catch (  NoSuchElementException e) {
    throw new IllegalArgumentException("Invalid version format: " + version);
  }
catch (  NumberFormatException e) {
    throw new IllegalArgumentException("Invalid version format: " + version,e);
  }
  this.major=major;
  this.minor=minor;
  this.micro=micro;
  this.qualifier=qualifier;
  validate();
}
 

Example 51

From project chukwa, under directory /src/test/java/org/apache/hadoop/chukwa/dataloader/.

Source file: TestSocketDataLoader.java

  29 
vote

public void testSocketTee() throws Exception {
  Configuration conf=new Configuration();
  conf.set("chukwaCollector.pipeline",SocketTeeWriter.class.getCanonicalName());
  conf.set("chukwaCollector.writerClass",PipelineStageWriter.class.getCanonicalName());
  PipelineStageWriter psw=new PipelineStageWriter();
  psw.init(conf);
  SocketDataLoader sdl=new SocketDataLoader("all");
  System.out.println("pipeline established; now pushing a chunk");
  ArrayList<Chunk> l=new ArrayList<Chunk>();
  l.add(new ChunkImpl("dt","name",1,new byte[]{'a'},null));
  psw.add(l);
  try {
    Collection<Chunk> clist=sdl.read();
    for (    Chunk c : clist) {
      if (c != null && c.getData() != null) {
        assertTrue("a".equals(new String(c.getData())));
      }
    }
  }
 catch (  NoSuchElementException e) {
  }
}
 

Example 52

From project CIShell, under directory /core/org.cishell.reference/src/org/cishell/reference/app/service/scheduler/.

Source file: SchedulerServiceImpl.java

  29 
vote

public boolean reschedule(Algorithm algorithm,Calendar newTime){
  ServiceReference reference=this.algorithmSchedulerTask.getServiceReference(algorithm);
  boolean canReschedule=false;
  try {
    AlgorithmState algorithmState=this.algorithmSchedulerTask.getAlgorithmState(algorithm);
    if (algorithmState.equals(AlgorithmState.RUNNING)) {
      canReschedule=false;
    }
 else     if (algorithmState.equals(AlgorithmState.STOPPED)) {
      this.algorithmSchedulerTask.purgeFinished();
      this.algorithmSchedulerTask.schedule(algorithm,reference,newTime);
      canReschedule=true;
    }
 else     if (algorithmState.equals(AlgorithmState.NEW)) {
      this.algorithmSchedulerTask.cancel(algorithm);
      this.algorithmSchedulerTask.schedule(algorithm,reference,newTime);
    }
 else {
      throw new IllegalStateException("Encountered an invalid state: " + algorithmState);
    }
  }
 catch (  NoSuchElementException e) {
    this.algorithmSchedulerTask.schedule(algorithm,reference,newTime);
    canReschedule=true;
  }
  return canReschedule;
}