1 package be
.nikiroo
.jvcard
;
3 import java
.security
.InvalidParameterException
;
7 * A data is a piece of information present in a {@link Contact}. It is
8 * basically a key/value pair with optional types and an optional group name.
13 public class Data
extends BaseClass
<TypeInfo
> {
14 public enum DataPart
{
15 FN_FAMILY
, FN_GIVEN
, FN_ADDITIONAL
, // Name
16 FN_PRE
, FN_POST
, // Pre/Post
17 BDAY_YYYY
, BDAY_MM
, BDAY_DD
, // BDay
18 ADR_PBOX
, ADR_EXTENDED
, ADR_STREET
, ADR_CITY
, ADR_REGION
, ADR_POSTAL_CODE
, ADR_COUNTRY
25 private int b64
; // -1 = no, 0 = still not ordered, the rest is order
28 * Create a new {@link Data} with the given values.
31 * the types of this {@link Data}
39 public Data(List
<TypeInfo
> types
, String name
, String value
, String group
) {
47 for (TypeInfo type
: this) {
48 if (type
.getName().equals("ENCODING")
49 && type
.getValue().equals("b")) {
57 * Return the name of this {@link Data}
61 public String
getName() {
66 * Return the value of this {@link Data}
70 public String
getValue() {
75 * Change the value of this {@link Data}
80 public void setValue(String value
) {
81 if ((value
== null && this.value
!= null)
82 || (value
!= null && !value
.equals(this.value
))) {
89 * Return the group of this {@link Data}
93 public String
getGroup() {
98 * Change the group of this {@link Data}
103 public void setGroup(String group
) {
104 if ((group
== null && this.group
!= null)
105 || (group
!= null && !group
.equals(this.group
))) {
112 * Return the bkey number of this {@link Data} or -1 if it is not binary.
114 * @return the bkey or -1
116 public int getB64Key() {
121 * Change the bkey of this {@link Data}
126 * @throw InvalidParameterException if the {@link Data} is not binary or if
127 * it is but you try to set a negative bkey
129 void resetB64Key(int i
) {
131 throw new InvalidParameterException(
132 "Cannot add a BKey on a non-binary object");
134 throw new InvalidParameterException(
135 "Cannot remove the BKey on a binary object");
141 * Check if this {@link Data} is binary
143 * @return TRUE if it is
145 public boolean isBinary() {