001: /*
002: Copyright (C) 2003 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.dataxslt;
034:
035: import org.w3c.dom.Element;
036: import org.w3c.dom.Node;
037:
038: import com.knowgate.misc.Gadgets;
039:
040: import dom.DOMSubDocument;
041:
042: /**
043: * <p>Microsite MetaBlock.</p>
044: * <p>This class represents a <metablock></metablock> section of a
045: * Microsite XML definition file. The XML file is first parsed into a DOMDocument
046: * and then DOMDocument nodes are wrapped with classes that add specific Microsite
047: * behavior.</p>
048: * @author Sergio Montoro Ten
049: * @version 1.1
050: */
051: public class MetaBlock extends DOMSubDocument {
052:
053: /**
054: * @param oRefNode DOMDocument Node holding <metablock> element.
055: */
056: public MetaBlock(Node oRefNode) {
057: super (oRefNode);
058: }
059:
060: // ----------------------------------------------------------
061:
062: public String id() {
063: Node oItem = oNode.getAttributes().getNamedItem("id");
064:
065: if (null == oItem)
066: return null;
067: else
068: return oItem.getNodeValue();
069: } // id()
070:
071: // ----------------------------------------------------------
072:
073: /**
074: * <p>Get metablock <maxoccurs> node</p>
075: * @return If maxoccurs node is not found then function returns -1
076: * @throws NumberFormatException If maxoccurs value is not a valid integer
077: */
078: public int maxoccurs() throws NumberFormatException {
079:
080: String sMaxOccurs = getElement("maxoccurs");
081:
082: if (null == sMaxOccurs)
083: return -1;
084: else
085: return Integer.parseInt(sMaxOccurs.trim());
086: } // maxoccurs
087:
088: // ----------------------------------------------------------
089:
090: public String name() {
091: return getElement("name");
092: } // name
093:
094: // ----------------------------------------------------------
095:
096: public String template() {
097: return getElement("template");
098: } // template
099:
100: // ----------------------------------------------------------
101:
102: public String thumbnail() {
103: return getElement("thumbnail");
104: } // thumbnail
105:
106: // ----------------------------------------------------------
107:
108: /**
109: * <p>Split <objects> node by commas and return resulting array</p>
110: */
111: public String[] objects() {
112: String sObjs = getElement("objects");
113:
114: if (null == sObjs)
115: return null;
116: else
117: return Gadgets.split(sObjs, ',');
118: } // objects
119:
120: // ----------------------------------------------------------
121:
122: }
|