1 -- | This module declares functions and data types for
2 -- JAR meta-information classes, such as MANIFEST.MF etc.
4 (module Java.META.Types,
5 module Java.META.Parser,
10 import Java.META.Parser
14 data Manifest = Manifest {
15 manifestVersion :: String,
18 signatureVersion :: Maybe String,
19 classPath :: [String],
20 mainClass :: Maybe String,
21 manifestEntries :: [ManifestEntry]}
25 data ManifestEntry = ManifestEntry {
28 meContentType :: Maybe String,
32 instance MetaSpec Manifest where
33 loadFirstSection s = Manifest {
34 manifestVersion = s ! "Manifest-Version",
35 createdBy = s ! "Created-By",
36 sealed = case M.lookup "Sealed" s of
38 Just str -> string2bool str,
39 signatureVersion = M.lookup "Signature-Version" s,
40 classPath = case M.lookup "Class-Path" s of
42 Just str -> words str,
43 mainClass = M.lookup "Main-Class" s,
46 loadOtherSection m s = m {manifestEntries = manifestEntries m ++ [entry]}
48 entry = ManifestEntry {
50 meSealed = case M.lookup "Sealed" s of
52 Just str -> string2bool str,
53 meContentType = M.lookup "Content-Type" s,
54 meBean = case M.lookup "Java-Bean" s of
56 Just str -> string2bool str }
58 storeMeta m = first: map store (manifestEntries m)
60 first = M.fromList $ [
61 ("Manifest-Version", manifestVersion m),
62 ("Created-By", createdBy m)] ++
63 lookupList "Signature-Version" (signatureVersion m) ++
64 lookupList "Main-Class" (mainClass m) ++
67 list -> [("Class-Path", unwords list)]
69 store e = M.fromList $ [
71 ("Sealed", bool2string $ meSealed e)] ++
72 lookupList "Content-Type" (meContentType e) ++
74 then [("Java-Bean", "true")]