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