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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classNpmPackage.NpmPackageFolder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcanonical()Stringdate()voiddebugDump(String purpose)List<String>dependencies()StringdependencySummary()Stringdescription()StringfhirVersion()convenience method for getting the package fhir versionStringfhirVersionList()static NpmPackagefromFolder(String path)static NpmPackagefromFolder(String folder, PackageGenerator.PackageType defType, String... exemptions)static NpmPackagefromPackage(InputStream tgz)static NpmPackagefromPackage(InputStream tgz, String desc)static NpmPackagefromPackage(InputStream tgz, String desc, boolean progress)static NpmPackagefromZip(InputStream stream, boolean dropRootFolder, String desc)Map<String,NpmPackage.NpmPackageFolder>getFolders()special case when playing around inside the packagecom.google.gson.JsonObjectgetNpm()Handle to the package json fileStringgetPath()Map<String,List<String>>getTypes()StringgetWebLocation()booleanhasFile(String folder, String file)Stringhomepage()booleanisType(PackageGenerator.PackageType template)static booleanisValidName(String pid)static booleanisValidVersion(String ver)Stringlicense()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 folderInputStreamloadExampleResource(String type, String id)voidloadFile(String n, byte[] data)static voidloadFiles(NpmPackage res, String path, File source, String... exemptions)InputStreamloadResource(String file)use the name from listResources()InputStreamloadResource(String type, String id)Stringname()convenience method for getting the package namevoidreadStream(InputStream tgz, String desc, boolean progress)voidsave(OutputStream stream)Stringsummary()Stringtitle()StringtoolsVersion()Stringtype()voidunPack(String dir)voidunPack(String dir, boolean withAppend)voidunPackWithAppend(String dir)Stringurl()Stringversion()convenience method for getting the package version
-
-
-
Method Detail
-
isValidName
public static boolean isValidName(String pid)
-
isValidVersion
public static boolean isValidVersion(String ver)
-
fromFolder
public static NpmPackage fromFolder(String path) throws IOException
- Throws:
IOException
-
loadFiles
public static void loadFiles(NpmPackage res, String path, File source, String... exemptions) throws FileNotFoundException, IOException
- Throws:
FileNotFoundExceptionIOException
-
fromFolder
public static NpmPackage fromFolder(String folder, PackageGenerator.PackageType defType, String... exemptions) throws IOException
- Throws:
IOException
-
fromPackage
public static NpmPackage fromPackage(InputStream tgz) throws IOException
- Throws:
IOException
-
fromPackage
public static NpmPackage fromPackage(InputStream tgz, String desc) throws IOException
- Throws:
IOException
-
fromPackage
public static NpmPackage fromPackage(InputStream tgz, String desc, boolean progress) throws IOException
- Throws:
IOException
-
readStream
public void readStream(InputStream tgz, String desc, boolean progress) throws IOException
- Throws:
IOException
-
loadFile
public void loadFile(String n, byte[] data) throws IOException
- Throws:
IOException
-
fromZip
public static NpmPackage fromZip(InputStream stream, boolean dropRootFolder, String desc) 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
-
loadResource
public InputStream loadResource(String file) throws IOException
use the name from listResources()- Parameters:
id-- 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
-
hasFile
public boolean hasFile(String folder, String file) throws IOException
- 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()
-
dependencies
public List<String> dependencies()
-
toolsVersion
public String toolsVersion()
-
getWebLocation
public String getWebLocation()
-
loadResource
public InputStream loadResource(String type, String id) throws IOException
- Throws:
IOException
-
loadExampleResource
public InputStream loadExampleResource(String type, String id) throws IOException
- Throws:
IOException
-
getFolders
public Map<String,NpmPackage.NpmPackageFolder> getFolders()
special case when playing around inside the package
-
save
public void save(OutputStream stream) throws IOException
- Throws:
IOException
-
fhirVersionList
public String fhirVersionList()
-
dependencySummary
public String dependencySummary()
-
unPack
public void unPack(String dir) throws IOException
- Throws:
IOException
-
unPackWithAppend
public void unPackWithAppend(String dir) throws IOException
- Throws:
IOException
-
unPack
public void unPack(String dir, boolean withAppend) throws IOException
- Throws:
IOException
-
-