Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package ch.cern.dirq;
  
  import java.io.File;
  import java.util.Iterator;
QueueNull - object oriented interface to a null directory based queue.

The goal of this module is to offer a null queue system using the same API as the other directory queue implementations. The queue will behave like a black hole: added data will disappear immediately so the queue will therefore always appear empty.

This can be used for testing purposes or to discard data like one would do on Unix by redirecting output to /dev/null.

Please refer to Queue for general information about directory queues.

Author(s):
Lionel Cons <lionel.cons@cern.ch>
Massimo Paladin <massimo.paladin@gmail.com> Copyright (C) CERN 2012-2013
 
 
 public class QueueNull implements Queue {

    
Constructor creating a null directory queue with no parameters.
 
     public QueueNull() {
     }

    
Return the queue id.

Returns:
the String "NULL"
 
     @Override
     public String getId() {
         return "NULL";
     }

    
Add data as a string to the queue.

Returns:
an empty String
 
     @Override
     public String add(String data) {
         return "";
     }

    
Add data as byte array to the queue.

Returns:
an empty String
 
     @Override
     public String add(byte[] data) {
         return "";
     }

    
Add the given file (identified by its path) to the queue.

Returns:
an empty String
 
     @Override
     public String addPath(String path) {
         File file = new File(path);
         if (file.exists())
             file.delete();
         return "";
     }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
 
     @Override
     public String get(String name) {
         throw new UnsupportedOperationException();
     }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
 
     @Override
     public byte[] getAsByteArray(String name) {
         throw new UnsupportedOperationException();
     }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
    @Override
    public String getPath(String path) {
        throw new UnsupportedOperationException();
    }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
    @Override
    public boolean lock(String name) {
        throw new UnsupportedOperationException();
    }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
    public boolean lock(String nameboolean permissive) {
        throw new UnsupportedOperationException();
    }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
    @Override
    public boolean unlock(String name) {
        throw new UnsupportedOperationException();
    }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
    @Override
    public boolean unlock(String nameboolean permissive) {
        throw new UnsupportedOperationException();
    }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as it does not make sense for a null queue.
    @Override
    public void remove(String name) {
        throw new UnsupportedOperationException();
    }

    
Return the number of elements in the queue.

Returns:
zero
    @Override
    public int count() {
        return 0;
    }

    
Does not do anything.
    @Override
    public void purge() {
    }

    
Does not do anything.
    @Override
    public void purge(Integer maxLock) {
    }

    
Does not do anything.
    @Override
    public void purge(Integer maxLockInteger maxTemp) {
    }

    
Iterator over QueueNull implementation.
    @Override
    public Iterator<Stringiterator() {
        return new QueueNullIterator();
    }
    private static class QueueNullIterator implements Iterator<String> {

        
Return true if there are still elements to be iterated.
        @Override
        public boolean hasNext() {
            return false;
        }

        
Return the next element to be iterated.
        @Override
        public String next() {
            throw new NoSuchElementException();
        }

        
Make sure visited element is removed from the list of iterable items.
        @Override
        public void remove() {
        }
    }
New to GrepCode? Check out our FAQ X