1 25 26 package org.objectweb.speedo.tutorial.pobjects.additional.inheritance; 27 28 31 public class EmployeeId { 32 33 public static final String SEP = ":"; 34 public String name; 35 public String type; 36 37 public EmployeeId() { 38 } 39 40 public EmployeeId(String name, String type) { 41 this.name = name; 42 this.type = type; 43 } 44 45 public EmployeeId(String str) { 46 setValue(str); 47 } 48 49 private void setValue(String str) { 50 if (str == null) { 51 throw new NullPointerException ("String representation of Employee Identifier is null"); 52 } 53 int idx = str.indexOf(SEP); 54 if (idx == -1) { 55 throw new NullPointerException ("Bad String representation of Employee Identifier: " + str); 56 } 57 name = str.substring(0, idx); 58 type = str.substring(idx + SEP.length()); 59 System.out.println(this.toString()); 60 } 61 62 public String toString() { 63 return name + SEP + type; 64 } 65 66 } 67 | Popular Tags |