Package com.google.appengine.api.datastore

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


    entity.setProperty("characterArray", Utils.newArrayList((long) 'c', (long) 'd'));
    entity.setProperty("primitiveFloatArray", Utils.newArrayList((double) 1.01f, (double) 1.02f));
    entity.setProperty("floatArray", Utils.newArrayList((double) 1.03f, (double) 1.04f));
    entity.setProperty("primitiveDoubleArray", Utils.newArrayList(2.01d, 2.02d));
    entity.setProperty("doubleArray", Utils.newArrayList(2.03d, 2.04d));
    entity.setProperty("primitiveByteArray", new ShortBlob(new byte[] {0xb, 0xc}));
    entity.setProperty("byteArray", new ShortBlob(new byte[] {0xe, 0xf}));
    entity.setProperty("primitiveBooleanArray", Utils.newArrayList(true, false));
    entity.setProperty("booleanArray", Utils.newArrayList(false, true));
    entity.setProperty("dateArray", Utils.newArrayList(DATE1, DATE2));
    entity.setProperty("ksEnumArray", Utils.newArrayList(
        KitchenSinkEnum.TWO.name(), KitchenSinkEnum.ONE.name()));
    entity.setProperty("bigDecimalArray", Utils.newArrayList(
        BigDecimals.toSortableString(new BigDecimal("3.4444")),
        BigDecimals.toSortableString(new BigDecimal("4.3333"))));
    entity.setProperty("userArray", Utils.newArrayList(USER1, USER2));
    entity.setProperty("blobArray", Utils.newArrayList(BLOB1, BLOB2));
    entity.setProperty("textArray", Utils.newArrayList(TEXT1, TEXT2));
    entity.setProperty("linkArray", Utils.newArrayList(LINK1, LINK2));
    entity.setProperty("shortBlobArray", Utils.newArrayList(SHORTBLOB1, SHORTBLOB2));
    entity.setProperty("blobKeyArray", Utils.newArrayList(BLOBKEY1, BLOBKEY2));

    entity.setProperty("strList", Utils.newArrayList("p", "q"));
    entity.setProperty("integerList", Utils.newArrayList(11L, 12L));
    entity.setProperty("longList", Utils.newArrayList(13L, 14L));
    entity.setProperty("shortList", Utils.newArrayList((long) (short) 15, (long) (short) 16));
    entity.setProperty("byteList", new ShortBlob(new byte[] {(byte) 0x8, (byte) 0x9}));
    entity.setProperty("charList", Utils.newArrayList((long) 'q', (long) 'r'));
    entity.setProperty("doubleList", Utils.newArrayList(22.44d, 23.55d));
    entity.setProperty("floatList", Utils.newArrayList((double) 23.44f, (double) 24.55f));
    entity.setProperty("booleanList", Utils.newArrayList(true, false));
    entity.setProperty("dateList", Utils.newArrayList(DATE1, DATE2));
View Full Code Here


  }

  public void testFilterByShortBlob() {
    Entity e = new Entity(HasBytesJDO.class.getSimpleName());
    e.setProperty("onePrimByte", 8L);
    e.setProperty("shortBlob", new ShortBlob("short blob".getBytes()));
    ds.put(null, e);
    Query q = pm.newQuery("select from " + HasBytesJDO.class.getName() + " where shortBlob == p1");
    q.declareParameters(ShortBlob.class.getName() + " p1");
    List<HasBytesJDO> result =
        (List<HasBytesJDO>) q.execute(new ShortBlob("short blob".getBytes()));
    assertEquals(1, result.size());
  }
View Full Code Here

  }

  public void testFilterByPrimitiveByteArray() {
    Entity e = new Entity(HasBytesJDO.class.getSimpleName());
    e.setProperty("onePrimByte", 8L);
    e.setProperty("primBytes", new ShortBlob("short blob".getBytes()));
    ds.put(null, e);
    Query q = pm.newQuery("select from " + HasBytesJDO.class.getName() + " where primBytes == p1");
    q.declareParameters("byte[] p1");
    List<HasBytesJDO> result = (List<HasBytesJDO>) q.execute("short blob".getBytes());
    assertEquals(1, result.size());
View Full Code Here

  }

  public void testFilterByByteArray() {
    Entity e = new Entity(HasBytesJDO.class.getSimpleName());
    e.setProperty("onePrimByte", 8L);
    e.setProperty("bytes", new ShortBlob("short blob".getBytes()));
    ds.put(null, e);
    Query q = pm.newQuery("select from " + HasBytesJDO.class.getName() + " where bytes == p1");
    q.declareParameters("Byte[] p1");
    List<HasBytesJDO> result = (List<HasBytesJDO>) q.execute(
        PrimitiveArrays.asList("short blob".getBytes()).toArray(new Byte[0]));
View Full Code Here

  private Object pojoParamToDatastoreParam(Object param, Class type) {
    if (param instanceof Enum) {
      // TODO Cater for persisting Enum as ordinal. Need the mmd of the other side
      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) {
      if (type.equals(Double.class)|| type.equals(double.class)
          ||type.equals(Float.class)|| type.equals(float.class)) {
        param = ((BigDecimal) param).doubleValue();
      }
View Full Code Here

   *
   * @return A {@code ShortBlob} representing the byte array.
   */
  private ShortBlob convertByteArrayToShortBlob(Object value) {
    if (value.getClass().getComponentType().isPrimitive()) {
      return new ShortBlob((byte[]) value);
    } else {
      return convertByteCollectionToShortBlob(Arrays.asList((Byte[]) value));
    }
  }
View Full Code Here

   * @param value The pojo collection.
   *
   * @return A {@code ShortBlob} representing the byte collection.
   */
  private ShortBlob convertByteCollectionToShortBlob(Collection<Byte> value) {
    return new ShortBlob(PrimitiveArrays.toByteArray(value));
  }
View Full Code Here

  }

  public void testFilterByShortBlob() {
    Entity e = new Entity(HasBytesJPA.class.getSimpleName());
    e.setProperty("onePrimByte", 8L);
    e.setProperty("shortBlob", new ShortBlob("short blob".getBytes()));
    ds.put(e);
    Query
        q =
        em.createQuery("select from " + HasBytesJPA.class.getName() + " c" + " where shortBlob = :p1");
    q.setParameter("p1", new ShortBlob("short blob".getBytes()));
    List<HasBytesJPA> result = (List<HasBytesJPA>) q.getResultList();
    assertEquals(1, result.size());
  }
View Full Code Here

  }

  public void testFilterByPrimitiveByteArray() {
    Entity e = new Entity(HasBytesJPA.class.getSimpleName());
    e.setProperty("onePrimByte", 8L);
    e.setProperty("primBytes", new ShortBlob("short blob".getBytes()));
    ds.put(e);
    Query
        q =
        em.createQuery("select from " + HasBytesJPA.class.getName() + " c" + " where primBytes = :p1");
    q.setParameter("p1", "short blob".getBytes());
View Full Code Here

  }

  public void testFilterByByteArray() {
    Entity e = new Entity(HasBytesJPA.class.getSimpleName());
    e.setProperty("onePrimByte", 8L);
    e.setProperty("bytes", new ShortBlob("short blob".getBytes()));
    ds.put(e);
    Query q = em.createQuery("select from " + HasBytesJPA.class.getName() + " c" + " where bytes = :p1");
    q.setParameter("p1", PrimitiveArrays.asList("short blob".getBytes()).toArray(new Byte[0]));
    List<HasBytesJPA> result = (List<HasBytesJPA>) q.getResultList();
    assertEquals(1, result.size());
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.