Methods Summary |
---|
public void | close()Method close
if (bs_stream != null) {
bs_stream.close();
bs_stream = null;
}
|
protected java.io.InputStream | createBackingStoreInputStream()Method createBackingStoreInputStream
try {
return new BufferedInputStream(
new FileInputStream(bs_handle.getCanonicalPath()));
} catch (IOException e) {
throw new FileNotFoundException(bs_handle.getAbsolutePath());
}
|
protected void | discardBackingStore()Method discardBackingStore
if (bs_handle != null) {
bs_handle.delete();
bs_handle = null;
}
|
public synchronized void | discardBuffer()Method discardBuffer
cache = null;
if (bs_stream != null) {
try {
bs_stream.close();
} catch (IOException e) {
// just ignore it...
}
bs_stream = null;
}
discardBackingStore();
|
protected void | finalize()Method finalize
discardBuffer();
|
public void | flush()Method flush
if (bs_stream != null) {
bs_stream.flush();
}
|
public java.lang.String | getBackingStoreFileName()Method getBackingStoreFileName
String fileName = null;
if (bs_handle != null) {
fileName = bs_handle.getCanonicalPath();
}
return fileName;
|
public static double | getDEFAULT_CACHE_INCREMENT()
return DEFAULT_CACHE_INCREMENT;
|
public static int | getDEFAULT_RESIDENT_SIZE()
return DEFAULT_RESIDENT_SIZE;
|
protected void | increaseCapacity(int count)Method increaseCapacity
if (cache == null) {
return;
}
if (count + cache.size() <= max_size) {
return;
} else if (enableBackingStore) {
switchToBackingStore();
} else {
throw new IOException("ByteArray can not increase capacity by " +
count +
" due to max size limit of " + max_size);
}
|
public static boolean | isDEFAULT_ENABLE_BACKING_STORE()
return DEFAULT_ENABLE_BACKING_STORE;
|
public boolean | isEnableBackingStore()
return enableBackingStore;
|
protected java.io.InputStream | makeInputStream()Method makeInputStream
close();
if (cache != null) {
return new ByteArrayInputStream(cache.toByteArray());
} else if (bs_handle != null) {
return createBackingStoreInputStream();
} else {
return null;
}
|
public static void | setDEFAULT_CACHE_INCREMENT(double DEFAULT_CACHE_INCREMENT)
ByteArray.DEFAULT_CACHE_INCREMENT = DEFAULT_CACHE_INCREMENT;
|
public static void | setDEFAULT_ENABLE_BACKING_STORE(boolean DEFAULT_ENABLE_BACKING_STORE)
ByteArray.DEFAULT_ENABLE_BACKING_STORE = DEFAULT_ENABLE_BACKING_STORE;
|
public static void | setDEFAULT_RESIDENT_SIZE(int DEFAULT_RESIDENT_SIZE)
ByteArray.DEFAULT_RESIDENT_SIZE = DEFAULT_RESIDENT_SIZE;
|
public void | setEnableBackingStore(boolean enableBackingStore)
this.enableBackingStore = enableBackingStore;
|
public long | size()Method size
return count;
|
protected void | switchToBackingStore()Method switchToBackingStore
bs_handle = File.createTempFile("Axis", ".msg");
bs_handle.createNewFile();
bs_handle.deleteOnExit();
bs_stream = new FileOutputStream(bs_handle);
bs_stream.write(cache.toByteArray());
cache = null;
|
public byte[] | toByteArray()Method toByteArray
InputStream inp = this.makeInputStream();
byte[] buf = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
buf = new byte[WORKING_BUFFER_SIZE];
int len;
while ((len = inp.read(buf, 0, WORKING_BUFFER_SIZE)) != -1) {
baos.write(buf, 0, len);
}
inp.close();
discardBackingStore();
return baos.toByteArray();
|
public void | write(byte[] bytes)Method write
write(bytes, 0, bytes.length);
|
public void | write(byte[] bytes, int start, int length)Method write
count += length;
if (cache != null) {
increaseCapacity(length);
}
if (cache != null) {
cache.write(bytes, start, length);
} else if (bs_stream != null) {
bs_stream.write(bytes, start, length);
} else {
throw new IOException("ByteArray does not have a backing store!");
}
|
public void | write(int b)Method write
count += 1;
if (cache != null) {
increaseCapacity(1);
}
if (cache != null) {
cache.write(b);
} else if (bs_stream != null) {
bs_stream.write(b);
} else {
throw new IOException("ByteArray does not have a backing store!");
}
|
public void | writeTo(java.io.OutputStream os)Method writeTo
InputStream inp = this.makeInputStream();
byte[] buf = null;
buf = new byte[WORKING_BUFFER_SIZE];
int len;
while ((len = inp.read(buf, 0, WORKING_BUFFER_SIZE)) != -1) {
os.write(buf, 0, len);
}
inp.close();
discardBackingStore();
|