Package net.sourceforge.cardme.vcard.types

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


   
    SourceType source = new SourceType();
    source.setSource("Whatever");
    vcard.setSource(source);
   
    NType n = new NType();
    n.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    n.setCharset(Charset.forName("UTF-8"));
    n.setLanguage(LanguageType.EN);
    n.setFamilyName("DÖe");
//    n.setFamilyName("Doe");
    n.setGivenName("John");
    n.addHonorificPrefix("Mr.");
    n.addHonorificSuffix("I");
    n.addAdditionalName("Johny");
    vcard.setN(n);
   
    FNType fn = new FNType();
    fn.setFormattedName("John \"Johny\" Doe");
    fn.setCharset(Charset.forName("UTF-8"));
View Full Code Here


  }
 
  @Test
  public void testBuildNType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    NType n = new NType();
    n.setFamilyName("Doe");
    n.setGivenName("John");
    n.addAdditionalName("Johny");
    n.addHonorificPrefix("Mr.");
    n.addHonorificSuffix("I");
    vcard.setN(n);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
View Full Code Here

 
  private VCardImpl getSimpleVCard()
  {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John \"Johny\" Doe"));
    return vcard;
  }
View Full Code Here

 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_1() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("This is a note with normal text.");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
View Full Code Here

 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_2() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("This is a note with normal text.");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
View Full Code Here

 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_3() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("新中西里杨阿姨 some spaces ");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
View Full Code Here

 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_4() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("新中西里杨阿姨 some spaces ");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
View Full Code Here

   * @param vcard
   * @throws VCardParseException
   */
  private void parseNType(String group, String value, List<ParameterType> paramTypeList, VCardImpl vcard) throws VCardParseException {
    try {
      NType nType = new NType();
      parseParamTypes(nType, paramTypeList, value, VCardTypeName.N);
     
      if(nType.isQuotedPrintable()) {
        value = decodeQuotedPrintableValue(nType, value);
      }
     
      switch(compatMode)
      {
        case MS_OUTLOOK:
        {
          parseNTypeOutlook(nType, value);
          break;
        }

        default:
        {
          parseNTypeRFC(nType, value);
          break;
        }
      }
     
      if(group != null) {
        nType.setGroup(group);
      }

      vcard.setN(nType);
    }
    catch(Exception ex) {
View Full Code Here

    String result = writer.buildVCardString();
    return result;
  }

  protected void appyBasicName(VCardImpl vcard) {
    vcard.setN(new NType("User", "Example"));
    vcard.setFN(new FNType("User, Example"));
  }
View Full Code Here

      assertEquals("477343c8e6bf375a9bac1f96a5000837", f.getUid());
    }
   
    //N
    {
      NType f = vcard.getN();
      assertEquals("Doe", f.getFamilyName());
      assertEquals("John", f.getGivenName());
     
      List<String> it = f.getAdditionalNames();
      assertEquals(1, it.size());
      assertEquals("Richter, James", it.get(0));
     
      it = f.getHonorificPrefixes();
      assertEquals(1, it.size());
      assertEquals("Mr.", it.get(0));
     
      it = f.getHonorificSuffixes();
      assertEquals(1, it.size());
      assertEquals("Sr.", it.get(0));
    }
   
    //FN
    {
      FNType f = vcard.getFN();
      assertEquals("Mr. John Richter, James Doe Sr.", f.getFormattedName());
    }
   
    //NICKNAME
    {
      NicknameType f = vcard.getNicknames();
      List<String> it = f.getNicknames();
      assertEquals(1, it.size());
      assertEquals("Johny", it.get(0));
    }
   
    //ORG
    {
      OrgType f = vcard.getOrg();
      assertEquals("IBM", f.getOrgName());
     
      List<String> it = f.getOrgUnits();
      assertEquals(2, it.size());
      assertEquals("Accounting", it.get(0));
      assertEquals("Dungeon", it.get(1));
    }
   
    //TITLE
    {
      TitleType f = vcard.getTitle();
      assertEquals("Money Counter", f.getTitle());
    }
   
    //CATEGORIES
    {
      CategoriesType f = vcard.getCategories();
      List<String> it = f.getCategories();
      assertEquals(1, it.size());
      assertEquals("VIP", it.get(0));
    }
   
    //NOTE
    {
      List<NoteType> it = vcard.getNotes();
      assertEquals(1, it.size());
      NoteFeature f = it.get(0);
      assertEquals("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", f.getNote());
    }
   
    //EMAIL
    {
      List<EmailType> it = vcard.getEmails();
      assertEquals(1, it.size());
     
      EmailType f = it.get(0);
      assertEquals("john.doe@ibm.com", f.getEmail());
     
      List<EmailParamType> types = f.getParams();
      assertEquals(1, types.size());
      assertTrue(types.contains(EmailParamType.WORK));
     
      List<ExtendedParamType> xlist = f.getExtendedParams();
      assertEquals(1, xlist.size());
      assertEquals("X-COUCHDB-UUID", xlist.get(0).getTypeName());
      assertEquals("83a75a5d-2777-45aa-bab5-76a4bd972490".toUpperCase(), xlist.get(0).getTypeValue());
    }
   
    //ADR
    {
      List<AdrType> it = vcard.getAdrs();
      assertEquals(1, it.size());
     
      AdrType f = it.get(0);
      assertEquals("ASB-123", f.getPostOfficeBox());
      assertEquals("", f.getExtendedAddress());
      assertEquals("15 Crescent moon drive", f.getStreetAddress());
      assertEquals("Albaney", f.getLocality());
      assertEquals("New York", f.getRegion());
      assertEquals("12345", f.getPostalCode());
     
      /*
       * This would fail under normal circumstances because Evolution
       * assumes that only the first white-space character is discarded
       * as part of the folding and that the rest are preserved. If every
       * application followed the RFC standard then that would be so, but
       * it is not.
       */
      assertEquals("United States of America", f.getCountryName());
     
      List<AdrParamType> types = f.getParams();
      assertEquals(1, types.size());
      assertTrue(types.contains(AdrParamType.HOME));
    }
   
    //BDAY
    {
      BDayType f = vcard.getBDay();
      assertEquals(1980, f.getBirthday().get(Calendar.YEAR));
      assertEquals(Calendar.MARCH, f.getBirthday().get(Calendar.MONTH));
      assertEquals(22, f.getBirthday().get(Calendar.DAY_OF_MONTH));
    }
   
    //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, 32);
      c.set(Calendar.SECOND, 54);
      Calendar actual = f.getRevision();
      assertEquals(c.getTime(), actual.getTime());
    }
   
    //custom types
    {
      List<ExtendedType> it = vcard.getExtendedTypes();
      assertEquals(7, it.size());
     
      ExtendedType f = it.get(0);
      assertEquals("X-COUCHDB-APPLICATION-ANNOTATIONS", f.getExtendedName());
      assertEquals("{\"Evolution\":{\"revision\":\"2012-03-05T13:32:54Z\"}}", f.getExtendedValue());
     
      f = it.get(1);
      assertEquals("X-AIM", f.getExtendedName());
      assertEquals("johnny5@aol.com", f.getExtendedValue());
     
      List<ExtendedParamType> xParamTypes = f.getExtendedParams();
      assertEquals(2, xParamTypes.size());
     
      ExtendedParamType xParamType = xParamTypes.get(0);
      assertEquals("TYPE", xParamType.getTypeName());
      assertEquals("HOME", xParamType.getTypeValue());
     
      xParamType = xParamTypes.get(1);
      assertEquals("X-COUCHDB-UUID",xParamType.getTypeName());
      assertEquals("cb9e11fc-bb97-4222-9cd8-99820c1de454".toUpperCase(), xParamType.getTypeValue());
     
      f = it.get(2);
      assertEquals("X-EVOLUTION-FILE-AS", f.getExtendedName());
      assertEquals("Doe, John", f.getExtendedValue());
     
      f = it.get(3);
      assertEquals("X-EVOLUTION-SPOUSE", f.getExtendedName());
      assertEquals("Maria", f.getExtendedValue());

      f = it.get(4);
      assertEquals("X-EVOLUTION-MANAGER", f.getExtendedName());
      assertEquals("Big Blue", f.getExtendedValue());
     
      f = it.get(5);
      assertEquals("X-EVOLUTION-ASSISTANT", f.getExtendedName());
      assertEquals("Little Red", f.getExtendedValue());
     
      f = it.get(6);
      assertEquals("X-EVOLUTION-ANNIVERSARY", f.getExtendedName());
      assertEquals("1980-03-22", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

TOP

Related Classes of net.sourceforge.cardme.vcard.types.NType

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.