aboutsummaryrefslogtreecommitdiff
path: root/tvloader/parser2v1/parse_other_license.go
diff options
context:
space:
mode:
Diffstat (limited to 'tvloader/parser2v1/parse_other_license.go')
-rw-r--r--tvloader/parser2v1/parse_other_license.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/tvloader/parser2v1/parse_other_license.go b/tvloader/parser2v1/parse_other_license.go
new file mode 100644
index 0000000..a2c3d00
--- /dev/null
+++ b/tvloader/parser2v1/parse_other_license.go
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
+
+package parser2v1
+
+import (
+ "fmt"
+
+ "github.com/spdx/tools-golang/spdx/v2_1"
+)
+
+func (parser *tvParser2_1) parsePairFromOtherLicense2_1(tag string, value string) error {
+ switch tag {
+ // tag for creating new other license section
+ case "LicenseID":
+ parser.otherLic = &v2_1.OtherLicense{}
+ parser.doc.OtherLicenses = append(parser.doc.OtherLicenses, parser.otherLic)
+ parser.otherLic.LicenseIdentifier = value
+ case "ExtractedText":
+ parser.otherLic.ExtractedText = value
+ case "LicenseName":
+ parser.otherLic.LicenseName = value
+ case "LicenseCrossReference":
+ parser.otherLic.LicenseCrossReferences = append(parser.otherLic.LicenseCrossReferences, value)
+ case "LicenseComment":
+ parser.otherLic.LicenseComment = value
+ // for relationship tags, pass along but don't change state
+ case "Relationship":
+ parser.rln = &v2_1.Relationship{}
+ parser.doc.Relationships = append(parser.doc.Relationships, parser.rln)
+ return parser.parsePairForRelationship2_1(tag, value)
+ case "RelationshipComment":
+ return parser.parsePairForRelationship2_1(tag, value)
+ // for annotation tags, pass along but don't change state
+ case "Annotator":
+ parser.ann = &v2_1.Annotation{}
+ parser.doc.Annotations = append(parser.doc.Annotations, parser.ann)
+ return parser.parsePairForAnnotation2_1(tag, value)
+ case "AnnotationDate":
+ return parser.parsePairForAnnotation2_1(tag, value)
+ case "AnnotationType":
+ return parser.parsePairForAnnotation2_1(tag, value)
+ case "SPDXREF":
+ return parser.parsePairForAnnotation2_1(tag, value)
+ case "AnnotationComment":
+ return parser.parsePairForAnnotation2_1(tag, value)
+ // tag for going on to review section (DEPRECATED)
+ case "Reviewer":
+ parser.st = psReview2_1
+ return parser.parsePairFromReview2_1(tag, value)
+ default:
+ return fmt.Errorf("received unknown tag %v in OtherLicense section", tag)
+ }
+
+ return nil
+}