Package com.google.appengine.api.datastore

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


  }

  public void testFetch() {
    Entity e = new Entity(HasLob.class.getSimpleName());
    e.setProperty("bigString", new Text("a really big string"));
    e.setProperty("bigByteArray", new Blob("a really big byte array".getBytes()));
    Date now = new Date();
    e.setProperty("dateList", new Blob(SerializationManager.DEFAULT_SERIALIZATION_STRATEGY.serialize(
        Utils.newArrayList(now)).getBytes()));
    ds.put(e);

    beginTxn();
    HasLob pojo = em.find(HasLob.class, e.getKey());
View Full Code Here


  public void testInsert() throws EntityNotFoundException, IllegalAccessException {
    HasUnindexedPropertiesJPA pojo = new HasUnindexedPropertiesJPA();
    pojo.setUnindexedString("str");
    pojo.setUnindexedList(Utils.newArrayList("a", "b", "c"));
    pojo.setUnindexedText(new Text("unindexed text"));
    pojo.setUnindexedBlob(new Blob("unindexed blob".getBytes()));
    pojo.setText(new Text("text"));
    pojo.setBlob(new Blob("blob".getBytes()));

    beginTxn();
    em.persist(pojo);
    commitTxn();
View Full Code Here

        byte[] someBytes = { 107, 116, 104, 120, 98, 121, 101 };
        ShortBlob shortBlobValue = new ShortBlob(someBytes);
        e1.setProperty("shortBlobProp", shortBlobValue);

        Blob blobValue = new Blob(someBytes);
        e1.setProperty("blobProp", blobValue);

        e1.setProperty("booleanProp", true);

        // returned as a long by the datastore
View Full Code Here

                totalSize = 0;
            }
            if (put) {
                byte[] content = new byte[targetProto.encodingSize()];
                targetProto.outputTo(content, 0);
                putList.add(new Blob(content));
            } else {
                deleteList.add(key);
            }
            totalSize += size + DatastoreUtil.EXTRA_SIZE;
        }
View Full Code Here

  }

  AppEngineRecord(Key lookup, Revision revision, byte[] value) {
    this.key = makeKey(lookup, revision);
    this.revision = revision;
    this.value = new Blob(value);
  }
View Full Code Here

    assert registrationDate != null;
    if (publicKey.length < MIN_PUBLIC_KEY_LENGTH) {
      throw new IllegalArgumentException("Public key too short, must be at least"
          + MIN_PUBLIC_KEY_LENGTH + " but was (" + publicKey.length + ")");
    }
    this.publicKey = new Blob(publicKey);
    this.publicHash = new ShortBlob(publicHash);
    this.registrationDate = registrationDate;
    this.key = keyForUser(publicHash);
  }
View Full Code Here

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

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

    @Override
    public Blob decode(JsonReader reader, Blob defaultValue) {
        String text = reader.read();
        if(text != null){
            try{
                return new Blob(Base64.decode(text));
            } catch(Base64DecoderException e){
            }
        }
        return defaultValue;
    }
View Full Code Here

        else
            throw new ClassCastException(object.getClass().getName());
    }
    public final static java.io.Serializable SerializableFromObject(java.lang.Object object){
        if (object instanceof Blob){
            Blob blob = (Blob)object;
            try {
                ByteArrayInputStream buffer = new ByteArrayInputStream(blob.getBytes());
                ObjectInputStream in = new ObjectInputStream(buffer);
                return (java.io.Serializable)in.readObject();
            }
            catch (java.lang.ClassNotFoundException exc){
                throw new java.lang.RuntimeException(exc);
View Full Code Here

TOP

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

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.