use of ezvcard.io.EmbeddedVCardException in project ez-vcard by mangstadt.
the class AgentScribe method _writeText.
@Override
protected String _writeText(Agent property, WriteContext context) {
String url = property.getUrl();
if (url != null) {
return url;
}
VCard vcard = property.getVCard();
if (vcard != null) {
throw new EmbeddedVCardException(vcard);
}
// don't write an empty value because parsers could interpret that as there being an embedded vCard on the next line
throw new SkipMeException(Messages.INSTANCE.getValidationWarning(8));
}
use of ezvcard.io.EmbeddedVCardException 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.io.EmbeddedVCardException 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