/** * <p> * Unescapes newline sequences in the LABEL parameter of {@link Address} * properties. Newlines cannot normally be escaped in parameter values. * </p> * <p> * Only version 4.0 allows this (and only version 4.0 defines a LABEL * parameter), but do this for all versions for compatibility. * </p> * @param property the property */ private void handleLabelParameter(VCardProperty property) { if (!(property instanceof Address)) { return; } Address adr = (Address) property; String label = adr.getLabel(); if (label == null) { return; } label = label.replace("\\n", StringUtils.NEWLINE); adr.setLabel(label); }
/** * Matches up a list of {@link Label} properties with their corresponding * {@link Address} properties. If no match can be found, then the LABEL * property itself is assigned to the vCard. * @param vcard the vCard that the properties belong to * @param labels the LABEL properties */ protected void assignLabels(VCard vcard, List<Label> labels) { List<Address> adrs = vcard.getAddresses(); for (Label label : labels) { boolean orphaned = true; Set<AddressType> labelTypes = new HashSet<AddressType>(label.getTypes()); for (Address adr : adrs) { if (adr.getLabel() != null) { //a label has already been assigned to it continue; } Set<AddressType> adrTypes = new HashSet<AddressType>(adr.getTypes()); if (adrTypes.equals(labelTypes)) { adr.setLabel(label.getValue()); orphaned = false; break; } } if (orphaned) { vcard.addOrphanedLabel(label); } } }
String labelStr = adr.getLabel(); if (labelStr == null) { continue;