1 11 package org.eclipse.jdt.internal.launching; 12 13 import java.util.ArrayList ; 14 15 18 public class CompositeId { 19 private String [] fParts; 20 21 public CompositeId(String [] parts) { 22 fParts= parts; 23 } 24 25 public static CompositeId fromString(String idString) { 26 ArrayList parts= new ArrayList (); 27 int commaIndex= idString.indexOf(','); 28 while (commaIndex > 0) { 29 int length= Integer.valueOf(idString.substring(0, commaIndex)).intValue(); 30 String part= idString.substring(commaIndex+1, commaIndex+1+length); 31 parts.add(part); 32 idString= idString.substring(commaIndex+1+length); 33 commaIndex= idString.indexOf(','); 34 } 35 String [] result= (String [])parts.toArray(new String [parts.size()]); 36 return new CompositeId(result); 37 } 38 39 public String toString() { 40 StringBuffer buf= new StringBuffer (); 41 for (int i= 0; i < fParts.length; i++) { 42 buf.append(fParts[i].length()); 43 buf.append(','); 44 buf.append(fParts[i]); 45 } 46 return buf.toString(); 47 } 48 49 public String get(int index) { 50 return fParts[index]; 51 } 52 53 public int getPartCount() { 54 return fParts.length; 55 } 56 } 57 | Popular Tags |