KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > dataxslt > MetaBlock


1 /*
2   Copyright (C) 2003 Know Gate S.L. All rights reserved.
3                       C/Oņa, 107 1š2 28050 Madrid (Spain)
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8
9   1. Redistributions of source code must retain the above copyright
10      notice, this list of conditions and the following disclaimer.
11
12   2. The end-user documentation included with the redistribution,
13      if any, must include the following acknowledgment:
14      "This product includes software parts from hipergate
15      (http://www.hipergate.org/)."
16      Alternately, this acknowledgment may appear in the software itself,
17      if and wherever such third-party acknowledgments normally appear.
18
19   3. The name hipergate must not be used to endorse or promote products
20      derived from this software without prior written permission.
21      Products derived from this software may not be called hipergate,
22      nor may hipergate appear in their name, without prior written
23      permission.
24
25   This library is distributed in the hope that it will be useful,
26   but WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28
29   You should have received a copy of hipergate License with this code;
30   if not, visit http://www.hipergate.org or mail to info@hipergate.org
31 */

32
33 package com.knowgate.dataxslt;
34
35 import org.w3c.dom.Element JavaDoc;
36 import org.w3c.dom.Node JavaDoc;
37
38 import com.knowgate.misc.Gadgets;
39
40 import dom.DOMSubDocument;
41
42 /**
43  * <p>Microsite MetaBlock.</p>
44  * <p>This class represents a &lt;metablock&gt;&lt;/metablock&gt; section of a
45  * Microsite XML definition file. The XML file is first parsed into a DOMDocument
46  * and then DOMDocument nodes are wrapped with classes that add specific Microsite
47  * behavior.</p>
48  * @author Sergio Montoro Ten
49  * @version 1.1
50  */

51 public class MetaBlock extends DOMSubDocument {
52
53   /**
54    * @param oRefNode DOMDocument Node holding &lt;metablock&gt; element.
55    */

56   public MetaBlock(Node JavaDoc oRefNode) {
57     super(oRefNode);
58   }
59
60   // ----------------------------------------------------------
61

62   public String JavaDoc id() {
63     Node JavaDoc oItem = oNode.getAttributes().getNamedItem("id");
64
65     if (null==oItem)
66       return null;
67     else
68       return oItem.getNodeValue();
69   } // id()
70

71   // ----------------------------------------------------------
72

73   /**
74    * <p>Get metablock &lt;maxoccurs&gt; node</p>
75    * @return If maxoccurs node is not found then function returns -1
76    * @throws NumberFormatException If maxoccurs value is not a valid integer
77    */

78   public int maxoccurs() throws NumberFormatException JavaDoc {
79
80     String JavaDoc sMaxOccurs = getElement("maxoccurs");
81
82     if (null==sMaxOccurs)
83       return -1;
84     else
85       return Integer.parseInt(sMaxOccurs.trim());
86   } // maxoccurs
87

88   // ----------------------------------------------------------
89

90   public String JavaDoc name() {
91     return getElement("name");
92   } // name
93

94   // ----------------------------------------------------------
95

96   public String JavaDoc template() {
97     return getElement("template");
98   } // template
99

100   // ----------------------------------------------------------
101

102   public String JavaDoc thumbnail() {
103     return getElement("thumbnail");
104   } // thumbnail
105

106   // ----------------------------------------------------------
107

108   /**
109    * <p>Split &lt;objects&gt; node by commas and return resulting array</p>
110    */

111   public String JavaDoc[] objects() {
112     String JavaDoc sObjs = getElement("objects");
113
114     if (null==sObjs)
115       return null;
116     else
117       return Gadgets.split(sObjs,',');
118   } // objects
119

120   // ----------------------------------------------------------
121

122 }
Popular Tags