mirror of
https://github.com/revanced/smali.git
synced 2025-05-04 08:34:25 +02:00
Removed unneeded support for making a stream
git-svn-id: https://smali.googlecode.com/svn/trunk@226 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
a537069854
commit
c6573dfb98
@ -246,134 +246,4 @@ public final class ByteArray {
|
||||
private int getUnsignedByte0(int off) {
|
||||
return bytes[start + off] & 0xff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a <code>DataInputStream</code> that reads from this instance,
|
||||
* with the cursor starting at the beginning of this instance's data.
|
||||
* <b>Note:</b> The returned instance may be cast to {@link #GetCursor}
|
||||
* if needed.
|
||||
*
|
||||
* @return non-null; an appropriately-constructed
|
||||
* <code>DataInputStream</code> instance
|
||||
*/
|
||||
public MyDataInputStream makeDataInputStream() {
|
||||
return new MyDataInputStream(makeInputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a <code>InputStream</code> that reads from this instance,
|
||||
* with the cursor starting at the beginning of this instance's data.
|
||||
* <b>Note:</b> The returned instance may be cast to {@link #GetCursor}
|
||||
* if needed.
|
||||
*
|
||||
* @return non-null; an appropriately-constructed
|
||||
* <code>InputStream</code> instancex
|
||||
*/
|
||||
public MyInputStream makeInputStream() {
|
||||
return new MyInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper interface that allows one to get the cursor (of a stream).
|
||||
*/
|
||||
public interface GetCursor {
|
||||
/**
|
||||
* Gets the current cursor.
|
||||
*
|
||||
* @return 0..size(); the cursor
|
||||
*/
|
||||
public int getCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for {@link #makeInputStream}, which implements the
|
||||
* stream functionality.
|
||||
*/
|
||||
public class MyInputStream extends InputStream {
|
||||
/** 0..size; the cursor */
|
||||
private int cursor;
|
||||
|
||||
/** 0..size; the mark */
|
||||
private int mark;
|
||||
|
||||
public MyInputStream() {
|
||||
cursor = 0;
|
||||
mark = 0;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (cursor >= size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result = getUnsignedByte0(cursor);
|
||||
cursor++;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int read(byte[] arr, int offset, int length) {
|
||||
if ((offset + length) > arr.length) {
|
||||
length = arr.length - offset;
|
||||
}
|
||||
|
||||
int maxLength = size - cursor;
|
||||
if (length > maxLength) {
|
||||
length = maxLength;
|
||||
}
|
||||
|
||||
System.arraycopy(bytes, cursor, arr, offset, length);
|
||||
cursor += length;
|
||||
return length;
|
||||
}
|
||||
|
||||
public int available() {
|
||||
return size - cursor;
|
||||
}
|
||||
|
||||
public void mark(int reserve) {
|
||||
mark = cursor;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
cursor = mark;
|
||||
}
|
||||
|
||||
public boolean markSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current cursor.
|
||||
*
|
||||
* @return 0..size(); the cursor
|
||||
*/
|
||||
public int getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for {@link #makeDataInputStream}. This is used
|
||||
* simply so that the cursor of a wrapped {@link #MyInputStream}
|
||||
* instance may be easily determined.
|
||||
*/
|
||||
public class MyDataInputStream extends DataInputStream {
|
||||
/** non-null; the underlying {@link #MyInputStream} */
|
||||
private final MyInputStream wrapped;
|
||||
|
||||
public MyDataInputStream(MyInputStream wrapped) {
|
||||
super(wrapped);
|
||||
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current cursor.
|
||||
*
|
||||
* @return 0..size(); the cursor
|
||||
*/
|
||||
public int getCursor() {
|
||||
return wrapped.getCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user