Skip to content

Commit 2048e75

Browse files
add helper method in ModelObject to create ExtractedLicenseInfo correctly
Signed-off-by: jkraenzke <jan.kraenzke@metaeffekt.com>
1 parent 0f80417 commit 2048e75

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

src/main/java/org/spdx/library/model/ModelObject.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@
4040
import org.spdx.library.model.enumerations.ReferenceCategory;
4141
import org.spdx.library.model.enumerations.RelationshipType;
4242
import org.spdx.library.model.enumerations.SpdxEnumFactory;
43-
import org.spdx.library.model.license.AnyLicenseInfo;
44-
import org.spdx.library.model.license.ConjunctiveLicenseSet;
43+
import org.spdx.library.model.license.*;
4544
import org.spdx.library.model.license.CrossRef.CrossRefBuilder;
46-
import org.spdx.library.model.license.DisjunctiveLicenseSet;
47-
import org.spdx.library.model.license.ListedLicenses;
48-
import org.spdx.library.model.license.SpdxNoAssertionLicense;
49-
import org.spdx.library.model.license.SpdxNoneLicense;
5045
import org.spdx.library.model.pointer.ByteOffsetPointer;
5146
import org.spdx.library.model.pointer.LineCharPointer;
5247
import org.spdx.library.model.pointer.SinglePointer;
@@ -1418,6 +1413,24 @@ public CrossRefBuilder createCrossRef(String url) throws InvalidSPDXAnalysisExce
14181413
return new CrossRefBuilder(this.modelStore, this.documentUri,
14191414
this.modelStore.getNextId(IdType.Anonymous, this.documentUri), this.copyManager, url);
14201415
}
1416+
1417+
/**
1418+
* Constructs {@link ExtractedLicenseInfo} with text set.
1419+
*
1420+
* <p> Note that object construction has side-effects relating to a document and modelStore,
1421+
* requiring document context.
1422+
* This may bind usage of {@link ExtractedLicenseInfo} instances to the document that they were created by!
1423+
*
1424+
* @param id id that the text relates to
1425+
* @param text license text corresponding to the id
1426+
* @return returns a constructed object
1427+
* @throws InvalidSPDXAnalysisException
1428+
*/
1429+
public ExtractedLicenseInfo createExtractedLicense(String id, String text) throws InvalidSPDXAnalysisException {
1430+
ExtractedLicenseInfo eli = new ExtractedLicenseInfo(modelStore, documentUri, id, copyManager, true);
1431+
eli.setExtractedText(text);
1432+
return eli;
1433+
}
14211434

14221435
@Override
14231436
public String toString() {

0 commit comments

Comments
 (0)