List of usage examples for java.lang IllegalArgumentException IllegalArgumentException
public IllegalArgumentException(Throwable cause)
From source file:Main.java
public static void setWidth(View view, int width) { if (view == null || view.getLayoutParams() == null) { throw new IllegalArgumentException("View LayoutParams is null"); }// w ww. j a v a2s . c om ViewGroup.LayoutParams params = view.getLayoutParams(); params.width = width; view.setLayoutParams(params); }
From source file:Main.java
/** * Sets the text for a node/*from w w w . j a v a2 s . c o m*/ */ public synchronized static void setText(Node n, String text) { if (n == null) throw new IllegalArgumentException("Node argument cannot be null"); if (text == null) throw new IllegalArgumentException("Node text argument cannot be null"); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i).getNodeType() == Node.TEXT_NODE) { nl.item(i).setNodeValue(text); return; } } Node textNode = n.getOwnerDocument().createTextNode(text); n.appendChild(textNode); }
From source file:Main.java
public static void setHeight(View view, int height) { if (view == null || view.getLayoutParams() == null) { throw new IllegalArgumentException("View LayoutParams is null"); }/*from ww w. ja va2s .c om*/ ViewGroup.LayoutParams params = view.getLayoutParams(); params.height = height; view.setLayoutParams(params); }
From source file:Main.java
public static void mergePropertiesIntoMap(Properties props, Map map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } else {/*from w w w. j av a2 s. c om*/ String key; Object value; if (props != null) { for (Enumeration en = props.propertyNames(); en.hasMoreElements(); map.put(key, value)) { key = (String) en.nextElement(); value = props.getProperty(key); if (value == null) { value = props.get(key); } } } } }
From source file:Main.java
public static <T> boolean isListIdentical(List<T> listA, List<T> listB) { if (listA == null || listB == null) { throw new IllegalArgumentException("input list should not be null"); }/*w ww . java2s . c o m*/ Object[] arrayA = listA.toArray(); Object[] arrayB = listB.toArray(); boolean ret = Arrays.equals(arrayA, arrayB); return ret; }
From source file:Main.java
public static int[] generateCompactNaf(BigInteger k) { if ((k.bitLength() >>> 16) != 0) { throw new IllegalArgumentException("'k' must have bitlength < 2^16"); }/*from w w w . j a v a 2s. co m*/ BigInteger _3k = k.shiftLeft(1).add(k); int digits = _3k.bitLength() - 1; int[] naf = new int[(digits + 1) >> 1]; int length = 0, zeroes = 0; for (int i = 1; i <= digits; ++i) { boolean _3kBit = _3k.testBit(i); boolean kBit = k.testBit(i); if (_3kBit == kBit) { ++zeroes; } else { int digit = kBit ? -1 : 1; naf[length++] = (digit << 16) | zeroes; zeroes = 0; } } if (naf.length > length) { naf = trim(naf, length); } return naf; }
From source file:Main.java
public static Bitmap getThumbnailsBitmap(Bitmap bitmap, int height, int width) { if (bitmap == null) { throw new IllegalArgumentException("Bitmap is null, please check you param"); }/* www .j av a2s.c o m*/ return ThumbnailUtils.extractThumbnail(bitmap, width, height); }
From source file:Main.java
private static void checkBaseDirValue(String baseDir) { if (baseDir.contains("/../")) { throw new IllegalArgumentException(ANDROID_BASE_DIR + " can't have \"..\" symbols"); }// ww w. ja va 2 s .co m if (baseDir.startsWith("../")) { throw new IllegalArgumentException(ANDROID_BASE_DIR + " can't starts with ..\" symbol"); } if (baseDir.contains("/./")) { throw new IllegalArgumentException(ANDROID_BASE_DIR + " can't have \".\" symbols"); } if (baseDir.contains("/./")) { throw new IllegalArgumentException(ANDROID_BASE_DIR + " can't have \".\" symbols"); } }
From source file:Main.java
public static void invokeAndWait(final Runnable doRun) { if (doRun == null) { throw new IllegalArgumentException("The runnable cannot be null"); }//from w ww.jav a 2 s . c o m if (EventQueue.isDispatchThread()) { doRun.run(); } else { try { EventQueue.invokeAndWait(doRun); } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } }
From source file:ArrayEnumerationFactory.java
static public Enumeration makeEnumeration(final Object obj) { Class type = obj.getClass();/*from ww w.ja va2 s .c om*/ if (!type.isArray()) { throw new IllegalArgumentException(obj.getClass().toString()); } else { return (new Enumeration() { int size = Array.getLength(obj); int cursor; public boolean hasMoreElements() { return (cursor < size); } public Object nextElement() { return Array.get(obj, cursor++); } }); } }