Skip to content

Commit

Permalink
Merge pull request #9 from ek08/master
Browse files Browse the repository at this point in the history
Accept YML
  • Loading branch information
goneall authored Feb 24, 2021
2 parents abf3525 + 8b07d69 commit 8846a18
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/org/spdx/tools/SpdxToolsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2020 Source Auditor Inc.
*
* SPDX-License-Identifier: Apache-2.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -42,7 +42,7 @@

/**
* Static helper methods for the various tools
*
*
* @author Gary O'Neall
*
*/
Expand All @@ -51,7 +51,7 @@ public class SpdxToolsHelper {
public enum SerFileType {
JSON, RDFXML, XML, XLS, XLSX, YAML, TAG
}

static Map<String, SerFileType> EXT_TO_FILETYPE;
static {
HashMap<String, SerFileType> temp = new HashMap<>();
Expand All @@ -64,6 +64,7 @@ public enum SerFileType {
temp.put("yaml", SerFileType.YAML);
temp.put("tag", SerFileType.TAG);
temp.put("spdx", SerFileType.TAG);
temp.put("yml", SerFileType.YAML);
EXT_TO_FILETYPE = Collections.unmodifiableMap(temp);
}

Expand All @@ -81,7 +82,7 @@ public static ISerializableModelStore fileTypeToStore(SerFileType fileType) thro
case XLSX: return new SpreadsheetStore(new InMemSpdxStore(), SpreadsheetFormatType.XLSX);
case XML: return new MultiFormatStore(new InMemSpdxStore(), Format.XML, Verbose.COMPACT);
case YAML: return new MultiFormatStore(new InMemSpdxStore(), Format.YAML, Verbose.COMPACT);
default: throw new InvalidSPDXAnalysisException("Unsupporte file type: "+fileType+". Check back later.");
default: throw new InvalidSPDXAnalysisException("Unsupported file type: "+fileType+". Check back later.");
}
}

Expand Down Expand Up @@ -118,13 +119,13 @@ public static SerFileType strToFileType(String str) {
String strFileType = str.toUpperCase().trim();
return SerFileType.valueOf(strFileType);
}

/**
* @param file file containing an SPDX document with the standard file extension for the serialization formats
* @return the SPDX document stored in the file
* @throws InvalidSPDXAnalysisException
* @throws IOException
* @throws InvalidFileNameException
* @throws InvalidFileNameException
*/
public static SpdxDocument deserializeDocument(File file) throws InvalidSPDXAnalysisException, IOException, InvalidFileNameException {
ISerializableModelStore store = fileTypeToStore(fileToFileType(file));
Expand Down

0 comments on commit 8846a18

Please sign in to comment.