pouncer
February 3rd, 2010, 09:11 AM
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
public class TestClass
{
public static ArrayList<Ledger> ledgerArray = new ArrayList<Ledger>();
public static Map<Ledger, String[]> expectedData = new HashMap<Ledger, String[]>();
private static class Ledger
{
public String ledgerId, narrativeOwner, reference, fund, orgDate, dueDate, action, value, narrative, narrativesLeft, currency, refNumber, entryType,
postDate, recordType;
public Ledger(String ledgerId, String narrativeOwner, String reference, String fund, String orgDate,
String dueDate, String action, String value, String narrative,
String narrativesLeft, String currency, String refNumber, String entryType,
String postDate, String recordType)
{
ledgerId = this.ledgerId;
narrativeOwner = this.narrativeOwner;
reference = this.reference;
fund = this.fund;
orgDate = this.orgDate;
dueDate = this.dueDate;
action = this.action;
value = this.value;
narrative = this.narrative;
narrativesLeft = this.narrativesLeft;
currency = this.currency;
refNumber = this.refNumber;
entryType = this.entryType;
postDate = this.postDate;
recordType = this.postDate;
ledgerArray.add(this);
}
}
public static void main(String[] args)
{
Calendar cal1 = Calendar.getInstance();
cal1.set(2010, 01, 29);
Date dt = cal1.getTime();
String strDate = DateFormatUtils.ISO_DATETIME_FORMAT.format(DateUtils.truncate(dt, Calendar.DAY_OF_MONTH));
expectedData.put(new Ledger("51782891", "51782891", "E17599", " ", strDate, strDate, " ", "10.00",
"Some narrative test", "0", "GBP", "B001712512", "D", strDate, "110"),
new String[] { "51782891", "17599", null, "17599~TAX", strDate, "N", "10",
"Some narrative test", "GBP", "INC", "B001712512", null, "D", null, null,
strDate, "Y", strDate, "-10", null});
for (int i = 0; i < ledgerArray.size(); i++)
{
Ledger led = (Ledger) ledgerArray.get(i);
System.out.println("ledgerid........... " + led.ledgerId);
}
}
}
ledgerid........... null
anyone see what im doing wrong? should be printing "51782891"
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
public class TestClass
{
public static ArrayList<Ledger> ledgerArray = new ArrayList<Ledger>();
public static Map<Ledger, String[]> expectedData = new HashMap<Ledger, String[]>();
private static class Ledger
{
public String ledgerId, narrativeOwner, reference, fund, orgDate, dueDate, action, value, narrative, narrativesLeft, currency, refNumber, entryType,
postDate, recordType;
public Ledger(String ledgerId, String narrativeOwner, String reference, String fund, String orgDate,
String dueDate, String action, String value, String narrative,
String narrativesLeft, String currency, String refNumber, String entryType,
String postDate, String recordType)
{
ledgerId = this.ledgerId;
narrativeOwner = this.narrativeOwner;
reference = this.reference;
fund = this.fund;
orgDate = this.orgDate;
dueDate = this.dueDate;
action = this.action;
value = this.value;
narrative = this.narrative;
narrativesLeft = this.narrativesLeft;
currency = this.currency;
refNumber = this.refNumber;
entryType = this.entryType;
postDate = this.postDate;
recordType = this.postDate;
ledgerArray.add(this);
}
}
public static void main(String[] args)
{
Calendar cal1 = Calendar.getInstance();
cal1.set(2010, 01, 29);
Date dt = cal1.getTime();
String strDate = DateFormatUtils.ISO_DATETIME_FORMAT.format(DateUtils.truncate(dt, Calendar.DAY_OF_MONTH));
expectedData.put(new Ledger("51782891", "51782891", "E17599", " ", strDate, strDate, " ", "10.00",
"Some narrative test", "0", "GBP", "B001712512", "D", strDate, "110"),
new String[] { "51782891", "17599", null, "17599~TAX", strDate, "N", "10",
"Some narrative test", "GBP", "INC", "B001712512", null, "D", null, null,
strDate, "Y", strDate, "-10", null});
for (int i = 0; i < ledgerArray.size(); i++)
{
Ledger led = (Ledger) ledgerArray.get(i);
System.out.println("ledgerid........... " + led.ledgerId);
}
}
}
ledgerid........... null
anyone see what im doing wrong? should be printing "51782891"