package net.titaniclinux.daogen.examples; import java.io.*; import java.sql.*; import java.util.*; import java.math.*; /** * Customer Value Object. * This class is value object representing database table CUSTOMER * This class is intented to be used together with associated Dao object. */ /** * This sourcecode has been generated by FREE DaoGen generator version 2.2.1. * The usage of generated code is restricted to OpenSource software projects * only. DaoGen is available in http://titaniclinux.net/daogen/ * * DaoGen license: The following DaoGen generated source code is licensed * under the terms of GNU GPL license. The full text for license is available * in GNU project's pages: http://www.gnu.org/copyleft/gpl.html * */ public class Customer implements Cloneable, Serializable { /** * Persistent Instance variables. This data is directly * mapped to the columns of database table. */ private int number; private String name; private String address; private java.sql.Date created; private int balance; /** * Constructors. DaoGen generates two constructors by default. * The first one takes no arguments and provides the most simple * way to create object instance. The another one takes one * argument, which is the primary key of the corresponding table. */ public Customer () { } public Customer (int numberIn) { this.number = numberIn; } /** * Get- and Set-methods for persistent variables. The default * behaviour does not make any checks against malformed data, * so these might require some manual additions. */ public int getNumber() { return this.number; } public void setNumber(int numberIn) { this.number = numberIn; } public String getName() { return this.name; } public void setName(String nameIn) { this.name = nameIn; } public String getAddress() { return this.address; } public void setAddress(String addressIn) { this.address = addressIn; } public java.sql.Date getCreated() { return this.created; } public void setCreated(java.sql.Date createdIn) { this.created = createdIn; } public int getBalance() { return this.balance; } public void setBalance(int balanceIn) { this.balance = balanceIn; } /** * setAll allows to set all persistent variables in one method call. * This is useful, when all data is available and it is needed to * set the initial state of this object. Note that this method will * directly modify instance variales, without going trough the * individual set-methods. */ public void setAll(int numberIn, String nameIn, String addressIn, java.sql.Date createdIn, int balanceIn) { this.number = numberIn; this.name = nameIn; this.address = addressIn; this.created = createdIn; this.balance = balanceIn; } /** * hasEqualMapping-method will compare two Customer instances * and return true if they contain same values in all persistent instance * variables. If hasEqualMapping returns true, it does not mean the objects * are the same instance. However it does mean that in that moment, they * are mapped to the same row in database. */ public boolean hasEqualMapping(Customer valueObject) { if (valueObject.getNumber() != this.number) { return(false); } if (this.name == null) { if (valueObject.getName() != null) return(false); } else if (!this.name.equals(valueObject.getName())) { return(false); } if (this.address == null) { if (valueObject.getAddress() != null) return(false); } else if (!this.address.equals(valueObject.getAddress())) { return(false); } if (this.created == null) { if (valueObject.getCreated() != null) return(false); } else if (!this.created.equals(valueObject.getCreated())) { return(false); } if (valueObject.getBalance() != this.balance) { return(false); } return true; } /** * toString will return String object representing the state of this * valueObject. This is useful during application development, and * possibly when application is writing object states in textlog. */ public String toString() { StringBuffer out = new StringBuffer(this.getDaogenVersion()); out.append("\nclass Customer, representing table CUSTOMER\n"); out.append("Persistent attributes: \n"); out.append("number = " + this.number + "\n"); out.append("name = " + this.name + "\n"); out.append("address = " + this.address + "\n"); out.append("created = " + this.created + "\n"); out.append("balance = " + this.balance + "\n"); out.append("Non persistent attributes: \n"); return out.toString(); } /** * Clone will return identical deep copy of this valueObject. * Note, that this method is different than the clone() which * is defined in java.lang.Object. Here, the retuned cloned object * will also have all its attributes cloned. */ public Object clone() { Customer cloned = new Customer(); cloned.setNumber(this.number); cloned.setName(new String(this.name)); cloned.setAddress(new String(this.address)); cloned.setCreated((java.sql.Date)this.created.clone()); cloned.setBalance(this.balance); return cloned; } /** * getDaogenVersion will return information about * generator which created these sources. */ public String getDaogenVersion() { return "DaoGen version 2.2.1"; } }