[gxml] Fixed Node.text_node. GomCollection method rename
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixed Node.text_node. GomCollection method rename
- Date: Thu, 9 Feb 2017 23:48:16 +0000 (UTC)
commit 53a0384cea59871682b47f2d93643cb43c8655c4
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Feb 8 14:41:04 2017 -0600
Fixed Node.text_node. GomCollection method rename
GomCollection.validate_add() has been renamed to validate_append()
gxml/GomCollections.vala | 16 ++++++++--------
gxml/GomNode.vala | 2 +-
test/GomDocumentTest.vala | 12 ++++++++++++
3 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/gxml/GomCollections.vala b/gxml/GomCollections.vala
index 8c50f7a..c230847 100644
--- a/gxml/GomCollections.vala
+++ b/gxml/GomCollections.vala
@@ -119,7 +119,7 @@ public interface GXml.GomCollection : Object
*
* Return: true if node and index should be added to collection.
*/
- public abstract bool validate_add (int index, DomElement element) throws GLib.Error;
+ public abstract bool validate_append (int index, DomElement element) throws GLib.Error;
}
/**
@@ -212,7 +212,7 @@ public abstract class GXml.BaseCollection : Object {
* {@link element}.
*
* Object is always added as a child of {@link element}
- * but just added to collection if {@link validate_add} returns true;
+ * but just added to collection if {@link validate_append} returns true;
*/
public void append (DomElement node) throws GLib.Error {
if (_element == null)
@@ -229,7 +229,7 @@ public abstract class GXml.BaseCollection : Object {
throw new DomError.QUOTA_EXCEEDED_ERROR
(_("Node element not appended as child of parent. No node added to collection"));
var index = _element.child_nodes.size - 1;
- if (!validate_add (index, node)) return;
+ if (!validate_append (index, node)) return;
_nodes_index.push_tail (index);
}
/**
@@ -248,7 +248,7 @@ public abstract class GXml.BaseCollection : Object {
var n = _element.child_nodes.get (i);
if (n is GomObject) {
if ((n as DomElement).local_name.down () == items_name.down ()) {
- if (validate_add (i, n as DomElement))
+ if (validate_append (i, n as DomElement))
_nodes_index.push_tail (i);
}
}
@@ -257,7 +257,7 @@ public abstract class GXml.BaseCollection : Object {
/**
* {@inheritDoc}
*/
- public abstract bool validate_add (int index, DomElement element) throws GLib.Error;
+ public abstract bool validate_append (int index, DomElement element) throws GLib.Error;
}
/**
@@ -281,7 +281,7 @@ public abstract class GXml.BaseCollection : Object {
* }}}
*/
public class GXml.GomArrayList : GXml.BaseCollection, GomCollection {
- public override bool validate_add (int index, DomElement element) throws GLib.Error {
+ public override bool validate_append (int index, DomElement element) throws GLib.Error {
#if DEBUG
GLib.message ("Adding node:"+element.node_name);
#endif
@@ -302,7 +302,7 @@ public class GXml.GomArrayList : GXml.BaseCollection, GomCollection {
* }
* public class YourList : GomHashMap {
* construct {
- * try { initialize_with_key (typeof (YourObject,"Name")); }
+ * try { initialize_with_key (typeof (YourObject),"Name"); }
* catch (GLib.Error e) {
* warning ("Initialization error for collection type: %s : %s"
* .printf (get_type ().name(), e.message));
@@ -371,7 +371,7 @@ public class GXml.GomHashMap : GXml.BaseCollection, GXml.GomCollection {
*
* Return: false if element should not be added to collection.
*/
- public override bool validate_add (int index, DomElement element) throws GLib.Error {
+ public override bool validate_append (int index, DomElement element) throws GLib.Error {
if (!(element is GomElement)) return false;
#if DEBUG
message ("Validating HashMap Element..."
diff --git a/gxml/GomNode.vala b/gxml/GomNode.vala
index 442b2ed..782faa5 100644
--- a/gxml/GomNode.vala
+++ b/gxml/GomNode.vala
@@ -144,7 +144,7 @@ public class GXml.GomNode : Object,
}
set {
try {
- var t = _document.create_text_node (text_content);
+ var t = _document.create_text_node (value);
child_nodes.add (t);
} catch (GLib.Error e) {
GLib.warning (_("Text content in element can't be created"));
diff --git a/test/GomDocumentTest.vala b/test/GomDocumentTest.vala
index b83a2ba..865a854 100644
--- a/test/GomDocumentTest.vala
+++ b/test/GomDocumentTest.vala
@@ -314,6 +314,18 @@ class GomDocumentTest : GXmlTest {
assert (text.node_value == "Star of my dreams");
} catch { assert_not_reached (); }
});
+ Test.add_func ("/gxml/gom-document/node_text_content", () => {
+ try {
+ DomDocument doc = new GomDocument.from_string ("<document_element />");
+ var r = doc.document_element;
+ assert (r != null);
+ assert (r.text_content == null);
+ r.text_content = "Starting";
+ assert (r.child_nodes.length == 1);
+ assert (r.child_nodes.item (0) is DomText);
+ assert (r.child_nodes.item (0).node_value == "Starting");
+ } catch { assert_not_reached (); }
+ });
Test.add_func ("/gxml/gom-document/create_comment", () => {
try {
DomDocument doc = new GomDocument.from_string ("<document_element />");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]