(Object o, Field field)
| 229 | } |
| 230 | |
| 231 | private void field(Object o, Field field) throws IOException { |
| 232 | try { |
| 233 | field.setAccessible(true); |
| 234 | Class type = field.getType(); |
| 235 | if (!type.isPrimitive()) { |
| 236 | writeObject(field.get(o)); |
| 237 | } else if (type == Byte.TYPE) { |
| 238 | rawByte(field.getByte(o)); |
| 239 | } else if (type == Character.TYPE) { |
| 240 | char c = field.getChar(o); |
| 241 | rawShort((short)c); |
| 242 | } else if (type == Double.TYPE) { |
| 243 | double d = field.getDouble(o); |
| 244 | rawLong(Double.doubleToLongBits(d)); |
| 245 | } else if (type == Float.TYPE) { |
| 246 | float f = field.getFloat(o); |
| 247 | rawInt(Float.floatToIntBits(f)); |
| 248 | } else if (type == Integer.TYPE) { |
| 249 | int i = field.getInt(o); |
| 250 | rawInt(i); |
| 251 | } else if (type == Long.TYPE) { |
| 252 | long l = field.getLong(o); |
| 253 | rawLong(l); |
| 254 | } else if (type == Short.TYPE) { |
| 255 | short s = field.getShort(o); |
| 256 | rawShort(s); |
| 257 | } else if (type == Boolean.TYPE) { |
| 258 | boolean b = field.getBoolean(o); |
| 259 | rawByte(b ? 1 : 0); |
| 260 | } else { |
| 261 | throw new UnsupportedOperationException("Field '" + field.getName() |
| 262 | + "' has unsupported type: " + type); |
| 263 | } |
| 264 | } catch (IOException e) { |
| 265 | throw e; |
| 266 | } catch (Exception e) { |
| 267 | throw new IOException(e); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | private static Field[] getFields(Class clazz) { |
| 272 | ArrayList<Field> list = new ArrayList<Field>(); |
no test coverage detected