Package com.google.appengine.api.datastore

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


  @Override
  public EvaluationResult evaluate(ProcessDataRecord record) {
    EvaluationResult r = ops.get(0).evaluate(record);
   
    if (r.getPayload() instanceof String) {
      ShortBlob val = new ShortBlob(((String) r.getPayload()).getBytes());
      return new EvaluationResult(val, r)
    } else {
      return r.withWarning(ErrorCode.W131);
    }
  }
View Full Code Here


        RandomStringUtils.randomAlphanumeric(10).getBytes()[0]));
      entity.setProperty("Blob", new Blob(RandomStringUtils
        .randomAlphanumeric(1000)
        .getBytes()));
      entity.setProperty("Text", new Text(RandomStringUtils.randomAlphanumeric(1000)));
      entity.setProperty("ShortBlob", new ShortBlob(RandomStringUtils
        .randomAlphanumeric(500)
        .getBytes()));
      entity.setProperty("BlobKey", new BlobKey(RandomStringUtils.randomAlphanumeric(10)));

      // Make Null Property
View Full Code Here

        RandomStringUtils.randomAlphanumeric(10).getBytes()[0]));
      entity.setProperty("Blob", new Blob(RandomStringUtils
        .randomAlphanumeric(1000)
        .getBytes()));
      entity.setProperty("Text", new Text(RandomStringUtils.randomAlphanumeric(1000)));
      entity.setProperty("ShortBlob", new ShortBlob(RandomStringUtils
        .randomAlphanumeric(500)
        .getBytes()));
      entity.setProperty("BlobKey", new BlobKey(RandomStringUtils.randomAlphanumeric(10)));

      // Make Null Property
View Full Code Here

      .randomAlphanumeric(1000)
      .getBytes()));
    entity.setProperty(GbProperty.TEXT, new Text(RandomStringUtils.randomAlphanumeric(1000)));
    entity.setProperty(GbProperty.DATE, new Date(RandomUtils.nextLong()));
    entity.setProperty(GbProperty.LINK, new Link(RandomStringUtils.randomAlphanumeric(30)));
    entity.setProperty(GbProperty.SHORT_BLOB, new ShortBlob(RandomStringUtils
      .randomAlphanumeric(500)
      .getBytes()));
    entity.setProperty(
      GbProperty.GEO_PT,
      new GeoPt(new Float(new Integer(RandomStringUtils.randomNumeric(2)) - 9), new Float(
View Full Code Here

     * @param value
     *            the array of bytes
     * @return a short blob
     */
    protected ShortBlob bytesToShortBlob(byte[] value) {
        return value != null ? new ShortBlob(value) : null;
    }
View Full Code Here

     *            the serializable object
     * @return a short blob
     */
    protected ShortBlob serializableToShortBlob(Object value) {
        return value != null
            ? new ShortBlob(ByteUtil.toByteArray(value))
            : null;
    }
View Full Code Here

    pojo.setByteList(PrimitiveArrays.asList("byte list".getBytes()));
    pojo.setByteSet(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())));
    pojo.setByteCollection(PrimitiveArrays.asList("byte collection".getBytes()));
    pojo.setOnePrimByte(Integer.valueOf(1).byteValue());
    pojo.setOneByte(Integer.valueOf(2).byteValue());
    pojo.setShortBlob(new ShortBlob("short blob".getBytes()));
    pojo.setSerializedPrimBytes("serialized prim bytes".getBytes());
    pojo.setSerializedBytes(PrimitiveArrays.asList("serialized bytes".getBytes()).toArray(new Byte[5]));
    pojo.setSerializedByteList(PrimitiveArrays.asList("serialized byte list".getBytes()));
    pojo.setSerializedByteSet(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes())));

    beginTxn();
    em.persist(pojo);
    commitTxn();

    Entity e = ds.get(KeyFactory.createKey(HasBytesJPA.class.getSimpleName(), pojo.getId()));
    assertEquals(new ShortBlob("prim bytes".getBytes()), e.getProperty("primBytes"));
    assertEquals(new ShortBlob("bytes".getBytes()), e.getProperty("bytes"));
    assertEquals(new ShortBlob("byte list".getBytes()), e.getProperty("byteList"));
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())),
                 new HashSet<Byte>(PrimitiveArrays.asList(
                     ((ShortBlob) e.getProperty("byteSet")).getBytes())));
    assertEquals(new ShortBlob("byte collection".getBytes()), e.getProperty("byteCollection"));
    assertEquals(1L, e.getProperty("onePrimByte"));
    assertEquals(2L, e.getProperty("oneByte"));
    assertEquals(new ShortBlob("short blob".getBytes()), e.getProperty("shortBlob"));
    assertEquals(new Blob("serialized prim bytes".getBytes()), e.getProperty("serializedPrimBytes"));
    assertEquals(new Blob("serialized bytes".getBytes()), e.getProperty("serializedBytes"));
    assertEquals(SS.serialize(PrimitiveArrays.asList("serialized byte list".getBytes())),
                 e.getProperty("serializedByteList"));
    assertEquals(SS.serialize(new HashSet<Byte>(PrimitiveArrays.asList(
View Full Code Here

        "serialized byte set".getBytes()))), e.getProperty("serializedByteSet"));
  }

  public void testFetch() {
    Entity e = new Entity(HasBytesJPA.class.getSimpleName());
    e.setProperty("primBytes", new ShortBlob("prim bytes".getBytes()));
    e.setProperty("bytes", new ShortBlob("bytes".getBytes()));
    e.setProperty("byteList", new ShortBlob("byte list".getBytes()));
    e.setProperty("byteSet", new ShortBlob("byte set".getBytes()));
    e.setProperty("byteCollection", new ShortBlob("byte collection".getBytes()));
    e.setProperty("onePrimByte", 1L);
    e.setProperty("oneByte", 2L);
    e.setProperty("shortBlob", new ShortBlob("short blob".getBytes()));
    e.setProperty("serializedPrimBytes", new Blob("serialized prim bytes".getBytes()));
    e.setProperty("serializedBytes", new Blob("serialized bytes".getBytes()));
    e.setProperty("serializedByteList", SS.serialize(PrimitiveArrays.asList("serialized byte list".getBytes())));
    e.setProperty("serializedByteSet", SS.serialize(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes()))));

    ds.put(e);

    beginTxn();
    HasBytesJPA pojo = em.find(HasBytesJPA.class, e.getKey());
    assertTrue(Arrays.equals("prim bytes".getBytes(), pojo.getPrimBytes()));
    assertEquals(PrimitiveArrays.asList("bytes".getBytes()), Arrays.asList(pojo.getBytes()));
    assertEquals(PrimitiveArrays.asList("byte list".getBytes()), pojo.getByteList());
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())), pojo.getByteSet());
    assertEquals(PrimitiveArrays.asList("byte collection".getBytes()), pojo.getByteCollection());
    assertEquals(Integer.valueOf(1).byteValue(), pojo.getOnePrimByte());
    assertEquals(Integer.valueOf(2).byteValue(), pojo.getOneByte().byteValue());
    assertEquals(new ShortBlob("short blob".getBytes()), pojo.getShortBlob());
    assertEquals(new Blob("serialized prim bytes".getBytes()), new Blob(pojo.getSerializedPrimBytes()));
    assertEquals(new Blob("serialized bytes".getBytes()),
                 new Blob(PrimitiveArrays.toByteArray(Arrays.asList(pojo.getSerializedBytes()))));
    assertEquals(PrimitiveArrays.asList("serialized byte list".getBytes()),
                 pojo.getSerializedByteList());
View Full Code Here

    pojo.setByteList(PrimitiveArrays.asList("byte list".getBytes()));
    pojo.setByteSet(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())));
    pojo.setByteCollection(PrimitiveArrays.asList("byte collection".getBytes()));
    pojo.setOnePrimByte(Integer.valueOf(1).byteValue());
    pojo.setOneByte(Integer.valueOf(2).byteValue());
    pojo.setShortBlob(new ShortBlob("short blob".getBytes()));
    pojo.setSerializedPrimBytes("serialized prim bytes".getBytes());
    pojo.setSerializedBytes(PrimitiveArrays.asList("serialized bytes".getBytes()).toArray(new Byte[5]));
    pojo.setSerializedByteList(PrimitiveArrays.asList("serialized byte list".getBytes()));
    pojo.setSerializedByteSet(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes())));

    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();

    Entity e = ds.get(KeyFactory.createKey(HasBytesJDO.class.getSimpleName(), pojo.getId()));
    assertEquals(new ShortBlob("prim bytes".getBytes()), e.getProperty("primBytes"));
    assertEquals(new ShortBlob("bytes".getBytes()), e.getProperty("bytes"));
    assertEquals(new ShortBlob("byte list".getBytes()), e.getProperty("byteList"));
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())),
                 new HashSet<Byte>(PrimitiveArrays.asList(
                     ((ShortBlob) e.getProperty("byteSet")).getBytes())));
    assertEquals(new ShortBlob("byte collection".getBytes()), e.getProperty("byteCollection"));
    assertEquals(1L, e.getProperty("onePrimByte"));
    assertEquals(2L, e.getProperty("oneByte"));
    assertEquals(new ShortBlob("short blob".getBytes()), e.getProperty("shortBlob"));
    assertEquals(new Blob("serialized prim bytes".getBytes()), e.getProperty("serializedPrimBytes"));
    assertEquals(new Blob("serialized bytes".getBytes()), e.getProperty("serializedBytes"));
    assertEquals(SS.serialize(PrimitiveArrays.asList("serialized byte list".getBytes())),
                 e.getProperty("serializedByteList"));
    assertEquals(SS.serialize(new HashSet<Byte>(PrimitiveArrays.asList(
View Full Code Here

        "serialized byte set".getBytes()))), e.getProperty("serializedByteSet"));
  }

  public void testFetch() {
    Entity e = new Entity(HasBytesJDO.class.getSimpleName());
    e.setProperty("primBytes", new ShortBlob("prim bytes".getBytes()));
    e.setProperty("bytes", new ShortBlob("bytes".getBytes()));
    e.setProperty("byteList", new ShortBlob("byte list".getBytes()));
    e.setProperty("byteSet", new ShortBlob("byte set".getBytes()));
    e.setProperty("byteCollection", new ShortBlob("byte collection".getBytes()));
    e.setProperty("onePrimByte", 1L);
    e.setProperty("oneByte", 2L);
    e.setProperty("shortBlob", new ShortBlob("short blob".getBytes()));
    e.setProperty("serializedPrimBytes", new Blob("serialized prim bytes".getBytes()));
    e.setProperty("serializedBytes", new Blob("serialized bytes".getBytes()));
    e.setProperty("serializedByteList", SS.serialize(PrimitiveArrays.asList("serialized byte list".getBytes())));
    e.setProperty("serializedByteSet", SS.serialize(new HashSet<Byte>(PrimitiveArrays.asList("serialized byte set".getBytes()))));

    ds.put(e);

    beginTxn();
    HasBytesJDO pojo = pm.getObjectById(HasBytesJDO.class, e.getKey());
    assertTrue(Arrays.equals("prim bytes".getBytes(), pojo.getPrimBytes()));
    assertEquals(PrimitiveArrays.asList("bytes".getBytes()), Arrays.asList(pojo.getBytes()));
    assertEquals(PrimitiveArrays.asList("byte list".getBytes()), pojo.getByteList());
    assertEquals(new HashSet<Byte>(PrimitiveArrays.asList("byte set".getBytes())), pojo.getByteSet());
    assertEquals(PrimitiveArrays.asList("byte collection".getBytes()), pojo.getByteCollection());
    assertEquals(Integer.valueOf(1).byteValue(), pojo.getOnePrimByte());
    assertEquals(Integer.valueOf(2).byteValue(), pojo.getOneByte().byteValue());
    assertEquals(new ShortBlob("short blob".getBytes()), pojo.getShortBlob());
    assertEquals(new Blob("serialized prim bytes".getBytes()), new Blob(pojo.getSerializedPrimBytes()));
    assertEquals(new Blob("serialized bytes".getBytes()),
                 new Blob(PrimitiveArrays.toByteArray(Arrays.asList(pojo.getSerializedBytes()))));
    assertEquals(PrimitiveArrays.asList("serialized byte list".getBytes()),
                 pojo.getSerializedByteList());
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.