use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.
the class VCardWriter method _write.
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void _write(VCard vcard, List<VCardProperty> propertiesToAdd) throws IOException {
VCardVersion targetVersion = getTargetVersion();
TargetApplication targetApplication = getTargetApplication();
Boolean includeTrailingSemicolons = this.includeTrailingSemicolons;
if (includeTrailingSemicolons == null) {
includeTrailingSemicolons = (targetVersion == VCardVersion.V4_0);
}
WriteContext context = new WriteContext(targetVersion, targetApplication, includeTrailingSemicolons);
writer.writeBeginComponent("VCARD");
writer.writeVersion(targetVersion.getVersion());
for (VCardProperty property : propertiesToAdd) {
VCardPropertyScribe scribe = index.getPropertyScribe(property);
String value = null;
VCard nestedVCard = null;
try {
value = scribe.writeText(property, context);
} catch (SkipMeException e) {
continue;
} catch (EmbeddedVCardException e) {
nestedVCard = e.getVCard();
}
VCardParameters parameters = scribe.prepareParameters(property, targetVersion, vcard);
if (nestedVCard != null) {
writeNestedVCard(nestedVCard, property, scribe, parameters, value);
continue;
}
handleValueParameter(property, scribe, parameters);
handleLabelParameter(property, parameters);
writer.writeProperty(property.getGroup(), scribe.getPropertyName(), new VObjectParameters(parameters.getMap()), value);
fixBinaryPropertyForOutlook(property);
}
writer.writeEndComponent("VCARD");
}
use of ezvcard.parameter.VCardParameters in project ez-vcard by mangstadt.
the class XCardWriter method write.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void write(VCardProperty property, VCard vcard) throws SAXException {
VCardPropertyScribe scribe = index.getPropertyScribe(property);
VCardParameters parameters = scribe.prepareParameters(property, targetVersion, vcard);
// get the property element to write
Element propertyElement;
if (property instanceof Xml) {
Xml xml = (Xml) property;
Document value = xml.getValue();
if (value == null) {
return;
}
propertyElement = value.getDocumentElement();
} else {
QName qname = scribe.getQName();
propertyElement = DOC.createElementNS(qname.getNamespaceURI(), qname.getLocalPart());
try {
scribe.writeXml(property, propertyElement);
} catch (SkipMeException e) {
return;
} catch (EmbeddedVCardException e) {
return;
}
}
start(propertyElement);
write(parameters);
write(propertyElement);
end(propertyElement);
}
Aggregations