KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > ejb > VOHelper


1 package org.apache.ojb.ejb;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 import java.math.BigDecimal JavaDoc;
20 import java.util.ArrayList JavaDoc;
21 import java.util.List JavaDoc;
22
23 /**
24  * Simple helper class.
25  *
26  * @author <a HREF="mailto:armin@codeAuLait.de">Armin Waibel</a>
27  */

28 public class VOHelper
29 {
30     public static List JavaDoc createNewArticleList(int number)
31     {
32         ArrayList JavaDoc list = new ArrayList JavaDoc();
33         for (int i = 0; i < number; i++)
34         {
35             list.add(createNewArticle(i));
36         }
37         return list;
38     }
39
40     public static List JavaDoc createNewPersonList(int number)
41     {
42         ArrayList JavaDoc list = new ArrayList JavaDoc();
43         for (int i = 0; i < number; i++)
44         {
45             list.add(createNewPerson(i));
46         }
47         return list;
48     }
49
50     public static ArticleVO createNewArticle(int counter)
51     {
52         return createNewArticle("A simple test article ", counter);
53     }
54
55     public static ArticleVO createNewArticle(String JavaDoc name, int counter)
56     {
57         ArticleVO a = new ArticleVO();
58         a.setName(name);
59         a.setPrice(new BigDecimal JavaDoc(0.45d * counter));
60         a.setDescription("test article description " + counter);
61         return a;
62     }
63
64     public static CategoryVO createNewCategory(String JavaDoc name)
65     {
66         return new CategoryVO(null, name, "this is a test category");
67     }
68
69     public static PersonVO createNewPerson(int counter)
70     {
71         PersonVO p = new PersonVO();
72         p.setFirstName("firstname " + counter);
73         p.setLastName("lastname " + counter);
74         p.setGrade("grade" + counter);
75         return p;
76     }
77 }
78
Popular Tags