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.laxser.blitz.web.portal.impl.WindowTask.java

public WindowTask(WindowImpl window, WindowRequest request, WindowResponse response) {
    if (window == null) {
        throw new NullPointerException("window");
    }/*from   w  ww. jav  a  2s.  c  o m*/
    this.window = window;
    this.request = request;
    this.response = response;
}

From source file:it.scoppelletti.mobilepower.bluetooth.BTManager.java

/**
 * Costruttore.//w ww  .j a v  a2s  . co m
 * 
 * @param ctx Contesto.
 */
public BTManager(Context ctx) {
    if (ctx == null) {
        throw new NullPointerException("Argument ctx is null.");
    }

    myCtx = ctx;
}

From source file:org.sloth.util.ControllerUtils.java

/**
 * Authorizes the {@code HttpSession} with the specified {@code User}.
 * /*from   w  w  w.  jav  a  2  s . c  o  m*/
 * @param s
 *            the {@code HttpSession}
 * @param u
 *            the {@code User}
 */
public static void auth(HttpSession s, User u) {
    if (u == null) {
        throw new NullPointerException("User must not be null.");
    }
    logger.info("Authorizing Session {} by User {}", s.getId(), u.getId());
    s.setAttribute(SESSION_ATTRIBUTE, u);
}

From source file:com.penguineering.cleanuri.sites.reichelt.ReicheltExtractor.java

@Override
public Map<Metakey, String> extractMetadata(URI uri) throws ExtractorException {
    if (uri == null)
        throw new NullPointerException("URI argument must not be null!");

    URL url;/*from w  w  w.j ava2  s  .co m*/
    try {
        url = uri.toURL();
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("The provided URI is not a URL!");
    }

    Map<Metakey, String> meta = new HashMap<Metakey, String>();

    try {
        final URLConnection con = url.openConnection();

        LineNumberReader reader = null;
        try {
            reader = new LineNumberReader(new InputStreamReader(con.getInputStream()));

            String line;
            while ((line = reader.readLine()) != null) {
                if (!line.contains("<h2>"))
                    continue;

                // h2
                int h2_idx = line.indexOf("h2");
                // Doppelpunkte
                int col_idx = line.indexOf("<span> :: <span");
                final String art_id = line.substring(h2_idx + 3, col_idx);
                meta.put(Metakey.ID, html2oUTF8(art_id).trim());

                int span_idx = line.indexOf("</span>");
                final String art_name = line.substring(col_idx + 32, span_idx);
                meta.put(Metakey.NAME, html2oUTF8(art_name).trim());

                break;
            }

            return meta;
        } finally {
            if (reader != null)
                reader.close();
        }
    } catch (IOException e) {
        throw new ExtractorException("I/O exception during extraction: " + e.getMessage(), e, uri);
    }

}

From source file:pl.hycom.jira.plugins.gitlab.integration.search.LucenePathSearcher.java

@PostConstruct
public void init() {
    if (indexPathManager.getIndexRootPath() == null) {
        throw new NullPointerException("Cannot start plugin, index root path is NULL");
    }/*ww  w. j  a  va 2 s  . c o  m*/
    Path path = Paths.get(indexPathManager.getPluginIndexRootPath(), COMMIT_INDEXER_DIRECTORY);
    if (path == null) {
        throw new InvalidPathException(getIndexPathStr(), "Index path doesn't exists");
    }
    luceneIndexPath = path;
    if (!luceneIndexPath.toFile().exists()) {
        luceneIndexPath.toFile().mkdir();
    }
}

From source file:com.gistlabs.mechanize.cache.inMemory.InMemoryCacheEntry.java

public InMemoryCacheEntry(final HttpUriRequest request, final HttpResponse response) {
    if (request == null)
        throw new NullPointerException("request can't be null!");
    this.request = request;
    if (response == null)
        throw new NullPointerException("response can't be null!");
    this.response = response;

}

From source file:edu.cornell.mannlib.vitro.webapp.filestorage.TempFileHolder.java

/**
 * Get the {@link TempFileHolder} which is stored as an attribute on this
 * session, extract the {@link FileInfo} from it, and remove it from the
 * session./*from ww  w  . ja v a  2s.  c o m*/
 * 
 * If there is no such attribute, of if it is not a {@link TempFileHolder},
 * return null.
 */
public static FileInfo remove(HttpSession session, String attributeName) {
    if (session == null) {
        throw new NullPointerException("session may not be null.");
    }
    if (attributeName == null) {
        throw new NullPointerException("attributeName may not be null.");
    }
    Object attribute = session.getAttribute(attributeName);
    if (attribute instanceof TempFileHolder) {
        FileInfo fileInfo = ((TempFileHolder) attribute).extractFileInfo();
        session.removeAttribute(attributeName);
        log.debug("remove this file: " + fileInfo);
        return fileInfo;
    } else if (attribute == null) {
        return null;
    } else {
        session.removeAttribute(attributeName);
        return null;
    }
}

From source file:org.usrz.libs.riak.AbstractJsonClient.java

protected AbstractJsonClient(ObjectMapper mapper) {
    if (mapper == null)
        throw new NullPointerException("Null object mapper");
    this.mapper = mapper;
}

From source file:cz.muni.pa165.carparkapp.serviceImpl.BranchServiceImpl.java

@Override
public boolean deleteBranch(BranchDTO branchdto) {
    if (branchdto == null)
        throw new NullPointerException("Argument cannot be null");

    Branch branch = mapper.map(branchdto, Branch.class);

    boolean result = branchDAO.deleteBranch(branch);

    return result;
}

From source file:eagle.log.entity.meta.EntitySerDeserializer.java

@SuppressWarnings("unchecked")
public <T> T readValue(Map<String, byte[]> qualifierValues, EntityDefinition ed) throws Exception {
    Class<? extends TaggedLogAPIEntity> clazz = ed.getEntityClass();
    if (clazz == null) {
        throw new NullPointerException("Entity class of service " + ed.getService() + " is null");
    }/*from   www.ja  v  a 2s .  c o m*/
    TaggedLogAPIEntity obj = clazz.newInstance();
    Map<String, Qualifier> map = ed.getQualifierNameMap();
    for (Map.Entry<String, byte[]> entry : qualifierValues.entrySet()) {
        Qualifier q = map.get(entry.getKey());
        if (q == null) {
            // if it's not pre-defined qualifier, it must be tag unless it's a bug
            if (obj.getTags() == null) {
                obj.setTags(new HashMap<String, String>());
            }
            obj.getTags().put(entry.getKey(), new StringSerDeser().deserialize(entry.getValue()));
            continue;
        }

        // TODO performance loss compared with new operator
        // parse different types of qualifiers
        String fieldName = q.getDisplayName();
        PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(obj, fieldName);
        if (entry.getValue() != null) {
            Object args = q.getSerDeser().deserialize(entry.getValue());
            pd.getWriteMethod().invoke(obj, args);
            //            if (logger.isDebugEnabled()) {
            //               logger.debug(entry.getKey() + ":" + args + " is deserialized");
            //            }
        }
    }
    return (T) obj;
}