File: node.go

package info (click to toggle)
golang-github-spdx-gordf 0.0~git20221230.b735bd5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 324 kB
  • sloc: makefile: 4
file content (41 lines) | stat: -rw-r--r-- 743 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package parser

import "fmt"

type NODETYPE string

const (
	LITERAL         NODETYPE = "LITERAL"
	RESOURCELITERAL          = "RESOURCE"
	NODEIDLITERAL            = "NodeIDLiteral"
	BLANK                    = "BNODE"
	IRI                      = "IRI"
)

type Node struct {
	NodeType NODETYPE
	ID       string
}

func (node *Node) String() string {
	return fmt.Sprintf("(%v, %v)", node.NodeType, node.ID)
}

type BlankNodeGetter struct {
	lastid int
}

func (getter *BlankNodeGetter) Get() Node {
	getter.lastid += 1
	return Node{
		NodeType: BLANK,
		ID:       fmt.Sprintf("N%v", getter.lastid),
	}
}

func (getter *BlankNodeGetter) GetFromId(id string) Node {
	return Node{
		NodeType: NODEIDLITERAL,
		ID:       fmt.Sprintf("N%v", id),
	}
}