1 package com.sslexplorer.navigation; 2 3 import javax.servlet.jsp.JspException ; 4 import javax.servlet.jsp.PageContext ; 5 6 import org.apache.struts.taglib.TagUtils; 7 import org.apache.struts.util.MessageResources; 8 9 import com.sslexplorer.policyframework.ResourceType; 10 import com.sslexplorer.table.TableItem; 11 12 19 public class WrappedFavoriteItem implements TableItem { 20 21 private AbstractFavoriteItem favoriteItem; 23 private String type; 24 25 32 public WrappedFavoriteItem(AbstractFavoriteItem favoriteItem, String type) { 33 this.favoriteItem = favoriteItem; 34 this.type = type; 35 } 36 37 43 public String getFavoriteType() { 44 return type; 45 } 46 47 52 public AbstractFavoriteItem getFavoriteItem() { 53 return favoriteItem; 54 } 55 56 63 public String getResourceTypeName(PageContext pageContext) throws JspException { 64 ResourceType rt = getFavoriteItem().getResource() == null ? null : getFavoriteItem().getResource().getResourceType(); 65 if (rt == null) { 66 return "?"; 67 } else { 68 MessageResources mr = TagUtils.getInstance().retrieveMessageResources(pageContext, rt.getBundle(), false); 69 rt.getBundle(); 70 if (mr == null) { 71 return "!Invalid bundle!"; 72 } else { 73 String msg = mr.getMessage("resourceType." + rt.getResourceTypeId() + ".title"); 74 return msg == null || msg.equals("") ? "!No message!" : msg; 75 } 76 } 77 78 } 79 80 85 public Object getColumnValue(int col) { 86 return favoriteItem.getResource().getResourceName(); 87 } 88 89 92 public boolean equals(Object obj) { 93 try { 94 return getFavoriteItem().getResource().getResourceId() == ((WrappedFavoriteItem) obj).getFavoriteItem().getResource() 95 .getResourceId() 96 && getFavoriteItem().getResource().getResourceType() == ((WrappedFavoriteItem) obj).getFavoriteItem() 97 .getResource().getResourceType(); 98 } catch (ClassCastException cse) { 99 return false; 100 } 101 } 102 103 } | Popular Tags |