1 7 8 package org.jboss.portal.core.theme.impl; 9 10 import org.apache.log4j.Logger; 11 import org.jboss.portal.server.theme.PortalTheme; 12 import org.jboss.portal.server.theme.ThemeLink; 13 14 21 public class ThemeLinkImpl 22 implements ThemeLink 23 { 24 private static final Logger log = Logger.getLogger(ThemeLinkImpl.class); 25 private String m_rel; 26 private String m_type; 27 private String m_href; 28 private String m_title; 29 private String m_media; 30 private PortalTheme m_theme; 31 32 42 public ThemeLinkImpl(PortalTheme theme, String rel, String type, String href, String title, String media) 43 { 44 log.debug("create theme link with rel=" + rel + " type=" + type 45 + " HREF=" + href + "title=" + title + " media=" + media); 46 m_theme = theme; 47 m_rel = rel; 48 m_type = type; 49 m_href = href; 50 m_title = title; 51 m_media = media; 52 } 53 54 57 public StringBuffer getLink() 58 { 59 log.debug("get link ..."); 60 StringBuffer link = new StringBuffer (); 61 62 link.append("<link rel='").append(m_rel).append("'"); 63 64 if (m_type != null) 65 { 66 link.append(" type='").append(m_type).append("'"); 67 } 68 69 if (m_href != null) 70 { 71 StringBuffer correctHREF = new StringBuffer (); 74 if (m_href.startsWith("/")) 75 { 76 correctHREF.append(m_theme.getContextPath()); 77 } 78 correctHREF.append(m_href); 79 link.append(" HREF='").append(correctHREF).append("'"); 80 } 81 82 if (m_title != null && !"".equals(m_title)) 83 { 84 link.append(" title='").append(m_title).append("'"); 85 } 86 if (m_media != null && !"".equals(m_media)) 87 { 88 link.append(" media='").append(m_media).append("'"); 89 } 90 91 link.append(" />"); 92 93 log.debug("returning: " + link); 94 95 return link; 96 } 97 98 101 public String toString() 102 { 103 return getLink().toString(); 104 } 105 } 106 | Popular Tags |