作業部屋の使い方を試しています。
クラスSearchData内で複数データ保持するように変更
| @@ -1,114 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2014 kgto. | |
| 3 | - * | |
| 4 | - * This library is free software; you can redistribute it and/or | |
| 5 | - * modify it under the terms of the GNU Lesser General Public | |
| 6 | - * License as published by the Free Software Foundation; either | |
| 7 | - * version 2.1 of the License, or (at your option) any later version. | |
| 8 | - * | |
| 9 | - * This library is distributed in the hope that it will be useful, | |
| 10 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | - * Lesser General Public License for more details. | |
| 13 | - * | |
| 14 | - * You should have received a copy of the GNU Lesser General Public | |
| 15 | - * License along with this library; if not, write to the Free Software | |
| 16 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
| 17 | - * MA 02110-1301 USA | |
| 18 | - */ | |
| 19 | -package core.test1; | |
| 20 | - | |
| 21 | -import webScraping.core.DebugProcess; | |
| 22 | -import javax.swing.text.MutableAttributeSet; | |
| 23 | -import javax.swing.text.html.HTML; | |
| 24 | -import org.junit.AfterClass; | |
| 25 | -import org.junit.BeforeClass; | |
| 26 | -import org.junit.Test; | |
| 27 | -import static org.junit.Assert.*; | |
| 28 | - | |
| 29 | -import org.junit.AfterClass; | |
| 30 | -import org.junit.BeforeClass; | |
| 31 | -import org.junit.Test; | |
| 32 | -import static org.junit.Assert.*; | |
| 33 | - | |
| 34 | -/** | |
| 35 | - * | |
| 36 | - * @author kgto | |
| 37 | - */ | |
| 38 | - | |
| 39 | - | |
| 40 | -public class DebugProcessTest { | |
| 41 | - | |
| 42 | - public DebugProcessTest() { | |
| 43 | - } | |
| 44 | - | |
| 45 | - @BeforeClass | |
| 46 | - public static void setUpClass() { | |
| 47 | - } | |
| 48 | - | |
| 49 | - @AfterClass | |
| 50 | - public static void tearDownClass() { | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Test of debuglog_set method, of class DebugProcess. | |
| 55 | - */ | |
| 56 | - @Test | |
| 57 | - public void testDebuglog_set() { | |
| 58 | - System.out.println("debuglog_set"); | |
| 59 | - DebugProcess.debuglog_set(); | |
| 60 | - // TODO review the generated test code and remove the default call to fail. | |
| 61 | - fail("The test case is a prototype."); | |
| 62 | - } | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * Test of debuglog_unset method, of class DebugProcess. | |
| 66 | - */ | |
| 67 | - @Test | |
| 68 | - public void testDebuglog_unset() { | |
| 69 | - System.out.println("debuglog_unset"); | |
| 70 | - DebugProcess.debuglog_unset(); | |
| 71 | - // TODO review the generated test code and remove the default call to fail. | |
| 72 | - fail("The test case is a prototype."); | |
| 73 | - } | |
| 74 | - | |
| 75 | - /** | |
| 76 | - * Test of htmlinfo method, of class DebugProcess. | |
| 77 | - */ | |
| 78 | - @Test | |
| 79 | - public void testHtmlinfo_4args() { | |
| 80 | - System.out.println("htmlinfo"); | |
| 81 | - HTML.Tag tag = null; | |
| 82 | - MutableAttributeSet attr = null; | |
| 83 | - String methodname = ""; | |
| 84 | - int count = 0; | |
| 85 | - DebugProcess.htmlinfo(tag, attr, methodname, count); | |
| 86 | - // TODO review the generated test code and remove the default call to fail. | |
| 87 | - fail("The test case is a prototype."); | |
| 88 | - } | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * Test of htmlinfo method, of class DebugProcess. | |
| 92 | - */ | |
| 93 | - @Test | |
| 94 | - public void testHtmlinfo_String() { | |
| 95 | - System.out.println("htmlinfo"); | |
| 96 | - String str = ""; | |
| 97 | - DebugProcess.htmlinfo(str); | |
| 98 | - // TODO review the generated test code and remove the default call to fail. | |
| 99 | - fail("The test case is a prototype."); | |
| 100 | - } | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * Test of htmlinfo method, of class DebugProcess. | |
| 104 | - */ | |
| 105 | - @Test | |
| 106 | - public void testHtmlinfo_charArr() { | |
| 107 | - System.out.println("htmlinfo"); | |
| 108 | - char[] data = null; | |
| 109 | - DebugProcess.htmlinfo(data); | |
| 110 | - // TODO review the generated test code and remove the default call to fail. | |
| 111 | - fail("The test case is a prototype."); | |
| 112 | - } | |
| 113 | - | |
| 114 | -} |
| @@ -0,0 +1,46 @@ | ||
| 1 | + | |
| 2 | +package utility.test1; | |
| 3 | + | |
| 4 | +import webScraping.utility.SearchDataRW; | |
| 5 | +import java.io.File; | |
| 6 | +import webScraping.core.SearchData; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * ファイル読込みテスト | |
| 10 | + * @author kgto | |
| 11 | + */ | |
| 12 | +public class SearchDataRWT02 { | |
| 13 | + SearchDataRW sio = new SearchDataRW(); | |
| 14 | + | |
| 15 | + File file = new File("test1.xml"); | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * @param args the command line arguments | |
| 19 | + */ | |
| 20 | + public static void main(String[] args) { | |
| 21 | + SearchDataRWT02 test01 = new SearchDataRWT02(); | |
| 22 | + test01.load01(); | |
| 23 | + } | |
| 24 | + | |
| 25 | + void SearchDataRWT01() { | |
| 26 | + } | |
| 27 | + | |
| 28 | + void load01() { | |
| 29 | + char spchar = '\t'; | |
| 30 | + | |
| 31 | + sio.load(file); | |
| 32 | + for(int i = 0; i < SearchData.size(); i++) { | |
| 33 | + SearchData sdat = SearchData.get(i); | |
| 34 | + | |
| 35 | + StringBuilder sbuf = new StringBuilder(); | |
| 36 | + sbuf.append(sdat.getitem()).append(spchar); | |
| 37 | + sbuf.append(sdat.getHtmltag()).append(spchar); | |
| 38 | + sbuf.append(sdat.getHtmlid()).append(spchar); | |
| 39 | + sbuf.append(sdat.getHtmlclass()).append(spchar); | |
| 40 | + sbuf.append(sdat.getaround()).append(spchar); | |
| 41 | + sbuf.append(sdat.getregexp()).append(spchar); | |
| 42 | + System.out.println(sbuf.toString()); | |
| 43 | + } | |
| 44 | + } | |
| 45 | + | |
| 46 | +} |
| @@ -64,7 +64,7 @@ | ||
| 64 | 64 | private final String splitchar = "\t"; |
| 65 | 65 | |
| 66 | 66 | private String UrlAdress; |
| 67 | - private ArrayList slist; | |
| 67 | + private ArrayList<SearchData> slist = new ArrayList<>(); | |
| 68 | 68 | |
| 69 | 69 | public SearchDataRW() { |
| 70 | 70 | try { |
| @@ -114,8 +114,8 @@ | ||
| 114 | 114 | //loadXml(file); |
| 115 | 115 | |
| 116 | 116 | read(file); |
| 117 | - UrlAdress = loadUrl(); | |
| 118 | - slist = loadSearchList(); | |
| 117 | + loadUrl(); | |
| 118 | + loadSearchList(); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /* ---------------------------------------------------------------------- */ |
| @@ -342,18 +342,15 @@ | ||
| 342 | 342 | |
| 343 | 343 | /* ---------------------------------------------------------------------- */ |
| 344 | 344 | |
| 345 | - String loadUrl() { | |
| 346 | - String urladdress; | |
| 347 | - | |
| 345 | + void loadUrl() { | |
| 348 | 346 | NodeList nodelist = root.getElementsByTagName("url"); |
| 349 | 347 | Node node = nodelist.item(0); |
| 350 | - urladdress = node.getFirstChild().getNodeValue(); | |
| 351 | - | |
| 352 | - return urladdress; | |
| 348 | + UrlAdress = node.getFirstChild().getNodeValue(); | |
| 353 | 349 | } |
| 354 | 350 | |
| 355 | - public ArrayList<SearchData> loadSearchList() { | |
| 356 | - ArrayList<SearchData> sdatlst = new ArrayList<>(); | |
| 351 | + public void loadSearchList() { | |
| 352 | + slist.clear(); | |
| 353 | + SearchData.clear(); | |
| 357 | 354 | |
| 358 | 355 | NodeList nodelist = root.getElementsByTagName("searchlist"); |
| 359 | 356 | for(int i = 0; i < nodelist.getLength(); i++) { |
| @@ -361,22 +358,13 @@ | ||
| 361 | 358 | |
| 362 | 359 | boolean sdatflg = false; |
| 363 | 360 | SearchData sdat = new SearchData(); |
| 364 | - | |
| 365 | - //NodeList childnodelist = childnode.getChildNodes(); | |
| 366 | - //for(int j = 0; j < childnodelist.getLength(); j++) { | |
| 367 | - // Node child = childnodelist.item(j); | |
| 368 | - | |
| 369 | - for (Node child = childnode.getFirstChild(); | |
| 370 | - child != null; child = child.getNextSibling()) { | |
| 371 | - | |
| 361 | + for (Node child = childnode.getFirstChild(); child != null; child = child.getNextSibling()) { | |
| 372 | 362 | if(child.getNodeType() == Node.ELEMENT_NODE) { |
| 373 | - | |
| 374 | 363 | String tag = child.getNodeName(); |
| 375 | 364 | String rtn = ""; |
| 376 | 365 | if(child.getFirstChild() != null) { |
| 377 | 366 | rtn = child.getFirstChild().getNodeValue(); |
| 378 | 367 | } |
| 379 | - | |
| 380 | 368 | switch (tag) { |
| 381 | 369 | case "item" : |
| 382 | 370 | sdat.setitem(rtn); |
| @@ -405,9 +393,9 @@ | ||
| 405 | 393 | } |
| 406 | 394 | } |
| 407 | 395 | } |
| 408 | - if(sdatflg) sdatlst.add(sdat); | |
| 396 | + if(sdatflg) slist.add(sdat); | |
| 397 | + if(sdatflg) SearchData.add(sdat); | |
| 409 | 398 | } |
| 410 | - return sdatlst; | |
| 411 | 399 | } |
| 412 | 400 | |
| 413 | 401 | public String loadMsg404() { |
| @@ -28,7 +28,6 @@ | ||
| 28 | 28 | import java.io.IOException; |
| 29 | 29 | import java.net.URI; |
| 30 | 30 | import java.net.URISyntaxException; |
| 31 | -import java.util.*; | |
| 32 | 31 | import java.util.logging.Level; |
| 33 | 32 | import java.util.logging.Logger; |
| 34 | 33 | import javax.swing.JFileChooser; |
| @@ -35,7 +34,6 @@ | ||
| 35 | 34 | import javax.swing.filechooser.FileFilter; |
| 36 | 35 | import javax.swing.filechooser.FileNameExtensionFilter; |
| 37 | 36 | import javax.swing.table.DefaultTableModel; |
| 38 | -import org.jdesktop.observablecollections.ObservableCollections; | |
| 39 | 37 | |
| 40 | 38 | /** |
| 41 | 39 | * HTMLページ上の特定の項目を検索し、その項目内容の値を取得する. |
| @@ -44,16 +42,13 @@ | ||
| 44 | 42 | public class HtmlSearch extends javax.swing.JFrame { |
| 45 | 43 | private final SearchDataRW sio = new SearchDataRW(); |
| 46 | 44 | |
| 47 | - private ArrayList slist = new ArrayList(); | |
| 48 | - private List serachDataList = ObservableCollections.observableList(slist); | |
| 45 | + SearchDataTableModel sdatatblmodel; | |
| 49 | 46 | |
| 50 | - SearchDataTableModel model; | |
| 51 | - | |
| 52 | 47 | /** |
| 53 | 48 | * Creates new form Frame1 |
| 54 | 49 | */ |
| 55 | 50 | public HtmlSearch() { |
| 56 | - model = new SearchDataTableModel(); | |
| 51 | + sdatatblmodel = new SearchDataTableModel(); | |
| 57 | 52 | |
| 58 | 53 | initComponents(); |
| 59 | 54 |
| @@ -70,14 +65,6 @@ | ||
| 70 | 65 | |
| 71 | 66 | } |
| 72 | 67 | |
| 73 | - public List getSerachDataList() { | |
| 74 | - return this.serachDataList; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public void setSerachDataList(List serachDataList) { | |
| 78 | - this.serachDataList = serachDataList; | |
| 79 | - } | |
| 80 | - | |
| 81 | 68 | /** |
| 82 | 69 | * This method is called from within the constructor to initialize the form. |
| 83 | 70 | * WARNING: Do NOT modify this code. The content of this method is always |
| @@ -86,7 +73,6 @@ | ||
| 86 | 73 | @SuppressWarnings("unchecked") |
| 87 | 74 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
| 88 | 75 | private void initComponents() { |
| 89 | - bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); | |
| 90 | 76 | |
| 91 | 77 | jFileChooser1 = new javax.swing.JFileChooser(); |
| 92 | 78 | jRadioButton1 = new javax.swing.JRadioButton(); |
| @@ -135,31 +121,9 @@ | ||
| 135 | 121 | |
| 136 | 122 | jPanelTab1.setBorder(javax.swing.BorderFactory.createTitledBorder("検索情報")); |
| 137 | 123 | |
| 124 | + jTable1.setModel(sdatatblmodel); | |
| 138 | 125 | jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
| 139 | 126 | jTable1.getTableHeader().setReorderingAllowed(false); |
| 140 | - | |
| 141 | - org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${serachDataList}"); | |
| 142 | - org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, jTable1); | |
| 143 | - org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${item}")); | |
| 144 | - columnBinding.setColumnName("項目名"); | |
| 145 | - columnBinding.setColumnClass(String.class); | |
| 146 | - columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${htmltag}")); | |
| 147 | - columnBinding.setColumnName("タグ"); | |
| 148 | - columnBinding.setColumnClass(String.class); | |
| 149 | - columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${htmlid}")); | |
| 150 | - columnBinding.setColumnName("ID"); | |
| 151 | - columnBinding.setColumnClass(String.class); | |
| 152 | - columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${htmlclass}")); | |
| 153 | - columnBinding.setColumnName("クラス"); | |
| 154 | - columnBinding.setColumnClass(String.class); | |
| 155 | - columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${around}")); | |
| 156 | - columnBinding.setColumnName("位置"); | |
| 157 | - columnBinding.setColumnClass(String.class); | |
| 158 | - columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${regexp}")); | |
| 159 | - columnBinding.setColumnName("抽出条件"); | |
| 160 | - columnBinding.setColumnClass(String.class); | |
| 161 | - bindingGroup.addBinding(jTableBinding); | |
| 162 | - jTableBinding.bind(); | |
| 163 | 127 | jScrollPane1.setViewportView(jTable1); |
| 164 | 128 | |
| 165 | 129 | jBtnRowIns.setText("行挿入"); |
| @@ -343,19 +307,16 @@ | ||
| 343 | 307 | .addContainerGap()) |
| 344 | 308 | ); |
| 345 | 309 | |
| 346 | - bindingGroup.bind(); | |
| 347 | - | |
| 348 | 310 | pack(); |
| 349 | 311 | }// </editor-fold>//GEN-END:initComponents |
| 350 | 312 | |
| 351 | 313 | private void jBtnRowInsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnRowInsActionPerformed |
| 352 | 314 | int SelectedRow = jTable1.getSelectedRow(); |
| 353 | - SearchData sdat = new SearchData(); | |
| 354 | - | |
| 315 | + SearchData sdata = new SearchData(); | |
| 355 | 316 | if(SelectedRow >= 0) { |
| 356 | - this.serachDataList.add(SelectedRow, sdat); | |
| 317 | + sdatatblmodel.insertRow(SelectedRow, sdata); | |
| 357 | 318 | } else { |
| 358 | - this.serachDataList.add(sdat); | |
| 319 | + sdatatblmodel.addRow(sdata); | |
| 359 | 320 | } |
| 360 | 321 | }//GEN-LAST:event_jBtnRowInsActionPerformed |
| 361 | 322 |
| @@ -362,7 +323,7 @@ | ||
| 362 | 323 | private void jBtnRowDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnRowDelActionPerformed |
| 363 | 324 | int SelectedRow = jTable1.getSelectedRow(); |
| 364 | 325 | if(!(SelectedRow < 0)) { |
| 365 | - this.serachDataList.remove(SelectedRow); | |
| 326 | + sdatatblmodel.removeRow(SelectedRow); | |
| 366 | 327 | } |
| 367 | 328 | }//GEN-LAST:event_jBtnRowDelActionPerformed |
| 368 | 329 |
| @@ -371,10 +332,13 @@ | ||
| 371 | 332 | int selected = jFileChooser1.showOpenDialog(this); |
| 372 | 333 | if (selected == JFileChooser.APPROVE_OPTION) { |
| 373 | 334 | File file = jFileChooser1.getSelectedFile(); |
| 374 | - serachDataList.clear(); | |
| 375 | 335 | sio.load(file); |
| 376 | 336 | jTxtUrl.setText(sio.geturl()); |
| 377 | - serachDataList.addAll(sio.getslist()); | |
| 337 | + sdatatblmodel.setRowCount(0); | |
| 338 | + for(int i = 0; i < SearchData.size(); i++) { | |
| 339 | + SearchData sdata = SearchData.get(i); | |
| 340 | + sdatatblmodel.addRow(sdata); | |
| 341 | + } | |
| 378 | 342 | } |
| 379 | 343 | }//GEN-LAST:event_jMenuLoadActionPerformed |
| 380 | 344 |
| @@ -384,7 +348,12 @@ | ||
| 384 | 348 | if (selected == JFileChooser.APPROVE_OPTION) { |
| 385 | 349 | File file = jFileChooser1.getSelectedFile(); |
| 386 | 350 | sio.seturl(jTxtUrl.getText()); |
| 387 | - sio.setslist(slist); | |
| 351 | + | |
| 352 | + SearchData.clear(); | |
| 353 | + for(int row = 0; row < sdatatblmodel.getRowCount(); row++) { | |
| 354 | + SearchData sdata = sdatatblmodel.getSearchData(row); | |
| 355 | + SearchData.add(sdata); | |
| 356 | + } | |
| 388 | 357 | sio.save(file); |
| 389 | 358 | } |
| 390 | 359 | }//GEN-LAST:event_jMenuSaveActionPerformed |
| @@ -392,9 +361,8 @@ | ||
| 392 | 361 | private void jBtnRowCpyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnRowCpyActionPerformed |
| 393 | 362 | int SelectedRow = jTable1.getSelectedRow(); |
| 394 | 363 | if(SelectedRow >= 0) { |
| 395 | - SearchData SelectData = (SearchData)slist.get(SelectedRow); | |
| 396 | - SearchData Cpydata = new SearchData(SelectData); | |
| 397 | - this.serachDataList.add(SelectedRow, Cpydata); | |
| 364 | + SearchData sdata = sdatatblmodel.getSearchData(SelectedRow); | |
| 365 | + sdatatblmodel.insertRow(SelectedRow, sdata); | |
| 398 | 366 | } |
| 399 | 367 | }//GEN-LAST:event_jBtnRowCpyActionPerformed |
| 400 | 368 |
| @@ -441,22 +409,16 @@ | ||
| 441 | 409 | } |
| 442 | 410 | |
| 443 | 411 | // 検索結果 |
| 444 | - for (Object slist1 : slist) { | |
| 445 | - SearchData sdata = (SearchData)slist1; | |
| 412 | + for(int row = 0; row < sdatatblmodel.getRowCount(); row++) { | |
| 413 | + SearchData sdata = sdatatblmodel.getSearchData(row); | |
| 446 | 414 | String ans = sdata.getitem(); |
| 447 | 415 | String rtn = par.search(sdata); |
| 448 | - jTxtRtn.append(ans + "\t" + rtn + "\r\n"); | |
| 416 | + jTxtRtn.append(ans + "\t" + rtn + "\n"); | |
| 449 | 417 | } |
| 418 | + | |
| 450 | 419 | jTxtRtn.setCaretPosition(0); |
| 451 | 420 | } |
| 452 | 421 | |
| 453 | - private void list2model() { | |
| 454 | - model.setRowCount(0); | |
| 455 | - for(int i = 0; i < SearchData.size(); i++) { | |
| 456 | - model.addRow(SearchData.getObjData(i)); | |
| 457 | - } | |
| 458 | - } | |
| 459 | - | |
| 460 | 422 | /** |
| 461 | 423 | * @param args the command line arguments |
| 462 | 424 | */ |
| @@ -518,25 +480,87 @@ | ||
| 518 | 480 | private javax.swing.JTextArea jTxtLabel; |
| 519 | 481 | private javax.swing.JTextArea jTxtRtn; |
| 520 | 482 | private javax.swing.JTextField jTxtUrl; |
| 521 | - private org.jdesktop.beansbinding.BindingGroup bindingGroup; | |
| 522 | 483 | // End of variables declaration//GEN-END:variables |
| 523 | 484 | } |
| 524 | 485 | |
| 525 | 486 | class SearchDataTableModel extends DefaultTableModel { |
| 487 | + /* ---------------------------------------------------------------------- * | |
| 488 | + * データ属性 | |
| 489 | + * ---------------------------------------------------------------------- */ | |
| 490 | + public String[] columnName = { | |
| 491 | + /* 0 */ "項目名", | |
| 492 | + /* 1 */ "タグ", | |
| 493 | + /* 2 */ "ID", | |
| 494 | + /* 3 */ "クラス", | |
| 495 | + /* 4 */ "位置", | |
| 496 | + /* 5 */ "抽出条件" | |
| 497 | + }; | |
| 498 | + | |
| 499 | + public Class[] columnClass = { | |
| 500 | + /* 0 */ String.class, | |
| 501 | + /* 1 */ String.class, | |
| 502 | + /* 2 */ String.class, | |
| 503 | + /* 3 */ String.class, | |
| 504 | + /* 4 */ String.class, | |
| 505 | + /* 5 */ String.class | |
| 506 | + }; | |
| 526 | 507 | |
| 508 | + int column_item = 0; | |
| 509 | + int column_htmltag = 1; | |
| 510 | + int column_htmlid = 2; | |
| 511 | + int column_htmlclass = 3; | |
| 512 | + int column_around = 4; | |
| 513 | + int column_regexp = 5; | |
| 514 | + | |
| 515 | + /* ---------------------------------------------------------------------- * | |
| 516 | + * 処理 | |
| 517 | + * ---------------------------------------------------------------------- */ | |
| 527 | 518 | @Override |
| 528 | 519 | public String getColumnName(int modelIndex) { |
| 529 | - return SearchData.columnName[modelIndex]; | |
| 520 | + return columnName[modelIndex]; | |
| 530 | 521 | } |
| 531 | 522 | |
| 532 | 523 | @Override |
| 533 | 524 | public Class<?> getColumnClass(int modelIndex) { |
| 534 | - return SearchData.columnClass[modelIndex]; | |
| 525 | + return columnClass[modelIndex]; | |
| 535 | 526 | } |
| 536 | 527 | |
| 537 | 528 | @Override |
| 538 | 529 | public int getColumnCount() { |
| 539 | - return SearchData.columnName.length; | |
| 530 | + return columnName.length; | |
| 540 | 531 | } |
| 532 | + | |
| 533 | + /* ---------------------------------------------------------------------- */ | |
| 541 | 534 | |
| 535 | + public SearchData getSearchData(int row) { | |
| 536 | + SearchData sdata = new SearchData(); | |
| 537 | + sdata.setitem(String.valueOf(getValueAt(row, column_item))); | |
| 538 | + sdata.setHtmltag(String.valueOf(getValueAt(row, column_htmltag))); | |
| 539 | + sdata.setHtmlid(String.valueOf(getValueAt(row, column_htmlid))); | |
| 540 | + sdata.setHtmlclass(String.valueOf(getValueAt(row, column_htmlclass))); | |
| 541 | + sdata.setaround(String.valueOf(getValueAt(row, column_around))); | |
| 542 | + sdata.setregexp(String.valueOf(getValueAt(row, column_regexp))); | |
| 543 | + return sdata; | |
| 544 | + } | |
| 545 | + | |
| 546 | + public void addRow(SearchData sdata) { | |
| 547 | + addRow(getObjdata(sdata)); | |
| 548 | + } | |
| 549 | + | |
| 550 | + public void insertRow(int row, SearchData sdata) { | |
| 551 | + insertRow(row, getObjdata(sdata)); | |
| 552 | + } | |
| 553 | + | |
| 554 | + private Object[] getObjdata(SearchData sdata) { | |
| 555 | + Object[] obj = new Object[] { | |
| 556 | + sdata.getitem(), | |
| 557 | + sdata.getHtmltag(), | |
| 558 | + sdata.getHtmlid(), | |
| 559 | + sdata.getHtmlclass(), | |
| 560 | + sdata.getaround(), | |
| 561 | + sdata.getregexp() | |
| 562 | + }; | |
| 563 | + return obj; | |
| 564 | + } | |
| 565 | + | |
| 542 | 566 | } |
| \ No newline at end of file |
| @@ -42,28 +42,6 @@ | ||
| 42 | 42 | /* ---------------------------------------------------------------------- * |
| 43 | 43 | * static 処理 |
| 44 | 44 | * ---------------------------------------------------------------------- */ |
| 45 | - /** | |
| 46 | - * データ属性 情報. | |
| 47 | - */ | |
| 48 | - public static String[] columnName = { | |
| 49 | - /* 0 */ "項目名", | |
| 50 | - /* 1 */ "タグ", | |
| 51 | - /* 2 */ "ID", | |
| 52 | - /* 3 */ "クラス", | |
| 53 | - /* 4 */ "位置", | |
| 54 | - /* 5 */ "抽出条件" | |
| 55 | - }; | |
| 56 | - | |
| 57 | - public static Class[] columnClass = { | |
| 58 | - /* 0 */ String.class, | |
| 59 | - /* 1 */ String.class, | |
| 60 | - /* 2 */ String.class, | |
| 61 | - /* 3 */ String.class, | |
| 62 | - /* 4 */ String.class, | |
| 63 | - /* 5 */ String.class | |
| 64 | - }; | |
| 65 | - | |
| 66 | - /* ---------------------------------------------------------------------- */ | |
| 67 | 45 | private static ArrayList<SearchData> slist = new ArrayList<>(); |
| 68 | 46 | |
| 69 | 47 | public static void addSearchData( |
| @@ -88,19 +66,6 @@ | ||
| 88 | 66 | return slist.get(i); |
| 89 | 67 | } |
| 90 | 68 | |
| 91 | - public static Object[] getObjData(int i) { | |
| 92 | - SearchData sdat = get(i); | |
| 93 | - Object[] obj = new Object[] { | |
| 94 | - sdat.getitem(), | |
| 95 | - sdat.getHtmltag(), | |
| 96 | - sdat.getHtmlid(), | |
| 97 | - sdat.getHtmlclass(), | |
| 98 | - sdat.getaround(), | |
| 99 | - sdat.getregexp() | |
| 100 | - }; | |
| 101 | - return obj; | |
| 102 | - } | |
| 103 | - | |
| 104 | 69 | public static int size() { |
| 105 | 70 | return slist.size(); |
| 106 | 71 | } |
| @@ -182,7 +147,7 @@ | ||
| 182 | 147 | public String getregexp() { |
| 183 | 148 | return regexp; |
| 184 | 149 | } |
| 185 | - | |
| 150 | + | |
| 186 | 151 | /* ---------------------------------------------------------------------- * |
| 187 | 152 | * メソッド |
| 188 | 153 | * ---------------------------------------------------------------------- */ |