Examples of PhotoType


Examples of com.tumblr.jumblr.types.Photo.PhotoType

    /**
     * Set the photo for this post
     * @param photo the photo to add
     */
    public void setPhoto(Photo photo) {
        PhotoType type = photo.getType();
        if (postType != null && !postType.equals(type)) {
            throw new IllegalArgumentException("Photos must all be the same type (source or data)");
        } else if (postType == PhotoType.SOURCE && pendingPhotos.size() > 0) {
            throw new IllegalArgumentException("Only one source URL can be provided");
        }
View Full Code Here

Examples of com.tumblr.jumblr.types.Photo.PhotoType

        details.put("type", "photo");
        details.put("link", link);
        details.put("caption", caption);

        if (pendingPhotos != null && pendingPhotos.size() > 0) {
            PhotoType type = pendingPhotos.get(0).getType();
            if (type == PhotoType.SOURCE) {
                details.put(type.getPrefix(), pendingPhotos.get(0).getDetail());
            } else if (type == PhotoType.FILE) {
                for (int i = 0; i < pendingPhotos.size(); i++) {
                    details.put(type.getPrefix() + "[" + i + "]", pendingPhotos.get(i).getDetail());
                }
            }
        }

        return details;
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

   
    NoteType note = new NoteType();
    note.setNote("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.");
    vcard.addNote(note);
   
    PhotoType photo1 = new PhotoType();
    photo1.setCompression(false);
    photo1.setEncodingType(EncodingType.BINARY);
    photo1.setImageMediaType(ImageMediaType.PNG);
    byte[] tuxPicture1 = Util.getFileAsBytes(new File("test/images/smallTux.png"));
    photo1.setPhoto(tuxPicture1);
    vcard.addPhoto(photo1);
   
    LogoType logo = new LogoType();
    logo.setCompression(true);
    logo.setEncodingType(EncodingType.BINARY);
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

    //PHOTO
    {
      List<PhotoType> it = vcard.getPhotos();
      assertEquals(1, it.size());
     
      PhotoType f = it.get(0);
      assertEquals(EncodingType.BINARY, f.getEncodingType());
      assertEquals(ImageMediaType.JPEG, f.getImageMediaType());
      assertEquals(32531, f.getPhoto().length);
    }
   
    //custom types
    {
      List<ExtendedType> it = vcard.getExtendedTypes();
      assertEquals(4, it.size());
     
      ExtendedType f = it.get(0);
      assertEquals("item2", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("_$!<AssistantPhone>!$_", f.getExtendedValue());

      f = it.get(1);
      assertEquals("item3", f.getGroup());
      assertEquals("X-ABADR", f.getExtendedName());
      assertEquals("Silicon Alley", f.getExtendedValue());
     
      f = it.get(2);
      assertEquals("item4", f.getGroup());
      assertEquals("X-ABADR", f.getExtendedName());
      assertEquals("Street 4, Building 6,\n Floor 8\nNew York\nUSA", f.getExtendedValue());
     
      f = it.get(3);
      assertEquals("item5", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("_$!<HomePage>!$_", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

    //PHOTO
    {
      List<PhotoType> it = vcard.getPhotos();
      assertEquals(1, it.size());
     
      PhotoType f = it.get(0);
      assertEquals(EncodingType.BINARY, f.getEncodingType());
      assertEquals(ImageMediaType.JPEG, f.getImageMediaType());
      assertEquals(7957, f.getPhoto().length);
    }
   
    //UID
    {
      UidType f = vcard.getUid();
      assertEquals("0e7602cc-443e-4b82-b4b1-90f62f99a199", f.getUid());
    }
   
    //GEO
    {
      GeoType f = vcard.getGeo();
      assertEquals(-2.6, f.getLatitude(), .01);
      assertEquals(3.4, f.getLongitude(), .01);
    }
   
    //CLASS
    {
      ClassType f = vcard.getSecurityClass();
      assertEquals("Public", f.getSecurityClass());
    }
   
    //PROFILE
    {
      ProfileType f = vcard.getProfile();
      assertEquals("VCard", f.getProfile());
    }
   
    //TZ
    {
      TzType f = vcard.getTz();
      assertEquals(1, f.getHourOffset());
      assertEquals(0, f.getMinuteOffset());
    }
   
    //LABEL
    {
      //This label does not get parsed because its parameter types
      //do not match any of the parameter types of any of the existing
      //addresses. In this case the parameter type PARCEL is extra from
      //the address.
      //
      //This is an issue with the way Labels and Addresses are defined in
      //the VCard RFC. There are 2 ways to go about it:
      //
      //1: An ADR may have only 1 LABEL associated to it, the LABEL directly under it
      //2: An ADR may have only 1 LABEL associated to it by parameter types. Only
      //   one ADR and LABEL without zero parameter types may hold an association.
      //
      // Cardme takes approach 2.
     
      /*
      List<LabelType> it = vcard.getLables();
      assertEquals(1, it.size());
     
      LabelType f = it.get(0);
      assertEquals("John Doe\nNew York, NewYork,\nSouth Crecent Drive,\nBuilding 5, floor 3,\nUSA", f.getLabel());
      List<LabelParamType> types = f.getParams();
      assertEquals(3, types.size());
      assertTrue(types.contains(LabelParamType.HOME));
      assertTrue(types.contains(LabelParamType.PARCEL));
      assertTrue(types.contains(LabelParamType.PREF));
      */
     
    }
   
    //SORT-STRING
    {
      SortStringFeature f = vcard.getSortString();
      assertEquals("JOHN", f.getSortString());
    }
   
    //ROLE
    {
      RoleFeature f = vcard.getRole();
      assertEquals("Counting Money", f.getRole());
    }
   
    //SOURCE
    {
      SourceFeature f = vcard.getSource();
      assertEquals("Whatever", f.getSource());
    }
   
    //MAILER
    {
      MailerFeature f = vcard.getMailer();
      assertEquals("Mozilla Thunderbird", f.getMailer());
    }
   
    //NAME
    {
      NameType f = vcard.getName();
      assertEquals("VCard for John Doe", f.getName());
    }
   
    //custom types
    {
      List<ExtendedType> it = vcard.getExtendedTypes();
      assertEquals(4, it.size());
     
      ExtendedType f = it.get(0);
      assertEquals("item2", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("_$!<HomePage>!$_", f.getExtendedValue());

      f = it.get(1);
      assertEquals("X-ABUID", f.getExtendedName());
      assertEquals("0E7602CC-443E-4B82-B4B1-90F62F99A199:ABPerson", f.getExtendedValue());
     
      f = it.get(2);
      assertEquals("X-GENERATOR", f.getExtendedName());
      assertEquals("Cardme Generator", f.getExtendedValue());
     
      f = it.get(3);
      assertEquals("X-LONG-STRING", f.getExtendedName());
      assertEquals("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

    //PHOTO
    {
      List<PhotoType> it = vcard.getPhotos();
      assertEquals(1, it.size());
     
      PhotoType f = it.get(0);
      assertEquals(EncodingType.BINARY, f.getEncodingType());
      assertEquals(ImageMediaType.JPEG, f.getImageMediaType());
      assertEquals(860, f.getPhoto().length);
    }
   
    //REV
    {
      RevType f = vcard.getRev();
      Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
      c.clear();
      c.set(Calendar.YEAR, 2012);
      c.set(Calendar.MONTH, Calendar.MARCH);
      c.set(Calendar.DAY_OF_MONTH, 5);
      c.set(Calendar.HOUR_OF_DAY, 13);
      c.set(Calendar.MINUTE, 19);
      c.set(Calendar.SECOND, 33);
      Calendar actual = f.getRevision();
      assertEquals(c.getTime(), actual.getTime());
    }
   
    //custom types
    {
      List<ExtendedType> it = vcard.getExtendedTypes();
      assertEquals(6, it.size());
     
      ExtendedType f = it.get(0);
      assertEquals("X-MS-OL-DEFAULT-POSTAL-ADDRESS", f.getExtendedName());
      assertEquals("2", f.getExtendedValue());
     
      f = it.get(1);
      assertEquals("X-MS-ANNIVERSARY", f.getExtendedName());
      assertEquals("20110113", f.getExtendedValue());
     
      f = it.get(2);
      assertEquals("X-MS-IMADDRESS", f.getExtendedName());
      assertEquals("johny5@aol.com", f.getExtendedValue());

      f = it.get(3);
      assertEquals("X-MS-OL-DESIGN", f.getExtendedName());
      assertEquals("<card xmlns=\"http://schemas.microsoft.com/office/outlook/12/electronicbusinesscards\" ver=\"1.0\" layout=\"left\" bgcolor=\"ffffff\"><img xmlns=\"\" align=\"tleft\" area=\"32\" use=\"photo\"/><fld xmlns=\"\" prop=\"name\" align=\"left\" dir=\"ltr\" style=\"b\" color=\"000000\" size=\"10\"/><fld xmlns=\"\" prop=\"org\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"title\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"dept\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"telwork\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"><label align=\"right\" color=\"626262\">Work</label></fld><fld xmlns=\"\" prop=\"telhome\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"><label align=\"right\" color=\"626262\">Home</label></fld><fld xmlns=\"\" prop=\"email\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"addrwork\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"addrhome\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"webwork\" align=\"left\" dir=\"ltr\" color=\"000000\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/><fld xmlns=\"\" prop=\"blank\" size=\"8\"/></card>", f.getExtendedValue());
      assertEquals(Charset.forName("UTF-8"), f.getCharset());
     
      f = it.get(4);
      assertEquals("X-MS-MANAGER", f.getExtendedName());
      assertEquals("Big Blue", f.getExtendedValue());
     
      f = it.get(5);
      assertEquals("X-MS-ASSISTANT", f.getExtendedName());
      assertEquals("Jenny", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

    //PHOTO
    {
      List<PhotoType> it = vcard.getPhotos();
      assertEquals(1, it.size());
     
      PhotoType f = it.get(0);
      assertEquals(EncodingType.BINARY, f.getEncodingType());
      assertEquals(null, f.getImageMediaType());
      assertEquals(18242, f.getPhoto().length);
    }
   
    //custom types
    {
      List<ExtendedType> it = vcard.getExtendedTypes();
      assertEquals(9, it.size());
     
      ExtendedType f = it.get(0);
      assertEquals("X-PHONETIC-FIRST-NAME", f.getExtendedName());
      assertEquals("Jon", f.getExtendedValue());
     
      f = it.get(1);
      assertEquals("X-PHONETIC-LAST-NAME", f.getExtendedName());
      assertEquals("Dow", f.getExtendedValue());
     
      f = it.get(2);
      assertEquals("item1", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("AssistantPhone", f.getExtendedValue());

      f = it.get(3);
      assertEquals("item2", f.getGroup());
      assertEquals("X-ABADR", f.getExtendedName());
      assertEquals("Silicon Alley", f.getExtendedValue());
     
      f = it.get(4);
      assertEquals("item3", f.getGroup());
      assertEquals("X-ABADR", f.getExtendedName());
      assertEquals("Street 4, Building 6,\nFloor 8\nNew York\nUSA", f.getExtendedValue());
     
      f = it.get(5);
      assertEquals("item4", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("_$!<HomePage>!$_", f.getExtendedValue());
     
      f = it.get(6);
      assertEquals("item5", f.getGroup());
      assertEquals("X-ABRELATEDNAMES", f.getExtendedName());
      assertEquals("Jenny", f.getExtendedValue());
     
      List<ExtendedParamType> xlist = f.getExtendedParams();
      assertEquals(1, xlist.size());
      assertEquals("TYPE", xlist.get(0).getTypeName());
      assertEquals("PREF", xlist.get(0).getTypeValue());
     
      f = it.get(7);
      assertEquals("item5", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("Spouse", f.getExtendedValue());
     
      f = it.get(8);
      assertEquals("X-ABUID", f.getExtendedName());
      assertEquals("6B29A774-D124-4822-B8D0-2780EC117F60:ABPerson", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

   * @param vcard
   * @throws VCardParseException
   */
  private void parsePhotoType(String group, String value, List<ParameterType> paramTypeList, VCardImpl vcard) throws VCardParseException {
    try {
      PhotoType photoType = new PhotoType();
      parseParamTypes(photoType, paramTypeList, value, VCardTypeName.PHOTO);
     
      if(photoType.isBinary()) {
        byte[] photoBytes = Base64Wrapper.decode(value);
        photoType.setCompression(false);
        photoType.setPhoto(photoBytes);
      }
      else {
        URI photoUri = new URI(value);
        photoType.setPhotoURI(photoUri);
      }
     
      if(group != null) {
        photoType.setGroup(group);
      }
     
      vcard.addPhoto(photoType);
    }
    catch(Exception ex) {
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

  @Test
  public void testLinkedProfileImage() throws URISyntaxException, VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    appyBasicName(vcard);
   
    PhotoType photo = new PhotoType();
    photo.setPhotoURI(new URI("http://www.google.com/intl/en_com/images/srpr/logo3w.png"));
    photo.setImageMediaType(ImageMediaType.PNG);
    vcard.addPhoto(photo);
    String result = getSerializedString(vcard);
   
    //Changed path to full URI as per http://www.ietf.org/rfc/rfc2426.txt, section 3.1.4
    assertTrue(result.contains("PHOTO;VALUE=URI:http://www.google.com/intl/en_com/images/srpr/logo3w.png"));
View Full Code Here

Examples of net.sourceforge.cardme.vcard.types.PhotoType

  @Test
  public void testProfileImage() throws IOException, VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    appyBasicName(vcard);
   
    PhotoType photo = new PhotoType();
    photo.setImageMediaType(ImageMediaType.PNG);
    photo.setEncodingType(EncodingType.BASE64);
    photo.setCompression(true);

    byte[] tuxPicture1 = Util.getFileAsBytes(new File("test/images/smallTux.png"));
    photo.setPhoto(tuxPicture1);
   
    vcard.addPhoto(photo);
    String result = getSerializedString(vcard);
    assertTrue(result.contains("PHOTO;ENCODING=BASE64;TYPE=PNG:"));
  }
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.