001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.core.metadata.portlet;
023:
024: import org.jboss.portal.common.markup.MarkupAttribute;
025: import org.jboss.portal.common.markup.MarkupElement;
026:
027: import java.util.ArrayList;
028:
029: /**
030: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
031: * @version $Revision: 8786 $
032: */
033: public class LinkElementMetaData extends ElementMetaData {
034:
035: /** %ContentType required : CDATA -- media type, as per [RFC2045]. */
036: private String typeAttribute;
037:
038: /** %LinkTypes : CDATA -- space-separated list of link types. */
039: private String relAttribute;
040:
041: /** %URI : CDATA -- a Uniform Resource Identifier, see [URI]. */
042: private String hrefAttribute;
043:
044: /** %MediaDesc : CDATA -- single or comma-separated list of media descriptors. */
045: private String mediaAttribute;
046:
047: /** %Text : CDATA -- advisory title/amplification. */
048: private String titleAttribute;
049:
050: public LinkElementMetaData(String relAttribute,
051: String typeAttribute, String hrefAttribute,
052: String mediaAttribute, String titleAttribute) {
053: this .typeAttribute = typeAttribute;
054: this .relAttribute = relAttribute;
055: this .hrefAttribute = hrefAttribute;
056: this .mediaAttribute = mediaAttribute;
057: this .titleAttribute = titleAttribute;
058: }
059:
060: public MarkupElement buildElement() {
061: ArrayList attributes = new ArrayList(5);
062: if (typeAttribute != null && typeAttribute.length() > 0) {
063: attributes.add(new MarkupAttribute("type", typeAttribute,
064: MarkupAttribute.Type.CONTENT_TYPE));
065: }
066: if (relAttribute != null && relAttribute.length() > 0) {
067: attributes.add(new MarkupAttribute("rel", relAttribute,
068: MarkupAttribute.Type.LINK_TYPES));
069: }
070: if (hrefAttribute != null && hrefAttribute.length() > 0) {
071: attributes.add(new MarkupAttribute("href", hrefAttribute,
072: MarkupAttribute.Type.URI));
073: }
074: if (mediaAttribute != null && mediaAttribute.length() > 0) {
075: attributes.add(new MarkupAttribute("media", mediaAttribute,
076: MarkupAttribute.Type.MEDIA_DESC));
077: }
078: if (titleAttribute != null && titleAttribute.length() > 0) {
079: attributes.add(new MarkupAttribute("title", titleAttribute,
080: MarkupAttribute.Type.TEXT));
081: }
082: return new MarkupElement(
083: "link",
084: null,
085: false,
086: (MarkupAttribute[]) attributes
087: .toArray(new MarkupAttribute[attributes.size()]));
088: }
089:
090: public String getTypeAttribute() {
091: return typeAttribute;
092: }
093:
094: public String getRelAttribute() {
095: return relAttribute;
096: }
097:
098: public String getHrefAttribute() {
099: return hrefAttribute;
100: }
101:
102: public String getMediaAttribute() {
103: return mediaAttribute;
104: }
105:
106: public String getTitleAttribute() {
107: return titleAttribute;
108: }
109: }
|