ezvcard.types
Class GenderType

java.lang.Object
  extended by ezvcard.types.VCardType
      extended by ezvcard.types.GenderType
All Implemented Interfaces:
Comparable<VCardType>

public class GenderType
extends VCardType

Defines the person's sex.

Setting the gender

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

Getting the gender

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

vCard property name: GENDER

vCard versions: 4.0

Author:
Michael Angstadt

Field Summary
static String FEMALE
           
static String MALE
           
static String NAME
           
static String NONE
           
static String OTHER
           
static String UNKNOWN
           
 
Fields inherited from class ezvcard.types.VCardType
group, subTypes, typeName
 
Constructor Summary
GenderType()
           
GenderType(String gender)
          Use of this constructor is discouraged.
 
Method Summary
protected  void doMarshalText(StringBuilder sb, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode)
          Converts this type object to a string for sending over the wire.
protected  void doMarshalXml(XCardElement parent, List<String> warnings, CompatibilityMode compatibilityMode)
          Marshals this type for inclusion in an xCard (XML document).
protected  void doUnmarshalText(String value, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode)
          Unmarshals the type value from off the wire.
protected  void doUnmarshalXml(XCardElement element, List<String> warnings, CompatibilityMode compatibilityMode)
          Unmarshals the type from an xCard (XML document).
static GenderType female()
          Creates a gender type whose value is set to "female".
 String getGender()
          Gets the gender value.
 VCardVersion[] getSupportedVersions()
          Gets the vCard versions that support this type.
 String getText()
          Gets the additional text associated with this gender type.
 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 GenderType male()
          Creates a gender type whose value is set to "male".
static GenderType none()
          Creates a gender type whose value is set to "none".
static GenderType other()
          Creates a gender type 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 gender type.
static GenderType unknown()
          Creates a gender type whose value is set to "unknown".
 
Methods inherited from class ezvcard.types.VCardType
compareTo, doMarshalSubTypes, doUnmarshalHtml, getGroup, getQName, getSubTypes, getTypeName, marshalSubTypes, marshalText, marshalXml, setGroup, unmarshalHtml, unmarshalText, unmarshalXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
See Also:
Constant Field Values

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

GenderType

public GenderType()

GenderType

public GenderType(String gender)
Use of this constructor is discouraged. Please use one of the static methods to create a new GENDER type.

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

getText

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

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

setText

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

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 type.

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 GenderType male()
Creates a gender type whose value is set to "male".

Returns:
a "male" gender type

female

public static GenderType female()
Creates a gender type whose value is set to "female".

Returns:
a "female" gender type

other

public static GenderType other()
Creates a gender type whose value is set to "other".

Returns:
an "other" gender type

none

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

Returns:
a "none" gender type

unknown

public static GenderType unknown()
Creates a gender type whose value is set to "unknown".

Returns:
a "unknown" gender type

getSupportedVersions

public VCardVersion[] getSupportedVersions()
Description copied from class: VCardType
Gets the vCard versions that support this type.

Overrides:
getSupportedVersions in class VCardType
Returns:
the vCard versions that support this type.

doMarshalText

protected void doMarshalText(StringBuilder sb,
                             VCardVersion version,
                             List<String> warnings,
                             CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Converts this type object to a string for sending over the wire. It is NOT responsible for folding.

Specified by:
doMarshalText in class VCardType
Parameters:
sb - the buffer to add the marshalled value to
version - the version vCard that is being generated
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the marshalling process
compatibilityMode - allows the programmer to customize the marshalling process depending on the expected consumer of the vCard

doUnmarshalText

protected void doUnmarshalText(String value,
                               VCardVersion version,
                               List<String> warnings,
                               CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Unmarshals the type value from off the wire.

Specified by:
doUnmarshalText in class VCardType
Parameters:
value - the unfolded value from off the wire. If the wire value is in the "quoted-printable" encoding, it will be decoded.
version - the version of the vCard that is being read or null if the VERSION type has not been parsed yet (v3.0 and v4.0 require that the VERSION type be at the top of the vCard, but v2.1 has no such requirement)
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the unmarshalling process
compatibilityMode - allows you to customize the unmarshalling process depending on where the vCard came from

doMarshalXml

protected void doMarshalXml(XCardElement parent,
                            List<String> warnings,
                            CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Marshals this type for inclusion in an xCard (XML document). All child classes SHOULD override this, but are not required to.

Overrides:
doMarshalXml in class VCardType
Parameters:
parent - the XML element that the type's value will be inserted into. For example, this would be the "<fn>" element for the "FN" type.
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the marshalling process
compatibilityMode - allows the programmer to customize the marshalling process depending on the expected consumer of the vCard

doUnmarshalXml

protected void doUnmarshalXml(XCardElement element,
                              List<String> warnings,
                              CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Unmarshals the type from an xCard (XML document).

Overrides:
doUnmarshalXml in class VCardType
Parameters:
element - the XML element that contains the type data. For example, this would be the "<fn>" element for the "FN" type. This object will NOT include the "<parameters>" child element (it is removed after being unmarshalled into a VCardSubTypes object).
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the unmarshalling process
compatibilityMode - allows the programmer to customize the unmarshalling process depending on where the vCard came from


Copyright © 2012-2013. All Rights Reserved.