Package com.biglybt.core.util
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 int
private byte[]
private int
private 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 int
private byte[][]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
static List
static Map
static byte[]
private boolean
encodeObject
(Object object, boolean utf_key_expected) private void
encodeObject
(Object object, OutputStream os, boolean utf_key_expected) static String
encodeToJSON
(Map b_map) static JSONArray
encodeToJSONArray
(List b_list) private static Object
static JSONObject
encodeToJSONObject
(Map<Object, Object> b_map) static void
encodeToStream
(Map object, OutputStream os) static StringBuffer
encodeToXML
(Map map, boolean simple) private String
private int
intToBytes
(int i) writes to int_buffer and returns start position in buffer (always runs to end of buffer)static boolean
isEncodable
(Object toCheck) static boolean
listsAreIdentical
(List list1, List list2) static void
static boolean
mapsAreIdentical
(Map map1, Map map2) private static Object
static boolean
objectsAreIdentical
(Object o1, Object o2) private byte[]
private void
private void
writeBytes
(byte[] bytes) private void
writeBytes
(byte[] bytes, int offset, int length) private void
writeChar
(char c) private void
writeInt
(int i) private void
writeLong
(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
-
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
-