types

package
v1.0.0-beta14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const JSON = "https:/json-schema.org/"
View Source
const Unix = "https://unixtime.org/"
View Source
const XSD = "http://www.w3.org/2001/XMLSchema/"

Variables

View Source
var GoTimeFormatTerm = ls.NewTerm(ls.LS, "goTimeFormat", false, false, ls.SetComposition, nil, "ls:goTimeFormat")
View Source
var JSONBooleanTerm = ls.NewTerm(JSON, "boolean", false, false, ls.OverrideComposition, struct {
	JSONBooleanParser
}{
	JSONBooleanParser{},
}, "json:boolean")
View Source
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
View Source
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

View Source
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
View Source
var MeasureTerm = ls.NewTerm(ls.LS, "Measure", false, false, ls.OverrideComposition, struct {
	measureParser
}{
	measureParser{},
})

MeasureTerm is used as a valueType.

A measure should have a value and a unit. There are several ways the values and units are specified.

A node may specify value and unit in its node value.

Node:

Measure
value: value and unit

A node may specify value and unit separately in its properties:

Node:

Measure
value: 123
measureUnit: <unit>

A node may be point to other nodes containing value or unit.

Node:                                  Node:
 Measure                              value: <unit>
 value: 123                            schemaNodeId: A
 measureUnitNode: A

Node:                     Node:               Node:
 Measure                  value: <unit>       value: <value>
 measureUnitNode: A       schemaNodeId: A     schemaNodeId: B
 measureValueNode: B

A node may refer to other nodes using pattern expressions

Node:
  Measure
  value: 123
  measureUnitPath: (this)<-[]-()-[]->(target : schemaNodeId:B)

            Node:
            value: <unit>
            schemaNodeId: B
View Source
var MeasureUnitNodeTerm = ls.NewTerm(ls.LS, "measure/unitNode", false, false, ls.OverrideComposition, nil)

MeasureUnitNodeTerm gives the schema node ID of the unit node

View Source
var MeasureUnitPathTerm = ls.NewTerm(ls.LS, "measure/unitPath", false, false, ls.OverrideComposition, nil)

MeasureUnitPathTerm gives the path to the unit node

View Source
var MeasureUnitTerm = ls.NewTerm(ls.LS, "measure/unit", false, false, ls.OverrideComposition, nil)

MeasureUnitTerm is a node property term giving measure unit

View Source
var MeasureValueNodeTerm = ls.NewTerm(ls.LS, "measure/valueNode", false, false, ls.OverrideComposition, nil)

MeasureValueNodeTerm gives the schema node ID of the value node

View Source
var MeasureValuePathTerm = ls.NewTerm(ls.LS, "measure/valuePath", false, false, ls.OverrideComposition, nil)

MeasureValuePathTerm gives the path to the value node

View Source
var MomentTimeFormatTerm = ls.NewTerm(ls.LS, "momentTimeFormat", false, false, ls.SetComposition, nil, "ls:momentTimeFormat")
View Source
var PatternDateTerm = ls.NewTerm(ls.LS, "date", false, false, ls.OverrideComposition, struct {
	PatternDateParser
}{
	PatternDateParser: PatternDateParser{},
}, "ls:date")
View Source
var PatternDateTimeTerm = ls.NewTerm(ls.LS, "dateTime", false, false, ls.OverrideComposition, struct {
	PatternDateTimeParser
}{
	PatternDateTimeParser: PatternDateTimeParser{},
}, "ls:dateTime")
View Source
var PatternTimeTerm = ls.NewTerm(ls.LS, "time", false, false, ls.OverrideComposition, struct {
	PatternTimeParser
}{
	PatternTimeParser: PatternTimeParser{},
}, "ls:time")
View Source
var UnixTimeNanoTerm = ls.NewTerm(Unix, "timeNano", false, false, ls.OverrideComposition, struct {
	UnixTimeNanoParser
}{
	UnixTimeNanoParser: UnixTimeNanoParser{},
}, "unix:timeNano")
View Source
var UnixTimeTerm = ls.NewTerm(Unix, "time", false, false, ls.OverrideComposition, struct {
	UnixTimeParser
}{
	UnixTimeParser: UnixTimeParser{},
}, "unix:time")
View Source
var XMLBooleanTerm = ls.NewTerm(XSD, "boolean", false, false, ls.OverrideComposition, struct {
	XMLBooleanParser
}{
	XMLBooleanParser{},
}, "xsd:boolean", "xs:boolean")
View Source
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]
View Source
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

View Source
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)

View Source
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

View Source
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)

View Source
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

View Source
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)

View Source
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 SetNodeMeasureValue

func SetNodeMeasureValue(node graph.Node, value Measure) error

SetNodeMeasureValue tries to set the measure and unit values based on the given Measure value

func ToGomentTime

func ToGomentTime(time time.Time) (*goment.Goment, error)

try to convert to go native time with function ToGoTime then pass result as parameter

Types

type Date

type Date struct {
	Month    int
	Day      int
	Year     int
	Location *time.Location
}

func (Date) String

func (d Date) String() string

func (Date) ToTime

func (d Date) ToTime() time.Time

type DateTime

type DateTime struct {
	Month        int
	Day          int
	Year         int
	Nanoseconds  int64
	Milliseconds int64
	Seconds      int64
	Minute       int64
	Hour         int64
	Location     *time.Location
}

func (DateTime) String

func (dt DateTime) String() string

func (DateTime) ToTime

func (dt DateTime) ToTime() time.Time

type ErrCannotParseTemporalValue

type ErrCannotParseTemporalValue string

func (ErrCannotParseTemporalValue) Error

type ErrIncompatibleTypes

type ErrIncompatibleTypes struct {
	// contains filtered or unexported fields
}

func (ErrIncompatibleTypes) Error

func (e ErrIncompatibleTypes) 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 GDay

type GDay int

GDay is XML Gregorian day part of date

func (GDay) String

func (g GDay) String() string

type GMonth

type GMonth int

GMonth is XML Gregorian month part of date

func (GMonth) String

func (g GMonth) String() string

type GMonthDay

type GMonthDay struct {
	Day   int
	Month int
}

GMonthDay is XML Gregorian part of Month/Day

func (GMonthDay) String

func (g GMonthDay) String() string

type GYear

type GYear int

GMonth is XML Gregorian year part of date

func (GYear) String

func (g GYear) String() string

type GYearMonth

type GYearMonth struct {
	Year  int
	Month int
}

GYearMonth is XML Gregorian part of Year/Month

func (GYearMonth) String

func (g GYearMonth) String() string

type JSONBooleanParser

type JSONBooleanParser struct{}

func (JSONBooleanParser) GetNodeValue

func (JSONBooleanParser) GetNodeValue(node graph.Node) (interface{}, error)

func (JSONBooleanParser) SetNodeValue

func (JSONBooleanParser) SetNodeValue(node graph.Node, value interface{}) error

type JSONDateParser

type JSONDateParser struct{}

func (JSONDateParser) GetNodeValue

func (JSONDateParser) GetNodeValue(node graph.Node) (interface{}, error)

ParseValue parses a JSON date

YYYY-MM-DD

func (JSONDateParser) SetNodeValue

func (JSONDateParser) SetNodeValue(node graph.Node, value interface{}) error

SetValue gets a target node and it's go native value, and sets the value of the target node to an JSONDate

type JSONDateTimeParser

type JSONDateTimeParser struct{}

func (JSONDateTimeParser) GetNodeValue

func (JSONDateTimeParser) GetNodeValue(node graph.Node) (interface{}, error)

ParseValue parses a JSON date-time

YYYY-MM-DD

func (JSONDateTimeParser) SetNodeValue

func (JSONDateTimeParser) SetNodeValue(node graph.Node, value interface{}) error

"2006-01-02T11:11:11Z07:00" -> Note: uses a 24Hour based clock "2006-01-02T11:11:11.999999999Z07:00"

type JSONTimeParser

type JSONTimeParser struct{}

func (JSONTimeParser) GetNodeValue

func (JSONTimeParser) GetNodeValue(node graph.Node) (interface{}, error)

ParseValue parses a JSON time

HH:mm
HH:mm:ss
HH:mm:ssZ

func (JSONTimeParser) SetNodeValue

func (JSONTimeParser) SetNodeValue(node graph.Node, value interface{}) error

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 GetNodeMeasureValue

func GetNodeMeasureValue(node graph.Node) (*Measure, error)

GetNodeMeasureValue tries to load the measure and unit from the given Measure node

type PatternDateParser

type PatternDateParser struct{}

func (PatternDateParser) GetNodeValue

func (PatternDateParser) GetNodeValue(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

func (PatternDateParser) SetNodeValue

func (PatternDateParser) SetNodeValue(node graph.Node, value interface{}) error

type PatternDateTimeParser

type PatternDateTimeParser struct{}

func (PatternDateTimeParser) GetNodeValue

func (PatternDateTimeParser) GetNodeValue(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

func (PatternDateTimeParser) SetNodeValue

func (PatternDateTimeParser) SetNodeValue(node graph.Node, value interface{}) error

type PatternTimeParser

type PatternTimeParser struct{}

func (PatternTimeParser) GetNodeValue

func (PatternTimeParser) GetNodeValue(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

func (PatternTimeParser) SetNodeValue

func (PatternTimeParser) SetNodeValue(node graph.Node, value interface{}) error

type TimeOfDay

type TimeOfDay struct {
	Nanoseconds  int64
	Milliseconds int64
	Seconds      int64
	Minute       int64
	Hour         int64
	Location     *time.Location
}

func (TimeOfDay) String

func (t TimeOfDay) String() string

func (TimeOfDay) ToTime

func (t TimeOfDay) ToTime() time.Time

type UnixTime

type UnixTime struct {
	Seconds  int64
	Location *time.Location
}

func (UnixTime) String

func (u UnixTime) String() string

func (UnixTime) ToTime

func (u UnixTime) ToTime() time.Time

type UnixTimeNano

type UnixTimeNano struct {
	Nanoseconds int64
	Location    *time.Location
}

func (UnixTimeNano) String

func (u UnixTimeNano) String() string

func (UnixTimeNano) ToTime

func (u UnixTimeNano) ToTime() time.Time

type UnixTimeNanoParser

type UnixTimeNanoParser struct{}

func (UnixTimeNanoParser) GetNodeValue

func (UnixTimeNanoParser) GetNodeValue(node graph.Node) (interface{}, error)

func (UnixTimeNanoParser) SetNodeValue

func (UnixTimeNanoParser) SetNodeValue(node graph.Node, value interface{}) error

type UnixTimeParser

type UnixTimeParser struct{}

func (UnixTimeParser) GetNodeValue

func (UnixTimeParser) GetNodeValue(node graph.Node) (interface{}, error)

func (UnixTimeParser) SetNodeValue

func (UnixTimeParser) SetNodeValue(node graph.Node, value interface{}) error

type XMLBooleanParser

type XMLBooleanParser struct{}

func (XMLBooleanParser) GetNodeValue

func (XMLBooleanParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XMLBooleanParser) SetNodeValue

func (XMLBooleanParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDDateParser

type XSDDateParser struct{}

func (XSDDateParser) GetNodeValue

func (XSDDateParser) GetNodeValue(node graph.Node) (interface{}, error)

ParseValue parses an XSDDate value.

[-]CCYY-MM-DD[Z|(+|-)hh:mm]

func (XSDDateParser) SetNodeValue

func (XSDDateParser) SetNodeValue(node graph.Node, value interface{}) error

SetValue gets a target node and it's go native value, and sets the value of the target node to an XSDDate

type XSDDateTimeParser

type XSDDateTimeParser struct{}

func (XSDDateTimeParser) GetNodeValue

func (XSDDateTimeParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDDateTimeParser) SetNodeValue

func (XSDDateTimeParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDGDayParser

type XSDGDayParser struct{}

func (XSDGDayParser) GetNodeValue

func (XSDGDayParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDGDayParser) SetNodeValue

func (XSDGDayParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDGMonthDayParser

type XSDGMonthDayParser struct{}

func (XSDGMonthDayParser) GetNodeValue

func (XSDGMonthDayParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDGMonthDayParser) SetNodeValue

func (XSDGMonthDayParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDGMonthParser

type XSDGMonthParser struct{}

func (XSDGMonthParser) GetNodeValue

func (XSDGMonthParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDGMonthParser) SetNodeValue

func (XSDGMonthParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDGYearMonthParser

type XSDGYearMonthParser struct{}

func (XSDGYearMonthParser) GetNodeValue

func (XSDGYearMonthParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDGYearMonthParser) SetNodeValue

func (XSDGYearMonthParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDGYearParser

type XSDGYearParser struct{}

func (XSDGYearParser) GetNodeValue

func (XSDGYearParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDGYearParser) SetNodeValue

func (XSDGYearParser) SetNodeValue(node graph.Node, value interface{}) error

type XSDTimeParser

type XSDTimeParser struct{}

func (XSDTimeParser) GetNodeValue

func (XSDTimeParser) GetNodeValue(node graph.Node) (interface{}, error)

func (XSDTimeParser) SetNodeValue

func (XSDTimeParser) SetNodeValue(node graph.Node, value interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL