DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
PlSqlBlock.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Linq;
20 
22 
23 namespace Deveel.Data.Sql.Statements {
24  public class PlSqlBlock : IPreparable, IDisposable {
25  private ICollection<SqlStatement> statements;
26  private ICollection<ExceptionHandler> exceptionHandlers;
27 
28  public PlSqlBlock() {
29  statements = new List<SqlStatement>();
30  exceptionHandlers = new List<ExceptionHandler>();
31  }
32 
34  Dispose(false);
35  }
36 
37  public string Label { get; set; }
38 
39  public IEnumerable<SqlStatement> Statements {
40  get { return statements.AsEnumerable(); }
41  }
42 
43  public IEnumerable<ExceptionHandler> ExceptionHandlers {
44  get { return exceptionHandlers.AsEnumerable(); }
45  }
46 
47  public void AddStatement(SqlStatement statement) {
48  // TODO: make further checks, such as if a labeled statement with
49  // the same label already exists
50  statements.Add(statement);
51  }
52 
53  public void AddExceptionHandler(ExceptionHandler handler) {
54  // TODO: make further checks here ...
55  exceptionHandlers.Add(handler);
56  }
57 
58  /*
59  protected virtual BlockExecuteContext CreateExecuteContext() {
60  throw new NotImplementedException();
61  }
62  */
63 
64  protected virtual PlSqlBlock Prepare(IExpressionPreparer preparer) {
65  throw new NotImplementedException();
66  }
67 
69  return Prepare(preparer);
70  }
71 
72  public void Dispose() {
73  Dispose(true);
74  GC.SuppressFinalize(this);
75  }
76 
77  protected virtual void Dispose(bool disposing) {
78  if (disposing) {
79  if (statements != null)
80  statements.Clear();
81  if (exceptionHandlers != null)
82  exceptionHandlers.Clear();
83  }
84 
85  statements = null;
86  exceptionHandlers = null;
87  }
88  }
89 }
void AddExceptionHandler(ExceptionHandler handler)
Definition: PlSqlBlock.cs:53
ICollection< SqlStatement > statements
Definition: PlSqlBlock.cs:25
virtual void Dispose(bool disposing)
Definition: PlSqlBlock.cs:77
void AddStatement(SqlStatement statement)
Definition: PlSqlBlock.cs:47
ICollection< ExceptionHandler > exceptionHandlers
Definition: PlSqlBlock.cs:26
Represents the foundation class of SQL statements to be executed.
Definition: SqlStatement.cs:32
virtual PlSqlBlock Prepare(IExpressionPreparer preparer)
Converts the underlying value of this instance into an object that can be evaluated by an expression...
Definition: PlSqlBlock.cs:64
An interface used to prepare a SqlExpression object.
object Prepare(IExpressionPreparer preparer)
Converts the underlying value of this instance into an object that can be evaluated by an expression...
A contract for objects that participate to a SqlExpression.Prepare phase of an expression evaluation...
Definition: IPreparable.cs:30