I Was Put on the P
It’s a ‘Me’ Game,
Young at Heart
The Finish Line Is
It All Depends on
Only Time Will Tel
Friends?
Apocalyptic fictio
This end justifies
Internships, and Iailiar.com)
*
* Copyright (c) 2005-2020 Mahmoud Fayed
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.htmlparser.util;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.io.IOException;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Stack;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.event.UndoableEditEvent;
import javax.swing.event.UndoableEditListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.URIResolver;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.stream.StreamResult;
import org.htmlparser.util.StringSplitter;
import org.htmlparser.util.TextUtils;
/**
* A swing utility class for HTML parsing
*
* @author Mahmoud Fayed
* @see http://sprunge.us/eOAO
*/
public class HtmlParser {
public static final int WIDTH = 500;
public static final String[][] NAMES = {{"abort", "accept", "accesskey", "action", "alt", "async", "autocomplete",
"autofocus", "autoplay", "autosave", "auxbutton", "beforeprint", "bgcolor", "charset", "checked",
"cite", "class", "clear", "code", "codebase", "codetype", "color", "cols", "colspan", "content",
"contenteditable", "contextmenu", "controls", "coords", "data", "datetime", "defaultChecked",
"defaultValue", "dir", "dirname", "disabled", "download", "draggable", "dynsrc", "enctype", "face",
"first", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget",
"frame", "framespacing", "height", "hidden", "home", "href", "httpupstream", "id", "ieurlfix", "image",
"images", "input", "isindex", "ismap", "itemid", "itemprop", "itemref", "itemscope", "itemtype",
"keyparams", "kind", "label", "lang", "layer", "leftmargin", "link", "loop", "lowsrc", "malignmark",
"manifest", "marginwidth", "marginheight", "maxlength", "media", "method", "multiple", "name", "nohref",
"noresize", "noshade", "noscript", "nowrap", "object", "onabort", "onafterprint", "onbeforeprint",
"onbeforeunload", "onblur", "onchange", "onclick", "oncontextmenu", "ondblclick", "ondrag",
"ondragend", "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "onerror",
"onfocus", "onhelp", "onkeydown", "onkeypress", "onkeyup", "onload", "onmousedown", "onmousemove",
"onmouseout", "onmouseover", "onmouseup", "onreset", "onselect", "onselectionchange",
"onselectionfocus", "onsubmit", "onsuspend", "onunload", "open", "optimum", "pattern", "ping",
"pluginspage", "prompt", "radiogroup", "readonly", "rel", "required", "rev", "rows", "rowspan",
"rules", "sabotage", "scope", "selected", "shape", "size", "type", "url", "value", "width", "wrap",
"xml:base", "xml:lang", "xmlns", "xmlns:svg", "xmlns:xlink", "xmlspace", "xsl:use-attribute-sets",
"xsl:with-param", "xsl:with-param-namespaces", "xsl:with-param-value", "xpath", "xpath1",
"yanchor", "yofocus", "zindex"};
private static final String[][] OPS = {{"get", "haschild", "hasparent", "hasnext", "hasprevious", "moveToBeginning",
"moveToEnd", "moveToNext", "moveToNextSibling", "moveToPrevious", "moveToPreviousSibling", "moveToTextEnd",
"moveToTextStart", "replace", "replaceAll", "replaceFrom", "replaceText"};
private static final String ELEMENT_SIGNATURE = "