1 23 24 29 30 package com.sun.enterprise.util; 31 32 36 38 39 public class TriStateBool 40 { 41 private TriStateBool() 42 { 43 } 44 45 47 56 public static final TriStateBool translate(String s) 57 { 58 if(StringUtils.ok(s)) 59 { 60 s = s.toLowerCase(); 61 62 if(s.equals("true")) 63 return TRUE; 64 if(s.equals("false")) 65 return FALSE; 66 } 67 return UNDEFINED; 68 } 69 70 72 public String toString() 73 { 74 if(this == TRUE) 75 return "TRUE"; 76 else if(this == FALSE) 77 return "FALSE"; 78 if(this == UNDEFINED) 79 return "UNDEFINED"; 80 else 81 return "IMPOSSIBLE VALUE!!"; 82 } 83 84 86 public static final TriStateBool TRUE = new TriStateBool(); 87 public static final TriStateBool FALSE = new TriStateBool(); 88 public static final TriStateBool UNDEFINED = new TriStateBool(); 89 90 92 public static void main(String [] args) 93 { 94 System.out.println("TruE: " + translate("TruE")); 95 System.out.println("FALse: " + translate("FALse")); 96 System.out.println("TruEX: " + translate("TruEX")); 97 } 98 99 } 100 | Popular Tags |