KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > setup > impl > dl > dbloader > SqlFunctionMetaData


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.setup.impl.dl.dbloader;
10
11 import org.jboss.portal.setup.PortalSetupException;
12
13 import java.sql.Date JavaDoc;
14
15
16 /**
17  * @author <a HREF="mailto:palber@novell.com">Polina Alber</a>
18  * Date: Apr 16, 2005; Time: 4:14:29 PM
19  * @since JBoss portal 2.0
20  * Class org.jboss.portal.setup.impl.dl.dbloader.SqlFunctionMetaData
21  */

22 public class SqlFunctionMetaData
23 {
24    private String JavaDoc m_funcString = null;
25    private String JavaDoc m_funcName = null;
26
27    protected SqlFunctionMetaData(String JavaDoc funcStr)
28    {
29       m_funcString = funcStr;
30       int index = funcStr.indexOf("(");
31       if (index > 0)
32       {
33          m_funcName = funcStr.substring(0, index);
34
35       }
36       else
37       {
38          m_funcName = funcStr;
39       }
40    }
41
42    public String JavaDoc toString()
43    {
44       return m_funcString;
45    }
46
47    public String JavaDoc getFuncName()
48    {
49       return m_funcName;
50    }
51
52    public Object JavaDoc resolveSQLFunction(String JavaDoc dbVendor) throws PortalSetupException
53    {
54       if ("now".equalsIgnoreCase(m_funcName))
55       {
56          return new Date JavaDoc(System.currentTimeMillis());
57       }
58       else
59       {
60          throw new PortalSetupException("Specified function: " +
61             (getFuncName() + " is not supported by hibernate dialect: " +
62             dbVendor));
63       }
64    }
65 }
66
Popular Tags