6.6 本章节例子中使用的类

Inventor.java

  1. package org.spring.samples.spel.inventor;
  2. import java.util.Date;
  3. import java.util.GregorianCalendar;
  4. public class Inventor {
  5. private String name;
  6. private String nationality;
  7. private String[] inventions;
  8. private Date birthdate;
  9. private PlaceOfBirth placeOfBirth;
  10. public Inventor(String name, String nationality) {
  11. GregorianCalendar c= new GregorianCalendar();
  12. this.name = name;
  13. this.nationality = nationality;
  14. this.birthdate = c.getTime();
  15. }
  16. public Inventor(String name, Date birthdate, String nationality) {
  17. this.name = name;
  18. this.nationality = nationality;
  19. this.birthdate = birthdate;
  20. }
  21. public Inventor() {
  22. }
  23. public String getName() {
  24. return name;
  25. }
  26. public void setName(String name) {
  27. this.name = name;
  28. }
  29. public String getNationality() {
  30. return nationality;
  31. }
  32. public void setNationality(String nationality) {
  33. this.nationality = nationality;
  34. }
  35. public Date getBirthdate() {
  36. return birthdate;
  37. }
  38. public void setBirthdate(Date birthdate) {
  39. this.birthdate = birthdate;
  40. }
  41. public PlaceOfBirth getPlaceOfBirth() {
  42. return placeOfBirth;
  43. }
  44. public void setPlaceOfBirth(PlaceOfBirth placeOfBirth) {
  45. this.placeOfBirth = placeOfBirth;
  46. }
  47. public void setInventions(String[] inventions) {
  48. this.inventions = inventions;
  49. }
  50. public String[] getInventions() {
  51. return inventions;
  52. }
  53. }

PlaceOfBirth.java

  1. package org.spring.samples.spel.inventor;
  2. public class PlaceOfBirth {
  3. private String city;
  4. private String country;
  5. public PlaceOfBirth(String city) {
  6. this.city=city;
  7. }
  8. public PlaceOfBirth(String city, String country) {
  9. this(city);
  10. this.country = country;
  11. }
  12. public String getCity() {
  13. return city;
  14. }
  15. public void setCity(String s) {
  16. this.city = s;
  17. }
  18. public String getCountry() {
  19. return country;
  20. }
  21. public void setCountry(String country) {
  22. this.country = country;
  23. }
  24. }

Society.java

  1. package org.spring.samples.spel.inventor;
  2. import java.util.*;
  3. public class Society {
  4. private String name;
  5. public static String Advisors = "advisors";
  6. public static String President = "president";
  7. private List<Inventor> members = new ArrayList<Inventor>();
  8. private Map officers = new HashMap();
  9. public List getMembers() {
  10. return members;
  11. }
  12. public Map getOfficers() {
  13. return officers;
  14. }
  15. public String getName() {
  16. return name;
  17. }
  18. public void setName(String name) {
  19. this.name = name;
  20. }
  21. public boolean isMember(String name) {
  22. for (Inventor inventor : members) {
  23. if (inventor.getName().equals(name)) {
  24. return true;
  25. }
  26. }
  27. return false;
  28. }
  29. }