thank you Claus and Martynas, both very good ideas here. it's a function we should move into Jena.
let's look at this in a bit more detail now, I currently envision this to be a factory method of org.apache.jena.query.Query returning boolean like .isSelect() .isAsk() .isDescribe() .isUpdate() Claus your solution would extend the following? org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:100) how is fuseki implementing this during query parsing at the moment? On Wed, Mar 18, 2020 at 1:00 PM Martynas Jusevičius <marty...@atomgraph.com> wrote: > I always wondered why there is no class hierarchy for SPARQL commands, > similarly to SP vocabulary [1]. Something like > > Command > Query > Describe > Construct > Select > Ask > Update > ... > > So that one could check command type doing instanceof Update or > instance of Select instead of query.isSelectType() etc. > > [1] https://github.com/spinrdf/spinrdf/blob/master/etc/sp.ttl > > > > On Wed, Mar 18, 2020 at 12:58 PM Marco Neumann <marco.neum...@gmail.com> > wrote: > > > > is there some utility function here in the code base now already to do > > this, or do I still need to roll my own here? > > > > On Tue, Jul 30, 2013 at 4:25 PM Andy Seaborne <a...@apache.org> wrote: > > > > > On 30/07/13 10:13, Arthur Vaïsse-Lesteven wrote: > > > > Hi, > > > > > > > > I would like to know if Jena offers a way to detect the type of an > > > unknow SPARQL request ?Starting from the query string. > > > > > > > > At the moment the only way I succed to code it without "basic > parsing" > > > of the query ( sort of thing I prefer avoid, manually parsing string > with > > > short function often create errors ) > > > > looks like this : > > > > > > > > [...] > > > > String queryString = "a query string, may be a select or an > > > update"; > > > > > > > > try{ > > > > Query select = QueryFactory.create(queryString); > > > > Service.process_select_query(select);//do some work with > > > the select > > > > } > > > > catch(QueryException e){ > > > > UpdateRequest update = > UpdateFactory.create(queryString); > > > > Service.process_update_query(update);//do some work with > > > the update > > > > } > > > > catch(ProcessException e){ > > > > //handle this exception > > > > } > > > > > > > > [...] > > > > > > > > So is it possible ? Or not ? > > > > > > Not currently. > > > > > > You could use a regexp to spot the SELECT/CONSTRUCT/DESCRIBE/ASK > keyword > > > coming after BASE/PREFIXES/Comments. > > > > > > Andy > > > > > > > > > > -- > > > > > > --- > > Marco Neumann > > KONA > -- --- Marco Neumann KONA