2024-10-16 21:28:04 +02:00
|
|
|
package atom
|
2024-10-13 17:19:40 +02:00
|
|
|
|
2024-10-16 18:33:23 +02:00
|
|
|
import (
|
2024-10-17 20:10:18 +02:00
|
|
|
"encoding/xml"
|
2024-10-16 18:33:23 +02:00
|
|
|
"fmt"
|
|
|
|
)
|
2024-10-13 17:19:40 +02:00
|
|
|
|
|
|
|
type Logo struct {
|
2024-10-17 20:10:18 +02:00
|
|
|
XMLName xml.Name `xml:"logo"`
|
2024-10-13 17:19:40 +02:00
|
|
|
*CommonAttributes
|
2024-10-19 12:28:09 +02:00
|
|
|
URI string `xml:",chardata"` // IRI
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-19 14:12:51 +02:00
|
|
|
// NewLogo creates a new Logo. It returns a *Logo.
|
|
|
|
func NewLogo(uri string) *Logo {
|
2024-10-19 14:52:19 +02:00
|
|
|
return &Logo{
|
|
|
|
CommonAttributes: newCommonAttributes(),
|
|
|
|
URI: uri,
|
|
|
|
}
|
2024-10-16 18:33:23 +02:00
|
|
|
}
|
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// Check checks the Logo for incompatibilities with RFC4287. It returns an
|
|
|
|
// error.
|
2024-10-13 17:19:40 +02:00
|
|
|
func (l *Logo) Check() error {
|
|
|
|
if l.URI == "" {
|
2024-10-18 19:04:08 +02:00
|
|
|
return fmt.Errorf("uri element of logo %v empty", l)
|
2024-10-16 18:33:23 +02:00
|
|
|
} else {
|
|
|
|
if !isValidIRI(l.URI) {
|
2024-10-18 19:04:08 +02:00
|
|
|
return fmt.Errorf("uri element of logo %v not correctly formatted", l)
|
2024-10-16 18:33:23 +02:00
|
|
|
}
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|