java.lang.reflect.Array.getLong()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中java.lang.reflect.Array.getLong()方法的一些代码示例,展示了Array.getLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.getLong()方法的具体详情如下:
包路径:java.lang.reflect.Array
类名称:Array
方法名:getLong

Array.getLong介绍

[英]Returns the long at the given index in the given array. Applies to byte, char, int, long, and short arrays.
[中]返回给定数组中给定索引处的long。适用于字节、字符、整数、长数组和短数组。

代码示例

代码示例来源:origin: redisson/redisson

@Override
  protected String toString(Object array, int index) {
    return ForNonArrayType.LONG.toString(Array.getLong(array, index));
  }
},

代码示例来源:origin: redisson/redisson

protected String arrayToString(Object o) {
  int len = Array.getLength(o);
  Class c = o.getClass().getComponentType();
  String res = "[ ";
  for (int i = 0; i < len; i++) {
    if ( c == byte.class ) res+=Array.getByte(o,i);
    if ( c == boolean.class ) res+=Array.getBoolean(o, i);
    if ( c == char.class ) res+=Array.getChar(o, i);
    if ( c == short.class ) res+=Array.getShort(o, i);
    if ( c == int.class ) res+=Array.getInt(o, i);
    if ( c == long.class ) res+=Array.getLong(o, i);
    if ( c == float.class ) res+=Array.getFloat(o, i);
    if ( c == double.class ) res+=Array.getDouble(o, i);
    if ( i < len-1)
      res+=",";
  }
  res += " ]";
  return res;
}

代码示例来源:origin: drewnoakes/metadata-extractor

if (i != 0)
  string.append(' ');
string.append(Array.getLong(o, i));

代码示例来源:origin: RuedigerMoeller/fast-serialization

protected String arrayToString(Object o) {
  int len = Array.getLength(o);
  Class c = o.getClass().getComponentType();
  String res = "[ ";
  for (int i = 0; i < len; i++) {
    if ( c == byte.class ) res+=Array.getByte(o,i);
    if ( c == boolean.class ) res+=Array.getBoolean(o, i);
    if ( c == char.class ) res+=Array.getChar(o, i);
    if ( c == short.class ) res+=Array.getShort(o, i);
    if ( c == int.class ) res+=Array.getInt(o, i);
    if ( c == long.class ) res+=Array.getLong(o, i);
    if ( c == float.class ) res+=Array.getFloat(o, i);
    if ( c == double.class ) res+=Array.getDouble(o, i);
    if ( i < len-1)
      res+=",";
  }
  res += " ]";
  return res;
}

代码示例来源:origin: redisson/redisson

writeRawInt(type, Array.getBoolean(primitiveArray, i) ? 1 : 0);
else
  writeRawInt(type, Array.getLong(primitiveArray, i));

代码示例来源:origin: RuedigerMoeller/fast-serialization

writeRawInt(type, Array.getBoolean(primitiveArray, i) ? 1 : 0);
else
  writeRawInt(type, Array.getLong(primitiveArray, i));

代码示例来源:origin: neo4j/neo4j

private void assertNumericArrayHeaderAndContent( Object array, PropertyType type, int expectedBitsUsedPerItem, Pair<byte[],byte[]> loadedBytesFromStore )
{
  assertArrayHeader( loadedBytesFromStore.first(), type, expectedBitsUsedPerItem );
  Bits bits = Bits.bitsFromBytes( loadedBytesFromStore.other() );
  int length = Array.getLength( array );
  for ( int i = 0; i < length; i++ )
  {
    if ( array instanceof double[] )
    {
      assertEquals( Double.doubleToLongBits( Array.getDouble( array, i ) ), bits.getLong( expectedBitsUsedPerItem ) );
    }
    else
    {
      assertEquals( Array.getLong( array, i ), bits.getLong( expectedBitsUsedPerItem ) );
    }
  }
}

代码示例来源:origin: com.googlecode.gstreamer-java/gstreamer-java

public Object get(Object array, int index) {
    return java.lang.reflect.Array.getLong(array, index);
  }
};

代码示例来源:origin: gdpancheng/LoonAndroid3

@Override
public Object get(Object array, int index) {
  return Array.getLong(array, index);
}

代码示例来源:origin: gstreamer-java/gst1-java-core

public Object get(Object array, int index) {
    return java.lang.reflect.Array.getLong(array, index);
  }
};

代码示例来源:origin: apache/sis

/**
 * Returns a {@linkplain Range#getMinValue() range minimum value} as a {@code long}.
 * The {@code index} can be any value from 0 inclusive to the set {@link #size() size}
 * exclusive. The returned values always increase with {@code index}.
 * Widening conversions are performed as needed.
 *
 * @param  index  the range index, from 0 inclusive to {@link #size() size} exclusive.
 * @return the minimum value for the range at the specified index, inclusive.
 * @throws IndexOutOfBoundsException if {@code index} is out of bounds.
 * @throws ClassCastException if range elements are not convertible to {@code long}.
 */
public long getMinLong(int index) throws IndexOutOfBoundsException, ClassCastException {
  if ((index *= 2) >= length) {
    throw new IndexOutOfBoundsException();
  }
  return Array.getLong(array, index);
}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns a {@linkplain Range#getMinValue() range minimum value} as a {@code long}.
 * The {@code index} can be any value from 0 inclusive to the set {@link #size() size}
 * exclusive. The returned values always increase with {@code index}.
 * Widening conversions are performed as needed.
 *
 * @param  index  the range index, from 0 inclusive to {@link #size() size} exclusive.
 * @return the minimum value for the range at the specified index, inclusive.
 * @throws IndexOutOfBoundsException if {@code index} is out of bounds.
 * @throws ClassCastException if range elements are not convertible to {@code long}.
 */
public long getMinLong(int index) throws IndexOutOfBoundsException, ClassCastException {
  if ((index *= 2) >= length) {
    throw new IndexOutOfBoundsException();
  }
  return Array.getLong(array, index);
}

代码示例来源:origin: com.github.samtools/htsjdk

private static long[] widenToUnsigned(final Object array) {
  final Class<?> componentType = array.getClass().getComponentType();
  final long mask;
  if (componentType == Byte.TYPE)    mask = 0xffL;
  else if (componentType == Short.TYPE)   mask = 0xffffL;
  else if (componentType == Integer.TYPE) mask = 0xffffffffL;
  else throw new IllegalArgumentException("Unrecognized unsigned array type " + componentType);
  final long[] ret = new long[Array.getLength(array)];
  for (int i = 0; i < ret.length; ++i) {
    ret[i] = Array.getLong(array, i) & mask;
  }
  return ret;
}

代码示例来源:origin: org.seqdoop/htsjdk

private long[] widenToUnsigned(final Object array) {
  final Class<?> componentType = array.getClass().getComponentType();
  final long mask;
  if (componentType == Byte.TYPE)    mask = 0xffL;
  else if (componentType == Short.TYPE)   mask = 0xffffL;
  else if (componentType == Integer.TYPE) mask = 0xffffffffL;
  else throw new IllegalArgumentException("Unrecognized unsigned array type " + componentType);
  final long[] ret = new long[Array.getLength(array)];
  for (int i = 0; i < ret.length; ++i) {
    ret[i] = Array.getLong(array, i) & mask;
  }
  return ret;
}

代码示例来源:origin: samtools/htsjdk

private static long[] widenToUnsigned(final Object array) {
  final Class<?> componentType = array.getClass().getComponentType();
  final long mask;
  if (componentType == Byte.TYPE)    mask = 0xffL;
  else if (componentType == Short.TYPE)   mask = 0xffffL;
  else if (componentType == Integer.TYPE) mask = 0xffffffffL;
  else throw new IllegalArgumentException("Unrecognized unsigned array type " + componentType);
  final long[] ret = new long[Array.getLength(array)];
  for (int i = 0; i < ret.length; ++i) {
    ret[i] = Array.getLong(array, i) & mask;
  }
  return ret;
}

代码示例来源:origin: org.utgenome.thirdparty/picard

private long[] widenToUnsigned(final Object array) {
  final Class<?> componentType = array.getClass().getComponentType();
  final long mask;
  if (componentType == Byte.TYPE)    mask = 0xffL;
  else if (componentType == Short.TYPE)   mask = 0xffffL;
  else if (componentType == Integer.TYPE) mask = 0xffffffffL;
  else throw new IllegalArgumentException("Unrecognized unsigned array type " + componentType);
  final long[] ret = new long[Array.getLength(array)];
  for (int i = 0; i < ret.length; ++i) {
    ret[i] = Array.getLong(array, i) & mask;
  }
  return ret;
}

代码示例来源:origin: org.testifyproject.external/external-bytebuddy

@Override
  protected String toString(Object array, int index) {
    return ForNonArrayType.LONG.toString(Array.getLong(array, index));
  }
},

代码示例来源:origin: org.apache.wicket/com.springsource.org.apache.wicket

/**
 * @throws IOException
 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,
 *      WicketObjectOutputStream)
 */
public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException
{
  int length = Array.getLength(object);
  dos.writeInt(length);
  for (int i = 0; i < length; i++)
  {
    dos.writeLong(Array.getLong(object, i));
  }
}

代码示例来源:origin: org.ops4j.pax.wicket/pax-wicket-service

/**
 * @throws IOException
 * @see org.apache.wicket.util.io.ClassStreamHandler.PrimitiveArray#writeArray(Object,
 *      WicketObjectOutputStream)
 */
@Override
public void writeArray(Object object, WicketObjectOutputStream dos) throws IOException
{
  int length = Array.getLength(object);
  dos.writeInt(length);
  for (int i = 0; i < length; i++)
  {
    dos.writeLong(Array.getLong(object, i));
  }
}

代码示例来源:origin: com.jtransc/jtransc-rt

@JTranscSync
public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
  Type elementType = getArrayElementType(array.getClass());
  if (elementType == Boolean.TYPE) return getBoolean(array, index);
  if (elementType == Byte.TYPE) return getByte(array, index);
  if (elementType == Character.TYPE) return getChar(array, index);
  if (elementType == Short.TYPE) return getShort(array, index);
  if (elementType == Integer.TYPE) return getInt(array, index);
  if (elementType == Long.TYPE) return getLong(array, index);
  if (elementType == Float.TYPE) return getFloat(array, index);
  if (elementType == Double.TYPE) return getDouble(array, index);
  return getInstance(array, index);
}

相关文章