-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df05e6b
commit f34d0c8
Showing
6 changed files
with
69 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 6 additions & 22 deletions
28
cfr/src/org/benf/cfr/reader/util/bytestream/BaseByteData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,23 @@ | ||
package org.benf.cfr.reader.util.bytestream; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.DataInputStream; | ||
|
||
public class BaseByteData extends AbstractBackedByteData { | ||
private final byte[] data; | ||
|
||
public BaseByteData(byte[] data) { | ||
this.data = data; | ||
} | ||
|
||
@Override | ||
public DataInputStream rawDataAsStream(int start, int len) { | ||
return new DataInputStream(new ByteArrayInputStream(data, start, len)); | ||
super(data); | ||
} | ||
|
||
@Override | ||
public ByteData getOffsetData(long offset) { | ||
return new OffsetBackedByteData(data, offset); | ||
return new OffsetBackedByteData(d, offset); | ||
} | ||
|
||
@Override | ||
public OffsettingByteData getOffsettingOffsetData(long offset) { | ||
return new OffsettingBackedByteData(data, offset); | ||
} | ||
|
||
@Override | ||
public byte[] getBytesAt(int count, long offset) { | ||
byte[] res = new byte[count]; | ||
System.arraycopy(data, (int) offset, res, 0, count); | ||
return res; | ||
return new OffsettingBackedByteData(d, offset); | ||
} | ||
|
||
@Override | ||
public byte getS1At(long o) { | ||
return data[(int) o]; | ||
int getRealOffset(int offset) { | ||
return offset; | ||
} | ||
|
||
} |
26 changes: 5 additions & 21 deletions
26
cfr/src/org/benf/cfr/reader/util/bytestream/OffsetBackedByteData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,25 @@ | ||
package org.benf.cfr.reader.util.bytestream; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.DataInputStream; | ||
|
||
public class OffsetBackedByteData extends AbstractBackedByteData { | ||
private final int offset; | ||
private final byte[] data; | ||
|
||
OffsetBackedByteData(byte[] data, long offset) { | ||
super(data); | ||
this.offset = (int) offset; | ||
this.data = data; | ||
} | ||
|
||
@Override | ||
public DataInputStream rawDataAsStream(int start, int len) { | ||
return new DataInputStream(new ByteArrayInputStream(data, start + offset, len)); | ||
} | ||
|
||
@Override | ||
public ByteData getOffsetData(long offset) { | ||
return new OffsetBackedByteData(data, this.offset + offset); | ||
return new OffsetBackedByteData(d, this.offset + offset); | ||
} | ||
|
||
@Override | ||
public OffsettingByteData getOffsettingOffsetData(long offset) { | ||
return new OffsettingBackedByteData(data, this.offset + offset); | ||
} | ||
|
||
@Override | ||
public byte getS1At(long o) { | ||
return data[(int) (offset + o)]; | ||
return new OffsettingBackedByteData(d, this.offset + offset); | ||
} | ||
|
||
@Override | ||
public byte[] getBytesAt(int count, long offset) { | ||
byte[] res = new byte[count]; | ||
System.arraycopy(data, (int) (this.offset + offset), res, 0, count); | ||
return res; | ||
int getRealOffset(int o) { | ||
return o + offset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters