Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers AndFilterWr
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2005-02-13 20:43:21
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12396/src/org/htmlparser/parserapplications/filterbuilder/wrappers Added Files: AndFilterWrapper.java OrFilterWrapper.java NotFilterWrapper.java HasAttributeFilterWrapper.java NodeClassFilterWrapper.java HasParentFilterWrapper.java TagNameFilterWrapper.java RegexFilterWrapper.java StringFilterWrapper.java HasChildFilterWrapper.java HasSiblingFilterWrapper.java Log Message: FilterBuilder --- NEW FILE: HasParentFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/HasParentFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.HasParentFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.parserapplications.filterbuilder.SubFilterList; /** * Wrapper for HasParentFilters. */ public class HasParentFilterWrapper extends Filter implements ActionListener { /** * The underlying filter. */ protected HasParentFilter mFilter; /** * The check box for recursion. */ protected JCheckBox mRecursive; /** * The drop target container. */ protected SubFilterList mContainer; /** * Create a wrapper over a new HasParentFilter. */ public HasParentFilterWrapper () { mFilter = new HasParentFilter (); // add the recursive flag mRecursive = new JCheckBox ("Recursive"); add (mRecursive); mRecursive.addActionListener (this); mRecursive.setSelected (mFilter.getRecursive ()); // add the subfilter container mContainer = new SubFilterList (this, "Parent Filter", 1); add (mContainer); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Has Parent"); } public String getIconSpec () { return ("images/HasParentFilter.gif"); } public NodeFilter getNodeFilter () { NodeFilter filter; HasParentFilter ret; ret = new HasParentFilter (); ret.setRecursive (mFilter.getRecursive ()); filter = mFilter.getParentFilter (); if (null != filter) ret.setParentFilter (((Filter)filter).getNodeFilter ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (HasParentFilter)filter; mRecursive.setSelected (mFilter.getRecursive ()); } public NodeFilter[] getSubNodeFilters () { NodeFilter filter; NodeFilter[] ret; filter = mFilter.getParentFilter (); if (null != filter) ret = new NodeFilter[] { filter }; else ret = new NodeFilter[0]; return (ret); } public void setSubNodeFilters (NodeFilter[] filters) { if (0 != filters.length) mFilter.setParentFilter (filters[0]); else mFilter.setParentFilter (null); } public String toJavaCode (StringBuffer out, int[] context) { String name; String ret; if (null != mFilter.getParentFilter ()) name = ((Filter)mFilter.getParentFilter ()).toJavaCode (out, context); else name = null; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("HasParentFilter "); out.append (ret); out.append (" = new HasParentFilter ();"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setRecursive ("); out.append (mFilter.getRecursive () ? "true" : "false"); out.append (");"); newline (out); if (null != name) { spaces (out, context[0]); out.append (ret); out.append (".setParentFilter ("); out.append (name); out.append (");"); newline (out); } return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs on the check box. */ public void actionPerformed (ActionEvent event) { Object source; boolean recursive; source = event.getSource (); if (source == mRecursive) { recursive = mRecursive.isSelected (); mFilter.setRecursive (recursive); } } } --- NEW FILE: NotFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/NotFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.NotFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.parserapplications.filterbuilder.SubFilterList; /** * Wrapper for NotFilters. */ public class NotFilterWrapper extends Filter { /** * The drop target container. */ protected SubFilterList mContainer; /** * The underlying filter. */ protected NotFilter mFilter; /** * Create a wrapper over a new NotFilter. */ public NotFilterWrapper () { mFilter = new NotFilter (); // add the subfilter container mContainer = new SubFilterList (this, "Predicate", 1); add (mContainer); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Not"); } public String getIconSpec () { return ("images/NotFilter.gif"); } public NodeFilter getNodeFilter () { NodeFilter predicate; NotFilter ret; ret = new NotFilter (); predicate = mFilter.getPredicate (); if (null != predicate) ret.setPredicate (((Filter)predicate).getNodeFilter ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (NotFilter)filter; } public NodeFilter[] getSubNodeFilters () { NodeFilter predicate; NodeFilter[] ret; predicate = mFilter.getPredicate (); if (null != predicate) ret = new NodeFilter[] { predicate }; else ret = new NodeFilter[0]; return (ret); } public void setSubNodeFilters (NodeFilter[] filters) { if (0 != filters.length) mFilter.setPredicate (filters[0]); else mFilter.setPredicate (null); } public String toJavaCode (StringBuffer out, int[] context) { String name; String ret; if (null != mFilter.getPredicate ()) name = ((Filter)mFilter.getPredicate ()).toJavaCode (out, context); else name = null; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("NotFilter "); out.append (ret); out.append (" = new NotFilter ();"); newline (out); if (null != name) { spaces (out, context[0]); out.append (ret); out.append (".setPredicate ("); out.append (name); out.append (");"); newline (out); } return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } } --- NEW FILE: StringFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/StringFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Locale; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JTextArea; import javax.swing.border.BevelBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.StringFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; /** * Wrapper for StringFilters. */ public class StringFilterWrapper extends Filter implements ActionListener, DocumentListener, Runnable { /** * The underlying filter. */ protected StringFilter mFilter; /** * Text to check for. */ protected JTextArea mPattern; /** * The check box for case sensitivity. */ protected JCheckBox mCaseSensitivity; /** * Combo box for locale. */ protected JComboBox mLocale; /** * Cached locales. */ protected static Locale[] mLocales = null; /** * Create a wrapper over a new StringFilter. */ public StringFilterWrapper () { Thread thread; mFilter = new StringFilter (); mFilter.setCaseSensitive (true); // add the text pattern mPattern = new JTextArea (2, 20); mPattern.setBorder (new BevelBorder (BevelBorder.LOWERED)); add (mPattern); mPattern.getDocument ().addDocumentListener (this); mPattern.setText (mFilter.getPattern ()); // add the case sensitivity flag mCaseSensitivity = new JCheckBox ("Case Sensitive"); add (mCaseSensitivity); mCaseSensitivity.addActionListener (this); mCaseSensitivity.setSelected (mFilter.getCaseSensitive ()); // add the locales choice mLocale = new JComboBox (); synchronized (mLocale) { mLocale.addItem (mFilter.getLocale ().getDisplayName ()); thread = new Thread (this); thread.setName ("locale_getter"); thread.setPriority (Thread.MIN_PRIORITY); thread.run (); } add (mLocale); mLocale.addActionListener (this); mLocale.setSelectedIndex (0); mLocale.setVisible (!mFilter.getCaseSensitive ()); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Nodes containing string"); } public String getIconSpec () { return ("images/StringFilter.gif"); } public NodeFilter getNodeFilter () { StringFilter ret; ret = new StringFilter (); ret.setCaseSensitive (mFilter.getCaseSensitive ()); ret.setLocale (mFilter .getLocale ()); ret.setPattern (mFilter.getPattern ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (StringFilter)filter; mPattern.setText (mFilter.getPattern ()); mCaseSensitivity.setSelected (mFilter.getCaseSensitive ()); mLocale.setVisible (!mFilter.getCaseSensitive ()); mLocale.setSelectedItem (mFilter.getLocale ().getDisplayName ()); } public NodeFilter[] getSubNodeFilters () { return (new NodeFilter[0]); } public void setSubNodeFilters (NodeFilter[] filters) { // should we complain? } public String toJavaCode (StringBuffer out, int[] context) { String ret; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("StringFilter "); out.append (ret); out.append (" = new StringFilter ();"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setCaseSensitive ("); out.append (mFilter.getCaseSensitive () ? "true" : "false"); out.append (");"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setLocale (new java.util.Locale (\""); out.append (mFilter .getLocale ().getLanguage ()); out.append ("\", \""); out.append (mFilter .getLocale ().getCountry ()); out.append ("\", \""); out.append (mFilter .getLocale ().getVariant ()); out.append ("\"));"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setPattern (\""); out.append (mFilter.getPattern ()); out.append ("\");"); newline (out); return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs on the combo box. */ public void actionPerformed (ActionEvent event) { Object source; boolean sensitive; Object[] selection; String locale; source = event.getSource (); if (source == mCaseSensitivity) { sensitive = mCaseSensitivity.isSelected (); mFilter.setCaseSensitive (sensitive); mLocale.setVisible (!sensitive); mLocale.setSelectedItem (mFilter.getLocale ().getDisplayName ()); } else if (source == mLocale) { synchronized (mLocale) { selection = mLocale.getSelectedObjects (); if ((null != selection) && (0 != selection.length)) { locale = (String)selection[0]; for (int i = 0; i < mLocales.length; i++) if (locale.equals (mLocales[i].getDisplayName ())) mFilter.setLocale (mLocales[i]); } } } } // // Runnable interface // public void run() { String locale; synchronized (mLocale) { mLocales = Locale.getAvailableLocales (); locale = mFilter.getLocale ().getDisplayName (); for (int i = 0; i < mLocales.length; i++) if (!locale.equals (mLocales[i].getDisplayName ())) mLocale.addItem (mLocales[i].getDisplayName ()); mLocale.invalidate (); } } // // DocumentListener interface // public void insertUpdate (DocumentEvent e) { Document doc; doc = e.getDocument (); try { mFilter.setPattern (doc.getText (0, doc.getLength ())); } catch (BadLocationException ble) { ble.printStackTrace (); } } public void removeUpdate (DocumentEvent e) { Document doc; doc = e.getDocument (); try { mFilter.setPattern (doc.getText (0, doc.getLength ())); } catch (BadLocationException ble) { ble.printStackTrace (); } } public void changedUpdate (DocumentEvent e) { // plain text components don't fire these events } } --- NEW FILE: HasChildFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/HasChildFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.HasChildFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.parserapplications.filterbuilder.SubFilterList; /** * Wrapper for HasChildFilters. */ public class HasChildFilterWrapper extends Filter implements ActionListener { /** * The underlying filter. */ protected HasChildFilter mFilter; /** * The check box for recursion. */ protected JCheckBox mRecursive; /** * The drop target container. */ protected SubFilterList mContainer; /** * Create a wrapper over a new HasChildFilter. */ public HasChildFilterWrapper () { mFilter = new HasChildFilter (); // add the recursive flag mRecursive = new JCheckBox ("Recursive"); add (mRecursive); mRecursive.addActionListener (this); mRecursive.setSelected (mFilter.getRecursive ()); // add the subfilter container mContainer = new SubFilterList (this, "Child Filter", 1); add (mContainer); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Has Child"); } public String getIconSpec () { return ("images/HasChildFilter.gif"); } public NodeFilter getNodeFilter () { NodeFilter filter; HasChildFilter ret; ret = new HasChildFilter (); ret.setRecursive (mFilter.getRecursive ()); filter = mFilter.getChildFilter (); if (null != filter) ret.setChildFilter (((Filter)filter).getNodeFilter ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (HasChildFilter)filter; mRecursive.setSelected (mFilter.getRecursive ()); } public NodeFilter[] getSubNodeFilters () { NodeFilter filter; NodeFilter[] ret; filter = mFilter.getChildFilter (); if (null != filter) ret = new NodeFilter[] { filter }; else ret = new NodeFilter[0]; return (ret); } public void setSubNodeFilters (NodeFilter[] filters) { if (0 != filters.length) mFilter.setChildFilter (filters[0]); else mFilter.setChildFilter (null); } public String toJavaCode (StringBuffer out, int[] context) { String name; String ret; if (null != mFilter.getChildFilter ()) name = ((Filter)mFilter.getChildFilter ()).toJavaCode (out, context); else name = null; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("HasChildFilter "); out.append (ret); out.append (" = new HasChildFilter ();"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setRecursive ("); out.append (mFilter.getRecursive () ? "true" : "false"); out.append (");"); newline (out); if (null != name) { spaces (out, context[0]); out.append (ret); out.append (".setChildFilter ("); out.append (name); out.append (");"); newline (out); } return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs on the check box. */ public void actionPerformed (ActionEvent event) { Object source; boolean recursive; source = event.getSource (); if (source == mRecursive) { recursive = mRecursive.isSelected (); mFilter.setRecursive (recursive); } } } --- NEW FILE: AndFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/AndFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.AndFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.parserapplications.filterbuilder.SubFilterList; /** * Wrapper for AndFilters. */ public class AndFilterWrapper extends Filter { /** * The drop target container. */ protected SubFilterList mContainer; /** * The underlying filter. */ protected AndFilter mFilter; /** * Create a wrapper over a new AndFilter. */ public AndFilterWrapper () { mFilter = new AndFilter (); // add the subfilter container mContainer = new SubFilterList (this, "Predicates", 0); add (mContainer); } // // Filter overrides and concrete implementations // public String getDescription () { return ("And"); } public String getIconSpec () { return ("images/AndFilter.gif"); } public NodeFilter getNodeFilter () { NodeFilter[] predicates; NodeFilter[] temp; AndFilter ret; ret = new AndFilter (); predicates = mFilter.getPredicates (); temp = new NodeFilter[predicates.length]; for (int i = 0; i < predicates.length; i++) temp[i] = ((Filter)predicates[i]).getNodeFilter (); ret.setPredicates (temp); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (AndFilter)filter; } public NodeFilter[] getSubNodeFilters () { return (mFilter.getPredicates ()); } public void setSubNodeFilters (NodeFilter[] filters) { mFilter.setPredicates (filters); } public String toJavaCode (StringBuffer out, int[] context) { String array; NodeFilter[] predicates; String[] names; String ret; predicates = mFilter.getPredicates (); array = null; // stoopid Java compiler if (0 != predicates.length) { names = new String[predicates.length]; for (int i = 0; i < predicates.length; i++) { names[i] = ((Filter)predicates[i]).toJavaCode (out, context); } array = "array" + context[2]++; spaces (out, context[0]); out.append ("NodeFilter[] "); out.append (array); out.append (" = new NodeFilter["); out.append (predicates.length); out.append ("];"); newline (out); for (int i = 0; i < predicates.length; i++) { spaces (out, context[0]); out.append (array); out.append ("["); out.append (i); out.append ("] = "); out.append (names[i]); out.append (";"); newline (out); } } ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("AndFilter "); out.append (ret); out.append (" = new AndFilter ();"); newline (out); if (0 != predicates.length) { spaces (out, context[0]); out.append (ret); out.append (".setPredicates ("); out.append (array); out.append (");"); newline (out); } return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } } --- NEW FILE: HasSiblingFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/HasSiblingFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.HasSiblingFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.parserapplications.filterbuilder.SubFilterList; /** * Wrapper for HasSiblingFilters. */ public class HasSiblingFilterWrapper extends Filter implements ActionListener { /** * The underlying filter. */ protected HasSiblingFilter mFilter; /** * The drop target container. */ protected SubFilterList mContainer; /** * Create a wrapper over a new HasParentFilter. */ public HasSiblingFilterWrapper () { mFilter = new HasSiblingFilter (); // add the subfilter container mContainer = new SubFilterList (this, "Sibling Filter", 1); add (mContainer); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Has Sibling"); } public String getIconSpec () { return ("images/HasSiblingFilter.gif"); } public NodeFilter getNodeFilter () { NodeFilter filter; HasSiblingFilter ret; ret = new HasSiblingFilter (); filter = mFilter.getSiblingFilter (); if (null != filter) ret.setSiblingFilter (((Filter)filter).getNodeFilter ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (HasSiblingFilter)filter; } public NodeFilter[] getSubNodeFilters () { NodeFilter filter; NodeFilter[] ret; filter = mFilter.getSiblingFilter (); if (null != filter) ret = new NodeFilter[] { filter }; else ret = new NodeFilter[0]; return (ret); } public void setSubNodeFilters (NodeFilter[] filters) { if (0 != filters.length) mFilter.setSiblingFilter (filters[0]); else mFilter.setSiblingFilter (null); } public String toJavaCode (StringBuffer out, int[] context) { String name; String ret; if (null != mFilter.getSiblingFilter ()) name = ((Filter)mFilter.getSiblingFilter ()).toJavaCode (out, context); else name = null; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("HasSiblingFilter "); out.append (ret); out.append (" = new HasSiblingFilter ();"); newline (out); if (null != name) { spaces (out, context[0]); out.append (ret); out.append (".setSiblingFilter ("); out.append (name); out.append (");"); newline (out); } return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs. */ public void actionPerformed (ActionEvent event) { } } --- NEW FILE: TagNameFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/TagNameFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import javax.swing.JComboBox; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.Tag; import org.htmlparser.filters.TagNameFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.tags.CompositeTag; import org.htmlparser.util.NodeIterator; import org.htmlparser.util.NodeList; import org.htmlparser.util.ParserException; /** * Wrapper for TagNameFilters. */ public class TagNameFilterWrapper extends Filter implements ActionListener { /** * The underlying filter. */ protected TagNameFilter mFilter; /** * Combo box for tag name. */ protected JComboBox mName; /** * Create a wrapper over a new TagNameFilter. */ public TagNameFilterWrapper () { mFilter = new TagNameFilter (); // add the tag name choice mName = new JComboBox (); mName.setEditable (true); add (mName); mName.addItem (mFilter.getName ()); mName.addActionListener (this); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Tag named"); } public String getIconSpec () { return ("images/TagNameFilter.gif"); } public NodeFilter getNodeFilter () { TagNameFilter ret; ret = new TagNameFilter (); ret.setName (mFilter.getName ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { Set set; mFilter = (TagNameFilter)filter; set = new HashSet (); context.reset (); try { for (NodeIterator iterator = context.elements (); iterator.hasMoreNodes (); ) addName (set, iterator.nextNode ()); } catch (ParserException pe) { // oh well, we tried } for (Iterator iterator = set.iterator (); iterator.hasNext (); ) mName.addItem (iterator.next ()); mName.setSelectedItem (mFilter.getName ()); } public NodeFilter[] getSubNodeFilters () { return (new NodeFilter[0]); } public void setSubNodeFilters (NodeFilter[] filters) { // should we complain? } public String toJavaCode (StringBuffer out, int[] context) { String ret; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("TagNameFilter "); out.append (ret); out.append (" = new TagNameFilter ();"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setName (\""); out.append (mFilter.getName ()); out.append ("\");"); newline (out); return (ret); } protected void addName (Set set, Node node) { NodeList children; if (node instanceof Tag) { set.add (((Tag)node).getTagName ()); if (node instanceof CompositeTag) { children = ((CompositeTag)node).getChildren (); if (null != children) for (int i = 0; i < children.size (); i++) addName (set, children.elementAt (i)); } } } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs on the combo box. */ public void actionPerformed (ActionEvent event) { Object source; Object[] selection; source = event.getSource (); if (source == mName) { selection = mName.getSelectedObjects (); if ((null != selection) && (0 != selection.length)) mFilter.setName ((String)selection[0]); } } } --- NEW FILE: NodeClassFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/NodeClassFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Iterator; import java.util.Set; import javax.swing.JComboBox; //import javax.swing.event.DocumentEvent; //import javax.swing.event.DocumentListener; //import javax.swing.text.BadLocationException; //import javax.swing.text.Document; import org.htmlparser.Node; import org.htmlparser.NodeFactory; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.Tag; import org.htmlparser.filters.NodeClassFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; /** * Wrapper for NodeClassFilters. */ public class NodeClassFilterWrapper extends Filter implements ActionListener // , // DocumentListener { /** * The underlying filter. */ protected NodeClassFilter mFilter; /** * Combo box for strategy. */ protected JComboBox mClass; /** * Create a wrapper over a new NodeClassFilter. */ public NodeClassFilterWrapper () { mFilter = new NodeClassFilter (); // add the strategy choice mClass = new JComboBox (); mClass.addItem (""); add (mClass); mClass.addActionListener (this); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Nodes of class"); } public String getIconSpec () { return ("images/NodeClassFilter.gif"); } public NodeFilter getNodeFilter () { NodeClassFilter ret; ret = new NodeClassFilter (); ret.setMatchClass (mFilter.getMatchClass ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { NodeFactory factory; PrototypicalNodeFactory proto; Set names; String name; Tag tag; mFilter = (NodeClassFilter)filter; factory = context.getNodeFactory (); if (factory instanceof PrototypicalNodeFactory) { proto = (PrototypicalNodeFactory)factory; // iterate over the classes names = proto.getTagNames (); for (Iterator iterator = names.iterator (); iterator.hasNext (); ) { name = (String)iterator.next (); tag = proto.get (name); mClass.addItem (tag.getClass ().getName ()); } } mClass.setSelectedItem (mFilter.getMatchClass ().getName ()); } public NodeFilter[] getSubNodeFilters () { return (new NodeFilter[0]); } public void setSubNodeFilters (NodeFilter[] filters) { // should we complain? } public String toJavaCode (StringBuffer out, int[] context) { String ret; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("NodeClassFilter "); out.append (ret); out.append (" = new NodeClassFilter ();"); newline (out); spaces (out, context[0]); out.append ("try { "); out.append (ret); out.append (".setMatchClass (Class.forName (\""); out.append (mFilter.getMatchClass ().getName ()); out.append ("\")); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace (); }"); newline (out); return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs on the combo box. */ public void actionPerformed (ActionEvent event) { Object source; source = event.getSource (); if (source == mClass) try { mFilter.setMatchClass (Class.forName ((String)mClass.getSelectedItem ())); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace (); } } // // // // DocumentListener interface // // // // public void insertUpdate (DocumentEvent e) // { // Document doc; // // doc = e.getDocument (); // try // { // mFilter.setPattern (doc.getText (0, doc.getLength ())); // } // catch (BadLocationException ble) // { // ble.printStackTrace (); // } // } // // public void removeUpdate (DocumentEvent e) // { // Document doc; // // doc = e.getDocument (); // try // { // mFilter.setPattern (doc.getText (0, doc.getLength ())); // } // catch (BadLocationException ble) // { // ble.printStackTrace (); // } // } // // public void changedUpdate (DocumentEvent e) // { // // plain text components don't fire these events // } } --- NEW FILE: HasAttributeFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/HasAttributeFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.Vector; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JTextArea; import javax.swing.border.BevelBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import org.htmlparser.Attribute; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.Tag; import org.htmlparser.filters.HasAttributeFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; import org.htmlparser.tags.CompositeTag; import org.htmlparser.util.NodeIterator; import org.htmlparser.util.NodeList; import org.htmlparser.util.ParserException; /** * Wrapper for HasAttributeFilters. */ public class HasAttributeFilterWrapper extends Filter implements ActionListener, DocumentListener { /** * The underlying filter. */ protected HasAttributeFilter mFilter; /** * Combo box for attribute name. */ protected JComboBox mAttributeName; /** * The check box for has value. */ protected JCheckBox mValued; /** * Value to check for. */ protected JTextArea mAttributeValue; /** * Create a wrapper over a new HasAttributeFilter. */ public HasAttributeFilterWrapper () { String value; mFilter = new HasAttributeFilter (); // add the attribute name choice mAttributeName = new JComboBox (); mAttributeName.setEditable (true); add (mAttributeName); mAttributeName.addItem (mFilter.getAttributeName ()); mAttributeName.addActionListener (this); // add the valued flag value = mFilter.getAttributeValue (); mValued = new JCheckBox ("Has Value"); add (mValued); mValued.setSelected (null != value); mValued.addActionListener (this); // add the value pattern mAttributeValue = new JTextArea (2, 20); mAttributeValue.setBorder (new BevelBorder (BevelBorder.LOWERED)); add (mAttributeValue); if (null != value) mAttributeValue.setText (value); else mAttributeValue.setVisible (false); mAttributeValue.getDocument ().addDocumentListener (this); } // // local methods // protected void addAttributes (Set set, Node node) { Vector attributes; Attribute attribute; String name; NodeList children; if (node instanceof Tag) { attributes = ((Tag)node).getAttributesEx (); for (int i = 1; i < attributes.size (); i++) { attribute = (Attribute)attributes.elementAt (i); name = attribute.getName (); if (null != name) set.add (name); } if (node instanceof CompositeTag) { children = ((CompositeTag)node).getChildren (); if (null != children) for (int i = 0; i < children.size (); i++) addAttributes (set, children.elementAt (i)); } } } protected void addAttributeValues (Set set, Node node) { Vector attributes; Attribute attribute; String value; NodeList children; if (node instanceof Tag) { attributes = ((Tag)node).getAttributesEx (); for (int i = 1; i < attributes.size (); i++) { attribute = (Attribute)attributes.elementAt (i); if (null != attribute.getName ()) { value = attribute.getValue (); if (null != value) set.add (value); } } if (node instanceof CompositeTag) { children = ((CompositeTag)node).getChildren (); if (null != children) for (int i = 0; i < children.size (); i++) addAttributeValues (set, children.elementAt (i)); } } } // // Filter overrides and concrete implementations // public String getDescription () { return ("Has attribute"); } public String getIconSpec () { return ("images/HasAttributeFilter.gif"); } public NodeFilter getNodeFilter () { HasAttributeFilter ret; ret = new HasAttributeFilter (); ret.setAttributeName (mFilter.getAttributeName ()); ret.setAttributeValue (mFilter.getAttributeValue ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { Set set; String name; String value; mFilter = (HasAttributeFilter)filter; set = new HashSet (); context.reset (); try { for (NodeIterator iterator = context.elements (); iterator.hasMoreNodes (); ) addAttributes (set, iterator.nextNode ()); } catch (ParserException pe) { // oh well, we tried } for (Iterator iterator = set.iterator (); iterator.hasNext (); ) mAttributeName.addItem (iterator.next ()); name = mFilter.getAttributeName (); if (!name.equals ("")) mAttributeName.setSelectedItem (name); value = mFilter.getAttributeValue (); if (null != value) { mValued.setSelected (true); mAttributeValue.setVisible (true); mAttributeValue.setText (value); } else { mValued.setSelected (false); mAttributeValue.setVisible (false); } } public NodeFilter[] getSubNodeFilters () { return (new NodeFilter[0]); } public void setSubNodeFilters (NodeFilter[] filters) { // should we complain? } public String toJavaCode (StringBuffer out, int[] context) { String ret; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("HasAttributeFilter "); out.append (ret); out.append (" = new HasAttributeFilter ();"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setAttributeName (\""); out.append (mFilter.getAttributeName ()); out.append ("\");"); newline (out); if (null != mFilter.getAttributeValue ()) { spaces (out, context[0]); out.append (ret); out.append (".setAttributeValue (\""); out.append (mFilter.getAttributeValue ()); out.append ("\");"); newline (out); } return (ret); } // // NodeFilter interface // public boolean accept (Node node) { return (mFilter.accept (node)); } // // ActionListener interface // /** * Invoked when an action occurs on the combo box. */ public void actionPerformed (ActionEvent event) { Object source; Object[] selection; boolean valued; source = event.getSource (); if (source == mAttributeName) { selection = mAttributeName.getSelectedObjects (); if ((null != selection) && (0 != selection.length)) mFilter.setAttributeName ((String)selection[0]); } else if (source == mValued) { valued = mValued.isSelected (); if (valued) { mFilter.setAttributeValue (mAttributeValue.getText ()); mAttributeValue.setVisible (true); } else { mAttributeValue.setVisible (false); mAttributeValue.setText (""); mFilter.setAttributeValue (null); } } } // // DocumentListener interface // public void insertUpdate (DocumentEvent e) { Document doc; doc = e.getDocument (); try { mFilter.setAttributeValue (doc.getText (0, doc.getLength ())); } catch (BadLocationException ble) { ble.printStackTrace (); } } public void removeUpdate (DocumentEvent e) { Document doc; doc = e.getDocument (); try { mFilter.setAttributeValue (doc.getText (0, doc.getLength ())); } catch (BadLocationException ble) { ble.printStackTrace (); } } public void changedUpdate (DocumentEvent e) { // plain text components don't fire these events } } --- NEW FILE: RegexFilterWrapper.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2005 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/parserapplications/filterbuilder/wrappers/RegexFilterWrapper.java,v $ // $Author: derrickoswald $ // $Date: 2005/02/13 20:43:06 $ // $Revision: 1.1 $ // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // package org.htmlparser.parserapplications.filterbuilder.wrappers; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComboBox; import javax.swing.JTextArea; import javax.swing.border.BevelBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.RegexFilter; import org.htmlparser.parserapplications.filterbuilder.Filter; /** * Wrapper for RegexFilters. */ public class RegexFilterWrapper extends Filter implements ActionListener, DocumentListener { /** * Mapping for RegexFilter constants to strings. */ public static Object[][] mMap; static { mMap = new Object[3][]; mMap[0] = new Object[2]; mMap[0][0] = "MATCH"; mMap[0][1] = new Integer (RegexFilter.MATCH); mMap[1] = new Object[2]; mMap[1][0] = "LOOKINGAT"; mMap[1][1] = new Integer (RegexFilter.LOOKINGAT); mMap[2] = new Object[2]; mMap[2][0] = "FIND"; mMap[2][1] = new Integer (RegexFilter.FIND); } /** * The underlying filter. */ protected RegexFilter mFilter; /** * Text to check for */ protected JTextArea mPattern; /** * Combo box for strategy. */ protected JComboBox mStrategy; /** * Create a wrapper over a new RegexFilter. */ public RegexFilterWrapper () { mFilter = new RegexFilter (); // add the text pattern mPattern = new JTextArea (2, 20); mPattern.setBorder (new BevelBorder (BevelBorder.LOWERED)); add (mPattern); mPattern.getDocument ().addDocumentListener (this); mPattern.setText (mFilter.getPattern ()); // add the strategy choice mStrategy = new JComboBox (); mStrategy.addItem ("MATCH"); mStrategy.addItem ("LOOKINGAT"); mStrategy.addItem ("FIND"); add (mStrategy); mStrategy.addActionListener (this); mStrategy.setSelectedIndex (strategyToIndex (mFilter.getStrategy ())); } // // Filter overrides and concrete implementations // public String getDescription () { return ("Nodes containing regex"); } public String getIconSpec () { return ("images/RegexFilter.gif"); } public NodeFilter getNodeFilter () { RegexFilter ret; ret = new RegexFilter (); ret.setStrategy (mFilter.getStrategy ()); ret.setPattern (mFilter.getPattern ()); return (ret); } public void setNodeFilter (NodeFilter filter, Parser context) { mFilter = (RegexFilter)filter; mPattern.setText (mFilter.getPattern ()); mStrategy.setSelectedIndex (strategyToIndex (mFilter.getStrategy ())); } public NodeFilter[] getSubNodeFilters () { return (new NodeFilter[0]); } public void setSubNodeFilters (NodeFilter[] filters) { // should we complain? } public String toJavaCode (StringBuffer out, int[] context) { String ret; ret = "filter" + context[1]++; spaces (out, context[0]); out.append ("RegexFilter "); out.append (ret); out.append (" = new RegexFilter ();"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setStrategy (RegexFilter."); out.append (strategyToString (mFilter.getStrategy ())); out.append (");"); newline (out); spaces (out, context[0]); out.append (ret); out.append (".setPattern (\""); out.append (mFilter.getPattern ()); out.append ("\");"); newline (out); return (ret); } public String strategyToString (int strategy) { for (int i =0; i < mMap.length; i++) if (strategy == ((Integer)mMap[i][1]).intValue ()) return ((String)mMap[i][0]); throw new IllegalArgumentException ("unknown strategy constant - " + strategy); } public int stringToStrategy (String strategy) { for (int i =0; i < mMap.length; i++) if (strategy.equalsIgn... [truncated message content] |