Example usage for java.lang NullPointerException NullPointerException

List of usage examples for java.lang NullPointerException NullPointerException

Introduction

In this page you can find the example usage for java.lang NullPointerException NullPointerException.

Prototype

public NullPointerException(String s) 

Source Link

Document

Constructs a NullPointerException with the specified detail message.

Usage

From source file:com.vnomicscorp.spring.security.cas.authentication.redis.DefaultCasAuthenticationTokenSerializer.java

@Override
public String serialize(CasAuthenticationToken token) throws CasAuthenticationTokenSerializerException {
    if (token == null) {
        throw new NullPointerException("Expected given token to be non-null");
    }//ww  w  .  j  a va2s.c  om
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(token);
        oos.flush();
        return new String(Base64.encode(baos.toByteArray()), charset);
    } catch (IOException e) {
        throw new CasAuthenticationTokenSerializerException(e);
    }
}

From source file:edu.dfci.cccb.mev.dataset.domain.gzip.GzipTsvInput.java

public GzipTsvInput(URL url) {
    if (url == null)
        throw new NullPointerException("URL cannot be null");
    this.url = url;
}

From source file:edu.cornell.mannlib.vitro.webapp.auth.permissions.PermissionRegistry.java

/**
 * Get the registry from the context. If there isn't one, throw an
 * exception.//from w ww.j  a  v a 2 s  . c o m
 */
public static PermissionRegistry getRegistry(ServletContext ctx) {
    if (ctx == null) {
        throw new NullPointerException("ctx may not be null.");
    }

    Object o = ctx.getAttribute(ATTRIBUTE_NAME);
    if (o == null) {
        throw new IllegalStateException("PermissionRegistry has not been set.");
    } else if (!(o instanceof PermissionRegistry)) {
        throw new IllegalStateException("PermissionRegistry was set to an " + "invalid object: " + o);
    }

    return (PermissionRegistry) o;
}

From source file:io.kahu.hawaii.util.exception.HawaiiExceptionTest.java

@Test
public void testMessage() throws Exception {
    ServerException e = new ServerException(TestServerError.S1);
    Assert.assertTrue("S1".equals(e.getMessage()));

    e = new ServerException(TestServerError.S1, new NullPointerException("npe"));
    Assert.assertTrue("S1".equals(e.getMessage()));

    e = new ServerException(TestServerError.S1, "piet");
    Assert.assertTrue("S1 - piet".equals(e.getMessage()));

    e = new ServerException(TestServerError.S1, "klaas", new NullPointerException("npe"));
    Assert.assertTrue("S1 - klaas".equals(e.getMessage()));

    e = new ServerException(TestServerError.S1, null, new NullPointerException("npe"));
    Assert.assertTrue("S1".equals(e.getMessage()));

    e = new ServerException(TestServerError.S1, "marie", null);
    Assert.assertTrue("S1 - marie".equals(e.getMessage()));
}

From source file:common.services.generic.GenericCacheService.java

public void init() {
    StringBuilder sb = new StringBuilder();
    common.utils.MiscUtils.checkNotNull(path, "path", sb);
    if (sb.length() > 0) {
        throw new NullPointerException(sb.toString());
    }/*from www  .  j  av a  2 s .c  o  m*/
}

From source file:de.cosmocode.json.JsonArrayList.java

/**
 * Constructs a new {@link JsonArrayList} using the specified {@link JSONArray}.
 * //from w w  w  .j a  v a  2  s  .c om
 * @param array the {@link JSONArray} this list will be backed by
 */
public JsonArrayList(JSONArray array) {
    if (array == null)
        throw new NullPointerException("JSONArray must not be null");
    this.array = array;
    if (contains(null))
        throw new NullPointerException("JSONList must not contain null values");
}

From source file:com.github.rvesse.airline.builder.AliasBuilder.java

public AliasBuilder<C> withArguments(String... args) {
    for (String arg : args) {
        if (arg == null)
            throw new NullPointerException("Alias argument cannot be null");
        arguments.add(arg);/*  w  w  w  . j  a  va 2s.  com*/
    }
    return this;
}

From source file:fr.recolnat.database.ExportsDatabase.java

public List<String[]> listUserExports(String user) {
    if (log.isDebugEnabled()) {
        log.debug("Entering listUserExports(user=" + user + ")");
    }// w w  w. j  av  a  2  s.  c o m
    if (user == null) {
        throw new NullPointerException("User is null");
    }
    while (this.database.isClosed()) {
        log.warn("Exports database is closed, waiting 500ms");
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            log.info("Received SIGINT.");
            return null;
        }
    }

    if (log.isDebugEnabled()) {
        log.debug("Opening user exports");
    }
    Map<String, String> userFiles = this.database.treeMap(user, Serializer.STRING, Serializer.STRING)
            .createOrOpen();
    if (log.isDebugEnabled()) {
        log.debug("Building exports list");
    }
    List<String[]> ret = new LinkedList<>();

    Iterator<String> itFileNames = userFiles.keySet().iterator();
    if (log.isDebugEnabled()) {
        log.debug("Got key set iterator");
    }
    while (itFileNames.hasNext()) {
        String fileName = itFileNames.next();
        String fileUrl = (String) userFiles.get(fileName);
        if (log.isDebugEnabled()) {
            log.debug("Adding " + fileName + " " + fileUrl);
        }
        ret.add(new String[] { fileName, fileUrl });
    }

    if (log.isDebugEnabled()) {
        log.debug("Returning " + ret.toString());
    }

    // This commit is called because createOrOpen is used earlier.
    this.database.commit();

    return ret;
}

From source file:it.cnr.isti.hlt.processfast.data.RecursiveFileLineIteratorProvider.java

public RecursiveFileLineIteratorProvider(String baseDir, String regexInclusion) {
    if (baseDir == null)
        throw new NullPointerException("The collection is 'null'");

    files = listFiles(baseDir, regexInclusion);
}

From source file:core.cms.controller2.AGenericPagesCmsController.java

@Override
public void init() {
    super.init();
    StringBuilder sb = new StringBuilder();

    common.utils.MiscUtils.checkNotNull(pagesCmsNavigationService, "pagesCmsNavigationService", sb);
    if (sb.length() > 0) {
        throw new NullPointerException(sb.toString());
    }//from   w ww  .  j  av  a  2 s.  c o  m
}