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

Public Member Functions

 SqlXmlNode (byte[] content)
 
SqlXmlNode Extract (string xpath)
 
SqlXmlNode Extract (string xpath, string xmlNs)
 
ISqlObject ExtractValue (string xpath)
 
ISqlObject ExtractValue (string xpath, string xmlNs)
 
SqlXmlNode Update (string xpath, ISqlObject value)
 
SqlXmlNode Update (string xpath, ISqlObject value, string xmlNs)
 
SqlString ToSqlString ()
 
SqlBinary ToSqlBinary ()
 
void Dispose ()
 
SqlXmlNode AppendChild (string xpath, SqlXmlNode value)
 
SqlXmlNode Delete (string xpath)
 
XmlNode ToXmlNode ()
 
byte[] ToBytes ()
 
SqlXmlNode InsertChild (string xpath, SqlXmlNode child, SqlXmlNode value)
 

Static Public Attributes

static readonly SqlXmlNode Null = new SqlXmlNode(null, true)
 

Properties

bool IsNull [get, private set]
 
- Properties inherited from Deveel.Data.Sql.Objects.ISqlObject
bool IsNull [get]
 Gets a boolean value indicating if the object is NULL. More...
 

Private Member Functions

 SqlXmlNode (byte[] content, bool isNull)
 
int IComparable. CompareTo (object obj)
 
int IComparable< ISqlObject >. CompareTo (ISqlObject other)
 
bool ISqlObject. IsComparableTo (ISqlObject other)
 Checks if the current object is comparable with the given one. More...
 
XPathNavigator CreateNavigator ()
 
XmlNamespaceManager NamespaceManager (string xmlNs)
 
void AsserCanEdit ()
 
byte[] SelectSingle (string xpath, string xmlNs)
 
bool SelectSingleValue (string xpath, string xmlNs, out object value, out Type valueType)
 
bool Update (string xpath, object value, string xmlNs, out byte[] updated)
 

Static Private Member Functions

static byte[] AsBinary (XPathNavigator navigator)
 

Private Attributes

byte[] content
 
XPathNavigator navigator
 

Detailed Description

Definition at line 8 of file SqlXmlNode.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Objects.SqlXmlNode.SqlXmlNode ( byte[]  content,
bool  isNull 
)
inlineprivate

Definition at line 14 of file SqlXmlNode.cs.

14  {
15  this.content = content;
16  IsNull = isNull;
17 
19  }
XPathNavigator CreateNavigator()
Definition: SqlXmlNode.cs:39
Deveel.Data.Sql.Objects.SqlXmlNode.SqlXmlNode ( byte[]  content)
inline

Definition at line 21 of file SqlXmlNode.cs.

22  : this(content, false) {
23  }

Member Function Documentation

SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.AppendChild ( string  xpath,
SqlXmlNode  value 
)
inline

Definition at line 190 of file SqlXmlNode.cs.

190  {
191  throw new NotImplementedException();
192  }
static byte [] Deveel.Data.Sql.Objects.SqlXmlNode.AsBinary ( XPathNavigator  navigator)
inlinestaticprivate

Definition at line 76 of file SqlXmlNode.cs.

76  {
77  using (var stream = new MemoryStream()) {
78  using (var writer = new StreamWriter(stream, Encoding.UTF8)) {
79  using (var xmlWriter = new XmlTextWriter(writer)) {
80  xmlWriter.Formatting = Formatting.None;
81 
82  navigator.WriteSubtree(xmlWriter);
83 
84  xmlWriter.Flush();
85 
86  return stream.ToArray();
87  }
88  }
89  }
90  }
void Deveel.Data.Sql.Objects.SqlXmlNode.AsserCanEdit ( )
inlineprivate

Definition at line 63 of file SqlXmlNode.cs.

63  {
64  if (!navigator.CanEdit)
65  throw new NotSupportedException("The current node cannot be edited.");
66  }
int IComparable. Deveel.Data.Sql.Objects.SqlXmlNode.CompareTo ( object  obj)
inlineprivate

Definition at line 25 of file SqlXmlNode.cs.

25  {
26  throw new NotSupportedException();
27  }
int IComparable<ISqlObject>. Deveel.Data.Sql.Objects.SqlXmlNode.CompareTo ( ISqlObject  other)
inlineprivate

Definition at line 29 of file SqlXmlNode.cs.

29  {
30  throw new NotSupportedException();
31  }
XPathNavigator Deveel.Data.Sql.Objects.SqlXmlNode.CreateNavigator ( )
inlineprivate

Definition at line 39 of file SqlXmlNode.cs.

39  {
40  if (IsNull)
41  return null;
42 
43  using (var stream = new MemoryStream(content)) {
44  using (var xmlReader = new StreamReader(stream, Encoding.UTF8)) {
45  var xmlDocument = new XmlDocument();
46  xmlDocument.Load(xmlReader);
47  return xmlDocument.CreateNavigator();
48  }
49  }
50  }
SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.Delete ( string  xpath)
inline

Definition at line 194 of file SqlXmlNode.cs.

194  {
195  throw new NotImplementedException();
196  }
void Deveel.Data.Sql.Objects.SqlXmlNode.Dispose ( )
inline

Definition at line 185 of file SqlXmlNode.cs.

185  {
186  navigator = null;
187  content = null;
188  }
SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.Extract ( string  xpath)
inline

Definition at line 121 of file SqlXmlNode.cs.

121  {
122  return Extract(xpath, null);
123  }
SqlXmlNode Extract(string xpath)
Definition: SqlXmlNode.cs:121
SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.Extract ( string  xpath,
string  xmlNs 
)
inline

Definition at line 125 of file SqlXmlNode.cs.

125  {
126  if (IsNull)
127  return Null;
128 
129  var bytes = SelectSingle(xpath, xmlNs);
130  if (bytes == null)
131  return Null;
132 
133  // TODO: Control the encoding on properties of the type...
134  return new SqlXmlNode(bytes);
135  }
SqlXmlNode(byte[] content, bool isNull)
Definition: SqlXmlNode.cs:14
byte[] SelectSingle(string xpath, string xmlNs)
Definition: SqlXmlNode.cs:68
static readonly SqlXmlNode Null
Definition: SqlXmlNode.cs:12
ISqlObject Deveel.Data.Sql.Objects.SqlXmlNode.ExtractValue ( string  xpath)
inline

Definition at line 137 of file SqlXmlNode.cs.

137  {
138  return ExtractValue(xpath, null);
139  }
ISqlObject ExtractValue(string xpath)
Definition: SqlXmlNode.cs:137
ISqlObject Deveel.Data.Sql.Objects.SqlXmlNode.ExtractValue ( string  xpath,
string  xmlNs 
)
inline

Definition at line 141 of file SqlXmlNode.cs.

141  {
142  if (IsNull)
143  return Null;
144 
145  object value;
146  Type valueType;
147  if (!SelectSingleValue(xpath, xmlNs, out value, out valueType))
148  return SqlNull.Value;
149 
150  if (valueType == typeof(string))
151  return new SqlString((string)value);
152 
153  // TODO: support other types
154 
155  throw new NotSupportedException();
156  }
static readonly SqlXmlNode Null
Definition: SqlXmlNode.cs:12
A user-defined TYPE that holds complex objects in a database column.
bool SelectSingleValue(string xpath, string xmlNs, out object value, out Type valueType)
Definition: SqlXmlNode.cs:92
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.InsertChild ( string  xpath,
SqlXmlNode  child,
SqlXmlNode  value 
)
inline

Definition at line 206 of file SqlXmlNode.cs.

206  {
207  throw new NotImplementedException();
208  }
bool ISqlObject. Deveel.Data.Sql.Objects.SqlXmlNode.IsComparableTo ( ISqlObject  other)
inlineprivate

Checks if the current object is comparable with the given one.

Parameters
otherThe other ISqlObject to compare.
Returns
Returns true if the current object is comparable with the given one, false otherwise.

Implements Deveel.Data.Sql.Objects.ISqlObject.

Definition at line 35 of file SqlXmlNode.cs.

35  {
36  return false;
37  }
XmlNamespaceManager Deveel.Data.Sql.Objects.SqlXmlNode.NamespaceManager ( string  xmlNs)
inlineprivate

Definition at line 52 of file SqlXmlNode.cs.

52  {
53  XmlNamespaceManager nsManager = null;
54  if (!String.IsNullOrEmpty(xmlNs)) {
55  var nameTable = new NameTable();
56  nameTable.Add(xmlNs);
57  nsManager = new XmlNamespaceManager(nameTable);
58  }
59 
60  return nsManager;
61  }
A long string in the system.
byte [] Deveel.Data.Sql.Objects.SqlXmlNode.SelectSingle ( string  xpath,
string  xmlNs 
)
inlineprivate

Definition at line 68 of file SqlXmlNode.cs.

68  {
69  var nodeNavigator = navigator.SelectSingleNode(xpath, NamespaceManager(xmlNs));
70  if (nodeNavigator == null)
71  return null;
72 
73  return AsBinary(nodeNavigator);
74  }
static byte[] AsBinary(XPathNavigator navigator)
Definition: SqlXmlNode.cs:76
XmlNamespaceManager NamespaceManager(string xmlNs)
Definition: SqlXmlNode.cs:52
bool Deveel.Data.Sql.Objects.SqlXmlNode.SelectSingleValue ( string  xpath,
string  xmlNs,
out object  value,
out Type  valueType 
)
inlineprivate

Definition at line 92 of file SqlXmlNode.cs.

92  {
93  value = null;
94  valueType = null;
95 
96  var nodeNavigator = navigator.SelectSingleNode(xpath, NamespaceManager(xmlNs));
97  if (nodeNavigator == null)
98  return false;
99 
100  valueType = nodeNavigator.ValueType;
101  value = nodeNavigator.TypedValue;
102  return true;
103  }
XmlNamespaceManager NamespaceManager(string xmlNs)
Definition: SqlXmlNode.cs:52
byte [] Deveel.Data.Sql.Objects.SqlXmlNode.ToBytes ( )
inline

Definition at line 202 of file SqlXmlNode.cs.

202  {
203  return content;
204  }
SqlBinary Deveel.Data.Sql.Objects.SqlXmlNode.ToSqlBinary ( )
inline

Definition at line 178 of file SqlXmlNode.cs.

178  {
179  if (IsNull)
180  return SqlBinary.Null;
181 
182  return new SqlBinary(content);
183  }
SqlString Deveel.Data.Sql.Objects.SqlXmlNode.ToSqlString ( )
inline

Definition at line 170 of file SqlXmlNode.cs.

170  {
171  if (IsNull)
172  return SqlString.Null;
173 
174  var bytes = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, content);
175  return new SqlString(bytes);
176  }
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
XmlNode Deveel.Data.Sql.Objects.SqlXmlNode.ToXmlNode ( )
inline

Definition at line 198 of file SqlXmlNode.cs.

198  {
199  throw new NotImplementedException();
200  }
bool Deveel.Data.Sql.Objects.SqlXmlNode.Update ( string  xpath,
object  value,
string  xmlNs,
out byte[]  updated 
)
inlineprivate

Definition at line 105 of file SqlXmlNode.cs.

105  {
106  AsserCanEdit();
107 
108  updated = null;
109 
110  var rootNavigator = navigator.Clone();
111  var nodeNavigator = rootNavigator.SelectSingleNode(xpath, NamespaceManager(xmlNs));
112  if (nodeNavigator == null)
113  return false;
114 
115  nodeNavigator.SetValue(value.ToString());
116 
117  updated = AsBinary(rootNavigator);
118  return true;
119  }
static byte[] AsBinary(XPathNavigator navigator)
Definition: SqlXmlNode.cs:76
XmlNamespaceManager NamespaceManager(string xmlNs)
Definition: SqlXmlNode.cs:52
SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.Update ( string  xpath,
ISqlObject  value 
)
inline

Definition at line 158 of file SqlXmlNode.cs.

158  {
159  return Update(xpath, value, null);
160  }
bool Update(string xpath, object value, string xmlNs, out byte[] updated)
Definition: SqlXmlNode.cs:105
SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.Update ( string  xpath,
ISqlObject  value,
string  xmlNs 
)
inline

Definition at line 162 of file SqlXmlNode.cs.

162  {
163  byte[] updated;
164  if (!Update(xpath, value, xmlNs, out updated))
165  return Null;
166 
167  return new SqlXmlNode(updated);
168  }
SqlXmlNode(byte[] content, bool isNull)
Definition: SqlXmlNode.cs:14
static readonly SqlXmlNode Null
Definition: SqlXmlNode.cs:12
bool Update(string xpath, object value, string xmlNs, out byte[] updated)
Definition: SqlXmlNode.cs:105

Member Data Documentation

byte [] Deveel.Data.Sql.Objects.SqlXmlNode.content
private

Definition at line 9 of file SqlXmlNode.cs.

XPathNavigator Deveel.Data.Sql.Objects.SqlXmlNode.navigator
private

Definition at line 10 of file SqlXmlNode.cs.

readonly SqlXmlNode Deveel.Data.Sql.Objects.SqlXmlNode.Null = new SqlXmlNode(null, true)
static

Definition at line 12 of file SqlXmlNode.cs.

Property Documentation

bool Deveel.Data.Sql.Objects.SqlXmlNode.IsNull
getprivate set

Definition at line 33 of file SqlXmlNode.cs.


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