KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > setup > impl > dl > cmsloader > CmsStatementMetaData


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.cmsloader;
10
11 import org.jboss.portal.setup.impl.dl.StatementMetaData;
12 import org.jboss.portal.setup.impl.dl.StatementType;
13 import org.jboss.portal.setup.PortalSetupException;
14 import org.jboss.portal.setup.CmsSetupException;
15 import org.jboss.portal.common.util.XML;
16 import org.w3c.dom.Element JavaDoc;
17
18 import java.util.List JavaDoc;
19 import java.util.ArrayList JavaDoc;
20
21 /**
22  * @author <a HREF="mailto:palber@novell.com">Polina Alber</a>
23  * Date: Apr 29, 2005; Time: 9:31:18 PM
24  * @since JBoss portal 2.0
25  * Class org.jboss.portal.setup.impl.dl.cmsloader.CmsStatementMetaData
26  */

27 public class CmsStatementMetaData extends StatementMetaData
28 {
29    private StatementType m_type = null;
30    private List JavaDoc m_contents = new ArrayList JavaDoc();
31
32    CmsStatementMetaData(Element JavaDoc statement) throws PortalSetupException
33    {
34       super(statement);
35       buildMetaData(statement);
36    }
37
38    /**
39     * @return type of a statement (INSERT, UPDATE, ALTER, and etc;
40     */

41    public StatementType getType()
42    {
43       return m_type;
44    }
45
46    public List JavaDoc getContents()
47    {
48       return m_contents;
49    }
50
51    /**
52     * @param config an XML element;
53     * Builds statement metadata by parsing xml estatement element
54     */

55    protected void buildMetaData(Element JavaDoc config) throws PortalSetupException
56    {
57       String JavaDoc strType = XML.asString(XML.getUniqueChild(config, "type", true));
58       m_type = StatementType.parseString(strType);
59
60       List JavaDoc contentDef = XML.getChildren(config, "content");
61
62       for (int i = 0; i < contentDef.size(); i++)
63       {
64          Element JavaDoc content = (Element JavaDoc)contentDef.get(i);
65
66          m_contents.add(buildContentMetaData(content));
67       }
68
69
70    }
71
72    private ContentMetaData buildContentMetaData(Element JavaDoc content)
73    {
74       return new ContentMetaData(content);
75
76    }
77
78 }
79
Popular Tags