From 34b771631f79bedf916bf03b16dfc0cf30338ff3 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 25 Jul 2021 11:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JsoupXpath/.gitignore | 1 - JsoupXpath/build.gradle | 44 - JsoupXpath/consumer-rules.pro | 0 JsoupXpath/proguard-rules.pro | 21 - JsoupXpath/src/main/AndroidManifest.xml | 4 - .../org/seimicrawler/xpath/JXDocument.java | 152 - .../java/org/seimicrawler/xpath/JXNode.java | 130 - .../org/seimicrawler/xpath/antlr/Xpath.interp | 120 - .../org/seimicrawler/xpath/antlr/Xpath.tokens | 76 - .../xpath/antlr/XpathBaseListener.java | 535 -- .../xpath/antlr/XpathBaseVisitor.java | 311 - .../xpath/antlr/XpathLexer.interp | 143 - .../seimicrawler/xpath/antlr/XpathLexer.java | 325 - .../xpath/antlr/XpathLexer.tokens | 76 - .../xpath/antlr/XpathListener.java | 388 -- .../seimicrawler/xpath/antlr/XpathParser.java | 2490 -------- .../xpath/antlr/XpathVisitor.java | 229 - .../seimicrawler/xpath/core/AxisSelector.java | 24 - .../seimicrawler/xpath/core/Constants.java | 10 - .../org/seimicrawler/xpath/core/Function.java | 13 - .../org/seimicrawler/xpath/core/NodeTest.java | 21 - .../org/seimicrawler/xpath/core/Scope.java | 76 - .../org/seimicrawler/xpath/core/XValue.java | 226 - .../xpath/core/XpathProcessor.java | 613 -- .../core/axis/AncestorOrSelfSelector.java | 34 - .../xpath/core/axis/AncestorSelector.java | 33 - .../xpath/core/axis/AttributeSelector.java | 32 - .../xpath/core/axis/ChildSelector.java | 28 - .../core/axis/DescendantOrSelfSelector.java | 34 - .../xpath/core/axis/DescendantSelector.java | 37 - .../xpath/core/axis/FollowingSelector.java | 51 - .../axis/FollowingSiblingOneSelector.java | 44 - .../core/axis/FollowingSiblingSelector.java | 48 - .../xpath/core/axis/ParentSelector.java | 34 - .../xpath/core/axis/PrecedingSelector.java | 56 - .../axis/PrecedingSiblingOneSelector.java | 44 - .../core/axis/PrecedingSiblingSelector.java | 48 - .../xpath/core/axis/SelfSelector.java | 23 - .../xpath/core/function/Concat.java | 30 - .../xpath/core/function/Contains.java | 29 - .../xpath/core/function/Count.java | 29 - .../xpath/core/function/First.java | 25 - .../xpath/core/function/FormatDate.java | 47 - .../xpath/core/function/Last.java | 28 - .../seimicrawler/xpath/core/function/Not.java | 30 - .../xpath/core/function/Position.java | 28 - .../xpath/core/function/StartsWith.java | 29 - .../xpath/core/function/StringLength.java | 30 - .../xpath/core/function/SubString.java | 47 - .../xpath/core/function/SubStringAfter.java | 32 - .../core/function/SubStringAfterLast.java | 32 - .../xpath/core/function/SubStringBefore.java | 33 - .../core/function/SubStringBeforeLast.java | 33 - .../xpath/core/function/SubStringEx.java | 44 - .../seimicrawler/xpath/core/node/AllText.java | 44 - .../seimicrawler/xpath/core/node/Html.java | 31 - .../seimicrawler/xpath/core/node/Node.java | 45 - .../org/seimicrawler/xpath/core/node/Num.java | 51 - .../xpath/core/node/OuterHtml.java | 31 - .../seimicrawler/xpath/core/node/Text.java | 108 - .../xpath/exception/DoFailOnErrorHandler.java | 35 - .../xpath/exception/NoSuchAxisException.java | 28 - .../exception/NoSuchFunctionException.java | 26 - .../exception/XpathMergeValueException.java | 13 - .../xpath/exception/XpathParserException.java | 23 - .../exception/XpathSyntaxErrorException.java | 30 - .../seimicrawler/xpath/util/CommonUtil.java | 121 - .../org/seimicrawler/xpath/util/Scanner.java | 141 - JsoupXpath/src/main/resources/Xpath.g4 | 296 - .../java/org/seimicrawler/xpath/BaseTest.java | 12 - .../seimicrawler/xpath/JXDocumentTest.java | 289 - .../xpath/core/function/DateFormatTest.java | 49 - .../xpath/core/function/SubStringTest.java | 53 - .../seimicrawler/xpath/core/node/NumTest.java | 59 - .../org/seimicrawler/xpath/expr/ExprTest.java | 63 - JsoupXpath/src/test/resources/d_test.html | 5416 ----------------- app/build.gradle | 2 +- .../main/res/layout/dialog_read_padding.xml | 70 +- app/src/main/res/layout/dialog_tip_config.xml | 568 +- settings.gradle | 2 +- 80 files changed, 324 insertions(+), 14382 deletions(-) delete mode 100644 JsoupXpath/.gitignore delete mode 100644 JsoupXpath/build.gradle delete mode 100644 JsoupXpath/consumer-rules.pro delete mode 100644 JsoupXpath/proguard-rules.pro delete mode 100644 JsoupXpath/src/main/AndroidManifest.xml delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/JXDocument.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/JXNode.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.interp delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.tokens delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseListener.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseVisitor.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.interp delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.tokens delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathListener.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathParser.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathVisitor.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/AxisSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Constants.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Function.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/NodeTest.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Scope.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XValue.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XpathProcessor.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorOrSelfSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AttributeSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ChildSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantOrSelfSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingOneSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ParentSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingOneSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/SelfSelector.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Concat.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Contains.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Count.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/First.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/FormatDate.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Last.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Not.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Position.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StartsWith.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StringLength.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubString.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfter.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfterLast.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBefore.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBeforeLast.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringEx.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/AllText.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Html.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Node.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Num.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/OuterHtml.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Text.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/DoFailOnErrorHandler.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchAxisException.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchFunctionException.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathMergeValueException.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathParserException.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathSyntaxErrorException.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/util/CommonUtil.java delete mode 100644 JsoupXpath/src/main/java/org/seimicrawler/xpath/util/Scanner.java delete mode 100644 JsoupXpath/src/main/resources/Xpath.g4 delete mode 100644 JsoupXpath/src/test/java/org/seimicrawler/xpath/BaseTest.java delete mode 100644 JsoupXpath/src/test/java/org/seimicrawler/xpath/JXDocumentTest.java delete mode 100644 JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/DateFormatTest.java delete mode 100644 JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/SubStringTest.java delete mode 100644 JsoupXpath/src/test/java/org/seimicrawler/xpath/core/node/NumTest.java delete mode 100644 JsoupXpath/src/test/java/org/seimicrawler/xpath/expr/ExprTest.java delete mode 100644 JsoupXpath/src/test/resources/d_test.html diff --git a/JsoupXpath/.gitignore b/JsoupXpath/.gitignore deleted file mode 100644 index 42afabfd2..000000000 --- a/JsoupXpath/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/JsoupXpath/build.gradle b/JsoupXpath/build.gradle deleted file mode 100644 index 72f0785d2..000000000 --- a/JsoupXpath/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -plugins { - id 'com.android.library' -} - -android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 30 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - android { - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - implementation('org.jsoup:jsoup:1.14.1') - implementation('org.antlr:antlr4-runtime:4.7.2') - implementation('org.apache.commons:commons-lang3:3.11') - implementation('org.slf4j:slf4j-api:1.7.30') - implementation('org.slf4j:slf4j-simple:1.7.30') - testImplementation('ch.qos.logback:logback-core:1.2.3') - testImplementation('org.powermock:powermock-module-junit4:1.6.3') - testImplementation('org.powermock:powermock-api-mockito:1.6.3') - testImplementation('com.tngtech.java:junit-dataprovider:1.10.2') - testImplementation('commons-io:commons-io:2.6') -} \ No newline at end of file diff --git a/JsoupXpath/consumer-rules.pro b/JsoupXpath/consumer-rules.pro deleted file mode 100644 index e69de29bb..000000000 diff --git a/JsoupXpath/proguard-rules.pro b/JsoupXpath/proguard-rules.pro deleted file mode 100644 index 481bb4348..000000000 --- a/JsoupXpath/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/JsoupXpath/src/main/AndroidManifest.xml b/JsoupXpath/src/main/AndroidManifest.xml deleted file mode 100644 index 2710c9ef1..000000000 --- a/JsoupXpath/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/JXDocument.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/JXDocument.java deleted file mode 100644 index a67d5d085..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/JXDocument.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.seimicrawler.xpath; - -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.tree.ParseTree; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.antlr.XpathLexer; -import org.seimicrawler.xpath.antlr.XpathParser; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.core.XpathProcessor; -import org.seimicrawler.xpath.exception.DoFailOnErrorHandler; -import org.seimicrawler.xpath.exception.XpathParserException; -import org.seimicrawler.xpath.exception.XpathSyntaxErrorException; - -import java.util.LinkedList; -import java.util.List; - -/* - Copyright 2014 Wang Haomiao - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - */ -public class JXDocument { - private final Elements elements; - - public JXDocument(Elements els) { - elements = els; - } - - public static JXDocument create(Document doc) { - Elements els = doc.children(); - return new JXDocument(els); - } - - public static JXDocument create(Elements els) { - return new JXDocument(els); - } - - public static JXDocument create(String html) { - Elements els = Jsoup.parse(html).children(); - return new JXDocument(els); - } - - public static JXDocument createByUrl(String url) { - Elements els; - try { - els = Jsoup.connect(url).get().children(); - } catch (Exception e) { - throw new XpathParserException("url资源获取失败", e); - } - return new JXDocument(els); - } - - public List sel(String xpath) { - List res = new LinkedList<>(); - for (JXNode node : selN(xpath)) { - if (node.isElement()) { - res.add(node.asElement()); - } else { - res.add(node.toString()); - } - } - return res; - } - - public List selN(String xpath) { - List finalRes = new LinkedList<>(); - try { - CharStream input = CharStreams.fromString(xpath); - XpathLexer lexer = new XpathLexer(input); - CommonTokenStream tokens = new CommonTokenStream(lexer); - XpathParser parser = new XpathParser(tokens); - parser.setErrorHandler(new DoFailOnErrorHandler()); - ParseTree tree = parser.main(); - XpathProcessor processor = new XpathProcessor(elements); - XValue calRes = processor.visit(tree); - - if (calRes.isElements()) { - for (Element el : calRes.asElements()) { - finalRes.add(JXNode.create(el)); - } - return finalRes; - } - if (calRes.isList()) { - for (String str : calRes.asList()) { - finalRes.add(JXNode.create(str)); - } - return finalRes; - } - if (calRes.isString()) { - finalRes.add(JXNode.create(calRes.asString())); - return finalRes; - } - if (calRes.isNumber()) { - finalRes.add(JXNode.create(calRes.asDouble())); - return finalRes; - } - if (calRes.isBoolean()) { - finalRes.add(JXNode.create(calRes.asBoolean())); - return finalRes; - } - if (calRes.isDate()) { - finalRes.add(JXNode.create(calRes.asDate())); - return finalRes; - } - finalRes.add(JXNode.create(calRes.asString())); - } catch (Exception e) { - String msg = "Please check the syntax of your xpath expr or commit a "; - throw new XpathSyntaxErrorException(msg + ExceptionUtils.getRootCauseMessage(e), e); - } - return finalRes; - } - - public Object selOne(String xpath) { - JXNode jxNode = selNOne(xpath); - if (jxNode != null) { - if (jxNode.isElement()) { - return jxNode.asElement(); - } else { - return jxNode.toString(); - } - } - return null; - } - - public JXNode selNOne(String xpath) { - List jxNodeList = selN(xpath); - if (jxNodeList != null && jxNodeList.size() > 0) { - return jxNodeList.get(0); - } - return null; - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/JXNode.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/JXNode.java deleted file mode 100644 index 255a8dde1..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/JXNode.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.seimicrawler.xpath; -/* - Copyright 2014 Wang Haomiao - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.Constants; - -import java.util.Date; -import java.util.List; -import java.util.Objects; - -/** - * XPath提取后的 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2016/5/12. - */ -public class JXNode { - private final Object value; - - public JXNode(Object val) { - this.value = val; - } - - public boolean isElement() { - return value instanceof Element; - } - - public Element asElement() { - return (Element) value; - } - - public boolean isString() { - return value instanceof String; - } - - public String asString() { - if (isString()) { - return (String) value; - } else if (isElement()) { - Element e = (Element) value; - if (Objects.equals(e.tagName(), Constants.DEF_TEXT_TAG_NAME)) { - return e.ownText(); - } else { - return e.toString(); - } - } else { - return String.valueOf(value); - } - } - - public boolean isNumber() { - return value instanceof Number; - } - - public Double asDouble() { - return (Double) value; - } - - public boolean isBoolean() { - return value instanceof Boolean; - } - - public Boolean asBoolean() { - return (Boolean) value; - } - - public boolean isDate() { - return value instanceof Date; - } - - public Date asDate() { - return (Date) value; - } - - public List sel(String xpath) { - if (!isElement()) { - return null; - } - JXDocument doc = new JXDocument(new Elements(asElement())); - return doc.selN(xpath); - } - - public JXNode selOne(String xpath) { - List jxNodeList = sel(xpath); - if (jxNodeList != null && jxNodeList.size() > 0) { - return jxNodeList.get(0); - } - return null; - } - - public static JXNode create(Object val) { - return new JXNode(val); - } - - @Override - public String toString() { - return asString(); - } - - public Object value() { - if (isElement()) { - return asElement(); - } - if (isBoolean()) { - return asBoolean(); - } - if (isNumber()) { - return asDouble(); - } - if (isDate()) { - return asDate(); - } - return asString(); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.interp b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.interp deleted file mode 100644 index 6b795019e..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.interp +++ /dev/null @@ -1,120 +0,0 @@ -token literal names: -null -'processing-instruction' -'or' -'and' -'$' -null -null -null -'/' -'//' -'(' -')' -'[' -']' -'-' -'+' -'.' -'*' -'`div`' -'`mod`' -'..' -'@' -',' -'|' -'<' -'>' -'<=' -'>=' -'=' -'!=' -'^=' -'$=' -'*=' -'~=' -'!~' -':' -'::' -'\'' -'"' -null -null -null - -token symbolic names: -null -null -null -null -null -NodeType -Number -AxisName -PATHSEP -ABRPATH -LPAR -RPAR -LBRAC -RBRAC -MINUS -PLUS -DOT -MUL -DIVISION -MODULO -DOTDOT -AT -COMMA -PIPE -LESS -MORE_ -LE -GE -EQUALITY -INEQUALITY -START_WITH -END_WITH -CONTAIN_WITH -REGEXP_WITH -REGEXP_NOT_WITH -COLON -CC -APOS -QUOT -Literal -Whitespace -NCName - -rule names: -main -locationPath -absoluteLocationPathNoroot -relativeLocationPath -step -axisSpecifier -nodeTest -predicate -abbreviatedStep -expr -primaryExpr -functionCall -unionExprNoRoot -pathExprNoRoot -filterExpr -orExpr -andExpr -equalityExpr -relationalExpr -additiveExpr -multiplicativeExpr -unaryExprNoRoot -qName -functionName -variableReference -nameTest -nCName - - -atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 43, 229, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 3, 2, 3, 2, 3, 3, 3, 3, 5, 3, 61, 10, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 7, 5, 69, 10, 5, 12, 5, 14, 5, 72, 11, 5, 3, 6, 3, 6, 3, 6, 7, 6, 77, 10, 6, 12, 6, 14, 6, 80, 11, 6, 3, 6, 5, 6, 83, 10, 6, 3, 7, 3, 7, 3, 7, 5, 7, 88, 10, 7, 5, 7, 90, 10, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 5, 8, 100, 10, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 118, 10, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 7, 13, 125, 10, 13, 12, 13, 14, 13, 128, 11, 13, 5, 13, 130, 10, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 5, 14, 137, 10, 14, 3, 14, 3, 14, 3, 14, 5, 14, 142, 10, 14, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 148, 10, 15, 5, 15, 150, 10, 15, 3, 16, 3, 16, 7, 16, 154, 10, 16, 12, 16, 14, 16, 157, 11, 16, 3, 17, 3, 17, 3, 17, 7, 17, 162, 10, 17, 12, 17, 14, 17, 165, 11, 17, 3, 18, 3, 18, 3, 18, 7, 18, 170, 10, 18, 12, 18, 14, 18, 173, 11, 18, 3, 19, 3, 19, 3, 19, 7, 19, 178, 10, 19, 12, 19, 14, 19, 181, 11, 19, 3, 20, 3, 20, 3, 20, 7, 20, 186, 10, 20, 12, 20, 14, 20, 189, 11, 20, 3, 21, 3, 21, 3, 21, 7, 21, 194, 10, 21, 12, 21, 14, 21, 197, 11, 21, 3, 22, 3, 22, 3, 22, 5, 22, 202, 10, 22, 3, 23, 5, 23, 205, 10, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 5, 24, 212, 10, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 5, 27, 225, 10, 27, 3, 28, 3, 28, 3, 28, 2, 2, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 2, 9, 3, 2, 10, 11, 4, 2, 18, 18, 22, 22, 3, 2, 30, 31, 5, 2, 26, 27, 29, 29, 32, 36, 3, 2, 16, 17, 3, 2, 19, 21, 4, 2, 9, 9, 43, 43, 2, 230, 2, 56, 3, 2, 2, 2, 4, 60, 3, 2, 2, 2, 6, 62, 3, 2, 2, 2, 8, 65, 3, 2, 2, 2, 10, 82, 3, 2, 2, 2, 12, 89, 3, 2, 2, 2, 14, 99, 3, 2, 2, 2, 16, 101, 3, 2, 2, 2, 18, 105, 3, 2, 2, 2, 20, 107, 3, 2, 2, 2, 22, 117, 3, 2, 2, 2, 24, 119, 3, 2, 2, 2, 26, 141, 3, 2, 2, 2, 28, 149, 3, 2, 2, 2, 30, 151, 3, 2, 2, 2, 32, 158, 3, 2, 2, 2, 34, 166, 3, 2, 2, 2, 36, 174, 3, 2, 2, 2, 38, 182, 3, 2, 2, 2, 40, 190, 3, 2, 2, 2, 42, 198, 3, 2, 2, 2, 44, 204, 3, 2, 2, 2, 46, 208, 3, 2, 2, 2, 48, 213, 3, 2, 2, 2, 50, 215, 3, 2, 2, 2, 52, 224, 3, 2, 2, 2, 54, 226, 3, 2, 2, 2, 56, 57, 5, 20, 11, 2, 57, 3, 3, 2, 2, 2, 58, 61, 5, 8, 5, 2, 59, 61, 5, 6, 4, 2, 60, 58, 3, 2, 2, 2, 60, 59, 3, 2, 2, 2, 61, 5, 3, 2, 2, 2, 62, 63, 9, 2, 2, 2, 63, 64, 5, 8, 5, 2, 64, 7, 3, 2, 2, 2, 65, 70, 5, 10, 6, 2, 66, 67, 9, 2, 2, 2, 67, 69, 5, 10, 6, 2, 68, 66, 3, 2, 2, 2, 69, 72, 3, 2, 2, 2, 70, 68, 3, 2, 2, 2, 70, 71, 3, 2, 2, 2, 71, 9, 3, 2, 2, 2, 72, 70, 3, 2, 2, 2, 73, 74, 5, 12, 7, 2, 74, 78, 5, 14, 8, 2, 75, 77, 5, 16, 9, 2, 76, 75, 3, 2, 2, 2, 77, 80, 3, 2, 2, 2, 78, 76, 3, 2, 2, 2, 78, 79, 3, 2, 2, 2, 79, 83, 3, 2, 2, 2, 80, 78, 3, 2, 2, 2, 81, 83, 5, 18, 10, 2, 82, 73, 3, 2, 2, 2, 82, 81, 3, 2, 2, 2, 83, 11, 3, 2, 2, 2, 84, 85, 7, 9, 2, 2, 85, 90, 7, 38, 2, 2, 86, 88, 7, 23, 2, 2, 87, 86, 3, 2, 2, 2, 87, 88, 3, 2, 2, 2, 88, 90, 3, 2, 2, 2, 89, 84, 3, 2, 2, 2, 89, 87, 3, 2, 2, 2, 90, 13, 3, 2, 2, 2, 91, 100, 5, 52, 27, 2, 92, 93, 7, 7, 2, 2, 93, 94, 7, 12, 2, 2, 94, 100, 7, 13, 2, 2, 95, 96, 7, 3, 2, 2, 96, 97, 7, 12, 2, 2, 97, 98, 7, 41, 2, 2, 98, 100, 7, 13, 2, 2, 99, 91, 3, 2, 2, 2, 99, 92, 3, 2, 2, 2, 99, 95, 3, 2, 2, 2, 100, 15, 3, 2, 2, 2, 101, 102, 7, 14, 2, 2, 102, 103, 5, 20, 11, 2, 103, 104, 7, 15, 2, 2, 104, 17, 3, 2, 2, 2, 105, 106, 9, 3, 2, 2, 106, 19, 3, 2, 2, 2, 107, 108, 5, 32, 17, 2, 108, 21, 3, 2, 2, 2, 109, 118, 5, 50, 26, 2, 110, 111, 7, 12, 2, 2, 111, 112, 5, 20, 11, 2, 112, 113, 7, 13, 2, 2, 113, 118, 3, 2, 2, 2, 114, 118, 7, 41, 2, 2, 115, 118, 7, 8, 2, 2, 116, 118, 5, 24, 13, 2, 117, 109, 3, 2, 2, 2, 117, 110, 3, 2, 2, 2, 117, 114, 3, 2, 2, 2, 117, 115, 3, 2, 2, 2, 117, 116, 3, 2, 2, 2, 118, 23, 3, 2, 2, 2, 119, 120, 5, 48, 25, 2, 120, 129, 7, 12, 2, 2, 121, 126, 5, 20, 11, 2, 122, 123, 7, 24, 2, 2, 123, 125, 5, 20, 11, 2, 124, 122, 3, 2, 2, 2, 125, 128, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 126, 127, 3, 2, 2, 2, 127, 130, 3, 2, 2, 2, 128, 126, 3, 2, 2, 2, 129, 121, 3, 2, 2, 2, 129, 130, 3, 2, 2, 2, 130, 131, 3, 2, 2, 2, 131, 132, 7, 13, 2, 2, 132, 25, 3, 2, 2, 2, 133, 136, 5, 28, 15, 2, 134, 135, 7, 25, 2, 2, 135, 137, 5, 26, 14, 2, 136, 134, 3, 2, 2, 2, 136, 137, 3, 2, 2, 2, 137, 142, 3, 2, 2, 2, 138, 139, 7, 10, 2, 2, 139, 140, 7, 25, 2, 2, 140, 142, 5, 26, 14, 2, 141, 133, 3, 2, 2, 2, 141, 138, 3, 2, 2, 2, 142, 27, 3, 2, 2, 2, 143, 150, 5, 4, 3, 2, 144, 147, 5, 30, 16, 2, 145, 146, 9, 2, 2, 2, 146, 148, 5, 8, 5, 2, 147, 145, 3, 2, 2, 2, 147, 148, 3, 2, 2, 2, 148, 150, 3, 2, 2, 2, 149, 143, 3, 2, 2, 2, 149, 144, 3, 2, 2, 2, 150, 29, 3, 2, 2, 2, 151, 155, 5, 22, 12, 2, 152, 154, 5, 16, 9, 2, 153, 152, 3, 2, 2, 2, 154, 157, 3, 2, 2, 2, 155, 153, 3, 2, 2, 2, 155, 156, 3, 2, 2, 2, 156, 31, 3, 2, 2, 2, 157, 155, 3, 2, 2, 2, 158, 163, 5, 34, 18, 2, 159, 160, 7, 4, 2, 2, 160, 162, 5, 34, 18, 2, 161, 159, 3, 2, 2, 2, 162, 165, 3, 2, 2, 2, 163, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 33, 3, 2, 2, 2, 165, 163, 3, 2, 2, 2, 166, 171, 5, 36, 19, 2, 167, 168, 7, 5, 2, 2, 168, 170, 5, 36, 19, 2, 169, 167, 3, 2, 2, 2, 170, 173, 3, 2, 2, 2, 171, 169, 3, 2, 2, 2, 171, 172, 3, 2, 2, 2, 172, 35, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 174, 179, 5, 38, 20, 2, 175, 176, 9, 4, 2, 2, 176, 178, 5, 38, 20, 2, 177, 175, 3, 2, 2, 2, 178, 181, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2, 179, 180, 3, 2, 2, 2, 180, 37, 3, 2, 2, 2, 181, 179, 3, 2, 2, 2, 182, 187, 5, 40, 21, 2, 183, 184, 9, 5, 2, 2, 184, 186, 5, 40, 21, 2, 185, 183, 3, 2, 2, 2, 186, 189, 3, 2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 39, 3, 2, 2, 2, 189, 187, 3, 2, 2, 2, 190, 195, 5, 42, 22, 2, 191, 192, 9, 6, 2, 2, 192, 194, 5, 42, 22, 2, 193, 191, 3, 2, 2, 2, 194, 197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 41, 3, 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 201, 5, 44, 23, 2, 199, 200, 9, 7, 2, 2, 200, 202, 5, 42, 22, 2, 201, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 43, 3, 2, 2, 2, 203, 205, 7, 16, 2, 2, 204, 203, 3, 2, 2, 2, 204, 205, 3, 2, 2, 2, 205, 206, 3, 2, 2, 2, 206, 207, 5, 26, 14, 2, 207, 45, 3, 2, 2, 2, 208, 211, 5, 54, 28, 2, 209, 210, 7, 37, 2, 2, 210, 212, 5, 54, 28, 2, 211, 209, 3, 2, 2, 2, 211, 212, 3, 2, 2, 2, 212, 47, 3, 2, 2, 2, 213, 214, 5, 46, 24, 2, 214, 49, 3, 2, 2, 2, 215, 216, 7, 6, 2, 2, 216, 217, 5, 46, 24, 2, 217, 51, 3, 2, 2, 2, 218, 225, 7, 19, 2, 2, 219, 220, 5, 54, 28, 2, 220, 221, 7, 37, 2, 2, 221, 222, 7, 19, 2, 2, 222, 225, 3, 2, 2, 2, 223, 225, 5, 46, 24, 2, 224, 218, 3, 2, 2, 2, 224, 219, 3, 2, 2, 2, 224, 223, 3, 2, 2, 2, 225, 53, 3, 2, 2, 2, 226, 227, 9, 8, 2, 2, 227, 55, 3, 2, 2, 2, 26, 60, 70, 78, 82, 87, 89, 99, 117, 126, 129, 136, 141, 147, 149, 155, 163, 171, 179, 187, 195, 201, 204, 211, 224] \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.tokens b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.tokens deleted file mode 100644 index 79142cd34..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/Xpath.tokens +++ /dev/null @@ -1,76 +0,0 @@ -T__0=1 -T__1=2 -T__2=3 -T__3=4 -NodeType=5 -Number=6 -AxisName=7 -PATHSEP=8 -ABRPATH=9 -LPAR=10 -RPAR=11 -LBRAC=12 -RBRAC=13 -MINUS=14 -PLUS=15 -DOT=16 -MUL=17 -DIVISION=18 -MODULO=19 -DOTDOT=20 -AT=21 -COMMA=22 -PIPE=23 -LESS=24 -MORE_=25 -LE=26 -GE=27 -EQUALITY=28 -INEQUALITY=29 -START_WITH=30 -END_WITH=31 -CONTAIN_WITH=32 -REGEXP_WITH=33 -REGEXP_NOT_WITH=34 -COLON=35 -CC=36 -APOS=37 -QUOT=38 -Literal=39 -Whitespace=40 -NCName=41 -'processing-instruction'=1 -'or'=2 -'and'=3 -'$'=4 -'/'=8 -'//'=9 -'('=10 -')'=11 -'['=12 -']'=13 -'-'=14 -'+'=15 -'.'=16 -'*'=17 -'`div`'=18 -'`mod`'=19 -'..'=20 -'@'=21 -','=22 -'|'=23 -'<'=24 -'>'=25 -'<='=26 -'>='=27 -'='=28 -'!='=29 -'^='=30 -'$='=31 -'*='=32 -'~='=33 -'!~'=34 -':'=35 -'::'=36 -'\''=37 -'"'=38 diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseListener.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseListener.java deleted file mode 100644 index cf05c7e57..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseListener.java +++ /dev/null @@ -1,535 +0,0 @@ -// Generated from resources/Xpath.g4 by ANTLR 4.7.2 -package org.seimicrawler.xpath.antlr; - -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.tree.ErrorNode; -import org.antlr.v4.runtime.tree.TerminalNode; - -/** - * This class provides an empty implementation of {@link XpathListener}, - * which can be extended to create a listener which only needs to handle a subset - * of the available methods. - */ -public class XpathBaseListener implements XpathListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterMain(XpathParser.MainContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitMain(XpathParser.MainContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterLocationPath(XpathParser.LocationPathContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitLocationPath(XpathParser.LocationPathContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterStep(XpathParser.StepContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitStep(XpathParser.StepContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterAxisSpecifier(XpathParser.AxisSpecifierContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitAxisSpecifier(XpathParser.AxisSpecifierContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterNodeTest(XpathParser.NodeTestContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitNodeTest(XpathParser.NodeTestContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterPredicate(XpathParser.PredicateContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitPredicate(XpathParser.PredicateContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterExpr(XpathParser.ExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitExpr(XpathParser.ExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterPrimaryExpr(XpathParser.PrimaryExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitPrimaryExpr(XpathParser.PrimaryExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterFunctionCall(XpathParser.FunctionCallContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitFunctionCall(XpathParser.FunctionCallContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterPathExprNoRoot(XpathParser.PathExprNoRootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitPathExprNoRoot(XpathParser.PathExprNoRootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterFilterExpr(XpathParser.FilterExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitFilterExpr(XpathParser.FilterExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterOrExpr(XpathParser.OrExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitOrExpr(XpathParser.OrExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterAndExpr(XpathParser.AndExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitAndExpr(XpathParser.AndExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterEqualityExpr(XpathParser.EqualityExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitEqualityExpr(XpathParser.EqualityExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterRelationalExpr(XpathParser.RelationalExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitRelationalExpr(XpathParser.RelationalExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterAdditiveExpr(XpathParser.AdditiveExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitAdditiveExpr(XpathParser.AdditiveExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterQName(XpathParser.QNameContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitQName(XpathParser.QNameContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterFunctionName(XpathParser.FunctionNameContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitFunctionName(XpathParser.FunctionNameContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterVariableReference(XpathParser.VariableReferenceContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitVariableReference(XpathParser.VariableReferenceContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterNameTest(XpathParser.NameTestContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitNameTest(XpathParser.NameTestContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterNCName(XpathParser.NCNameContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitNCName(XpathParser.NCNameContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void enterEveryRule(ParserRuleContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void exitEveryRule(ParserRuleContext ctx) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void visitTerminal(TerminalNode node) { - } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override - public void visitErrorNode(ErrorNode node) { - } -} \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseVisitor.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseVisitor.java deleted file mode 100644 index dca29eb56..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathBaseVisitor.java +++ /dev/null @@ -1,311 +0,0 @@ -// Generated from resources/Xpath.g4 by ANTLR 4.7.2 -package org.seimicrawler.xpath.antlr; - -import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; - -/** - * This class provides an empty implementation of {@link XpathVisitor}, - * which can be extended to create a visitor which only needs to handle a subset - * of the available methods. - * - * @param The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public class XpathBaseVisitor extends AbstractParseTreeVisitor implements XpathVisitor { - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitMain(XpathParser.MainContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitLocationPath(XpathParser.LocationPathContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitStep(XpathParser.StepContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitAxisSpecifier(XpathParser.AxisSpecifierContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitNodeTest(XpathParser.NodeTestContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitPredicate(XpathParser.PredicateContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitExpr(XpathParser.ExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitPrimaryExpr(XpathParser.PrimaryExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitFunctionCall(XpathParser.FunctionCallContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitPathExprNoRoot(XpathParser.PathExprNoRootContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitFilterExpr(XpathParser.FilterExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitOrExpr(XpathParser.OrExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitAndExpr(XpathParser.AndExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitEqualityExpr(XpathParser.EqualityExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitRelationalExpr(XpathParser.RelationalExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitAdditiveExpr(XpathParser.AdditiveExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitQName(XpathParser.QNameContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitFunctionName(XpathParser.FunctionNameContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitVariableReference(XpathParser.VariableReferenceContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitNameTest(XpathParser.NameTestContext ctx) { - return visitChildren(ctx); - } - - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override - public T visitNCName(XpathParser.NCNameContext ctx) { - return visitChildren(ctx); - } -} \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.interp b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.interp deleted file mode 100644 index 464993d51..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.interp +++ /dev/null @@ -1,143 +0,0 @@ -token literal names: -null -'processing-instruction' -'or' -'and' -'$' -null -null -null -'/' -'//' -'(' -')' -'[' -']' -'-' -'+' -'.' -'*' -'`div`' -'`mod`' -'..' -'@' -',' -'|' -'<' -'>' -'<=' -'>=' -'=' -'!=' -'^=' -'$=' -'*=' -'~=' -'!~' -':' -'::' -'\'' -'"' -null -null -null - -token symbolic names: -null -null -null -null -null -NodeType -Number -AxisName -PATHSEP -ABRPATH -LPAR -RPAR -LBRAC -RBRAC -MINUS -PLUS -DOT -MUL -DIVISION -MODULO -DOTDOT -AT -COMMA -PIPE -LESS -MORE_ -LE -GE -EQUALITY -INEQUALITY -START_WITH -END_WITH -CONTAIN_WITH -REGEXP_WITH -REGEXP_NOT_WITH -COLON -CC -APOS -QUOT -Literal -Whitespace -NCName - -rule names: -T__0 -T__1 -T__2 -T__3 -NodeType -Number -Digits -AxisName -PATHSEP -ABRPATH -LPAR -RPAR -LBRAC -RBRAC -MINUS -PLUS -DOT -MUL -DIVISION -MODULO -DOTDOT -AT -COMMA -PIPE -LESS -MORE_ -LE -GE -EQUALITY -INEQUALITY -START_WITH -END_WITH -CONTAIN_WITH -REGEXP_WITH -REGEXP_NOT_WITH -COLON -CC -APOS -QUOT -Literal -Whitespace -NCName -NCNameStartChar -NCNameChar - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 43, 499, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 184, 10, 6, 3, 7, 3, 7, 3, 7, 5, 7, 189, 10, 7, 5, 7, 191, 10, 7, 3, 7, 3, 7, 5, 7, 195, 10, 7, 3, 8, 6, 8, 198, 10, 8, 13, 8, 14, 8, 199, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 5, 9, 379, 10, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 3, 41, 3, 41, 7, 41, 464, 10, 41, 12, 41, 14, 41, 467, 11, 41, 3, 41, 3, 41, 3, 41, 7, 41, 472, 10, 41, 12, 41, 14, 41, 475, 11, 41, 3, 41, 5, 41, 478, 10, 41, 3, 42, 6, 42, 481, 10, 42, 13, 42, 14, 42, 482, 3, 42, 3, 42, 3, 43, 3, 43, 7, 43, 489, 10, 43, 12, 43, 14, 43, 492, 11, 43, 3, 44, 3, 44, 3, 45, 3, 45, 5, 45, 498, 10, 45, 2, 2, 46, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 2, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 2, 89, 2, 3, 2, 7, 3, 2, 36, 36, 3, 2, 41, 41, 5, 2, 11, 12, 15, 15, 34, 34, 16, 2, 67, 92, 97, 97, 99, 124, 194, 216, 218, 248, 250, 769, 882, 895, 897, 8193, 8206, 8207, 8306, 8593, 11266, 12273, 12291, 55297, 63746, 64977, 65010, 65535, 7, 2, 47, 48, 50, 59, 185, 185, 770, 881, 8257, 8258, 2, 526, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 3, 91, 3, 2, 2, 2, 5, 114, 3, 2, 2, 2, 7, 117, 3, 2, 2, 2, 9, 121, 3, 2, 2, 2, 11, 183, 3, 2, 2, 2, 13, 194, 3, 2, 2, 2, 15, 197, 3, 2, 2, 2, 17, 378, 3, 2, 2, 2, 19, 380, 3, 2, 2, 2, 21, 382, 3, 2, 2, 2, 23, 385, 3, 2, 2, 2, 25, 387, 3, 2, 2, 2, 27, 389, 3, 2, 2, 2, 29, 391, 3, 2, 2, 2, 31, 393, 3, 2, 2, 2, 33, 395, 3, 2, 2, 2, 35, 397, 3, 2, 2, 2, 37, 399, 3, 2, 2, 2, 39, 401, 3, 2, 2, 2, 41, 407, 3, 2, 2, 2, 43, 413, 3, 2, 2, 2, 45, 416, 3, 2, 2, 2, 47, 418, 3, 2, 2, 2, 49, 420, 3, 2, 2, 2, 51, 422, 3, 2, 2, 2, 53, 424, 3, 2, 2, 2, 55, 426, 3, 2, 2, 2, 57, 429, 3, 2, 2, 2, 59, 432, 3, 2, 2, 2, 61, 434, 3, 2, 2, 2, 63, 437, 3, 2, 2, 2, 65, 440, 3, 2, 2, 2, 67, 443, 3, 2, 2, 2, 69, 446, 3, 2, 2, 2, 71, 449, 3, 2, 2, 2, 73, 452, 3, 2, 2, 2, 75, 454, 3, 2, 2, 2, 77, 457, 3, 2, 2, 2, 79, 459, 3, 2, 2, 2, 81, 477, 3, 2, 2, 2, 83, 480, 3, 2, 2, 2, 85, 486, 3, 2, 2, 2, 87, 493, 3, 2, 2, 2, 89, 497, 3, 2, 2, 2, 91, 92, 7, 114, 2, 2, 92, 93, 7, 116, 2, 2, 93, 94, 7, 113, 2, 2, 94, 95, 7, 101, 2, 2, 95, 96, 7, 103, 2, 2, 96, 97, 7, 117, 2, 2, 97, 98, 7, 117, 2, 2, 98, 99, 7, 107, 2, 2, 99, 100, 7, 112, 2, 2, 100, 101, 7, 105, 2, 2, 101, 102, 7, 47, 2, 2, 102, 103, 7, 107, 2, 2, 103, 104, 7, 112, 2, 2, 104, 105, 7, 117, 2, 2, 105, 106, 7, 118, 2, 2, 106, 107, 7, 116, 2, 2, 107, 108, 7, 119, 2, 2, 108, 109, 7, 101, 2, 2, 109, 110, 7, 118, 2, 2, 110, 111, 7, 107, 2, 2, 111, 112, 7, 113, 2, 2, 112, 113, 7, 112, 2, 2, 113, 4, 3, 2, 2, 2, 114, 115, 7, 113, 2, 2, 115, 116, 7, 116, 2, 2, 116, 6, 3, 2, 2, 2, 117, 118, 7, 99, 2, 2, 118, 119, 7, 112, 2, 2, 119, 120, 7, 102, 2, 2, 120, 8, 3, 2, 2, 2, 121, 122, 7, 38, 2, 2, 122, 10, 3, 2, 2, 2, 123, 124, 7, 101, 2, 2, 124, 125, 7, 113, 2, 2, 125, 126, 7, 111, 2, 2, 126, 127, 7, 111, 2, 2, 127, 128, 7, 103, 2, 2, 128, 129, 7, 112, 2, 2, 129, 184, 7, 118, 2, 2, 130, 131, 7, 118, 2, 2, 131, 132, 7, 103, 2, 2, 132, 133, 7, 122, 2, 2, 133, 184, 7, 118, 2, 2, 134, 135, 7, 114, 2, 2, 135, 136, 7, 116, 2, 2, 136, 137, 7, 113, 2, 2, 137, 138, 7, 101, 2, 2, 138, 139, 7, 103, 2, 2, 139, 140, 7, 117, 2, 2, 140, 141, 7, 117, 2, 2, 141, 142, 7, 107, 2, 2, 142, 143, 7, 112, 2, 2, 143, 144, 7, 105, 2, 2, 144, 145, 7, 47, 2, 2, 145, 146, 7, 107, 2, 2, 146, 147, 7, 112, 2, 2, 147, 148, 7, 117, 2, 2, 148, 149, 7, 118, 2, 2, 149, 150, 7, 116, 2, 2, 150, 151, 7, 119, 2, 2, 151, 152, 7, 101, 2, 2, 152, 153, 7, 118, 2, 2, 153, 154, 7, 107, 2, 2, 154, 155, 7, 113, 2, 2, 155, 184, 7, 112, 2, 2, 156, 157, 7, 112, 2, 2, 157, 158, 7, 113, 2, 2, 158, 159, 7, 102, 2, 2, 159, 184, 7, 103, 2, 2, 160, 161, 7, 112, 2, 2, 161, 162, 7, 119, 2, 2, 162, 184, 7, 111, 2, 2, 163, 164, 7, 99, 2, 2, 164, 165, 7, 110, 2, 2, 165, 166, 7, 110, 2, 2, 166, 167, 7, 86, 2, 2, 167, 168, 7, 103, 2, 2, 168, 169, 7, 122, 2, 2, 169, 184, 7, 118, 2, 2, 170, 171, 7, 113, 2, 2, 171, 172, 7, 119, 2, 2, 172, 173, 7, 118, 2, 2, 173, 174, 7, 103, 2, 2, 174, 175, 7, 116, 2, 2, 175, 176, 7, 74, 2, 2, 176, 177, 7, 118, 2, 2, 177, 178, 7, 111, 2, 2, 178, 184, 7, 110, 2, 2, 179, 180, 7, 106, 2, 2, 180, 181, 7, 118, 2, 2, 181, 182, 7, 111, 2, 2, 182, 184, 7, 110, 2, 2, 183, 123, 3, 2, 2, 2, 183, 130, 3, 2, 2, 2, 183, 134, 3, 2, 2, 2, 183, 156, 3, 2, 2, 2, 183, 160, 3, 2, 2, 2, 183, 163, 3, 2, 2, 2, 183, 170, 3, 2, 2, 2, 183, 179, 3, 2, 2, 2, 184, 12, 3, 2, 2, 2, 185, 190, 5, 15, 8, 2, 186, 188, 7, 48, 2, 2, 187, 189, 5, 15, 8, 2, 188, 187, 3, 2, 2, 2, 188, 189, 3, 2, 2, 2, 189, 191, 3, 2, 2, 2, 190, 186, 3, 2, 2, 2, 190, 191, 3, 2, 2, 2, 191, 195, 3, 2, 2, 2, 192, 193, 7, 48, 2, 2, 193, 195, 5, 15, 8, 2, 194, 185, 3, 2, 2, 2, 194, 192, 3, 2, 2, 2, 195, 14, 3, 2, 2, 2, 196, 198, 4, 50, 59, 2, 197, 196, 3, 2, 2, 2, 198, 199, 3, 2, 2, 2, 199, 197, 3, 2, 2, 2, 199, 200, 3, 2, 2, 2, 200, 16, 3, 2, 2, 2, 201, 202, 7, 99, 2, 2, 202, 203, 7, 112, 2, 2, 203, 204, 7, 101, 2, 2, 204, 205, 7, 103, 2, 2, 205, 206, 7, 117, 2, 2, 206, 207, 7, 118, 2, 2, 207, 208, 7, 113, 2, 2, 208, 379, 7, 116, 2, 2, 209, 210, 7, 99, 2, 2, 210, 211, 7, 112, 2, 2, 211, 212, 7, 101, 2, 2, 212, 213, 7, 103, 2, 2, 213, 214, 7, 117, 2, 2, 214, 215, 7, 118, 2, 2, 215, 216, 7, 113, 2, 2, 216, 217, 7, 116, 2, 2, 217, 218, 7, 47, 2, 2, 218, 219, 7, 113, 2, 2, 219, 220, 7, 116, 2, 2, 220, 221, 7, 47, 2, 2, 221, 222, 7, 117, 2, 2, 222, 223, 7, 103, 2, 2, 223, 224, 7, 110, 2, 2, 224, 379, 7, 104, 2, 2, 225, 226, 7, 99, 2, 2, 226, 227, 7, 118, 2, 2, 227, 228, 7, 118, 2, 2, 228, 229, 7, 116, 2, 2, 229, 230, 7, 107, 2, 2, 230, 231, 7, 100, 2, 2, 231, 232, 7, 119, 2, 2, 232, 233, 7, 118, 2, 2, 233, 379, 7, 103, 2, 2, 234, 235, 7, 101, 2, 2, 235, 236, 7, 106, 2, 2, 236, 237, 7, 107, 2, 2, 237, 238, 7, 110, 2, 2, 238, 379, 7, 102, 2, 2, 239, 240, 7, 102, 2, 2, 240, 241, 7, 103, 2, 2, 241, 242, 7, 117, 2, 2, 242, 243, 7, 101, 2, 2, 243, 244, 7, 103, 2, 2, 244, 245, 7, 112, 2, 2, 245, 246, 7, 102, 2, 2, 246, 247, 7, 99, 2, 2, 247, 248, 7, 112, 2, 2, 248, 379, 7, 118, 2, 2, 249, 250, 7, 102, 2, 2, 250, 251, 7, 103, 2, 2, 251, 252, 7, 117, 2, 2, 252, 253, 7, 101, 2, 2, 253, 254, 7, 103, 2, 2, 254, 255, 7, 112, 2, 2, 255, 256, 7, 102, 2, 2, 256, 257, 7, 99, 2, 2, 257, 258, 7, 112, 2, 2, 258, 259, 7, 118, 2, 2, 259, 260, 7, 47, 2, 2, 260, 261, 7, 113, 2, 2, 261, 262, 7, 116, 2, 2, 262, 263, 7, 47, 2, 2, 263, 264, 7, 117, 2, 2, 264, 265, 7, 103, 2, 2, 265, 266, 7, 110, 2, 2, 266, 379, 7, 104, 2, 2, 267, 268, 7, 104, 2, 2, 268, 269, 7, 113, 2, 2, 269, 270, 7, 110, 2, 2, 270, 271, 7, 110, 2, 2, 271, 272, 7, 113, 2, 2, 272, 273, 7, 121, 2, 2, 273, 274, 7, 107, 2, 2, 274, 275, 7, 112, 2, 2, 275, 379, 7, 105, 2, 2, 276, 277, 7, 104, 2, 2, 277, 278, 7, 113, 2, 2, 278, 279, 7, 110, 2, 2, 279, 280, 7, 110, 2, 2, 280, 281, 7, 113, 2, 2, 281, 282, 7, 121, 2, 2, 282, 283, 7, 107, 2, 2, 283, 284, 7, 112, 2, 2, 284, 285, 7, 105, 2, 2, 285, 286, 7, 47, 2, 2, 286, 287, 7, 117, 2, 2, 287, 288, 7, 107, 2, 2, 288, 289, 7, 100, 2, 2, 289, 290, 7, 110, 2, 2, 290, 291, 7, 107, 2, 2, 291, 292, 7, 112, 2, 2, 292, 379, 7, 105, 2, 2, 293, 294, 7, 114, 2, 2, 294, 295, 7, 99, 2, 2, 295, 296, 7, 116, 2, 2, 296, 297, 7, 103, 2, 2, 297, 298, 7, 112, 2, 2, 298, 379, 7, 118, 2, 2, 299, 300, 7, 114, 2, 2, 300, 301, 7, 116, 2, 2, 301, 302, 7, 103, 2, 2, 302, 303, 7, 101, 2, 2, 303, 304, 7, 103, 2, 2, 304, 305, 7, 102, 2, 2, 305, 306, 7, 107, 2, 2, 306, 307, 7, 112, 2, 2, 307, 379, 7, 105, 2, 2, 308, 309, 7, 114, 2, 2, 309, 310, 7, 116, 2, 2, 310, 311, 7, 103, 2, 2, 311, 312, 7, 101, 2, 2, 312, 313, 7, 103, 2, 2, 313, 314, 7, 102, 2, 2, 314, 315, 7, 107, 2, 2, 315, 316, 7, 112, 2, 2, 316, 317, 7, 105, 2, 2, 317, 318, 7, 47, 2, 2, 318, 319, 7, 117, 2, 2, 319, 320, 7, 107, 2, 2, 320, 321, 7, 100, 2, 2, 321, 322, 7, 110, 2, 2, 322, 323, 7, 107, 2, 2, 323, 324, 7, 112, 2, 2, 324, 379, 7, 105, 2, 2, 325, 326, 7, 117, 2, 2, 326, 327, 7, 103, 2, 2, 327, 328, 7, 110, 2, 2, 328, 379, 7, 104, 2, 2, 329, 330, 7, 104, 2, 2, 330, 331, 7, 113, 2, 2, 331, 332, 7, 110, 2, 2, 332, 333, 7, 110, 2, 2, 333, 334, 7, 113, 2, 2, 334, 335, 7, 121, 2, 2, 335, 336, 7, 107, 2, 2, 336, 337, 7, 112, 2, 2, 337, 338, 7, 105, 2, 2, 338, 339, 7, 47, 2, 2, 339, 340, 7, 117, 2, 2, 340, 341, 7, 107, 2, 2, 341, 342, 7, 100, 2, 2, 342, 343, 7, 110, 2, 2, 343, 344, 7, 107, 2, 2, 344, 345, 7, 112, 2, 2, 345, 346, 7, 105, 2, 2, 346, 347, 7, 47, 2, 2, 347, 348, 7, 113, 2, 2, 348, 349, 7, 112, 2, 2, 349, 379, 7, 103, 2, 2, 350, 351, 7, 114, 2, 2, 351, 352, 7, 116, 2, 2, 352, 353, 7, 103, 2, 2, 353, 354, 7, 101, 2, 2, 354, 355, 7, 103, 2, 2, 355, 356, 7, 102, 2, 2, 356, 357, 7, 107, 2, 2, 357, 358, 7, 112, 2, 2, 358, 359, 7, 105, 2, 2, 359, 360, 7, 47, 2, 2, 360, 361, 7, 117, 2, 2, 361, 362, 7, 107, 2, 2, 362, 363, 7, 100, 2, 2, 363, 364, 7, 110, 2, 2, 364, 365, 7, 107, 2, 2, 365, 366, 7, 112, 2, 2, 366, 367, 7, 105, 2, 2, 367, 368, 7, 47, 2, 2, 368, 369, 7, 113, 2, 2, 369, 370, 7, 112, 2, 2, 370, 379, 7, 103, 2, 2, 371, 372, 7, 117, 2, 2, 372, 373, 7, 107, 2, 2, 373, 374, 7, 100, 2, 2, 374, 375, 7, 110, 2, 2, 375, 376, 7, 107, 2, 2, 376, 377, 7, 112, 2, 2, 377, 379, 7, 105, 2, 2, 378, 201, 3, 2, 2, 2, 378, 209, 3, 2, 2, 2, 378, 225, 3, 2, 2, 2, 378, 234, 3, 2, 2, 2, 378, 239, 3, 2, 2, 2, 378, 249, 3, 2, 2, 2, 378, 267, 3, 2, 2, 2, 378, 276, 3, 2, 2, 2, 378, 293, 3, 2, 2, 2, 378, 299, 3, 2, 2, 2, 378, 308, 3, 2, 2, 2, 378, 325, 3, 2, 2, 2, 378, 329, 3, 2, 2, 2, 378, 350, 3, 2, 2, 2, 378, 371, 3, 2, 2, 2, 379, 18, 3, 2, 2, 2, 380, 381, 7, 49, 2, 2, 381, 20, 3, 2, 2, 2, 382, 383, 7, 49, 2, 2, 383, 384, 7, 49, 2, 2, 384, 22, 3, 2, 2, 2, 385, 386, 7, 42, 2, 2, 386, 24, 3, 2, 2, 2, 387, 388, 7, 43, 2, 2, 388, 26, 3, 2, 2, 2, 389, 390, 7, 93, 2, 2, 390, 28, 3, 2, 2, 2, 391, 392, 7, 95, 2, 2, 392, 30, 3, 2, 2, 2, 393, 394, 7, 47, 2, 2, 394, 32, 3, 2, 2, 2, 395, 396, 7, 45, 2, 2, 396, 34, 3, 2, 2, 2, 397, 398, 7, 48, 2, 2, 398, 36, 3, 2, 2, 2, 399, 400, 7, 44, 2, 2, 400, 38, 3, 2, 2, 2, 401, 402, 7, 98, 2, 2, 402, 403, 7, 102, 2, 2, 403, 404, 7, 107, 2, 2, 404, 405, 7, 120, 2, 2, 405, 406, 7, 98, 2, 2, 406, 40, 3, 2, 2, 2, 407, 408, 7, 98, 2, 2, 408, 409, 7, 111, 2, 2, 409, 410, 7, 113, 2, 2, 410, 411, 7, 102, 2, 2, 411, 412, 7, 98, 2, 2, 412, 42, 3, 2, 2, 2, 413, 414, 7, 48, 2, 2, 414, 415, 7, 48, 2, 2, 415, 44, 3, 2, 2, 2, 416, 417, 7, 66, 2, 2, 417, 46, 3, 2, 2, 2, 418, 419, 7, 46, 2, 2, 419, 48, 3, 2, 2, 2, 420, 421, 7, 126, 2, 2, 421, 50, 3, 2, 2, 2, 422, 423, 7, 62, 2, 2, 423, 52, 3, 2, 2, 2, 424, 425, 7, 64, 2, 2, 425, 54, 3, 2, 2, 2, 426, 427, 7, 62, 2, 2, 427, 428, 7, 63, 2, 2, 428, 56, 3, 2, 2, 2, 429, 430, 7, 64, 2, 2, 430, 431, 7, 63, 2, 2, 431, 58, 3, 2, 2, 2, 432, 433, 7, 63, 2, 2, 433, 60, 3, 2, 2, 2, 434, 435, 7, 35, 2, 2, 435, 436, 7, 63, 2, 2, 436, 62, 3, 2, 2, 2, 437, 438, 7, 96, 2, 2, 438, 439, 7, 63, 2, 2, 439, 64, 3, 2, 2, 2, 440, 441, 7, 38, 2, 2, 441, 442, 7, 63, 2, 2, 442, 66, 3, 2, 2, 2, 443, 444, 7, 44, 2, 2, 444, 445, 7, 63, 2, 2, 445, 68, 3, 2, 2, 2, 446, 447, 7, 128, 2, 2, 447, 448, 7, 63, 2, 2, 448, 70, 3, 2, 2, 2, 449, 450, 7, 35, 2, 2, 450, 451, 7, 128, 2, 2, 451, 72, 3, 2, 2, 2, 452, 453, 7, 60, 2, 2, 453, 74, 3, 2, 2, 2, 454, 455, 7, 60, 2, 2, 455, 456, 7, 60, 2, 2, 456, 76, 3, 2, 2, 2, 457, 458, 7, 41, 2, 2, 458, 78, 3, 2, 2, 2, 459, 460, 7, 36, 2, 2, 460, 80, 3, 2, 2, 2, 461, 465, 7, 36, 2, 2, 462, 464, 10, 2, 2, 2, 463, 462, 3, 2, 2, 2, 464, 467, 3, 2, 2, 2, 465, 463, 3, 2, 2, 2, 465, 466, 3, 2, 2, 2, 466, 468, 3, 2, 2, 2, 467, 465, 3, 2, 2, 2, 468, 478, 7, 36, 2, 2, 469, 473, 7, 41, 2, 2, 470, 472, 10, 3, 2, 2, 471, 470, 3, 2, 2, 2, 472, 475, 3, 2, 2, 2, 473, 471, 3, 2, 2, 2, 473, 474, 3, 2, 2, 2, 474, 476, 3, 2, 2, 2, 475, 473, 3, 2, 2, 2, 476, 478, 7, 41, 2, 2, 477, 461, 3, 2, 2, 2, 477, 469, 3, 2, 2, 2, 478, 82, 3, 2, 2, 2, 479, 481, 9, 4, 2, 2, 480, 479, 3, 2, 2, 2, 481, 482, 3, 2, 2, 2, 482, 480, 3, 2, 2, 2, 482, 483, 3, 2, 2, 2, 483, 484, 3, 2, 2, 2, 484, 485, 8, 42, 2, 2, 485, 84, 3, 2, 2, 2, 486, 490, 5, 87, 44, 2, 487, 489, 5, 89, 45, 2, 488, 487, 3, 2, 2, 2, 489, 492, 3, 2, 2, 2, 490, 488, 3, 2, 2, 2, 490, 491, 3, 2, 2, 2, 491, 86, 3, 2, 2, 2, 492, 490, 3, 2, 2, 2, 493, 494, 9, 5, 2, 2, 494, 88, 3, 2, 2, 2, 495, 498, 5, 87, 44, 2, 496, 498, 9, 6, 2, 2, 497, 495, 3, 2, 2, 2, 497, 496, 3, 2, 2, 2, 498, 90, 3, 2, 2, 2, 15, 2, 183, 188, 190, 194, 199, 378, 465, 473, 477, 482, 490, 497, 3, 8, 2, 2] \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.java deleted file mode 100644 index 78c2667a5..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.java +++ /dev/null @@ -1,325 +0,0 @@ -// Generated from resources/Xpath.g4 by ANTLR 4.7.2 -package org.seimicrawler.xpath.antlr; - -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.LexerATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) -public class XpathLexer extends Lexer { - static { - RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); - } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, NodeType = 5, Number = 6, AxisName = 7, PATHSEP = 8, - ABRPATH = 9, LPAR = 10, RPAR = 11, LBRAC = 12, RBRAC = 13, MINUS = 14, PLUS = 15, DOT = 16, - MUL = 17, DIVISION = 18, MODULO = 19, DOTDOT = 20, AT = 21, COMMA = 22, PIPE = 23, LESS = 24, - MORE_ = 25, LE = 26, GE = 27, EQUALITY = 28, INEQUALITY = 29, START_WITH = 30, END_WITH = 31, - CONTAIN_WITH = 32, REGEXP_WITH = 33, REGEXP_NOT_WITH = 34, COLON = 35, CC = 36, - APOS = 37, QUOT = 38, Literal = 39, Whitespace = 40, NCName = 41; - public static String[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static String[] modeNames = { - "DEFAULT_MODE" - }; - - private static String[] makeRuleNames() { - return new String[]{ - "T__0", "T__1", "T__2", "T__3", "NodeType", "Number", "Digits", "AxisName", - "PATHSEP", "ABRPATH", "LPAR", "RPAR", "LBRAC", "RBRAC", "MINUS", "PLUS", - "DOT", "MUL", "DIVISION", "MODULO", "DOTDOT", "AT", "COMMA", "PIPE", - "LESS", "MORE_", "LE", "GE", "EQUALITY", "INEQUALITY", "START_WITH", - "END_WITH", "CONTAIN_WITH", "REGEXP_WITH", "REGEXP_NOT_WITH", "COLON", - "CC", "APOS", "QUOT", "Literal", "Whitespace", "NCName", "NCNameStartChar", - "NCNameChar" - }; - } - - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[]{ - null, "'processing-instruction'", "'or'", "'and'", "'$'", null, null, - null, "'/'", "'//'", "'('", "')'", "'['", "']'", "'-'", "'+'", "'.'", - "'*'", "'`div`'", "'`mod`'", "'..'", "'@'", "','", "'|'", "'<'", "'>'", - "'<='", "'>='", "'='", "'!='", "'^='", "'$='", "'*='", "'~='", "'!~'", - "':'", "'::'", "'''", "'\"'" - }; - } - - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - - private static String[] makeSymbolicNames() { - return new String[]{ - null, null, null, null, null, "NodeType", "Number", "AxisName", "PATHSEP", - "ABRPATH", "LPAR", "RPAR", "LBRAC", "RBRAC", "MINUS", "PLUS", "DOT", - "MUL", "DIVISION", "MODULO", "DOTDOT", "AT", "COMMA", "PIPE", "LESS", - "MORE_", "LE", "GE", "EQUALITY", "INEQUALITY", "START_WITH", "END_WITH", - "CONTAIN_WITH", "REGEXP_WITH", "REGEXP_NOT_WITH", "COLON", "CC", "APOS", - "QUOT", "Literal", "Whitespace", "NCName" - }; - } - - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - - public XpathLexer(CharStream input) { - super(input); - _interp = new LexerATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); - } - - @Override - public String getGrammarFileName() { - return "Xpath.g4"; - } - - @Override - public String[] getRuleNames() { - return ruleNames; - } - - @Override - public String getSerializedATN() { - return _serializedATN; - } - - @Override - public String[] getChannelNames() { - return channelNames; - } - - @Override - public String[] getModeNames() { - return modeNames; - } - - @Override - public ATN getATN() { - return _ATN; - } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2+\u01f3\b\1\4\2\t" + - "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13" + - "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" + - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4" + - ",\t,\4-\t-\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2" + - "\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\5\3\5\3" + - "\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6" + - "\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3" + - "\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6" + - "\3\6\3\6\3\6\3\6\3\6\3\6\3\6\5\6\u00b8\n\6\3\7\3\7\3\7\5\7\u00bd\n\7\5" + - "\7\u00bf\n\7\3\7\3\7\5\7\u00c3\n\7\3\b\6\b\u00c6\n\b\r\b\16\b\u00c7\3" + - "\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t" + - "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3" + - "\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t" + - "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3" + - "\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t" + - "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3" + - "\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t" + - "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3" + - "\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t" + - "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3" + - "\t\3\t\5\t\u017b\n\t\3\n\3\n\3\13\3\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16" + - "\3\17\3\17\3\20\3\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24\3\24\3\24\3\24" + - "\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\27\3\27\3\30" + - "\3\30\3\31\3\31\3\32\3\32\3\33\3\33\3\34\3\34\3\34\3\35\3\35\3\35\3\36" + - "\3\36\3\37\3\37\3\37\3 \3 \3 \3!\3!\3!\3\"\3\"\3\"\3#\3#\3#\3$\3$\3$\3" + - "%\3%\3&\3&\3&\3\'\3\'\3(\3(\3)\3)\7)\u01d0\n)\f)\16)\u01d3\13)\3)\3)\3" + - ")\7)\u01d8\n)\f)\16)\u01db\13)\3)\5)\u01de\n)\3*\6*\u01e1\n*\r*\16*\u01e2" + - "\3*\3*\3+\3+\7+\u01e9\n+\f+\16+\u01ec\13+\3,\3,\3-\3-\5-\u01f2\n-\2\2" + - ".\3\3\5\4\7\5\t\6\13\7\r\b\17\2\21\t\23\n\25\13\27\f\31\r\33\16\35\17" + - "\37\20!\21#\22%\23\'\24)\25+\26-\27/\30\61\31\63\32\65\33\67\349\35;\36" + - "=\37? A!C\"E#G$I%K&M\'O(Q)S*U+W\2Y\2\3\2\7\3\2$$\3\2))\5\2\13\f\17\17" + - "\"\"\20\2C\\aac|\u00c2\u00d8\u00da\u00f8\u00fa\u0301\u0372\u037f\u0381" + - "\u2001\u200e\u200f\u2072\u2191\u2c02\u2ff1\u3003\ud801\uf902\ufdd1\ufdf2" + - "\uffff\7\2/\60\62;\u00b9\u00b9\u0302\u0371\u2041\u2042\2\u020e\2\3\3\2" + - "\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\21" + - "\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2" + - "\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3" + - "\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3" + - "\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3" + - "\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2" + - "\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\3[\3\2\2\2\5" + - "r\3\2\2\2\7u\3\2\2\2\ty\3\2\2\2\13\u00b7\3\2\2\2\r\u00c2\3\2\2\2\17\u00c5" + - "\3\2\2\2\21\u017a\3\2\2\2\23\u017c\3\2\2\2\25\u017e\3\2\2\2\27\u0181\3" + - "\2\2\2\31\u0183\3\2\2\2\33\u0185\3\2\2\2\35\u0187\3\2\2\2\37\u0189\3\2" + - "\2\2!\u018b\3\2\2\2#\u018d\3\2\2\2%\u018f\3\2\2\2\'\u0191\3\2\2\2)\u0197" + - "\3\2\2\2+\u019d\3\2\2\2-\u01a0\3\2\2\2/\u01a2\3\2\2\2\61\u01a4\3\2\2\2" + - "\63\u01a6\3\2\2\2\65\u01a8\3\2\2\2\67\u01aa\3\2\2\29\u01ad\3\2\2\2;\u01b0" + - "\3\2\2\2=\u01b2\3\2\2\2?\u01b5\3\2\2\2A\u01b8\3\2\2\2C\u01bb\3\2\2\2E" + - "\u01be\3\2\2\2G\u01c1\3\2\2\2I\u01c4\3\2\2\2K\u01c6\3\2\2\2M\u01c9\3\2" + - "\2\2O\u01cb\3\2\2\2Q\u01dd\3\2\2\2S\u01e0\3\2\2\2U\u01e6\3\2\2\2W\u01ed" + - "\3\2\2\2Y\u01f1\3\2\2\2[\\\7r\2\2\\]\7t\2\2]^\7q\2\2^_\7e\2\2_`\7g\2\2" + - "`a\7u\2\2ab\7u\2\2bc\7k\2\2cd\7p\2\2de\7i\2\2ef\7/\2\2fg\7k\2\2gh\7p\2" + - "\2hi\7u\2\2ij\7v\2\2jk\7t\2\2kl\7w\2\2lm\7e\2\2mn\7v\2\2no\7k\2\2op\7" + - "q\2\2pq\7p\2\2q\4\3\2\2\2rs\7q\2\2st\7t\2\2t\6\3\2\2\2uv\7c\2\2vw\7p\2" + - "\2wx\7f\2\2x\b\3\2\2\2yz\7&\2\2z\n\3\2\2\2{|\7e\2\2|}\7q\2\2}~\7o\2\2" + - "~\177\7o\2\2\177\u0080\7g\2\2\u0080\u0081\7p\2\2\u0081\u00b8\7v\2\2\u0082" + - "\u0083\7v\2\2\u0083\u0084\7g\2\2\u0084\u0085\7z\2\2\u0085\u00b8\7v\2\2" + - "\u0086\u0087\7r\2\2\u0087\u0088\7t\2\2\u0088\u0089\7q\2\2\u0089\u008a" + - "\7e\2\2\u008a\u008b\7g\2\2\u008b\u008c\7u\2\2\u008c\u008d\7u\2\2\u008d" + - "\u008e\7k\2\2\u008e\u008f\7p\2\2\u008f\u0090\7i\2\2\u0090\u0091\7/\2\2" + - "\u0091\u0092\7k\2\2\u0092\u0093\7p\2\2\u0093\u0094\7u\2\2\u0094\u0095" + - "\7v\2\2\u0095\u0096\7t\2\2\u0096\u0097\7w\2\2\u0097\u0098\7e\2\2\u0098" + - "\u0099\7v\2\2\u0099\u009a\7k\2\2\u009a\u009b\7q\2\2\u009b\u00b8\7p\2\2" + - "\u009c\u009d\7p\2\2\u009d\u009e\7q\2\2\u009e\u009f\7f\2\2\u009f\u00b8" + - "\7g\2\2\u00a0\u00a1\7p\2\2\u00a1\u00a2\7w\2\2\u00a2\u00b8\7o\2\2\u00a3" + - "\u00a4\7c\2\2\u00a4\u00a5\7n\2\2\u00a5\u00a6\7n\2\2\u00a6\u00a7\7V\2\2" + - "\u00a7\u00a8\7g\2\2\u00a8\u00a9\7z\2\2\u00a9\u00b8\7v\2\2\u00aa\u00ab" + - "\7q\2\2\u00ab\u00ac\7w\2\2\u00ac\u00ad\7v\2\2\u00ad\u00ae\7g\2\2\u00ae" + - "\u00af\7t\2\2\u00af\u00b0\7J\2\2\u00b0\u00b1\7v\2\2\u00b1\u00b2\7o\2\2" + - "\u00b2\u00b8\7n\2\2\u00b3\u00b4\7j\2\2\u00b4\u00b5\7v\2\2\u00b5\u00b6" + - "\7o\2\2\u00b6\u00b8\7n\2\2\u00b7{\3\2\2\2\u00b7\u0082\3\2\2\2\u00b7\u0086" + - "\3\2\2\2\u00b7\u009c\3\2\2\2\u00b7\u00a0\3\2\2\2\u00b7\u00a3\3\2\2\2\u00b7" + - "\u00aa\3\2\2\2\u00b7\u00b3\3\2\2\2\u00b8\f\3\2\2\2\u00b9\u00be\5\17\b" + - "\2\u00ba\u00bc\7\60\2\2\u00bb\u00bd\5\17\b\2\u00bc\u00bb\3\2\2\2\u00bc" + - "\u00bd\3\2\2\2\u00bd\u00bf\3\2\2\2\u00be\u00ba\3\2\2\2\u00be\u00bf\3\2" + - "\2\2\u00bf\u00c3\3\2\2\2\u00c0\u00c1\7\60\2\2\u00c1\u00c3\5\17\b\2\u00c2" + - "\u00b9\3\2\2\2\u00c2\u00c0\3\2\2\2\u00c3\16\3\2\2\2\u00c4\u00c6\4\62;" + - "\2\u00c5\u00c4\3\2\2\2\u00c6\u00c7\3\2\2\2\u00c7\u00c5\3\2\2\2\u00c7\u00c8" + - "\3\2\2\2\u00c8\20\3\2\2\2\u00c9\u00ca\7c\2\2\u00ca\u00cb\7p\2\2\u00cb" + - "\u00cc\7e\2\2\u00cc\u00cd\7g\2\2\u00cd\u00ce\7u\2\2\u00ce\u00cf\7v\2\2" + - "\u00cf\u00d0\7q\2\2\u00d0\u017b\7t\2\2\u00d1\u00d2\7c\2\2\u00d2\u00d3" + - "\7p\2\2\u00d3\u00d4\7e\2\2\u00d4\u00d5\7g\2\2\u00d5\u00d6\7u\2\2\u00d6" + - "\u00d7\7v\2\2\u00d7\u00d8\7q\2\2\u00d8\u00d9\7t\2\2\u00d9\u00da\7/\2\2" + - "\u00da\u00db\7q\2\2\u00db\u00dc\7t\2\2\u00dc\u00dd\7/\2\2\u00dd\u00de" + - "\7u\2\2\u00de\u00df\7g\2\2\u00df\u00e0\7n\2\2\u00e0\u017b\7h\2\2\u00e1" + - "\u00e2\7c\2\2\u00e2\u00e3\7v\2\2\u00e3\u00e4\7v\2\2\u00e4\u00e5\7t\2\2" + - "\u00e5\u00e6\7k\2\2\u00e6\u00e7\7d\2\2\u00e7\u00e8\7w\2\2\u00e8\u00e9" + - "\7v\2\2\u00e9\u017b\7g\2\2\u00ea\u00eb\7e\2\2\u00eb\u00ec\7j\2\2\u00ec" + - "\u00ed\7k\2\2\u00ed\u00ee\7n\2\2\u00ee\u017b\7f\2\2\u00ef\u00f0\7f\2\2" + - "\u00f0\u00f1\7g\2\2\u00f1\u00f2\7u\2\2\u00f2\u00f3\7e\2\2\u00f3\u00f4" + - "\7g\2\2\u00f4\u00f5\7p\2\2\u00f5\u00f6\7f\2\2\u00f6\u00f7\7c\2\2\u00f7" + - "\u00f8\7p\2\2\u00f8\u017b\7v\2\2\u00f9\u00fa\7f\2\2\u00fa\u00fb\7g\2\2" + - "\u00fb\u00fc\7u\2\2\u00fc\u00fd\7e\2\2\u00fd\u00fe\7g\2\2\u00fe\u00ff" + - "\7p\2\2\u00ff\u0100\7f\2\2\u0100\u0101\7c\2\2\u0101\u0102\7p\2\2\u0102" + - "\u0103\7v\2\2\u0103\u0104\7/\2\2\u0104\u0105\7q\2\2\u0105\u0106\7t\2\2" + - "\u0106\u0107\7/\2\2\u0107\u0108\7u\2\2\u0108\u0109\7g\2\2\u0109\u010a" + - "\7n\2\2\u010a\u017b\7h\2\2\u010b\u010c\7h\2\2\u010c\u010d\7q\2\2\u010d" + - "\u010e\7n\2\2\u010e\u010f\7n\2\2\u010f\u0110\7q\2\2\u0110\u0111\7y\2\2" + - "\u0111\u0112\7k\2\2\u0112\u0113\7p\2\2\u0113\u017b\7i\2\2\u0114\u0115" + - "\7h\2\2\u0115\u0116\7q\2\2\u0116\u0117\7n\2\2\u0117\u0118\7n\2\2\u0118" + - "\u0119\7q\2\2\u0119\u011a\7y\2\2\u011a\u011b\7k\2\2\u011b\u011c\7p\2\2" + - "\u011c\u011d\7i\2\2\u011d\u011e\7/\2\2\u011e\u011f\7u\2\2\u011f\u0120" + - "\7k\2\2\u0120\u0121\7d\2\2\u0121\u0122\7n\2\2\u0122\u0123\7k\2\2\u0123" + - "\u0124\7p\2\2\u0124\u017b\7i\2\2\u0125\u0126\7r\2\2\u0126\u0127\7c\2\2" + - "\u0127\u0128\7t\2\2\u0128\u0129\7g\2\2\u0129\u012a\7p\2\2\u012a\u017b" + - "\7v\2\2\u012b\u012c\7r\2\2\u012c\u012d\7t\2\2\u012d\u012e\7g\2\2\u012e" + - "\u012f\7e\2\2\u012f\u0130\7g\2\2\u0130\u0131\7f\2\2\u0131\u0132\7k\2\2" + - "\u0132\u0133\7p\2\2\u0133\u017b\7i\2\2\u0134\u0135\7r\2\2\u0135\u0136" + - "\7t\2\2\u0136\u0137\7g\2\2\u0137\u0138\7e\2\2\u0138\u0139\7g\2\2\u0139" + - "\u013a\7f\2\2\u013a\u013b\7k\2\2\u013b\u013c\7p\2\2\u013c\u013d\7i\2\2" + - "\u013d\u013e\7/\2\2\u013e\u013f\7u\2\2\u013f\u0140\7k\2\2\u0140\u0141" + - "\7d\2\2\u0141\u0142\7n\2\2\u0142\u0143\7k\2\2\u0143\u0144\7p\2\2\u0144" + - "\u017b\7i\2\2\u0145\u0146\7u\2\2\u0146\u0147\7g\2\2\u0147\u0148\7n\2\2" + - "\u0148\u017b\7h\2\2\u0149\u014a\7h\2\2\u014a\u014b\7q\2\2\u014b\u014c" + - "\7n\2\2\u014c\u014d\7n\2\2\u014d\u014e\7q\2\2\u014e\u014f\7y\2\2\u014f" + - "\u0150\7k\2\2\u0150\u0151\7p\2\2\u0151\u0152\7i\2\2\u0152\u0153\7/\2\2" + - "\u0153\u0154\7u\2\2\u0154\u0155\7k\2\2\u0155\u0156\7d\2\2\u0156\u0157" + - "\7n\2\2\u0157\u0158\7k\2\2\u0158\u0159\7p\2\2\u0159\u015a\7i\2\2\u015a" + - "\u015b\7/\2\2\u015b\u015c\7q\2\2\u015c\u015d\7p\2\2\u015d\u017b\7g\2\2" + - "\u015e\u015f\7r\2\2\u015f\u0160\7t\2\2\u0160\u0161\7g\2\2\u0161\u0162" + - "\7e\2\2\u0162\u0163\7g\2\2\u0163\u0164\7f\2\2\u0164\u0165\7k\2\2\u0165" + - "\u0166\7p\2\2\u0166\u0167\7i\2\2\u0167\u0168\7/\2\2\u0168\u0169\7u\2\2" + - "\u0169\u016a\7k\2\2\u016a\u016b\7d\2\2\u016b\u016c\7n\2\2\u016c\u016d" + - "\7k\2\2\u016d\u016e\7p\2\2\u016e\u016f\7i\2\2\u016f\u0170\7/\2\2\u0170" + - "\u0171\7q\2\2\u0171\u0172\7p\2\2\u0172\u017b\7g\2\2\u0173\u0174\7u\2\2" + - "\u0174\u0175\7k\2\2\u0175\u0176\7d\2\2\u0176\u0177\7n\2\2\u0177\u0178" + - "\7k\2\2\u0178\u0179\7p\2\2\u0179\u017b\7i\2\2\u017a\u00c9\3\2\2\2\u017a" + - "\u00d1\3\2\2\2\u017a\u00e1\3\2\2\2\u017a\u00ea\3\2\2\2\u017a\u00ef\3\2" + - "\2\2\u017a\u00f9\3\2\2\2\u017a\u010b\3\2\2\2\u017a\u0114\3\2\2\2\u017a" + - "\u0125\3\2\2\2\u017a\u012b\3\2\2\2\u017a\u0134\3\2\2\2\u017a\u0145\3\2" + - "\2\2\u017a\u0149\3\2\2\2\u017a\u015e\3\2\2\2\u017a\u0173\3\2\2\2\u017b" + - "\22\3\2\2\2\u017c\u017d\7\61\2\2\u017d\24\3\2\2\2\u017e\u017f\7\61\2\2" + - "\u017f\u0180\7\61\2\2\u0180\26\3\2\2\2\u0181\u0182\7*\2\2\u0182\30\3\2" + - "\2\2\u0183\u0184\7+\2\2\u0184\32\3\2\2\2\u0185\u0186\7]\2\2\u0186\34\3" + - "\2\2\2\u0187\u0188\7_\2\2\u0188\36\3\2\2\2\u0189\u018a\7/\2\2\u018a \3" + - "\2\2\2\u018b\u018c\7-\2\2\u018c\"\3\2\2\2\u018d\u018e\7\60\2\2\u018e$" + - "\3\2\2\2\u018f\u0190\7,\2\2\u0190&\3\2\2\2\u0191\u0192\7b\2\2\u0192\u0193" + - "\7f\2\2\u0193\u0194\7k\2\2\u0194\u0195\7x\2\2\u0195\u0196\7b\2\2\u0196" + - "(\3\2\2\2\u0197\u0198\7b\2\2\u0198\u0199\7o\2\2\u0199\u019a\7q\2\2\u019a" + - "\u019b\7f\2\2\u019b\u019c\7b\2\2\u019c*\3\2\2\2\u019d\u019e\7\60\2\2\u019e" + - "\u019f\7\60\2\2\u019f,\3\2\2\2\u01a0\u01a1\7B\2\2\u01a1.\3\2\2\2\u01a2" + - "\u01a3\7.\2\2\u01a3\60\3\2\2\2\u01a4\u01a5\7~\2\2\u01a5\62\3\2\2\2\u01a6" + - "\u01a7\7>\2\2\u01a7\64\3\2\2\2\u01a8\u01a9\7@\2\2\u01a9\66\3\2\2\2\u01aa" + - "\u01ab\7>\2\2\u01ab\u01ac\7?\2\2\u01ac8\3\2\2\2\u01ad\u01ae\7@\2\2\u01ae" + - "\u01af\7?\2\2\u01af:\3\2\2\2\u01b0\u01b1\7?\2\2\u01b1<\3\2\2\2\u01b2\u01b3" + - "\7#\2\2\u01b3\u01b4\7?\2\2\u01b4>\3\2\2\2\u01b5\u01b6\7`\2\2\u01b6\u01b7" + - "\7?\2\2\u01b7@\3\2\2\2\u01b8\u01b9\7&\2\2\u01b9\u01ba\7?\2\2\u01baB\3" + - "\2\2\2\u01bb\u01bc\7,\2\2\u01bc\u01bd\7?\2\2\u01bdD\3\2\2\2\u01be\u01bf" + - "\7\u0080\2\2\u01bf\u01c0\7?\2\2\u01c0F\3\2\2\2\u01c1\u01c2\7#\2\2\u01c2" + - "\u01c3\7\u0080\2\2\u01c3H\3\2\2\2\u01c4\u01c5\7<\2\2\u01c5J\3\2\2\2\u01c6" + - "\u01c7\7<\2\2\u01c7\u01c8\7<\2\2\u01c8L\3\2\2\2\u01c9\u01ca\7)\2\2\u01ca" + - "N\3\2\2\2\u01cb\u01cc\7$\2\2\u01ccP\3\2\2\2\u01cd\u01d1\7$\2\2\u01ce\u01d0" + - "\n\2\2\2\u01cf\u01ce\3\2\2\2\u01d0\u01d3\3\2\2\2\u01d1\u01cf\3\2\2\2\u01d1" + - "\u01d2\3\2\2\2\u01d2\u01d4\3\2\2\2\u01d3\u01d1\3\2\2\2\u01d4\u01de\7$" + - "\2\2\u01d5\u01d9\7)\2\2\u01d6\u01d8\n\3\2\2\u01d7\u01d6\3\2\2\2\u01d8" + - "\u01db\3\2\2\2\u01d9\u01d7\3\2\2\2\u01d9\u01da\3\2\2\2\u01da\u01dc\3\2" + - "\2\2\u01db\u01d9\3\2\2\2\u01dc\u01de\7)\2\2\u01dd\u01cd\3\2\2\2\u01dd" + - "\u01d5\3\2\2\2\u01deR\3\2\2\2\u01df\u01e1\t\4\2\2\u01e0\u01df\3\2\2\2" + - "\u01e1\u01e2\3\2\2\2\u01e2\u01e0\3\2\2\2\u01e2\u01e3\3\2\2\2\u01e3\u01e4" + - "\3\2\2\2\u01e4\u01e5\b*\2\2\u01e5T\3\2\2\2\u01e6\u01ea\5W,\2\u01e7\u01e9" + - "\5Y-\2\u01e8\u01e7\3\2\2\2\u01e9\u01ec\3\2\2\2\u01ea\u01e8\3\2\2\2\u01ea" + - "\u01eb\3\2\2\2\u01ebV\3\2\2\2\u01ec\u01ea\3\2\2\2\u01ed\u01ee\t\5\2\2" + - "\u01eeX\3\2\2\2\u01ef\u01f2\5W,\2\u01f0\u01f2\t\6\2\2\u01f1\u01ef\3\2" + - "\2\2\u01f1\u01f0\3\2\2\2\u01f2Z\3\2\2\2\17\2\u00b7\u00bc\u00be\u00c2\u00c7" + - "\u017a\u01d1\u01d9\u01dd\u01e2\u01ea\u01f1\3\b\2\2"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } -} \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.tokens b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.tokens deleted file mode 100644 index 79142cd34..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathLexer.tokens +++ /dev/null @@ -1,76 +0,0 @@ -T__0=1 -T__1=2 -T__2=3 -T__3=4 -NodeType=5 -Number=6 -AxisName=7 -PATHSEP=8 -ABRPATH=9 -LPAR=10 -RPAR=11 -LBRAC=12 -RBRAC=13 -MINUS=14 -PLUS=15 -DOT=16 -MUL=17 -DIVISION=18 -MODULO=19 -DOTDOT=20 -AT=21 -COMMA=22 -PIPE=23 -LESS=24 -MORE_=25 -LE=26 -GE=27 -EQUALITY=28 -INEQUALITY=29 -START_WITH=30 -END_WITH=31 -CONTAIN_WITH=32 -REGEXP_WITH=33 -REGEXP_NOT_WITH=34 -COLON=35 -CC=36 -APOS=37 -QUOT=38 -Literal=39 -Whitespace=40 -NCName=41 -'processing-instruction'=1 -'or'=2 -'and'=3 -'$'=4 -'/'=8 -'//'=9 -'('=10 -')'=11 -'['=12 -']'=13 -'-'=14 -'+'=15 -'.'=16 -'*'=17 -'`div`'=18 -'`mod`'=19 -'..'=20 -'@'=21 -','=22 -'|'=23 -'<'=24 -'>'=25 -'<='=26 -'>='=27 -'='=28 -'!='=29 -'^='=30 -'$='=31 -'*='=32 -'~='=33 -'!~'=34 -':'=35 -'::'=36 -'\''=37 -'"'=38 diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathListener.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathListener.java deleted file mode 100644 index 58287510b..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathListener.java +++ /dev/null @@ -1,388 +0,0 @@ -// Generated from resources/Xpath.g4 by ANTLR 4.7.2 -package org.seimicrawler.xpath.antlr; - -import org.antlr.v4.runtime.tree.ParseTreeListener; - -/** - * This interface defines a complete listener for a parse tree produced by - * {@link XpathParser}. - */ -public interface XpathListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link XpathParser#main}. - * - * @param ctx the parse tree - */ - void enterMain(XpathParser.MainContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#main}. - * - * @param ctx the parse tree - */ - void exitMain(XpathParser.MainContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#locationPath}. - * - * @param ctx the parse tree - */ - void enterLocationPath(XpathParser.LocationPathContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#locationPath}. - * - * @param ctx the parse tree - */ - void exitLocationPath(XpathParser.LocationPathContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#absoluteLocationPathNoroot}. - * - * @param ctx the parse tree - */ - void enterAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#absoluteLocationPathNoroot}. - * - * @param ctx the parse tree - */ - void exitAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#relativeLocationPath}. - * - * @param ctx the parse tree - */ - void enterRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#relativeLocationPath}. - * - * @param ctx the parse tree - */ - void exitRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#step}. - * - * @param ctx the parse tree - */ - void enterStep(XpathParser.StepContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#step}. - * - * @param ctx the parse tree - */ - void exitStep(XpathParser.StepContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#axisSpecifier}. - * - * @param ctx the parse tree - */ - void enterAxisSpecifier(XpathParser.AxisSpecifierContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#axisSpecifier}. - * - * @param ctx the parse tree - */ - void exitAxisSpecifier(XpathParser.AxisSpecifierContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#nodeTest}. - * - * @param ctx the parse tree - */ - void enterNodeTest(XpathParser.NodeTestContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#nodeTest}. - * - * @param ctx the parse tree - */ - void exitNodeTest(XpathParser.NodeTestContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#predicate}. - * - * @param ctx the parse tree - */ - void enterPredicate(XpathParser.PredicateContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#predicate}. - * - * @param ctx the parse tree - */ - void exitPredicate(XpathParser.PredicateContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#abbreviatedStep}. - * - * @param ctx the parse tree - */ - void enterAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#abbreviatedStep}. - * - * @param ctx the parse tree - */ - void exitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#expr}. - * - * @param ctx the parse tree - */ - void enterExpr(XpathParser.ExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#expr}. - * - * @param ctx the parse tree - */ - void exitExpr(XpathParser.ExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#primaryExpr}. - * - * @param ctx the parse tree - */ - void enterPrimaryExpr(XpathParser.PrimaryExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#primaryExpr}. - * - * @param ctx the parse tree - */ - void exitPrimaryExpr(XpathParser.PrimaryExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#functionCall}. - * - * @param ctx the parse tree - */ - void enterFunctionCall(XpathParser.FunctionCallContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#functionCall}. - * - * @param ctx the parse tree - */ - void exitFunctionCall(XpathParser.FunctionCallContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#unionExprNoRoot}. - * - * @param ctx the parse tree - */ - void enterUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#unionExprNoRoot}. - * - * @param ctx the parse tree - */ - void exitUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#pathExprNoRoot}. - * - * @param ctx the parse tree - */ - void enterPathExprNoRoot(XpathParser.PathExprNoRootContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#pathExprNoRoot}. - * - * @param ctx the parse tree - */ - void exitPathExprNoRoot(XpathParser.PathExprNoRootContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#filterExpr}. - * - * @param ctx the parse tree - */ - void enterFilterExpr(XpathParser.FilterExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#filterExpr}. - * - * @param ctx the parse tree - */ - void exitFilterExpr(XpathParser.FilterExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#orExpr}. - * - * @param ctx the parse tree - */ - void enterOrExpr(XpathParser.OrExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#orExpr}. - * - * @param ctx the parse tree - */ - void exitOrExpr(XpathParser.OrExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#andExpr}. - * - * @param ctx the parse tree - */ - void enterAndExpr(XpathParser.AndExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#andExpr}. - * - * @param ctx the parse tree - */ - void exitAndExpr(XpathParser.AndExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#equalityExpr}. - * - * @param ctx the parse tree - */ - void enterEqualityExpr(XpathParser.EqualityExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#equalityExpr}. - * - * @param ctx the parse tree - */ - void exitEqualityExpr(XpathParser.EqualityExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#relationalExpr}. - * - * @param ctx the parse tree - */ - void enterRelationalExpr(XpathParser.RelationalExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#relationalExpr}. - * - * @param ctx the parse tree - */ - void exitRelationalExpr(XpathParser.RelationalExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#additiveExpr}. - * - * @param ctx the parse tree - */ - void enterAdditiveExpr(XpathParser.AdditiveExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#additiveExpr}. - * - * @param ctx the parse tree - */ - void exitAdditiveExpr(XpathParser.AdditiveExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#multiplicativeExpr}. - * - * @param ctx the parse tree - */ - void enterMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#multiplicativeExpr}. - * - * @param ctx the parse tree - */ - void exitMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#unaryExprNoRoot}. - * - * @param ctx the parse tree - */ - void enterUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#unaryExprNoRoot}. - * - * @param ctx the parse tree - */ - void exitUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#qName}. - * - * @param ctx the parse tree - */ - void enterQName(XpathParser.QNameContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#qName}. - * - * @param ctx the parse tree - */ - void exitQName(XpathParser.QNameContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#functionName}. - * - * @param ctx the parse tree - */ - void enterFunctionName(XpathParser.FunctionNameContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#functionName}. - * - * @param ctx the parse tree - */ - void exitFunctionName(XpathParser.FunctionNameContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#variableReference}. - * - * @param ctx the parse tree - */ - void enterVariableReference(XpathParser.VariableReferenceContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#variableReference}. - * - * @param ctx the parse tree - */ - void exitVariableReference(XpathParser.VariableReferenceContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#nameTest}. - * - * @param ctx the parse tree - */ - void enterNameTest(XpathParser.NameTestContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#nameTest}. - * - * @param ctx the parse tree - */ - void exitNameTest(XpathParser.NameTestContext ctx); - - /** - * Enter a parse tree produced by {@link XpathParser#nCName}. - * - * @param ctx the parse tree - */ - void enterNCName(XpathParser.NCNameContext ctx); - - /** - * Exit a parse tree produced by {@link XpathParser#nCName}. - * - * @param ctx the parse tree - */ - void exitNCName(XpathParser.NCNameContext ctx); -} \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathParser.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathParser.java deleted file mode 100644 index 06248f719..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/antlr/XpathParser.java +++ /dev/null @@ -1,2490 +0,0 @@ -// Generated from resources/Xpath.g4 by ANTLR 4.7.2 -package org.seimicrawler.xpath.antlr; - -import org.antlr.v4.runtime.NoViableAltException; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.ParserATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; -import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.tree.ParseTreeListener; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; -import org.antlr.v4.runtime.tree.TerminalNode; - -import java.util.List; - -@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) -public class XpathParser extends Parser { - static { - RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); - } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, NodeType = 5, Number = 6, AxisName = 7, PATHSEP = 8, - ABRPATH = 9, LPAR = 10, RPAR = 11, LBRAC = 12, RBRAC = 13, MINUS = 14, PLUS = 15, DOT = 16, - MUL = 17, DIVISION = 18, MODULO = 19, DOTDOT = 20, AT = 21, COMMA = 22, PIPE = 23, LESS = 24, - MORE_ = 25, LE = 26, GE = 27, EQUALITY = 28, INEQUALITY = 29, START_WITH = 30, END_WITH = 31, - CONTAIN_WITH = 32, REGEXP_WITH = 33, REGEXP_NOT_WITH = 34, COLON = 35, CC = 36, - APOS = 37, QUOT = 38, Literal = 39, Whitespace = 40, NCName = 41; - public static final int - RULE_main = 0, RULE_locationPath = 1, RULE_absoluteLocationPathNoroot = 2, - RULE_relativeLocationPath = 3, RULE_step = 4, RULE_axisSpecifier = 5, - RULE_nodeTest = 6, RULE_predicate = 7, RULE_abbreviatedStep = 8, RULE_expr = 9, - RULE_primaryExpr = 10, RULE_functionCall = 11, RULE_unionExprNoRoot = 12, - RULE_pathExprNoRoot = 13, RULE_filterExpr = 14, RULE_orExpr = 15, RULE_andExpr = 16, - RULE_equalityExpr = 17, RULE_relationalExpr = 18, RULE_additiveExpr = 19, - RULE_multiplicativeExpr = 20, RULE_unaryExprNoRoot = 21, RULE_qName = 22, - RULE_functionName = 23, RULE_variableReference = 24, RULE_nameTest = 25, - RULE_nCName = 26; - - private static String[] makeRuleNames() { - return new String[]{ - "main", "locationPath", "absoluteLocationPathNoroot", "relativeLocationPath", - "step", "axisSpecifier", "nodeTest", "predicate", "abbreviatedStep", - "expr", "primaryExpr", "functionCall", "unionExprNoRoot", "pathExprNoRoot", - "filterExpr", "orExpr", "andExpr", "equalityExpr", "relationalExpr", - "additiveExpr", "multiplicativeExpr", "unaryExprNoRoot", "qName", "functionName", - "variableReference", "nameTest", "nCName" - }; - } - - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[]{ - null, "'processing-instruction'", "'or'", "'and'", "'$'", null, null, - null, "'/'", "'//'", "'('", "')'", "'['", "']'", "'-'", "'+'", "'.'", - "'*'", "'`div`'", "'`mod`'", "'..'", "'@'", "','", "'|'", "'<'", "'>'", - "'<='", "'>='", "'='", "'!='", "'^='", "'$='", "'*='", "'~='", "'!~'", - "':'", "'::'", "'''", "'\"'" - }; - } - - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - - private static String[] makeSymbolicNames() { - return new String[]{ - null, null, null, null, null, "NodeType", "Number", "AxisName", "PATHSEP", - "ABRPATH", "LPAR", "RPAR", "LBRAC", "RBRAC", "MINUS", "PLUS", "DOT", - "MUL", "DIVISION", "MODULO", "DOTDOT", "AT", "COMMA", "PIPE", "LESS", - "MORE_", "LE", "GE", "EQUALITY", "INEQUALITY", "START_WITH", "END_WITH", - "CONTAIN_WITH", "REGEXP_WITH", "REGEXP_NOT_WITH", "COLON", "CC", "APOS", - "QUOT", "Literal", "Whitespace", "NCName" - }; - } - - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { - return "Xpath.g4"; - } - - @Override - public String[] getRuleNames() { - return ruleNames; - } - - @Override - public String getSerializedATN() { - return _serializedATN; - } - - @Override - public ATN getATN() { - return _ATN; - } - - public XpathParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); - } - - public static class MainContext extends ParserRuleContext { - public ExprContext expr() { - return getRuleContext(ExprContext.class, 0); - } - - public MainContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_main; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterMain(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitMain(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitMain(this); - else return visitor.visitChildren(this); - } - } - - public final MainContext main() throws RecognitionException { - MainContext _localctx = new MainContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_main); - try { - enterOuterAlt(_localctx, 1); - { - setState(54); - expr(); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class LocationPathContext extends ParserRuleContext { - public RelativeLocationPathContext relativeLocationPath() { - return getRuleContext(RelativeLocationPathContext.class, 0); - } - - public AbsoluteLocationPathNorootContext absoluteLocationPathNoroot() { - return getRuleContext(AbsoluteLocationPathNorootContext.class, 0); - } - - public LocationPathContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_locationPath; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterLocationPath(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitLocationPath(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitLocationPath(this); - else return visitor.visitChildren(this); - } - } - - public final LocationPathContext locationPath() throws RecognitionException { - LocationPathContext _localctx = new LocationPathContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_locationPath); - try { - setState(58); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__0: - case NodeType: - case AxisName: - case DOT: - case MUL: - case DOTDOT: - case AT: - case NCName: - enterOuterAlt(_localctx, 1); - { - setState(56); - relativeLocationPath(); - } - break; - case PATHSEP: - case ABRPATH: - enterOuterAlt(_localctx, 2); - { - setState(57); - absoluteLocationPathNoroot(); - } - break; - default: - throw new NoViableAltException(this); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class AbsoluteLocationPathNorootContext extends ParserRuleContext { - public Token op; - - public RelativeLocationPathContext relativeLocationPath() { - return getRuleContext(RelativeLocationPathContext.class, 0); - } - - public TerminalNode PATHSEP() { - return getToken(XpathParser.PATHSEP, 0); - } - - public TerminalNode ABRPATH() { - return getToken(XpathParser.ABRPATH, 0); - } - - public AbsoluteLocationPathNorootContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_absoluteLocationPathNoroot; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterAbsoluteLocationPathNoroot(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitAbsoluteLocationPathNoroot(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitAbsoluteLocationPathNoroot(this); - else return visitor.visitChildren(this); - } - } - - public final AbsoluteLocationPathNorootContext absoluteLocationPathNoroot() throws RecognitionException { - AbsoluteLocationPathNorootContext _localctx = new AbsoluteLocationPathNorootContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_absoluteLocationPathNoroot); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(60); - ((AbsoluteLocationPathNorootContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!(_la == PATHSEP || _la == ABRPATH)) { - ((AbsoluteLocationPathNorootContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(61); - relativeLocationPath(); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class RelativeLocationPathContext extends ParserRuleContext { - public Token op; - - public List step() { - return getRuleContexts(StepContext.class); - } - - public StepContext step(int i) { - return getRuleContext(StepContext.class, i); - } - - public List PATHSEP() { - return getTokens(XpathParser.PATHSEP); - } - - public TerminalNode PATHSEP(int i) { - return getToken(XpathParser.PATHSEP, i); - } - - public List ABRPATH() { - return getTokens(XpathParser.ABRPATH); - } - - public TerminalNode ABRPATH(int i) { - return getToken(XpathParser.ABRPATH, i); - } - - public RelativeLocationPathContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_relativeLocationPath; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterRelativeLocationPath(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitRelativeLocationPath(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitRelativeLocationPath(this); - else return visitor.visitChildren(this); - } - } - - public final RelativeLocationPathContext relativeLocationPath() throws RecognitionException { - RelativeLocationPathContext _localctx = new RelativeLocationPathContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_relativeLocationPath); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(63); - step(); - setState(68); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == PATHSEP || _la == ABRPATH) { - { - { - setState(64); - ((RelativeLocationPathContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!(_la == PATHSEP || _la == ABRPATH)) { - ((RelativeLocationPathContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(65); - step(); - } - } - setState(70); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class StepContext extends ParserRuleContext { - public AxisSpecifierContext axisSpecifier() { - return getRuleContext(AxisSpecifierContext.class, 0); - } - - public NodeTestContext nodeTest() { - return getRuleContext(NodeTestContext.class, 0); - } - - public List predicate() { - return getRuleContexts(PredicateContext.class); - } - - public PredicateContext predicate(int i) { - return getRuleContext(PredicateContext.class, i); - } - - public AbbreviatedStepContext abbreviatedStep() { - return getRuleContext(AbbreviatedStepContext.class, 0); - } - - public StepContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_step; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterStep(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitStep(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitStep(this); - else return visitor.visitChildren(this); - } - } - - public final StepContext step() throws RecognitionException { - StepContext _localctx = new StepContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_step); - int _la; - try { - setState(80); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__0: - case NodeType: - case AxisName: - case MUL: - case AT: - case NCName: - enterOuterAlt(_localctx, 1); - { - setState(71); - axisSpecifier(); - setState(72); - nodeTest(); - setState(76); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == LBRAC) { - { - { - setState(73); - predicate(); - } - } - setState(78); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - break; - case DOT: - case DOTDOT: - enterOuterAlt(_localctx, 2); - { - setState(79); - abbreviatedStep(); - } - break; - default: - throw new NoViableAltException(this); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class AxisSpecifierContext extends ParserRuleContext { - public TerminalNode AxisName() { - return getToken(XpathParser.AxisName, 0); - } - - public TerminalNode CC() { - return getToken(XpathParser.CC, 0); - } - - public TerminalNode AT() { - return getToken(XpathParser.AT, 0); - } - - public AxisSpecifierContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_axisSpecifier; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterAxisSpecifier(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitAxisSpecifier(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitAxisSpecifier(this); - else return visitor.visitChildren(this); - } - } - - public final AxisSpecifierContext axisSpecifier() throws RecognitionException { - AxisSpecifierContext _localctx = new AxisSpecifierContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_axisSpecifier); - int _la; - try { - setState(87); - _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 5, _ctx)) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(82); - match(AxisName); - setState(83); - match(CC); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(85); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la == AT) { - { - setState(84); - match(AT); - } - } - - } - break; - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class NodeTestContext extends ParserRuleContext { - public NameTestContext nameTest() { - return getRuleContext(NameTestContext.class, 0); - } - - public TerminalNode NodeType() { - return getToken(XpathParser.NodeType, 0); - } - - public TerminalNode LPAR() { - return getToken(XpathParser.LPAR, 0); - } - - public TerminalNode RPAR() { - return getToken(XpathParser.RPAR, 0); - } - - public TerminalNode Literal() { - return getToken(XpathParser.Literal, 0); - } - - public NodeTestContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_nodeTest; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterNodeTest(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitNodeTest(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitNodeTest(this); - else return visitor.visitChildren(this); - } - } - - public final NodeTestContext nodeTest() throws RecognitionException { - NodeTestContext _localctx = new NodeTestContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_nodeTest); - try { - setState(97); - _errHandler.sync(this); - switch (_input.LA(1)) { - case AxisName: - case MUL: - case NCName: - enterOuterAlt(_localctx, 1); - { - setState(89); - nameTest(); - } - break; - case NodeType: - enterOuterAlt(_localctx, 2); - { - setState(90); - match(NodeType); - setState(91); - match(LPAR); - setState(92); - match(RPAR); - } - break; - case T__0: - enterOuterAlt(_localctx, 3); - { - setState(93); - match(T__0); - setState(94); - match(LPAR); - setState(95); - match(Literal); - setState(96); - match(RPAR); - } - break; - default: - throw new NoViableAltException(this); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class PredicateContext extends ParserRuleContext { - public TerminalNode LBRAC() { - return getToken(XpathParser.LBRAC, 0); - } - - public ExprContext expr() { - return getRuleContext(ExprContext.class, 0); - } - - public TerminalNode RBRAC() { - return getToken(XpathParser.RBRAC, 0); - } - - public PredicateContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_predicate; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterPredicate(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitPredicate(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitPredicate(this); - else return visitor.visitChildren(this); - } - } - - public final PredicateContext predicate() throws RecognitionException { - PredicateContext _localctx = new PredicateContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_predicate); - try { - enterOuterAlt(_localctx, 1); - { - setState(99); - match(LBRAC); - setState(100); - expr(); - setState(101); - match(RBRAC); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class AbbreviatedStepContext extends ParserRuleContext { - public TerminalNode DOT() { - return getToken(XpathParser.DOT, 0); - } - - public TerminalNode DOTDOT() { - return getToken(XpathParser.DOTDOT, 0); - } - - public AbbreviatedStepContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_abbreviatedStep; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterAbbreviatedStep(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitAbbreviatedStep(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitAbbreviatedStep(this); - else return visitor.visitChildren(this); - } - } - - public final AbbreviatedStepContext abbreviatedStep() throws RecognitionException { - AbbreviatedStepContext _localctx = new AbbreviatedStepContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_abbreviatedStep); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(103); - _la = _input.LA(1); - if (!(_la == DOT || _la == DOTDOT)) { - _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class ExprContext extends ParserRuleContext { - public OrExprContext orExpr() { - return getRuleContext(OrExprContext.class, 0); - } - - public ExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_expr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitExpr(this); - else return visitor.visitChildren(this); - } - } - - public final ExprContext expr() throws RecognitionException { - ExprContext _localctx = new ExprContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_expr); - try { - enterOuterAlt(_localctx, 1); - { - setState(105); - orExpr(); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class PrimaryExprContext extends ParserRuleContext { - public VariableReferenceContext variableReference() { - return getRuleContext(VariableReferenceContext.class, 0); - } - - public TerminalNode LPAR() { - return getToken(XpathParser.LPAR, 0); - } - - public ExprContext expr() { - return getRuleContext(ExprContext.class, 0); - } - - public TerminalNode RPAR() { - return getToken(XpathParser.RPAR, 0); - } - - public TerminalNode Literal() { - return getToken(XpathParser.Literal, 0); - } - - public TerminalNode Number() { - return getToken(XpathParser.Number, 0); - } - - public FunctionCallContext functionCall() { - return getRuleContext(FunctionCallContext.class, 0); - } - - public PrimaryExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_primaryExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterPrimaryExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitPrimaryExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitPrimaryExpr(this); - else return visitor.visitChildren(this); - } - } - - public final PrimaryExprContext primaryExpr() throws RecognitionException { - PrimaryExprContext _localctx = new PrimaryExprContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_primaryExpr); - try { - setState(115); - _errHandler.sync(this); - switch (_input.LA(1)) { - case T__3: - enterOuterAlt(_localctx, 1); - { - setState(107); - variableReference(); - } - break; - case LPAR: - enterOuterAlt(_localctx, 2); - { - setState(108); - match(LPAR); - setState(109); - expr(); - setState(110); - match(RPAR); - } - break; - case Literal: - enterOuterAlt(_localctx, 3); - { - setState(112); - match(Literal); - } - break; - case Number: - enterOuterAlt(_localctx, 4); - { - setState(113); - match(Number); - } - break; - case AxisName: - case NCName: - enterOuterAlt(_localctx, 5); - { - setState(114); - functionCall(); - } - break; - default: - throw new NoViableAltException(this); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class FunctionCallContext extends ParserRuleContext { - public FunctionNameContext functionName() { - return getRuleContext(FunctionNameContext.class, 0); - } - - public TerminalNode LPAR() { - return getToken(XpathParser.LPAR, 0); - } - - public TerminalNode RPAR() { - return getToken(XpathParser.RPAR, 0); - } - - public List expr() { - return getRuleContexts(ExprContext.class); - } - - public ExprContext expr(int i) { - return getRuleContext(ExprContext.class, i); - } - - public List COMMA() { - return getTokens(XpathParser.COMMA); - } - - public TerminalNode COMMA(int i) { - return getToken(XpathParser.COMMA, i); - } - - public FunctionCallContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_functionCall; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterFunctionCall(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitFunctionCall(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitFunctionCall(this); - else return visitor.visitChildren(this); - } - } - - public final FunctionCallContext functionCall() throws RecognitionException { - FunctionCallContext _localctx = new FunctionCallContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_functionCall); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(117); - functionName(); - setState(118); - match(LPAR); - setState(127); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__3) | (1L << NodeType) | (1L << Number) | (1L << AxisName) | (1L << PATHSEP) | (1L << ABRPATH) | (1L << LPAR) | (1L << MINUS) | (1L << DOT) | (1L << MUL) | (1L << DOTDOT) | (1L << AT) | (1L << Literal) | (1L << NCName))) != 0)) { - { - setState(119); - expr(); - setState(124); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == COMMA) { - { - { - setState(120); - match(COMMA); - setState(121); - expr(); - } - } - setState(126); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - - setState(129); - match(RPAR); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class UnionExprNoRootContext extends ParserRuleContext { - public Token op; - - public PathExprNoRootContext pathExprNoRoot() { - return getRuleContext(PathExprNoRootContext.class, 0); - } - - public UnionExprNoRootContext unionExprNoRoot() { - return getRuleContext(UnionExprNoRootContext.class, 0); - } - - public TerminalNode PIPE() { - return getToken(XpathParser.PIPE, 0); - } - - public TerminalNode PATHSEP() { - return getToken(XpathParser.PATHSEP, 0); - } - - public UnionExprNoRootContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_unionExprNoRoot; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterUnionExprNoRoot(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitUnionExprNoRoot(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitUnionExprNoRoot(this); - else return visitor.visitChildren(this); - } - } - - public final UnionExprNoRootContext unionExprNoRoot() throws RecognitionException { - UnionExprNoRootContext _localctx = new UnionExprNoRootContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_unionExprNoRoot); - int _la; - try { - setState(139); - _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 11, _ctx)) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(131); - pathExprNoRoot(); - setState(134); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la == PIPE) { - { - setState(132); - ((UnionExprNoRootContext) _localctx).op = match(PIPE); - setState(133); - unionExprNoRoot(); - } - } - - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(136); - match(PATHSEP); - setState(137); - match(PIPE); - setState(138); - unionExprNoRoot(); - } - break; - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class PathExprNoRootContext extends ParserRuleContext { - public Token op; - - public LocationPathContext locationPath() { - return getRuleContext(LocationPathContext.class, 0); - } - - public FilterExprContext filterExpr() { - return getRuleContext(FilterExprContext.class, 0); - } - - public RelativeLocationPathContext relativeLocationPath() { - return getRuleContext(RelativeLocationPathContext.class, 0); - } - - public TerminalNode PATHSEP() { - return getToken(XpathParser.PATHSEP, 0); - } - - public TerminalNode ABRPATH() { - return getToken(XpathParser.ABRPATH, 0); - } - - public PathExprNoRootContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_pathExprNoRoot; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterPathExprNoRoot(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitPathExprNoRoot(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitPathExprNoRoot(this); - else return visitor.visitChildren(this); - } - } - - public final PathExprNoRootContext pathExprNoRoot() throws RecognitionException { - PathExprNoRootContext _localctx = new PathExprNoRootContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_pathExprNoRoot); - int _la; - try { - setState(147); - _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 13, _ctx)) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(141); - locationPath(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(142); - filterExpr(); - setState(145); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la == PATHSEP || _la == ABRPATH) { - { - setState(143); - ((PathExprNoRootContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!(_la == PATHSEP || _la == ABRPATH)) { - ((PathExprNoRootContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(144); - relativeLocationPath(); - } - } - - } - break; - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class FilterExprContext extends ParserRuleContext { - public PrimaryExprContext primaryExpr() { - return getRuleContext(PrimaryExprContext.class, 0); - } - - public List predicate() { - return getRuleContexts(PredicateContext.class); - } - - public PredicateContext predicate(int i) { - return getRuleContext(PredicateContext.class, i); - } - - public FilterExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_filterExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterFilterExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitFilterExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitFilterExpr(this); - else return visitor.visitChildren(this); - } - } - - public final FilterExprContext filterExpr() throws RecognitionException { - FilterExprContext _localctx = new FilterExprContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_filterExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(149); - primaryExpr(); - setState(153); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == LBRAC) { - { - { - setState(150); - predicate(); - } - } - setState(155); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class OrExprContext extends ParserRuleContext { - public List andExpr() { - return getRuleContexts(AndExprContext.class); - } - - public AndExprContext andExpr(int i) { - return getRuleContext(AndExprContext.class, i); - } - - public OrExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_orExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterOrExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitOrExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitOrExpr(this); - else return visitor.visitChildren(this); - } - } - - public final OrExprContext orExpr() throws RecognitionException { - OrExprContext _localctx = new OrExprContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_orExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(156); - andExpr(); - setState(161); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == T__1) { - { - { - setState(157); - match(T__1); - setState(158); - andExpr(); - } - } - setState(163); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class AndExprContext extends ParserRuleContext { - public List equalityExpr() { - return getRuleContexts(EqualityExprContext.class); - } - - public EqualityExprContext equalityExpr(int i) { - return getRuleContext(EqualityExprContext.class, i); - } - - public AndExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_andExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterAndExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitAndExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitAndExpr(this); - else return visitor.visitChildren(this); - } - } - - public final AndExprContext andExpr() throws RecognitionException { - AndExprContext _localctx = new AndExprContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_andExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(164); - equalityExpr(); - setState(169); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == T__2) { - { - { - setState(165); - match(T__2); - setState(166); - equalityExpr(); - } - } - setState(171); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class EqualityExprContext extends ParserRuleContext { - public Token op; - - public List relationalExpr() { - return getRuleContexts(RelationalExprContext.class); - } - - public RelationalExprContext relationalExpr(int i) { - return getRuleContext(RelationalExprContext.class, i); - } - - public List EQUALITY() { - return getTokens(XpathParser.EQUALITY); - } - - public TerminalNode EQUALITY(int i) { - return getToken(XpathParser.EQUALITY, i); - } - - public List INEQUALITY() { - return getTokens(XpathParser.INEQUALITY); - } - - public TerminalNode INEQUALITY(int i) { - return getToken(XpathParser.INEQUALITY, i); - } - - public EqualityExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_equalityExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterEqualityExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitEqualityExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitEqualityExpr(this); - else return visitor.visitChildren(this); - } - } - - public final EqualityExprContext equalityExpr() throws RecognitionException { - EqualityExprContext _localctx = new EqualityExprContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_equalityExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(172); - relationalExpr(); - setState(177); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == EQUALITY || _la == INEQUALITY) { - { - { - setState(173); - ((EqualityExprContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!(_la == EQUALITY || _la == INEQUALITY)) { - ((EqualityExprContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(174); - relationalExpr(); - } - } - setState(179); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class RelationalExprContext extends ParserRuleContext { - public Token op; - - public List additiveExpr() { - return getRuleContexts(AdditiveExprContext.class); - } - - public AdditiveExprContext additiveExpr(int i) { - return getRuleContext(AdditiveExprContext.class, i); - } - - public List LESS() { - return getTokens(XpathParser.LESS); - } - - public TerminalNode LESS(int i) { - return getToken(XpathParser.LESS, i); - } - - public List MORE_() { - return getTokens(XpathParser.MORE_); - } - - public TerminalNode MORE_(int i) { - return getToken(XpathParser.MORE_, i); - } - - public List GE() { - return getTokens(XpathParser.GE); - } - - public TerminalNode GE(int i) { - return getToken(XpathParser.GE, i); - } - - public List START_WITH() { - return getTokens(XpathParser.START_WITH); - } - - public TerminalNode START_WITH(int i) { - return getToken(XpathParser.START_WITH, i); - } - - public List END_WITH() { - return getTokens(XpathParser.END_WITH); - } - - public TerminalNode END_WITH(int i) { - return getToken(XpathParser.END_WITH, i); - } - - public List CONTAIN_WITH() { - return getTokens(XpathParser.CONTAIN_WITH); - } - - public TerminalNode CONTAIN_WITH(int i) { - return getToken(XpathParser.CONTAIN_WITH, i); - } - - public List REGEXP_WITH() { - return getTokens(XpathParser.REGEXP_WITH); - } - - public TerminalNode REGEXP_WITH(int i) { - return getToken(XpathParser.REGEXP_WITH, i); - } - - public List REGEXP_NOT_WITH() { - return getTokens(XpathParser.REGEXP_NOT_WITH); - } - - public TerminalNode REGEXP_NOT_WITH(int i) { - return getToken(XpathParser.REGEXP_NOT_WITH, i); - } - - public RelationalExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_relationalExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterRelationalExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitRelationalExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitRelationalExpr(this); - else return visitor.visitChildren(this); - } - } - - public final RelationalExprContext relationalExpr() throws RecognitionException { - RelationalExprContext _localctx = new RelationalExprContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_relationalExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(180); - additiveExpr(); - setState(185); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LESS) | (1L << MORE_) | (1L << GE) | (1L << START_WITH) | (1L << END_WITH) | (1L << CONTAIN_WITH) | (1L << REGEXP_WITH) | (1L << REGEXP_NOT_WITH))) != 0)) { - { - { - setState(181); - ((RelationalExprContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LESS) | (1L << MORE_) | (1L << GE) | (1L << START_WITH) | (1L << END_WITH) | (1L << CONTAIN_WITH) | (1L << REGEXP_WITH) | (1L << REGEXP_NOT_WITH))) != 0))) { - ((RelationalExprContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(182); - additiveExpr(); - } - } - setState(187); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class AdditiveExprContext extends ParserRuleContext { - public Token op; - - public List multiplicativeExpr() { - return getRuleContexts(MultiplicativeExprContext.class); - } - - public MultiplicativeExprContext multiplicativeExpr(int i) { - return getRuleContext(MultiplicativeExprContext.class, i); - } - - public List PLUS() { - return getTokens(XpathParser.PLUS); - } - - public TerminalNode PLUS(int i) { - return getToken(XpathParser.PLUS, i); - } - - public List MINUS() { - return getTokens(XpathParser.MINUS); - } - - public TerminalNode MINUS(int i) { - return getToken(XpathParser.MINUS, i); - } - - public AdditiveExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_additiveExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterAdditiveExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitAdditiveExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitAdditiveExpr(this); - else return visitor.visitChildren(this); - } - } - - public final AdditiveExprContext additiveExpr() throws RecognitionException { - AdditiveExprContext _localctx = new AdditiveExprContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_additiveExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(188); - multiplicativeExpr(); - setState(193); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la == MINUS || _la == PLUS) { - { - { - setState(189); - ((AdditiveExprContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!(_la == MINUS || _la == PLUS)) { - ((AdditiveExprContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(190); - multiplicativeExpr(); - } - } - setState(195); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class MultiplicativeExprContext extends ParserRuleContext { - public Token op; - - public UnaryExprNoRootContext unaryExprNoRoot() { - return getRuleContext(UnaryExprNoRootContext.class, 0); - } - - public MultiplicativeExprContext multiplicativeExpr() { - return getRuleContext(MultiplicativeExprContext.class, 0); - } - - public TerminalNode MUL() { - return getToken(XpathParser.MUL, 0); - } - - public TerminalNode DIVISION() { - return getToken(XpathParser.DIVISION, 0); - } - - public TerminalNode MODULO() { - return getToken(XpathParser.MODULO, 0); - } - - public MultiplicativeExprContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_multiplicativeExpr; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterMultiplicativeExpr(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitMultiplicativeExpr(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitMultiplicativeExpr(this); - else return visitor.visitChildren(this); - } - } - - public final MultiplicativeExprContext multiplicativeExpr() throws RecognitionException { - MultiplicativeExprContext _localctx = new MultiplicativeExprContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_multiplicativeExpr); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(196); - unaryExprNoRoot(); - setState(199); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MUL) | (1L << DIVISION) | (1L << MODULO))) != 0)) { - { - setState(197); - ((MultiplicativeExprContext) _localctx).op = _input.LT(1); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MUL) | (1L << DIVISION) | (1L << MODULO))) != 0))) { - ((MultiplicativeExprContext) _localctx).op = (Token) _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(198); - multiplicativeExpr(); - } - } - - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class UnaryExprNoRootContext extends ParserRuleContext { - public Token sign; - - public UnionExprNoRootContext unionExprNoRoot() { - return getRuleContext(UnionExprNoRootContext.class, 0); - } - - public TerminalNode MINUS() { - return getToken(XpathParser.MINUS, 0); - } - - public UnaryExprNoRootContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_unaryExprNoRoot; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterUnaryExprNoRoot(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitUnaryExprNoRoot(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitUnaryExprNoRoot(this); - else return visitor.visitChildren(this); - } - } - - public final UnaryExprNoRootContext unaryExprNoRoot() throws RecognitionException { - UnaryExprNoRootContext _localctx = new UnaryExprNoRootContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_unaryExprNoRoot); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(202); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la == MINUS) { - { - setState(201); - ((UnaryExprNoRootContext) _localctx).sign = match(MINUS); - } - } - - setState(204); - unionExprNoRoot(); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class QNameContext extends ParserRuleContext { - public List nCName() { - return getRuleContexts(NCNameContext.class); - } - - public NCNameContext nCName(int i) { - return getRuleContext(NCNameContext.class, i); - } - - public TerminalNode COLON() { - return getToken(XpathParser.COLON, 0); - } - - public QNameContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_qName; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterQName(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitQName(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitQName(this); - else return visitor.visitChildren(this); - } - } - - public final QNameContext qName() throws RecognitionException { - QNameContext _localctx = new QNameContext(_ctx, getState()); - enterRule(_localctx, 44, RULE_qName); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(206); - nCName(); - setState(209); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la == COLON) { - { - setState(207); - match(COLON); - setState(208); - nCName(); - } - } - - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class FunctionNameContext extends ParserRuleContext { - public QNameContext qName() { - return getRuleContext(QNameContext.class, 0); - } - - public FunctionNameContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_functionName; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterFunctionName(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitFunctionName(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitFunctionName(this); - else return visitor.visitChildren(this); - } - } - - public final FunctionNameContext functionName() throws RecognitionException { - FunctionNameContext _localctx = new FunctionNameContext(_ctx, getState()); - enterRule(_localctx, 46, RULE_functionName); - try { - enterOuterAlt(_localctx, 1); - { - setState(211); - qName(); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class VariableReferenceContext extends ParserRuleContext { - public QNameContext qName() { - return getRuleContext(QNameContext.class, 0); - } - - public VariableReferenceContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_variableReference; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).enterVariableReference(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) - ((XpathListener) listener).exitVariableReference(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitVariableReference(this); - else return visitor.visitChildren(this); - } - } - - public final VariableReferenceContext variableReference() throws RecognitionException { - VariableReferenceContext _localctx = new VariableReferenceContext(_ctx, getState()); - enterRule(_localctx, 48, RULE_variableReference); - try { - enterOuterAlt(_localctx, 1); - { - setState(213); - match(T__3); - setState(214); - qName(); - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class NameTestContext extends ParserRuleContext { - public TerminalNode MUL() { - return getToken(XpathParser.MUL, 0); - } - - public NCNameContext nCName() { - return getRuleContext(NCNameContext.class, 0); - } - - public TerminalNode COLON() { - return getToken(XpathParser.COLON, 0); - } - - public QNameContext qName() { - return getRuleContext(QNameContext.class, 0); - } - - public NameTestContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_nameTest; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterNameTest(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitNameTest(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitNameTest(this); - else return visitor.visitChildren(this); - } - } - - public final NameTestContext nameTest() throws RecognitionException { - NameTestContext _localctx = new NameTestContext(_ctx, getState()); - enterRule(_localctx, 50, RULE_nameTest); - try { - setState(222); - _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 23, _ctx)) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(216); - match(MUL); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(217); - nCName(); - setState(218); - match(COLON); - setState(219); - match(MUL); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(221); - qName(); - } - break; - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static class NCNameContext extends ParserRuleContext { - public TerminalNode NCName() { - return getToken(XpathParser.NCName, 0); - } - - public TerminalNode AxisName() { - return getToken(XpathParser.AxisName, 0); - } - - public NCNameContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - - @Override - public int getRuleIndex() { - return RULE_nCName; - } - - @Override - public void enterRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).enterNCName(this); - } - - @Override - public void exitRule(ParseTreeListener listener) { - if (listener instanceof XpathListener) ((XpathListener) listener).exitNCName(this); - } - - @Override - public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof XpathVisitor) - return ((XpathVisitor) visitor).visitNCName(this); - else return visitor.visitChildren(this); - } - } - - public final NCNameContext nCName() throws RecognitionException { - NCNameContext _localctx = new NCNameContext(_ctx, getState()); - enterRule(_localctx, 52, RULE_nCName); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(224); - _la = _input.LA(1); - if (!(_la == AxisName || _la == NCName)) { - _errHandler.recoverInline(this); - } else { - if (_input.LA(1) == Token.EOF) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } finally { - exitRule(); - } - return _localctx; - } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3+\u00e5\4\2\t\2\4" + - "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t" + - "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + - "\4\32\t\32\4\33\t\33\4\34\t\34\3\2\3\2\3\3\3\3\5\3=\n\3\3\4\3\4\3\4\3" + - "\5\3\5\3\5\7\5E\n\5\f\5\16\5H\13\5\3\6\3\6\3\6\7\6M\n\6\f\6\16\6P\13\6" + - "\3\6\5\6S\n\6\3\7\3\7\3\7\5\7X\n\7\5\7Z\n\7\3\b\3\b\3\b\3\b\3\b\3\b\3" + - "\b\3\b\5\bd\n\b\3\t\3\t\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\f\3\f" + - "\3\f\3\f\3\f\5\fv\n\f\3\r\3\r\3\r\3\r\3\r\7\r}\n\r\f\r\16\r\u0080\13\r" + - "\5\r\u0082\n\r\3\r\3\r\3\16\3\16\3\16\5\16\u0089\n\16\3\16\3\16\3\16\5" + - "\16\u008e\n\16\3\17\3\17\3\17\3\17\5\17\u0094\n\17\5\17\u0096\n\17\3\20" + - "\3\20\7\20\u009a\n\20\f\20\16\20\u009d\13\20\3\21\3\21\3\21\7\21\u00a2" + - "\n\21\f\21\16\21\u00a5\13\21\3\22\3\22\3\22\7\22\u00aa\n\22\f\22\16\22" + - "\u00ad\13\22\3\23\3\23\3\23\7\23\u00b2\n\23\f\23\16\23\u00b5\13\23\3\24" + - "\3\24\3\24\7\24\u00ba\n\24\f\24\16\24\u00bd\13\24\3\25\3\25\3\25\7\25" + - "\u00c2\n\25\f\25\16\25\u00c5\13\25\3\26\3\26\3\26\5\26\u00ca\n\26\3\27" + - "\5\27\u00cd\n\27\3\27\3\27\3\30\3\30\3\30\5\30\u00d4\n\30\3\31\3\31\3" + - "\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\33\5\33\u00e1\n\33\3\34\3\34" + - "\3\34\2\2\35\2\4\6\b\n\f\16\20\22\24\26\30\32\34\36 \"$&(*,.\60\62\64" + - "\66\2\t\3\2\n\13\4\2\22\22\26\26\3\2\36\37\5\2\32\33\35\35 $\3\2\20\21" + - "\3\2\23\25\4\2\t\t++\2\u00e6\28\3\2\2\2\4<\3\2\2\2\6>\3\2\2\2\bA\3\2\2" + - "\2\nR\3\2\2\2\fY\3\2\2\2\16c\3\2\2\2\20e\3\2\2\2\22i\3\2\2\2\24k\3\2\2" + - "\2\26u\3\2\2\2\30w\3\2\2\2\32\u008d\3\2\2\2\34\u0095\3\2\2\2\36\u0097" + - "\3\2\2\2 \u009e\3\2\2\2\"\u00a6\3\2\2\2$\u00ae\3\2\2\2&\u00b6\3\2\2\2" + - "(\u00be\3\2\2\2*\u00c6\3\2\2\2,\u00cc\3\2\2\2.\u00d0\3\2\2\2\60\u00d5" + - "\3\2\2\2\62\u00d7\3\2\2\2\64\u00e0\3\2\2\2\66\u00e2\3\2\2\289\5\24\13" + - "\29\3\3\2\2\2:=\5\b\5\2;=\5\6\4\2<:\3\2\2\2<;\3\2\2\2=\5\3\2\2\2>?\t\2" + - "\2\2?@\5\b\5\2@\7\3\2\2\2AF\5\n\6\2BC\t\2\2\2CE\5\n\6\2DB\3\2\2\2EH\3" + - "\2\2\2FD\3\2\2\2FG\3\2\2\2G\t\3\2\2\2HF\3\2\2\2IJ\5\f\7\2JN\5\16\b\2K" + - "M\5\20\t\2LK\3\2\2\2MP\3\2\2\2NL\3\2\2\2NO\3\2\2\2OS\3\2\2\2PN\3\2\2\2" + - "QS\5\22\n\2RI\3\2\2\2RQ\3\2\2\2S\13\3\2\2\2TU\7\t\2\2UZ\7&\2\2VX\7\27" + - "\2\2WV\3\2\2\2WX\3\2\2\2XZ\3\2\2\2YT\3\2\2\2YW\3\2\2\2Z\r\3\2\2\2[d\5" + - "\64\33\2\\]\7\7\2\2]^\7\f\2\2^d\7\r\2\2_`\7\3\2\2`a\7\f\2\2ab\7)\2\2b" + - "d\7\r\2\2c[\3\2\2\2c\\\3\2\2\2c_\3\2\2\2d\17\3\2\2\2ef\7\16\2\2fg\5\24" + - "\13\2gh\7\17\2\2h\21\3\2\2\2ij\t\3\2\2j\23\3\2\2\2kl\5 \21\2l\25\3\2\2" + - "\2mv\5\62\32\2no\7\f\2\2op\5\24\13\2pq\7\r\2\2qv\3\2\2\2rv\7)\2\2sv\7" + - "\b\2\2tv\5\30\r\2um\3\2\2\2un\3\2\2\2ur\3\2\2\2us\3\2\2\2ut\3\2\2\2v\27" + - "\3\2\2\2wx\5\60\31\2x\u0081\7\f\2\2y~\5\24\13\2z{\7\30\2\2{}\5\24\13\2" + - "|z\3\2\2\2}\u0080\3\2\2\2~|\3\2\2\2~\177\3\2\2\2\177\u0082\3\2\2\2\u0080" + - "~\3\2\2\2\u0081y\3\2\2\2\u0081\u0082\3\2\2\2\u0082\u0083\3\2\2\2\u0083" + - "\u0084\7\r\2\2\u0084\31\3\2\2\2\u0085\u0088\5\34\17\2\u0086\u0087\7\31" + - "\2\2\u0087\u0089\5\32\16\2\u0088\u0086\3\2\2\2\u0088\u0089\3\2\2\2\u0089" + - "\u008e\3\2\2\2\u008a\u008b\7\n\2\2\u008b\u008c\7\31\2\2\u008c\u008e\5" + - "\32\16\2\u008d\u0085\3\2\2\2\u008d\u008a\3\2\2\2\u008e\33\3\2\2\2\u008f" + - "\u0096\5\4\3\2\u0090\u0093\5\36\20\2\u0091\u0092\t\2\2\2\u0092\u0094\5" + - "\b\5\2\u0093\u0091\3\2\2\2\u0093\u0094\3\2\2\2\u0094\u0096\3\2\2\2\u0095" + - "\u008f\3\2\2\2\u0095\u0090\3\2\2\2\u0096\35\3\2\2\2\u0097\u009b\5\26\f" + - "\2\u0098\u009a\5\20\t\2\u0099\u0098\3\2\2\2\u009a\u009d\3\2\2\2\u009b" + - "\u0099\3\2\2\2\u009b\u009c\3\2\2\2\u009c\37\3\2\2\2\u009d\u009b\3\2\2" + - "\2\u009e\u00a3\5\"\22\2\u009f\u00a0\7\4\2\2\u00a0\u00a2\5\"\22\2\u00a1" + - "\u009f\3\2\2\2\u00a2\u00a5\3\2\2\2\u00a3\u00a1\3\2\2\2\u00a3\u00a4\3\2" + - "\2\2\u00a4!\3\2\2\2\u00a5\u00a3\3\2\2\2\u00a6\u00ab\5$\23\2\u00a7\u00a8" + - "\7\5\2\2\u00a8\u00aa\5$\23\2\u00a9\u00a7\3\2\2\2\u00aa\u00ad\3\2\2\2\u00ab" + - "\u00a9\3\2\2\2\u00ab\u00ac\3\2\2\2\u00ac#\3\2\2\2\u00ad\u00ab\3\2\2\2" + - "\u00ae\u00b3\5&\24\2\u00af\u00b0\t\4\2\2\u00b0\u00b2\5&\24\2\u00b1\u00af" + - "\3\2\2\2\u00b2\u00b5\3\2\2\2\u00b3\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4" + - "%\3\2\2\2\u00b5\u00b3\3\2\2\2\u00b6\u00bb\5(\25\2\u00b7\u00b8\t\5\2\2" + - "\u00b8\u00ba\5(\25\2\u00b9\u00b7\3\2\2\2\u00ba\u00bd\3\2\2\2\u00bb\u00b9" + - "\3\2\2\2\u00bb\u00bc\3\2\2\2\u00bc\'\3\2\2\2\u00bd\u00bb\3\2\2\2\u00be" + - "\u00c3\5*\26\2\u00bf\u00c0\t\6\2\2\u00c0\u00c2\5*\26\2\u00c1\u00bf\3\2" + - "\2\2\u00c2\u00c5\3\2\2\2\u00c3\u00c1\3\2\2\2\u00c3\u00c4\3\2\2\2\u00c4" + - ")\3\2\2\2\u00c5\u00c3\3\2\2\2\u00c6\u00c9\5,\27\2\u00c7\u00c8\t\7\2\2" + - "\u00c8\u00ca\5*\26\2\u00c9\u00c7\3\2\2\2\u00c9\u00ca\3\2\2\2\u00ca+\3" + - "\2\2\2\u00cb\u00cd\7\20\2\2\u00cc\u00cb\3\2\2\2\u00cc\u00cd\3\2\2\2\u00cd" + - "\u00ce\3\2\2\2\u00ce\u00cf\5\32\16\2\u00cf-\3\2\2\2\u00d0\u00d3\5\66\34" + - "\2\u00d1\u00d2\7%\2\2\u00d2\u00d4\5\66\34\2\u00d3\u00d1\3\2\2\2\u00d3" + - "\u00d4\3\2\2\2\u00d4/\3\2\2\2\u00d5\u00d6\5.\30\2\u00d6\61\3\2\2\2\u00d7" + - "\u00d8\7\6\2\2\u00d8\u00d9\5.\30\2\u00d9\63\3\2\2\2\u00da\u00e1\7\23\2" + - "\2\u00db\u00dc\5\66\34\2\u00dc\u00dd\7%\2\2\u00dd\u00de\7\23\2\2\u00de" + - "\u00e1\3\2\2\2\u00df\u00e1\5.\30\2\u00e0\u00da\3\2\2\2\u00e0\u00db\3\2" + - "\2\2\u00e0\u00df\3\2\2\2\u00e1\65\3\2\2\2\u00e2\u00e3\t\b\2\2\u00e3\67" + - "\3\2\2\2\32 The return type of the visit operation. Use {@link Void} for - * operations with no return type. - */ -public interface XpathVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link XpathParser#main}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitMain(XpathParser.MainContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#locationPath}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitLocationPath(XpathParser.LocationPathContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#absoluteLocationPathNoroot}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#relativeLocationPath}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#step}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitStep(XpathParser.StepContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#axisSpecifier}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitAxisSpecifier(XpathParser.AxisSpecifierContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#nodeTest}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitNodeTest(XpathParser.NodeTestContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#predicate}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitPredicate(XpathParser.PredicateContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#abbreviatedStep}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#expr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpr(XpathParser.ExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#primaryExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitPrimaryExpr(XpathParser.PrimaryExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#functionCall}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunctionCall(XpathParser.FunctionCallContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#unionExprNoRoot}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#pathExprNoRoot}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitPathExprNoRoot(XpathParser.PathExprNoRootContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#filterExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitFilterExpr(XpathParser.FilterExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#orExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitOrExpr(XpathParser.OrExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#andExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitAndExpr(XpathParser.AndExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#equalityExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitEqualityExpr(XpathParser.EqualityExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#relationalExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitRelationalExpr(XpathParser.RelationalExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#additiveExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitAdditiveExpr(XpathParser.AdditiveExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#multiplicativeExpr}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#unaryExprNoRoot}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#qName}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitQName(XpathParser.QNameContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#functionName}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunctionName(XpathParser.FunctionNameContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#variableReference}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitVariableReference(XpathParser.VariableReferenceContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#nameTest}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitNameTest(XpathParser.NameTestContext ctx); - - /** - * Visit a parse tree produced by {@link XpathParser#nCName}. - * - * @param ctx the parse tree - * @return the visitor result - */ - T visitNCName(XpathParser.NCNameContext ctx); -} \ No newline at end of file diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/AxisSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/AxisSelector.java deleted file mode 100644 index fa726fcb8..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/AxisSelector.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.seimicrawler.xpath.core; - -import org.jsoup.select.Elements; - -/** - * https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-AxisSpecifier - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public interface AxisSelector { - /** - * assign name - * - * @return name - */ - String name(); - - /** - * @param context - * @return res - */ - XValue apply(Elements context); -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Constants.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Constants.java deleted file mode 100644 index 617de970f..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Constants.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.seimicrawler.xpath.core; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2020/9/24. - */ -public class Constants { - public final static String DEF_TEXT_TAG_NAME = "JX_TEXT"; - public final static String EL_SAME_TAG_INDEX_KEY = "EL_SAME_TAG_INDEX_KEY"; -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Function.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Function.java deleted file mode 100644 index e1cd6ff60..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Function.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.seimicrawler.xpath.core; - -import java.util.List; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public interface Function { - String name(); - - XValue call(Scope scope, List params); -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/NodeTest.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/NodeTest.java deleted file mode 100644 index 99ca5c0b7..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/NodeTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.seimicrawler.xpath.core; - - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public interface NodeTest { - /** - * 支持的函数名 - */ - String name(); - - /** - * 函数具体逻辑 - * - * @param scope 上下文 - * @return 计算好的节点 - */ - XValue call(Scope scope); -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Scope.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Scope.java deleted file mode 100644 index fda915c8d..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/Scope.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.seimicrawler.xpath.core; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.exception.XpathParserException; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/13. - */ -public class Scope { - private Elements context; - private boolean isRecursion = false; - private Scope parent; - - private Scope(Elements context) { - super(); - this.context = new Elements(); - this.context.addAll(context); - } - - private Scope(Element context) { - super(); - this.context = new Elements(); - this.context.add(context); - } - - public static Scope create(Elements elements) { - return new Scope(elements); - } - - public static Scope create(Element el) { - return new Scope(el); - } - - public static Scope create(Scope scope) { - return new Scope(scope.context()).setParent(scope); - } - - public Scope setParent(Scope scope) { - this.parent = scope; - return this; - } - - public Scope getParent() { - return parent; - } - - public void setContext(Elements context) { - this.context = context; - } - - public boolean isRecursion() { - return isRecursion; - } - - void recursion() { - this.isRecursion = true; - } - - public void notRecursion() { - this.isRecursion = false; - } - - public Elements context() { - return this.context; - } - - public Element singleEl() { - if (context.size() == 1) { - return context.first(); - } - throw new XpathParserException("current context is more than one el,total = " + context.size()); - } -} - diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XValue.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XValue.java deleted file mode 100644 index 2b30bc23b..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XValue.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.seimicrawler.xpath.core; - -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.time.DateFormatUtils; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.exception.XpathParserException; - -import java.math.BigDecimal; -import java.text.ParseException; -import java.util.Date; -import java.util.List; -import java.util.Objects; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2017/12/5. - */ -public class XValue implements Comparable { - public XValue(Object val) { - this.value = val; - } - - public static XValue create(Object val) { - return new XValue(val); - } - - private Object value; - - private boolean isAttr = false; - private boolean isExprStr = false; - - /** - * 同类型节点的顺序 - */ - private int siblingIndex; - - /** - * 满足特殊场景计算筛选需求 - */ - private List xValues; - - public boolean isBoolean() { - return value instanceof Boolean; - } - - public boolean isNumber() { - return value instanceof Number; - } - - public boolean isElements() { - return value instanceof Elements; - } - - public boolean isString() { - return value instanceof String; - } - - public boolean isList() { - return value instanceof List; - } - - public boolean isDate() { - return value instanceof Date; - } - - public Boolean asBoolean() { - if (value instanceof Boolean) { - return (Boolean) value; - } - return value != null && !StringUtils.isBlank(asString()); - } - - public Date asDate() { - if (value instanceof String) { - try { - return DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.parse((String) value); - } catch (ParseException e) { - throw new XpathParserException("cast to date fail. vale = " + value); - } - } - if (value instanceof Date) { - return (Date) value; - } - throw new XpathParserException("cast to date fail. vale = " + value); - } - - public Double asDouble() { - if (value instanceof String) { - return new BigDecimal((String) value).doubleValue(); - } else if (value instanceof Number) { - return ((Number) value).doubleValue(); - } else { - throw new XpathParserException("cast to number fail. vale = " + value); - } - } - - public Long asLong() { - if (value instanceof String) { - //对于带小数点的,四舍五入 - return new BigDecimal((String) value).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); - } else if (value instanceof Number) { - return ((Number) value).longValue(); - } else { - throw new XpathParserException("cast to number fail. vale = " + value); - } - } - - public Elements asElements() { - return (Elements) value; - } - - public String asString() { - if (isElements()) { - StringBuilder accum = new StringBuilder(); - for (Element e : asElements()) { - accum.append(e.ownText()); - } - return accum.toString(); - } else if (value instanceof Element && Objects.equals(((Element) value).tagName(), Constants.DEF_TEXT_TAG_NAME)) { - return ((Element) value).ownText(); - } else if (value instanceof List) { - return StringUtils.join((List) value, ","); - } else { - return String.valueOf(value).trim(); - } - } - - public List asList() { - return (List) value; - } - - public XValue attr() { - this.isAttr = true; - return this; - } - - public boolean isAttr() { - return isAttr; - } - - public XValue exprStr() { - this.isExprStr = true; - String str = StringUtils.removeStart(String.valueOf(this.value), "'"); - str = StringUtils.removeStart(str, "\""); - str = StringUtils.removeEnd(str, "'"); - this.value = StringUtils.removeEnd(str, "\""); - return this; - } - - public boolean isExprStr() { - return isExprStr; - } - - public int getSiblingIndex() { - return siblingIndex; - } - - public void setSiblingIndex(int siblingIndex) { - this.siblingIndex = siblingIndex; - } - - public List getxValues() { - return xValues; - } - - public void setxValues(List xValues) { - this.xValues = xValues; - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .append("value", value) - .append("isAttr", isAttr) - .append("isExprStr", isExprStr) - .toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - XValue value1 = (XValue) o; - return Objects.equals(value, value1.value); - } - - @Override - public int hashCode() { - return Objects.hashCode(value); - } - - - @Override - public int compareTo(XValue o) { - if (this.equals(o)) { - return 0; - } - if (o == null || o.value == null) { - return 1; - } - if (this.value == null) { - return -1; - } - - if (isString()) { - return asString().compareTo(o.asString()); - } else if (isNumber()) { - return asDouble().compareTo(o.asDouble()); - } else { - throw new XpathParserException("Unsupported comparable XValue = " + toString()); - } - } - - public Class valType() { - if (value == null) { - return Object.class; - } - return value.getClass(); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XpathProcessor.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XpathProcessor.java deleted file mode 100644 index c3480546f..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/XpathProcessor.java +++ /dev/null @@ -1,613 +0,0 @@ -package org.seimicrawler.xpath.core; - -import org.antlr.v4.runtime.tree.ParseTree; -import org.antlr.v4.runtime.tree.TerminalNode; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.antlr.XpathBaseVisitor; -import org.seimicrawler.xpath.antlr.XpathParser; -import org.seimicrawler.xpath.exception.XpathMergeValueException; -import org.seimicrawler.xpath.exception.XpathParserException; -import org.seimicrawler.xpath.util.CommonUtil; -import org.seimicrawler.xpath.util.Scanner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.Stack; - -import static org.seimicrawler.xpath.antlr.XpathParser.CONTAIN_WITH; -import static org.seimicrawler.xpath.antlr.XpathParser.DIVISION; -import static org.seimicrawler.xpath.antlr.XpathParser.END_WITH; -import static org.seimicrawler.xpath.antlr.XpathParser.GE; -import static org.seimicrawler.xpath.antlr.XpathParser.LE; -import static org.seimicrawler.xpath.antlr.XpathParser.LESS; -import static org.seimicrawler.xpath.antlr.XpathParser.MODULO; -import static org.seimicrawler.xpath.antlr.XpathParser.MORE_; -import static org.seimicrawler.xpath.antlr.XpathParser.MUL; -import static org.seimicrawler.xpath.antlr.XpathParser.REGEXP_NOT_WITH; -import static org.seimicrawler.xpath.antlr.XpathParser.REGEXP_WITH; -import static org.seimicrawler.xpath.antlr.XpathParser.START_WITH; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2017/8/30. - */ -public class XpathProcessor extends XpathBaseVisitor { - private final Logger logger = LoggerFactory.getLogger(XpathProcessor.class); - private final Stack scopeStack = new Stack<>(); - private final Scope rootScope; - - public XpathProcessor(Elements root) { - rootScope = Scope.create(root); - scopeStack.push(Scope.create(root).setParent(rootScope)); - } - - @Override - public XValue visitMain(XpathParser.MainContext ctx) { - return visit(ctx.expr()); - } - - @Override - public XValue visitLocationPath(XpathParser.LocationPathContext ctx) { - if (ctx.relativeLocationPath() != null && !ctx.relativeLocationPath().isEmpty()) { - return visit(ctx.relativeLocationPath()); - } - return visit(ctx.absoluteLocationPathNoroot()); - } - - @Override - public XValue visitAbsoluteLocationPathNoroot(XpathParser.AbsoluteLocationPathNorootContext ctx) { - // '//' - if (Objects.equals(ctx.op.getText(), "//")) { - currentScope().recursion(); - } - return visit(ctx.relativeLocationPath()); - } - - @Override - public XValue visitRelativeLocationPath(XpathParser.RelativeLocationPathContext ctx) { - XValue finalVal = null; - for (int i = 0; i < ctx.getChildCount(); i++) { - ParseTree step = ctx.getChild(i); - if (step instanceof XpathParser.StepContext) { - finalVal = visit(step); - if (finalVal.isElements()) { - updateCurrentContext(finalVal.asElements()); - } - } else { - if ("//".equals(step.getText())) { - currentScope().recursion(); - } else { - currentScope().notRecursion(); - } - } - } - return finalVal; - } - - @Override - public XValue visitStep(XpathParser.StepContext ctx) { - if (ctx.abbreviatedStep() != null && !ctx.abbreviatedStep().isEmpty()) { - return visit(ctx.abbreviatedStep()); - } - boolean filterByAttr = false; - boolean isAxisOk = false; - if (ctx.axisSpecifier() != null && !ctx.axisSpecifier().isEmpty()) { - XValue axis = visit(ctx.axisSpecifier()); - if (axis != null) { - isAxisOk = true; - if (axis.isElements()) { - updateCurrentContext(axis.asElements()); - } else if (axis.isAttr()) { - filterByAttr = true; - } - } - } - if (ctx.nodeTest() != null && !ctx.nodeTest().isEmpty()) { - XValue nodeTest = visit(ctx.nodeTest()); - if (filterByAttr) { - Elements context = currentScope().context(); - String attrName = nodeTest.asString(); - if (currentScope().isRecursion()) { - if (context.size() == 1) { - Element el = currentScope().singleEl(); - Elements findRes = el.select("[" + attrName + "]"); - List attrs = new LinkedList<>(); - for (Element e : findRes) { - attrs.add(e.attr(attrName)); - } - return XValue.create(attrs); - } else { - Elements findRes = new Elements(); - for (Element el : context) { - findRes.addAll(el.select("[" + attrName + "]")); - } - List attrs = new LinkedList<>(); - for (Element e : findRes) { - attrs.add(e.attr(attrName)); - } - return XValue.create(attrs); - } - } else { - if (context.size() == 1) { - Element el = currentScope().singleEl(); - return XValue.create(el.attr(attrName)); - } else { - List attrs = new LinkedList<>(); - for (Element el : context) { - attrs.add(el.attr(attrName)); - } - return XValue.create(attrs); - } - } - - } else { - if (nodeTest.isExprStr()) { - String tagName = nodeTest.asString(); - Elements current = currentScope().context(); - if (currentScope().isRecursion()) { - updateCurrentContext(current.select(tagName)); - } else { - Elements newContext = new Elements(); - for (Element el : currentScope().context()) { - if (isAxisOk) { - if (el.nodeName().equals(tagName) || "*".equals(tagName)) { - newContext.add(el); - } - } else { - for (Element e : el.children()) { - if (e.nodeName().equals(tagName) || "*".equals(tagName)) { - newContext.add(e); - } - } - } - - } - updateCurrentContext(newContext); - } - } else { - // nodeType 计算结果,直接返给上层 - if (nodeTest.isElements()) { - updateCurrentContext(nodeTest.asElements()); - } else { - return nodeTest; - } - } - } - } - if (ctx.predicate() != null && ctx.predicate().size() > 0) { - for (XpathParser.PredicateContext predicate : ctx.predicate()) { - XValue predicateVal = visit(predicate); - updateCurrentContext(predicateVal.asElements()); - } - } - return XValue.create(currentScope().context()); - } - - @Override - public XValue visitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx) { - if ("..".equals(ctx.getText())) { - Set total = new HashSet<>(); - Elements newContext = new Elements(); - for (Element e : currentScope().context()) { - total.add(e.parent()); - } - newContext.addAll(total); - return XValue.create(newContext); - } else { - return XValue.create(currentScope().context()); - } - } - - @Override - public XValue visitAxisSpecifier(XpathParser.AxisSpecifierContext ctx) { - TerminalNode axisNode = ctx.AxisName(); - if (axisNode != null) { - String axis = ctx.AxisName().getText(); - AxisSelector axisSelector = Scanner.findSelectorByName(axis); - return axisSelector.apply(currentScope().context()); - } else { - String token = ctx.getText(); - if ("@".equals(token)) { - return XValue.create(null).attr(); - } - } - return null; - } - - @Override - public XValue visitNodeTest(XpathParser.NodeTestContext ctx) { - if (ctx.nameTest() != null) { - return visit(ctx.nameTest()); - } - if (ctx.NodeType() != null) { - NodeTest nodeTest = Scanner.findNodeTestByName(ctx.NodeType().getText()); - return nodeTest.call(currentScope()); - } - // todo: | 'processing-instruction' '(' Literal ')' - return null; - } - - @Override - public XValue visitPredicate(XpathParser.PredicateContext ctx) { - Elements newContext = new Elements(); - for (Element e : currentScope().context()) { - scopeStack.push(Scope.create(e).setParent(currentScope())); - XValue exprVal = visit(ctx.expr()); - scopeStack.pop(); - if (exprVal.isNumber()) { - long index = exprVal.asLong(); - if (index < 0) { - if (Objects.equals(e.tagName(), Constants.DEF_TEXT_TAG_NAME)) { - index = CommonUtil.getJxSameTagIndexInSiblings(e) + index + 1; - } else { - index = CommonUtil.sameTagElNums(e, currentScope()) + index + 1; - } - if (index < 0) { - index = 1; - } - } - if (Objects.equals(e.tagName(), Constants.DEF_TEXT_TAG_NAME)) { - if (index == CommonUtil.getJxSameTagIndexInSiblings(e)) { - newContext.add(e); - } - } else { - if (index == CommonUtil.getElIndexInSameTags(e, currentScope())) { - newContext.add(e); - } - } - - } else if (exprVal.isBoolean()) { - if (exprVal.asBoolean()) { - newContext.add(e); - } - } else if (exprVal.isString()) { - //根据表达式执行结果是否为空作为条件,如 //*[@foo] - if (StringUtils.isNotBlank(exprVal.asString())) { - newContext.add(e); - } - } else if (exprVal.isElements()) { - //根据表达式执行结果是否为空进行过滤,如 //div[./a] - Elements els = exprVal.asElements(); - if (els.size() > 0) { - newContext.add(e); - } - } else if (exprVal.isList()) { - //根据表达式执行结果是否为空进行过滤,如 //div[./a/text()] - List stringList = exprVal.asList(); - if (stringList.size() > 0) { - newContext.add(e); - } - } else { - throw new XpathParserException("unknown expr val:" + exprVal); - } - } - return XValue.create(newContext); - } - - @Override - public XValue visitNameTest(XpathParser.NameTestContext ctx) { - if ("*".equals(ctx.getText())) { - return XValue.create("*").exprStr(); - } else if (ctx.qName() != null && !ctx.qName().isEmpty()) { - return visit(ctx.qName()); - } else if (ctx.nCName() != null && !ctx.nCName().isEmpty()) { - return visit(ctx.nCName()); - } - return null; - } - - @Override - public XValue visitQName(XpathParser.QNameContext ctx) { - List ncNameContexts = ctx.nCName(); - if (ncNameContexts != null) { - if (ncNameContexts.size() > 1) { - List ncNames = new LinkedList<>(); - for (XpathParser.NCNameContext ncNameContext : ncNameContexts) { - XValue value = visit(ncNameContext); - if (value != null) { - ncNames.add(value.asString()); - } - } - // TODO: 2018/3/14 考虑体现出这个结构来 - return XValue.create(StringUtils.join(ncNames, ":")); - } else { - return visit(ncNameContexts.get(0)); - } - } - return null; - } - - @Override - public XValue visitNCName(XpathParser.NCNameContext ctx) { - if (ctx.AxisName() != null) { - return XValue.create(ctx.AxisName().getText()).exprStr(); - } else { - return XValue.create(ctx.NCName().getText()).exprStr(); - } - } - - @Override - public XValue visitExpr(XpathParser.ExprContext ctx) { - return visit(ctx.orExpr()); - } - - @Override - public XValue visitOrExpr(XpathParser.OrExprContext ctx) { - List andExprContexts = ctx.andExpr(); - if (andExprContexts.size() > 1) { - Boolean res = visit(andExprContexts.get(0)).asBoolean(); - for (int i = 1; i < andExprContexts.size(); i++) { - res = (res | visit(andExprContexts.get(i)).asBoolean()); - } - return XValue.create(res); - } else { - return visit(andExprContexts.get(0)); - } - } - - @Override - public XValue visitAndExpr(XpathParser.AndExprContext ctx) { - List equalityExprContexts = ctx.equalityExpr(); - if (equalityExprContexts.size() > 1) { - Boolean res = visit(equalityExprContexts.get(0)).asBoolean(); - for (int i = 1; i < equalityExprContexts.size(); i++) { - res = (res & visit(equalityExprContexts.get(i)).asBoolean()); - } - return XValue.create(res); - } else { - return visit(equalityExprContexts.get(0)); - } - } - - @Override - public XValue visitEqualityExpr(XpathParser.EqualityExprContext ctx) { - List relationalExprContexts = ctx.relationalExpr(); - if (relationalExprContexts.size() == 1) { - return visit(relationalExprContexts.get(0)); - } else if (relationalExprContexts.size() == 2) { - XValue left = visit(relationalExprContexts.get(0)); - XValue right = visit(relationalExprContexts.get(1)); - if ("=".equals(ctx.op.getText())) { - if (left.valType().equals(right.valType())) { - return XValue.create(Objects.equals(left, right)); - } else { - return XValue.create(Objects.equals(left.asString(), right.asString())); - } - } else { - if (left.valType().equals(right.valType())) { - return XValue.create(!Objects.equals(left, right)); - } else { - return XValue.create(!Objects.equals(left.asString(), right.asString())); - } - } - } else { - throw new XpathParserException("error equalityExpr near:" + ctx.getText()); - } - } - - @Override - public XValue visitRelationalExpr(XpathParser.RelationalExprContext ctx) { - List additiveExprContexts = ctx.additiveExpr(); - if (additiveExprContexts.size() == 1) { - return visit(additiveExprContexts.get(0)); - } else if (additiveExprContexts.size() == 2) { - XValue left = visit(additiveExprContexts.get(0)); - XValue right = visit(additiveExprContexts.get(1)); - switch (ctx.op.getType()) { - case MORE_: - return XValue.create(left.compareTo(right) > 0); - case GE: - return XValue.create(left.compareTo(right) >= 0); - case LESS: - return XValue.create(left.compareTo(right) < 0); - case LE: - return XValue.create(left.compareTo(right) <= 0); - case START_WITH: - return XValue.create(left.asString().startsWith(right.asString())); - case END_WITH: - return XValue.create(left.asString().endsWith(right.asString())); - case CONTAIN_WITH: - return XValue.create(left.asString().contains(right.asString())); - case REGEXP_WITH: - return XValue.create(left.asString().matches(right.asString())); - case REGEXP_NOT_WITH: - return XValue.create(!left.asString().matches(right.asString())); - default: - throw new XpathParserException("unknown operator" + ctx.op.getText()); - } - } else { - throw new XpathParserException("error equalityExpr near:" + ctx.getText()); - } - } - - @Override - public XValue visitAdditiveExpr(XpathParser.AdditiveExprContext ctx) { - List multiplicativeExprContexts = ctx.multiplicativeExpr(); - if (multiplicativeExprContexts.size() == 1) { - return visit(multiplicativeExprContexts.get(0)); - } else { - Double res = visit(multiplicativeExprContexts.get(0)).asDouble(); - String op = null; - for (int i = 1; i < ctx.getChildCount(); i++) { - ParseTree chiCtx = ctx.getChild(i); - if (chiCtx instanceof XpathParser.MultiplicativeExprContext) { - XValue next = visit(chiCtx); - if ("+".equals(op)) { - res += next.asDouble(); - } else if ("-".equals(op)) { - res -= next.asDouble(); - } else { - throw new XpathParserException("syntax error, " + ctx.getText()); - } - } else { - op = chiCtx.getText(); - } - } - return XValue.create(res); - } - } - - @Override - public XValue visitMultiplicativeExpr(XpathParser.MultiplicativeExprContext ctx) { - if (ctx.multiplicativeExpr() == null || ctx.multiplicativeExpr().isEmpty()) { - return visit(ctx.unaryExprNoRoot()); - } else { - XValue left = visit(ctx.unaryExprNoRoot()); - XValue right = visit(ctx.multiplicativeExpr()); - switch (ctx.op.getType()) { - case MUL: - return XValue.create(left.asDouble() * right.asDouble()); - case DIVISION: - return XValue.create(left.asDouble() / right.asDouble()); - case MODULO: - return XValue.create(left.asDouble() % right.asDouble()); - default: - throw new XpathParserException("syntax error, " + ctx.getText()); - } - } - } - - @Override - public XValue visitUnaryExprNoRoot(XpathParser.UnaryExprNoRootContext ctx) { - XValue value = visit(ctx.unionExprNoRoot()); - if (ctx.sign == null) { - return value; - } - return XValue.create(-value.asDouble()); - } - - @Override - public XValue visitUnionExprNoRoot(XpathParser.UnionExprNoRootContext ctx) { - if (ctx.pathExprNoRoot() == null && !ctx.pathExprNoRoot().isEmpty()) { - return visit(ctx.unionExprNoRoot()); - } - XValue pathExprNoRoot = visit(ctx.pathExprNoRoot()); - if (ctx.op == null) { - return pathExprNoRoot; - } - scopeStack.push(Scope.create(currentScope().getParent())); - XValue unionExprNoRoot = visit(ctx.unionExprNoRoot()); - scopeStack.pop(); - if (pathExprNoRoot.isElements()) { - if (unionExprNoRoot.isElements()) { - pathExprNoRoot.asElements().addAll(unionExprNoRoot.asElements()); - } else { - Element element = new Element("V"); - element.appendText(unionExprNoRoot.asString()); - pathExprNoRoot.asElements().add(element); - } - return pathExprNoRoot; - } else if (pathExprNoRoot.isString()) { - if (unionExprNoRoot.isElements()) { - Element element = new Element("V"); - element.appendText(pathExprNoRoot.asString()); - unionExprNoRoot.asElements().add(element); - return unionExprNoRoot; - } else { - return XValue.create(pathExprNoRoot.asString() + unionExprNoRoot.asString()); - } - } else if (pathExprNoRoot.isBoolean()) { - if (unionExprNoRoot.isBoolean()) { - return XValue.create(pathExprNoRoot.asBoolean() | unionExprNoRoot.asBoolean()); - } else if (unionExprNoRoot.isElements()) { - Element element = new Element("V"); - element.appendText(pathExprNoRoot.asString()); - unionExprNoRoot.asElements().add(element); - return unionExprNoRoot; - } else if (unionExprNoRoot.isString()) { - return XValue.create(pathExprNoRoot.asBoolean() + unionExprNoRoot.asString()); - } else { - throw new XpathMergeValueException("can not merge val1=" + pathExprNoRoot.asBoolean() + ",val2=" + unionExprNoRoot.asString()); - } - } else if (pathExprNoRoot.isNumber()) { - if (unionExprNoRoot.isString()) { - return XValue.create(pathExprNoRoot.asDouble() + unionExprNoRoot.asString()); - } else if (unionExprNoRoot.isElements()) { - Element element = new Element("V"); - element.appendText(pathExprNoRoot.asString()); - unionExprNoRoot.asElements().add(element); - return unionExprNoRoot; - } else { - throw new XpathMergeValueException("can not merge val1=" + pathExprNoRoot.asDouble() + ",val2=" + unionExprNoRoot.asString()); - } - } else { - List tmpVal = new LinkedList<>(); - if (StringUtils.isNotBlank(pathExprNoRoot.asString())) { - tmpVal.add(pathExprNoRoot.asString()); - } - if (StringUtils.isNotBlank(unionExprNoRoot.asString())) { - tmpVal.add(unionExprNoRoot.asString()); - } - return XValue.create(StringUtils.join(tmpVal, ",")); - } - } - - @Override - public XValue visitPathExprNoRoot(XpathParser.PathExprNoRootContext ctx) { - if (ctx.locationPath() != null && !ctx.locationPath().isEmpty()) { - return visit(ctx.locationPath()); - } - if (ctx.op == null) { - return visit(ctx.filterExpr()); - } - if ("//".equals(ctx.op.getText())) { - currentScope().recursion(); - } - return visit(ctx.relativeLocationPath()); - } - - @Override - public XValue visitFilterExpr(XpathParser.FilterExprContext ctx) { - //暂时先不考虑支持 : primaryExpr predicate* - return visit(ctx.primaryExpr()); - } - - @Override - public XValue visitPrimaryExpr(XpathParser.PrimaryExprContext ctx) { - if (ctx.expr() != null && !ctx.expr().isEmpty()) { - return visit(ctx.expr()); - } else if (ctx.functionCall() != null && !ctx.functionCall().isEmpty()) { - return visit(ctx.functionCall()); - } else if (ctx.Literal() != null) { - return XValue.create(ctx.Literal().getText()).exprStr(); - } else if (ctx.Number() != null) { - return XValue.create(NumberUtils.createDouble(ctx.Number().getText())); - } - throw new XpathParserException("not support variableReference:" + ctx.getText()); - } - - @Override - public XValue visitFunctionCall(XpathParser.FunctionCallContext ctx) { - List params = new LinkedList<>(); - XValue funcName = visit(ctx.functionName()); - for (XpathParser.ExprContext exprContext : ctx.expr()) { - scopeStack.push(Scope.create(currentScope())); - params.add(visit(exprContext)); - scopeStack.pop(); - } - Function function = Scanner.findFunctionByName(funcName.asString()); - return function.call(currentScope(), params); - } - - @Override - public XValue visitFunctionName(XpathParser.FunctionNameContext ctx) { - return visit(ctx.qName()); - } - - private Scope currentScope() { - return scopeStack.peek(); - } - - private void updateCurrentContext(Elements newContext) { - scopeStack.peek().setContext(newContext); - } - -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorOrSelfSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorOrSelfSelector.java deleted file mode 100644 index 564803d5b..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorOrSelfSelector.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * the ancestor-or-self axis contains the context node and the ancestors of the context node; - * thus, the ancestor axis will always include the root node - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class AncestorOrSelfSelector implements AxisSelector { - @Override - public String name() { - return "ancestor-or-self"; - } - - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - total.addAll(el.parents()); - //include self - total.add(el); - } - return XValue.create(new Elements(total)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorSelector.java deleted file mode 100644 index bd3620088..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AncestorSelector.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of - * the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include - * the root node, unless the context node is the root node - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class AncestorSelector implements AxisSelector { - @Override - public String name() { - return "ancestor"; - } - - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - total.addAll(el.parents()); - } - return XValue.create(new Elements(total)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AttributeSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AttributeSelector.java deleted file mode 100644 index f47e5d2e5..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/AttributeSelector.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -/** - * the attribute axis contains the attributes of the context node; the axis will be empty unless the context node is an element - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class AttributeSelector implements AxisSelector { - /** - * assign name - * - * @return name - */ - @Override - public String name() { - return "attribute"; - } - - /** - * @param context - * @return res - */ - @Override - public XValue apply(Elements context) { - return XValue.create(null).attr(); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ChildSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ChildSelector.java deleted file mode 100644 index 7d1c1edb4..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ChildSelector.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -/** - * the child axis contains the children of the context node - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class ChildSelector implements AxisSelector { - @Override - public String name() { - return "child"; - } - - @Override - public XValue apply(Elements context) { - Elements childs = new Elements(); - for (Element el : context) { - childs.addAll(el.children()); - } - return XValue.create(childs); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantOrSelfSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantOrSelfSelector.java deleted file mode 100644 index 438899b89..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantOrSelfSelector.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.HashSet; -import java.util.Set; - -/** - * the descendant-or-self axis contains the context node and the descendants of the context node - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class DescendantOrSelfSelector implements AxisSelector { - @Override - public String name() { - return "descendant-or-self"; - } - - @Override - public XValue apply(Elements context) { - Set total = new HashSet<>(); - Elements descendant = new Elements(); - for (Element el : context) { - Elements tmp = el.getAllElements(); - total.addAll(tmp); - } - descendant.addAll(total); - return XValue.create(descendant); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantSelector.java deleted file mode 100644 index 4a676a24d..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/DescendantSelector.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.HashSet; -import java.util.Set; - -/** - * the descendant axis contains the descendants of the context node; a descendant is a child or a child - * of a child and so on; thus the descendant axis never contains attribute or namespace nodes - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class DescendantSelector implements AxisSelector { - @Override - public String name() { - return "descendant"; - } - - @Override - public XValue apply(Elements context) { - Set total = new HashSet<>(); - Elements descendant = new Elements(); - for (Element el : context) { - Elements tmp = el.getAllElements(); - //exclude self - tmp.remove(el); - total.addAll(tmp); - } - descendant.addAll(total); - return XValue.create(descendant); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSelector.java deleted file mode 100644 index b37e3fdab..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSelector.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.CommonUtil; - -import java.util.LinkedList; -import java.util.List; - - -/** - * the following axis contains all nodes in the same document as the context node that are after the context node in - * document order, excluding any descendants and excluding attribute nodes and namespace nodes - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class FollowingSelector implements AxisSelector { - @Override - public String name() { - return "following"; - } - - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - Elements p = el.parents(); - for (Element pe : p) { - Elements fs = CommonUtil.followingSibling(pe); - if (fs == null) { - continue; - } - for (Element pse : fs) { - //include pse - total.addAll(pse.getAllElements()); - } - } - Elements fs = CommonUtil.followingSibling(el); - if (fs == null) { - continue; - } - for (Element se : fs) { - total.addAll(se.getAllElements()); - } - } - return XValue.create(new Elements(total)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingOneSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingOneSelector.java deleted file mode 100644 index c91c085b7..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingOneSelector.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * the following-sibling-one JsoupXpath自定义扩展,比较常用 - * - * @author https://github.com/hermitmmll - * @since 2018/3/27. - */ -public class FollowingSiblingOneSelector implements AxisSelector { - /** - * assign name - * - * @return name - */ - @Override - public String name() { - return "following-sibling-one"; - } - - /** - * @param context - * @return res - */ - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - if (el.nextElementSibling() != null) { - total.add(el.nextElementSibling()); - } - } - Elements newContext = new Elements(); - newContext.addAll(total); - return XValue.create(newContext); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingSelector.java deleted file mode 100644 index e4b1e329c..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/FollowingSiblingSelector.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.CommonUtil; - -import java.util.LinkedList; -import java.util.List; - -/** - * the following-sibling axis contains all the following siblings of the context node; if the context node is an - * attribute node or namespace node, the following-sibling axis is empty - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/27. - */ -public class FollowingSiblingSelector implements AxisSelector { - /** - * assign name - * - * @return name - */ - @Override - public String name() { - return "following-sibling"; - } - - /** - * @param context - * @return res - */ - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - Elements fs = CommonUtil.followingSibling(el); - if (fs == null) { - continue; - } - total.addAll(fs); - } - Elements newContext = new Elements(); - newContext.addAll(total); - return XValue.create(newContext); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ParentSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ParentSelector.java deleted file mode 100644 index 2dc7dfb0d..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/ParentSelector.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * the parent axis contains the parent of the context node, if there is one - * https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-AxisSpecifier - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public class ParentSelector implements AxisSelector { - @Override - public String name() { - return "parent"; - } - - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - Elements parents = new Elements(); - for (Element el : context) { - total.add(el.parent()); - } - parents.addAll(total); - return XValue.create(parents); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSelector.java deleted file mode 100644 index 082f51286..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSelector.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.CommonUtil; - -import java.util.LinkedList; -import java.util.List; - -/** - * the preceding axis contains all nodes in the same document as the context node that are before the context - * node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/27. - */ -public class PrecedingSelector implements AxisSelector { - /** - * assign name - * - * @return name - */ - @Override - public String name() { - return "preceding"; - } - - /** - * @param context - * @return res - */ - @Override - public XValue apply(Elements context) { - Elements preceding = new Elements(); - List total = new LinkedList<>(); - for (Element el : context) { - Elements p = el.parents(); - for (Element pe : p) { - Elements ps = CommonUtil.precedingSibling(pe); - if (ps == null) { - continue; - } - total.addAll(ps); - } - Elements ps = CommonUtil.precedingSibling(el); - if (ps == null) { - continue; - } - total.addAll(ps); - } - preceding.addAll(total); - return XValue.create(preceding); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingOneSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingOneSelector.java deleted file mode 100644 index de92957c5..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingOneSelector.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * the preceding-sibling-one axis JsoupXpath自定义扩展,用于选取节点的前一个兄弟节点,如果存在的话。 - * - * @author github.com/hermitmmll - * @since 2018/3/27. - */ -public class PrecedingSiblingOneSelector implements AxisSelector { - /** - * assign name - * - * @return name - */ - @Override - public String name() { - return "preceding-sibling-one"; - } - - /** - * @param context - * @return res - */ - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - if (el.previousElementSibling() != null) { - total.add(el); - } - } - Elements newContext = new Elements(); - newContext.addAll(total); - return XValue.create(newContext); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingSelector.java deleted file mode 100644 index d170e0032..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/PrecedingSiblingSelector.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.CommonUtil; - -import java.util.LinkedList; -import java.util.List; - -/** - * the preceding-sibling axis contains all the preceding siblings of the context node; if the context node is - * an attribute node or namespace node, the preceding-sibling axis is empty - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/27. - */ -public class PrecedingSiblingSelector implements AxisSelector { - /** - * assign name - * - * @return name - */ - @Override - public String name() { - return "preceding-sibling"; - } - - /** - * @param context - * @return res - */ - @Override - public XValue apply(Elements context) { - List total = new LinkedList<>(); - for (Element el : context) { - Elements ps = CommonUtil.precedingSibling(el); - if (ps == null) { - continue; - } - total.addAll(ps); - } - Elements newContext = new Elements(); - newContext.addAll(total); - return XValue.create(newContext); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/SelfSelector.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/SelfSelector.java deleted file mode 100644 index 3d4555200..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/axis/SelfSelector.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.seimicrawler.xpath.core.axis; - -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.XValue; - -/** - * the self axis contains just the context node itself - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public class SelfSelector implements AxisSelector { - @Override - public String name() { - return "self"; - } - - @Override - public XValue apply(Elements es) { - return XValue.create(es); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Concat.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Concat.java deleted file mode 100644 index 3c149b372..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Concat.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: string concat(string, string, string*) - * The concat function returns the concatenation of its arguments. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class Concat implements Function { - @Override - public String name() { - return "concat"; - } - - @Override - public XValue call(Scope scope, List params) { - StringBuilder accum = new StringBuilder(); - for (XValue v : params) { - accum.append(v.asString()); - } - return XValue.create(accum.toString()); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Contains.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Contains.java deleted file mode 100644 index 796ef5019..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Contains.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: boolean contains(string, string) - *

- * The contains function returns true if the first argument string contains the second argument string, and otherwise returns false. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class Contains implements Function { - @Override - public String name() { - return "contains"; - } - - @Override - public XValue call(Scope scope, List params) { - String first = params.get(0).asString(); - String second = params.get(1).asString(); - return XValue.create(first.contains(second)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Count.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Count.java deleted file mode 100644 index 4c53cd52e..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Count.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: number count(node-set) - * The count function returns the number of nodes in the argument node-set. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/27. - */ -public class Count implements Function { - @Override - public String name() { - return "count"; - } - - @Override - public XValue call(Scope scope, List params) { - if (params == null || params.size() == 0) { - return XValue.create(0); - } - return XValue.create(params.get(0).asElements().size()); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/First.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/First.java deleted file mode 100644 index cd2670520..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/First.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * first in xpath is 1 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/29. - */ -public class First implements Function { - @Override - public String name() { - return "first"; - } - - @Override - public XValue call(Scope scope, List params) { - return XValue.create(1); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/FormatDate.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/FormatDate.java deleted file mode 100644 index 1372b7a03..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/FormatDate.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.time.FastDateFormat; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.exception.XpathParserException; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Locale; - -/** - * Function: string format-date(string, string, string) - * The format-date function returns Date object - * The first parameter is the date and time - * The second parameter is the time format of the first parameter. - * The third parameter is not required, and is required if the date format of the first parameter requires that the time zone must be specified - * For example, format-date("1999/04/01","yyyy/MM/dd") returns Date Object, and format-date("1999/04/01 07:55:23 pm","yyyy/MM/dd hh:mm:ss a",'en') returns Date Object. - * - * @author github.com/zzldn@163.com - * @since 2019/1/22. - */ -public class FormatDate implements Function { - @Override - public String name() { - return "format-date"; - } - - @Override - public XValue call(Scope scope, List params) { - String value = params.get(0).asString(); - String patten = params.get(1).asString(); - try { - if (params.size() > 2 && null != params.get(2)) { - final Locale locale = Locale.forLanguageTag(params.get(2).asString()); - final SimpleDateFormat format = new SimpleDateFormat(patten, locale); - return XValue.create(format.parse(value)); - } - return XValue.create(FastDateFormat.getInstance(patten).parse(value)); - } catch (ParseException e) { - throw new XpathParserException("date format exception!", e); - } - - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Last.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Last.java deleted file mode 100644 index 6dae66f6b..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Last.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: number last() - * The last function returns a number equal to the context size from the expression evaluation context. - * e.g. - * para[last()] selects the last para child of the context node - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/27. - */ -public class Last implements Function { - @Override - public String name() { - return "last"; - } - - @Override - public XValue call(Scope scope, List params) { - return XValue.create(-1); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Not.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Not.java deleted file mode 100644 index d5af0b500..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Not.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.exception.XpathParserException; - -import java.util.List; - -/** - * bool not(bool) - * - * @author github.com/hermitmmll - * @since 2018/4/3. - */ -public class Not implements Function { - @Override - public String name() { - return "not"; - } - - @Override - public XValue call(Scope scope, List params) { - if (params.size() == 1) { - return XValue.create(!params.get(0).asBoolean()); - } else { - throw new XpathParserException("error param in not(bool) function.Please check."); - } - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Position.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Position.java deleted file mode 100644 index 24cb49259..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/Position.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.CommonUtil; - -import java.util.List; - -/** - * The position function returns a number equal to the context position from the expression evaluation context. - * e.g. - * /child::doc/child::chapter[position()=5]/child::section[position()=2] selects the second section of the fifth chapter of the doc document element - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public class Position implements Function { - @Override - public String name() { - return "position"; - } - - @Override - public XValue call(Scope scope, List params) { - return XValue.create(CommonUtil.getElIndexInSameTags(scope.singleEl(), scope.getParent())); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StartsWith.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StartsWith.java deleted file mode 100644 index f70db13f9..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StartsWith.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: boolean starts-with(string, string) - *

- * The starts-with function returns true if the first argument string starts with the second argument string, and otherwise returns false. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class StartsWith implements Function { - @Override - public String name() { - return "starts-with"; - } - - @Override - public XValue call(Scope scope, List params) { - String first = params.get(0).asString(); - String second = params.get(1).asString(); - return XValue.create(first.startsWith(second)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StringLength.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StringLength.java deleted file mode 100644 index 169c4f8d2..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/StringLength.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * number string-length(string?) - * The string-length returns the number of characters in the string (see [3.6 Strings]). If the argument is - * omitted, it defaults to the context node converted to a string, in other words the string-value of the context node. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/27. - */ -public class StringLength implements Function { - @Override - public String name() { - return "string-length"; - } - - @Override - public XValue call(Scope scope, List params) { - if (params == null || params.size() == 0) { - return XValue.create(0); - } - return XValue.create(params.get(0).asString().length()); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubString.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubString.java deleted file mode 100644 index d264bc9cf..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubString.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: string substring(string, number, number?) - * https://www.w3.org/TR/1999/REC-xpath-19991116/#function-substring - * The substring function returns the substring of the first argument starting at the position specified in - * the second argument with length specified in the third argument. For example, substring("12345",2,3) returns "234". - * If the third argument is not specified, it returns the substring starting at the position specified in the - * second argument and continuing to the end of the string. For example, substring("12345",2) returns "2345". - *

- * substring("12345", 1.5, 2.6) returns "234" - * substring("12345", 0 `div` 0, 3) returns "" - * substring("12345", 1, 0 `div` 0) returns "" - * substring("12345", -42, 1 `div` 0) returns "12345" - * substring("12345", -1 `div` 0, 1 `div` 0) returns "" - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ - -public class SubString implements Function { - @Override - public String name() { - return "substring"; - } - - @Override - public XValue call(Scope scope, List params) { - String target = params.get(0).asString(); - int start = params.get(1).asLong().intValue(); - start = Math.max(start - 1, 0); - if (params.get(2) != null) { - int end = params.get(2).asLong().intValue(); - end = Math.min(start + end, target.length()); - end = Math.max(end, 0); - return XValue.create(StringUtils.substring(target, start, end)); - } - return XValue.create(StringUtils.substring(target, start)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfter.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfter.java deleted file mode 100644 index d52de57aa..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfter.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: string substring-after(string, string) - * The substring-after function returns the substring of the first argument string that follows - * the first occurrence of the second argument string in the first argument string, or the empty string if - * the first argument string does not contain the second argument string. - * For example, substring-after("1999/04/01","/") returns 04/01, and substring-after("1999/04/01","19") returns 99/04/01. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class SubStringAfter implements Function { - @Override - public String name() { - return "substring-after"; - } - - @Override - public XValue call(Scope scope, List params) { - String target = params.get(0).asString(); - String sep = params.get(1).asString(); - return XValue.create(StringUtils.substringAfter(target, sep)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfterLast.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfterLast.java deleted file mode 100644 index ffb28edd1..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringAfterLast.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: string substring-after-last(string, string) - * The substring-after function returns the substring of the first argument string that follows - * the first occurrence of the second argument string in the first argument string, or the empty string if - * the first argument string does not contain the second argument string. - * For example, substring-after-last("1999/04/01","/") returns 01. - * - * @author github.com/zzldnl - * @since 2018/3/26. - */ -public class SubStringAfterLast implements Function { - @Override - public String name() { - return "substring-after-last"; - } - - @Override - public XValue call(Scope scope, List params) { - String target = params.get(0).asString(); - String sep = params.get(1).asString(); - return XValue.create(StringUtils.substringAfterLast(target, sep)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBefore.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBefore.java deleted file mode 100644 index 6db7980a3..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBefore.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: string substring-before(string, string) - *

- * The substring-before function returns the substring of the first argument string that precedes the - * first occurrence of the second argument string in the first argument string, or the empty string - * if the first argument string does not contain the second argument string. - * For example, substring-before("1999/04/01","/") returns 1999. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class SubStringBefore implements Function { - @Override - public String name() { - return "substring-before"; - } - - @Override - public XValue call(Scope scope, List params) { - String target = params.get(0).asString(); - String sep = params.get(1).asString(); - return XValue.create(StringUtils.substringBefore(target, sep)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBeforeLast.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBeforeLast.java deleted file mode 100644 index 6bc022104..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringBeforeLast.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * Function: string substring-before-last(string, string) - *

- * The substring-before function returns the substring of the first argument string that precedes the - * first occurrence of the second argument string in the first argument string, or the empty string - * if the first argument string does not contain the second argument string. - * For example, substring-before-last("1999/04/01","/") returns 1999/04. - * - * @author github.com/zzldnl - * @since 2018/3/26. - */ -public class SubStringBeforeLast implements Function { - @Override - public String name() { - return "substring-before-last"; - } - - @Override - public XValue call(Scope scope, List params) { - String target = params.get(0).asString(); - String sep = params.get(1).asString(); - return XValue.create(StringUtils.substringBeforeLast(target, sep)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringEx.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringEx.java deleted file mode 100644 index ae1db61f2..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/function/SubStringEx.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.List; - -/** - * JsoupXpath扩展函数(统一使用 ‘jx’ 域),保持使用习惯java开发者习惯相同,第一个数字为起始索引(且索引从0开始),第二个数字为结束索引 - *

- * StringUtils.substring(null, *, *) = null - * StringUtils.substring("", * , *) = ""; - * StringUtils.substring("abc", 0, 2) = "ab" - * StringUtils.substring("abc", 2, 0) = "" - * StringUtils.substring("abc", 2, 4) = "c" - * StringUtils.substring("abc", 2.13, 3.7) = "c" - * StringUtils.substring("abc", 4, 6) = "" - * StringUtils.substring("abc", 2, 2) = "" - * StringUtils.substring("abc", -2, -1) = "b" - * StringUtils.substring("abc", -4, 2) = "ab" - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ - -public class SubStringEx implements Function { - @Override - public String name() { - return "substring-ex"; - } - - @Override - public XValue call(Scope scope, List params) { - String target = params.get(0).asString(); - int start = params.get(1).asLong().intValue(); - if (params.get(2) != null) { - int end = params.get(2).asLong().intValue(); - return XValue.create(StringUtils.substring(target, start, end)); - } - return XValue.create(StringUtils.substring(target, start)); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/AllText.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/AllText.java deleted file mode 100644 index 36582504b..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/AllText.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.jsoup.nodes.Element; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * 获取当前节点下以及所有子孙节点中纯文本 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class AllText implements NodeTest { - /** - * 支持的函数名 - */ - @Override - public String name() { - return "allText"; - } - - /** - * 函数具体逻辑 - * - * @param scope 上下文 - * @return 计算好的节点 - */ - @Override - public XValue call(Scope scope) { - List res = new LinkedList<>(); - for (Element e : scope.context()) { - if ("script".equals(e.nodeName())) { - res.add(e.data()); - } else { - res.add(e.text()); - } - } - return XValue.create(res); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Html.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Html.java deleted file mode 100644 index 0bca9fb15..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Html.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.jsoup.nodes.Element; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * 获取全部节点的内部的html - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/4/9. - */ -public class Html implements NodeTest { - @Override - public String name() { - return "html"; - } - - @Override - public XValue call(Scope scope) { - List res = new LinkedList<>(); - for (Element e : scope.context()) { - res.add(e.html()); - } - return XValue.create(res); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Node.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Node.java deleted file mode 100644 index db6aef02d..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Node.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.apache.commons.lang3.StringUtils; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -/** - * 获取当前节点下所有子节点以及独立文本 - * - * @author: github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/4/4. - */ -public class Node implements NodeTest { - /** - * 支持的函数名 - */ - @Override - public String name() { - return "node"; - } - - /** - * 函数具体逻辑 - * - * @param scope 上下文 - * @return 计算好的节点 - */ - @Override - public XValue call(Scope scope) { - Elements context = new Elements(); - for (Element el : scope.context()) { - context.addAll(el.children()); - String txt = el.ownText(); - if (StringUtils.isNotBlank(txt)) { - Element et = new Element(""); - et.appendText(txt); - context.add(et); - } - } - return XValue.create(context); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Num.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Num.java deleted file mode 100644 index 9d66fc45f..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Num.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.apache.commons.lang3.StringUtils; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.Scanner; - -import java.math.BigDecimal; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * 提取自由文本中的数字,如果知道节点的自有文本(即非子代节点所包含的文本)中只存在一个数字,如阅读数,评论数,价格等那么直接可以直接提取此数字出来。 - * 如果有多个数字将提取第一个匹配的连续数字,支持小数,返回double - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class Num implements NodeTest { - private static final Pattern numExt = Pattern.compile("\\d*\\.?\\d+"); - - /** - * 支持的函数名 - */ - @Override - public String name() { - return "num"; - } - - /** - * 函数具体逻辑 - * - * @param scope 上下文 - * @return 计算好的节点 - */ - @Override - public XValue call(Scope scope) { - NodeTest textFun = Scanner.findNodeTestByName("allText"); - XValue textVal = textFun.call(scope); - String whole = StringUtils.join(textVal.asList(), ""); - Matcher matcher = numExt.matcher(whole); - if (matcher.find()) { - String numStr = matcher.group(); - BigDecimal num = new BigDecimal(numStr); - return XValue.create(num.doubleValue()); - } else { - return XValue.create(null); - } - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/OuterHtml.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/OuterHtml.java deleted file mode 100644 index f158ef88c..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/OuterHtml.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.jsoup.nodes.Element; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * 获取全部节点的 包含节点本身在内的全部html - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/4/9. - */ -public class OuterHtml implements NodeTest { - @Override - public String name() { - return "outerHtml"; - } - - @Override - public XValue call(Scope scope) { - List res = new LinkedList<>(); - for (Element e : scope.context()) { - res.add(e.outerHtml()); - } - return XValue.create(res); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Text.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Text.java deleted file mode 100644 index d52553d15..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/core/node/Text.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.jsoup.nodes.Element; -import org.jsoup.nodes.Node; -import org.jsoup.nodes.TextNode; -import org.jsoup.select.Elements; -import org.jsoup.select.NodeTraversor; -import org.jsoup.select.NodeVisitor; -import org.seimicrawler.xpath.core.Constants; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.util.CommonUtil; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - * `text()`不再简单的返回节点下的所有文本,而是按照标准语义识别出多个文本块,返回文本块列表,如 - * ``` - *

one two three

- * ``` - * - `//text()` 返回 `["one", "two", "three" ]` - * - `//text()[2]` 返回 `["three"]` - */ -public class Text implements NodeTest { - /** - * 支持的函数名 - */ - @Override - public String name() { - return "text"; - } - - /** - * 函数具体逻辑 - * - * @param scope 上下文 - * @return 计算好的节点 - */ - @Override - public XValue call(Scope scope) { - Elements context = scope.context(); - final Elements res = new Elements(); - if (context != null && context.size() > 0) { - if (scope.isRecursion()) { - for (final Element e : context) { - final Map indexMap = new HashMap<>(); - NodeTraversor.traverse(new NodeVisitor() { - @Override - public void head(Node node, int depth) { - if (node instanceof TextNode) { - TextNode textNode = (TextNode) node; - String key = depth + "_" + textNode.parent().hashCode(); - Integer index = indexMap.get(key); - if (index == null) { - index = 1; - } else { - index += 1; - } - indexMap.put(key, index); - Element data = new Element(Constants.DEF_TEXT_TAG_NAME); - data.text(textNode.getWholeText()); - try { - Method parent = Node.class.getDeclaredMethod("setParentNode", Node.class); - parent.setAccessible(true); - parent.invoke(data, textNode.parent()); - } catch (Exception e) { - //ignore - } - CommonUtil.setSameTagIndexInSiblings(data, index); - res.add(data); - } - } - - @Override - public void tail(Node node, int depth) { - - } - }, e); - } - } else { - for (Element e : context) { - if ("script".equals(e.nodeName())) { - Element data = new Element(Constants.DEF_TEXT_TAG_NAME); - data.text(e.data()); - CommonUtil.setSameTagIndexInSiblings(data, 1); - res.add(data); - } else { - List textNodes = e.textNodes(); - for (int i = 0; i < textNodes.size(); i++) { - TextNode textNode = textNodes.get(i); - Element data = new Element(Constants.DEF_TEXT_TAG_NAME); - data.text(textNode.getWholeText()); - CommonUtil.setSameTagIndexInSiblings(data, i + 1); - res.add(data); - } - } - } - } - } - return XValue.create(res); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/DoFailOnErrorHandler.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/DoFailOnErrorHandler.java deleted file mode 100644 index 1dfcd670a..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/DoFailOnErrorHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.seimicrawler.xpath.exception; - -import org.antlr.v4.runtime.DefaultErrorStrategy; -import org.antlr.v4.runtime.InputMismatchException; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.misc.ParseCancellationException; - -/** - * 如果语法解析异常,直接抛出并终止解析 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/23. - */ -public class DoFailOnErrorHandler extends DefaultErrorStrategy { - - @Override - public void recover(Parser recognizer, RecognitionException e) { - for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { - context.exception = e; - } - throw new ParseCancellationException(e); - } - - @Override - public Token recoverInline(Parser recognizer) throws RecognitionException { - InputMismatchException e = new InputMismatchException(recognizer); - for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { - context.exception = e; - } - throw new ParseCancellationException(e); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchAxisException.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchAxisException.java deleted file mode 100644 index deb40ad7d..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchAxisException.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.seimicrawler.xpath.exception; -/* - Copyright 2014 Wang Haomiao - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/** - * 使用不存在的轴语法则抛出此异常 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * Date: 14-3-15 - */ -public class NoSuchAxisException extends RuntimeException { - public NoSuchAxisException(String msg) { - super(msg); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchFunctionException.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchFunctionException.java deleted file mode 100644 index 5266905d9..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/NoSuchFunctionException.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.seimicrawler.xpath.exception; -/* - Copyright 2014 Wang Haomiao - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * Date: 14-3-16 - */ -public class NoSuchFunctionException extends RuntimeException { - public NoSuchFunctionException(String msg) { - super(msg); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathMergeValueException.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathMergeValueException.java deleted file mode 100644 index e7036050b..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathMergeValueException.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.seimicrawler.xpath.exception; - -/** - * 无法合并多个表达式的解析结果 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2017/12/5. - */ -public class XpathMergeValueException extends RuntimeException { - public XpathMergeValueException(String message) { - super(message); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathParserException.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathParserException.java deleted file mode 100644 index 62f5065a8..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathParserException.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.seimicrawler.xpath.exception; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2017/12/5. - */ -public class XpathParserException extends RuntimeException { - /** - * Constructs a new runtime exception with the specified detail message. - * The cause is not initialized, and may subsequently be initialized by a - * call to {@link #initCause}. - * - * @param message the detail message. The detail message is saved for - * later retrieval by the {@link #getMessage()} method. - */ - public XpathParserException(String message) { - super(message); - } - - public XpathParserException(String message, Throwable e) { - super(message, e); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathSyntaxErrorException.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathSyntaxErrorException.java deleted file mode 100644 index f4a83909d..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/exception/XpathSyntaxErrorException.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.seimicrawler.xpath.exception; -/* - Copyright 2014 Wang Haomiao - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 14-3-19 - */ -public class XpathSyntaxErrorException extends RuntimeException { - public XpathSyntaxErrorException(String msg) { - super(msg); - } - - public XpathSyntaxErrorException(String msg, Throwable e) { - super(msg, e); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/util/CommonUtil.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/util/CommonUtil.java deleted file mode 100644 index 9cebd438c..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/util/CommonUtil.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.seimicrawler.xpath.util; -/* - Copyright 2014 Wang Haomiao - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -import org.apache.commons.lang3.StringUtils; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.seimicrawler.xpath.core.Constants; -import org.seimicrawler.xpath.core.Scope; - -import java.util.Objects; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * Date: 14-3-15 - */ -public class CommonUtil { - - /** - * 获取同名元素在同胞中的index - * - * @param e - * @return - */ - public static int getElIndexInSameTags(Element e, Scope scope) { - Elements chs = e.parent().children(); - int index = 1; - for (Element cur : chs) { - if (e.tagName().equals(cur.tagName()) && scope.context().contains(cur)) { - if (e.equals(cur)) { - break; - } else { - index += 1; - } - } - } - return index; - } - - - /** - * 获取同胞中同名元素的数量 - * - * @param e - * @return - */ - public static int sameTagElNums(Element e, Scope scope) { - Elements context = new Elements(); - Elements els = e.parent().getElementsByTag(e.tagName()); - for (Element el : els) { - if (scope.context().contains(el)) { - context.add(el); - } - } - return context.size(); - } - - public static int getIndexInContext(Scope scope, Element el) { - for (int i = 0; i < scope.context().size(); i++) { - Element tmp = scope.context().get(i); - if (Objects.equals(tmp, el)) { - return i + 1; - } - } - return Integer.MIN_VALUE; - } - - public static Elements followingSibling(Element el) { - Elements rs = new Elements(); - Element tmp = el.nextElementSibling(); - while (tmp != null) { - rs.add(tmp); - tmp = tmp.nextElementSibling(); - } - if (rs.size() > 0) { - return rs; - } - return null; - } - - public static Elements precedingSibling(Element el) { - Elements rs = new Elements(); - Element tmp = el.previousElementSibling(); - while (tmp != null) { - rs.add(tmp); - tmp = tmp.previousElementSibling(); - } - if (rs.size() > 0) { - return rs; - } - return null; - } - - public static void setSameTagIndexInSiblings(Element ori, int index) { - if (ori == null) { - return; - } - ori.attr(Constants.EL_SAME_TAG_INDEX_KEY, String.valueOf(index)); - } - - public static int getJxSameTagIndexInSiblings(Element ori) { - String val = ori.attr(Constants.EL_SAME_TAG_INDEX_KEY); - if (StringUtils.isBlank(val)) { - return -1; - } - return Integer.parseInt(val); - } -} diff --git a/JsoupXpath/src/main/java/org/seimicrawler/xpath/util/Scanner.java b/JsoupXpath/src/main/java/org/seimicrawler/xpath/util/Scanner.java deleted file mode 100644 index 01a999303..000000000 --- a/JsoupXpath/src/main/java/org/seimicrawler/xpath/util/Scanner.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.seimicrawler.xpath.util; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.seimicrawler.xpath.core.AxisSelector; -import org.seimicrawler.xpath.core.Function; -import org.seimicrawler.xpath.core.NodeTest; -import org.seimicrawler.xpath.core.axis.AncestorOrSelfSelector; -import org.seimicrawler.xpath.core.axis.AncestorSelector; -import org.seimicrawler.xpath.core.axis.AttributeSelector; -import org.seimicrawler.xpath.core.axis.ChildSelector; -import org.seimicrawler.xpath.core.axis.DescendantOrSelfSelector; -import org.seimicrawler.xpath.core.axis.DescendantSelector; -import org.seimicrawler.xpath.core.axis.FollowingSelector; -import org.seimicrawler.xpath.core.axis.FollowingSiblingOneSelector; -import org.seimicrawler.xpath.core.axis.FollowingSiblingSelector; -import org.seimicrawler.xpath.core.axis.ParentSelector; -import org.seimicrawler.xpath.core.axis.PrecedingSelector; -import org.seimicrawler.xpath.core.axis.PrecedingSiblingOneSelector; -import org.seimicrawler.xpath.core.axis.PrecedingSiblingSelector; -import org.seimicrawler.xpath.core.axis.SelfSelector; -import org.seimicrawler.xpath.core.function.Concat; -import org.seimicrawler.xpath.core.function.Contains; -import org.seimicrawler.xpath.core.function.Count; -import org.seimicrawler.xpath.core.function.First; -import org.seimicrawler.xpath.core.function.FormatDate; -import org.seimicrawler.xpath.core.function.Last; -import org.seimicrawler.xpath.core.function.Not; -import org.seimicrawler.xpath.core.function.Position; -import org.seimicrawler.xpath.core.function.StartsWith; -import org.seimicrawler.xpath.core.function.StringLength; -import org.seimicrawler.xpath.core.function.SubString; -import org.seimicrawler.xpath.core.function.SubStringAfter; -import org.seimicrawler.xpath.core.function.SubStringAfterLast; -import org.seimicrawler.xpath.core.function.SubStringBefore; -import org.seimicrawler.xpath.core.function.SubStringBeforeLast; -import org.seimicrawler.xpath.core.function.SubStringEx; -import org.seimicrawler.xpath.core.node.AllText; -import org.seimicrawler.xpath.core.node.Html; -import org.seimicrawler.xpath.core.node.Node; -import org.seimicrawler.xpath.core.node.Num; -import org.seimicrawler.xpath.core.node.OuterHtml; -import org.seimicrawler.xpath.core.node.Text; -import org.seimicrawler.xpath.exception.NoSuchAxisException; -import org.seimicrawler.xpath.exception.NoSuchFunctionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; - -/** - * 考虑更广泛的兼容性,替换掉 FastClasspathScanner,采用手工注册 - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/2/28. - */ -public class Scanner { - private static final Map axisSelectorMap = new HashMap<>(); - private static final Map nodeTestMap = new HashMap<>(); - private static final Map functionMap = new HashMap<>(); - private static final Logger logger = LoggerFactory.getLogger(Scanner.class); - - static { - initAxis(AncestorOrSelfSelector.class, AncestorSelector.class, AttributeSelector.class, ChildSelector.class, DescendantOrSelfSelector.class, DescendantSelector.class, FollowingSelector.class, FollowingSiblingOneSelector.class, FollowingSiblingSelector.class, ParentSelector.class, PrecedingSelector.class, PrecedingSiblingOneSelector.class, PrecedingSiblingSelector.class, SelfSelector.class); - initFunction(Concat.class, Contains.class, Count.class, First.class, Last.class, Not.class, Position.class, StartsWith.class, StringLength.class, SubString.class, SubStringAfter.class, SubStringBefore.class, SubStringEx.class, FormatDate.class, SubStringAfterLast.class, SubStringBeforeLast.class); - initNode(AllText.class, Html.class, Node.class, Num.class, OuterHtml.class, Text.class); - } - - public static AxisSelector findSelectorByName(String selectorName) { - AxisSelector selector = axisSelectorMap.get(selectorName); - if (selector == null) { - throw new NoSuchAxisException("not support axis: " + selectorName); - } - return selector; - } - - public static NodeTest findNodeTestByName(String nodeTestName) { - NodeTest nodeTest = nodeTestMap.get(nodeTestName); - if (nodeTest == null) { - throw new NoSuchFunctionException("not support nodeTest: " + nodeTestName); - } - return nodeTest; - } - - public static Function findFunctionByName(String funcName) { - Function function = functionMap.get(funcName); - if (function == null) { - throw new NoSuchFunctionException("not support function: " + funcName); - } - return function; - } - - public static void registerFunction(Class func) { - Function function; - try { - function = func.newInstance(); - functionMap.put(function.name(), function); - } catch (Exception e) { - logger.info(ExceptionUtils.getRootCauseMessage(e), e); - } - } - - public static void registerNodeTest(Class nodeTestClass) { - NodeTest nodeTest; - try { - nodeTest = nodeTestClass.newInstance(); - nodeTestMap.put(nodeTest.name(), nodeTest); - } catch (Exception e) { - logger.info(ExceptionUtils.getRootCauseMessage(e), e); - } - } - - public static void registerAxisSelector(Class axisSelectorClass) { - AxisSelector axisSelector; - try { - axisSelector = axisSelectorClass.newInstance(); - axisSelectorMap.put(axisSelector.name(), axisSelector); - } catch (Exception e) { - logger.info(ExceptionUtils.getRootCauseMessage(e), e); - } - } - - public static void initAxis(Class... cls) { - for (Class axis : cls) { - registerAxisSelector(axis); - } - } - - public static void initFunction(Class... cls) { - for (Class func : cls) { - registerFunction(func); - } - } - - public static void initNode(Class... cls) { - for (Class node : cls) { - registerNodeTest(node); - } - } - -} diff --git a/JsoupXpath/src/main/resources/Xpath.g4 b/JsoupXpath/src/main/resources/Xpath.g4 deleted file mode 100644 index 9d439dcab..000000000 --- a/JsoupXpath/src/main/resources/Xpath.g4 +++ /dev/null @@ -1,296 +0,0 @@ -grammar Xpath; - -/* -XPath 1.0 grammar. Should conform to the official spec at -http://www.w3.org/TR/1999/REC-xpath-19991116. The grammar -rules have been kept as close as possible to those in the -spec, but some adjustmewnts were unavoidable. These were -mainly removing left recursion (spec seems to be based on -LR), and to deal with the double nature of the '*' token -(node wildcard and multiplication operator). See also -section 3.7 in the spec. These rule changes should make -no difference to the strings accepted by the grammar. - -Written by Jan-Willem van den Broek -Version 1.0 - -Do with this code as you will. -*/ -/* - Ported to Antlr4 by Tom Everett -*/ -/** -操作符扩展: - a^=b 字符串a以字符串b开头 a startwith b - a*=b a包含b, a contains b - a$=b a以b结尾 a endwith b - a~=b a的内容符合 正则表达式b - a!~b a的内容不符合 正则表达式b - -轴扩展: - following-sibling-one - preceding-sibling-one - sibling - -NodeTest扩展: - num 抽取数字 - allText 提取节点下全部文本 - outerHtml 获取全部节点的 包含节点本身在内的全部html - html 获取全部节点的内部的html - -*/ - -main : expr - ; - -locationPath - : relativeLocationPath - | absoluteLocationPathNoroot - ; - -absoluteLocationPathNoroot - : op=(PATHSEP|ABRPATH) relativeLocationPath - ; - -relativeLocationPath - : step (op=(PATHSEP|ABRPATH) step)* - ; - -step - : axisSpecifier nodeTest predicate* - | abbreviatedStep - ; - -axisSpecifier - : AxisName '::' - | '@'? - ; - -nodeTest: nameTest - | NodeType '(' ')' - | 'processing-instruction' '(' Literal ')' - ; - -predicate - : '[' expr ']' - ; - -abbreviatedStep - : '.' - | '..' - ; - -expr : orExpr - ; - -primaryExpr - : variableReference - | '(' expr ')' - | Literal - | Number - | functionCall - ; - -functionCall - : functionName '(' ( expr ( ',' expr )* )? ')' - ; - -unionExprNoRoot - : pathExprNoRoot (op=PIPE unionExprNoRoot)? - | PATHSEP PIPE unionExprNoRoot - ; - -pathExprNoRoot - : locationPath - | filterExpr (op=(PATHSEP|ABRPATH) relativeLocationPath)? - ; - -filterExpr - : primaryExpr predicate* - ; - -orExpr : andExpr ('or' andExpr)* - ; - -andExpr : equalityExpr ('and' equalityExpr)* - ; - -equalityExpr - : relationalExpr (op=(EQUALITY|INEQUALITY) relationalExpr)* - ; - -relationalExpr - : additiveExpr (op=(LESS|MORE_|LESS|GE|START_WITH|END_WITH|CONTAIN_WITH|REGEXP_WITH|REGEXP_NOT_WITH) additiveExpr)* - ; - -additiveExpr - : multiplicativeExpr (op=(PLUS|MINUS) multiplicativeExpr)* - ; - -multiplicativeExpr - : unaryExprNoRoot (op=(MUL|DIVISION|MODULO) multiplicativeExpr)? -// | '/' (op=('`div`'|'`mod`') multiplicativeExpr)? - ; - -unaryExprNoRoot - : (sign=MINUS)? unionExprNoRoot - ; - -qName : nCName (':' nCName)? - ; - -functionName - : qName // Does not match nodeType, as per spec. - ; - -variableReference - : '$' qName - ; - -nameTest: '*' - | nCName ':' '*' - | qName - ; - -nCName : NCName - | AxisName - ; - -NodeType: 'comment' - | 'text' - | 'processing-instruction' - | 'node' - | 'num' //抽取数字 - | 'allText' //提取节点下全部文本 - | 'outerHtml' //获取全部节点的 包含节点本身在内的全部html - | 'html' //获取全部节点的内部的html - ; - -Number : Digits ('.' Digits?)? - | '.' Digits - ; - -fragment -Digits : ('0'..'9')+ - ; - -AxisName: 'ancestor' - | 'ancestor-or-self' - | 'attribute' - | 'child' - | 'descendant' - | 'descendant-or-self' - | 'following' - | 'following-sibling' -// | 'namespace' - | 'parent' - | 'preceding' - | 'preceding-sibling' - | 'self' - | 'following-sibling-one' - | 'preceding-sibling-one' - | 'sibling' - ; - - - PATHSEP - :'/'; - ABRPATH - : '//'; - LPAR - : '('; - RPAR - : ')'; - LBRAC - : '['; - RBRAC - : ']'; - MINUS - : '-'; - PLUS - : '+'; - DOT - : '.'; - MUL - : '*'; - DIVISION - : '`div`'; - MODULO - : '`mod`'; - DOTDOT - : '..'; - AT - : '@'; - COMMA - : ','; - PIPE - : '|'; - LESS - : '<'; - MORE_ - : '>'; - LE - : '<='; - GE - : '>='; - EQUALITY - : '='; - INEQUALITY - : '!='; - START_WITH - : '^='; - END_WITH - : '$='; - CONTAIN_WITH - : '*='; - REGEXP_WITH - : '~='; - REGEXP_NOT_WITH - : '!~'; - COLON - : ':'; - CC - : '::'; - APOS - : '\''; - QUOT - : '"'; - -Literal : '"' ~'"'* '"' - | '\'' ~'\''* '\'' - ; - -Whitespace - : (' '|'\t'|'\n'|'\r')+ ->skip - ; - -NCName : NCNameStartChar NCNameChar* - ; - -fragment -NCNameStartChar - : 'A'..'Z' - | '_' - | 'a'..'z' - | '\u00C0'..'\u00D6' - | '\u00D8'..'\u00F6' - | '\u00F8'..'\u02FF' - | '\u0370'..'\u037D' - | '\u037F'..'\u1FFF' - | '\u200C'..'\u200D' - | '\u2070'..'\u218F' - | '\u2C00'..'\u2FEF' - | '\u3001'..'\uD7FF' - | '\uF900'..'\uFDCF' - | '\uFDF0'..'\uFFFD' -// Unfortunately, java escapes can't handle this conveniently, -// as they're limited to 4 hex digits. TODO. -// | '\U010000'..'\U0EFFFF' - ; - -fragment -NCNameChar - : NCNameStartChar | '-' | '.' | '0'..'9' - | '\u00B7' | '\u0300'..'\u036F' - | '\u203F'..'\u2040' - ; \ No newline at end of file diff --git a/JsoupXpath/src/test/java/org/seimicrawler/xpath/BaseTest.java b/JsoupXpath/src/test/java/org/seimicrawler/xpath/BaseTest.java deleted file mode 100644 index fc97764c2..000000000 --- a/JsoupXpath/src/test/java/org/seimicrawler/xpath/BaseTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.seimicrawler.xpath; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author: github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2018/3/26. - */ -public class BaseTest { - protected Logger logger = LoggerFactory.getLogger(BaseTest.class); -} diff --git a/JsoupXpath/src/test/java/org/seimicrawler/xpath/JXDocumentTest.java b/JsoupXpath/src/test/java/org/seimicrawler/xpath/JXDocumentTest.java deleted file mode 100644 index 5a578b548..000000000 --- a/JsoupXpath/src/test/java/org/seimicrawler/xpath/JXDocumentTest.java +++ /dev/null @@ -1,289 +0,0 @@ -package org.seimicrawler.xpath; - -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.seimicrawler.xpath.exception.XpathSyntaxErrorException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * JXDocument Tester. - * - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @version 1.0 - */ -@RunWith(DataProviderRunner.class) -public class JXDocumentTest { - - private JXDocument underTest; - - private JXDocument doubanTest; - - private JXDocument custom; - private final ClassLoader loader = getClass().getClassLoader(); - private final Logger logger = LoggerFactory.getLogger(JXDocumentTest.class); - - @Before - public void before() throws Exception { - String html = "
some body
Two
"; - underTest = JXDocument.create(html); - if (doubanTest == null) { - URL t = loader.getResource("d_test.html"); - assert t != null; - File dBook = new File(t.toURI()); - String context = FileUtils.readFileToString(dBook, StandardCharsets.UTF_8); - doubanTest = JXDocument.create(context); - } - custom = JXDocument.create("
  • 性别:
  • "); - } - - /** - * Method: sel(String xpath) - */ - @Test - public void testSel() throws Exception { - String xpath = "//script[1]/text()"; - JXNode res = underTest.selNOne(xpath); - Assert.assertNotNull(res); - Assert.assertEquals("console.log('aaaaa')", res.asString()); - } - - @Test - public void testNotMatchFilter() throws Exception { - String xpath = "//div[contains(@class,'xiao')]/text()"; - JXNode node = underTest.selNOne(xpath); - Assert.assertEquals("Two", node.asString()); - } - - @Test - @DataProvider(value = { - "//a/@href", - "//div[@class='paginator']/span[@class='next']/a/@href", - }) - public void testXpath(String xpath) throws XpathSyntaxErrorException { - logger.info("current xpath: {}", xpath); - List rs = doubanTest.selN(xpath); - for (JXNode n : rs) { - if (!n.isString()) { - int index = n.asElement().siblingIndex(); - logger.info("index = {}", index); - } - logger.info(n.toString()); - } - } - - /** - * d_test.html 来源于 https://book.douban.com/tag/%E4%BA%92%E8%81%94%E7%BD%91 - *

    - * 为了测试各种可能情况,ul[@class='subject-list']节点以及其下内容被复制了一份出来,并修改部分书名前缀为'T2-'以便区分 - */ - @DataProvider - public static Object[][] dataOfXpathAndexpect() { - return new Object[][]{ - {"//ul[@class='subject-list']/li[position()<3][last()]/div/h2/allText()", "黑客与画家 : 硅谷创业之父Paul Graham文集T2-黑客与画家 : 硅谷创业之父Paul Graham文集"}, - {"//ul[@class='subject-list']/li[first()]/div/h2/allText()", "失控 : 全人类的最终命运和结局T2-失控 : 全人类的最终命运和结局"}, - {"//ul[@class='subject-list']/li[./div/div/span[@class='pl']/num()>(1000+90*(2*50))][last()][1]/div/h2/allText()", "长尾理论长尾理论"}, - {"//ul[@class='subject-list']/li[self::li/div/div/span[@class='pl']/num()>10000][-1]/div/h2/allText()", "长尾理论长尾理论"}, - {"//ul[@class='subject-list']/li[contains(self::li/div/div/span[@class='pl']//text(),'14582')]/div/h2//text()", "黑客与画家: 硅谷创业之父Paul Graham文集T2-黑客与画家: 硅谷创业之父Paul Graham文集"}, - {"//ul[@class='subject-list']/li[contains(./div/div/span[@class='pl']//text(),'14582')]/div/h2//text()", "黑客与画家: 硅谷创业之父Paul Graham文集T2-黑客与画家: 硅谷创业之父Paul Graham文集"}, - {"//*[@id=\"subject_list\"]/ul/li[2]/div[2]/h2/a//text()", "黑客与画家: 硅谷创业之父Paul Graham文集T2-黑客与画家: 硅谷创业之父Paul Graham文集"}, - {"//ul[@class]", 3L}, - {"//a[@id]/@href", "https://www.douban.com/doumail/"}, - {"//*[@id=\"subject_list\"]/ul[1]/li[8]/div[2]/div[2]/span[3]/num()", "3734.0"}, - {"//a[@id]/@href | //*[@id=\"subject_list\"]/ul[1]/li[8]/div[2]/div[2]/span[3]/num()", "https://www.douban.com/doumail/3734.0"}, - }; - } - - @UseDataProvider("dataOfXpathAndexpect") - @Test - public void testXpathAndAssert(String xpath, Object expect) throws XpathSyntaxErrorException { - logger.info("current xpath: {}", xpath); - List rs = doubanTest.selN(xpath); - if (expect instanceof String) { - String res = StringUtils.join(rs, ""); - logger.info(res); - Assert.assertEquals(expect, res); - } else if (expect instanceof Number) { - long size = (long) expect; - Assert.assertEquals(size, rs.size()); - } - } - - @Test - @DataProvider(value = { - "//ul[@class='subject-list']/li[position()<3]" - }) - public void testJXNode(String xpath) throws XpathSyntaxErrorException { - logger.info("current xpath: {}", xpath); - List jxNodeList = doubanTest.selN(xpath); - Set expect = new HashSet<>(); - //第一个 ul 中的 - expect.add("失控: 全人类的最终命运和结局"); - expect.add("黑客与画家: 硅谷创业之父Paul Graham文集"); - //第二个 ul 中的 - expect.add("T2-失控: 全人类的最终命运和结局"); - expect.add("T2-黑客与画家: 硅谷创业之父Paul Graham文集"); - - Set res = new HashSet<>(); - for (JXNode node : jxNodeList) { - if (!node.isString()) { - String currentRes = StringUtils.join(node.sel("/div/h2/a//text()"), ""); - logger.info(currentRes); - res.add(currentRes); - } - } - Assert.assertEquals(expect, res); - } - - @Test - @DataProvider(value = { - "//ul[@class='subject-list']" - }) - public void testRecursionNode(String xpath) throws XpathSyntaxErrorException { - logger.info("current xpath: {}", xpath); - List jxNodeList = doubanTest.selN(xpath); - logger.info("size = {}", jxNodeList.size()); - // 有两个ul,下面的是为了测试特意复制添加的 - Assert.assertEquals(2, jxNodeList.size()); - } - - @Test - @DataProvider(value = { - "//body/div/div/h1/text()", - "/body/div/div/h1/text()" - }) - public void absolutePathTest(String xpath) throws XpathSyntaxErrorException { - logger.info("current xpath: {}", xpath); - List jxNodeList = doubanTest.selN(xpath); - logger.info("size = {},res ={}", jxNodeList.size(), jxNodeList); - } - - @Test - public void testAs() throws XpathSyntaxErrorException { - List jxNodeList = custom.selN("//b[contains(text(),'性别')]/parent::*/text()"); - Assert.assertEquals("男", StringUtils.join(jxNodeList, "")); - for (JXNode jxNode : jxNodeList) { - logger.info(jxNode.toString()); - } - } - - /** - * fix https://github.com/zhegexiaohuozi/JsoupXpath/issues/33 - */ -// @Test - public void testNotObj() { - JXDocument doc = JXDocument.createByUrl("https://www.gxwztv.com/61/61514/"); -// List nodes = doc.selN("//*[@id=\"chapters-list\"]/li[@style]"); - List nodes = doc.selN("//*[@id=\"chapters-list\"]/li[not(@style)]"); - for (JXNode node : nodes) { - logger.info("r = {}", node); - } - } - - /** - * fix https://github.com/zhegexiaohuozi/JsoupXpath/issues/34 - */ - @Test - public void testAttrAtRoot() { - String content = "\n" + - " \n" + - " \n" + - " 第2章 神奇交流群\n" + - " \n" + - ""; - JXDocument doc = JXDocument.create(content); - List nodes = doc.selN("//@href"); - for (JXNode node : nodes) { - logger.info("r = {}", node); - } - } - - @Test - public void testA() { - String content = "网页设计师"; - JXDocument doc = JXDocument.create(content); - List nodes = doc.selN("//*[text()='网页设计师']"); - for (JXNode node : nodes) { - logger.info("r = {}", node); - } - } - - /** - * fix https://github.com/zhegexiaohuozi/JsoupXpath/issues/52 - */ - @Test - public void fixTextBehaviorTest() { - String html = "

    分类:动漫地区:日本年份:2010

    "; - JXDocument jxDocument = JXDocument.create(html); - List jxNodes = jxDocument.selN("//text()[3]"); - String actual = StringUtils.join(jxNodes, ""); - logger.info("actual = {}", actual); - Assert.assertEquals("2010", actual); - List nodes = jxDocument.selN("//text()"); - String allText = StringUtils.join(nodes, ""); - Assert.assertEquals("分类:动漫地区:日本年份:2010", allText); - logger.info("all = {}", allText); - } - - /** - * fix https://github.com/zhegexiaohuozi/JsoupXpath/issues/44 - */ - @Test - public void fixTextElNoParentTest() { - String test = "
    a
    need
    not need
    c
    "; - JXDocument j = JXDocument.create(test); - List l = j.selN("//div[@class='a']//text()[not(ancestor::div[@class='e'])]"); - Set finalRes = new HashSet<>(); - for (JXNode i : l) { - logger.info("{}", i.toString()); - finalRes.add(i.asString()); - } - Assert.assertFalse(finalRes.contains("not need")); - Assert.assertTrue(finalRes.contains("need")); - Assert.assertEquals(4, finalRes.size()); - } - - /** - * fix https://github.com/zhegexiaohuozi/JsoupXpath/issues/53 - */ - @Test - public void fixIssue53() { - String content = "
  • \n" + - "
    \n" + - "
    \n" + - "
    \n" + - "

    我们平凡我们忠诚

    \n" + - "

    巡璃 |短篇|连载

    \n" + - "

    这是一位普通老兵的故事,这位老兵没有走上战场,也没有人歌颂他,但他的工作却是面对生与死,他是一名普通的军转干部,没有得到任何荣誉,却仍旧坚守着信仰,永远忠诚。除了他的家人,他的战友,他的故事不被任何人所知,但他的故事正是一代军人、一代军转干部的写照。所以,我来歌颂他,歌颂那一代人。

    \n" + - "

    最新更新 第一次见识到生死·2020-02-19

    \n" + - "
    \n" + - "
    \n" + - "
    \n" + - "

    4497总字数

    \n" + - "

    0总推荐

    \n" + - "
    \n" + - "

    书籍详情 加入书架

    \n" + - "
  • "; - JXDocument j = JXDocument.create(content); - List l = j.selN("//*[text()='总字数']//text()"); - Assert.assertEquals(2, l.size()); - Assert.assertEquals("4497", l.get(0).asString()); - Assert.assertEquals("总字数", l.get(1).asString()); - } - -} diff --git a/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/DateFormatTest.java b/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/DateFormatTest.java deleted file mode 100644 index 8b9571d89..000000000 --- a/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/DateFormatTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.junit.Test; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; - -/** - * @description: TODO
    - * @create: 2019-01-21 21:07 - * @author: zzldn@163.com - * @since JDK1.8 - **/ - -public class DateFormatTest { - - @Test - public void defaultTest() { - List params = new LinkedList<>(); - params.add(XValue.create("2019-01-21 19:05:42")); - params.add(XValue.create("yyyy-MM-dd HH:mm:ss")); - FormatDate formatDate = new FormatDate(); - XValue value = formatDate.call(null, params); - System.out.println(value.asDate()); - } - - @Test - public void defaultTimeTest() { - List params = new LinkedList<>(); - params.add(XValue.create("19:05:42")); - params.add(XValue.create("HH:mm:ss")); - FormatDate formatDate = new FormatDate(); - XValue value = formatDate.call(null, params); - System.out.println(value.asDate()); - } - - @Test - public void localTest() { - List params = new LinkedList<>(); - params.add(XValue.create("1/21/2019 07:05:42 AM")); - params.add(XValue.create("MM/dd/yyyy hh:mm:ss aa")); - params.add(XValue.create(Locale.ENGLISH.toString())); - FormatDate formatDate = new FormatDate(); - XValue value = formatDate.call(null, params); - System.out.println(value.asDate()); - } -} diff --git a/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/SubStringTest.java b/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/SubStringTest.java deleted file mode 100644 index 1ca106f86..000000000 --- a/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/function/SubStringTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.seimicrawler.xpath.core.function; - -import org.junit.Assert; -import org.junit.Test; -import org.seimicrawler.xpath.core.XValue; - -import java.util.LinkedList; -import java.util.List; - -/** - * SubString Tester. - * - * @author seimimaster@gmail.com - * @version 1.0 - */ -public class SubStringTest { - - /** - * substring("12345", 1.5, 2.6) returns "234" - * Method: call(Element context, List params) - */ - @Test - public void testCall() throws Exception { - List params = new LinkedList<>(); - params.add(XValue.create("12345")); - params.add(XValue.create("1.5")); - params.add(XValue.create("2.6")); - SubString subStringFunc = new SubString(); - Assert.assertEquals(subStringFunc.call(null, params).asString(), "234"); - } - - @Test - public void testZeroLength() throws Exception { - List params = new LinkedList<>(); - params.add(XValue.create("12345")); - params.add(XValue.create("2")); - params.add(XValue.create("-6")); - SubString subStringFunc = new SubString(); - Assert.assertEquals(subStringFunc.call(null, params).asString(), ""); - } - - @Test - public void testOneLength() throws Exception { - List params = new LinkedList<>(); - params.add(XValue.create("12345")); - params.add(XValue.create("0")); - params.add(XValue.create("1")); - SubString subStringFunc = new SubString(); - Assert.assertEquals(subStringFunc.call(null, params).asString(), "1"); - } - - -} diff --git a/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/node/NumTest.java b/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/node/NumTest.java deleted file mode 100644 index d685fcbac..000000000 --- a/JsoupXpath/src/test/java/org/seimicrawler/xpath/core/node/NumTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.seimicrawler.xpath.core.node; - -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; -import org.junit.Assert; -import org.junit.Test; -import org.seimicrawler.xpath.BaseTest; -import org.seimicrawler.xpath.core.Scope; -import org.seimicrawler.xpath.core.XValue; - -/** - * Num Tester. - * - * @author seimimaster@gmail.com - * @version 1.0 - */ -public class NumTest extends BaseTest { - - /** - * Method: call(Elements context) - */ - @Test - public void testCall() throws Exception { - Elements context = new Elements(); - Element el = new Element("V"); - el.appendText("test 33.69"); - context.add(el); - Num n = new Num(); - XValue v = n.call(Scope.create(context)); - logger.info("v = {}", v); - Assert.assertEquals(33.69, v.asDouble(), 0.00000000000001); - } - - @Test - public void testShort() throws Exception { - Elements context = new Elements(); - Element el = new Element("V"); - el.appendText("test .69"); - context.add(el); - Num n = new Num(); - XValue v = n.call(Scope.create(context)); - logger.info("v = {}", v); - Assert.assertEquals(0.69, v.asDouble(), 0.00000000000001); - } - - @Test - public void testOnZero() throws Exception { - Elements context = new Elements(); - Element el = new Element("V"); - el.appendText("test 69."); - context.add(el); - Num n = new Num(); - XValue v = n.call(Scope.create(context)); - logger.info("v = {}", v); - Assert.assertEquals(69, v.asDouble(), 0.00000000000001); - } - - -} diff --git a/JsoupXpath/src/test/java/org/seimicrawler/xpath/expr/ExprTest.java b/JsoupXpath/src/test/java/org/seimicrawler/xpath/expr/ExprTest.java deleted file mode 100644 index df7bbc832..000000000 --- a/JsoupXpath/src/test/java/org/seimicrawler/xpath/expr/ExprTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.seimicrawler.xpath.expr; - -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.tree.ParseTree; -import org.apache.commons.io.FileUtils; -import org.jsoup.Jsoup; -import org.jsoup.select.Elements; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.seimicrawler.xpath.BaseTest; -import org.seimicrawler.xpath.antlr.XpathLexer; -import org.seimicrawler.xpath.antlr.XpathParser; -import org.seimicrawler.xpath.core.XValue; -import org.seimicrawler.xpath.core.XpathProcessor; -import org.seimicrawler.xpath.exception.DoFailOnErrorHandler; - -import java.io.File; -import java.math.BigDecimal; -import java.net.URL; -import java.nio.charset.StandardCharsets; - -/** - * @author github.com/zhegexiaohuozi seimimaster@gmail.com - * @since 2017/12/6. - */ -public class ExprTest extends BaseTest { - - private Elements root; - private final ClassLoader loader = getClass().getClassLoader(); - - @Before - public void init() throws Exception { - // https://book.douban.com/tag/%E4%BA%92%E8%81%94%E7%BD%91 - URL t = loader.getResource("d_test.html"); - assert t != null; - File dBook = new File(t.toURI()); - String context = FileUtils.readFileToString(dBook, StandardCharsets.UTF_8); - root = Jsoup.parse(context).children(); - } - - @Test - public void exp() { - String xpath = "//a[@id]/@href"; - CharStream input = CharStreams.fromString(xpath); - XpathLexer lexer = new XpathLexer(input); - CommonTokenStream tokens = new CommonTokenStream(lexer); - XpathParser parser = new XpathParser(tokens); - parser.setErrorHandler(new DoFailOnErrorHandler()); - ParseTree tree = parser.main(); - XpathProcessor processor = new XpathProcessor(root); - XValue value = processor.visit(tree); - logger.info("visit res = {}", value); - } - - @Test - public void roundHalfUp() { - int x = new BigDecimal("5.53").setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); - Assert.assertEquals(6, x); - } -} \ No newline at end of file diff --git a/JsoupXpath/src/test/resources/d_test.html b/JsoupXpath/src/test/resources/d_test.html deleted file mode 100644 index b7becb155..000000000 --- a/JsoupXpath/src/test/resources/d_test.html +++ /dev/null @@ -1,5416 +0,0 @@ - - - - - - 豆瓣图书标签: 互联网 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    - -

    豆瓣图书标签: 互联网

    - -
    - -
    -
    - - -
    - - - 综合排序 -  /  - - 按出版日期排序 -  /  - - 按评价排序 - -
    - - - - - -
    - - <前页 - - - - 1 - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 7 - - - 8 - - - 9 - - ... - - 96 - - 97 - - - - 后页> - - -
    - - -
    -
    -
    - -
    -
    - - -

    - 相关的标签 -  · · · · · · - -

    - - - - - -
    - - -
    -
    -
    - - -

    - > 浏览全部图书标签 -

    - - -

    - "互联网"相关豆列 -  · · · · · · - -

    - - - - - -
    -
    - -
    -

    最近受关注的书-互联网

    - -
    - - - - - -
    -
    - -
    -
    -
    - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/build.gradle b/app/build.gradle index 2fd7672db..f43a57a42 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -179,7 +179,7 @@ dependencies { //规则相关 implementation('org.jsoup:jsoup:1.14.1') implementation('com.jayway.jsonpath:json-path:2.6.0') - implementation(project(path: ':JsoupXpath')) + implementation('cn.wanghaomiao:JsoupXpath:2.5.0') implementation(project(path: ':epublib')) //JS rhino diff --git a/app/src/main/res/layout/dialog_read_padding.xml b/app/src/main/res/layout/dialog_read_padding.xml index a517996d0..ab08bf930 100644 --- a/app/src/main/res/layout/dialog_read_padding.xml +++ b/app/src/main/res/layout/dialog_read_padding.xml @@ -2,13 +2,13 @@ + android:layout_height="wrap_content"> + android:orientation="vertical" + android:padding="10dp"> + android:orientation="horizontal" + android:paddingBottom="10dp"> + android:text="@string/header" + android:textSize="18sp" /> + app:max="100" + app:title="@string/padding_top" /> + app:max="100" + app:title="@string/padding_bottom" /> + app:max="100" + app:title="@string/padding_left" /> + app:max="100" + app:title="@string/padding_right" /> @@ -80,36 +80,36 @@ android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingBottom="10dp" - android:textSize="18sp" - android:text="@string/main_body" /> + android:text="@string/main_body" + android:textSize="18sp" /> + app:max="200" + app:title="@string/padding_top" /> + app:max="100" + app:title="@string/padding_bottom" /> + app:max="100" + app:title="@string/padding_left" /> + app:max="100" + app:title="@string/padding_right" /> + android:text="@string/footer" + android:textSize="18sp" /> + app:max="100" + app:title="@string/padding_top" /> + app:max="100" + app:title="@string/padding_bottom" /> + app:max="100" + app:title="@string/padding_left" /> + app:max="100" + app:title="@string/padding_right" /> diff --git a/app/src/main/res/layout/dialog_tip_config.xml b/app/src/main/res/layout/dialog_tip_config.xml index 55bfb6b4e..2cd7353ab 100644 --- a/app/src/main/res/layout/dialog_tip_config.xml +++ b/app/src/main/res/layout/dialog_tip_config.xml @@ -1,321 +1,327 @@ - + android:layout_height="wrap_content"> - - - + android:orientation="vertical" + android:padding="16dp"> - + android:text="@string/body_title" + android:textSize="18sp" /> - + + + + + + + + + + app:max="10" + app:title="@string/title_font_size" /> - - - - - - + app:max="100" + app:title="@string/title_margin_top" /> - - - - - - - + android:padding="3dp" + app:max="100" + app:title="@string/title_margin_bottom" /> - - - - - - - + android:text="@string/header" + android:textSize="18sp" /> - - - - - - - + + + + + + + + - - + + + + + + + + - - - - - - + + + + + + + + - - + + + + + + + + + android:text="@string/footer" + android:textSize="18sp" /> - - - - - - - - - + + + + + + + + - - - - - - + + + + + + + + - - + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - + android:text="@string/header_footer" + android:textSize="18sp" /> - + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="RtlHardcoded,RtlSymmetry"> + + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index a489efdc2..6e5b9d8ee 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app',':JsoupXpath',':epublib' +include ':app',':epublib'