Search in sources :

Example 1 with WriteContext

use of ezvcard.io.text.WriteContext in project ez-vcard by mangstadt.

the class VCardPropertyScribe method _writeXml.

/**
 * <p>
 * Marshals a property's value to an XML element (xCard).
 * </p>
 * <p>
 * This method should be overridden by child classes that wish to support
 * xCard. The default implementation of this method will append one child
 * element to the property's XML element. The child element's name will be
 * that of the property's data type (retrieved using the {@link #dataType}
 * method), and the child element's text content will be set to the
 * property's marshalled plain-text value (retrieved using the
 * {@link #writeText} method).
 * </p>
 * @param property the property
 * @param element the property's XML element
 * @throws SkipMeException if the property should not be written to the data
 * stream
 */
protected void _writeXml(T property, XCardElement element) {
    String value = writeText(property, new WriteContext(VCardVersion.V4_0, null, false));
    VCardDataType dataType = dataType(property, VCardVersion.V4_0);
    element.append(dataType, value);
}
Also used : VCardDataType(ezvcard.VCardDataType) WriteContext(ezvcard.io.text.WriteContext)

Example 2 with WriteContext

use of ezvcard.io.text.WriteContext in project ez-vcard by mangstadt.

the class AgentScribeTest method writeText.

@Test
public void writeText() {
    sensei.assertWriteText(withUrl).run(url);
    for (VCardVersion version : values()) {
        try {
            scribe.writeText(withVCard, new WriteContext(version, null, false));
            fail();
        } catch (EmbeddedVCardException e) {
            assertEquals(vcard, e.getVCard());
        }
    }
    sensei.assertWriteText(empty).skipMe();
}
Also used : EmbeddedVCardException(ezvcard.io.EmbeddedVCardException) VCardVersion(ezvcard.VCardVersion) WriteContext(ezvcard.io.text.WriteContext) Test(org.junit.Test)

Aggregations

WriteContext (ezvcard.io.text.WriteContext)2 VCardDataType (ezvcard.VCardDataType)1 VCardVersion (ezvcard.VCardVersion)1 EmbeddedVCardException (ezvcard.io.EmbeddedVCardException)1 Test (org.junit.Test)1