1 27 package org.htmlparser.parserapplications.filterbuilder.wrappers; 28 29 import java.awt.event.ActionEvent ; 30 import java.awt.event.ActionListener ; 31 32 import org.htmlparser.Node; 33 import org.htmlparser.NodeFilter; 34 import org.htmlparser.Parser; 35 import org.htmlparser.filters.HasSiblingFilter; 36 import org.htmlparser.parserapplications.filterbuilder.Filter; 37 import org.htmlparser.parserapplications.filterbuilder.SubFilterList; 38 39 42 public class HasSiblingFilterWrapper 43 extends 44 Filter 45 implements 46 ActionListener 47 { 48 51 protected HasSiblingFilter mFilter; 52 53 56 protected SubFilterList mContainer; 57 58 61 public HasSiblingFilterWrapper () 62 { 63 mFilter = new HasSiblingFilter (); 64 65 mContainer = new SubFilterList (this, "Sibling Filter", 1); 67 add (mContainer); 68 } 69 70 74 public String getDescription () 75 { 76 return ("Has Sibling"); 77 } 78 79 public String getIconSpec () 80 { 81 return ("images/HasSiblingFilter.gif"); 82 } 83 84 public NodeFilter getNodeFilter () 85 { 86 NodeFilter filter; 87 HasSiblingFilter ret; 88 89 ret = new HasSiblingFilter (); 90 91 filter = mFilter.getSiblingFilter (); 92 if (null != filter) 93 ret.setSiblingFilter (((Filter)filter).getNodeFilter ()); 94 95 return (ret); 96 } 97 98 public void setNodeFilter (NodeFilter filter, Parser context) 99 { 100 mFilter = (HasSiblingFilter)filter; 101 } 102 103 public NodeFilter[] getSubNodeFilters () 104 { 105 NodeFilter filter; 106 NodeFilter[] ret; 107 108 filter = mFilter.getSiblingFilter (); 109 if (null != filter) 110 ret = new NodeFilter[] { filter }; 111 else 112 ret = new NodeFilter[0]; 113 114 return (ret); 115 } 116 117 public void setSubNodeFilters (NodeFilter[] filters) 118 { 119 if (0 != filters.length) 120 mFilter.setSiblingFilter (filters[0]); 121 else 122 mFilter.setSiblingFilter (null); 123 } 124 125 public String toJavaCode (StringBuffer out, int[] context) 126 { 127 String name; 128 String ret; 129 130 if (null != mFilter.getSiblingFilter ()) 131 name = ((Filter)mFilter.getSiblingFilter ()).toJavaCode (out, context); 132 else 133 name = null; 134 ret = "filter" + context[1]++; 135 spaces (out, context[0]); 136 out.append ("HasSiblingFilter "); 137 out.append (ret); 138 out.append (" = new HasSiblingFilter ();"); 139 newline (out); 140 if (null != name) 141 { 142 spaces (out, context[0]); 143 out.append (ret); 144 out.append (".setSiblingFilter ("); 145 out.append (name); 146 out.append (");"); 147 newline (out); 148 } 149 150 return (ret); 151 } 152 153 157 public boolean accept (Node node) 158 { 159 return (mFilter.accept (node)); 160 } 161 162 166 169 public void actionPerformed (ActionEvent event) 170 { 171 } 172 } 173 | Popular Tags |