1 20 package fr.dyade.aaa.util; 21 22 import java.util.*; 23 24 public class ConditionnalString implements java.io.Serializable { 25 26 27 public static ConditionnalString valueOf(String s) throws Exception { 28 StringTokenizer tokenizer = new StringTokenizer(s, "(),"); 29 int tokenNb = tokenizer.countTokens(); 30 String value = ""; 31 if (tokenNb == 2) { 32 value = tokenizer.nextToken(); 33 } 34 String c = tokenizer.nextToken(); 35 boolean condition = Boolean.valueOf(c).booleanValue(); 36 ConditionnalString cs = new ConditionnalString(value, condition); 37 return cs; 38 } 39 40 public String value = null; 41 public boolean condition = false; 42 43 public ConditionnalString(String value, boolean condition) { 44 this.value = value; 45 this.condition = condition; 46 } 47 48 public String toString() { 49 return '(' + value + ',' + condition + ')'; 50 } 51 } 52 | Popular Tags |