2018-10-11 09:26:00 +00:00
|
|
|
package activitystreams
|
2017-09-12 15:22:10 +00:00
|
|
|
|
2018-07-18 14:29:47 +00:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2017-09-16 17:53:11 +00:00
|
|
|
type (
|
2018-03-27 14:16:07 +00:00
|
|
|
// IRI is a Internationalized Resource Identifiers (IRIs) RFC3987
|
2017-09-16 17:53:11 +00:00
|
|
|
IRI URI
|
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// URI is a Uniform Resource Identifier (URI) RFC3986
|
2017-09-16 17:53:11 +00:00
|
|
|
URI string
|
|
|
|
)
|
2018-07-13 08:17:03 +00:00
|
|
|
|
2018-07-16 13:58:36 +00:00
|
|
|
// String returns the String value of the URI object
|
2018-07-13 08:17:03 +00:00
|
|
|
func (u URI) String() string {
|
|
|
|
return string(u)
|
|
|
|
}
|
2018-07-16 13:58:36 +00:00
|
|
|
|
|
|
|
// String returns the String value of the IRI object
|
2018-07-13 08:17:03 +00:00
|
|
|
func (i IRI) String() string {
|
|
|
|
return string(i)
|
|
|
|
}
|
|
|
|
|
2018-07-16 13:58:36 +00:00
|
|
|
// GetLink returns a copy of itself
|
2018-07-13 08:17:03 +00:00
|
|
|
func (u URI) GetLink() URI {
|
|
|
|
return u
|
|
|
|
}
|
2018-07-16 13:58:36 +00:00
|
|
|
|
|
|
|
// GetLink returns a URI type coercion of the IRI object
|
2018-07-13 08:17:03 +00:00
|
|
|
func (i IRI) GetLink() URI {
|
|
|
|
return URI(i)
|
|
|
|
}
|
2018-07-18 14:29:47 +00:00
|
|
|
|
|
|
|
// UnmarshalJSON
|
|
|
|
func (u *URI) UnmarshalJSON(s []byte) error {
|
|
|
|
*u = URI(strings.Trim(string(s), "\""))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON
|
|
|
|
func (i *IRI) UnmarshalJSON(s []byte) error {
|
|
|
|
*i = IRI(strings.Trim(string(s), "\""))
|
|
|
|
return nil
|
|
|
|
}
|
2018-07-24 21:11:08 +00:00
|
|
|
|
|
|
|
// UnmarshalText
|
|
|
|
func (u URI) UnmarshalText(s []byte) error {
|
|
|
|
u = URI(strings.Trim(string(s), "\""))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalText
|
|
|
|
func (i IRI) UnmarshalText(s []byte) error {
|
|
|
|
i = IRI(strings.Trim(string(s), "\""))
|
|
|
|
return nil
|
|
|
|
}
|
2018-07-25 09:54:12 +00:00
|
|
|
|
|
|
|
// IsObject
|
|
|
|
func (u URI) GetID() *ObjectID {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsObject
|
|
|
|
func (i IRI) GetID() *ObjectID {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetType
|
|
|
|
func (u URI) GetType() ActivityVocabularyType {
|
|
|
|
return LinkType
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetType
|
|
|
|
func (i IRI) GetType() ActivityVocabularyType {
|
|
|
|
return LinkType
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsLink
|
|
|
|
func (u URI) IsLink() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsLink
|
|
|
|
func (i IRI) IsLink() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsObject
|
|
|
|
func (u URI) IsObject() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsObject
|
|
|
|
func (i IRI) IsObject() bool {
|
|
|
|
return false
|
|
|
|
}
|