1 27 package org.htmlparser.tags; 28 29 import org.htmlparser.NodeFilter; 30 import org.htmlparser.filters.AndFilter; 31 import org.htmlparser.filters.IsEqualFilter; 32 import org.htmlparser.filters.NodeClassFilter; 33 import org.htmlparser.filters.HasParentFilter; 34 import org.htmlparser.filters.NotFilter; 35 import org.htmlparser.filters.OrFilter; 36 import org.htmlparser.util.NodeList; 37 38 41 public class TableRow extends CompositeTag 42 { 43 46 private static final String [] mIds = new String [] {"TR"}; 47 48 51 private static final String [] mEndTagEnders = new String [] {"TABLE"}; 52 53 56 public TableRow () 57 { 58 } 59 60 64 public String [] getIds () 65 { 66 return (mIds); 67 } 68 69 73 public String [] getEnders () 74 { 75 return (mIds); 76 } 77 78 82 public String [] getEndTagEnders () 83 { 84 return (mEndTagEnders); 85 } 86 87 90 public TableColumn[] getColumns () 91 { 92 NodeList kids; 93 NodeClassFilter cls; 94 HasParentFilter recursion; 95 NodeFilter filter; 96 TableColumn[] ret; 97 98 kids = getChildren (); 99 if (null != kids) 100 { 101 cls = new NodeClassFilter (TableRow.class); 102 recursion = new HasParentFilter (null); 103 filter = new OrFilter ( 104 new AndFilter ( 105 cls, 106 new IsEqualFilter (this)), 107 new AndFilter ( new NotFilter (cls), recursion)); 110 recursion.setParentFilter (filter); 111 kids = kids.extractAllNodesThatMatch ( 112 new AndFilter ( 114 new NodeClassFilter (TableColumn.class), 115 filter), true); 116 ret = new TableColumn[kids.size ()]; 117 kids.copyToNodeArray (ret); 118 } 119 else 120 ret = new TableColumn[0]; 121 122 return (ret); 123 } 124 125 128 public int getColumnCount () 129 { 130 return (getColumns ().length); 131 } 132 133 137 public TableHeader[] getHeaders () 138 { 139 NodeList kids; 140 NodeClassFilter cls; 141 HasParentFilter recursion; 142 NodeFilter filter; 143 TableHeader[] ret; 144 145 kids = getChildren (); 146 if (null != kids) 147 { 148 cls = new NodeClassFilter (TableRow.class); 149 recursion = new HasParentFilter (null); 150 filter = new OrFilter ( 151 new AndFilter ( 152 cls, 153 new IsEqualFilter (this)), 154 new AndFilter ( new NotFilter (cls), recursion)); 157 recursion.setParentFilter (filter); 158 kids = kids.extractAllNodesThatMatch ( 159 new AndFilter ( 161 new NodeClassFilter (TableHeader.class), 162 filter), true); 163 ret = new TableHeader[kids.size ()]; 164 kids.copyToNodeArray (ret); 165 } 166 else 167 ret = new TableHeader[0]; 168 169 return (ret); 170 } 171 172 176 public int getHeaderCount () 177 { 178 return (getHeaders ().length); 179 } 180 181 185 public boolean hasHeader () 186 { 187 return (0 != getHeaderCount ()); 188 } 189 } 190 | Popular Tags |