1 package org.bsf.smartValueObject.demo; 2 3 import java.io.Serializable ; 4 import java.text.SimpleDateFormat ; 5 import java.util.ArrayList ; 6 import java.util.Collection ; 7 import java.util.Date ; 8 import java.util.Iterator ; 9 10 15 public class CompanyVO implements Serializable { 16 private Long id; 17 private String name; 18 private Date creationDate; 19 private Collection subsidiaries = new ArrayList (); 20 21 private final SimpleDateFormat _dateFormat = new SimpleDateFormat ( "dd/MM/yy" ); 22 23 24 public Long getId() { 25 return id; 26 } 27 28 public void setId( Long id ) { 29 this.id = id; 30 } 31 32 33 public String getName() { 34 return name; 35 } 36 37 public void setName( String name ) { 38 this.name = name; 39 } 40 41 42 public Date getCreationDate() { 43 return creationDate; 44 } 45 46 public void setCreationDate( Date creationDate ) { 47 this.creationDate = creationDate; 48 } 49 50 public void addSubsidiary( SubsidiaryVO s ) { 51 s.setCompanyVO(this); 52 subsidiaries.add( s ); 53 } 54 55 public void removeSubsidiary( SubsidiaryVO s ) { 56 subsidiaries.remove( s ); 57 } 58 59 64 public Collection getSubsidiaries() { 65 return subsidiaries; 66 } 67 68 private void setSubsidiaries(Collection s) { 70 this.subsidiaries = s; 71 } 72 73 public Iterator subsidiaries() { 74 return subsidiaries.iterator(); 75 } 76 77 public String toString() { 78 String dateAsString = ""; 79 80 if ( creationDate != null ) { 81 dateAsString = _dateFormat.format( creationDate ); 83 } 84 85 return "CompanyVO: id=" + id + " name=" + name + " creationdate=" + dateAsString; 86 } 87 } 88 | Popular Tags |