Examples of ShortBlob


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

            book.setCopyrightYear(1939);
            Date authorBirthdate =
                new GregorianCalendar(1902, Calendar.FEBRUARY, 27).getTime();
            book.setAuthorBirthdate(authorBirthdate);

            ShortBlob coverIcon = new ShortBlob(new byte[] { 1, 2, 126, 127 });
            book.setCoverIcon(coverIcon);

            // stored as a multi-valued property
            book.setTags(Arrays.asList("depression", "grapes", "wrath"));
View Full Code Here

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

        Text textValue = new Text("text value, can be up to 1 megabyte");
        e1.setProperty("textProp", textValue);

        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);
View Full Code Here

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

    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

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

     * @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

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

     *            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

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

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

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

      // obj);
    } else if (obj instanceof Text) {
      Text text = (Text) obj;
      return text.getValue();
    } else if (obj instanceof ShortBlob) {
      ShortBlob sbl = (ShortBlob) obj;
      return Base64.encodeBytes(sbl.getBytes());
    } else if (obj instanceof Blob) {
      Blob sbl = (Blob) obj;
      return Base64.encodeBytes(sbl.getBytes());
    } else if (obj instanceof Link) {
      Link lnk = (Link) obj;
      return lnk.getValue();
    } else if (obj instanceof Category) {
      Category cat = (Category) obj;
View Full Code Here

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

          return parseUsingAppropriateLocale(args);
        }
      } else if (obj == Text.class) {
        return new Text(args);
      } else if (obj == ShortBlob.class) {
        return new ShortBlob(Base64.decode(args));
      } else if (obj == Blob.class) {
        return new Blob(Base64.decode(args));
      } else if (obj == Link.class) {
        return new Link(args);
      } else if (obj == Category.class) {
View Full Code Here

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

              if (k == -1) {
                break;
              }
              s.write(k);
            }
            return isShort ? new ShortBlob(s.toByteArray())
                : new Blob(s.toByteArray());
          } catch (IOException e) {
            Activator.log(e);
            return null;
          }
        }
        return null;
      }

      public String getName() {
        return "Set from file";
      }

      public String getDescription() {
        return "";
      }
    });
    OneLineTextElement<Object> m = new OneLineTextElement<Object>(binding) {

      private org.eclipse.swt.widgets.Text txt;

      private Composite newComposite;
      private GridLayout layout;
      private boolean packFlg = false;

      private AbstractBlobVisualizer[] viewers = new AbstractBlobVisualizer[] {
          new ImageBlobVisualizer(),
          new SerializableBlobVisualizer(new IUpdateBlob() {

            public void updateBlob(byte[] data) {
              Blob blob = new Blob(data);
              onValue(blob);
            }

          }, project) };
      private AbstractBlobVisualizer last;

      protected void onValue(Object value) {
        commitToBinding(value);
        initBlobViewer(value);
      }

      public void initBlobViewer(Object value) {
        if (value != null) {
          if (value instanceof Blob) {
            Blob blob = (Blob) value;
            if (last == null || !last.isSupported(blob)) {
              boolean flg = false;
              for (AbstractBlobVisualizer handler : viewers) {
                if (last != null) {
                  last.dispose();
                  last = null;
                }
                if (handler.isSupported(blob)) {
                  last = handler;
                  last.init(newComposite);
                  last.handleBlob(blob);
                  // if (packFlg ) {
                  // newComposite.getShell().pack(true);
                  // } else {
                  // packFlg = true;
                  // }
                  Display.getCurrent().asyncExec(
                      new Runnable() {

                        public void run() {
                          newComposite.getShell()
                              .pack(true);
                          newComposite.getShell()
                              .layout(true, true);
                        }
                      });

                  // newComposite.getShell().layout(true,
                  // true);
                  flg = true;
                  break;

                }
              }
              if (!flg) {
                // if (packFlg) {
                // newComposite.getShell().pack(true);
                // } else {
                // packFlg = true;
                // }
                // newComposite.getShell().layout(true, true);
                Display.getCurrent().asyncExec(new Runnable() {

                  public void run() {
                    newComposite.getShell().pack(true);
                    newComposite.getShell().layout(true,
                        true);
                  }
                });
              }
            } else {
              last.handleBlob(blob);
              // newComposite.getShell().pack(true);
              // newComposite.getShell().layout(true, true);
              Display.getCurrent().asyncExec(new Runnable() {

                public void run() {
                  newComposite.getShell().pack(true);
                  newComposite.getShell().layout(true, true);
                }
              });

            }
          }
        }
      }

      protected void doCommit(final IBinding binding2) {
        // commitToBinding(this.getgetValue());
      }

      protected org.eclipse.swt.widgets.Text internalCreateControl(
          Composite conComposite) {
        newComposite = new Composite(conComposite, SWT.INHERIT_FORCE);
        layout = new GridLayout(1, false);
        layout.horizontalSpacing = 0;
        layout.verticalSpacing = 2;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        newComposite.setLayout(layout);
        txt = super.internalCreateControl(newComposite);
        Object value = binding.getValue();
        if (value instanceof Blob) {
          initBlobViewer(value);
        }

        // txt.setVisible(false);

        return txt;
      }

      protected void installSelector(Composite conComposite) {
        super.installSelector(conComposite);
        Button button = new Button(conComposite, SWT.NONE);
        button.setText("Store to File");
        this.registerPart(button);
        button.addListener(SWT.Selection, new Listener() {

          public void handleEvent(Event event) {
            FileDialog dlg = new FileDialog(Display.getCurrent()
                .getActiveShell(), SWT.SAVE);
            dlg.setText("Export blob to file:");
            String open = dlg.open();
            if (open != null) {
              try {
                FileOutputStream fs = new FileOutputStream(open);
                try {
                  Object value = binding.getValue();
                  if (value instanceof Blob) {
                    Blob b = (Blob) value;
                    fs.write(b.getBytes());
                  }
                  if (value instanceof ShortBlob) {
                    ShortBlob b = (ShortBlob) value;
                    fs.write(b.getBytes());
                  }
                } finally {
                  fs.close();
                }
View Full Code Here

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

        m.setImHandleAttr2(new IMHandle(new URL("http://aim.com"), "network"));
        m.setLinkAttr(new Link("link"));
        m.setPhoneNumberAttr(new PhoneNumber("000-0000-0000"));
        m.setPostalAddressAttr(new PostalAddress("address"));
        m.setRatingAttr(new Rating(70));
        m.setShortBlobAttr(new ShortBlob("hello".getBytes()));
        m.setTextAttr(new Text("hello"));
        m.setEncryptedTextAttr(new Text("hello"));
        m.setUser1(new User("user@test.com", "authDomain"));
        m.setUser2(new User("user@test.com", "authDomain", "userId"));
        m.setUser3(new User(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.