1 package org.apache.tools.ant.taskdefs.optional.jmx.converter; 2 3 52 53 54 55 import java.util.Set ; 56 import java.util.StringTokenizer ; 57 58 64 public class SetValueConverter implements ValueConverter { 65 66 private static String [] supportedTypes = {Set .class.getName()}; 67 68 71 public SetValueConverter() { 72 } 73 74 81 public Object valueOf(String value, String type) throws Exception { 82 83 try { 84 StringTokenizer tokenizer = new StringTokenizer (value," ,[]\t\n\r\f"); 85 86 Set result = new java.util.TreeSet (); 87 while (tokenizer.hasMoreTokens()) { 88 String item = tokenizer.nextToken(); 89 result.add(item); 90 } 91 return result; 92 } catch (Exception x) { 93 throw new org.apache.tools.ant.BuildException("Invalid Set value format. Expected format \"value1, value2, value3\" etc. E.g. [red, green, blue], etc.",x); 94 } 95 } 96 97 public String [] getSupportedTypes() { 98 return supportedTypes; 99 } 100 101 } 102 103 | Popular Tags |