DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Deveel.Data.Sql.Expressions.PreparerVisitor Class Reference
Inheritance diagram for Deveel.Data.Sql.Expressions.PreparerVisitor:
Deveel.Data.Sql.Expressions.SqlExpressionVisitor

Public Member Functions

 PreparerVisitor (IExpressionPreparer preparer)
 
override SqlExpression Visit (SqlExpression expression)
 Visits a given SQL expression. More...
 
override SqlExpression VisitAssign (SqlAssignExpression assign)
 
override SqlExpression VisitQuery (SqlQueryExpression query)
 
- Public Member Functions inherited from Deveel.Data.Sql.Expressions.SqlExpressionVisitor
virtual SqlExpression[] VisitExpressionList (SqlExpression[] list)
 Visits a list of expressions given. More...
 
virtual SqlExpression VisitFunctionCall (SqlFunctionCallExpression expression)
 Visits the expression that calls the function defined. More...
 
virtual SqlExpression VisitBinary (SqlBinaryExpression binaryEpression)
 
virtual SqlExpression VisitUnary (SqlUnaryExpression unary)
 
virtual SqlExpression VisitCast (SqlCastExpression castExpression)
 
virtual SqlExpression VisitReference (SqlReferenceExpression reference)
 
virtual SqlExpression VisitVariableReference (SqlVariableReferenceExpression reference)
 
virtual SqlExpression VisitConstant (SqlConstantExpression constant)
 
virtual SqlExpression VisitConditional (SqlConditionalExpression conditional)
 
virtual SqlExpression VisitTuple (SqlTupleExpression expression)
 

Static Private Member Functions

static IEnumerable< T > Prepare< T > (IEnumerable< T > list, IExpressionPreparer preparer)
 

Private Attributes

readonly IExpressionPreparer preparer
 

Detailed Description

Definition at line 21 of file PreparerVisitor.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Expressions.PreparerVisitor.PreparerVisitor ( IExpressionPreparer  preparer)
inline

Definition at line 24 of file PreparerVisitor.cs.

24  {
25  this.preparer = preparer;
26  }
readonly IExpressionPreparer preparer

Member Function Documentation

static IEnumerable<T> Deveel.Data.Sql.Expressions.PreparerVisitor.Prepare< T > ( IEnumerable< T >  list,
IExpressionPreparer  preparer 
)
inlinestaticprivate
Type Constraints
T :IPreparable 

Definition at line 47 of file PreparerVisitor.cs.

48  : IPreparable {
49  var newList = new List<T>();
50  foreach (var item in list) {
51  var newItem = item;
52  if (newItem != null) {
53  newItem = (T)newItem.Prepare(preparer);
54  }
55 
56  newList.Add(newItem);
57  }
58 
59  return newList.ToArray();
60  }
readonly IExpressionPreparer preparer
override SqlExpression Deveel.Data.Sql.Expressions.PreparerVisitor.Visit ( SqlExpression  expression)
inlinevirtual

Visits a given SQL expression.

Parameters
expressionThe SqlExpression to visit.
Returns
Returns an instance of SqlExpression as result of the visit.

Reimplemented from Deveel.Data.Sql.Expressions.SqlExpressionVisitor.

Definition at line 28 of file PreparerVisitor.cs.

28  {
29  if (preparer.CanPrepare(expression))
30  expression = preparer.Prepare(expression);
31 
32  return base.Visit(expression);
33  }
SqlExpression Prepare(SqlExpression expression)
Returns the new translated object to be mutated from the given expression.
readonly IExpressionPreparer preparer
bool CanPrepare(SqlExpression expression)
Verifies whether the instance of the interface can prepare the given expression.
override SqlExpression Deveel.Data.Sql.Expressions.PreparerVisitor.VisitAssign ( SqlAssignExpression  assign)
inlinevirtual

Parameters
assign
Returns

Reimplemented from Deveel.Data.Sql.Expressions.SqlExpressionVisitor.

Definition at line 35 of file PreparerVisitor.cs.

35  {
36  var reference = assign.ReferenceExpression;
37  if (reference != null)
38  reference = reference.Prepare(preparer);
39 
40  var valueExpression = assign.ValueExpression;
41  if (valueExpression != null)
42  valueExpression = valueExpression.Prepare(preparer);
43 
44  return SqlExpression.Assign(reference, valueExpression);
45  }
readonly IExpressionPreparer preparer
override SqlExpression Deveel.Data.Sql.Expressions.PreparerVisitor.VisitQuery ( SqlQueryExpression  query)
inlinevirtual

Parameters
query
Returns

Reimplemented from Deveel.Data.Sql.Expressions.SqlExpressionVisitor.

Definition at line 62 of file PreparerVisitor.cs.

62  {
63  var selectColumns = Prepare(query.SelectColumns, preparer);
64  var newExpression = new SqlQueryExpression(selectColumns);
65 
66  var where = query.WhereExpression;
67  if (where != null)
68  where = where.Prepare(preparer);
69 
70  newExpression.WhereExpression = where;
71 
72  var having = query.HavingExpression;
73  if (having != null)
74  having = having.Prepare(preparer);
75 
76  newExpression.HavingExpression = having;
77 
78  var from = query.FromClause;
79  if (from != null)
80  from = (FromClause) ((IPreparable)from).Prepare(preparer);
81 
82  query.FromClause = from;
83 
84  var nextComposite = query.NextComposite;
85  if (nextComposite != null)
86  nextComposite = (SqlQueryExpression) nextComposite.Prepare(preparer);
87 
88  query.NextComposite = nextComposite;
89 
90  return newExpression;
91  }
readonly IExpressionPreparer preparer

Member Data Documentation

readonly IExpressionPreparer Deveel.Data.Sql.Expressions.PreparerVisitor.preparer
private

Definition at line 22 of file PreparerVisitor.cs.


The documentation for this class was generated from the following file: