Parent: [r3] (diff)

Child: [r23] (diff)

Download this file

SectionPackage.java    189 lines (152 with data), 6.4 kB

  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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* SPDXVersion: SPDX-1.1
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
* Creator: Organization: TripleCheck (contact@triplecheck.de)
* Created: 2013-08-29T00:00:00Z
* LicenseName: NOASSERTION
* FileName: SectionPackage.java
* FileType: SOURCE
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
* FileComment: <text>Class to define the properties of the SPDX 1.1 SectionPackage
* Infomation field</text>
*/
package spdxlib;
import java.util.ArrayList;
public class SectionPackage {
public TagValue
name, // formal name of the package, mandatory, one
version, // optional, one
fileName; // filename of the compressed file, optional, one
public Person
supplier = new Person(), // organization and author, optional, one
originator = new Person();// only if supplier differs, optional, one
public TagValue
// Data Format: uniform resource locator | ���NONE��� | ���NOASSERTION���
downloadLocation, // where it can be downloaded, mandatory, one
// Data Format: 160 bit binary represented as 40 hexidecimal digits
verificationCode, // special calculation routine, mandatory, one
checksum, // SHA1 checksum of the package, optional, one
sourceInfo, // other info about the origin, optional, one
licenseConcluded; // the overall licensing terms, mandatory, one
public ArrayList<TagValue>// list the licenses collected from the files included
licenseInfoFromFiles = new ArrayList(); // mandatory, one or many
public TagValue //TODO attention to be given on multiple/disjunctive licenses
licenseDeclared, // license declared by author, mandatory, one
licenseComments, // other info about the origin, optional, one
copyrighText, // report date/copyrights applicable, mandatory, one
summary, // summarize use or function of package, optional, one
description; // detail use or function of package, optional, one
public ArrayList<FileInfo> // information about all files present on the package
files = new ArrayList(); // mandatory, one or many
public ArrayList<TagValue> // tags not recognized
unknown = new ArrayList(); // mandatory, one or many
// non-standard data
public ArrayList<TagValue>// list the dependencies for this SPDX document
dependencies = new ArrayList(); // optional, one or many
public boolean parseTag(TagValue tag){
// only process tags starting with "Creat"
if((tag.title.length() < 7)
|| (!tag.title.substring(0, 7).equalsIgnoreCase("Package"))){
return false;
}
if(tag.title.equalsIgnoreCase("PackageName")){
this.name = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageVersion")){
this.version = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageFileName")){
this.fileName = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageSupplier->Person")){
supplier.setTagPerson(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageSupplier->Organization")){
supplier.setTagOrganization(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageSupplier->Tool")){
supplier.setTagTool(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageOriginator->Person")){
originator.setTagPerson(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageOriginator->Organization")){
supplier.setTagOrganization(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageOriginator->Tool")){
supplier.setTagTool(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageDownloadLocation")){
this.downloadLocation = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageVerificationCode")){
this.verificationCode = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageChecksum->SHA1")){
this.checksum = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageSourceInfo")){
this.sourceInfo = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageLicenseConcluded")){
this.licenseConcluded = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageLicenseInfoFromFiles")){
this.licenseInfoFromFiles.add(tag);
return true;
}
if(tag.title.equalsIgnoreCase("PackageLicenseDeclared")){
this.licenseDeclared = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageLicenseComments")){
this.licenseComments = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageCopyrightText")){
this.copyrighText = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageSummary")){
this.summary = tag;
return true;
}
if(tag.title.equalsIgnoreCase("PackageDescription")){
this.description = tag;
return true;
}
// non-standard data
if(tag.title.equalsIgnoreCase("PackageDependency")){
this.dependencies.add(tag);
return true;
}
// we found some tags that is unknown
unknown.add(tag); // add it for future processing
System.out.println("Unknown package tag found: "
+ tag.title + " = " + tag);
// nothing found, return false
return false;
}
/**
* This method is used by tree nodes
* @return
*/
@Override
public String toString(){
return "Package";
}
}