本文整理了Java中org.apache.jena.atlas.lib.Bytes.setInt()
方法的一些代码示例,展示了Bytes.setInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.setInt()
方法的具体详情如下:
包路径:org.apache.jena.atlas.lib.Bytes
类名称:Bytes
方法名:setInt
[英]Put an int into a byte array
[中]
代码示例来源:origin: apache/jena
/** Put a long into a byte array from a given position
* @param value The integer
* @param b byte array
* @param idx starting point
*/
public static final void setLong(long value, byte[] b, int idx) {
int lo = (int)(value & 0xFFFFFFFFL) ;
int hi = (int)(value >>> 32) ;
setInt(hi, b, idx) ;
setInt(lo, b, idx + 4) ;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** Put an int into a byte array
* @param value The integer
* @param b byte array
*/
public static final void setInt(int value, byte[]b)
{ setInt(value, b, 0) ; }
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** Put a long into a byte array from a given position
* @param value The integer
* @param b byte array
* @param idx starting point
*/
public static final void setLong(long value, byte[]b, int idx)
{
int lo = (int)(value&0xFFFFFFFFL) ;
int hi = (int)(value>>>32) ;
setInt(hi, b, idx) ;
setInt(lo, b, idx+4) ;
}
代码示例来源:origin: apache/jena
/** Put an int into a byte array
* @param value The integer
* @param b byte array
*/
public static final void setInt(int value, byte[]b)
{ setInt(value, b, 0) ; }
代码示例来源:origin: apache/jena
/** int to byte array */
public static byte[] packInt(int val) {
byte[] valBytes = new byte[Integer.SIZE / Byte.SIZE] ;
setInt(val, valBytes, 0) ;
return valBytes ;
}
代码示例来源:origin: apache/jena
/** Put an int value into an allocated byte array.
* @param v
* @return byte[] array
* @see Integer#SIZE
*/
public static byte[] intToBytes(int v) {
byte[] bytes = new byte[Integer.BYTES] ;
setInt(v, bytes);
return bytes ;
}
代码示例来源:origin: org.apache.jena/jena-base
/** int to byte array */
public static byte[] packInt(int val) {
byte[] valBytes = new byte[Integer.SIZE / Byte.SIZE] ;
setInt(val, valBytes, 0) ;
return valBytes ;
}
代码示例来源:origin: org.apache.jena/jena-base
/** Put an int value into an allocated byte array.
* @param v
* @return byte[] array
* @see Integer#SIZE
*/
public static byte[] intToBytes(int v) {
byte[] bytes = new byte[Integer.BYTES] ;
setInt(v, bytes);
return bytes ;
}
代码示例来源:origin: org.apache.jena/jena-base
/** Put an int into a byte array
* @param value The integer
* @param b byte array
*/
public static final void setInt(int value, byte[]b)
{ setInt(value, b, 0) ; }
代码示例来源:origin: org.apache.jena/jena-base
/** Put a long into a byte array from a given position
* @param value The integer
* @param b byte array
* @param idx starting point
*/
public static final void setLong(long value, byte[] b, int idx) {
int lo = (int)(value & 0xFFFFFFFFL) ;
int hi = (int)(value >>> 32) ;
setInt(hi, b, idx) ;
setInt(lo, b, idx + 4) ;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** int to byte array */
public static byte[] packInt(int val)
{
byte[] valBytes = new byte[Integer.SIZE/Byte.SIZE] ;
setInt(val, valBytes, 0) ;
return valBytes ;
}
代码示例来源:origin: apache/jena
static List<Record> createData(int N, RecordFactory recordFactory)
{
List<Record> originaldata = new ArrayList<>(N) ;
for ( int i = 0; i < N ; i++ )
{
Record record = recordFactory.create() ;
Bytes.setInt(i+1, record.getKey()) ;
if ( recordFactory.hasValue() )
Bytes.setInt(10*i+1, record.getValue()) ;
originaldata.add(record) ;
}
return originaldata ;
}
代码示例来源:origin: apache/jena
static List<Record> createData(int N, RecordFactory recordFactory)
{
List<Record> originaldata = new ArrayList<>(N) ;
for ( int i = 0; i < N ; i++ )
{
Record record = recordFactory.create() ;
Bytes.setInt(i+1, record.getKey()) ;
if ( recordFactory.hasValue() )
Bytes.setInt(10*i+1, record.getValue()) ;
originaldata.add(record) ;
}
return originaldata ;
}
代码示例来源:origin: apache/jena
@Test public void packInt4()
{
byte[] b = new byte[8] ;
Bytes.setInt(0x01020304,b,0) ;
Bytes.setInt(0x05060708,b,4) ;
int i1 = Bytes.getInt(b,0) ;
int i2 = Bytes.getInt(b,4) ;
assertEquals(0x01020304, i1) ;
assertEquals(0x05060708, i2) ;
}
代码示例来源:origin: apache/jena
@Test public void packInt3()
{
byte[] b = new byte[4] ;
Bytes.setInt(0xF1F2F3F4,b) ;
int i = Bytes.getInt(b) ;
assertEquals(0xF1F2F3F4, i) ;
}
代码示例来源:origin: apache/jena
private static long writeOne(Transactional transactional, TransBinaryDataFile transBinaryFile, String data) {
return
Txn.calculateWrite(transactional, ()->{
byte[] bytes = StrUtils.asUTF8bytes(data) ;
int len = bytes.length ;
byte[] lenBytes = new byte[4] ;
Bytes.setInt(len, lenBytes);
// To work with strings, we write length,bytes.
long x = transBinaryFile.write(lenBytes);
transBinaryFile.write(bytes);
return x ;
}) ;
}
代码示例来源:origin: org.apache.jena/jena-dboe-trans-data
private static long writeOne(Transactional transactional, TransBinaryDataFile transBinaryFile, String data) {
return
Txn.calculateWrite(transactional, ()->{
byte[] bytes = StrUtils.asUTF8bytes(data) ;
int len = bytes.length ;
byte[] lenBytes = new byte[4] ;
Bytes.setInt(len, lenBytes);
// To work with strings, we write length,bytes.
long x = transBinaryFile.write(lenBytes);
transBinaryFile.write(bytes);
return x ;
}) ;
}
代码示例来源:origin: apache/jena
@Test public void packInt2()
{
byte[] b = new byte[8] ;
Bytes.setInt(0x01020304,b,0) ;
Bytes.setInt(0x05060708,b,4) ;
assertEquals(0x01, b[0]) ;
assertEquals(0x02, b[1]) ;
assertEquals(0x03, b[2]) ;
assertEquals(0x04, b[3]) ;
assertEquals(0x05, b[4]) ;
assertEquals(0x06, b[5]) ;
assertEquals(0x07, b[6]) ;
assertEquals(0x08, b[7]) ;
}
代码示例来源:origin: apache/jena
@Test public void packInt1()
{
byte[] b = new byte[4] ;
Bytes.setInt(0x01020304,b) ;
assertEquals(0x01, b[0]) ;
assertEquals(0x02, b[1]) ;
assertEquals(0x03, b[2]) ;
assertEquals(0x04, b[3]) ;
}
代码示例来源:origin: org.seaborne.rdf-delta/rdf-delta-base
@Test public void pState_02() {
PersistentState ps = new PersistentState(filename);
byte[] b = new byte[4];
Bytes.setInt(-99, b);
ps.set(b);
assertEquals(4, ps.get().length);
PersistentState ps2 = new PersistentState(filename);
assertEquals(4, ps2.get().length);
}
内容来源于网络,如有侵权,请联系作者删除!