use of com.github.mangstadt.vinnie.VObjectParameters in project vinnie by mangstadt.
the class VObjectWriterTest method group.
@Test
public void group() throws Exception {
for (SyntaxStyle style : SyntaxStyle.values()) {
StringWriter sw = new StringWriter();
VObjectWriter writer = new VObjectWriter(sw, style);
writer.writeProperty("group", "PROP", new VObjectParameters(), "value");
writer.writeProperty("", "PROP", new VObjectParameters(), "value");
writer.writeProperty(null, "PROP", new VObjectParameters(), "value");
String actual = sw.toString();
// @formatter:off
String expected = "group.PROP:value\r\n" + "PROP:value\r\n" + "PROP:value\r\n";
// @formatter:on
assertEquals(expected, actual);
}
}
use of com.github.mangstadt.vinnie.VObjectParameters in project vinnie by mangstadt.
the class VObjectWriter method copyParameters.
/**
* Copies the given list of parameters if it hasn't been copied before.
* @param parameters the parameters
* @return the copy or the same object if the parameters were copied before
*/
private VObjectParameters copyParameters(VObjectParameters parameters) {
if (parametersCopied) {
return parameters;
}
VObjectParameters copy = new VObjectParameters(parameters);
parametersCopied = true;
return copy;
}
use of com.github.mangstadt.vinnie.VObjectParameters 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");
}
Aggregations