Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package ch.cern.dirq;
  
  import java.io.File;
  import java.util.Iterator;
  import java.util.Map;

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):
Massimo Paladin - massimo.paladin@gmail.com
Copyright (C) CERN 2012-2013
 
 public class QueueNull implements Queue {

    
Constructor which creates a null directory queue which accept no parameters.
 
     public QueueNull() {
     }

    

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

    

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

    
Delete the File at the given path.

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 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 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 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 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 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 does not make sense for a null queue.
    @Override
    public void remove(String name) {
        throw new UnsupportedOperationException();
    }

    
Always return 0.
    @Override
    public int count() {
        return 0;
    }

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as does not make sense for a null queue.
    @Override
    public Iterator<Stringiterator() {
        return new QueueNullIterator();
    }
    private static class QueueNullIterator implements Iterator<String> {

        

Returns:
false as it is a null queue.
        @Override
        public boolean hasNext() {
            return false;
        }

        

Returns:
null as it is a null queue.
        @Override
        public String next() {
            return null;
        }

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

    

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

    
Not implemented, always throws UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException as 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 does not make sense for a null queue.
    @Override
    public boolean unlock(String name) {
        throw new UnsupportedOperationException();
    }

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

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

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

    
Does not do anything.
    @Override
    public void purge(int maxTempint maxLock) {
    }
New to GrepCode? Check out our FAQ X