T
- the property classU
- the media type classpublic abstract class BinaryPropertyScribe<T extends BinaryProperty<U>,U extends MediaTypeParameter> extends VCardPropertyScribe<T>
VCardPropertyScribe.DateWriter, VCardPropertyScribe.Result<T extends VCardProperty>, VCardPropertyScribe.SemiStructuredIterator, VCardPropertyScribe.Splitter, VCardPropertyScribe.StructuredIterator
clazz, propertyName, qname
Constructor and Description |
---|
BinaryPropertyScribe(java.lang.Class<T> clazz,
java.lang.String propertyName) |
Modifier and Type | Method and Description |
---|---|
protected abstract U |
_buildMediaTypeObj(java.lang.String mediaType)
Builds a
MediaTypeParameter object based on the information in
the MEDIATYPE parameter or data URI of 4.0 vCards. |
protected abstract U |
_buildTypeObj(java.lang.String type)
Builds a
MediaTypeParameter object based on the value of the TYPE
parameter in 2.1/3.0 vCards. |
protected VCardDataType |
_dataType(T property,
VCardVersion version)
Determines the data type of a property instance.
|
protected VCardDataType |
_defaultDataType(VCardVersion version)
Determines the property's default data type.
|
protected abstract T |
_newInstance(byte[] data,
U contentType) |
protected abstract T |
_newInstance(java.lang.String uri,
U contentType) |
protected T |
_parseText(java.lang.String value,
VCardDataType dataType,
VCardVersion version,
VCardParameters parameters,
java.util.List<java.lang.String> warnings)
Unmarshals a property from a plain-text vCard.
|
protected T |
_parseXml(XCardElement element,
VCardParameters parameters,
java.util.List<java.lang.String> warnings)
Unmarshals a property from an XML document (xCard).
|
protected void |
_prepareParameters(T property,
VCardParameters copy,
VCardVersion version,
VCard vcard)
Sanitizes a property's parameters before the property is written.
|
protected java.lang.String |
_writeText(T property,
VCardVersion version)
Marshals a property's value to a string.
|
protected void |
_writeXml(T property,
XCardElement parent)
Marshals a property's value to an XML element (xCard).
|
protected T |
cannotUnmarshalValue(java.lang.String value,
VCardVersion version,
java.util.List<java.lang.String> warnings,
U contentType)
Called if the unmarshalling code cannot determine how to unmarshal the
value.
|
protected U |
parseContentType(VCardParameters parameters,
VCardVersion version) |
dataType, date, date, defaultDataType, escape, getPropertyClass, getPropertyName, getQName, handlePrefParam, list, list, list, missingXmlElements, missingXmlElements, parseText, parseXml, prepareParameters, semistructured, semistructured, splitter, structured, structured, unescape, writeText, writeXml
public BinaryPropertyScribe(java.lang.Class<T> clazz, java.lang.String propertyName)
protected VCardDataType _defaultDataType(VCardVersion version)
VCardPropertyScribe
Determines the property's default data type.
When writing a plain-text vCard, if the data type of a property instance
(as determined by the VCardPropertyScribe.dataType(T, org.opencrx.application.uses.ezvcard.VCardVersion)
method) matches the default data
type, then a VALUE parameter will *not* be written.
When parsing a plain-text vCard, if a property has no VALUE parameter,
then the property's default data type will be passed into the
VCardPropertyScribe.parseText(java.lang.String, org.opencrx.application.uses.ezvcard.VCardDataType, org.opencrx.application.uses.ezvcard.VCardVersion, org.opencrx.application.uses.ezvcard.parameter.VCardParameters)
method.
_defaultDataType
in class VCardPropertyScribe<T extends BinaryProperty<U>>
version
- the vCard versionprotected VCardDataType _dataType(T property, VCardVersion version)
VCardPropertyScribe
Determines the data type of a property instance.
This method should be overridden by child classes if a property's data
type changes depending on its value. The default implementation of this
method calls VCardPropertyScribe._defaultDataType(org.opencrx.application.uses.ezvcard.VCardVersion)
.
_dataType
in class VCardPropertyScribe<T extends BinaryProperty<U>>
property
- the propertyversion
- the version of the vCard that is being generatedprotected void _prepareParameters(T property, VCardParameters copy, VCardVersion version, VCard vcard)
VCardPropertyScribe
Sanitizes a property's parameters before the property is written.
This method should be overridden by child classes that wish to tweak the property's parameters before the property is written. The default implementation of this method does nothing.
_prepareParameters
in class VCardPropertyScribe<T extends BinaryProperty<U>>
property
- the propertycopy
- the list of parameters to make modifications to (it is a copy
of the property's parameters)version
- the version of the vCard that is being generatedvcard
- the vCard that the property belongs toprotected java.lang.String _writeText(T property, VCardVersion version)
VCardPropertyScribe
_writeText
in class VCardPropertyScribe<T extends BinaryProperty<U>>
property
- the propertyversion
- the version of the vCard that is being generatedprotected T _parseText(java.lang.String value, VCardDataType dataType, VCardVersion version, VCardParameters parameters, java.util.List<java.lang.String> warnings)
VCardPropertyScribe
_parseText
in class VCardPropertyScribe<T extends BinaryProperty<U>>
value
- the value as read off the wiredataType
- the data type of the property value. The property's VALUE
parameter is used to determine the data type. If the property has no
VALUE parameter, then this parameter will be set to the property's
default datatype, as determined by the VCardPropertyScribe.defaultDataType(org.opencrx.application.uses.ezvcard.VCardVersion)
method.
Note that the VALUE parameter is removed from the property's parameter
list after it has been read.version
- the version of the vCard that is being parsedparameters
- the parsed parameters. These parameters will be
assigned to the property object once this method returns. Therefore, do
not assign any parameters to the property object itself whilst inside of
this method, or else they will be overwritten.warnings
- allows the programmer to alert the user to any
note-worthy (but non-critical) issues that occurred during the
unmarshalling processprotected void _writeXml(T property, XCardElement parent)
VCardPropertyScribe
Marshals a property's value to an XML element (xCard).
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 VCardPropertyScribe.dataType(T, org.opencrx.application.uses.ezvcard.VCardVersion)
method), and the child element's text content will be set to the
property's marshalled plain-text value (retrieved using the
VCardPropertyScribe.writeText(T, org.opencrx.application.uses.ezvcard.VCardVersion)
method).
_writeXml
in class VCardPropertyScribe<T extends BinaryProperty<U>>
property
- the propertyparent
- the property's XML elementprotected T _parseXml(XCardElement element, VCardParameters parameters, java.util.List<java.lang.String> warnings)
VCardPropertyScribe
Unmarshals a property from an XML document (xCard).
This method should be overridden by child classes that wish to support
xCard. The default implementation of this method will find the first
child element with the xCard namespace. The element's name will be used
as the property's data type and its text content will be passed into the
VCardPropertyScribe._parseText(java.lang.String, org.opencrx.application.uses.ezvcard.VCardDataType, org.opencrx.application.uses.ezvcard.VCardVersion, org.opencrx.application.uses.ezvcard.parameter.VCardParameters, java.util.List<java.lang.String>)
method. If no such child element is found, then the
parent element's text content will be passed into VCardPropertyScribe._parseText(java.lang.String, org.opencrx.application.uses.ezvcard.VCardDataType, org.opencrx.application.uses.ezvcard.VCardVersion, org.opencrx.application.uses.ezvcard.parameter.VCardParameters, java.util.List<java.lang.String>)
and
the data type will be null.
_parseXml
in class VCardPropertyScribe<T extends BinaryProperty<U>>
element
- the property's XML elementparameters
- the parsed parameters. These parameters will be
assigned to the property object once this method returns. Therefore, do
not assign any parameters to the property object itself whilst inside of
this method, or else they will be overwritten.warnings
- allows the programmer to alert the user to any
note-worthy (but non-critical) issues that occurred during the
unmarshalling processprotected T cannotUnmarshalValue(java.lang.String value, VCardVersion version, java.util.List<java.lang.String> warnings, U contentType)
value
- the valueversion
- the version of the vCardwarnings
- the warningscontentType
- the content type of the resource of null if unknownprotected abstract U _buildMediaTypeObj(java.lang.String mediaType)
MediaTypeParameter
object based on the information in
the MEDIATYPE parameter or data URI of 4.0 vCards.mediaType
- the media type string (e.g. "image/jpeg")protected abstract U _buildTypeObj(java.lang.String type)
MediaTypeParameter
object based on the value of the TYPE
parameter in 2.1/3.0 vCards.type
- the TYPE valueprotected U parseContentType(VCardParameters parameters, VCardVersion version)
This software is published under the BSD license. Copyright © 2003-${build.year}, CRIXP AG, Switzerland, All rights reserved. Use is subject to license terms.