01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.core.metadata.portlet;
23:
24: import org.jboss.portal.common.markup.MarkupAttribute;
25: import org.jboss.portal.common.markup.MarkupElement;
26:
27: import java.util.ArrayList;
28:
29: /**
30: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
31: * @version $Revision: 8786 $
32: */
33: public class NamedMetaElementMetaData extends ElementMetaData {
34:
35: /** NAME. */
36: private String nameAttribute;
37:
38: /** CDATA. */
39: private String contentAttribute;
40:
41: public NamedMetaElementMetaData(String nameAttribute,
42: String contentAttribute) {
43: if (nameAttribute == null) {
44: throw new IllegalArgumentException(
45: "'name' attribute of meta element must NOT be null. http-equiv meta "
46: + "elements are not currently supported.");
47: }
48: if (contentAttribute == null) {
49: throw new IllegalArgumentException(
50: "Content attribute required for meta element: "
51: + nameAttribute);
52: }
53:
54: //
55: this .nameAttribute = nameAttribute;
56: this .contentAttribute = contentAttribute;
57: }
58:
59: public String getNameAttribute() {
60: return nameAttribute;
61: }
62:
63: public String getContentAttribute() {
64: return contentAttribute;
65: }
66:
67: public MarkupElement buildElement() {
68: ArrayList attributes = new ArrayList(3);
69: if (nameAttribute != null && nameAttribute.length() > 0) {
70: attributes.add(new MarkupAttribute("name", nameAttribute,
71: MarkupAttribute.Type.NAME));
72: }
73: if (contentAttribute != null && contentAttribute.length() > 0) {
74: attributes.add(new MarkupAttribute("content",
75: contentAttribute, MarkupAttribute.Type.CDATA));
76: }
77: return new MarkupElement(
78: "meta",
79: null,
80: false,
81: (MarkupAttribute[]) attributes
82: .toArray(new MarkupAttribute[attributes.size()]));
83: }
84: }
|