1 18 package org.objectweb.speedo.pobjects.detach; 19 20 24 public class VehicleId { 25 public static final String SEP = ":"; 26 public String name; 27 public String type; 28 29 public VehicleId() { 30 } 31 32 public VehicleId(String name, String type) { 33 this.name = name; 34 this.type = type; 35 } 36 37 public VehicleId(String str) { 38 setValue(str); 39 } 40 41 private void setValue(String str) { 42 if (str == null) { 43 throw new NullPointerException ("String representation of Vehicle Identifier is null"); 44 } 45 int idx = str.indexOf(SEP); 46 if (idx == -1) { 47 throw new NullPointerException ("Bad String representation of Vehicle Identifier: " + str); 48 } 49 name = str.substring(0, idx); 50 type = str.substring(idx + SEP.length()); 51 } 52 53 public String toString() { 54 return name + SEP + type; 55 } 56 } | Popular Tags |