Giter Site home page Giter Site logo

salesforce-soql-parser's Introduction

Salesforce SOQL Parser

This is a java parser for SOQL (Salesforce Query Language) implemented with ANTLR 3. This parser was built following to the SOQL syntax definition provided by Salesforce.

There is a another implementation of the parser based on ANTLR 4 not yet released. The SOQL ANTLR 4 grammar can be seen here.

Usage

You can use the parser generated by ANTLR straight away, but the simplest way to parse and process queries is by using the SOQLParserHelper. With the SOQLParserHelper you can create a simpler object representation of the SOQL query.

public String printSelectClause(String soqlText)
{
    //Use the SOQLParserHelper to create a SOQLQuery object containing the SOQL query data
    SOQLQuery queryData = SOQLParserHelper.createSOQLData(soqlText);
        
    //Get the object representation of part of the SOQL query 
    SelectClause selectClause = queryData.getSelectClause();
        
    //Use the toSOQLText method of any part of the query to convert it back to text
    return selectClause.toSOQLText();
}

You can also use the SOQLParserHelper to obtain the ANTRL AST of a SOQL query.

SOQLCommonTree queryDataAST = SOQLParserHelper.createSOQLParserTree(soqlText);

To simplify query processing the SOQLQuery class accepts visitors. The easiest way to implement visitors for SOQLQuery is extending the SOQLDataBaseVisitor class.

Maven Configuration

Maven dependency

<dependency>
    <groupId>org.mule.tools</groupId>
    <artifactId>salesforce-soql-parser</artifactId>
    <version>2.0</version>
</dependency>

Maven repositories

<repositories>
    <repository>
        <id>mulesoft-releases</id>
        <name>MuleSoft Releases Repository</name>
        <url>http://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
    </repository>
    <repository>
        <id>mulesoft-snapshots</id>
        <name>MuleSoft Snapshots Repository</name>
        <url>http://repository.mulesoft.org/snapshots/</url>
        <layout>default</layout>
    </repository>
</repositories>

License

Common Public Attribution License Version 1.0 (CPAL)

salesforce-soql-parser's People

Contributors

dnp1988 avatar

Stargazers

Teo Asinari avatar  avatar  avatar

Watchers

Adam Luong avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.