1 package org.paneris.jammyjoes.controller; 2 3 import org.melati.util.UTF8URLEncoder; 4 import org.paneris.jammyjoes.model.Age; 5 6 public class SearchAge { 7 8 private Age age; 9 private String name; 10 private Integer minAge; 11 private Integer maxAge; 12 private boolean isNull = true; 13 14 public SearchAge(Age age) { 15 this.age = age; 16 this.name = null; 17 isNull = false; 18 } 19 20 public SearchAge(Integer minAge, Integer maxAge) { 21 this.minAge = minAge; 22 this.maxAge = maxAge; 23 this.age = null; 24 this.name = null; 25 isNull = false; 26 } 27 28 public SearchAge(String name) { 29 this.name = name; 30 this.age = null; 31 isNull = false; 32 } 33 34 public SearchAge() { 35 } 36 37 public String toString() { 38 if (age != null) return age.getName(); 39 if (name != null) return name; 40 if (minAge != null && maxAge != null) { 41 return minAge + "_" + maxAge; 42 } 43 return ""; 44 } 45 46 public boolean isNull() { 47 return isNull; 48 } 49 50 public String pathise() { 51 if (age == null) 52 return "/_"; 53 return "/" + UTF8URLEncoder.encode(age.getName()); 54 } 55 56 }