DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
RoutineParameter.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.Text;
19 
20 using Deveel.Data.Types;
21 
22 namespace Deveel.Data.Routines {
23  public sealed class RoutineParameter {
24  public RoutineParameter(string name, SqlType type, ParameterAttributes attributes)
25  : this(name, type, ParameterDirection.Input, attributes) {
26  }
27 
28  public RoutineParameter(string name, SqlType type)
29  : this(name, type, ParameterDirection.Input) {
30  }
31 
32  public RoutineParameter(string name, SqlType type, ParameterDirection direction)
33  : this(name, type, direction, ParameterAttributes.None) {
34  }
35 
36  public RoutineParameter(string name, SqlType type, ParameterDirection direction, ParameterAttributes attributes) {
37  Attributes = attributes;
38  Direction = direction;
39  Type = type;
40  Name = name;
41  }
42 
43  public string Name { get; private set; }
44 
45  public ParameterDirection Direction { get; private set; }
46 
47  public SqlType Type { get; private set; }
48 
49  public ParameterAttributes Attributes { get; private set; }
50 
51  public int Offset { get; internal set; }
52 
53  public bool IsNullable {
54  get { return (Attributes & ParameterAttributes.Nullable) != 0; }
55  }
56 
57  public bool IsUnbounded {
58  get { return (Attributes & ParameterAttributes.Unbounded) != 0; }
59  }
60 
61  public bool IsOutput {
62  get { return (Direction & ParameterDirection.Output) != 0; }
63  }
64 
65  public bool IsInput {
66  get { return (Direction & ParameterDirection.Input) != 0; }
67  }
68 
69  public override string ToString() {
70  var sb = new StringBuilder();
71  if (IsInput && !IsOutput) {
72  sb.Append("IN");
73  } else if (IsOutput && !IsInput) {
74  sb.Append("OUT");
75  } else if (IsOutput && IsInput) {
76  sb.Append("IN OUT");
77  }
78 
79  sb.Append(Name);
80  sb.Append(" ");
81  sb.Append(Type);
82 
83  if (!IsNullable)
84  sb.Append("NOT NULL");
85 
86  return sb.ToString();
87  }
88  }
89 }
RoutineParameter(string name, SqlType type, ParameterDirection direction)
ParameterDirection
The possible directions of a procedure parameter.
RoutineParameter(string name, SqlType type, ParameterAttributes attributes)
RoutineParameter(string name, SqlType type, ParameterDirection direction, ParameterAttributes attributes)
RoutineParameter(string name, SqlType type)
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
The parameter provides an input value to the procedure, but won't be able to output a value eventuall...