Package org.hl7.fhir.utilities.cache
Class NpmPackage
- java.lang.Object
-
- org.hl7.fhir.utilities.cache.NpmPackage
-
public class NpmPackage extends Object
info and loader for a package Packages may exist on disk in the cache, or purely in memory when they are loaded on the fly Packages are contained in subfolders (see the package spec). The FHIR resources will be in "package"- Author:
- Grahame Grieve
-
-
Constructor Summary
Constructors Constructor Description NpmPackage(com.google.gson.JsonObject npm, Map<String,byte[]> content, List<String> folders)NpmPackage(String path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcanonical()List<String>copyTo(String folder, String dest)Copies all the files in the package folder [folder] to the nominated dest, and returns a list of all the file names copiedStringdate()List<String>dependencies()Stringdescription()StringfhirVersion()convenience method for getting the package fhir versionstatic NpmPackagefromFolder(String folder, String... exemptions)static NpmPackagefromFolder(String folder, PackageGenerator.PackageType defType, String... exemptions)static NpmPackagefromPackage(InputStream tgz)static NpmPackagefromPackage(InputStream tgz, boolean progress)static NpmPackagefromZip(InputStream stream, boolean dropRootFolder)IniFilegetCache()Map<String,byte[]>getContent()special case when playing around inside the packagecom.google.gson.JsonObjectgetNpm()Handle to the package json fileStringgetPath()StringgetWebLocation()booleanhasFile(String folder, String name)booleanisType(PackageGenerator.PackageType template)List<String>list(String folder)Accessing the contents of the package - get a list of files in a subfolder of the packageList<String>listResources(String... types)InputStreamload(String folder, String file)get a stream that contains the contents of one of the files in a folderInputStreamloadResource(String type, String id)Stringname()convenience method for getting the package namevoidsave(OutputStream stream)voidsetPath(String path)only for use by the package manager itselfStringsummary()Stringtype()voidunPack(String dir)Stringversion()convenience method for getting the package version
-
-
-
Constructor Detail
-
NpmPackage
public NpmPackage(com.google.gson.JsonObject npm, Map<String,byte[]> content, List<String> folders)
-
NpmPackage
public NpmPackage(String path) throws IOException
- Throws:
IOException
-
-
Method Detail
-
fromPackage
public static NpmPackage fromPackage(InputStream tgz) throws IOException
- Throws:
IOException
-
fromPackage
public static NpmPackage fromPackage(InputStream tgz, boolean progress) throws IOException
- Throws:
IOException
-
fromZip
public static NpmPackage fromZip(InputStream stream, boolean dropRootFolder) throws IOException
- Throws:
IOException
-
list
public List<String> list(String folder) throws IOException
Accessing the contents of the package - get a list of files in a subfolder of the package- Parameters:
folder-- Returns:
- Throws:
IOException
-
listResources
public List<String> listResources(String... types) throws IOException
- Throws:
IOException
-
copyTo
public List<String> copyTo(String folder, String dest) throws IOException
Copies all the files in the package folder [folder] to the nominated dest, and returns a list of all the file names copied- Parameters:
folder-- Returns:
- Throws:
IOException
-
load
public InputStream load(String folder, String file) throws IOException
get a stream that contains the contents of one of the files in a folder- Parameters:
folder-file-- Returns:
- Throws:
IOException
-
getNpm
public com.google.gson.JsonObject getNpm()
Handle to the package json file- Returns:
-
fhirVersion
public String fhirVersion()
convenience method for getting the package fhir version- Returns:
-
isType
public boolean isType(PackageGenerator.PackageType template)
-
description
public String description()
-
setPath
public void setPath(String path)
only for use by the package manager itself- Parameters:
path-
-
getWebLocation
public String getWebLocation()
-
hasFile
public boolean hasFile(String folder, String name) throws IOException
- Throws:
IOException
-
loadResource
public InputStream loadResource(String type, String id) throws IOException
- Throws:
IOException
-
getContent
public Map<String,byte[]> getContent()
special case when playing around inside the package
-
fromFolder
public static NpmPackage fromFolder(String folder, String... exemptions) throws IOException
- Throws:
IOException
-
fromFolder
public static NpmPackage fromFolder(String folder, PackageGenerator.PackageType defType, String... exemptions) throws IOException
- Throws:
IOException
-
unPack
public void unPack(String dir) throws IOException
- Throws:
IOException
-
save
public void save(OutputStream stream) throws IOException
- Throws:
IOException
-
dependencies
public List<String> dependencies()
-
-