1 package org.paneris.jammyjoes.controller;
2
3
4 public class TitleGenerator {
5
6 private SearchType type;
7 private SearchAge age;
8 private SearchMaufacturer manufacturer;
9 private boolean onlyAge;
10 private String name;
11 private String description;
12
13 public TitleGenerator(SearchType type, SearchAge age, SearchMaufacturer manufacturer, String name, String description) {
14 this.type = type;
15 this.age = age;
16 this.manufacturer = manufacturer;
17 this.name = name;
18 this.description = description;
19 if (type.isNull() && manufacturer.isNull() && !age.isNull()) {
20 onlyAge = true;
21 }
22 }
23
24 private String variableTitle() {
25 String title = "Creative, discovery and thinking toys for babies and kids";
26 if (name != null) {
27 return name;
28 }
29 if (description != null) {
30 return description;
31 }
32 if (!type.isNull()) {
33 title = type + " toys";;
34 } else {
35 if (!manufacturer.isNull()) {
36 title = manufacturer + " toys";
37 }
38 }
39 if (onlyAge) {
40 title = age + " toys";
41 } else {
42 if (!age.isNull()) {
43 title += " for " + age;
44 }
45 }
46 return title;
47 }
48
49 public String getTitle() {
50 return variableTitle() + " at Jammy Joes toy shop in Poole, Dorset, UK.";
51 }
52
53 public String getKeywords() {
54 String keywords = "";
55 if (!type.isNull()) keywords += type + ", ";
56 if (!age.isNull()) keywords += age + ", ";
57 if (!manufacturer.isNull()) keywords += manufacturer + ", ";
58 if (name != null) keywords += name + ", ";
59 if (description != null) keywords += description + ", ";
60 return keywords + "Creative, discovery and thinking toys for babies and kids at Jammy Joes toy shop in Poole, Dorset, UK.";
61 }
62 }