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.trendrr.oss.networking.strest.StrestUtil.java

static void validateHeaderName(String name) {
    if (name == null) {
        throw new NullPointerException("name");
    }//  w  w  w . ja  v  a 2 s . co  m
    for (int i = 0; i < name.length(); i++) {
        char c = name.charAt(i);
        if (c > 127) {
            throw new IllegalArgumentException("name contains non-ascii character: " + name);
        }

        // Check prohibited characters.
        switch (c) {
        case '\t':
        case '\n':
        case 0x0b:
        case '\f':
        case '\r':
        case ' ':
        case ',':
        case ':':
        case ';':
        case '=':
            throw new IllegalArgumentException("name contains one of the following prohibited characters: "
                    + "=,;: \\t\\r\\n\\v\\f: " + name);
        }
    }
}

From source file:com.upnext.beaconos.sdk.backend.JacksonConverterFactory.java

public JacksonConverterFactory(ObjectMapper objectMapper) {
    if (objectMapper == null) {
        throw new NullPointerException("objectMapper is null.");
    }//from w w w .j ava 2s.  com
    this.objectMapper = objectMapper;
}

From source file:com.bstek.dorado.common.event.ClientEventRegistry.java

/**
 * //from www .j a v a 2  s . co  m
 * 
 * @param clientEventRegisterInfo
 *            ?
 */
public static void registerClientEvent(ClientEventRegisterInfo clientEventRegisterInfo) {
    Class<?> type = clientEventRegisterInfo.getType();
    if (type == null) {
        throw new NullPointerException("[type] should not be null.");
    }

    Map<String, ClientEventRegisterInfo> eventMap = typeMap.get(type);
    if (eventMap == null) {
        eventMap = new HashMap<String, ClientEventRegisterInfo>();
        typeMap.put(type, eventMap);
    }

    String eventName = clientEventRegisterInfo.getName();
    if (StringUtils.isEmpty(eventName)) {
        throw new IllegalArgumentException("[eventName] should not be empty.");
    }

    if (eventMap.containsKey(eventName)) {
        throw new IllegalArgumentException(
                "Client event [" + type.getName() + "," + eventName + "] is already registered.");
    }

    eventMap.put(eventName, clientEventRegisterInfo);
}

From source file:org.bigmouth.nvwa.network.http.utils.HttpUtils.java

public static HttpResponse get(HttpRequest request) throws UnexpectStatusCodeException, HttpException {
    if (null == request) {
        throw new NullPointerException("request");
    }//w  ww . j  a va2 s. c  o m
    request.setMethod(Method.GET);
    return access(request);
}

From source file:jef.tools.Assert.java

/**
 *  ?null/*from   ww w  .  j a v  a 2s .c  o m*/
 * @param obj
 * @param msg
 */
public static void notNull(Object obj, String msg) {
    if (obj == null)
        throw new NullPointerException(msg);
}

From source file:com.toolazydogs.security4j.Principal.java

protected Principal(String realm) {
    if (realm == null)
        throw new NullPointerException("Realm cannot be null");
    this.realm = realm;
}

From source file:com.github.nmorel.gwtjackson.shared.model.AutoValue_Animal.java

private AutoValue_Animal(String name, int numberOfLegs) {
    if (name == null) {
        throw new NullPointerException("Null name");
    }//w ww.  j av a2s  .c o m
    this.name = name;
    this.numberOfLegs = numberOfLegs;
}

From source file:hd3gtv.mydmam.useraction.fileoperation.CopyMove.java

public static void checkExistsCanRead(File element) throws IOException, NullPointerException {
    if (element == null) {
        throw new NullPointerException("element is null");
    }/*from   w w  w .ja  v a2s .  co m*/
    if (element.exists() == false) {
        throw new FileNotFoundException("\"" + element.getPath() + "\" in filesytem");
    }
    if (element.canRead() == false) {
        throw new IOException("Can't read element \"" + element.getPath() + "\"");
    }
}

From source file:Main.java

public static void appendChild(Document doc, Node parentNode, String childName, String childContents) {
    if (childContents == null)
        throw (new NullPointerException("ChildNode is null."));

    Element child = doc.createElement(childName);
    child.setTextContent(childContents);
    parentNode.appendChild(child);/*w ww.  jav a  2  s . c  om*/
}

From source file:hd3gtv.mydmam.auth.AuthenticationBackend.java

public static void refreshConfiguration() throws Exception {
    if (Configuration.global.isElementExists("auth") == false) {
        throw new NullPointerException("Can't found \"auth\" element in configuration");
    }//ww w  . jav  a  2  s. c  o  m
    if (Configuration.global.isElementKeyExists("auth", "backend") == false) {
        throw new NullPointerException("Can't found \"auth/backend\" element in configuration");
    }

    List<LinkedHashMap<String, ?>> elements = Configuration.global.getListMapValues("auth", "backend");

    if (elements == null) {
        throw new NullPointerException("No items for \"auth/backend\" element in configuration");
    }

    force_select_domain = Configuration.global.getValueBoolean("auth", "force_select_domain");

    authenticators = new ArrayList<Authenticator>(elements.size());
    authenticators_domains = new ArrayList<String>(elements.size());

    LinkedHashMap<String, ?> configuration_element;
    File auth_file;
    for (int pos = 0; pos < elements.size(); pos++) {
        configuration_element = elements.get(pos);
        String element_source = (String) configuration_element.get("source");
        if (element_source.equals("local")) {
            String path = (String) configuration_element.get("path");

            auth_file = new File(path);
            if (auth_file.exists() == false) {
                if (auth_file.isAbsolute() == false) {
                    if (auth_file.getParentFile().getName().equals("conf") & Configuration
                            .getGlobalConfigurationDirectory().getParentFile().getName().equals("conf")) {
                        /**
                         * SQLite file is located in Play conf directory, and Play /app.d/ is also located in conf directory.
                         * We consider that conf directory is the same.
                         */
                        auth_file = new File(Configuration.getGlobalConfigurationDirectory().getParent()
                                + File.separator + auth_file.getName());
                    }
                }
            }
            if (auth_file.exists() == false) {
                throw new FileNotFoundException(path);
            }

            String masterkey = (String) configuration_element.get("masterkey");
            authenticators.add(new AuthenticatorLocalsqlite(auth_file, masterkey));

            String label = (String) configuration_element.get("label");
            authenticators_domains.add(label);
        } else if (element_source.equals("ad")) {
            String domain = (String) configuration_element.get("domain");
            String server = (String) configuration_element.get("server");
            int port = (Integer) configuration_element.get("port");
            authenticators.add(new AuthenticatorActivedirectory(domain, server, port));

            authenticators_domains.add(domain);
        } else {
            Log2.log.error("Can't import \"auth/backend\" " + (pos + 1) + " configuration item", null,
                    new Log2Dump("item", configuration_element.toString()));
        }
    }

    if (authenticators.isEmpty()) {
        throw new NullPointerException("No authentication backend is correctly set");
    }
}