我是很大的字……我居然比旁边的字小我最小...啊啊啊......居然可以设置不同的字体字号
我先来个居中对齐!
我是来右对齐的!
我可以设置很多不同的字体风格,比如:加粗、斜体、下划线。
我可以设置一个超链接,牛逼吗 快戳我看看
我是很大的字……我居然比旁边的字小我最小...啊啊啊......居然可以设置不同的字体字号
我先来个居中对齐!
我是来右对齐的!
我可以设置很多不同的字体风格,比如:加粗、斜体、下划线。
我可以设置一个超链接,牛逼吗 快戳我看看
", " This class provides a default implementation of the SAX2
32 | * {@link Attributes Attributes} interface, with the
33 | * addition of manipulators so that the list can be modified or
34 | * reused. There are two typical uses of this class: This class replaces the now-deprecated SAX1 {@link
45 | * org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
46 | * class; in addition to supporting the updated Attributes
47 | * interface rather than the deprecated {@link org.xml.sax.AttributeList
48 | * AttributeList} interface, it also includes a much more efficient
49 | * implementation using a single array rather than a set of Vectors. This constructor is especially useful inside a
85 | * {@link org.xml.sax.ContentHandler#startElement startElement} event. In many cases, it will be more efficient to look up the name once and
186 | * use the index query methods rather than using the name query methods
187 | * repeatedly. Note that little memory is freed by this call:
307 | * the current array is kept so it can be
308 | * reused. It may be more efficient to reuse an existing object
322 | * rather than constantly allocating new ones. For the sake of speed, this method does no checking
345 | * to see if the attribute is already in the list: that is
346 | * the responsibility of the application. For the sake of speed, this method does no checking
373 | * for name conflicts or well-formedness: such checks are the
374 | * responsibility of the application.
");
55 |
56 | content = ActionscriptTextUtils.parseFontHTML(content);
57 |
58 | String p_regex = "SAXParser using the currently
65 | * configured factory parameters.
66 | */
67 | public SAXParser newSAXParser()
68 | throws ParserConfigurationException {
69 | try {
70 | return SAXParserImpl.newInstance(features);
71 | } catch (SAXException se) {
72 | // Translate to ParserConfigurationException
73 | throw new ParserConfigurationException(se.getMessage());
74 | }
75 | }
76 |
77 | /**
78 | * Defines that the specified feature is to enabled/disabled (as
79 | * per second argument) on reader instances created by this
80 | * factory.
81 | */
82 | public void setFeature(String name, boolean value)
83 | throws ParserConfigurationException, SAXNotRecognizedException,
84 | SAXNotSupportedException {
85 | // First, let's see if it's a valid call
86 | getPrototype().setFeature(name, value);
87 |
88 | // If not, exception was thrown: so we are good now:
89 | if (features == null) {
90 | // Let's retain the ordering as well
91 | features = new LinkedHashMap();
92 | }
93 | features.put(name, value ? Boolean.TRUE : Boolean.FALSE);
94 | }
95 |
96 | /**
97 | * Returns whether the specified property will be enabled or disabled
98 | * on reader instances constructed by this factory.
99 | */
100 | public boolean getFeature(String name)
101 | throws ParserConfigurationException, SAXNotRecognizedException,
102 | SAXNotSupportedException {
103 | return getPrototype().getFeature(name);
104 | }
105 |
106 | // // // Internal methods
107 |
108 | private SAXParserImpl getPrototype() {
109 | if (prototypeParser == null) {
110 | prototypeParser = new SAXParserImpl();
111 | }
112 | return prototypeParser;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/PYXScanner.java:
--------------------------------------------------------------------------------
1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
2 | //
3 | // TagSoup is licensed under the Apache License,
4 | // Version 2.0. You may obtain a copy of this license at
5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have
6 | // additional legal rights not granted by this license.
7 | //
8 | // TagSoup is distributed in the hope that it will be useful, but
9 | // unless required by applicable law or agreed to in writing, TagSoup
10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11 | // OF ANY KIND, either express or implied; not even the implied warranty
12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | //
14 | //
15 | // This file is part of TagSoup.
16 | //
17 | // This program is free software; you can redistribute it and/or modify
18 | // it under the terms of the GNU General Public License as published by
19 | // the Free Software Foundation; either version 2 of the License, or
20 | // (at your option) any later version. You may also distribute
21 | // and/or modify it under version 2.1 of the Academic Free License.
22 | //
23 | // This program is distributed in the hope that it will be useful,
24 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 | //
27 | //
28 | // PYX Scanner
29 |
30 | package com.xys.lib_tv_fullhtml.tagsoup;
31 |
32 | import org.xml.sax.SAXException;
33 |
34 | import java.io.BufferedReader;
35 | import java.io.BufferedWriter;
36 | import java.io.IOException;
37 | import java.io.InputStreamReader;
38 | import java.io.OutputStreamWriter;
39 | import java.io.Reader;
40 | import java.io.Writer;
41 |
42 | /**
43 | * A Scanner that accepts PYX format instead of HTML.
44 | * Useful primarily for debugging.
45 | **/
46 | public class PYXScanner implements Scanner {
47 |
48 | public static void main(String[] argv) throws IOException, SAXException {
49 | Scanner s = new PYXScanner();
50 | Reader r = new InputStreamReader(System.in, "UTF-8");
51 | Writer w = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"));
52 | s.scan(r, new PYXWriter(w));
53 | }
54 |
55 | public void resetDocumentLocator(String publicid, String systemid) {
56 | // Need this method for interface compatibility, but note
57 | // that PyxScanner does not implement Locator.
58 | }
59 |
60 | public void scan(Reader r, ScanHandler h) throws IOException, SAXException {
61 | BufferedReader br = new BufferedReader(r);
62 | String s;
63 | char[] buff = null;
64 | boolean instag = false;
65 | while ((s = br.readLine()) != null) {
66 | int size = s.length();
67 | if (buff == null || buff.length < size) {
68 | buff = new char[size];
69 | }
70 | s.getChars(0, size, buff, 0);
71 | switch (buff[0]) {
72 | case '(':
73 | if (instag) {
74 | h.stagc(buff, 0, 0);
75 | instag = false;
76 | }
77 | h.gi(buff, 1, size - 1);
78 | instag = true;
79 | break;
80 | case ')':
81 | if (instag) {
82 | h.stagc(buff, 0, 0);
83 | instag = false;
84 | }
85 | h.etag(buff, 1, size - 1);
86 | break;
87 | case '?':
88 | if (instag) {
89 | h.stagc(buff, 0, 0);
90 | instag = false;
91 | }
92 | h.pi(buff, 1, size - 1);
93 | break;
94 | case 'A':
95 | int sp = s.indexOf(' ');
96 | h.aname(buff, 1, sp - 1);
97 | h.aval(buff, sp + 1, size - sp - 1);
98 | break;
99 | case '-':
100 | if (instag) {
101 | h.stagc(buff, 0, 0);
102 | instag = false;
103 | }
104 | if (s.equals("-\\n")) {
105 | buff[0] = '\n';
106 | h.pcdata(buff, 0, 1);
107 | } else {
108 | // FIXME:
109 | // Does not decode \t and \\ in input
110 | h.pcdata(buff, 1, size - 1);
111 | }
112 | break;
113 | case 'E':
114 | if (instag) {
115 | h.stagc(buff, 0, 0);
116 | instag = false;
117 | }
118 | h.entity(buff, 1, size - 1);
119 | break;
120 | default:
121 | // System.err.print("Gotcha ");
122 | // System.err.print(s);
123 | // System.err.print('\n');
124 | break;
125 | }
126 | }
127 | h.eof(buff, 0, 0);
128 | }
129 |
130 | public void startCDATA() {
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/Schema.java:
--------------------------------------------------------------------------------
1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
2 | //
3 | // TagSoup is licensed under the Apache License,
4 | // Version 2.0. You may obtain a copy of this license at
5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have
6 | // additional legal rights not granted by this license.
7 | //
8 | // TagSoup is distributed in the hope that it will be useful, but
9 | // unless required by applicable law or agreed to in writing, TagSoup
10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11 | // OF ANY KIND, either express or implied; not even the implied warranty
12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | //
14 | //
15 | // Model of document
16 |
17 | package com.xys.lib_tv_fullhtml.tagsoup;
18 |
19 | import java.util.HashMap;
20 |
21 | /**
22 | * Abstract class representing a TSSL schema.
23 | * Actual TSSL schemas are compiled into concrete subclasses of this class.
24 | **/
25 |
26 | public abstract class Schema {
27 |
28 | public static final int M_ANY = 0xFFFFFFFF;
29 | public static final int M_EMPTY = 0;
30 | public static final int M_PCDATA = 1 << 30;
31 | public static final int M_ROOT = 1 << 31;
32 |
33 |
34 | public static final int F_RESTART = 1;
35 | public static final int F_CDATA = 2;
36 | public static final int F_NOFORCE = 4;
37 |
38 | private HashMap theEntities =
39 | new HashMap(); // String -> Character
40 | private HashMap theElementTypes =
41 | new HashMap(); // String -> ElementType
42 |
43 | private String theURI = "";
44 | private String thePrefix = "";
45 | private ElementType theRoot = null;
46 |
47 | /**
48 | * Add or replace an element type for this schema.
49 | *
50 | * @param name Name (Qname) of the element
51 | * @param model Models of the element's content as a vector of bits
52 | * @param memberOf Models the element is a member of as a vector of bits
53 | * @param flags Flags for the element
54 | **/
55 |
56 | public void elementType(String name, int model, int memberOf, int flags) {
57 | ElementType e = new ElementType(name, model, memberOf, flags, this);
58 | theElementTypes.put(name.toLowerCase(), e);
59 | if (memberOf == M_ROOT) theRoot = e;
60 | }
61 |
62 | /**
63 | * Get the root element of this schema
64 | **/
65 |
66 | public ElementType rootElementType() {
67 | return theRoot;
68 | }
69 |
70 | /**
71 | * Add or replace a default attribute for an element type in this schema.
72 | *
73 | * @param elemName Name (Qname) of the element type
74 | * @param attrName Name (Qname) of the attribute
75 | * @param type Type of the attribute
76 | * @param value Default value of the attribute; null if no default
77 | **/
78 |
79 | public void attribute(String elemName, String attrName,
80 | String type, String value) {
81 | ElementType e = getElementType(elemName);
82 | if (e == null) {
83 | throw new Error("Attribute " + attrName +
84 | " specified for unknown element type " +
85 | elemName);
86 | }
87 | e.setAttribute(attrName, type, value);
88 | }
89 |
90 | /**
91 | * Specify natural parent of an element in this schema.
92 | *
93 | * @param name Name of the child element
94 | * @param parentName Name of the parent element
95 | **/
96 |
97 | public void parent(String name, String parentName) {
98 | ElementType child = getElementType(name);
99 | ElementType parent = getElementType(parentName);
100 | if (child == null) {
101 | throw new Error("No child " + name + " for parent " + parentName);
102 | }
103 | if (parent == null) {
104 | throw new Error("No parent " + parentName + " for child " + name);
105 | }
106 | child.setParent(parent);
107 | }
108 |
109 | /**
110 | * Add to or replace a character entity in this schema.
111 | *
112 | * @param name Name of the entity
113 | * @param value Value of the entity
114 | **/
115 |
116 | public void entity(String name, int value) {
117 | theEntities.put(name, new Integer(value));
118 | }
119 |
120 | /**
121 | * Get an ElementType by name.
122 | *
123 | * @param name Name (Qname) of the element type
124 | * @return The corresponding ElementType
125 | **/
126 |
127 | public ElementType getElementType(String name) {
128 | return (ElementType) (theElementTypes.get(name.toLowerCase()));
129 | }
130 |
131 | /**
132 | * Get an entity value by name.
133 | *
134 | * @param name Name of the entity
135 | * @return The corresponding character, or 0 if none
136 | **/
137 |
138 | public int getEntity(String name) {
139 | // System.err.println("%% Looking up entity " + name);
140 | Integer ch = (Integer) theEntities.get(name);
141 | if (ch == null) return 0;
142 | return ch.intValue();
143 | }
144 |
145 | /**
146 | * Return the URI (namespace name) of this schema.
147 | **/
148 |
149 | public String getURI() {
150 | return theURI;
151 | }
152 |
153 | /**
154 | * Change the URI (namespace name) of this schema.
155 | **/
156 |
157 | public void setURI(String uri) {
158 | theURI = uri;
159 | }
160 |
161 | /**
162 | * Return the prefix of this schema.
163 | **/
164 |
165 | public String getPrefix() {
166 | return thePrefix;
167 | }
168 |
169 | /**
170 | * Change the prefix of this schema.
171 | **/
172 |
173 | public void setPrefix(String prefix) {
174 | thePrefix = prefix;
175 | }
176 |
177 | }
178 |
--------------------------------------------------------------------------------
/lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/jaxp/SAX1ParserAdapter.java:
--------------------------------------------------------------------------------
1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
2 | //
3 | // TagSoup is licensed under the Apache License,
4 | // Version 2.0. You may obtain a copy of this license at
5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have
6 | // additional legal rights not granted by this license.
7 | //
8 | // TagSoup is distributed in the hope that it will be useful, but
9 | // unless required by applicable law or agreed to in writing, TagSoup
10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11 | // OF ANY KIND, either express or implied; not even the implied warranty
12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 |
14 | package com.xys.lib_tv_fullhtml.tagsoup.jaxp;
15 |
16 | import org.xml.sax.AttributeList;
17 | import org.xml.sax.Attributes;
18 | import org.xml.sax.ContentHandler;
19 | import org.xml.sax.DTDHandler;
20 | import org.xml.sax.DocumentHandler;
21 | import org.xml.sax.EntityResolver;
22 | import org.xml.sax.ErrorHandler;
23 | import org.xml.sax.InputSource;
24 | import org.xml.sax.Locator;
25 | import org.xml.sax.SAXException;
26 | import org.xml.sax.SAXNotSupportedException;
27 | import org.xml.sax.XMLReader;
28 |
29 | import java.io.IOException;
30 |
31 | /**
32 | * This is a simpler adapter class that allows using SAX1 interface on top
33 | * of basic SAX2 implementation, such as TagSoup.
34 | *
35 | * @author Tatu Saloranta (cowtowncoder@yahoo.com)
36 | * @deprecated
37 | */
38 | public class SAX1ParserAdapter
39 | implements org.xml.sax.Parser {
40 | final XMLReader xmlReader;
41 |
42 | public SAX1ParserAdapter(XMLReader xr) {
43 | xmlReader = xr;
44 | }
45 |
46 | // Sax1 API impl
47 |
48 | public void parse(InputSource source)
49 | throws SAXException {
50 | try {
51 | xmlReader.parse(source);
52 | } catch (IOException ioe) {
53 | throw new SAXException(ioe);
54 | }
55 | }
56 |
57 | public void parse(String systemId)
58 | throws SAXException {
59 | try {
60 | xmlReader.parse(systemId);
61 | } catch (IOException ioe) {
62 | throw new SAXException(ioe);
63 | }
64 | }
65 |
66 | /**
67 | * @deprecated
68 | */
69 | public void setDocumentHandler(DocumentHandler h) {
70 | xmlReader.setContentHandler(new DocHandlerWrapper(h));
71 | }
72 |
73 | public void setDTDHandler(DTDHandler h) {
74 | xmlReader.setDTDHandler(h);
75 | }
76 |
77 | public void setEntityResolver(EntityResolver r) {
78 | xmlReader.setEntityResolver(r);
79 | }
80 |
81 | public void setErrorHandler(ErrorHandler h) {
82 | xmlReader.setErrorHandler(h);
83 | }
84 |
85 | public void setLocale(java.util.Locale locale)
86 | throws SAXException {
87 | /* I have no idea what this is supposed to do... so let's
88 | * throw an exception
89 | */
90 | throw new SAXNotSupportedException("TagSoup does not implement setLocale() method");
91 | }
92 |
93 | // Helper classes:
94 |
95 | /**
96 | * We need another helper class to deal with differences between
97 | * Sax2 handler (content handler), and Sax1 handler (document handler)
98 | *
99 | * @deprecated
100 | */
101 | final static class DocHandlerWrapper
102 | implements ContentHandler {
103 | final DocumentHandler docHandler;
104 |
105 | final AttributesWrapper mAttrWrapper = new AttributesWrapper();
106 |
107 | /**
108 | * @deprecated
109 | */
110 | DocHandlerWrapper(DocumentHandler h) {
111 | docHandler = h;
112 | }
113 |
114 | public void characters(char[] ch, int start, int length)
115 | throws SAXException {
116 | docHandler.characters(ch, start, length);
117 | }
118 |
119 | public void endDocument()
120 | throws SAXException {
121 | docHandler.endDocument();
122 | }
123 |
124 | public void endElement(String uri, String localName, String qName)
125 | throws SAXException {
126 | if (qName == null) {
127 | qName = localName;
128 | }
129 | docHandler.endElement(qName);
130 | }
131 |
132 | public void endPrefixMapping(String prefix) {
133 | // no equivalent in SAX1, ignore
134 | }
135 |
136 | public void ignorableWhitespace(char[] ch, int start, int length)
137 | throws SAXException {
138 | docHandler.ignorableWhitespace(ch, start, length);
139 | }
140 |
141 | public void processingInstruction(String target, String data)
142 | throws SAXException {
143 | docHandler.processingInstruction(target, data);
144 | }
145 |
146 | public void setDocumentLocator(Locator locator) {
147 | docHandler.setDocumentLocator(locator);
148 | }
149 |
150 | public void skippedEntity(String name) {
151 | // no equivalent in SAX1, ignore
152 | }
153 |
154 | public void startDocument()
155 | throws SAXException {
156 | docHandler.startDocument();
157 | }
158 |
159 | public void startElement(String uri, String localName, String qName,
160 | Attributes attrs)
161 | throws SAXException {
162 | if (qName == null) {
163 | qName = localName;
164 | }
165 | // Also, need to wrap Attributes to look like AttributeLost
166 | mAttrWrapper.setAttributes(attrs);
167 | docHandler.startElement(qName, mAttrWrapper);
168 | }
169 |
170 | public void startPrefixMapping(String prefix, String uri) {
171 | // no equivalent in SAX1, ignore
172 | }
173 | }
174 |
175 | /**
176 | * And one more helper to deal with attribute access differences
177 | *
178 | * @deprecated
179 | */
180 | final static class AttributesWrapper
181 | implements AttributeList {
182 | Attributes attrs;
183 |
184 | public AttributesWrapper() {
185 | }
186 |
187 | public void setAttributes(Attributes a) {
188 | attrs = a;
189 | }
190 |
191 | public int getLength() {
192 | return attrs.getLength();
193 | }
194 |
195 | public String getName(int i) {
196 | String n = attrs.getQName(i);
197 | return (n == null) ? attrs.getLocalName(i) : n;
198 | }
199 |
200 | public String getType(int i) {
201 | return attrs.getType(i);
202 | }
203 |
204 | public String getType(String name) {
205 | return attrs.getType(name);
206 | }
207 |
208 | public String getValue(int i) {
209 | return attrs.getValue(i);
210 | }
211 |
212 | public String getValue(String name) {
213 | return attrs.getValue(name);
214 | }
215 | }
216 | }
217 |
--------------------------------------------------------------------------------
/lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/Element.java:
--------------------------------------------------------------------------------
1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan.
2 | //
3 | // TagSoup is licensed under the Apache License,
4 | // Version 2.0. You may obtain a copy of this license at
5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have
6 | // additional legal rights not granted by this license.
7 | //
8 | // TagSoup is distributed in the hope that it will be useful, but
9 | // unless required by applicable law or agreed to in writing, TagSoup
10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
11 | // OF ANY KIND, either express or implied; not even the implied warranty
12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 |
14 | package com.xys.lib_tv_fullhtml.tagsoup;
15 |
16 | /**
17 | * The internal representation of an actual element (not an element type).
18 | * An Element has an element type, attributes, and a successor Element
19 | * for use in constructing stacks and queues of Elements.
20 | *
21 | * @see ElementType
22 | * @see AttributesImpl
23 | */
24 | public class Element {
25 |
26 |
27 | private ElementType theType; // type of element
28 | private AttributesImpl theAtts; // attributes of element
29 | private Element theNext; // successor of element
30 | private boolean preclosed; // this element has been preclosed
31 |
32 | /**
33 | * Return an Element from a specified ElementType.
34 | *
35 | * @param type The element type of the newly constructed element
36 | * @param defaultAttributes True if default attributes are wanted
37 | */
38 |
39 | public Element(ElementType type, boolean defaultAttributes) {
40 | theType = type;
41 | if (defaultAttributes) theAtts = new AttributesImpl(type.atts());
42 | else theAtts = new AttributesImpl();
43 | theNext = null;
44 | preclosed = false;
45 | }
46 |
47 | /**
48 | * Return the element type.
49 | *
50 | * @return The element type.
51 | */
52 |
53 | public ElementType type() {
54 | return theType;
55 | }
56 |
57 | /**
58 | * Return the attributes as an AttributesImpl object.
59 | * Returning an AttributesImpl makes the attributes mutable.
60 | *
61 | * @return The attributes
62 | * @see AttributesImpl
63 | */
64 | public AttributesImpl atts() {
65 | return theAtts;
66 | }
67 |
68 | /**
69 | * Return the next element in an element stack or queue.
70 | *
71 | * @return The next element
72 | */
73 |
74 | public Element next() {
75 | return theNext;
76 | }
77 |
78 | /**
79 | * Change the next element in an element stack or queue.
80 | *
81 | * @param next The new next element
82 | */
83 |
84 | public void setNext(Element next) {
85 | theNext = next;
86 | }
87 |
88 | /**
89 | * Return the name of the element's type.
90 | * Convenience method.
91 | *
92 | * @return The element type name
93 | */
94 |
95 | public String name() {
96 | return theType.name();
97 | }
98 |
99 | /**
100 | * Return the namespace name of the element's type.
101 | * Convenience method.
102 | *
103 | * @return The element type namespace name
104 | */
105 |
106 | public String namespace() {
107 | return theType.namespace();
108 | }
109 |
110 | /**
111 | * Return the local name of the element's type.
112 | * Convenience method.
113 | *
114 | * @return The element type local name
115 | */
116 |
117 | public String localName() {
118 | return theType.localName();
119 | }
120 |
121 | /**
122 | * Return the content model vector of the element's type.
123 | * Convenience method.
124 | *
125 | * @return The content model vector
126 | */
127 |
128 | public int model() {
129 | return theType.model();
130 | }
131 |
132 | /**
133 | * Return the member-of vector of the element's type.
134 | * Convenience method.
135 | *
136 | * @return The member-of vector
137 | */
138 |
139 | public int memberOf() {
140 | return theType.memberOf();
141 | }
142 |
143 | /**
144 | * Return the flags vector of the element's type.
145 | * Convenience method.
146 | *
147 | * @return The flags vector
148 | */
149 |
150 | public int flags() {
151 | return theType.flags();
152 | }
153 |
154 | /**
155 | * Return the parent element type of the element's type.
156 | * Convenience method.
157 | *
158 | * @return The parent element type
159 | */
160 |
161 | public ElementType parent() {
162 | return theType.parent();
163 | }
164 |
165 | /**
166 | * Return true if the type of this element can contain the type of
167 | * another element.
168 | * Convenience method.
169 | *
170 | * @param other The other element
171 | */
172 |
173 | public boolean canContain(Element other) {
174 | return theType.canContain(other.theType);
175 | }
176 |
177 |
178 | /**
179 | * Set an attribute and its value into this element.
180 | *
181 | * @param name The attribute name (Qname)
182 | * @param type The attribute type
183 | * @param value The attribute value
184 | */
185 |
186 | public void setAttribute(String name, String type, String value) {
187 | theType.setAttribute(theAtts, name, type, value);
188 | }
189 |
190 | /**
191 | * Make this element anonymous.
192 | * Remove any id or name attribute present
193 | * in the element's attributes.
194 | */
195 |
196 | public void anonymize() {
197 | for (int i = theAtts.getLength() - 1; i >= 0; i--) {
198 | if (theAtts.getType(i).equals("ID") ||
199 | theAtts.getQName(i).equals("name")) {
200 | theAtts.removeAttribute(i);
201 | }
202 | }
203 | }
204 |
205 | /**
206 | * Clean the attributes of this element.
207 | * Attributes with null name (the name was ill-formed)
208 | * or null value (the attribute was present in the element type but
209 | * not in this actual element) are removed.
210 | */
211 |
212 | public void clean() {
213 | for (int i = theAtts.getLength() - 1; i >= 0; i--) {
214 | String name = theAtts.getLocalName(i);
215 | if (theAtts.getValue(i) == null || name == null ||
216 | name.length() == 0) {
217 | theAtts.removeAttribute(i);
218 | continue;
219 | }
220 | }
221 | }
222 |
223 | /**
224 | * Force this element to preclosed status, meaning that an end-tag has
225 | * been seen but the element cannot yet be closed for structural reasons.
226 | */
227 |
228 | public void preclose() {
229 | preclosed = true;
230 | }
231 |
232 | /**
233 | * Return true if this element has been preclosed.
234 | */
235 |
236 | public boolean isPreclosed() {
237 | return preclosed;
238 | }
239 |
240 | }
241 |
--------------------------------------------------------------------------------
/lib_tv_fullhtml/lib_tv_fullhtml.iml:
--------------------------------------------------------------------------------
1 |
2 |
25 | * This module, both source code and documentation, is in the
26 | * Public Domain, and comes with NO WARRANTY.
27 | * See http://www.saxproject.org
28 | * for further information.
29 | *
30 | *
31 | *
39 | *
43 | *
44 | *