2018-11-29 05:40:11 +09:00
|
|
|
package rdf
|
|
|
|
|
2018-12-02 00:36:33 +09:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
rdfSpec = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
|
|
langstringSpec = "langstring"
|
|
|
|
propertySpec = "Property"
|
|
|
|
valueSpec = "value"
|
|
|
|
)
|
|
|
|
|
2018-11-29 05:40:11 +09:00
|
|
|
type RDFOntology struct{}
|
|
|
|
|
|
|
|
func (o *RDFOntology) SpecURI() string {
|
2018-12-02 00:36:33 +09:00
|
|
|
return rdfSpec
|
2018-11-29 05:40:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o *RDFOntology) Load() ([]RDFNode, error) {
|
2018-12-02 00:36:33 +09:00
|
|
|
return o.LoadAsAlias("")
|
2018-11-29 05:40:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o *RDFOntology) LoadAsAlias(s string) ([]RDFNode, error) {
|
2018-12-02 00:36:33 +09:00
|
|
|
return []RDFNode{
|
|
|
|
&AliasedDelegate{
|
|
|
|
Spec: rdfSpec,
|
|
|
|
Alias: s,
|
|
|
|
Name: langstringSpec,
|
|
|
|
Delegate: &langstring{},
|
|
|
|
},
|
|
|
|
&AliasedDelegate{
|
|
|
|
Spec: rdfSpec,
|
|
|
|
Alias: s,
|
|
|
|
Name: propertySpec,
|
|
|
|
Delegate: &property{},
|
|
|
|
},
|
|
|
|
&AliasedDelegate{
|
|
|
|
Spec: rdfSpec,
|
|
|
|
Alias: s,
|
|
|
|
Name: valueSpec,
|
|
|
|
Delegate: &value{},
|
|
|
|
},
|
|
|
|
}, nil
|
2018-11-29 05:40:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o *RDFOntology) LoadElement(name string, payload map[string]interface{}) ([]RDFNode, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2018-12-02 00:36:33 +09:00
|
|
|
|
|
|
|
var _ RDFNode = &langstring{}
|
|
|
|
|
|
|
|
type langstring struct{}
|
|
|
|
|
|
|
|
func (l *langstring) Enter(key string, ctx *ParsingContext) (bool, error) {
|
|
|
|
return true, fmt.Errorf("rdf langstring cannot be entered")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *langstring) Exit(key string, ctx *ParsingContext) (bool, error) {
|
|
|
|
return true, fmt.Errorf("rdf langstring cannot be exited")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *langstring) Apply(key string, value interface{}, ctx *ParsingContext) (bool, error) {
|
2018-12-02 21:55:29 +09:00
|
|
|
// TODO: Act as value
|
2018-12-02 00:36:33 +09:00
|
|
|
return true, fmt.Errorf("rdf langstring cannot be applied")
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ RDFNode = &property{}
|
|
|
|
|
|
|
|
type property struct{}
|
|
|
|
|
|
|
|
func (p *property) Enter(key string, ctx *ParsingContext) (bool, error) {
|
|
|
|
return true, fmt.Errorf("rdf property cannot be entered")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *property) Exit(key string, ctx *ParsingContext) (bool, error) {
|
|
|
|
return true, fmt.Errorf("rdf property cannot be exited")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *property) Apply(key string, value interface{}, ctx *ParsingContext) (bool, error) {
|
2018-12-02 21:55:29 +09:00
|
|
|
// TODO: Act as value
|
2018-12-02 00:36:33 +09:00
|
|
|
return true, fmt.Errorf("rdf property cannot be applied")
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ RDFNode = &value{}
|
|
|
|
|
|
|
|
type value struct{}
|
|
|
|
|
|
|
|
func (v *value) Enter(key string, ctx *ParsingContext) (bool, error) {
|
|
|
|
return true, fmt.Errorf("rdf value cannot be entered")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *value) Exit(key string, ctx *ParsingContext) (bool, error) {
|
|
|
|
return true, fmt.Errorf("rdf value cannot be exited")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *value) Apply(key string, value interface{}, ctx *ParsingContext) (bool, error) {
|
2018-12-02 21:55:29 +09:00
|
|
|
// TODO: Act as value
|
2018-12-02 00:36:33 +09:00
|
|
|
return true, fmt.Errorf("rdf value cannot be applied")
|
|
|
|
}
|