Class BEncoder
java.lang.Object
com.biglybt.core.util.BEncoder
A set of utility methods to encode a Map into a bencoded array of byte.
integer are represented as Long, String as byte[], dictionaries as Map, and list as List.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate byte[]private intprivate OutputStream(package private) static final byte[](package private) static final byte[](package private) static final byte[]private final byte[]private static final byte[]private static intprivate byte[][] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectstatic Liststatic Mapstatic byte[]static byte[]encodeIfLessThan(Map map, long max_size) private booleanencodeObject(Object object, boolean utf_key_expected) private voidencodeObject(Object object, OutputStream os, boolean utf_key_expected) static StringencodeToJSON(Map b_map) static JSONArrayencodeToJSONArray(List b_list) private static Objectstatic JSONObjectencodeToJSONObject(Map<Object, Object> b_map) static voidencodeToStream(Map object, OutputStream os) static StringBufferencodeToXML(Map map, boolean simple) static longgetEncodedSize(Map map) private Stringprivate intintToBytes(int i) writes to int_buffer and returns start position in buffer (always runs to end of buffer)static booleanisEncodable(Object toCheck) static booleanlistsAreIdentical(List list1, List list2) static voidstatic booleanmapsAreIdentical(Map map1, Map map2) private static Objectstatic booleanobjectsAreIdentical(Object o1, Object o2) private byte[]private voidprivate voidwriteBytes(byte[] bytes) private voidwriteBytes(byte[] bytes, int offset, int length) private voidwriteChar(char c) private voidwriteInt(int i) private voidwriteLong(long l)
-
Field Details
-
BUFFER_DOUBLE_LIMIT
private static final int BUFFER_DOUBLE_LIMIT- See Also:
-
MINUS_1_BYTES
private static final byte[] MINUS_1_BYTES -
non_ascii_logs
private static volatile int non_ascii_logs -
current_buffer
private byte[] current_buffer -
current_buffer_pos
private int current_buffer_pos -
old_buffers
private byte[][] old_buffers -
current_os
-
int_buffer
private final byte[] int_buffer -
digits
static final byte[] digits -
DigitTens
static final byte[] DigitTens -
DigitOnes
static final byte[] DigitOnes
-
-
Constructor Details
-
BEncoder
public BEncoder()
-
-
Method Details
-
encode
- Throws:
IOException
-
encodeToStream
- Throws:
IOException
-
encodeObject
private void encodeObject(Object object, OutputStream os, boolean utf_key_expected) throws IOException - Throws:
IOException
-
encodeObject
- Throws:
IOException
-
writeChar
- Throws:
IOException
-
writeInt
- Throws:
IOException
-
writeLong
- Throws:
IOException
-
writeBytes
- Throws:
IOException
-
writeBytes
- Throws:
IOException
-
writeByteBuffer
- Throws:
IOException
-
getEncodedSoFar
-
toByteArray
private byte[] toByteArray() -
normaliseObject
-
isEncodable
-
objectsAreIdentical
-
listsAreIdentical
-
mapsAreIdentical
-
getEncodedSize
-
encodeIfLessThan
-
cloneMap
-
cloneList
-
clone
-
encodeToXML
-
encodeToJSONGeneric
-
encodeToJSONArray
-
encodeToJSONObject
-
encodeToJSON
-
intToBytes
private int intToBytes(int i) writes to int_buffer and returns start position in buffer (always runs to end of buffer)- Parameters:
i-- Returns:
-
main
-