forked from javasoze/kamikaze
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add hardcoded SUID to all serializable classes in production
's 3.0.1, and add new serialization/deserialization from/to byte[] array
- Loading branch information
hao yan
committed
Dec 14, 2011
1 parent
abe1f8b
commit 51968f4
Showing
10 changed files
with
746 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.kamikaze.docidset.utils; | ||
|
||
public class Conversion { | ||
public static final int BYTES_PER_INT = 4; | ||
public static final int BYTES_PER_LONG = 8; | ||
|
||
public static final void intToByteArray(int value, byte[] bytes, int offset) { | ||
bytes[offset] = (byte)(value >>> 24); | ||
bytes[offset+1] = (byte)(value >>> 16); | ||
bytes[offset+2] = (byte)(value >>> 8); | ||
bytes[offset+3] = (byte)value; | ||
} | ||
|
||
public static final int byteArrayToInt(byte [] b, int offset) { | ||
return (b[offset] << 24) | ||
+ ((b[offset+1] & 0xFF) << 16) | ||
+ ((b[offset+2] & 0xFF) << 8) | ||
+ (b[offset+3] & 0xFF); | ||
} | ||
|
||
public static final void longToByteArray(long value, byte[] bytes, int offset) { | ||
bytes[offset] = (byte)(value >>> 56); | ||
bytes[offset+1] = (byte)(value >>> 48); | ||
bytes[offset+2] = (byte)(value >>> 40); | ||
bytes[offset+3] = (byte)(value >>> 32); | ||
bytes[offset+4] = (byte)(value >>> 24); | ||
bytes[offset+5] = (byte)(value >>> 16); | ||
bytes[offset+6] = (byte)(value >>> 8); | ||
bytes[offset+7] = (byte)value; | ||
} | ||
|
||
public static final long byteArrayToLong(byte [] b, int offset) { | ||
return (b[offset] << 56) | ||
+ ((b[offset+1] & 0xFF) << 48) | ||
+ ((b[offset+2] & 0xFF) << 40) | ||
+ ((b[offset+3] & 0xFF) << 32) | ||
+ ((b[offset+4] & 0xFF) << 24) | ||
+ ((b[offset+5] & 0xFF) << 16) | ||
+ ((b[offset+6] & 0xFF) << 8) | ||
+ (b[offset+7] & 0xFF); | ||
} | ||
|
||
} |
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
Oops, something went wrong.