@SupportedVersions(value=V4_0) public class Gender extends VCardProperty
Defines the person's sex.
Code sample (creating)
VCard vcard = new VCard(); Gender gender = Gender.male(); vcard.setGender(gender);
Code sample (retrieving)
VCard vcard = ... Gender gender = vcard.getGender(); if (gender.isMale()) { //gender is male } else if (gender.isFemale()) { //gender is female } //etc
Property name: GENDER
Supported versions: 4.0
Modifier and Type | Field and Description |
---|---|
static String |
FEMALE |
static String |
MALE |
static String |
NONE |
static String |
OTHER |
static String |
UNKNOWN |
group, parameters
Constructor and Description |
---|
Gender(Gender original)
Copy constructor.
|
Gender(String gender)
Creates a gender property.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_validate(List<ValidationWarning> warnings,
VCardVersion version,
VCard vcard)
Checks the property for data consistency problems or deviations from the
spec.
|
Gender |
copy()
Creates a copy of this property object.
|
boolean |
equals(Object obj) |
static Gender |
female()
Creates a gender property whose value is set to "female".
|
String |
getGender()
Gets the gender value.
|
String |
getText()
Gets the additional text associated with this property.
|
int |
hashCode() |
boolean |
isFemale()
Determines if the gender is "female" or not.
|
boolean |
isMale()
Determines if the gender is "male" or not.
|
boolean |
isNone()
Determines if the gender is "none" or not.
|
boolean |
isOther()
Determines if the gender is "other" or not.
|
boolean |
isUnknown()
Determines if the gender is "unknown" or not.
|
static Gender |
male()
Creates a gender property whose value is set to "male".
|
static Gender |
none()
Creates a gender property whose value is set to "none".
|
static Gender |
other()
Creates a gender property whose value is set to "other".
|
void |
setGender(String gender)
Sets the gender value.
|
void |
setText(String text)
Sets the additional text associated with this property.
|
protected Map<String,Object> |
toStringValues()
Gets string representations of the class's fields for the
VCardProperty.toString() method. |
static Gender |
unknown()
Creates a gender property whose value is set to "unknown".
|
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, isSupportedBy, removeParameter, setGroup, setParameter, setParameters, toString, validate
public static final String MALE
public static final String FEMALE
public static final String OTHER
public static final String NONE
public static final String UNKNOWN
public Gender(String gender)
gender
- the gender value (e.g. "F")public String getText()
public void setText(String text)
text
- additional text or null to removepublic String getGender()
public void setGender(String gender)
gender
- the gender value (see static strings for the possible
values)public boolean isMale()
public boolean isFemale()
public boolean isOther()
public boolean isNone()
public boolean isUnknown()
public static Gender male()
public static Gender female()
public static Gender other()
public static Gender none()
public static Gender unknown()
protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard)
VCardProperty
_validate
in class VCardProperty
warnings
- the list to add the warnings toversion
- the version to check the property againstvcard
- the vCard this property belongs toprotected Map<String,Object> toStringValues()
VCardProperty
Gets string representations of the class's fields for the
VCardProperty.toString()
method.
Meant to be overridden by child classes. The default implementation returns an empty map.
toStringValues
in class VCardProperty
public Gender 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
public int hashCode()
hashCode
in class VCardProperty
public boolean equals(Object obj)
equals
in class VCardProperty
Copyright © 2012–2023 Michael Angstadt. All rights reserved.