From: <jbo...@li...> - 2006-04-22 05:00:58
|
Author: woolfel Date: 2006-04-22 01:00:49 -0400 (Sat, 22 Apr 2006) New Revision: 3904 Added: labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Address.java labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/GroupTransaction.java labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Security.java labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/SubTransaction.java labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Transaction.java Log: adding a bunch of sample objects for testing purposes. I plan to write more rule generators to use these objects. peter Added: labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Address.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Address.java 2006-04-22 04:58:09 UTC (rev 3903) +++ labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Address.java 2006-04-22 05:00:49 UTC (rev 3904) @@ -0,0 +1,177 @@ +package com.sample.benchmark.models; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Peter Lin + * + * A simple address class that represents a house a person owns. + */ +public class Address implements Serializable { + + protected String title = null; + protected String accountId = null; + protected String street = null; + protected String street2 = null; + protected String status = null; + protected String city = null; + protected String state = null; + protected String postalCode = null; + protected String houseType = null; + protected String country = null; + + protected ArrayList listeners = new ArrayList(); + + /** + * + */ + public Address() { + super(); + } + + public void setTitle(String val){ + if (!val.equals(this.title)){ + String old = this.title; + this.title = val; + notifyListener("title",old,this.title); + } + } + + public String getTitle(){ + return this.title; + } + + public void setState(String val){ + if (!val.equals(this.state)){ + String old = this.state; + this.state = val; + notifyListener("officeCode",old,this.state); + } + } + + public String getState(){ + return this.state; + } + + public void setCity(String val){ + if (!val.equals(this.city)){ + String old = this.city; + this.city = val; + notifyListener("regionCode",old,this.city); + } + } + + public String getCity(){ + return this.city; + } + + public void setStreet2(String val){ + if (!val.equals(this.street2)){ + String old = this.street2; + this.street2 = val; + notifyListener("status",old,this.street2); + } + } + + public String getStreet2(){ + return this.street2; + } + + public void setAccountId(String val){ + if (!val.equals(this.accountId)){ + String old = this.accountId; + this.accountId = val; + notifyListener("accountId",old,this.accountId); + } + } + + public String getAccountId(){ + return this.accountId; + } + + public void setStreet(String val){ + if (!val.equals(this.street)){ + String old = this.street; + this.street = val; + notifyListener("accountType",old,this.street); + } + } + + public String getStreet(){ + return this.street; + } + + public void setStatus(String val){ + if (!val.equals(this.status)){ + String old = this.status; + this.status = val; + notifyListener("username",old,this.status); + } + } + + public String getStatus(){ + return this.status; + } + + public String getPostalCode() { + return this.postalCode; + } + + public void setPostalCode(String val) { + if (!val.equals(this.postalCode)){ + String old = this.postalCode; + this.postalCode = val; + notifyListener("areaCode",old,this.postalCode); + } + } + + public String getHouseType() { + return this.houseType; + } + + public void setHouseType(String val) { + if (!val.equals(this.houseType)){ + String old = this.houseType; + this.houseType = val; + notifyListener("exchange",old,this.houseType); + } + } + + public String getCountry() { + return this.country; + } + + public void setCountry(String val) { + if (!val.equals(this.country)){ + String old = this.country; + this.country = val; + notifyListener("number",old,this.country); + } + } + + public void addPropertyChangeListener(PropertyChangeListener listener){ + this.listeners.add(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener){ + this.listeners.remove(listener); + } + + protected void notifyListener(String field, Object oldValue, Object newValue){ + if (listeners == null || listeners.size() == 0) { + return; + } else { + PropertyChangeEvent event = new PropertyChangeEvent(this, field, + oldValue, newValue); + + for (int i = 0; i < listeners.size(); i++) { + ((java.beans.PropertyChangeListener) listeners.get(i)) + .propertyChange(event); + } + } + + } +} Added: labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/GroupTransaction.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/GroupTransaction.java 2006-04-22 04:58:09 UTC (rev 3903) +++ labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/GroupTransaction.java 2006-04-22 05:00:49 UTC (rev 3904) @@ -0,0 +1,121 @@ +package com.sample.benchmark.models; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Peter Lin + * + */ +public class GroupTransaction extends Security { + + protected String[] accountIds = null; + protected double buyPrice; + protected String purchaseDate = null; + protected double shares; + protected double total; + protected String transactionId = null; + + protected ArrayList listeners = new ArrayList(); + + public GroupTransaction() { + super(); + } + + public void setAccountIds(String[] id) { + if (id != this.accountIds) { + String[] old = this.accountIds; + this.accountIds = id; + this.notifyListener("accountIds",old,this.accountIds); + } + } + + public String[] getAccountIds() { + return this.accountIds; + } + + public void setBuyPrice(double price) { + if (price != this.buyPrice) { + Double old = new Double(this.buyPrice); + this.buyPrice = price; + this.notifyListener("buyPrice",old,new Double(this.buyPrice)); + } + } + + public double getBuyPrice() { + return this.buyPrice; + } + + public void setPurchaseDate(String date) { + if (!date.equals(this.purchaseDate)) { + String old = this.purchaseDate; + this.purchaseDate = date; + this.notifyListener("purchaseDate",old,this.purchaseDate); + } + } + + public String getPurchaseDate() { + return this.purchaseDate; + } + + public void setShares(double shares) { + if (shares != this.shares) { + Double old = new Double(this.shares); + this.shares = shares; + this.notifyListener("shares",old,new Double(this.shares)); + } + } + + public double getShares() { + return this.shares; + } + + public void setTotal(double value) { + if (value != this.total) { + Double old = new Double(this.total); + this.total = value; + this.notifyListener("total",old,new Double(this.total)); + } + } + + public double getTotal() { + return this.total; + } + + public void setTransactionId(String id) { + if (!id.equals(this.transactionId)) { + String old = this.transactionId; + this.transactionId = id; + this.notifyListener("transactionId",old,this.transactionId); + } + } + + public String getTransactionId() { + return this.transactionId; + } + + public void addPropertyChangeListener(PropertyChangeListener listener){ + this.listeners.add(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener){ + this.listeners.remove(listener); + } + + protected void notifyListener(String field, Object oldValue, Object newValue){ + if (listeners == null || listeners.size() == 0) { + return; + } else { + PropertyChangeEvent event = new PropertyChangeEvent(this, field, + oldValue, newValue); + + for (int i = 0; i < listeners.size(); i++) { + ((java.beans.PropertyChangeListener) listeners.get(i)) + .propertyChange(event); + } + } + + } +} Added: labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Security.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Security.java 2006-04-22 04:58:09 UTC (rev 3903) +++ labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Security.java 2006-04-22 05:00:49 UTC (rev 3904) @@ -0,0 +1,177 @@ +package com.sample.benchmark.models; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Peter Lin + * + */ +public class Security implements Serializable{ + + protected String countryCode = null; + protected double currentPrice; + protected int cusip; + protected String exchange = null; + protected int industryGroupID; + protected int industryID; + protected String issuer = null; + protected double lastPrice; + protected int sectorID; + protected int subIndustryID; + + protected ArrayList listeners = new ArrayList(); + + public Security() { + super(); + } + + public void setCountryCode(String code) { + if (!code.equals(this.countryCode)) { + String old = this.countryCode; + this.countryCode = code; + this.notifyListener("countryCode",old,this.countryCode); + } + } + + public String getCountryCode() { + return this.countryCode; + } + + public void setCurrentPrice(double price) { + if (price != this.currentPrice) { + Double old = new Double(this.currentPrice); + this.currentPrice = price; + this.notifyListener("currentPrice",old,new Double(this.currentPrice)); + } + } + + public double getCurrentPrice() { + return this.currentPrice; + } + + public void setCusip(int value) { + if (value != this.cusip) { + Integer old = new Integer(this.cusip); + this.cusip = value; + this.notifyListener("cusip",old,new Integer(this.cusip)); + } + } + + public int getCusip() { + return this.cusip; + } + + public void setExchange(String exc) { + if (!exc.equals(this.exchange)) { + String old = this.exchange; + this.exchange = exc; + this.notifyListener("exchange",old,this.exchange); + } + } + + public String getExchange() { + return this.exchange; + } + + public void setIndustryGroupID(int id) { + if (id != this.industryGroupID) { + int old = this.industryGroupID; + this.industryGroupID = id; + this.notifyListener("industryGroupID", + new Integer(old), new Integer(this.industryGroupID)); + } + } + + public int getIndustryGroupID() { + return this.industryGroupID; + } + + public void setIndustryID(int id) { + if (id != this.industryID) { + int old = this.industryID; + this.industryID = id; + this.notifyListener("industryID", + new Integer(old), new Integer(this.industryID)); + } + } + + public int getIndustryID() { + return this.industryID; + } + + public void setIssuer(String name) { + if (!name.equals(this.issuer)) { + String old = this.issuer; + this.issuer = name; + this.notifyListener("issuer", old, this.issuer); + } + } + + public String getIssuer() { + return this.issuer; + } + + public void setLastPrice(double price) { + if (price != this.lastPrice) { + Double old = new Double(this.lastPrice); + this.lastPrice = price; + this.notifyListener("lastPrice",old,new Double(this.lastPrice)); + } + } + + public double getLastPrice() { + return this.lastPrice; + } + + public void setSectorID(int id) { + if (id != this.sectorID) { + int old = this.sectorID; + this.sectorID = id; + this.notifyListener("sectorID", + new Integer(old), new Integer(this.sectorID)); + } + } + + public int getSectorID() { + return this.sectorID; + } + + public void setSubIndustryID(int id) { + if (id != this.subIndustryID) { + int old = this.subIndustryID; + this.subIndustryID = id; + this.notifyListener("subIndustryID", + new Integer(old), new Integer(this.subIndustryID)); + } + } + + public int getSubIndustryID() { + return this.subIndustryID; + } + + public void addPropertyChangeListener(PropertyChangeListener listener){ + this.listeners.add(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener){ + this.listeners.remove(listener); + } + + protected void notifyListener(String field, Object oldValue, Object newValue){ + if (listeners == null || listeners.size() == 0) { + return; + } else { + PropertyChangeEvent event = new PropertyChangeEvent(this, field, + oldValue, newValue); + + for (int i = 0; i < listeners.size(); i++) { + ((java.beans.PropertyChangeListener) listeners.get(i)) + .propertyChange(event); + } + } + + } +} Added: labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/SubTransaction.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/SubTransaction.java 2006-04-22 04:58:09 UTC (rev 3903) +++ labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/SubTransaction.java 2006-04-22 05:00:49 UTC (rev 3904) @@ -0,0 +1,55 @@ +package com.sample.benchmark.models; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Peter Lin + * + */ +public class SubTransaction extends Security { + + protected String[] transactionSet = null; + protected ArrayList listeners = new ArrayList(); + + public SubTransaction() { + super(); + } + + public void setTransactionSet(String[] ids) { + if (ids != this.transactionSet) { + String[] old = this.transactionSet; + this.transactionSet = ids; + this.notifyListener("transactionSet", old, this.transactionSet); + } + } + + public String[] getTransactionSet() { + return this.transactionSet; + } + + public void addPropertyChangeListener(PropertyChangeListener listener){ + this.listeners.add(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener){ + this.listeners.remove(listener); + } + + protected void notifyListener(String field, Object oldValue, Object newValue){ + if (listeners == null || listeners.size() == 0) { + return; + } else { + PropertyChangeEvent event = new PropertyChangeEvent(this, field, + oldValue, newValue); + + for (int i = 0; i < listeners.size(); i++) { + ((java.beans.PropertyChangeListener) listeners.get(i)) + .propertyChange(event); + } + } + + } +} Added: labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Transaction.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Transaction.java 2006-04-22 04:58:09 UTC (rev 3903) +++ labs/jbossrules/trunk/drools-examples/src/main/java/com/sample/benchmark/models/Transaction.java 2006-04-22 05:00:49 UTC (rev 3904) @@ -0,0 +1,121 @@ +package com.sample.benchmark.models; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Peter Lin + * + */ +public class Transaction extends Security { + + protected String accountId = null; + protected double buyPrice; + protected String purchaseDate = null; + protected double shares; + protected double total; + protected String transactionId = null; + + protected ArrayList listeners = new ArrayList(); + + public Transaction() { + super(); + } + + public void setAccountId(String id) { + if (!id.equals(this.accountId)) { + String old = this.accountId; + this.accountId = id; + this.notifyListener("accountId",old,this.accountId); + } + } + + public String getAccountId() { + return this.accountId; + } + + public void setBuyPrice(double price) { + if (price != this.buyPrice) { + Double old = new Double(this.buyPrice); + this.buyPrice = price; + this.notifyListener("buyPrice",old,new Double(this.buyPrice)); + } + } + + public double getBuyPrice() { + return this.buyPrice; + } + + public void setPurchaseDate(String date) { + if (!date.equals(this.purchaseDate)) { + String old = this.purchaseDate; + this.purchaseDate = date; + this.notifyListener("purchaseDate",old,this.purchaseDate); + } + } + + public String getPurchaseDate() { + return this.purchaseDate; + } + + public void setShares(double shares) { + if (shares != this.shares) { + Double old = new Double(this.shares); + this.shares = shares; + this.notifyListener("shares",old,new Double(this.shares)); + } + } + + public double getShares() { + return this.shares; + } + + public void setTotal(double value) { + if (value != this.total) { + Double old = new Double(this.total); + this.total = value; + this.notifyListener("total",old,new Double(this.total)); + } + } + + public double getTotal() { + return this.total; + } + + public void setTransactionId(String id) { + if (!id.equals(this.transactionId)) { + String old = this.transactionId; + this.transactionId = id; + this.notifyListener("transactionId",old,this.transactionId); + } + } + + public String getTransactionId() { + return this.transactionId; + } + + public void addPropertyChangeListener(PropertyChangeListener listener){ + this.listeners.add(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener){ + this.listeners.remove(listener); + } + + protected void notifyListener(String field, Object oldValue, Object newValue){ + if (listeners == null || listeners.size() == 0) { + return; + } else { + PropertyChangeEvent event = new PropertyChangeEvent(this, field, + oldValue, newValue); + + for (int i = 0; i < listeners.size(); i++) { + ((java.beans.PropertyChangeListener) listeners.get(i)) + .propertyChange(event); + } + } + + } +} |