java.lang.NullPointerException Java Examples
The following examples show how to use
java.lang.NullPointerException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppletClassLoader.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #2
Source File: AppletClassLoader.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #3
Source File: AppletClassLoader.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #4
Source File: SmsCipher.java From Silence with GNU General Public License v3.0 | 6 votes |
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message) throws LegacyMessageException, InvalidMessageException, DuplicateMessageException, NoSessionException, UntrustedIdentityException { try { byte[] decoded = transportDetails.getDecodedMessage(message.getMessageBody().getBytes()); SignalMessage signalMessage = new SignalMessage(decoded); SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1)); byte[] padded = sessionCipher.decrypt(signalMessage); byte[] plaintext = transportDetails.getStrippedPaddingMessageBody(padded); if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) { signalProtocolStore.deleteSession(new SignalProtocolAddress(message.getSender(), 1)); } return message.withMessageBody(new String(plaintext)); } catch (IOException | IllegalArgumentException | NullPointerException e) { throw new InvalidMessageException(e); } }
Example #5
Source File: AppletClassLoader.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #6
Source File: AppletClassLoader.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #7
Source File: AppletClassLoader.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #8
Source File: AppletClassLoader.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #9
Source File: AppletClassLoader.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #10
Source File: constructor.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Runs the test using the specified harness. * * @param harness the test harness (<code>null</code> not permitted). */ public void test(TestHarness harness) { NullPointerException object1 = new NullPointerException(); harness.check(object1 != null); harness.check(object1.toString(), "java.lang.NullPointerException"); NullPointerException object2 = new NullPointerException("nothing happens"); harness.check(object2 != null); harness.check(object2.toString(), "java.lang.NullPointerException: nothing happens"); NullPointerException object3 = new NullPointerException(null); harness.check(object3 != null); harness.check(object3.toString(), "java.lang.NullPointerException"); }
Example #11
Source File: AppletClassLoader.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or {@code null} * if the resource could not be found * @since 1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #12
Source File: AppletClassLoader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #13
Source File: AppletClassLoader.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #14
Source File: AppletClassLoader.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #15
Source File: AppletClassLoader.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns an input stream for reading the specified resource from the * the loaded jar files. * * The search order is described in the documentation for {@link * #getResource(String)}.<p> * * @param name the resource name * @return an input stream for reading the resource, or <code>null</code> * if the resource could not be found * @since JDK1.1 */ public InputStream getResourceAsStreamFromJar(String name) { if (name == null) { throw new NullPointerException("name"); } try { InputStream is = null; synchronized(syncResourceAsStreamFromJar) { resourceAsStreamFromJarInCall = true; // Call super class is = super.getResourceAsStream(name); resourceAsStreamFromJarInCall = false; } return is; } catch (Exception e) { return null; } }
Example #16
Source File: UndertowServletMessages_$bundle.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public final NullPointerException paramCannotBeNullNPE(final String name) { final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), paramCannotBeNullNPE$str(), name)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; }
Example #17
Source File: WorkflowParser.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
public void parseDataLinks(Set<Step> cwlSteps) { for(Step step: cwlSteps) { for(InputPort stepInput: step.getInputs()) { String[] sourcePath = stepInput.getSource().split("/"); String source = sourcePath[sourcePath.length-1]; source = source.replace("#", ""); DataLink dataLink = new DataLink(); SenderPort sender = workflowInputs.get(source); if(sender == null) { sender = processorOutputs.get(source); } if(sender == null) { throw new NullPointerException("Cannot find sender port with name: " + source); } String receiverId = stepInput.getName(); ReceiverPort receiver = workflowOutputs.get(receiverId); if(receiver == null) { receiver = processorInputs.get(receiverId); } if(receiver == null) { throw new NullPointerException("Cannot find receiver port with name: " + receiverId); } dataLink.setSendsTo(receiver); dataLink.setReceivesFrom(sender); dataLinks.add(dataLink); } } }
Example #18
Source File: IvParameterSpecTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * IvParameterSpec(byte[] iv) constructor testing. Checks that * NullPointerException is thrown in the case of null input * array and that input array is copied during initialization. */ public void testIvParameterSpec1() { try { new IvParameterSpec(null); fail("Should raise an NullPointerException " + "in the case of null byte array."); } catch(NullPointerException e) { } byte[] iv = new byte[] {1, 2, 3, 4, 5}; IvParameterSpec ivps = new IvParameterSpec(iv); iv[0] ++; assertFalse("The change of input array's content should not cause " + "the change of internal array", iv[0] == ivps.getIV()[0]); }
Example #19
Source File: UndertowServletMessages_$bundle.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public final NullPointerException listenerCannotBeNull() { final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), listenerCannotBeNull$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; }
Example #20
Source File: UndertowServletMessages_$bundle.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public final NullPointerException nullName() { final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), nullName$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; }
Example #21
Source File: TryCatch.java From pluotsorbet with GNU General Public License v2.0 | 5 votes |
/** * Runs the test using the specified harness. * * @param harness the test harness (<code>null</code> not permitted). */ public void test(TestHarness harness) { // flag that is set when exception is caught boolean caught = false; try { throw new NullPointerException("NullPointerException"); } catch (NullPointerException e) { // correct exception was caught caught = true; } harness.check(caught); }
Example #22
Source File: ParsingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkNull(int start, int end, int radix) { int n = 0; try { n = Integer.parseInt(null, start, end, radix); System.err.println("parseInt(null, " + start + ", " + end + ", " + radix + ") incorrectly returned " + n); throw new RuntimeException(); } catch (NullPointerException npe) { ; // Expected } }
Example #23
Source File: UndertowServletMessages_$bundle.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public final NullPointerException headerNameWasNull() { final NullPointerException result = new NullPointerException(String.format(getLoggingLocale(), headerNameWasNull$str())); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; }
Example #24
Source File: FastLongBuffer.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Append single long to the end of array buffer. * @param long_array long[] */ public void append(long[] long_array) { if (long_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; long[] lastBuffer; if (bufferArrayList.size == 0) { lastBuffer = new long[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size - 1); lastBuffer = (long[]) bufferArrayList.oa[lastBufferIndex]; } if ((this.size + long_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(long_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.oa[lastBufferIndex+z], 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(long_array,offset,(long[]) bufferArrayList.oa[lastBufferIndex+z], 0, l & r); } size += long_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((long_array.length + size) / pageSize)) // + (((long_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((long_array.length + size) >> exp) + (((long_array.length + size)&r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size); for (int i = 0; i < n; i++) { long[] newBuffer = new long[pageSize]; if (i < n - 1) { // full copy System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, long_array.length+ size - pageSize*i - capacity); } bufferArrayList.add(newBuffer); } // update length size += long_array.length; // update capacity capacity += n * pageSize; // update } }
Example #25
Source File: FastIntBuffer.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Append an int array to the end of this buffer instance * @param int_array int[] */ public void append(int[] int_array) { if (int_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; int[] lastBuffer; if (bufferArrayList.size() == 0) { lastBuffer = new int[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size() - 1); lastBuffer = (int[]) bufferArrayList.get(lastBufferIndex); } if ((this.size + int_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length //System.arraycopy(input, 0, lastBuffer, size % pageSize, input.length); if (this.size + int_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(int_array, 0, lastBuffer, size & r, int_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(int_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = int_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(int_array,offset, (int[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(int_array, offset, (int[]) bufferArrayList.get(lastBufferIndex+z), 0, l & r); } size += int_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((int_array.length + size) / pageSize)) // + (((int_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((int_array.length + size) >> exp) + (((int_array.length + size) &r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(int_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(int_array, 0, lastBuffer, size& r, capacity - size); for (int i = 0; i < n; i++) { int[] newBuffer = new int[pageSize]; if (i < n - 1) { // full copy System.arraycopy( int_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( int_array, pageSize * i + capacity - size, newBuffer, 0, int_array.length + this.size - capacity - pageSize*i); } bufferArrayList.add(newBuffer); } // update length size += int_array.length; // update capacity capacity += n * pageSize; // update } }
Example #26
Source File: FastLongBuffer.java From vtd-xml with GNU General Public License v2.0 | 4 votes |
/** * Append single long to the end of array buffer. * @param long_array long[] */ public void append(long[] long_array) { if (long_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; long[] lastBuffer; if (bufferArrayList.size == 0) { lastBuffer = new long[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size - 1); lastBuffer = (long[]) bufferArrayList.oa[lastBufferIndex]; } if ((this.size + long_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(long_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.oa[lastBufferIndex+z], 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(long_array,offset,(long[]) bufferArrayList.oa[lastBufferIndex+z], 0, l & r); } size += long_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((long_array.length + size) / pageSize)) // + (((long_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((long_array.length + size) >> exp) + (((long_array.length + size)&r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size); for (int i = 0; i < n; i++) { long[] newBuffer = new long[pageSize]; if (i < n - 1) { // full copy System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, long_array.length+ size - pageSize*i - capacity); } bufferArrayList.add(newBuffer); } // update length size += long_array.length; // update capacity capacity += n * pageSize; // update } }
Example #27
Source File: FastLongBuffer.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Append single long to the end of array buffer. * @param long_array long[] */ public void append(long[] long_array) { if (long_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; long[] lastBuffer; if (bufferArrayList.size() == 0) { lastBuffer = new long[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size() - 1); lastBuffer = (long[]) bufferArrayList.get(lastBufferIndex); } if ((this.size + long_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(long_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, l & r); } size += long_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((long_array.length + size) / pageSize)) // + (((long_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((long_array.length + size) >> exp) + (((long_array.length + size)&r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size); for (int i = 0; i < n; i++) { long[] newBuffer = new long[pageSize]; if (i < n - 1) { // full copy System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, long_array.length+ size - pageSize*i - capacity); } bufferArrayList.add(newBuffer); } // update length size += long_array.length; // update capacity capacity += n * pageSize; // update } }
Example #28
Source File: FastLongBuffer.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Append single long to the end of array buffer. * @param long_array long[] */ public void append(long[] long_array) { if (long_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; long[] lastBuffer; if (bufferArrayList.size == 0) { lastBuffer = new long[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size - 1); lastBuffer = (long[]) bufferArrayList.oa[lastBufferIndex]; } if ((this.size + long_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(long_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.oa[lastBufferIndex+z], 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(long_array,offset,(long[]) bufferArrayList.oa[lastBufferIndex+z], 0, l & r); } size += long_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((long_array.length + size) / pageSize)) // + (((long_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((long_array.length + size) >> exp) + (((long_array.length + size)&r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size); for (int i = 0; i < n; i++) { long[] newBuffer = new long[pageSize]; if (i < n - 1) { // full copy System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, long_array.length+ size - pageSize*i - capacity); } bufferArrayList.add(newBuffer); } // update length size += long_array.length; // update capacity capacity += n * pageSize; // update } }
Example #29
Source File: FastLongBuffer.java From vtd-xml with GNU General Public License v2.0 | 4 votes |
/** * Append single long to the end of array buffer. * @param long_array long[] */ public void append(long[] long_array) { if (long_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; long[] lastBuffer; if (bufferArrayList.size() == 0) { lastBuffer = new long[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size() - 1); lastBuffer = (long[]) bufferArrayList.get(lastBufferIndex); } if ((this.size + long_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(long_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, l & r); } size += long_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((long_array.length + size) / pageSize)) // + (((long_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((long_array.length + size) >> exp) + (((long_array.length + size)&r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size); for (int i = 0; i < n; i++) { long[] newBuffer = new long[pageSize]; if (i < n - 1) { // full copy System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, long_array.length+ size - pageSize*i - capacity); } bufferArrayList.add(newBuffer); } // update length size += long_array.length; // update capacity capacity += n * pageSize; // update } }
Example #30
Source File: FastLongBuffer.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Append single long to the end of array buffer. * @param long_array long[] */ public void append(long[] long_array) { if (long_array == null) { throw new NullPointerException(); } // no additional buffer space needed int lastBufferIndex; long[] lastBuffer; if (bufferArrayList.size() == 0) { lastBuffer = new long[pageSize]; bufferArrayList.add(lastBuffer); lastBufferIndex = 0; capacity = pageSize; } else { lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1), bufferArrayList.size() - 1); lastBuffer = (long[]) bufferArrayList.get(lastBufferIndex); } if ((this.size + long_array.length) < this.capacity) { //get the last buffer from the bufferListArray //obtain the starting offset in that buffer to which the data is to be copied //update length if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r); // copy the first part System.arraycopy(long_array, 0, lastBuffer, size & r, offset); // copy the middle part int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize); offset += pageSize; } // copy the last part System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, l & r); } size += long_array.length; return; } else // new buffers needed { // compute the number of additional buffers needed // int n = // ((int) ((long_array.length + size) / pageSize)) // + (((long_array.length + size) % pageSize) > 0 ? 1 : 0) // - (int) (capacity / pageSize); int n = ((long_array.length + size) >> exp) + (((long_array.length + size)&r) > 0 ? 1 : 0) - (capacity >> exp); // create these buffers // add to bufferArrayList //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size); System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size); for (int i = 0; i < n; i++) { long[] newBuffer = new long[pageSize]; if (i < n - 1) { // full copy System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else { // last page System.arraycopy( long_array, pageSize * i + capacity - size, newBuffer, 0, long_array.length+ size - pageSize*i - capacity); } bufferArrayList.add(newBuffer); } // update length size += long_array.length; // update capacity capacity += n * pageSize; // update } }