Cleanup, minor updates.
[hs-java.git] / Java / META / Spec.hs
1 module Java.META.Spec where
2
3 import Data.Char (toLower)
4
5 import Java.META.Types
6
7 class MetaSpec s where
8   loadFirstSection :: Section -> s
9
10   loadOtherSection :: s -> Section -> s
11   loadOtherSection s _ = s
12
13   storeMeta :: s -> META
14
15 loadSpec :: (MetaSpec s) => META -> s
16 loadSpec [] = error "Cannot load empty metadata"
17 loadSpec (s:ss) =
18   let x = loadFirstSection s
19   in  foldl loadOtherSection x ss
20
21 lookupList :: String -> Maybe String -> [(String, String)]
22 lookupList _ Nothing = []
23 lookupList name (Just val) = [(name, val)]
24
25 bool2string :: Bool -> String
26 bool2string True = "true"
27 bool2string False = "false"
28
29 string2bool :: String -> Bool
30 string2bool s
31   | map toLower s == "true" = True
32   | otherwise = False
33