[displaytag-cvs] displaytag-examples/src/main/java/org/displaytag/sample ReportableListObject.java,N
Brought to you by:
fgiust
|
From: fabrizio g. <fg...@us...> - 2005-10-16 20:35:15
|
Update of /cvsroot/displaytag/displaytag-examples/src/main/java/org/displaytag/sample In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18537/src/main/java/org/displaytag/sample Added Files: ReportableListObject.java ListHolder.java TotalWrapper.java ReportList.java ListObject.java Wrapper.java RandomSampleUtil.java LongDateWrapper.java TestList.java DisplaySourceServlet.java Log Message: committing DISPL-245 WYSIWYG Exports - from Jorge L. Barroso + some changes and fixes --- NEW FILE: RandomSampleUtil.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.Calendar; import java.util.Date; import java.util.Random; /** * Utility class used to get random word and sentences used in examples. * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public final class RandomSampleUtil { /** * list of words. */ private static String[] words = new String[]{"Lorem", //$NON-NLS-1$ "ipsum", //$NON-NLS-1$ "dolor", //$NON-NLS-1$ "sit", //$NON-NLS-1$ "amet", //$NON-NLS-1$ "consetetur", //$NON-NLS-1$ "sadipscing", //$NON-NLS-1$ "elitr", //$NON-NLS-1$ "sed", //$NON-NLS-1$ "diam", //$NON-NLS-1$ "nonumy", //$NON-NLS-1$ "eirmod", //$NON-NLS-1$ "tempor", //$NON-NLS-1$ "invidunt", //$NON-NLS-1$ "ut", //$NON-NLS-1$ "labore", //$NON-NLS-1$ "et", //$NON-NLS-1$ "dolore", //$NON-NLS-1$ "magna", //$NON-NLS-1$ "aliquyam", //$NON-NLS-1$ "erat", //$NON-NLS-1$ "sed", //$NON-NLS-1$ "diam", //$NON-NLS-1$ "voluptua", //$NON-NLS-1$ "At", //$NON-NLS-1$ "vero", //$NON-NLS-1$ "eos", //$NON-NLS-1$ "et", //$NON-NLS-1$ "accusam", //$NON-NLS-1$ "et", //$NON-NLS-1$ "justo", //$NON-NLS-1$ "duo", //$NON-NLS-1$ "dolores", //$NON-NLS-1$ "et", //$NON-NLS-1$ "ea", //$NON-NLS-1$ "rebum", //$NON-NLS-1$ "Stet", //$NON-NLS-1$ "clita", //$NON-NLS-1$ "kasd", //$NON-NLS-1$ "gubergren", //$NON-NLS-1$ "no", //$NON-NLS-1$ "sea", //$NON-NLS-1$ "takimata", //$NON-NLS-1$ "sanctus", //$NON-NLS-1$ "est"}; //$NON-NLS-1$ /** * random number producer. */ private static Random random = new Random(); /** * utility class, don't instantiate. */ private RandomSampleUtil() { super(); } /** * returns a random word. * @return random word */ public static String getRandomWord() { return words[random.nextInt(words.length)]; } /** * returns a random sentence. * @param wordNumber number of word in the sentence * @return random sentence made of <code>wordNumber</code> words */ public static String getRandomSentence(int wordNumber) { StringBuffer buffer = new StringBuffer(wordNumber * 12); int j = 0; while (j < wordNumber) { buffer.append(getRandomWord()); buffer.append(" "); //$NON-NLS-1$ j++; } return buffer.toString(); } /** * returns a random email. * @return random email */ public static String getRandomEmail() { return getRandomWord() + "@" + getRandomWord() + ".com"; //$NON-NLS-1$ //$NON-NLS-2$ } /** * returns a random date. * @return random date */ public static Date getRandomDate() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 365 - random.nextInt(730)); return calendar.getTime(); } } --- NEW FILE: DisplaySourceServlet.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet used to display jsp source for example pages. * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class DisplaySourceServlet extends HttpServlet { /** * D1597A17A6. */ private static final long serialVersionUID = 899149338534L; /** * the folder containg example pages. */ private static final String EXAMPLE_FOLDER = "/"; //$NON-NLS-1$ /** * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest, HttpServletResponse) */ protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String jspFile = request.getRequestURI(); // lastIndexOf(".") can't be null, since the servlet is mapped to ".source" jspFile = jspFile.substring(0, jspFile.lastIndexOf(".")); //$NON-NLS-1$ if (jspFile.lastIndexOf("/") != -1) //$NON-NLS-1$ { jspFile = jspFile.substring(jspFile.lastIndexOf("/") + 1); //$NON-NLS-1$ } // only want to show sample pages, don't play with url! if (!jspFile.startsWith("example-")) //$NON-NLS-1$ { throw new ServletException("Invalid file selected: " + jspFile); //$NON-NLS-1$ } String fullName = EXAMPLE_FOLDER + jspFile; InputStream inputStream = getServletContext().getResourceAsStream(fullName); if (inputStream == null) { throw new ServletException("Unable to find JSP file: " + jspFile); //$NON-NLS-1$ } response.setContentType("text/html"); //$NON-NLS-1$ PrintWriter out = response.getWriter(); out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " //$NON-NLS-1$ + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); //$NON-NLS-1$ out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"); //$NON-NLS-1$ out.println("<head>"); //$NON-NLS-1$ out.println("<title>"); //$NON-NLS-1$ out.println("source for " + jspFile); //$NON-NLS-1$ out.println("</title>"); //$NON-NLS-1$ out.println("<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />"); //$NON-NLS-1$ out.println("</head>"); //$NON-NLS-1$ out.println("<body>"); //$NON-NLS-1$ out.println("<pre>"); //$NON-NLS-1$ for (int currentChar = inputStream.read(); currentChar != -1; currentChar = inputStream.read()) { if (currentChar == '<') { out.print("<"); //$NON-NLS-1$ } else { out.print((char) currentChar); } } out.println("</pre>"); //$NON-NLS-1$ out.println("</body>"); //$NON-NLS-1$ out.println("</html>"); //$NON-NLS-1$ } } --- NEW FILE: ListObject.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; /** * Just a test class that returns columns of data that are useful for testing out the ListTag class and ListColumn * class. * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class ListObject { /** * random number generator. */ private static Random random = new Random(); /** * id. */ private int id = -1; /** * name. */ private String name; /** * email. */ private String email; /** * date. */ private Date date; /** * money. */ private double money; /** * description. */ private String description; /** * long description. */ private String longDescription; /** * status. */ private String status; /** * url. */ private String url; /** * sub list used to test nested tables. */ private List subList; /** * Constructor for ListObject. */ public ListObject() { this.id = random.nextInt(99998) + 1; this.money = (random.nextInt(999998) + 1) / 100; String firstName = RandomSampleUtil.getRandomWord(); String lastName = RandomSampleUtil.getRandomWord(); this.name = StringUtils.capitalize(firstName) + ' ' + StringUtils.capitalize(lastName); this.email = firstName + '-' + lastName + '@' + RandomSampleUtil.getRandomWord() + ".com"; //$NON-NLS-1$ this.date = RandomSampleUtil.getRandomDate(); this.description = RandomSampleUtil.getRandomWord() + ' ' // + RandomSampleUtil.getRandomWord() + "..."; //$NON-NLS-1$ this.longDescription = RandomSampleUtil.getRandomSentence(10); this.status = RandomSampleUtil.getRandomWord().toUpperCase(); // added sublist for testing of nested tables this.subList = new ArrayList(); this.subList.add(new SubListItem()); this.subList.add(new SubListItem()); this.subList.add(new SubListItem()); this.url = "http://www." + lastName + ".org/"; //$NON-NLS-1$ //$NON-NLS-2$ } /** * getter for id. * @return int id */ public int getId() { return this.id; } /** * setter for id. * @param value int id */ public void setId(int value) { this.id = value; } /** * getter for name. * @return String name */ public String getName() { return this.name; } /** * getter for email. * @return String email */ public String getEmail() { return this.email; } /** * setter for email. * @param value String email */ public void setEmail(String value) { this.email = value; } /** * getter for date. * @return Date */ public Date getDate() { return (Date) this.date.clone(); } /** * getter for money. * @return double money */ public double getMoney() { return this.money; } /** * getter for description. * @return String description */ public String getDescription() { return this.description; } /** * getter for long description. * @return String long description */ public String getLongDescription() { return this.longDescription; } /** * getter for status. * @return String status */ public String getStatus() { return this.status; } /** * getter for url. * @return String url */ public String getUrl() { return this.url; } /** * test for null values. * @return null */ public String getNullValue() { return null; } /** * Returns a simple string representation of the object. * @return String simple representation of the object */ public String toString() { return "ListObject(" + this.id + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } /** * Returns a detailed string representation of the object. * @return String detailed representation of the object */ public String toDetailedString() { return "ID: " //$NON-NLS-1$ + this.id + "\n" //$NON-NLS-1$ + "Name: " //$NON-NLS-1$ + this.name + "\n" //$NON-NLS-1$ + "Email: " //$NON-NLS-1$ + this.email + "\n" //$NON-NLS-1$ + "Date: " //$NON-NLS-1$ + this.date + "\n" //$NON-NLS-1$ + "Money: " //$NON-NLS-1$ + this.money + "\n" //$NON-NLS-1$ + "Description: " //$NON-NLS-1$ + this.description + "\n" //$NON-NLS-1$ + "Status: " //$NON-NLS-1$ + this.status + "\n" //$NON-NLS-1$ + "URL: " //$NON-NLS-1$ + this.url + "\n"; //$NON-NLS-1$ } /** * Returns the subList. * @return List */ public List getSubList() { return this.subList; } /** * Inner class used in testing nested tables. * @author Fabrizio Giustina */ public static class SubListItem { /** * name. */ private String itemName; /** * email. */ private String itemEmail; /** * Constructor for SubListItem. */ public SubListItem() { this.itemName = RandomSampleUtil.getRandomWord(); this.itemEmail = RandomSampleUtil.getRandomEmail(); } /** * getter for name. * @return String name */ public String getName() { return this.itemName; } /** * getter for email. * @return String */ public String getEmail() { return this.itemEmail; } /** * @see java.lang.Object#toString() */ public String toString() { return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE) // .append("name", this.itemName) //$NON-NLS-1$ .append("email", this.itemEmail) //$NON-NLS-1$ .toString(); } } } --- NEW FILE: TestList.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.ArrayList; import java.util.Random; /** * Just a utility class for testing out the table and column tags. When this class is created, it loads itself with a * number of ListObjects that are shown throughout the various example pages that exercise the table object. If created * via the default constructor, this loads itself with 60 ListObjects. * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class TestList extends ArrayList { /** * D1597A17A6. */ private static final long serialVersionUID = 899149338534L; /** * Creats a TestList that is filled with 60 ListObjects suitable for testing. */ public TestList() { super(); for (int j = 0; j < 60; j++) { add(new ListObject()); } } /** * Creates a TestList that is filled with [size] ListObjects suitable for testing. * @param size int size of the list * @param duplicates boolean put duplicates in the list */ public TestList(int size, boolean duplicates) { if (duplicates) { // generate a random number between 1 and 3 and duplicate that many number of times. for (int j = 0; j < size; j++) { ListObject object1 = new ListObject(); ListObject object2 = new ListObject(); ListObject object3 = new ListObject(); int random = new Random().nextInt(3); for (int k = 0; k <= random; k++) { add(object1); } object1.setId(object2.getId()); random = new Random().nextInt(3); for (int k = 0; k <= random; k++) { add(object1); add(object2); } object1.setEmail(object3.getEmail()); random = new java.util.Random().nextInt(3); for (int k = 0; k <= random; k++) { add(object1); } } } else { for (int j = 0; j < size; j++) { add(new ListObject()); } } } /** * Returns a ListObject using get(index) from the Array. * @param index int index of the List object into the array * @return ListObject */ public ListObject getItem(int index) { return (ListObject) super.get(index); } } --- NEW FILE: Wrapper.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.text.DecimalFormat; import org.apache.commons.lang.time.FastDateFormat; import org.displaytag.decorator.TableDecorator; /** * This class is a decorator of the TestObjects that we keep in our List. This class provides a number of methods for * formatting data, creating dynamic links, and exercising some aspects of the display:table API functionality. * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class Wrapper extends TableDecorator { /** * FastDateFormat used to format dates in getDate(). */ private FastDateFormat dateFormat; /** * DecimalFormat used to format money in getMoney(). */ private DecimalFormat moneyFormat; /** * Creates a new Wrapper decorator who's job is to reformat some of the data located in our TestObject's. */ public Wrapper() { super(); // Formats for displaying dates and money. this.dateFormat = FastDateFormat.getInstance("MM/dd/yy"); //$NON-NLS-1$ this.moneyFormat = new DecimalFormat("$ #,###,###.00"); //$NON-NLS-1$ } /** * Test method which always returns a null value. * @return <code>null</code> */ public String getNullValue() { return null; } /** * Returns the date as a String in MM/dd/yy format. * @return formatted date */ public String getDate() { return this.dateFormat.format(((ListObject) this.getCurrentRowObject()).getDate()); } /** * Returns the money as a String in $ #,###,###.00 format. * @return String */ public String getMoney() { return this.moneyFormat.format(((ListObject) this.getCurrentRowObject()).getMoney()); } /** * Returns the TestObject's ID as a hyperlink that the person can click on and "drill down" for more details. * @return String */ public String getLink1() { ListObject object = (ListObject) getCurrentRowObject(); int index = getListIndex(); return "<a href=\"details.jsp?index=" //$NON-NLS-1$ + index + "\">" //$NON-NLS-1$ + object.getId() + "</a>"; //$NON-NLS-1$ } /** * Returns an "action bar" of sorts that allow the user to perform various actions on the TestObject based on it's * id. * @return String */ public String getLink2() { ListObject object = (ListObject) getCurrentRowObject(); int id = object.getId(); return "<a href=\"details.jsp?id=" //$NON-NLS-1$ + id + "&action=view\">View</a> | " //$NON-NLS-1$ + "<a href=\"details.jsp?id=" //$NON-NLS-1$ + id + "&action=edit\">Edit</a> | " //$NON-NLS-1$ + "<a href=\"details.jsp?id=" //$NON-NLS-1$ + id + "&action=delete\">Delete</a>"; //$NON-NLS-1$ } } --- NEW FILE: TotalWrapper.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.List; import org.displaytag.decorator.TableDecorator; /** * This decorator only does a summing of different groups in the reporting style examples... * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class TotalWrapper extends TableDecorator { /** * total amount. */ private double grandTotal; /** * total amount for city. */ private double cityTotal; /** * After every row completes we evaluate to see if we should be drawing a new total line and summing the results * from the previous group. * @return String */ public final String finishRow() { int listindex = ((List) getDecoratedObject()).indexOf(this.getCurrentRowObject()); ReportableListObject reportableObject = (ReportableListObject) this.getCurrentRowObject(); String nextCity; this.cityTotal += reportableObject.getAmount(); this.grandTotal += reportableObject.getAmount(); if (listindex == ((List) getDecoratedObject()).size() - 1) { nextCity = "XXXXXX"; // Last row hack, it's only a demo folks... //$NON-NLS-1$ } else { nextCity = ((ReportableListObject) ((List) getDecoratedObject()).get(listindex + 1)).getCity(); } StringBuffer buffer = new StringBuffer(1000); // City subtotals... if (!nextCity.equals(reportableObject.getCity())) { buffer.append("\n<tr>\n<td> </td><td> </td><td><hr noshade size=\"1\"></td>"); //$NON-NLS-1$ buffer.append("\n<td> </td></tr>"); //$NON-NLS-1$ buffer.append("\n<tr><td> </td>"); //$NON-NLS-1$ buffer.append("\n<td align=\"right\"><strong>" //$NON-NLS-1$ + reportableObject.getCity() + " Total:</strong></td>\n<td><strong>"); //$NON-NLS-1$ buffer.append(this.cityTotal); buffer.append("</strong></td>\n<td> </td>\n</tr>"); //$NON-NLS-1$ buffer.append("\n<tr>\n<td colspan=\"4\"> \n</td>\n</tr>"); //$NON-NLS-1$ this.cityTotal = 0; } // Grand totals... if (getViewIndex() == ((List) getDecoratedObject()).size() - 1) { buffer.append("<tr><td colspan=\"4\"><hr></td></tr>"); //$NON-NLS-1$ buffer.append("<tr><td> </td>"); //$NON-NLS-1$ buffer.append("<td align=\"right\"><strong>Grand Total:</strong></td><td><strong>"); //$NON-NLS-1$ buffer.append(this.grandTotal); buffer.append("</strong></td><td> </td></tr>"); //$NON-NLS-1$ } return buffer.toString(); } } --- NEW FILE: ListHolder.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.List; /** * Simple objects which holds a list. * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class ListHolder extends Object { /** * contained list. */ private List list; /** * Instantiate a new ListHolder and initialize a TestList with 5 elements. */ public ListHolder() { this.list = new TestList(15, false); } /** * Returns the contained list. * @return a TestList with 15 elements */ public final List getList() { return this.list; } } --- NEW FILE: ReportableListObject.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.Random; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.apache.commons.lang.builder.CompareToBuilder; /** * A test class that has data that looks more like information that comes back in a report. * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class ReportableListObject extends Object implements Comparable { /** * random number producer. */ private static Random random = new Random(); /** * city names. */ private static String[] cities = // {"Roma", "Olympia", "Neapolis", "Carthago"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ /** * project names. */ private static String[] projects = // {"Taxes", "Arts", "Army", "Gladiators"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ /** * city. */ private String city; /** * project. */ private String project; /** * task. */ private String task; /** * amount. */ private double amount; /** * Constructor for ReportableListObject. */ public ReportableListObject() { this.amount = (random.nextInt(99999) + 1) / 100; this.city = cities[random.nextInt(cities.length)]; this.project = projects[random.nextInt(projects.length)]; this.task = RandomSampleUtil.getRandomSentence(4); } /** * getter for city. * @return String city */ public String getCity() { return this.city; } /** * getter for project. * @return String project */ public String getProject() { return this.project; } /** * getter for task. * @return String task */ public String getTask() { return this.task; } /** * getter for amount. * @return double amount */ public double getAmount() { return this.amount; } /** * @see java.lang.Comparable#compareTo(Object) */ public int compareTo(Object object) { ReportableListObject myClass = (ReportableListObject) object; return new CompareToBuilder().append(this.project, myClass.project).append(this.amount, myClass.amount).append( this.city, myClass.city).append(this.task, myClass.task).toComparison(); } /** * @see java.lang.Object#toString() */ public String toString() { return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE) // .append("project", this.project) //$NON-NLS-1$ .append("amount", this.amount) //$NON-NLS-1$ .append("city", this.city) //$NON-NLS-1$ .append("task", this.task) //$NON-NLS-1$ .toString(); } } --- NEW FILE: ReportList.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.ArrayList; import java.util.Collections; /** * Just a utility class for testing out the table and column tags. This List fills itself with objects and sorts them as * though it where pulling data from a report. This list is used to show the various report oriented examples (such as * grouping, callbacks, and data exports). * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class ReportList extends ArrayList { /** * D1597A17A6. */ private static final long serialVersionUID = 899149338534L; /** * Creats a TestList that is filled with 20 ReportableListObject suitable for testing. */ public ReportList() { super(); for (int j = 0; j < 20; j++) { add(new ReportableListObject()); } Collections.sort(this); } /** * Creates a TestList that is filled with [size] ReportableListObject suitable for testing. * @param size int */ public ReportList(int size) { super(); for (int j = 0; j < size; j++) { add(new ReportableListObject()); } Collections.sort(this); } } --- NEW FILE: LongDateWrapper.java --- /** * Licensed under the Artistic License; you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://displaytag.sourceforge.net/license.html * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ package org.displaytag.sample; import java.util.Date; import org.apache.commons.lang.time.FastDateFormat; import org.displaytag.decorator.ColumnDecorator; /** * Simple column decorator which formats a date. * @author epesh * @author Fabrizio Giustina * @version $Revision$ ($Author$) */ public class LongDateWrapper implements ColumnDecorator { /** * FastDateFormat used to format the date object. */ private FastDateFormat dateFormat = FastDateFormat.getInstance("MM/dd/yyyy HH:mm:ss"); //$NON-NLS-1$ /** * transform the given object into a String representation. The object is supposed to be a date. * @param columnValue Object * @return String */ public final String decorate(Object columnValue) { Date date = (Date) columnValue; return this.dateFormat.format(date); } } |