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:Main.java

public static <T> T checkNotNull(T reference, String message) {
    if (reference == null) {
        throw new NullPointerException(message);
    }//from  w  w w  . j a v a  2s.  c  o m
    return reference;
}

From source file:Main.java

public static Bitmap drawImageBorder(Bitmap srcBitmap, Bitmap borderBitmap) {
    if (srcBitmap == null)
        throw new NullPointerException("srcBitmap should not null");
    if (borderBitmap == null)
        return srcBitmap;
    Bitmap temp = srcBitmap.copy(Config.ARGB_8888, true);
    /*Bitmap border = borderBitmap;
    if (srcBitmap.getWidth() != borderBitmap.getWidth() || 
      srcBitmap.getHeight() != borderBitmap.getHeight()) {
       border = zoomBitmap(borderBitmap, srcBitmap.getWidth(), srcBitmap.getHeight());
    }*//* ww  w .j  av a2 s .  c o m*/
    Canvas canvas = new Canvas(temp);
    Matrix m = new Matrix();
    m.postScale((float) temp.getWidth() / borderBitmap.getWidth(),
            (float) temp.getHeight() / borderBitmap.getHeight());
    //canvas.drawBitmap(border, 0, 0, null);
    canvas.drawBitmap(borderBitmap, m, null);
    return temp;
}

From source file:Main.java

public static CharSequence getText() {
    if (clipboardManager == null)
        throw new NullPointerException(initializeErrorString);

    return clipboardManager.getText();
}

From source file:Main.java

/***********************************************************************/
public static Node traverseToTag(String tag, Node node) {
    Node n = traverseToInnerTag(tag, node);
    if (n == null) {
        throw new NullPointerException(String.format("The Tag '%s' could not be found from '%s'", tag, node));
    }/*w  w w. j a  v a2  s.  c o m*/
    return n;
}

From source file:MainClass.java

public static String capitalize(String s) throws NullPointerException {
    if (s == null) {
        throw new NullPointerException("Your passed a null argument");
    }/*  w w w . j  a v  a 2  s  .  c o m*/
    Character firstChar = s.charAt(0);
    String theRest = s.substring(1);
    return firstChar.toString().toUpperCase() + theRest;
}

From source file:Main.java

public static boolean isValidEmail(EditText paramEditText) {
    if (paramEditText == null) {
        throw new NullPointerException("EditText can't null");
    }/* w  w  w .ja  va 2s. com*/
    return isValidEmail(paramEditText.getText().toString());
}

From source file:Main.java

public static void setText(CharSequence text) {
    if (clipboardManager == null)
        throw new NullPointerException(initializeErrorString);

    clipboardManager.setText(text);/*from   w w  w . j  a  v  a  2  s . c  om*/
}

From source file:Main.java

public static Bitmap decodeYUV420SP(byte[] rgbBuf, byte[] yuv420sp, int width, int height) {
    final int frameSize = width * height;
    if (rgbBuf == null)
        throw new NullPointerException("buffer 'rgbBuf' is null");
    if (rgbBuf.length < frameSize * 3)
        throw new IllegalArgumentException(
                "buffer 'rgbBuf' size " + rgbBuf.length + " < minimum " + frameSize * 3);

    if (yuv420sp == null)
        throw new NullPointerException("buffer 'yuv420sp' is null");

    if (yuv420sp.length < frameSize * 3 / 2)
        throw new IllegalArgumentException(
                "buffer 'yuv420sp' size " + yuv420sp.length + " < minimum " + frameSize * 3 / 2);

    int i = 0, y = 0;
    int uvp = 0, u = 0, v = 0;
    int y1192 = 0, r = 0, g = 0, b = 0;

    for (int j = 0, yp = 0; j < height; j++) {
        uvp = frameSize + (j >> 1) * width;
        u = 0;/*from  w ww  . ja  va 2  s . co  m*/
        v = 0;
        for (i = 0; i < width; i++, yp++) {
            y = (0xff & ((int) yuv420sp[yp])) - 16;
            if (y < 0)
                y = 0;
            if ((i & 1) == 0) {
                v = (0xff & yuv420sp[uvp++]) - 128;
                u = (0xff & yuv420sp[uvp++]) - 128;
            }

            y1192 = 1192 * y;
            r = (y1192 + 1634 * v);
            g = (y1192 - 833 * v - 400 * u);
            b = (y1192 + 2066 * u);

            if (r < 0)
                r = 0;
            else if (r > 262143)
                r = 262143;
            if (g < 0)
                g = 0;
            else if (g > 262143)
                g = 262143;
            if (b < 0)
                b = 0;
            else if (b > 262143)
                b = 262143;

            rgbBuf[yp * 3] = (byte) (r >> 10);
            rgbBuf[yp * 3 + 1] = (byte) (g >> 10);
            rgbBuf[yp * 3 + 2] = (byte) (b >> 10);
        }
    }
    return BitmapFactory.decodeByteArray(rgbBuf, 0, rgbBuf.length);
}

From source file:Main.java

public static <K, V> Map<K, List<V>> copyNullSafeMultiHashMapReified(Class<V> valueType,
        Map<? extends K, List<?>> map) {
    if (valueType == null)
        throw new NullPointerException("valueType");
    if (map == null)
        throw new NullPointerException("map");

    @SuppressWarnings("unchecked")
    Map<K, List<V>> result = (Map<K, List<V>>) (Map<?, ?>) copyNullSafeMutableHashMap(map);
    for (Map.Entry<K, List<V>> entry : result.entrySet()) {
        List<V> value = entry.getValue();
        ArrayList<V> valueCopy = new ArrayList<V>(value);
        for (V element : valueCopy) {
            valueType.cast(element);/*from w w w . j  a  va  2  s. c o  m*/
        }

        entry.setValue(Collections.unmodifiableList(valueCopy));
    }
    return result;
}

From source file:Main.java

public static <T> List<T> getAllOfExclude(Container container, Class<T> clazz,
        Collection<? extends Component> exclude) {
    if (container == null) {
        throw new NullPointerException("container == null");
    }//from   ww  w. j ava 2 s.co  m
    if (clazz == null) {
        throw new NullPointerException("clazz == null");
    }
    if (exclude == null) {
        throw new NullPointerException("exclude == null");
    }
    List<T> components = new ArrayList<>();
    addAllOfExclude(container, clazz, components, exclude);
    return components;
}