31 lines
		
	
	
		
			548 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			548 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package atom
 | 
						|
 | 
						|
import (
 | 
						|
	"errors"
 | 
						|
	"fmt"
 | 
						|
)
 | 
						|
 | 
						|
type Icon struct {
 | 
						|
	*CommonAttributes
 | 
						|
	URI IRI `xml:",chardata"`
 | 
						|
}
 | 
						|
 | 
						|
// NewIcon creates a new Icon. It returns a *Icon.
 | 
						|
func NewIcon(uri string) *Icon {
 | 
						|
	return &Icon{URI: IRI(uri)}
 | 
						|
}
 | 
						|
 | 
						|
// Check checks the Icon for incompatibilities with RFC4287. It returns an
 | 
						|
// error.
 | 
						|
func (i *Icon) Check() error {
 | 
						|
	if i.URI == "" {
 | 
						|
		return errors.New("uri element of icon empty")
 | 
						|
	} else {
 | 
						|
		if !isValidIRI(i.URI) {
 | 
						|
			return fmt.Errorf("uri attribute %v of icon not correctly formatted", i.URI)
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	return nil
 | 
						|
}
 |