X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=Java%2FMETA%2FSpec.hs;h=afda1434b95ac349d20929f3dcf27d55f52b33da;hb=359cf0fa124cd3bc0ffedf8ecee77022970ba562;hp=82d55c1ed712e6702e9206ef62c55b12696cb378;hpb=5a372b10d0647f9d572b9a70d7512cf653df97e3;p=hs-java.git diff --git a/Java/META/Spec.hs b/Java/META/Spec.hs index 82d55c1..afda143 100644 --- a/Java/META/Spec.hs +++ b/Java/META/Spec.hs @@ -1,9 +1,5 @@ module Java.META.Spec where -import Control.Monad -import Control.Monad.Error -import qualified Data.Map as M -import Data.Map ((!)) import Data.Char (toLower) import Java.META.Types @@ -35,65 +31,3 @@ string2bool s | map toLower s == "true" = True | otherwise = False -data Manifest = Manifest { - manifestVersion :: String, - createdBy :: String, - sealed :: Bool, - signatureVersion :: Maybe String, - classPath :: [String], - mainClass :: Maybe String, - manifestEntries :: [ManifestEntry]} - deriving (Eq, Show) - -data ManifestEntry = ManifestEntry { - meName :: String, - meSealed :: Bool, - meContentType :: Maybe String, - meBean :: Bool } - deriving (Eq, Show) - -instance MetaSpec Manifest where - loadFirstSection s = Manifest { - manifestVersion = s ! "Manifest-Version", - createdBy = s ! "Created-By", - sealed = case M.lookup "Sealed" s of - Nothing -> False - Just str -> string2bool str, - signatureVersion = M.lookup "Signature-Version" s, - classPath = case M.lookup "Class-Path" s of - Nothing -> [] - Just str -> words str, - mainClass = M.lookup "Main-Class" s, - manifestEntries = []} - - loadOtherSection m s = m {manifestEntries = manifestEntries m ++ [entry]} - where - entry = ManifestEntry { - meName = s ! "Name", - meSealed = case M.lookup "Sealed" s of - Nothing -> sealed m - Just str -> string2bool str, - meContentType = M.lookup "Content-Type" s, - meBean = case M.lookup "Java-Bean" s of - Nothing -> False - Just str -> string2bool str } - - storeMeta m = first: map store (manifestEntries m) - where - first = M.fromList $ [ - ("Manifest-Version", manifestVersion m), - ("Created-By", createdBy m)] ++ - lookupList "Signature-Version" (signatureVersion m) ++ - lookupList "Main-Class" (mainClass m) ++ - case classPath m of - [] -> [] - list -> [("Class-Path", unwords list)] - - store e = M.fromList $ [ - ("Name", meName e), - ("Sealed", bool2string $ meSealed e)] ++ - lookupList "Content-Type" (meContentType e) ++ - if meBean e - then [("Java-Bean", "true")] - else [] -