-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontent_line.go
52 lines (44 loc) · 883 Bytes
/
content_line.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package vcard
import "strings"
type ContentLine struct {
Group, Name string
Params map[string]Value
Value StructuredValue
}
// values separated by ';' has a structural meaning
type StructuredValue []Value
// values seprated by ',' is a multi value
type Value []string
func (sv StructuredValue) GetTextList() []string {
var textList []string
for _, v := range sv {
for _, s := range v {
textList = append(textList, s)
}
}
return textList
}
func (v StructuredValue) GetText() string {
if len(v) > 0 && len(v[0]) > 0 {
return v[0][0]
}
return ""
}
func (v StructuredValue) GetAllText() string {
if len(v) > 0 {
text := []string{}
for _, v0 := range v {
if len(v0) > 0 {
text = append(text, v0[0])
}
}
return strings.Join(text, ";")
}
return ""
}
func (v Value) GetText() string {
if len(v) > 0 {
return v[0]
}
return ""
}