Code example for Field

Methods: getType, setBoolean

0
    } 
     
    private void setPrimitiveField(Field f, Object object, String valueContent) 
    	throws IllegalArgumentException, IllegalAccessException { 
    	 
    	String clzName = f.getType().getName();
		if(clzName.equals("boolean")) {
			if(valueContent != null && valueContent.equalsIgnoreCase("true"))
				f.setBoolean(object, true);
			else 
				f.setBoolean(object, false);
		} else if(clzName.equals("byte")) {
			byte value = 0;
			if(valueContent != null)
				value = Byte.parseByte(valueContent);
			f.setByte(object, value);
		} else if(clzName.equals("char")) {
			char value = '\0';
			if(valueContent != null) {
				if(valueContent.charAt(0) == '\'')
					value = valueContent.charAt(1);