commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Marsh (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JXPATH-191) List operations and Predicates do not seem to work
Date Mon, 03 Jul 2017 13:43:00 GMT
David Marsh created JXPATH-191:
----------------------------------

             Summary: List operations and Predicates do not seem to work
                 Key: JXPATH-191
                 URL: https://issues.apache.org/jira/browse/JXPATH-191
             Project: Commons JXPath
          Issue Type: Improvement
            Reporter: David Marsh


This program does not work :-

    public static void main(String[] args) {
        Deal deal = new Deal();

        Quote firstQuote = (Quote)JXPathContext.newContext(deal).
                getValue("quotes[1]");

        Quote lastQuote = (Quote)JXPathContext.newContext(deal).
                getValue("quotes[last()]");

        System.out.println(lastQuote.id);
    }

    private static class Deal {
        private List<Quote> quotes = new ArrayList<>();
        {
            quotes.add(new Quote(1));
            quotes.add(new Quote(2));
        }

        public Collection<Quote> getQuotes() {
            return quotes;
        }
    }

    private static class Quote {
        int id;
        public Quote(int id) {
            this.id = id;
        }
    }

Exception in thread "main" org.apache.commons.jxpath.JXPathException: Cannot access property:
com.baml.gmdp.ux.reporting.model.generic.JXPathTest$Deal.quotes; No read method

Most importantly id like to do XPath experessions like "quotes[last()]".



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message