Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.ShortBlob


  // TODO(maxr): Use TypeConversionUtils
  private Object pojoParamToDatastoreParam(Object param) {
    if (param instanceof Enum) {
      param = ((Enum) param).name();
    } else if (param instanceof byte[]) {
      param = new ShortBlob((byte[]) param);
    } else if (param instanceof Byte[]) {
      param = new ShortBlob(PrimitiveArrays.toByteArray(Arrays.asList((Byte[]) param)));
    } else if (param instanceof BigDecimal) {
      param = ((BigDecimal) param).doubleValue();
    } else if (param instanceof Character) {
      param = param.toString();
    }
View Full Code Here


  // TODO(maxr): Use TypeConversionUtils
  private Object pojoParamToDatastoreParam(Object param) {
    if (param instanceof Enum) {
      param = ((Enum) param).name();
    } else if (param instanceof byte[]) {
      param = new ShortBlob((byte[]) param);
    } else if (param instanceof Byte[]) {
      param = new ShortBlob(PrimitiveArrays.toByteArray(Arrays.asList((Byte[]) param)));
    } else if (param instanceof BigDecimal) {
      param = ((BigDecimal) param).doubleValue();
    } else if (param instanceof Character) {
      param = param.toString();
    }
View Full Code Here

        byte[] bValue = (byte[]) value;
        if (bValue != null) {
          if (bValue.length > DataTypeUtils.MAX_SHORT_BLOB_PROPERTY_LENGTH) {
            throw new RuntimeException("Bytes " + bValue.length + " exceeds the max supported length " + DataTypeUtils.MAX_SHORT_BLOB_PROPERTY_LENGTH);
          }
          value = new ShortBlob(bValue);
        }
      } else if (type.equals(EdmSimpleType.DATETIME)) {
        LocalDateTime dValue = (LocalDateTime) value;
        if (dValue != null) {
          value = dValue.toDateTime().toDate(); // TODO review
View Full Code Here

        }
        case BYTES: {
          if (value instanceof byte[]) {
            byte[] bytes = (byte[]) value;
            if (bytes.length > 500) {
              result = new ShortBlob(bytes);
            } else result = new Blob(bytes);
          }
          break;
        }
        case ENUM: {
View Full Code Here

     "some byte".getBytes() as ShortBlob
     * </code></pre>
     */
    public static <T> T asType(byte[] self, Class<T> blobClass) {
        if (blobClass == ShortBlob.class)
            return blobClass.cast(new ShortBlob(self));
        if (blobClass == Blob.class)
            return blobClass.cast(new Blob(self));
        return DefaultGroovyMethods.asType(self, blobClass);
    }
View Full Code Here

        testEqualityQueries(new IMHandle(IMHandle.Scheme.xmpp, "foo@foo.com"), new IMHandle(IMHandle.Scheme.xmpp, "bar@bar.com"));
    }

    @Test
    public void testShortBlobProperty() {
        testEqualityQueries(new ShortBlob("foo".getBytes()), new ShortBlob("bar".getBytes()));
    }
View Full Code Here

            asSet(1381363200000001L),   // 1 microsecond after 2013-10-10
            asSet(false),
            asSet(true),
            asSet(
                "sip sip",
                new ShortBlob("sip sip".getBytes()),
                new PostalAddress("sip sip"),
                new PhoneNumber("sip sip"),
                new Email("sip sip"),
                new IMHandle(IMHandle.Scheme.sip, "sip"),   // this is stored as "sip sip"
                new Link("sip sip"),
                new Category("sip sip"),
                new BlobKey("sip sip")
            ),
            asSet(
                "xmpp xmpp",
                new ShortBlob("xmpp xmpp".getBytes()),
                new PostalAddress("xmpp xmpp"),
                new PhoneNumber("xmpp xmpp"),
                new Email("xmpp xmpp"),
                new IMHandle(IMHandle.Scheme.xmpp, "xmpp"), // this is stored as "xmpp xmpp"
                new Link("xmpp xmpp"),
View Full Code Here

        Link[] linkDat = {new Link("http://www.hotmail.com"), new Link("http://www.google.com.com"),
            new Link("http://www.gmail.com")};
        Category[] categoryDat = {new Category("developer"), new Category("test"),
            new Category("manager")};
        Text[] textDat = {new Text("english"), new Text("chinese"), new Text("japanese")};
        ShortBlob[] byteString = {new ShortBlob("shortblob".getBytes()),
            new ShortBlob("shortText".getBytes()), new ShortBlob("shortImage".getBytes())};
        Blob[] blobDat = {new Blob("blobImage".getBytes()), new Blob("blobText".getBytes()),
            new Blob("blobData".getBytes())};

        clearData(kindName);
        List<Entity> elist = new ArrayList<Entity>();
View Full Code Here

        doEqOnlyFilter(kindName, "phoneProp", new PhoneNumber("650-321-7654"));
        doEqOnlyFilter(kindName, "addressProp", new PostalAddress("19451 Via Monte Rd. CA95070"));
        doEqOnlyFilter(kindName, "emailProp", new Email("somebody2@gmail.com"));
        doEqOnlyFilter(kindName, "linkProp", new Link("http://www.google.com.com"));
        doEqOnlyFilter(kindName, "categoryProp", new Category("test"));
        doEqOnlyFilter(kindName, "byteStrProp", new ShortBlob("shortText".getBytes()));
        String[] inDat = {"abc", "xyz"};
        doInFilter(kindName, "stringProp", inDat);
    }
View Full Code Here

    @Test
    public void testShortBlobType() {
        String propertyName = "byteStrProp";
        List<Entity> elist = doQuery(kindName, propertyName, ShortBlob.class, true);
        ShortBlob shortblob = (ShortBlob) elist.get(0).getProperty(propertyName);
        ShortBlob sameDat = (ShortBlob) elist.get(0).getProperty(propertyName);
        ShortBlob diffDat = (ShortBlob) elist.get(1).getProperty(propertyName);
        assertTrue(shortblob.equals(sameDat));
        assertFalse(shortblob.equals(diffDat));
        Arrays.equals("shortblob".getBytes(), shortblob.getBytes());
        assertEquals(0, shortblob.compareTo(sameDat));
        assertTrue(shortblob.compareTo(diffDat) != 0);
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.ShortBlob

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.