Search in sources :

Example 6 with XValue

use of org.seimicrawler.xpath.core.XValue in project JsoupXpath by zhegexiaohuozi.

the class DateFormatTest method localTest.

@Test
public void localTest() {
    List<XValue> 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());
}
Also used : XValue(org.seimicrawler.xpath.core.XValue) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 7 with XValue

use of org.seimicrawler.xpath.core.XValue in project JsoupXpath by zhegexiaohuozi.

the class DateFormatTest method defaultTest.

@Test
public void defaultTest() {
    List<XValue> 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());
}
Also used : XValue(org.seimicrawler.xpath.core.XValue) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 8 with XValue

use of org.seimicrawler.xpath.core.XValue in project JsoupXpath by zhegexiaohuozi.

the class NumTest method testOnZero.

@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);
}
Also used : Element(org.jsoup.nodes.Element) Elements(org.jsoup.select.Elements) XValue(org.seimicrawler.xpath.core.XValue) BaseTest(org.seimicrawler.xpath.BaseTest) Test(org.junit.Test)

Example 9 with XValue

use of org.seimicrawler.xpath.core.XValue in project JsoupXpath by zhegexiaohuozi.

the class NumTest method testShort.

@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);
}
Also used : Element(org.jsoup.nodes.Element) Elements(org.jsoup.select.Elements) XValue(org.seimicrawler.xpath.core.XValue) BaseTest(org.seimicrawler.xpath.BaseTest) Test(org.junit.Test)

Example 10 with XValue

use of org.seimicrawler.xpath.core.XValue in project JsoupXpath by zhegexiaohuozi.

the class NumTest method testCall.

/**
 * 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);
}
Also used : Element(org.jsoup.nodes.Element) Elements(org.jsoup.select.Elements) XValue(org.seimicrawler.xpath.core.XValue) BaseTest(org.seimicrawler.xpath.BaseTest) Test(org.junit.Test)

Aggregations

XValue (org.seimicrawler.xpath.core.XValue)10 Test (org.junit.Test)7 LinkedList (java.util.LinkedList)5 Element (org.jsoup.nodes.Element)5 BaseTest (org.seimicrawler.xpath.BaseTest)4 Elements (org.jsoup.select.Elements)3 BigDecimal (java.math.BigDecimal)2 CharStream (org.antlr.v4.runtime.CharStream)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)2 ParseTree (org.antlr.v4.runtime.tree.ParseTree)2 XpathLexer (org.seimicrawler.xpath.antlr.XpathLexer)2 XpathParser (org.seimicrawler.xpath.antlr.XpathParser)2 XpathProcessor (org.seimicrawler.xpath.core.XpathProcessor)2 DoFailOnErrorHandler (org.seimicrawler.xpath.exception.DoFailOnErrorHandler)2 Matcher (java.util.regex.Matcher)1 NodeTest (org.seimicrawler.xpath.core.NodeTest)1 XpathParserException (org.seimicrawler.xpath.exception.XpathParserException)1 XpathSyntaxErrorException (org.seimicrawler.xpath.exception.XpathSyntaxErrorException)1