コード例 #1
0
 /**
  * Deserialize an {@link com.microsoft.windowsazure.services.table.client.EntityProperty}.
  *
  * @param property a datastore {@link
  *     com.microsoft.windowsazure.services.table.client.EntityProperty}.
  * @return the deserialized object.
  * @throws java.io.IOException
  * @throws ClassNotFoundException
  * @see com.microsoft.windowsazure.services.table.client.EntityProperty
  */
 public static Object deserialize(EntityProperty property)
     throws IOException, ClassNotFoundException {
   byte[] bytes = property.getValueAsByteArray();
   ByteArrayInputStream b = new ByteArrayInputStream(bytes);
   ObjectInputStream o = new ObjectInputStream(b);
   return o.readObject();
 }
コード例 #2
0
 /**
  * Retrieve the property value from an {@link
  * com.microsoft.windowsazure.services.table.client.EntityProperty}.
  *
  * @param entityProperty the property container
  * @param type type class of the property to be retrieved
  * @return the retrieved property
  */
 public static Object getPropertyValue(EntityProperty entityProperty, Class<?> type) {
   if (String.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsString();
   }
   if (Double.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsDouble();
   }
   if (Integer.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsInteger();
   }
   if (Long.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsLong();
   }
   if (Boolean.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsBoolean();
   }
   if (byte[].class.isAssignableFrom(type)) {
     return entityProperty.getValueAsByteArray();
   }
   if (Byte[].class.isAssignableFrom(type)) {
     return entityProperty.getValueAsByteObjectArray();
   }
   if (Date.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsDate();
   }
   if (UUID.class.isAssignableFrom(type)) {
     return entityProperty.getValueAsUUID();
   }
   throw new KunderaException("Unknown type " + type);
 }