schema

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayNode

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

func (*ArrayNode) ASTNode

func (n *ArrayNode) ASTNode() (jschema.ASTNode, error)

func (*ArrayNode) AddConstraint

func (n *ArrayNode) AddConstraint(c constraint.Constraint)

AddConstraint adds new constraint to this node. Won't add if c is nil.

func (ArrayNode) BasisLexEventOfSchemaForNode

func (n ArrayNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent

func (ArrayNode) Child

func (n ArrayNode) Child(i uint) Node

func (ArrayNode) Children

func (n ArrayNode) Children() []Node

func (*ArrayNode) Comment

func (n *ArrayNode) Comment() string

func (ArrayNode) Constraint

func (n ArrayNode) Constraint(t constraint.Type) constraint.Constraint

return *Constraint or nil (if not found)

func (ArrayNode) ConstraintMap

func (n ArrayNode) ConstraintMap() *Constraints

return map or nil

func (*ArrayNode) DeleteConstraint

func (n *ArrayNode) DeleteConstraint(t constraint.Type)

func (*ArrayNode) Grow

func (n *ArrayNode) Grow(lex lexeme.LexEvent) (Node, bool)

func (ArrayNode) IndentedNodeString

func (n ArrayNode) IndentedNodeString(depth int) string

func (ArrayNode) IndentedTreeString

func (n ArrayNode) IndentedTreeString(depth int) string

func (ArrayNode) Len

func (n ArrayNode) Len() int

func (ArrayNode) NumberOfConstraints

func (n ArrayNode) NumberOfConstraints() int

func (ArrayNode) Parent

func (n ArrayNode) Parent() Node

func (*ArrayNode) RealType

func (n *ArrayNode) RealType() string

func (*ArrayNode) SetComment

func (n *ArrayNode) SetComment(s string)

func (*ArrayNode) SetParent

func (n *ArrayNode) SetParent(parent Node)

func (*ArrayNode) SetRealType

func (n *ArrayNode) SetRealType(s string)

func (ArrayNode) Type

func (n ArrayNode) Type() json.Type

func (ArrayNode) Value

func (n ArrayNode) Value() bytes.Bytes

type BranchNode

type BranchNode interface {
	Children() []Node
	Len() int
}

BranchNode that can contain child elements (an array or an object).

type Constraints

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

Constraints an ordered map of node constraints. gen:OrderedMap

func (*Constraints) Delete

func (m *Constraints) Delete(k constraint.Type)

func (*Constraints) Each

func (m *Constraints) Each(fn eachConstraintsFunc) error

func (*Constraints) EachSafe

func (m *Constraints) EachSafe(fn eachSafeConstraintsFunc)

func (*Constraints) Filter

func (m *Constraints) Filter(fn filterConstraintsFunc)

Filter iterates and changes values in the map.

func (*Constraints) Find

func (m *Constraints) Find(fn findConstraintsFunc) (ConstraintsItem, bool)

Find finds first matched item from the map.

func (*Constraints) Get

Get gets a value by key.

func (*Constraints) GetValue

GetValue gets a value by key.

func (*Constraints) Has

func (m *Constraints) Has(k constraint.Type) bool

Has checks that specified key is set.

func (*Constraints) Len

func (m *Constraints) Len() int

Len returns count of values.

func (*Constraints) Map

func (m *Constraints) Map(fn mapConstraintsFunc) error

Map iterates and changes values in the map.

func (*Constraints) MarshalJSON

func (m *Constraints) MarshalJSON() ([]byte, error)

func (*Constraints) Set

Set sets a value with specified key.

func (*Constraints) Update

Update updates a value with specified key.

type ConstraintsItem

type ConstraintsItem struct {
	Key   constraint.Type
	Value constraint.Constraint
}

ConstraintsItem represent single data from the Constraints.

type InnerObjectNodeKey

type InnerObjectNodeKey struct {
	Lex        lexeme.LexEvent
	Index      int
	IsShortcut bool
}

type LiteralNode

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

func (*LiteralNode) ASTNode

func (n *LiteralNode) ASTNode() (jschema.ASTNode, error)

func (*LiteralNode) AddConstraint

func (n *LiteralNode) AddConstraint(c constraint.Constraint)

AddConstraint adds new constraint to this node. Won't add if c is nil.

func (LiteralNode) BasisLexEventOfSchemaForNode

func (n LiteralNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent

func (*LiteralNode) Comment

func (n *LiteralNode) Comment() string

func (LiteralNode) Constraint

func (n LiteralNode) Constraint(t constraint.Type) constraint.Constraint

return *Constraint or nil (if not found)

func (LiteralNode) ConstraintMap

func (n LiteralNode) ConstraintMap() *Constraints

return map or nil

func (*LiteralNode) DeleteConstraint

func (n *LiteralNode) DeleteConstraint(t constraint.Type)

func (*LiteralNode) Grow

func (n *LiteralNode) Grow(lex lexeme.LexEvent) (Node, bool)

func (LiteralNode) IndentedNodeString

func (n LiteralNode) IndentedNodeString(depth int) string

func (LiteralNode) IndentedTreeString

func (n LiteralNode) IndentedTreeString(depth int) string

func (LiteralNode) NumberOfConstraints

func (n LiteralNode) NumberOfConstraints() int

func (LiteralNode) Parent

func (n LiteralNode) Parent() Node

func (*LiteralNode) RealType

func (n *LiteralNode) RealType() string

func (*LiteralNode) SetComment

func (n *LiteralNode) SetComment(s string)

func (*LiteralNode) SetParent

func (n *LiteralNode) SetParent(parent Node)

func (*LiteralNode) SetRealType

func (n *LiteralNode) SetRealType(s string)

func (LiteralNode) Type

func (n LiteralNode) Type() json.Type

func (LiteralNode) Value

func (n LiteralNode) Value() bytes.Bytes

type MixedNode

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

func NewMixedNode

func NewMixedNode(lex lexeme.LexEvent) *MixedNode

func (MixedNode) ASTNode

func (n MixedNode) ASTNode() (jschema.ASTNode, error)

func (*MixedNode) AddConstraint

func (n *MixedNode) AddConstraint(c constraint.Constraint)

AddConstraint adds new constraint to this node. Won't add if c is nil.

func (MixedNode) BasisLexEventOfSchemaForNode

func (n MixedNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent

func (*MixedNode) Comment

func (n *MixedNode) Comment() string

func (MixedNode) Constraint

func (n MixedNode) Constraint(t constraint.Type) constraint.Constraint

return *Constraint or nil (if not found)

func (MixedNode) ConstraintMap

func (n MixedNode) ConstraintMap() *Constraints

return map or nil

func (*MixedNode) DeleteConstraint

func (n *MixedNode) DeleteConstraint(t constraint.Type)

func (*MixedNode) Grow

func (*MixedNode) Grow(lexeme.LexEvent) (Node, bool)

func (MixedNode) IndentedNodeString

func (n MixedNode) IndentedNodeString(depth int) string

func (MixedNode) IndentedTreeString

func (n MixedNode) IndentedTreeString(depth int) string

func (MixedNode) NumberOfConstraints

func (n MixedNode) NumberOfConstraints() int

func (MixedNode) Parent

func (n MixedNode) Parent() Node

func (*MixedNode) RealType

func (n *MixedNode) RealType() string

func (*MixedNode) SetComment

func (n *MixedNode) SetComment(s string)

func (*MixedNode) SetJsonType

func (n *MixedNode) SetJsonType(t json.Type)

for mixed node n.baseNode.jsonType is an EXAMPLE type

func (*MixedNode) SetParent

func (n *MixedNode) SetParent(parent Node)

func (*MixedNode) SetRealType

func (n *MixedNode) SetRealType(s string)

func (MixedNode) Type

func (n MixedNode) Type() json.Type

func (MixedNode) Value

func (n MixedNode) Value() bytes.Bytes

type MixedValueNode

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

func NewMixedValueNode

func NewMixedValueNode(lex lexeme.LexEvent) *MixedValueNode

func (*MixedValueNode) ASTNode

func (n *MixedValueNode) ASTNode() (jschema.ASTNode, error)

func (*MixedValueNode) AddConstraint

func (n *MixedValueNode) AddConstraint(c constraint.Constraint)

func (MixedValueNode) BasisLexEventOfSchemaForNode

func (n MixedValueNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent

func (*MixedValueNode) Comment

func (n *MixedValueNode) Comment() string

func (MixedValueNode) Constraint

func (n MixedValueNode) Constraint(t constraint.Type) constraint.Constraint

return *Constraint or nil (if not found)

func (MixedValueNode) ConstraintMap

func (n MixedValueNode) ConstraintMap() *Constraints

return map or nil

func (*MixedValueNode) DeleteConstraint

func (n *MixedValueNode) DeleteConstraint(t constraint.Type)

func (*MixedValueNode) Grow

func (n *MixedValueNode) Grow(lex lexeme.LexEvent) (Node, bool)

func (*MixedValueNode) IndentedNodeString

func (n *MixedValueNode) IndentedNodeString(depth int) string

func (*MixedValueNode) IndentedTreeString

func (n *MixedValueNode) IndentedTreeString(depth int) string

func (MixedValueNode) NumberOfConstraints

func (n MixedValueNode) NumberOfConstraints() int

func (MixedValueNode) Parent

func (n MixedValueNode) Parent() Node

func (*MixedValueNode) RealType

func (n *MixedValueNode) RealType() string

func (*MixedValueNode) SetComment

func (n *MixedValueNode) SetComment(s string)

func (*MixedValueNode) SetParent

func (n *MixedValueNode) SetParent(parent Node)

func (*MixedValueNode) SetRealType

func (n *MixedValueNode) SetRealType(s string)

func (MixedValueNode) Type

func (n MixedValueNode) Type() json.Type

func (MixedValueNode) Value

func (n MixedValueNode) Value() bytes.Bytes

type Node

type Node interface {
	// Type returns type of this node.
	Type() json.Type

	SetRealType(string)
	RealType() string

	// Parent returns a parent of this node.
	Parent() Node

	// SetParent sets a parent for this node.
	SetParent(Node)

	// BasisLexEventOfSchemaForNode returns a LexEvent from the scheme on the
	// basis of which the node is created. It is used to check on the schemes for
	// compliance with the example and the list of constraints. Also used to display
	// an error.
	BasisLexEventOfSchemaForNode() lexeme.LexEvent

	// Grow this method receives the input lexical event from the scanner, fill
	// yourself with data from them. If necessary, creates children. Returns the
	// node to which you want to pass the next lexeme (yourself, child, or parent).
	Grow(lexeme.LexEvent) (Node, bool)

	// Constraint returns a constraint by its type.
	Constraint(constraint.Type) constraint.Constraint

	// AddConstraint adds a constraint to this node.
	AddConstraint(constraint.Constraint)

	// DeleteConstraint removes a constraint from this node.
	DeleteConstraint(constraint.Type)

	// ConstraintMap returns a list of constraints or nil (if empty).
	ConstraintMap() *Constraints

	// NumberOfConstraints returns the number of constraints.
	NumberOfConstraints() int

	// IndentedTreeString returns the text representation of the node and recursively
	// all children. You can specify the indent (number of tabs) that is placed
	// before each line in the text view.
	IndentedTreeString(int) string

	// IndentedNodeString returns the text representation of the node without children.
	// You can specify the indent (number of tabs) that is placed before each line
	// in the text view.
	IndentedNodeString(int) string

	// Value returns this node's value.
	Value() bytes.Bytes

	// ASTNode returns proper ASTNode for this node.
	ASTNode() (jschema.ASTNode, error)

	// SetComment sets a comment for this node.
	SetComment(string)

	// Comment returns this node comment.
	Comment() string
}

func NewNode

func NewNode(lex lexeme.LexEvent) Node

type ObjectNode

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

func (*ObjectNode) ASTNode

func (n *ObjectNode) ASTNode() (jschema.ASTNode, error)

func (*ObjectNode) AddChild

func (n *ObjectNode) AddChild(key ObjectNodeKey, child Node)

func (*ObjectNode) AddConstraint

func (n *ObjectNode) AddConstraint(c constraint.Constraint)

AddConstraint adds new constraint to this node. Won't add if c is nil.

func (ObjectNode) BasisLexEventOfSchemaForNode

func (n ObjectNode) BasisLexEventOfSchemaForNode() lexeme.LexEvent

func (ObjectNode) Child

func (n ObjectNode) Child(key string) (Node, bool)

func (ObjectNode) Children

func (n ObjectNode) Children() []Node

func (*ObjectNode) Comment

func (n *ObjectNode) Comment() string

func (ObjectNode) Constraint

func (n ObjectNode) Constraint(t constraint.Type) constraint.Constraint

return *Constraint or nil (if not found)

func (ObjectNode) ConstraintMap

func (n ObjectNode) ConstraintMap() *Constraints

return map or nil

func (*ObjectNode) DeleteConstraint

func (n *ObjectNode) DeleteConstraint(t constraint.Type)

func (*ObjectNode) Grow

func (n *ObjectNode) Grow(lex lexeme.LexEvent) (Node, bool)

func (ObjectNode) IndentedNodeString

func (n ObjectNode) IndentedNodeString(depth int) string

func (ObjectNode) IndentedTreeString

func (n ObjectNode) IndentedTreeString(depth int) string

func (ObjectNode) Key

func (n ObjectNode) Key(index int) ObjectNodeKey

func (ObjectNode) Keys

func (n ObjectNode) Keys() *ObjectNodeKeys

func (ObjectNode) Len

func (n ObjectNode) Len() int

func (ObjectNode) NumberOfConstraints

func (n ObjectNode) NumberOfConstraints() int

func (ObjectNode) Parent

func (n ObjectNode) Parent() Node

func (*ObjectNode) RealType

func (n *ObjectNode) RealType() string

func (*ObjectNode) SetComment

func (n *ObjectNode) SetComment(s string)

func (*ObjectNode) SetParent

func (n *ObjectNode) SetParent(parent Node)

func (*ObjectNode) SetRealType

func (n *ObjectNode) SetRealType(s string)

func (ObjectNode) Type

func (ObjectNode) Type() json.Type

func (ObjectNode) Value

func (n ObjectNode) Value() bytes.Bytes

type ObjectNodeKey

type ObjectNodeKey struct {
	Name       string
	Lex        lexeme.LexEvent
	IsShortcut bool
}

type ObjectNodeKeys

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

gen:OrderedMap

func (*ObjectNodeKeys) Delete

func (m *ObjectNodeKeys) Delete(k string)

func (*ObjectNodeKeys) Each

func (m *ObjectNodeKeys) Each(fn eachObjectNodeKeysFunc) error

func (*ObjectNodeKeys) EachSafe

func (m *ObjectNodeKeys) EachSafe(fn eachSafeObjectNodeKeysFunc)

func (*ObjectNodeKeys) Filter

func (m *ObjectNodeKeys) Filter(fn filterObjectNodeKeysFunc)

Filter iterates and changes values in the map.

func (*ObjectNodeKeys) Find

func (m *ObjectNodeKeys) Find(fn findObjectNodeKeysFunc) (ObjectNodeKeysItem, bool)

Find finds first matched item from the map.

func (*ObjectNodeKeys) Get

Get gets a value by key.

func (*ObjectNodeKeys) GetValue

func (m *ObjectNodeKeys) GetValue(k string) InnerObjectNodeKey

GetValue gets a value by key.

func (*ObjectNodeKeys) Has

func (m *ObjectNodeKeys) Has(k string) bool

Has checks that specified key is set.

func (*ObjectNodeKeys) Len

func (m *ObjectNodeKeys) Len() int

Len returns count of values.

func (*ObjectNodeKeys) Map

func (m *ObjectNodeKeys) Map(fn mapObjectNodeKeysFunc) error

Map iterates and changes values in the map.

func (*ObjectNodeKeys) MarshalJSON

func (m *ObjectNodeKeys) MarshalJSON() ([]byte, error)

func (*ObjectNodeKeys) Set

Set sets a value with specified key.

func (*ObjectNodeKeys) Update

Update updates a value with specified key.

type ObjectNodeKeysItem

type ObjectNodeKeysItem struct {
	Key   string
	Value InnerObjectNodeKey
}

ObjectNodeKeysItem represent single data from the ObjectNodeKeys.

type Schema

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

func New

func New() Schema

func (*Schema) AddNamedType

func (s *Schema) AddNamedType(name string, typ *Schema, rootFile *fs.File, begin bytes.Index)

func (*Schema) AddType

func (s *Schema) AddType(n string, t Type)

func (*Schema) AddUnnamedType

func (s *Schema) AddUnnamedType(typ *Schema, rootFile *fs.File, begin bytes.Index) string

AddUnnamedType Adds an unnamed TYPE to the SCHEMA. Returns a unique name for the added TYPE.

func (Schema) RootNode

func (s Schema) RootNode() Node

func (*Schema) SetRootNode

func (s *Schema) SetRootNode(node Node)

func (Schema) String

func (s Schema) String() string

func (Schema) Type

func (s Schema) Type(name string) *Schema

Type returns *Schema or panic if not found.

func (Schema) TypesList

func (s Schema) TypesList() map[string]Type

type Type

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

func (*Type) Begin

func (s *Type) Begin() bytes.Index

func (*Type) RootFile

func (s *Type) RootFile() *fs.File

func (*Type) Schema

func (s *Type) Schema() *Schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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