Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
2e079911
Commit
2e079911
authored
15 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
add: public methods copyXXXToByte() and copyByteToXXX()
SVN: 15628
parent
0fdfac9e
No related branches found
No related tags found
1 merge request
!40
SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/java/ch/systemsx/cisd/base/convert/NativeData.java
+202
-12
202 additions, 12 deletions
source/java/ch/systemsx/cisd/base/convert/NativeData.java
sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java
+15
-14
15 additions, 14 deletions
...t/java/ch/systemsx/cisd/base/convert/NativeDataTests.java
with
217 additions
and
26 deletions
source/java/ch/systemsx/cisd/base/convert/NativeData.java
+
202
−
12
View file @
2e079911
...
@@ -70,7 +70,7 @@ public class NativeData
...
@@ -70,7 +70,7 @@ public class NativeData
* Returns <code>true</code> if this platform is a little-endian platform and <code>false</code>
* Returns <code>true</code> if this platform is a little-endian platform and <code>false</code>
* , if it is a big-endian platform.
* , if it is a big-endian platform.
*/
*/
static
native
boolean
isLittleEndian
();
private
static
native
boolean
isLittleEndian
();
/**
/**
* Copies a range from an array of <code>int</code> into an array of <code>byte</code>.
* Copies a range from an array of <code>int</code> into an array of <code>byte</code>.
...
@@ -85,7 +85,7 @@ public class NativeData
...
@@ -85,7 +85,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyIntToByte
(
int
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
private
static
native
void
copyIntToByte
(
int
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -101,7 +101,7 @@ public class NativeData
...
@@ -101,7 +101,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyByteToInt
(
byte
[]
inData
,
int
inStart
,
int
[]
outData
,
int
outStart
,
private
static
native
void
copyByteToInt
(
byte
[]
inData
,
int
inStart
,
int
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -117,7 +117,7 @@ public class NativeData
...
@@ -117,7 +117,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyLongToByte
(
long
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
private
static
native
void
copyLongToByte
(
long
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -133,7 +133,7 @@ public class NativeData
...
@@ -133,7 +133,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyByteToLong
(
byte
[]
inData
,
int
inStart
,
long
[]
outData
,
int
outStart
,
private
static
native
void
copyByteToLong
(
byte
[]
inData
,
int
inStart
,
long
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -149,7 +149,7 @@ public class NativeData
...
@@ -149,7 +149,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyShortToByte
(
short
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
private
static
native
void
copyShortToByte
(
short
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -165,7 +165,7 @@ public class NativeData
...
@@ -165,7 +165,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyByteToShort
(
byte
[]
inData
,
int
inStart
,
short
[]
outData
,
int
outStart
,
private
static
native
void
copyByteToShort
(
byte
[]
inData
,
int
inStart
,
short
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -181,7 +181,7 @@ public class NativeData
...
@@ -181,7 +181,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyFloatToByte
(
float
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
private
static
native
void
copyFloatToByte
(
float
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -197,7 +197,7 @@ public class NativeData
...
@@ -197,7 +197,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyByteToFloat
(
byte
[]
inData
,
int
inStart
,
float
[]
outData
,
int
outStart
,
private
static
native
void
copyByteToFloat
(
byte
[]
inData
,
int
inStart
,
float
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -213,7 +213,7 @@ public class NativeData
...
@@ -213,7 +213,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyDoubleToByte
(
double
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
private
static
native
void
copyDoubleToByte
(
double
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
/**
/**
...
@@ -229,7 +229,7 @@ public class NativeData
...
@@ -229,7 +229,7 @@ public class NativeData
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* @param byteOrder The ordinal of {@link ByteOrder}, encoding what byte order the
* <var>outData</var> should be in.
* <var>outData</var> should be in.
*/
*/
static
native
void
copyByteToDouble
(
byte
[]
inData
,
int
inStart
,
double
[]
outData
,
int
outStart
,
private
static
native
void
copyByteToDouble
(
byte
[]
inData
,
int
inStart
,
double
[]
outData
,
int
outStart
,
int
len
,
int
byteOrder
);
int
len
,
int
byteOrder
);
//
//
...
@@ -240,7 +240,7 @@ public class NativeData
...
@@ -240,7 +240,7 @@ public class NativeData
public
static
void
ensureNativeLibIsLoaded
()
public
static
void
ensureNativeLibIsLoaded
()
{
{
}
}
/**
/**
* Returns the native byte order of the host running this JRE.
* Returns the native byte order of the host running this JRE.
*/
*/
...
@@ -249,6 +249,196 @@ public class NativeData
...
@@ -249,6 +249,196 @@ public class NativeData
return
isLittleEndian
()
?
ByteOrder
.
LITTLE_ENDIAN
:
ByteOrder
.
BIG_ENDIAN
;
return
isLittleEndian
()
?
ByteOrder
.
LITTLE_ENDIAN
:
ByteOrder
.
BIG_ENDIAN
;
}
}
/**
* Copies a range from an array of <code>int</code> into an array of <code>byte</code>.
*
* @param inData The input array of <code>int</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>int</code> to
* start
* @param outData The output array of <code>byte</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>byte</code> to
* start
* @param len The number of <code>int</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyIntToByte
(
int
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyIntToByte
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>byte</code> into an array of <code>int</code>.
*
* @param inData The input array of <code>byte</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>byte</code> to
* start
* @param outData The output array of <code>int</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>int</code> to
* start
* @param len The number of <code>int</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyByteToInt
(
byte
[]
inData
,
int
inStart
,
int
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyByteToInt
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>long</code> into an array of <code>byte</code>.
*
* @param inData The input array of <code>long</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>long</code> to
* start
* @param outData The output array of <code>byte</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>byte</code> to
* start
* @param len The number of <code>long</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyLongToByte
(
long
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyLongToByte
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>byte</code> into an array of <code>long</code>.
*
* @param inData The input array of <code>byte</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>byte</code> to
* start
* @param outData The output array of <code>long</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>long</code> to
* start
* @param len The number of <code>long</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyByteToLong
(
byte
[]
inData
,
int
inStart
,
long
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyByteToLong
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>short</code> into an array of <code>byte</code>.
*
* @param inData The input array of <code>short</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>short</code> to
* start
* @param outData The output array of <code>byte</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>byte</code> to
* start
* @param len The number of <code>short</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyShortToByte
(
short
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyShortToByte
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>byte</code> into an array of <code>short</code>.
*
* @param inData The input array of <code>byte</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>byte</code> to
* start
* @param outData The output array of <code>short</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>short</code> to
* start
* @param len The number of <code>short</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyByteToShort
(
byte
[]
inData
,
int
inStart
,
short
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyByteToShort
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>float</code> into an array of <code>byte</code>.
*
* @param inData The input array of <code>float</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>float</code> to
* start
* @param outData The output array of <code>byte</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>byte</code> to
* start
* @param len The number of <code>float</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyFloatToByte
(
float
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyFloatToByte
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>byte</code> into an array of <code>float</code>.
*
* @param inData The input array of <code>byte</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>byte</code> to
* start
* @param outData The output array of <code>float</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>float</code> to
* start
* @param len The number of <code>float</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyByteToFloat
(
byte
[]
inData
,
int
inStart
,
float
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyByteToFloat
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>double</code> into an array of <code>byte</code>.
*
* @param inData The input array of <code>double</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>double</code> to
* start
* @param outData The output array of <code>byte</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>byte</code> to
* start
* @param len The number of <code>double</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyDoubleToByte
(
double
[]
inData
,
int
inStart
,
byte
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyDoubleToByte
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
* Copies a range from an array of <code>byte</code> into an array of <code>double</code>.
*
* @param inData The input array of <code>byte</code> values.
* @param inStart The position in the input array <code>inData</code> of <code>byte</code> to
* start
* @param outData The output array of <code>double</code> values.
* @param outStart The start in the output array <code>byteData</code> of <code>double</code> to
* start
* @param len The number of <code>double</code> to copy
* @param byteOrder The {@link ByteOrder}, encoding what byte order the <var>outData</var>
* should be in.
*/
public
static
void
copyByteToDouble
(
byte
[]
inData
,
int
inStart
,
double
[]
outData
,
int
outStart
,
int
len
,
ByteOrder
byteOrder
)
{
copyByteToDouble
(
inData
,
inStart
,
outData
,
outStart
,
len
,
byteOrder
.
ordinal
());
}
/**
/**
* Converts a <code>byte[]</code> array into a <code>short[]</code> array.
* Converts a <code>byte[]</code> array into a <code>short[]</code> array.
*
*
...
...
This diff is collapsed.
Click to expand it.
sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java
+
15
−
14
View file @
2e079911
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
ch.systemsx.cisd.base.convert
;
package
ch.systemsx.cisd.base.convert
;
import
static
org
.
testng
.
AssertJUnit
.
assertEquals
;
import
static
org
.
testng
.
AssertJUnit
.
assertFalse
;
import
static
org
.
testng
.
AssertJUnit
.
assertFalse
;
import
static
org
.
testng
.
AssertJUnit
.
assertTrue
;
import
static
org
.
testng
.
AssertJUnit
.
assertTrue
;
...
@@ -71,10 +72,10 @@ public class NativeDataTests
...
@@ -71,10 +72,10 @@ public class NativeDataTests
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
NativeData
.
copyIntToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
copyIntToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
final
int
[]
iarr2
=
new
int
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
final
int
[]
iarr2
=
new
int
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
NativeData
.
copyByteToInt
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
copyByteToInt
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
}
}
...
@@ -88,10 +89,10 @@ public class NativeDataTests
...
@@ -88,10 +89,10 @@ public class NativeDataTests
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
NativeData
.
copyLongToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
copyLongToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
final
long
[]
iarr2
=
new
long
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
final
long
[]
iarr2
=
new
long
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
NativeData
.
copyByteToLong
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
copyByteToLong
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
}
}
...
@@ -105,10 +106,10 @@ public class NativeDataTests
...
@@ -105,10 +106,10 @@ public class NativeDataTests
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
NativeData
.
copyShortToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
copyShortToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
final
short
[]
iarr2
=
new
short
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
final
short
[]
iarr2
=
new
short
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
NativeData
.
copyByteToShort
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
copyByteToShort
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
}
}
...
@@ -122,10 +123,10 @@ public class NativeDataTests
...
@@ -122,10 +123,10 @@ public class NativeDataTests
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
NativeData
.
copyFloatToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
copyFloatToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
final
float
[]
iarr2
=
new
float
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
final
float
[]
iarr2
=
new
float
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
NativeData
.
copyByteToFloat
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
copyByteToFloat
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
}
}
...
@@ -139,10 +140,10 @@ public class NativeDataTests
...
@@ -139,10 +140,10 @@ public class NativeDataTests
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
System
.
arraycopy
(
orignalArr
,
0
,
iarr
,
sourceOfs
,
orignalArr
.
length
);
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
final
byte
[]
barr
=
new
byte
[
iarr
.
length
*
sizeOfTarget
+
targetOfs
];
NativeData
.
copyDoubleToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
copyDoubleToByte
(
iarr
,
sourceOfs
,
barr
,
targetOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
final
double
[]
iarr2
=
new
double
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
final
double
[]
iarr2
=
new
double
[(
barr
.
length
-
targetOfs
)
/
sizeOfTarget
];
NativeData
.
copyByteToDouble
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
copyByteToDouble
(
barr
,
targetOfs
,
iarr2
,
sourceOfs
,
orignalArr
.
length
,
NativeData
.
ByteOrder
.
NATIVE
.
ordinal
()
);
NativeData
.
ByteOrder
.
NATIVE
);
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
assertTrue
(
Arrays
.
equals
(
iarr
,
iarr2
));
}
}
...
@@ -239,13 +240,13 @@ public class NativeDataTests
...
@@ -239,13 +240,13 @@ public class NativeDataTests
@Test
(
expectedExceptions
=
NullPointerException
.
class
)
@Test
(
expectedExceptions
=
NullPointerException
.
class
)
public
void
testNPE
()
public
void
testNPE
()
{
{
NativeData
.
copyByteToLong
(
null
,
0
,
null
,
0
,
0
,
0
);
NativeData
.
copyByteToLong
(
null
,
0
,
null
,
0
,
0
,
ByteOrder
.
NATIVE
);
}
}
@Test
(
expectedExceptions
=
IllegalArgumentException
.
class
)
@Test
(
expectedExceptions
=
IllegalArgumentException
.
class
)
public
void
testIAE
()
public
void
testIAE
()
{
{
NativeData
.
copyByteToLong
(
new
byte
[]
{},
-
1
,
new
long
[]
{},
0
,
0
,
0
);
NativeData
.
copyByteToLong
(
new
byte
[]
{},
-
1
,
new
long
[]
{},
0
,
0
,
ByteOrder
.
NATIVE
);
}
}
@Test
@Test
...
@@ -261,12 +262,12 @@ public class NativeDataTests
...
@@ -261,12 +262,12 @@ public class NativeDataTests
ByteOrder
.
NATIVE
);
ByteOrder
.
NATIVE
);
if
(
Arrays
.
equals
(
values
,
valuesLE
))
if
(
Arrays
.
equals
(
values
,
valuesLE
))
{
{
System
.
out
.
println
(
"Platform is little endian."
);
assertEquals
(
NativeData
.
ByteOrder
.
LITTLE_ENDIAN
,
NativeData
.
getNativeByteOrder
()
);
assertFalse
(
Arrays
.
equals
(
values
,
valuesBE
));
assertFalse
(
Arrays
.
equals
(
values
,
valuesBE
));
}
}
if
(
Arrays
.
equals
(
values
,
valuesBE
))
if
(
Arrays
.
equals
(
values
,
valuesBE
))
{
{
System
.
out
.
println
(
"Platform is big endian."
);
assertEquals
(
NativeData
.
ByteOrder
.
BIG_ENDIAN
,
NativeData
.
getNativeByteOrder
()
);
assertFalse
(
Arrays
.
equals
(
values
,
valuesLE
));
assertFalse
(
Arrays
.
equals
(
values
,
valuesLE
));
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment