ezvcard.property
Class Gender

java.lang.Object
  extended by ezvcard.property.VCardProperty
      extended by ezvcard.property.Gender
All Implemented Interfaces:
Comparable<VCardProperty>

public class Gender
extends VCardProperty

Defines the person's sex.

Setting the gender

 VCard vcard = new VCard();
 Gender gender = Gender.male();
 vcard.setGender(gender);
 

Getting the gender

 VCard vcard = ...
 Gender gender = vcard.getGender();
 if (gender != null){
   if (gender.isMale()){
     ...
   } else if (gender.isFemale()){
     ...
   }
   ...
 }
 

Property name: GENDER

Supported versions: 4.0

Author:
Michael Angstadt

Field Summary
static String FEMALE
           
static String MALE
           
static String NONE
           
static String OTHER
           
static String UNKNOWN
           
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
Gender(String gender)
          Creates a gender property.
 
Method Summary
 Set<VCardVersion> _supportedVersions()
           Gets the vCard versions that support this property.
protected  void _validate(List<Warning> warnings, VCardVersion version, VCard vcard)
          Checks the property for data consistency problems or deviations from the spec.
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.
 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.
static Gender unknown()
          Creates a gender property whose value is set to "unknown".
 
Methods inherited from class ezvcard.property.VCardProperty
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, removeParameter, setGroup, setParameter, setParameters, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MALE

public static final String MALE
See Also:
Constant Field Values

FEMALE

public static final String FEMALE
See Also:
Constant Field Values

OTHER

public static final String OTHER
See Also:
Constant Field Values

NONE

public static final String NONE
See Also:
Constant Field Values

UNKNOWN

public static final String UNKNOWN
See Also:
Constant Field Values
Constructor Detail

Gender

public Gender(String gender)
Creates a gender property. Use of this constructor is discouraged. Please use one of the static factory methods to create a new GENDER property.

Parameters:
gender - the gender value (e.g. "F")
Method Detail

_supportedVersions

public Set<VCardVersion> _supportedVersions()
Description copied from class: VCardProperty

Gets the vCard versions that support this property.

This method should be overridden by child classes if the property does not support all vCard versions. The default implementation of this method returns all vCard versions.

Overrides:
_supportedVersions in class VCardProperty
Returns:
the vCard versions that support this property.

getText

public String getText()
Gets the additional text associated with this property.

Returns:
the additional text or null if there is no text

setText

public void setText(String text)
Sets the additional text associated with this property.

Parameters:
text - additional text or null to remove

getGender

public String getGender()
Gets the gender value.

Returns:
the gender value (see static strings for the possible values)

setGender

public void setGender(String gender)
Sets the gender value.

Parameters:
gender - the gender value (see static strings for the possible values)

isMale

public boolean isMale()
Determines if the gender is "male" or not.

Returns:
true if the gender is "male", false if not

isFemale

public boolean isFemale()
Determines if the gender is "female" or not.

Returns:
true if the gender is "female", false if not

isOther

public boolean isOther()
Determines if the gender is "other" or not.

Returns:
true if the gender is "other", false if not

isNone

public boolean isNone()
Determines if the gender is "none" or not. A group, organization, or location may have this gender property.

Returns:
true if the gender is "none", false if not

isUnknown

public boolean isUnknown()
Determines if the gender is "unknown" or not.

Returns:
true if the gender is "unknown", false if not

male

public static Gender male()
Creates a gender property whose value is set to "male".

Returns:
a "male" gender property

female

public static Gender female()
Creates a gender property whose value is set to "female".

Returns:
a "female" gender property

other

public static Gender other()
Creates a gender property whose value is set to "other".

Returns:
an "other" gender property

none

public static Gender none()
Creates a gender property whose value is set to "none". Groups, organizations, and locations should be given this gender property.

Returns:
a "none" gender property

unknown

public static Gender unknown()
Creates a gender property whose value is set to "unknown".

Returns:
a "unknown" gender property

_validate

protected void _validate(List<Warning> warnings,
                         VCardVersion version,
                         VCard vcard)
Description copied from class: VCardProperty
Checks the property for data consistency problems or deviations from the spec. Meant to be overridden by child classes that wish to provide validation logic.

Overrides:
_validate in class VCardProperty
Parameters:
warnings - the list to add the warnings to
version - the version to check the property against
vcard - the vCard this property belongs to


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.