public class Sound extends BinaryProperty<SoundType>
Defines a sound, such as the correct pronunciation of the person's name.
Code sample (creating)
VCard vcard = new VCard(); //URL Sound sound = new Sound("http://www.mywebsite.com/my-name.ogg", SoundType.OGG); vcard.addSound(sound); //binary data byte data[] = ... sound = new Sound(data, SoundType.OGG); vcard.addSound(sound);
Code sample (retrieving)
VCard vcard = ... for (Sound sound : vcard.getSounds()) { SoundType contentType = sound.getContentType(); //e.g. "audio/ogg" String url = sound.getUrl(); if (url != null) { //property value is a URL continue; } byte[] data = sound.getData(); if (data != null) { //property value is binary data continue; } }
Property name: SOUND
Supported versions: 2.1, 3.0, 4.0
contentType, data, url
group, parameters
Constructor and Description |
---|
Sound(byte[] data,
SoundType type)
Creates a sound property.
|
Sound(InputStream in,
SoundType type)
Creates a sound property.
|
Sound(Path file,
SoundType type)
Creates a sound property.
|
Sound(Sound original)
Copy constructor.
|
Sound(String url,
SoundType type)
Creates a sound property.
|
Modifier and Type | Method and Description |
---|---|
Sound |
copy()
Creates a copy of this property object.
|
String |
getLanguage()
Gets the language that the property value is written in.
|
void |
setLanguage(String language)
Sets the language that the property value is written in.
|
_validate, equals, getAltId, getContentType, getData, getPids, getPref, getType, getUrl, hashCode, setAltId, setContentType, setData, setPref, setType, setUrl, toStringValues
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, isSupportedBy, removeParameter, setGroup, setParameter, setParameters, toString, validate
public Sound(String url, SoundType type)
url
- the URL to the sound filetype
- the content type (e.g. OGG)public Sound(byte[] data, SoundType type)
data
- the binary data of the sound filetype
- the content type (e.g. OGG)public Sound(InputStream in, SoundType type) throws IOException
in
- an input stream to the binary data (will be closed)type
- the content type (e.g. OGG)IOException
- if there's a problem reading from the input streampublic Sound(Path file, SoundType type) throws IOException
file
- the sound filetype
- the content type (e.g. OGG)IOException
- if there's a problem reading from the filepublic String getLanguage()
VCardProperty
public void setLanguage(String language)
VCardProperty
language
- the language or null to removepublic Sound copy()
VCardProperty
Creates a copy of this property object.
The default implementation of this method uses reflection to look for a copy constructor. Child classes SHOULD override this method to avoid the performance overhead involved in using reflection.
The child class's copy constructor, if present, MUST invoke the
VCardProperty.VCardProperty(VCardProperty)
super constructor to ensure that
the group name and parameters are also copied.
This method MUST be overridden by the child class if the child class does
not have a copy constructor. Otherwise, an
UnsupportedOperationException
will be thrown when an attempt is
made to copy the property (such as in the VCard
class's copy constructor
).
copy
in class VCardProperty
Copyright © 2012–2023 Michael Angstadt. All rights reserved.