} else if (obj instanceof Date) {
result = new DatePropertyInfo((Date)obj);
} else if (obj instanceof Email) {
result = new StringPropertyInfo(((Email) obj).getEmail());
} else if (obj instanceof Long) { // short, int, long are all stored as long value
result = new LongPropertyInfo((Long)obj);
} else if (obj instanceof Double) {// float and double are both stored as 64-bit double precision, IEEE 754
result = new DoublePropertyInfo((Double)obj);
} else if (obj instanceof BigDecimal) { // most processed fields will be bigdecimal
BigDecimal bd = (BigDecimal) obj;
if ((double)bd.longValue() == bd.doubleValue()) { // try to make it long if there is no lose of precision
result = new LongPropertyInfo(bd.longValue());
} else {
result = new DoublePropertyInfo(bd.doubleValue());
}
} else if (obj instanceof User) {
User user = (User)obj;
result = new UserPropertyInfo(user.getAuthDomain(), user.getEmail(),
user.getFederatedIdentity(), user.getUserId(), user.getNickname());
} else if (obj instanceof GeoPt) {
float latitude = ((GeoPt) obj).getLatitude();
float longitude = ((GeoPt) obj).getLongitude();
result = new GeoPtPropertyInfo(latitude, longitude);
} else if (obj instanceof ShortBlob) {
result = new StringPropertyInfo(new String(((ShortBlob) obj).getBytes()));
} else if (obj instanceof Blob) {
Blob b = (Blob) obj;
String fileName = index == null ? propertyName : propertyName + "[" + index + "]";
FileDownloadPath downloadPath = AutoBeanUtil.newFileDownloadPath(
FileDownloadPath.Type.DATASTORE_BLOB, keyString, propertyName, index, fileName, b.getBytes().length);
String pathStr = AutoBeanUtil.encode(FileDownloadPath.class, downloadPath);
result = new BlobPropertyInfo(b.getBytes().length, pathStr);
} else if (obj instanceof BlobStringWrapper) { // user has edited a blob, in string form, it's not in memcache, nor datastore
result = new BlobPropertyInfo(((BlobStringWrapper) obj).getRawString().getBytes());
} else if (obj instanceof BlobFileRefWrapper) { // user has uploaded the blob, but still stay in memcache
FileDownloadPath path = ((BlobFileRefWrapper) obj).getRef();
String pathStr = AutoBeanUtil.encode(FileDownloadPath.class, path);
result = new BlobPropertyInfo(path.getSize(), pathStr);
} else if (obj instanceof BlobKey) {
String blobKeyString = ((BlobKey) obj).getKeyString();
result = new BlobKeyPropertyInfo(blobKeyString);
} else if (obj instanceof Key) {
result = convert((Key)obj);
} else if (obj instanceof Link) {
result = new StringPropertyInfo(((Link) obj).getValue());
} else if (obj instanceof IMHandle) {
String protocol = ((IMHandle) obj).getProtocol();
String address = ((IMHandle) obj).getAddress();
result = new IMHandlePropertyInfo(protocol, address);
} else if (obj instanceof PostalAddress) {
result = new StringPropertyInfo(((PostalAddress) obj).getAddress());
} else if (obj instanceof Rating) {
result = new LongPropertyInfo(((Rating) obj).getRating());
} else if (obj instanceof PhoneNumber) {
result = new StringPropertyInfo(((PhoneNumber) obj).getNumber());
} else if (obj instanceof Text) {
Text t = (Text)obj;
String fileName = index == null ? propertyName : propertyName + "[" + index + "]";