Package org.yaac.shared.property

Examples of org.yaac.shared.property.StringPropertyInfo


    if (obj == null) {
      result = new NullPropertyInfo();
    } else if (obj instanceof Boolean) {
      result = new BooleanPropertyInfo((Boolean)obj);
    } else if (obj instanceof String) {
      result = new StringPropertyInfo((String)obj);
    } else if (obj instanceof Category) {
      result = new StringPropertyInfo(((Category) obj).getCategory());
    } 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 + "]";
      FileDownloadPath downloadPath = AutoBeanUtil.newFileDownloadPath(
          FileDownloadPath.Type.DATASTORE_TEXT, keyString, propertyName, index,
View Full Code Here


    e.setProperty("p_1", 1L);
    e.setProperty("p_2", "abc");
    e.setProperty("p_3", true);
   
    List<PropertyUpdateInfo> changes = newArrayList(
        new PropertyUpdateInfo("p_1", new LongPropertyInfo(1l)).setNewInfo(new StringPropertyInfo("sssss")));
   
    Entity actual = service.applyChange(e, changes);
   
    // key is not changed
    assertEquals("kind_a", actual.getKey().getKind());
View Full Code Here

   
    Key key = KeyFactory.createKey("kind_a", "name_1");
    DatastoreServiceFactory.getDatastoreService().put(new Entity(key));
    String keyString = KeyFactory.keyToString(key);
   
    assertEquals(new StringPropertyInfo("str"), service.parsePropertyExp(keyString, "'str'", null));
    assertEquals(new LongPropertyInfo(10l), service.parsePropertyExp(keyString, "10", null));
    assertEquals(new DoublePropertyInfo(10.5D), service.parsePropertyExp(keyString, "10.5", null));
    assertEquals(new LongPropertyInfo(10l), service.parsePropertyExp(keyString, "long(10.5)", null));
    assertEquals(new DoublePropertyInfo(10D), service.parsePropertyExp(keyString, "double(10)", null));
    assertEquals(new ListPropertyInfo().add(new LongPropertyInfo(10)).add(new StringPropertyInfo("abc")),
        service.parsePropertyExp(keyString, "list(10, 'abc')", new ArrayList<String>()));
  }
View Full Code Here

TOP

Related Classes of org.yaac.shared.property.StringPropertyInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.