/** Constructs an instance with the specified capacity. * * @param capacity the initial capacity to use. * @throws NegativeArraySizeException if the specified {@code capacity} is negative. * @see #capacity() */ public StringBuilder (int capacity) { if (capacity < 0) { throw new NegativeArraySizeException(); } chars = new char[capacity]; }
return null; } catch (NegativeArraySizeException e) { VolleyLog.d("%s: %s", file.getAbsolutePath(), e.toString()); remove(key); return null;
@Test public void testReadBytesThrowsNegativeArraySizeException() throws Throwable { InputStream in = new ByteArrayInputStream("testString".getBytes()); ISOFieldPackager iFEB_LLLNUM = new IFEB_LLLNUM(); try { iFEB_LLLNUM.readBytes(in, -1); fail("Expected NegativeArraySizeException to be thrown"); } catch (NegativeArraySizeException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("(ByteArrayInputStream) in.available()", 10, in.available()); } }
@Test public void testUnpackThrowsNegativeArraySizeException() throws Throwable { byte[] bytes = new byte[0]; InputStream in = new ByteArrayInputStream(bytes); try { new Base1_BITMAP126(-1, "testISOFieldPackagerDescription").unpack(new IFB_AMOUNT().createComponent(100), in); fail("Expected NegativeArraySizeException to be thrown"); } catch (NegativeArraySizeException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("(ByteArrayInputStream) in.available()", 0, in.available()); } }
/** Constructs an instance with the specified capacity. * * @param capacity the initial capacity to use. * @throws NegativeArraySizeException if the specified {@code capacity} is negative. * @see #capacity() */ public StringBuilder (int capacity) { if (capacity < 0) { throw new NegativeArraySizeException(); } chars = new char[capacity]; }
@Test public void testUninterpretThrowsNegativeArraySizeException() throws Throwable { byte[] rawData = new byte[1]; try { new AsciiHexInterpreter().uninterpret(rawData, 100, -1); fail("Expected NegativeArraySizeException to be thrown"); } catch (NegativeArraySizeException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
public void setBufferSize(final int size) { if (size < 0) { throw new NegativeArraySizeException("size"); } synchronized (buffer) { bufferSize = (size < 1) ? 1 : size; buffer.notifyAll(); } }
@Test public void testUninterpretThrowsNegativeArraySizeException() throws Throwable { byte[] rawData = new byte[0]; try { new AsciiInterpreter().uninterpret(rawData, 100, -1); fail("Expected NegativeArraySizeException to be thrown"); } catch (NegativeArraySizeException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
/** * Sets the number of messages allowed in the event buffer * before the calling thread is blocked (if blocking is true) * or until messages are summarized and discarded. Changing * the size will not affect messages already in the buffer. * * @param size buffer size, must be positive. */ public void setBufferSize(final int size) { // // log4j 1.2 would throw exception if size was negative // and deadlock if size was zero. // if (size < 0) { throw new java.lang.NegativeArraySizeException("size"); } synchronized (buffer) { // // don't let size be zero. // bufferSize = (size < 1) ? 1 : size; buffer.notifyAll(); } }
@Test public void testReadHeaderThrowsNegativeArraySizeException() throws Throwable { BaseChannel nACChannel = new NACChannel(); try { nACChannel.readHeader(-1); fail("Expected NegativeArraySizeException to be thrown"); } catch (NegativeArraySizeException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("(NACChannel) nACChannel.serverIn", ((NACChannel) nACChannel).serverIn); } }
public IcedBitSet(byte[] v, int nbits, int offset) { if(nbits < 0) throw new NegativeArraySizeException("nbits < 0: " + nbits); if(offset < 0) throw new IndexOutOfBoundsException("offset < 0: " + offset); assert (nbits >> 3) <= v.length; _val = v; _nbits = nbits; _offset = offset; } public IcedBitSet(int nbits) { this(nbits, 0); }
@Test public void testUnpackThrowsNegativeArraySizeException() throws Throwable { byte[] b = new byte[3]; ISOFieldPackager[] fld = new ISOFieldPackager[3]; fld[0] = new IFA_LLBNUM(); CTCSubElementPackager cTCSubElementPackager = new CTCSubElementPackager(); cTCSubElementPackager.setFieldPackager(fld); try { cTCSubElementPackager.unpack(new ISOBinaryField(), b); fail("Expected NegativeArraySizeException to be thrown"); } catch (NegativeArraySizeException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
public IcedBitSet(int nbits, int offset) { if(nbits < 0) throw new NegativeArraySizeException("nbits < 0: " + nbits); if(offset < 0) throw new IndexOutOfBoundsException("offset < 0: " + offset); _nbits = nbits; _offset = offset; _val = new byte[((nbits-1) >> 3) + 1]; }
AbstractStringBuilder(int capacity) { if (capacity < 0) { throw new NegativeArraySizeException(Integer.toString(capacity)); } value = new char[capacity]; }
/** * Copies {@code newLength} elements from {@code original} into a new array. * If {@code newLength} is greater than {@code original.length}, the result is padded * with the value {@code false}. * * @param original the original array * @param newLength the length of the new array * @return the new array * @throws NegativeArraySizeException if {@code newLength < 0} * @throws NullPointerException if {@code original == null} * @since 1.6 */ public static boolean[] copyOf(boolean[] original, int newLength) { if (newLength < 0) { throw new NegativeArraySizeException(Integer.toString(newLength)); } return copyOfRange(original, 0, newLength); }
/** * Copies {@code newLength} elements from {@code original} into a new array. * If {@code newLength} is greater than {@code original.length}, the result is padded * with the value {@code 0L}. * * @param original the original array * @param newLength the length of the new array * @return the new array * @throws NegativeArraySizeException if {@code newLength < 0} * @throws NullPointerException if {@code original == null} * @since 1.6 */ public static long[] copyOf(long[] original, int newLength) { if (newLength < 0) { throw new NegativeArraySizeException(Integer.toString(newLength)); } return copyOfRange(original, 0, newLength); }
/** * Copies {@code newLength} elements from {@code original} into a new array. * If {@code newLength} is greater than {@code original.length}, the result is padded * with the value {@code '\\u0000'}. * * @param original the original array * @param newLength the length of the new array * @return the new array * @throws NegativeArraySizeException if {@code newLength < 0} * @throws NullPointerException if {@code original == null} * @since 1.6 */ public static char[] copyOf(char[] original, int newLength) { if (newLength < 0) { throw new NegativeArraySizeException(Integer.toString(newLength)); } return copyOfRange(original, 0, newLength); }
/** * Copies {@code newLength} elements from {@code original} into a new array. * If {@code newLength} is greater than {@code original.length}, the result is padded * with the value {@code (short) 0}. * * @param original the original array * @param newLength the length of the new array * @return the new array * @throws NegativeArraySizeException if {@code newLength < 0} * @throws NullPointerException if {@code original == null} * @since 1.6 */ public static short[] copyOf(short[] original, int newLength) { if (newLength < 0) { throw new NegativeArraySizeException(Integer.toString(newLength)); } return copyOfRange(original, 0, newLength); }
/** * Copies {@code newLength} elements from {@code original} into a new array. * If {@code newLength} is greater than {@code original.length}, the result is padded * with the value {@code (byte) 0}. * * @param original the original array * @param newLength the length of the new array * @return the new array * @throws NegativeArraySizeException if {@code newLength < 0} * @throws NullPointerException if {@code original == null} * @since 1.6 */ public static byte[] copyOf(byte[] original, int newLength) { if (newLength < 0) { throw new NegativeArraySizeException(Integer.toString(newLength)); } return copyOfRange(original, 0, newLength); }
/** * Copies {@code newLength} elements from {@code original} into a new array. * If {@code newLength} is greater than {@code original.length}, the result is padded * with the value {@code 0.0d}. * * @param original the original array * @param newLength the length of the new array * @return the new array * @throws NegativeArraySizeException if {@code newLength < 0} * @throws NullPointerException if {@code original == null} * @since 1.6 */ public static double[] copyOf(double[] original, int newLength) { if (newLength < 0) { throw new NegativeArraySizeException(Integer.toString(newLength)); } return copyOfRange(original, 0, newLength); }