xref: /aosp_15_r20/external/spdx-tools/tvsaver/saver2v1/save_annotation.go (revision ba677afa8f67bb56cbc794f4d0e378e0da058e16)
1// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
2
3package saver2v1
4
5import (
6	"fmt"
7	"io"
8
9	"github.com/spdx/tools-golang/spdx/common"
10	"github.com/spdx/tools-golang/spdx/v2_1"
11)
12
13func renderAnnotation2_1(ann *v2_1.Annotation, w io.Writer) error {
14	if ann.Annotator.Annotator != "" && ann.Annotator.AnnotatorType != "" {
15		fmt.Fprintf(w, "Annotator: %s: %s\n", ann.Annotator.AnnotatorType, ann.Annotator.Annotator)
16	}
17	if ann.AnnotationDate != "" {
18		fmt.Fprintf(w, "AnnotationDate: %s\n", ann.AnnotationDate)
19	}
20	if ann.AnnotationType != "" {
21		fmt.Fprintf(w, "AnnotationType: %s\n", ann.AnnotationType)
22	}
23	annIDStr := common.RenderDocElementID(ann.AnnotationSPDXIdentifier)
24	if annIDStr != "SPDXRef-" {
25		fmt.Fprintf(w, "SPDXREF: %s\n", annIDStr)
26	}
27	if ann.AnnotationComment != "" {
28		fmt.Fprintf(w, "AnnotationComment: %s\n", textify(ann.AnnotationComment))
29	}
30
31	return nil
32}
33