List of usage examples for java.lang.reflect Field getModifiers
public int getModifiers()
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *///w w w . j a v a 2 s . c o m public static void set(Object target, Field field, char value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setChar(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, "char" })); } }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *///from www .jav a 2s .c om public static void set(Object target, Field field, long value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setLong(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, "long" })); } }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *//* ww w .j a v a 2 s . c om*/ public static void set(Object target, Field field, float value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setFloat(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, "float" })); } }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *//*from ww w .j a v a 2 s .c om*/ public static void set(Object target, Field field, short value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setShort(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, "short" })); } }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *//*from ww w .ja v a 2 s. co m*/ public static void set(Object target, Field field, Object value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.set(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, value == null ? "" : value.getClass() })); } }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *///from ww w . j a v a 2s. c om public static void set(Object target, Field field, double value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setDouble(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, "double" })); } }
From source file:org.apache.openjpa.enhance.Reflection.java
/** * Set the value of the given field in the given object. *///from w w w . j ava 2s . c o m public static void set(Object target, Field field, boolean value) { if (target == null || field == null) return; makeAccessible(field, field.getModifiers()); try { field.setBoolean(target, value); } catch (Throwable t) { throw wrapReflectionException(t, _loc.get("set-field", new Object[] { target, field, value, "boolean" })); } }
From source file:no.digipost.api.xml.SchemasTest.java
@Test public void allSchemasExist() throws Exception { for (Field field : Schemas.class.getFields()) { if (isStatic(field.getModifiers()) && Resource.class.isAssignableFrom(field.getType())) { Resource resource = (Resource) field.get(Schemas.class); assertTrue(resource + " must exist! (declared in " + Schemas.class.getName() + "." + field.getName() + ")", resource.exists()); }// w w w .java 2s . c o m } }
From source file:org.acoveo.tools.Reflection.java
/** * Return the value of the given field in the given object. *//*from ww w.ja v a 2s. c om*/ public static int getInt(Object target, Field field) { if (target == null || field == null) return 0; makeAccessible(field, field.getModifiers()); try { return field.getInt(target); } catch (Throwable t) { throw wrapReflectionException(t); } }
From source file:org.acoveo.tools.Reflection.java
/** * Return the value of the given field in the given object. *//*ww w. j a v a2 s . c o m*/ public static double getDouble(Object target, Field field) { if (target == null || field == null) return 0D; makeAccessible(field, field.getModifiers()); try { return field.getDouble(target); } catch (Throwable t) { throw wrapReflectionException(t); } }