private static Telephone convertToVCardTelephone(PhoneNumber personNumber) { Telephone telephone = new Telephone(personNumber.getValue()); telephone.setPref(getPref(personNumber.getMetadata())); return telephone; }
String primaryValue2 = "411"; String secondaryValue = "(555) 867-5309"; Telephone primaryTelephone1 = new Telephone(primaryValue1); primaryTelephone1.setPref(VCARD_PRIMARY_PREF); Telephone primaryTelephone2 = new Telephone(primaryValue2); primaryTelephone2.setPref(VCARD_PRIMARY_PREF); Telephone secondaryTelephone = new Telephone(secondaryValue); secondaryTelephone.setPref(VCARD_PRIMARY_PREF + 1);
Statement valueStatement = getValueStatement(telephoneResource); String telephoneNumber = valueStatement.getObject().toString(); Telephone telephoneObject = new Telephone(telephoneNumber); if (telephoneResource.hasProperty(RDF.type)) { telephoneResource.listProperties(RDF.type).forEachRemaining(typeProperty -> } else { String telephoneNumber = telephoneResource.getURI(); Telephone telephoneObject = new Telephone(telephoneNumber); vcard.addTelephoneNumber(telephoneObject);
@Override public Telephone copy() { return new Telephone(this); }
public static void main(String[] args) { Telephone t1 = new Telephone(555,666,777, "mario"); System.out.println(t1.toString()); // Added line to print result }
@Override protected Telephone _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) { String text = element.first(VCardDataType.TEXT); if (text != null) { return new Telephone(text); } String uri = element.first(VCardDataType.URI); if (uri != null) { try { return new Telephone(TelUri.parse(uri)); } catch (IllegalArgumentException e) { context.addWarning(18); return new Telephone(uri); } } throw missingXmlElements(VCardDataType.TEXT, VCardDataType.URI); }
/** * <p> * Adds a telephone number. * </p> * <p> * <b>Property name:</b> {@code TEL}<br> * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} * </p> * @param telephoneNumber the telephone number to add (e.g. * "+1 555-555-5555") * @param types the type(s) to assign to the telephone number (e.g. "cell", * "work", etc) * @return the property object that was created * @see <a href="http://tools.ietf.org/html/rfc6350#page-34">RFC 6350 * p.34</a> * @see <a href="http://tools.ietf.org/html/rfc2426#page-14">RFC 2426 * p.14</a> * @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.13</a> */ public Telephone addTelephoneNumber(String telephoneNumber, TelephoneType... types) { Telephone property = new Telephone(telephoneNumber); property.getTypes().addAll(Arrays.asList(types)); addTelephoneNumber(property); return property; }
@Override protected Telephone _parseHtml(HCardElement element, ParseContext context) { Telephone property; String href = element.attr("href"); try { property = new Telephone(TelUri.parse(href)); } catch (IllegalArgumentException e) { //not a tel URI property = new Telephone(element.value()); } List<String> types = element.types(); property.getParameters().putAll(VCardParameters.TYPE, types); return property; }
Telephone tel = new Telephone(telecomNumber.getString("areaCode") + telecomNumber.getString("contactNumber")); tel.getTypes().add(TelephoneType.WORK); vcard.addTelephoneNumber(tel);