Source code: com/xpn/xwiki/objects/classes/DBListClass.java
1 /**
2 * ===================================================================
3 *
4 * Copyright (c) 2003,2004 Ludovic Dubost, All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details, published at
15 * http://www.gnu.org/copyleft/gpl.html or in gpl.txt in the
16 * root folder of this distribution.
17
18 * Created by
19 * User: Ludovic Dubost
20 * Date: 5 févr. 2004
21 * Time: 15:58:43
22 */
23 package com.xpn.xwiki.objects.classes;
24
25 import com.xpn.xwiki.XWiki;
26 import com.xpn.xwiki.XWikiContext;
27 import com.xpn.xwiki.objects.meta.PropertyMetaClass;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32 public class DBListClass extends ListClass {
33 public DBListClass(PropertyMetaClass wclass) {
34 super(<font color=red>"dblist"font>, <font color=red>"DB List"font>, wclass);
35 }
36
37 public DBListClass() {
38 this(null);
39 }
40
41 public List getList(XWikiContext context) {
42 XWiki xwiki = context.getWiki();
43 try {
44 return xwiki.search(getSql(), context);
45 } catch (Exception e) {
46 e.printStackTrace();
47 return new ArrayList();
48 }
49 }
50
51 public String getSql() {
52 return getLargeStringValue(<font color=red>"sql"font>);
53 }
54
55 public void setSql(String sql) {
56 setLargeStringValue(<font color=red>"sql"font>, sql);
57 }
58 }