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

x33g5p2x  于2022-01-17 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(97)

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

Field.getShort介绍

[英]Returns the value of the field in the specified object as a short. This reproduces the effect of object.fieldName

If this field is static, the object argument is ignored. Otherwise, if the object is null, a NullPointerException is thrown. If the object is not an instance of the declaring class of the method, an IllegalArgumentException is thrown.

If this Field object is enforcing access control (see AccessibleObject) and this field is not accessible from the current context, an IllegalAccessException is thrown.
[中]将指定对象中字段的值作为短字符串返回。这再现了对象的效果。字段名
如果此字段是静态的,则忽略对象参数。否则,如果对象为null,则抛出NullPointerException。如果该对象不是该方法声明类的实例,则会引发IllegalArgumentException。
如果此字段对象正在强制访问控制(请参见AccessibleObject),并且无法从当前上下文访问此字段,则会引发IllegaAccessException。

代码示例

代码示例来源:origin: btraceio/btrace

/**
 * Gets the value of a static <code>short</code> field.
 *
 * @param field Field object whose value is returned.
 * @return the value of the <code>short</code> field
 */
public static short getShort(Field field) {
  checkStatic(field);
  try {
    return field.getShort(null);
  } catch (Exception exp) {
    throw translate(exp);
  }
}

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

public final int getShortValue(Object obj) throws IllegalAccessException {
  if (!isAndroid && memOffset >= 0) {
    return FSTUtil.unFlaggedUnsafe.getShort(obj, memOffset);
  }
  return field.getShort(obj);
}

代码示例来源:origin: spring-projects/spring-loaded

public short getReflectS() throws Exception {
  return f_s.getShort(t);
}

代码示例来源:origin: btraceio/btrace

/**
 * Gets the value of an instance <code>short</code> field.
 *
 * @param field Field object whose value is returned.
 * @param obj the object to extract the <code>short</code> value
 * from
 * @return the value of the <code>short</code> field
 */
public static short getShort(Field field, Object obj) {
  try {
    return field.getShort(obj);
  } catch (Exception exp) {
    throw translate(exp);
  }
}

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

public short getShort(Object o) throws IllegalArgumentException, IllegalAccessException {
 return this.field.getShort(o);
}

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

public final int getShortValue(Object obj) throws IllegalAccessException {
  if (!isAndroid && memOffset >= 0) {
    return FSTUtil.unFlaggedUnsafe.getShort(obj, memOffset);
  }
  return field.getShort(obj);
}

代码示例来源:origin: spring-projects/spring-loaded

public static short callSetAndGetShort(Field thiz, Object o) throws IllegalArgumentException, IllegalAccessException {
  thiz.setShort(o, (short) (thiz.getShort(o) + 1));
  return thiz.getShort(o);
}

代码示例来源:origin: spring-projects/spring-loaded

public static short callSetShort(Field thiz, Object o) throws IllegalArgumentException, IllegalAccessException {
  thiz.setShort(o, (short) 1234);
  return thiz.getShort(o);
}

代码示例来源:origin: org.apache.poi/poi

short sid;
try {
  sid = recCls.getField("RECORD_ID").getShort(null);
} catch (IllegalArgumentException e) {
  throw new RuntimeException(e);

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

private int getInt(Object object, Class<?> fieldType, Class<?> expectedType) {
  if (fieldType == Integer.TYPE) {
    return getI(object, field);
  }
  if (fieldType == Character.TYPE) {
    return getC(object, field);
  }
  return getShort(object, fieldType, expectedType);
}

代码示例来源:origin: hibernate/hibernate-orm

return Short.valueOf( field.getShort( owner ) );

代码示例来源:origin: org.apache.poi/poi

sid = recClass.getField("sid").getShort(null);
} catch (Exception illegalArgumentException) {
  throw new org.apache.poi.util.RecordFormatException(

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

/**
 * Returns the value of the field in the specified object as a {@code short}
 * . This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public short getShort(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getShort(object, getType(), Short.TYPE);
}

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

output.writeLong(field.getLong(obj));
} else if (type == short.class) {
  output.writeShort(field.getShort(obj));
} else if (type == boolean.class) {
  output.writeBoolean(field.getBoolean(obj));

代码示例来源:origin: boonproject/boon

@Override
public short getShort( Object obj ) {
  try {
    return field.getShort( obj );
  } catch ( Exception e ) {
    analyzeError( e, obj );
    return 0;
  }
}

代码示例来源:origin: boonproject/boon

@Override
public short getShort( Object obj ) {
  try {
    return field.getShort( obj );
  } catch ( Exception e ) {
    analyzeError( e, obj );
    return 0;
  }
}

代码示例来源:origin: com.sleepycat/je

@Override
void writePrimitiveField(Object o, EntityOutput output, Field field)
  throws IllegalAccessException {
  output.writeShort(field.getShort(o));
}

代码示例来源:origin: com.esotericsoftware/kryo

public void copy (Object original, Object copy) {
    try {
      field.setShort(copy, field.getShort(original));
    } catch (Exception e) {
      KryoException ex = new KryoException(e);
      ex.addTrace(this + " (" + type.getName() + ")");
      throw ex;
    }
  }
}

代码示例来源:origin: com.esotericsoftware/kryo

public void write (Output output, Object object) {
  try {
    output.writeShort(field.getShort(object));
  } catch (Exception e) {
    KryoException ex = new KryoException(e);
    ex.addTrace(this + " (" + type.getName() + ")");
    throw ex;
  }
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

public void copy (Object original, Object copy) {
    try {
      field.setShort(copy, field.getShort(original));
    } catch (Exception e) {
      KryoException ex = new KryoException(e);
      ex.addTrace(this + " (" + type.getName() + ")");
      throw ex;
    }
  }
}

相关文章

微信公众号

最新文章

更多