Documentation
¶
Index ¶
- Constants
- Variables
- func BuildMeasureNodes(ctx *ls.Context, builder ls.GraphBuilder, measureSchemaNode graph.Node) error
- func BuildMeasureNodesForLayer(ctx *ls.Context, bldr ls.GraphBuilder, layer *ls.Layer) error
- func SetMeasureService(ctx *ls.Context, svc MeasureService)
- func SetMeasureValue(ctx *ls.Context, svc MeasureService, measureNode, schemaNode graph.Node, ...) error
- func ToGomentTime(time time.Time) (*goment.Goment, error)
- type Date
- type DateTime
- type ErrCannotParseTemporalValue
- type ErrIncompatibleTypes
- type ErrMeasureProcessing
- type ErrMultipleNodesMatch
- type ErrNotAMeasure
- type GDay
- type GMonth
- type GMonthDay
- type GYear
- type GYearMonth
- type JSONBooleanParser
- type JSONDateParser
- type JSONDateTimeParser
- type JSONTimeParser
- type Measure
- type MeasureService
- type PatternDateParser
- type PatternDateTimeParser
- type PatternTimeParser
- type TimeOfDay
- type UnixTime
- type UnixTimeNano
- type UnixTimeNanoParser
- type UnixTimeParser
- type XMLBooleanParser
- type XSDDateParser
- type XSDDateTimeParser
- type XSDGDayParser
- type XSDGMonthDayParser
- type XSDGMonthParser
- type XSDGYearMonthParser
- type XSDGYearParser
- type XSDTimeParser
Constants ¶
const JSON = "https:/json-schema.org/"
const Unix = "https://unixtime.org/"
const XSD = "http://www.w3.org/2001/XMLSchema/"
Variables ¶
var GoTimeFormatTerm = ls.NewTerm(ls.LS, "goTimeFormat", false, false, ls.SetComposition, nil, "ls:goTimeFormat")
var JSONBooleanTerm = ls.NewTerm(JSON, "boolean", false, false, ls.OverrideComposition, struct { JSONBooleanParser }{ JSONBooleanParser{}, }, "json:boolean")
var JSONDateTerm = ls.NewTerm(JSON, "date", false, false, ls.OverrideComposition, struct { JSONDateParser }{ JSONDateParser: JSONDateParser{}, }, "json:date")
JSONDate is a node-type that identifies the underlying value as a JSON date value
YYYY-MM-DD
var JSONDateTimeTerm = ls.NewTerm(JSON, "date-time", false, false, ls.OverrideComposition, struct { JSONDateTimeParser }{ JSONDateTimeParser: JSONDateTimeParser{}, }, "json:date-time")
JSONDateTime is a node-type that identifies the underlying value as a JSON datetime value, RFC3339 or RFC3339Nano
YYYY-MM-DDTHH:mm:ssZ YYYY-MM-DDTHH:mm:ss.00000Z
var JSONTimeTerm = ls.NewTerm(JSON, "time", false, false, ls.OverrideComposition, struct { JSONTimeParser }{ JSONTimeParser: JSONTimeParser{}, }, "json:time")
JSONTime is a node-type that identifies the underlying value as a JSON time value
HH:mm HH:mm:ss HH:mm:ssZ
var MeasureTerm = ls.NewTerm(ls.LS, "Measure", false, false, ls.OverrideComposition, struct {
measureParser
}{
measureParser{},
}, "Measure")
MeasureTerm is used as a valuetype for a measure node
var MeasureUnitDomainTerm = ls.NewTerm(ls.LS, "measure/unitDomain", false, false, ls.OverrideComposition, nil)
MeasureUnitDomainTerm is a node property that specifies that the measure is of a certain domain
var MeasureUnitExpr = ls.NewTerm(ls.LS, "measure/unitExpr", false, false, ls.OverrideComposition, ls.CompileOCSemantics{})
MeasureUnitExpr gives the expression that returns the unit. The result can be a node or a value. The expression is evaluated with (valueNode) bound to the value node of the unit expr
var MeasureUnitNode = ls.NewTerm(ls.LS, "measure/unitNode", false, false, ls.OverrideComposition, nil)
MeasureUnitNode gives the schema node id containing the unit. This node must appear under the common parent with measure node
var MeasureUnitTerm = ls.NewTerm(ls.LS, "measure/unit", false, false, ls.OverrideComposition, nil)
MeasureUnitTerm is a node property term giving measure unit
var MeasureUseUnitTerm = ls.NewTerm(ls.LS, "measure/useUnit", false, false, ls.OverrideComposition, nil)
MeasureUseUnitTerm is a node property that specifies that all measures must be converted to this unit
var MeasureValueNode = ls.NewTerm(ls.LS, "measure/valueNode", false, false, ls.OverrideComposition, nil)
MeasureValueNode gives the schema node id containing the value. This node must appear under the common parent with measure node
var MeasureValueNodeExpr = ls.NewTerm(ls.LS, "measure/valueNodeExpr", false, false, ls.OverrideComposition, ls.CompileOCSemantics{})
MeasureValueExpr gives the expression that returns the measured value node. The result must be a node.
var MeasureValueTerm = ls.NewTerm(ls.LS, "measure/value", false, false, ls.OverrideComposition, nil)
MeasureValueTerm is a node property term giving measure value.
var MomentTimeFormatTerm = ls.NewTerm(ls.LS, "momentTimeFormat", false, false, ls.SetComposition, nil, "ls:momentTimeFormat")
var PatternDateTerm = ls.NewTerm(ls.LS, "date", false, false, ls.OverrideComposition, struct { PatternDateParser }{ PatternDateParser: PatternDateParser{}, }, "ls:date")
var PatternDateTimeTerm = ls.NewTerm(ls.LS, "dateTime", false, false, ls.OverrideComposition, struct { PatternDateTimeParser }{ PatternDateTimeParser: PatternDateTimeParser{}, }, "ls:dateTime")
var PatternTimeTerm = ls.NewTerm(ls.LS, "time", false, false, ls.OverrideComposition, struct { PatternTimeParser }{ PatternTimeParser: PatternTimeParser{}, }, "ls:time")
var UnixTimeNanoTerm = ls.NewTerm(Unix, "timeNano", false, false, ls.OverrideComposition, struct { UnixTimeNanoParser }{ UnixTimeNanoParser: UnixTimeNanoParser{}, }, "unix:timeNano")
var UnixTimeTerm = ls.NewTerm(Unix, "time", false, false, ls.OverrideComposition, struct { UnixTimeParser }{ UnixTimeParser: UnixTimeParser{}, }, "unix:time")
var XMLBooleanTerm = ls.NewTerm(XSD, "boolean", false, false, ls.OverrideComposition, struct { XMLBooleanParser }{ XMLBooleanParser{}, }, "xsd:boolean", "xs:boolean")
var XSDDateTerm = ls.NewTerm(XSD, "date", false, false, ls.OverrideComposition, struct { XSDDateParser }{ XSDDateParser: XSDDateParser{}, }, "xsd:date", "xs:date")
XSDDate is a node-type that identifies the underlying value as an XML date. The format is:
[-]CCYY-MM-DD[Z|(+|-)hh:mm]
var XSDDateTimeTerm = ls.NewTerm(XSD, "dateTime", false, false, ls.OverrideComposition, struct { XSDDateTimeParser }{ XSDDateTimeParser: XSDDateTimeParser{}, }, "xsd:dateTime", "xs:dateTime")
XSDDateTime is a node-type that identifies the underlying value as an XML date-time value
var XSDGDayTerm = ls.NewTerm(XSD, "gDay", false, false, ls.OverrideComposition, struct { XSDGDayParser }{ XSDGDayParser: XSDGDayParser{}, }, "xsd:gDay", "xs:gDay")
XSDGday can be used as a node-type to interpret the underlying value as a day (GDay)
var XSDGMonthDayTerm = ls.NewTerm(XSD, "gMonthDay", false, false, ls.OverrideComposition, struct { XSDGMonthDayParser }{ XSDGMonthDayParser: XSDGMonthDayParser{}, }, "xsd:gMonthDay", "xs:gMonthDay")
XSDMonthDay can be used as a node-type to interpret the underlying value as a MM-DD
var XSDGMonthTerm = ls.NewTerm(XSD, "gMonth", false, false, ls.OverrideComposition, struct { XSDGMonthParser }{ XSDGMonthParser: XSDGMonthParser{}, }, "xsd:gMonth", "xs:gMonth")
XSDGMonth can be used as node-type to interpret the underlying value as a month (int)
var XSDGYearMonthTerm = ls.NewTerm(XSD, "gYearMonth", false, false, ls.OverrideComposition, struct { XSDGYearMonthParser }{ XSDGYearMonthParser: XSDGYearMonthParser{}, }, "xsd:gYearMonth", "xs:gYearMonth")
XSDGYearMonth can be used as a node-type to interpret the underlying value as a YYYY-MM
var XSDGYearTerm = ls.NewTerm(XSD, "gYear", false, false, ls.OverrideComposition, struct { XSDGYearParser }{ XSDGYearParser: XSDGYearParser{}, }, "xsd:gYear", "xs:gYear")
XSDGYear can be used as a node-type to interpret the underlying value as a year value (int)
var XSDTimeTerm = ls.NewTerm(XSD, "time", false, false, ls.OverrideComposition, struct { XSDTimeParser }{ XSDTimeParser: XSDTimeParser{}, }, "xsd:time", "xs:time")
XSDTime is a node-type that identifies the underlying value as an XML time.
Functions ¶
func BuildMeasureNodes ¶
func BuildMeasureNodes(ctx *ls.Context, builder ls.GraphBuilder, measureSchemaNode graph.Node) error
BuildMeasureNode uses the measureSchemaNode to locate measure node instances in the graph, and creates/updates measure nodes in the graph. This function uses the measure service set in the context.
func BuildMeasureNodesForLayer ¶
BuildMeasureNodesForLayer builds all the measure nodes for the layer
func SetMeasureService ¶
func SetMeasureService(ctx *ls.Context, svc MeasureService)
SetMeasureService sets the measure service in context
func SetMeasureValue ¶
func SetMeasureValue(ctx *ls.Context, svc MeasureService, measureNode, schemaNode graph.Node, value Measure) error
SetMeasureValue sets the value of the measure node based on value. The schemaNode is used to collect measure annotations, and can be the same as the measure node, or can be nil. If nil, measure node itself will be used. The measure service will be used if the measure has to be converted to a different unit.
Types ¶
type DateTime ¶
type ErrCannotParseTemporalValue ¶
type ErrCannotParseTemporalValue string
func (ErrCannotParseTemporalValue) Error ¶
func (e ErrCannotParseTemporalValue) Error() string
type ErrIncompatibleTypes ¶
type ErrIncompatibleTypes struct {
// contains filtered or unexported fields
}
func (ErrIncompatibleTypes) Error ¶
func (e ErrIncompatibleTypes) Error() string
type ErrMeasureProcessing ¶
func (ErrMeasureProcessing) Error ¶
func (e ErrMeasureProcessing) Error() string
type ErrMultipleNodesMatch ¶
type ErrMultipleNodesMatch struct {
Src string
}
func (ErrMultipleNodesMatch) Error ¶
func (e ErrMultipleNodesMatch) Error() string
type ErrNotAMeasure ¶
type ErrNotAMeasure struct {
Value string
}
func (ErrNotAMeasure) Error ¶
func (e ErrNotAMeasure) Error() string
type GYearMonth ¶
GYearMonth is XML Gregorian part of Year/Month
func (GYearMonth) String ¶
func (g GYearMonth) String() string
type JSONBooleanParser ¶
type JSONBooleanParser struct{}
func (JSONBooleanParser) FormatNativeValue ¶
func (JSONBooleanParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (JSONBooleanParser) GetNativeValue ¶
func (JSONBooleanParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type JSONDateParser ¶
type JSONDateParser struct{}
func (JSONDateParser) FormatNativeValue ¶
func (JSONDateParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
FormatNativeValue gets a target node and it's go native value, and returns the value of the target node to an JSONDate
func (JSONDateParser) GetNativeValue ¶
func (JSONDateParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
ParseValue parses a JSON date
YYYY-MM-DD
type JSONDateTimeParser ¶
type JSONDateTimeParser struct{}
func (JSONDateTimeParser) FormatNativeValue ¶
func (JSONDateTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
"2006-01-02T11:11:11Z07:00" -> Note: uses a 24Hour based clock "2006-01-02T11:11:11.999999999Z07:00"
func (JSONDateTimeParser) GetNativeValue ¶
func (JSONDateTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
ParseValue parses a JSON date-time
YYYY-MM-DD
type JSONTimeParser ¶
type JSONTimeParser struct{}
func (JSONTimeParser) FormatNativeValue ¶
func (JSONTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (JSONTimeParser) GetNativeValue ¶
func (JSONTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
ParseValue parses a JSON time
HH:mm HH:mm:ss HH:mm:ssZ
type Measure ¶
type Measure struct {
Value string `json:"value" yaml:"value"`
Unit string `json:"unit" yaml:"unit"`
}
Measure is the data type that contains a value and a unit
func ParseMeasure ¶
ParseMeasure parses a number and then a string for units
type MeasureService ¶
type MeasureService interface {
// If the measure value does not include a spearate unit field,
// then the field may be embedded into the value. This will parse
// the embedded unit if possible and return it as a measure
Parse(string) (Measure, error)
// Convert a given measure into target unit if possible. Domain
// may or may not be present, and may qualify the measure (such as
// whether this is a height or weight, etc).
Convert(measure Measure, targetUnit string, domain string) (Measure, error)
}
MeasureService parses/validates/converts measures
func GetMeasureService ¶
func GetMeasureService(ctx *ls.Context) MeasureService
GetMeasureService returns the measure service set in the context. If there is none, returns defaultMeasureService
type PatternDateParser ¶
type PatternDateParser struct{}
func (PatternDateParser) FormatNativeValue ¶
func (PatternDateParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (PatternDateParser) GetNativeValue ¶
func (PatternDateParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
ParseValue looks at the goTimeFormat, momentTimeFormat properties in the node, and parses the datetime using that. The format property can be an array, giving all possible formats
type PatternDateTimeParser ¶
type PatternDateTimeParser struct{}
func (PatternDateTimeParser) FormatNativeValue ¶
func (PatternDateTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (PatternDateTimeParser) GetNativeValue ¶
func (PatternDateTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
GetNativeValue looks at the goTimeFormat, momentTimeFormat properties in the node, and parses the datetime using that. The format property can be an array, giving all possible formats
type PatternTimeParser ¶
type PatternTimeParser struct{}
func (PatternTimeParser) FormatNativeValue ¶
func (PatternTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (PatternTimeParser) GetNativeValue ¶
func (PatternTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
ParseValue looks at the goTimeFormat, momentTimeFormat properties in the node, and parses the datetime using that. The format property can be an array, giving all possible formats
type TimeOfDay ¶
type UnixTimeNano ¶
func (UnixTimeNano) String ¶
func (u UnixTimeNano) String() string
func (UnixTimeNano) ToTime ¶
func (u UnixTimeNano) ToTime() time.Time
type UnixTimeNanoParser ¶
type UnixTimeNanoParser struct{}
func (UnixTimeNanoParser) FormatNativeValue ¶
func (UnixTimeNanoParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (UnixTimeNanoParser) GetNativeValue ¶
func (UnixTimeNanoParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type UnixTimeParser ¶
type UnixTimeParser struct{}
func (UnixTimeParser) FormatNativeValue ¶
func (UnixTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (UnixTimeParser) GetNativeValue ¶
func (UnixTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XMLBooleanParser ¶
type XMLBooleanParser struct{}
func (XMLBooleanParser) FormatNativeValue ¶
func (XMLBooleanParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XMLBooleanParser) GetNativeValue ¶
func (XMLBooleanParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDDateParser ¶
type XSDDateParser struct{}
func (XSDDateParser) FormatNativeValue ¶
func (XSDDateParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
FormatNativeValue gets a target node and it's go native value, and returns the value of the target node to an XSDDate
func (XSDDateParser) GetNativeValue ¶
func (XSDDateParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
GetNativeValue parses an XSDDate value.
[-]CCYY-MM-DD[Z|(+|-)hh:mm]
type XSDDateTimeParser ¶
type XSDDateTimeParser struct{}
func (XSDDateTimeParser) FormatNativeValue ¶
func (XSDDateTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDDateTimeParser) GetNativeValue ¶
func (XSDDateTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDGDayParser ¶
type XSDGDayParser struct{}
func (XSDGDayParser) FormatNativeValue ¶
func (XSDGDayParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDGDayParser) GetNativeValue ¶
func (XSDGDayParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDGMonthDayParser ¶
type XSDGMonthDayParser struct{}
func (XSDGMonthDayParser) FormatNativeValue ¶
func (XSDGMonthDayParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDGMonthDayParser) GetNativeValue ¶
func (XSDGMonthDayParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDGMonthParser ¶
type XSDGMonthParser struct{}
func (XSDGMonthParser) FormatNativeValue ¶
func (XSDGMonthParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDGMonthParser) GetNativeValue ¶
func (XSDGMonthParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDGYearMonthParser ¶
type XSDGYearMonthParser struct{}
func (XSDGYearMonthParser) FormatNativeValue ¶
func (XSDGYearMonthParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDGYearMonthParser) GetNativeValue ¶
func (XSDGYearMonthParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDGYearParser ¶
type XSDGYearParser struct{}
func (XSDGYearParser) FormatNativeValue ¶
func (XSDGYearParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDGYearParser) GetNativeValue ¶
func (XSDGYearParser) GetNativeValue(value string, node graph.Node) (interface{}, error)
type XSDTimeParser ¶
type XSDTimeParser struct{}
func (XSDTimeParser) FormatNativeValue ¶
func (XSDTimeParser) FormatNativeValue(newValue, oldValue interface{}, node graph.Node) (string, error)
func (XSDTimeParser) GetNativeValue ¶
func (XSDTimeParser) GetNativeValue(value string, node graph.Node) (interface{}, error)