Examples of LabelType


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

    .addParam(AdrParamType.PREF)
    .addExtendedParam(new ExtendedParamType("CUSTOM-PARAM-TYPE", VCardTypeName.ADR))
    .addExtendedParam(new ExtendedParamType("CUSTOM-PARAM-TYPE", "WITH-CUSTOM-VALUE", VCardTypeName.ADR));
   

    LabelType labelForAddress1 = new LabelType();
    labelForAddress1.setCharset("UTF-8");
    labelForAddress1.addParam(LabelParamType.HOME)
    .addParam(LabelParamType.PARCEL)
    .addParam(LabelParamType.PREF)
    .setLabel("John Doe\nNew York, NewYork,\nSouth Crecent Drive,\nBuilding 5, floor 3,\nUSA");
   
    address1.setLabel(labelForAddress1);
View Full Code Here

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

   * @param vcard
   * @throws VCardParseException
   */
  private void parseLabelType(String group, String value, List<ParameterType> paramTypeList, VCardImpl vcard) throws VCardParseException {
    try {
      LabelType labelType = new LabelType();
      parseParamTypes(labelType, paramTypeList, value, VCardTypeName.LABEL);
     
      if(labelType.isQuotedPrintable()) {
        value = decodeQuotedPrintableValue(labelType, value);
      }
     
      labelType.setLabel(VCardUtils.unescapeString(value));
     
      if(group != null) {
        labelType.setGroup(group);
      }
     
      boolean match = false;
      List<AdrType> adrList = vcard.getAdrs();
     
      for(AdrType adrType : adrList) {
        if(!match) {
          //Get address and all its parameter and extended parameter types
          List<AdrParamType> aPrmList = adrType.getParams();
          List<ExtendedParamType> aXPrmList = adrType.getExtendedParams();
         
          List<LabelParamType> lPrmList = labelType.getParams();
          List<ExtendedParamType> lXPrmList = labelType.getExtendedParams();
         
         
          //See how many address parameter types match each label parameter type
          int paramsMatched = 0;
          for(LabelParamType labelParamType : lPrmList) {
            for(AdrParamType adrParamType : aPrmList) {
              if(adrParamType.getType().equals(labelParamType.getType())) {
                paramsMatched++;
              }
            }
          }
         
          //See how many extended address parameter types match each extended label parameter type
          int xparamsMatched = 0;
          for(ExtendedParamType labelXParamType : lXPrmList) {
            for(ExtendedParamType adrXParamType : aXPrmList) {
              if(adrXParamType.hasTypeValue()) {
                if(adrXParamType.getTypeName().equals(labelXParamType.getTypeName()) &&
                   adrXParamType.getTypeValue().equals(labelXParamType.getTypeValue())) {
                  xparamsMatched++;
                }
              }
              else {
                if(adrXParamType.getTypeName().equals(labelXParamType.getTypeName())) {
                  xparamsMatched++;
                }
              }
            }
          }
         
          //If the number of matching parameter types match between the label
          //and the address then this label belongs to the respective address.
          if(paramsMatched == labelType.getParamSize() && xparamsMatched == labelType.getExtendedParamSize()) {
            //Only set the label on the address if it does not already have one
           
            if(!adrType.hasLabel()) {
              adrType.setLabel(labelType);
            }
            else {
              vcard.addError("Label with duplicate parameter types was detected and ignored. Label -> "+labelType.toString(), ErrorSeverity.WARNING, new VCardParseException("Duplicate label"));
            }
           
            match = true;
          }
        }//if
View Full Code Here

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

            handleError(vbe.getMessage(), vbe, ErrorSeverity.WARNING);
          }
        }
       
        if(adrType.hasLabel()) {
          LabelType label = adrType.getLabel();
         
          try {
            buildLabelType(sb, label);
          }
          catch(VCardBuildException vbe) {
View Full Code Here

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

    //LABEL
    {
      List<LabelType> it = vcard.getLables();
      assertEquals(2, it.size());
     
      LabelType f = it.get(0);
      assertEquals("Cresent moon drive\r\nAlbaney, New York  12345", f.getLabel());
     
      List<LabelParamType> types = f.getParams();
      assertEquals(2, types.size());
      assertTrue(types.contains(LabelParamType.WORK));
      assertTrue(types.contains(LabelParamType.PREF));
     
      f = it.get(1);
      assertEquals("Silicon Alley 5,\r\nNew York, New York  12345", f.getLabel());
      types = f.getParams();
      assertEquals(1, types.size());
      assertTrue(types.contains(LabelParamType.HOME));
    }
   
    //URL
    {
      List<UrlType> it = vcard.getUrls();
      assertEquals(1, it.size());
     
      UrlType f = it.get(0);
      assertEquals("http://www.ibm.com", f.getRawUrl());
     
      List<UrlParamType> types = f.getParams();
      assertEquals(1, types.size());
      assertTrue(types.contains(UrlParamType.WORK));
    }
   
    //ROLE
    {
      RoleType f = vcard.getRole();
      assertEquals("Counting Money", f.getRole());
    }
   
    //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));
    }
   
    //EMAIL
    {
      List<EmailType> it = vcard.getEmails();
      assertEquals(1, it.size());
     
      EmailType f = it.get(0);
      assertEquals("john.doe@ibm.cm", f.getEmail());
     
      List<EmailParamType> types = f.getParams();
      assertEquals(2, types.size());
      assertTrue(types.contains(EmailParamType.PREF));
      assertTrue(types.contains(EmailParamType.INTERNET));
    }

    //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 org.libreplan.business.labels.entities.LabelType

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
    public boolean isUnique(LabelType labelType) {
        try {
            LabelType result = findUniqueByName(labelType);
            return (result == null || result.getId().equals(labelType.getId()));
        } catch (InstanceNotFoundException e) {
            return true;
        } catch (NonUniqueResultException e) {
            return false;
        } catch (Exception e) {
View Full Code Here

Examples of org.libreplan.business.labels.entities.LabelType

    @Override
    public LabelType findUniqueByName(String name)
            throws InstanceNotFoundException, NonUniqueResultException {
        Criteria c = getSession().createCriteria(LabelType.class);
        c.add(Restrictions.eq("name", name));
        LabelType labelType = (LabelType) c.uniqueResult();

        if (labelType == null) {
            throw new InstanceNotFoundException(null, "LabelType");
        }
        return labelType;
View Full Code Here

Examples of org.libreplan.business.labels.entities.LabelType

    }

    @Test
    @Transactional
    public void testSaveLabelType() {
        LabelType labelType = LabelType.create(UUID.randomUUID().toString());
        labelTypeDAO.save(labelType);
        assertTrue(labelType.getId() != null);
    }
View Full Code Here

Examples of org.libreplan.business.labels.entities.LabelType

    }

    @Test
    @Transactional
    public void testRemoveLabelType() throws InstanceNotFoundException {
        LabelType labelType = LabelType.create(UUID.randomUUID().toString());
        labelTypeDAO.save(labelType);
        labelTypeDAO.remove(labelType.getId());
        assertFalse(labelTypeDAO.exists(labelType.getId()));
    }
View Full Code Here

Examples of org.libreplan.business.labels.entities.LabelType

    @Test
    @Transactional
    public void testListLabelTypes() {
        int previous = labelTypeDAO.list(LabelType.class).size();
        LabelType labelType = LabelType.create(UUID.randomUUID().toString());
        labelTypeDAO.save(labelType);
        List<LabelType> list = labelTypeDAO.list(LabelType.class);
        assertEquals(previous + 1, list.size());
    }
View Full Code Here

Examples of org.libreplan.business.labels.entities.LabelType

    public void testInSpringContainer() {
        assertNotNull(labelDAO);
    }

    public Label createValidLabel() {
        LabelType labelType = LabelType.create(UUID.randomUUID().toString());
        labelTypeDAO.save(labelType);
        Label label = Label.create(UUID.randomUUID().toString());
        label.setType(labelType);
        return label;
    }
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.