DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
CellKey.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 
19 using Deveel.Data.Sql;
20 using Deveel.Data.Sql.Tables;
21 
22 namespace Deveel.Data.Caching {
23  public sealed class CellKey : IEquatable<CellKey> {
24  private readonly string database;
25  private readonly CellId cellId;
26 
27  internal CellKey(string database, CellId cellId) {
28  if (String.IsNullOrEmpty(database))
29  throw new ArgumentNullException("database");
30 
31  if (cellId.RowId.IsNull)
32  throw new ArgumentException("Null ROWID in key.","cellId");
33  if (cellId.ColumnOffset < 0)
34  throw new ArgumentOutOfRangeException("cellId", "The column offset in the key is smaller than zero.");
35 
36  this.database = database;
37  this.cellId = cellId;
38  }
39 
40  public string Database {
41  get { return database; }
42  }
43 
44  public RowId RowId {
45  get { return cellId.RowId; }
46  }
47 
48  public int ColumnOffset {
49  get { return cellId.ColumnOffset; }
50  }
51 
52  public bool Equals(CellKey other) {
53  if (other == null)
54  return false;
55 
56  return String.Equals(database, other.database) &&
57  cellId.Equals(other.cellId);
58  }
59 
60  public override bool Equals(object obj) {
61  var other = obj as CellKey;
62  return Equals(other);
63  }
64 
65  public override int GetHashCode() {
66  unchecked {
67  return ((database != null ? database.GetHashCode() : 0)*397) ^ cellId.GetHashCode();
68  }
69  }
70  }
71 }
bool IsNull
Gets a boolean value indicating if the object equivales to a NULL.
Definition: RowId.cs:64
readonly CellId cellId
Definition: CellKey.cs:25
readonly string database
Definition: CellKey.cs:24
bool Equals(CellKey other)
Definition: CellKey.cs:52
The default implementation of a database in a system.
Definition: Database.cs:38
override int GetHashCode()
Definition: CellKey.cs:65
RowId(int tableId, int rowNumber)
Constructs the object with the references to the given table unique ID and the number of the row with...
Definition: RowId.cs:39
override bool Equals(object obj)
Definition: CellKey.cs:60
CellKey(string database, CellId cellId)
Definition: CellKey.cs:27
Defines the value of a ROWID object, that is a unique reference within a database system to a single ...
Definition: RowId.cs:24