Java Reference
In-Depth Information
private void create(String customerCreationString) {
String cmd=
StringUtils.defaultString(customerCreationString).trim();
String[] parts = cmd.split(" ");
String firstName = parts[1], lastName = parts[2];
Date date = null;
try {
date =
DateFormat.getDateInstance(DateFormat.SHORT).parse(parts[3]);
} catch (ParseException e) {
log(ExceptionUtils.getFullStackTrace(e));
}
customerService.createCustomer(firstName, lastName, date);
list();
}
private void delete(String c) {
log("delete:" + c);
String id = StringUtils.defaultString(c).trim().split(" ")[1];
customerService.removeCustomer(id);
list();
}
private void update(String stringToUpdate) {
String[] parts = StringUtils.defaultString(stringToUpdate).trim()
.split(" ");
String idOfCustomerAsPrintedOnConsole = parts[1],
firstName = parts[2],
lastName = parts[3];
Date date = null;
try {
date =
DateFormat.getDateInstance(DateFormat.SHORT).parse(parts[4]);
} catch (ParseException e) {
log(ExceptionUtils.getFullStackTrace(e));
}
customerService.updateCustomer(idOfCustomerAsPrintedOnConsole,
firstName, lastName, date);
list();
}
private CustomerService customerService;
public CustomerService getCustomerService() {
return customerService;
}
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
enum Commands {
LIST, UPDATE, DELETE, CREATE
}
Search WWH ::




Custom Search