Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.providers.query
Class QuerySectionProcessor

    java.lang.Object
      org.makumba.providers.query.QuerySectionProcessor

    public class QuerySectionProcessor

extends Object

Given a query and a starting point, this class identifies the subquery where the starting point is, its parent query, its grandparent query ... ending with the outer query. After this analysis, it can insert text in the query and expand the FROM and WHERE sections. For all queries and subqueries the class separates the projection, FROM and WHERE sections. To analyze/process just the outer query, use 0 as a starting point.

Version:
  $Id: $
Author:
  Cristian Bogdan

Nested Class Summary
`(package private) static class` | `QuerySectionProcessor.Insertion`
`(package private) class` | `QuerySectionProcessor.SubqueryData`

Field Summary
`static Pattern` | `allFunctionBegin`
`(package private) boolean` | `closed`
`static Pattern` | `ident`
`static String` | `PATTERN_ALL_FUNCTION_CALL_BEGIN`
`(package private) StringBuffer` | `query`
`(package private) ArrayList<QuerySectionProcessor.SubqueryData>` | `subqueries`

Constructor Summary
`QuerySectionProcessor(String query, int startPoint)`

Method Summary
`void` | `addFromWhere(QuerySectionProcessor func, String thisExpr)` Given a query, add from it to the FROM section and to the WHERE condition of the outermost possible suquery.
`void` | `addFromWhere(String from, String where)` Add to the FROM section and to the WHERE condition of the outermost suquery.
`String` | `getFrom()` Return the FROM section of the outer query, without the word FROM
`String` | `getInitialFrom()` Return the initial FROM section of all subqueries up to the starting point.
`String` | `getProjectionText()` Return the projection section of the outer query, without the word SELECT
`String` | `getText()` Return the query text
`String` | `getWhere()` Return the WHERE section of the outer query, without the word WHERE.
`static void` | `main(String[] argv)`
`(package private) static String` | `paranthesize(String before, String after, String expr)`
`void` | `replaceExpr(int regionStart, int regionLength, String text)` Replace the expression begining at regionStart, of length regionLength with the given text.
`void` | `replaceParameter(String name, String parameterInline)` Inline a parameter.
`(package private) void` | `replaceThis(String thisExpr)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### query

    StringBuffer query

### subqueries

    ArrayList<QuerySectionProcessor.SubqueryData> subqueries

### closed

    boolean closed

### PATTERN_ALL_FUNCTION_CALL_BEGIN

    public static final String PATTERN_ALL_FUNCTION_CALL_BEGIN

### allFunctionBegin

    public static final Pattern allFunctionBegin

### ident

    public static final Pattern ident

Constructor Detail

### QuerySectionProcessor

    public QuerySectionProcessor(String query,
                                 int startPoint)

Method Detail

### getInitialFrom

    public String getInitialFrom()

  Return the initial FROM section of all subqueries up to the starting point. This gives the complete type-context for a function inlined at the starting point.

### getProjectionText

    public String getProjectionText()

  Return the projection section of the outer query, without the word SELECT

### replaceParameter

    public void replaceParameter(String name,
                                 String parameterInline)

  Inline a parameter.

### replaceThis

    void replaceThis(String thisExpr)

### replaceExpr

    public void replaceExpr(int regionStart,
                            int regionLength,
                            String text)

  Replace the expression begining at regionStart, of length regionLength with the given text.

### addFromWhere

    public void addFromWhere(QuerySectionProcessor func,
                             String thisExpr)

  Given a query, add from it to the FROM section and to the WHERE condition of the outermost possible suquery. If the FROM uses a label defined in a subquery, the sections will be added to that subquery. Otherwise everything will be added to the outer query. The labels of the given query will be adapted according to the context of this query as in the end the text of that query will make it somewhere into this query. The "this" of the given query wil be replaced by thisExpr.

  Parameters:
    `func` - the section processor of the function expression that might contain a from or a where
    `thisExpr` - the object that will substitute "this" in the expression

### addFromWhere

    public void addFromWhere(String from,
                             String where)

  Add to the FROM section and to the WHERE condition of the outermost suquery.

  Parameters:
    `from` - the from section
    `where` - the where section for joining it

### getText

    public String getText()

  Return the query text

### getWhere

    public String getWhere()

  Return the WHERE section of the outer query, without the word WHERE.

### getFrom

    public String getFrom()

  Return the FROM section of the outer query, without the word FROM

### paranthesize

    static String paranthesize(String before,
                               String after,
                               String expr)

### main

    public static void main(String[] argv)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20