From e00632462aaedecab0b57101fa90bb4255dded51 Mon Sep 17 00:00:00 2001 From: Daniel Espinosa Date: Mon, 9 Apr 2018 17:40:40 -0500 Subject: [PATCH] Deprecate Node derived classes. Fixes on BaseCollection. Deprecate Node and all derived classes as it is tied to DOM1. Collection.element is renamed to parent_element to avoid conflicts with GomCollection.element --- gxml/Attribute.vala | 3 ++- gxml/CDATA.vala | 3 ++- gxml/Character.vala | 9 +++++--- gxml/Collections.vala | 38 ++++++++++++++++----------------- gxml/Comment.vala | 3 ++- gxml/Containers.vala | 22 ------------------- gxml/Document.vala | 4 +++- gxml/DocumentType.vala | 3 ++- gxml/DomCharacter.vala | 13 ++++++++++- gxml/Element.vala | 3 ++- gxml/GXmlAttribute.vala | 2 +- gxml/GXmlCDATA.vala | 2 +- gxml/GomCollections.vala | 14 +++++++++--- gxml/Namespace.vala | 3 ++- gxml/Node.vala | 1 + gxml/NodeType.vala | 8 +++---- gxml/Notation.vala | 4 +++- gxml/ProcessingInstruction.vala | 3 ++- 18 files changed, 74 insertions(+), 64 deletions(-) delete mode 100644 gxml/Containers.vala diff --git a/gxml/Attribute.vala b/gxml/Attribute.vala index f7e5ee4d..655bcc98 100644 --- a/gxml/Attribute.vala +++ b/gxml/Attribute.vala @@ -22,7 +22,7 @@ using Gee; /** - * DOM4 Interface to handle XML tags properties, powered by libxml2 library. + * DOM1 Interface to handle XML tags properties, powered by libxml2 library. * * Its features relays on {@link GXml.Node} interface inplementation to access * {@link GXml.Element} properties. @@ -30,6 +30,7 @@ using Gee; * Attribute's name could be get from {@link GXml.Node.name} property. Its value * should be get from {@link GXml.Node.value} property. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomAttr")] public interface GXml.Attribute : Object, GXml.Node { public abstract GXml.Namespace? @namespace { owned get; set; } public abstract string? prefix { owned get; } diff --git a/gxml/CDATA.vala b/gxml/CDATA.vala index e555a0d4..2e0c9b1e 100644 --- a/gxml/CDATA.vala +++ b/gxml/CDATA.vala @@ -23,8 +23,9 @@ using Gee; /** - * CDATA sections in XML documents. + * DOM1 CDATA sections in XML documents. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "")] public interface GXml.CDATA : Object, GXml.Node { diff --git a/gxml/Character.vala b/gxml/Character.vala index d0ad2489..4d4e7a3b 100644 --- a/gxml/Character.vala +++ b/gxml/Character.vala @@ -7,19 +7,22 @@ * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . * * Authors: * Daniel Espinosa */ - +/** + * DOM1 interface + */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomCharacterData")] public interface GXml.Character : Object, GXml.Node { public abstract string str { owned get; set; } diff --git a/gxml/Collections.vala b/gxml/Collections.vala index d5bedbbd..5f1df310 100644 --- a/gxml/Collections.vala +++ b/gxml/Collections.vala @@ -23,27 +23,27 @@ using Gee; /** - * A DOM4 interface to keep references to {@link DomElement} children of a {@link element} + * A DOM4 interface to keep references to {@link DomElement} children of a {@link parent_element} */ public interface GXml.Collection : Object { /** - * A list of child {@link DomElement} objects of {@link element} + * A list of child {@link DomElement} objects of {@link parent_element} */ public abstract GLib.Queue nodes_index { get; } /** - * A {@link GXml.DomCollection} with all child elements in collection. + * A {@link GXml.DomElement} with all child elements in collection. */ - public abstract GXml.DomCollection element { get; construct set; } + public abstract GXml.DomElement parent_element { get; construct set; } /** - * Local name of {@link DomElement} objects of {@link element}, which could be + * Local name of {@link DomElement} objects of {@link parent_element}, which could be * contained in this collection. * * Used when reading to add elements to collection. */ public abstract string items_name { get; } /** - * A {@link GLib.Type} of {@link DomElement} child objects of {@link element}, + * A {@link GLib.Type} of {@link DomElement} child objects of {@link parent_element}, * which could be contained in this collection. * * Type should be an {@link GomObject}. @@ -51,11 +51,11 @@ public interface GXml.Collection : Object public abstract Type items_type { get; construct set; } /** * Search and add references to all {@link GomObject} nodes as child of - * {@link element} with same, case insensitive, name of {@link items_name} + * {@link parent_element} with same, case insensitive, name of {@link items_name} */ public abstract void search () throws GLib.Error; /** - * Gets a child {@link DomElement} of {@link element} referenced in + * Gets a child {@link DomElement} of {@link parent_element} referenced in * {@link nodes_index}. */ public virtual DomElement? get_item (int index) throws GLib.Error { @@ -65,12 +65,12 @@ public interface GXml.Collection : Object throw new DomError.INDEX_SIZE_ERROR (_("Invalid index for elements in array list")); int i = nodes_index.peek_nth (index); - if (i < 0 || i >= element.child_nodes.size) + if (i < 0 || i >= parent_element.child_nodes.size) throw new DomError.INDEX_SIZE_ERROR (_("Invalid index reference for child elements in array list")); - var e = element.child_nodes.get (i); + var e = parent_element.child_nodes.get (i); if (e != null) - if (!(e is GXml.DomCollection)) + if (!(e is GXml.Collection)) throw new DomError.INVALID_NODE_TYPE_ERROR (_("Referenced object's type is invalid. Should be a GXmlDomElement")); return (DomElement?) e; @@ -86,7 +86,7 @@ public interface GXml.Collection : Object */ public virtual int length { get { return (int) nodes_index.get_length (); } } /** - * Initialize collection to use a given {@link GXml.DomCollection} derived type. + * Initialize collection to use a given {@link GXml.Collection} derived type. * Internally, this method create an instance of given type to initialize * {@link items_type} and {@link items_name}. * @@ -96,8 +96,8 @@ public interface GXml.Collection : Object public abstract void initialize (GLib.Type t) throws GLib.Error; /** * Creates a new instance of {@link items_type}, with same - * {@link DomNode.owner_document} than {@link element}. New instance - * is not set as a child of collection's {@link element}; to do so, + * {@link DomNode.owner_document} than {@link parent_element}. New instance + * is not set as a child of collection's {@link parent_element}; to do so, * use {@link append} * * Returns: a new instance object or null if type is not a {@link DomElement} or no parent has been set @@ -105,9 +105,9 @@ public interface GXml.Collection : Object public virtual DomElement? create_item () { if (items_type.is_a (GLib.Type.INVALID)) return null; if (!items_type.is_a (typeof (DomElement))) return null; - if (element == null) return null; + if (parent_element == null) return null; return Object.new (items_type, - "owner_document", element.owner_document) as DomElement; + "owner_document", parent_element.owner_document) as DomElement; } /** * Validate if given node and index, should be added to collection. @@ -131,7 +131,7 @@ public interface GXml.Collection : Object public interface GXml.List : Object, Collection, Traversable, Iterable {} /** - * Inteface to be implemented by {@link GXml.DomCollection} derived classes + * Inteface to be implemented by {@link GXml.Collection} derived classes * in order to provide a string to be used in {@link GomHashMap} as key. * * If {@link GomHashMap} has set its {@link GomHashMap.attribute_key} @@ -167,7 +167,7 @@ public interface GXml.Map : Object, GXml.Collection, Traversable, It /** - * Inteface to be implemented by {@link GXml.DomCollection} derived classes + * Inteface to be implemented by {@link GXml.Collection} derived classes * in order to provide a strings to be used in {@link GomHashPairedMap} as keys. */ public interface GXml.MappeableElementPairKey : Object, DomElement { @@ -215,7 +215,7 @@ public interface GXml.PairedMap : Object, GXml.Collection, Traversable - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Authors: - * Daniel Espinosa - */ - diff --git a/gxml/Document.vala b/gxml/Document.vala index c10d1885..be502132 100644 --- a/gxml/Document.vala +++ b/gxml/Document.vala @@ -25,16 +25,18 @@ using Gee; /** * Errors for documents handling {@link GXml.Document} reading/writing */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomError")] public errordomain GXml.DocumentError { INVALID_DOCUMENT_ERROR, INVALID_FILE } /** - * Interface to handle XML documents. + * DOM1 Interface to handle XML documents. * * Provides basic interfaces to read and create XML documents. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomDocument")] public interface GXml.Document : Object, GXml.Node { /** diff --git a/gxml/DocumentType.vala b/gxml/DocumentType.vala index fd0fa112..e07e4e25 100644 --- a/gxml/DocumentType.vala +++ b/gxml/DocumentType.vala @@ -23,6 +23,7 @@ using Gee; /** - * Interface to represent Document type definitions. + * DOM1 Interface to represent Document type definitions. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomDocumentType")] public interface GXml.DocumentType : Object, GXml.Node {} diff --git a/gxml/DomCharacter.vala b/gxml/DomCharacter.vala index b9226a08..79a5bae8 100644 --- a/gxml/DomCharacter.vala +++ b/gxml/DomCharacter.vala @@ -20,6 +20,9 @@ * Daniel Espinosa */ +/** + * DOM4 character handling interface + */ public interface GXml.DomCharacterData : GLib.Object, GXml.DomNode, GXml.DomNonDocumentTypeChildNode, @@ -67,6 +70,9 @@ public interface GXml.DomCharacterData : GLib.Object, } } +/** + * DOM4 text node + */ public interface GXml.DomText : GXml.DomCharacterData { public virtual GXml.DomText split_text (int offset) throws GLib.Error { Init.init (); @@ -93,10 +99,15 @@ public interface GXml.DomText : GXml.DomCharacterData { } } } - +/** + * DOM4 Processing Instruction node + */ public interface GXml.DomProcessingInstruction : GXml.DomCharacterData { public abstract string target { owned get; } } +/** + * DOM4 comment node + */ public interface GXml.DomComment : GXml.DomCharacterData {} diff --git a/gxml/Element.vala b/gxml/Element.vala index 60474e78..c022dc5e 100644 --- a/gxml/Element.vala +++ b/gxml/Element.vala @@ -22,11 +22,12 @@ using Gee; /** - * Interface to access XML document's tags, properties and content. + * DOM1 Interface to access XML document's tags, properties and content. * * Provides methods to create new XML tags properties and its values, and * access to tag's contents. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomElement")] public interface GXml.Element : Object, GXml.Node { /** diff --git a/gxml/GXmlAttribute.vala b/gxml/GXmlAttribute.vala index bee36e5c..29d955e2 100644 --- a/gxml/GXmlAttribute.vala +++ b/gxml/GXmlAttribute.vala @@ -22,7 +22,7 @@ using Gee; /** - * Class implemeting {@link GXml.Attribute} interface, not tied to libxml-2.0 library. + * Class implemeting {@link GXml.DomAttr} interface, not tied to libxml-2.0 library. */ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr { diff --git a/gxml/GXmlCDATA.vala b/gxml/GXmlCDATA.vala index 653988c7..e7982e4d 100644 --- a/gxml/GXmlCDATA.vala +++ b/gxml/GXmlCDATA.vala @@ -22,7 +22,7 @@ using Gee; /** - * DOM4 Class implemeting {@link GXml.CDATA} interface, powered by libxml2 library. + * DOM1 Class implemeting {@link GXml.CDATA} interface, powered by libxml2 library. */ public class GXml.GCDATA : GXml.GNode, GXml.CDATA { diff --git a/gxml/GomCollections.vala b/gxml/GomCollections.vala index 30ace7d6..ad885fff 100644 --- a/gxml/GomCollections.vala +++ b/gxml/GomCollections.vala @@ -24,10 +24,8 @@ using Gee; /** * A DOM4 interface to keep references to {@link DomElement} in a {@link element} * child nodes. Only {@link GomObject} are supported. - * - * @deprecated 0.18 - * @see GXml.Collection */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.Collection")] public interface GXml.GomCollection : Object { /** @@ -187,6 +185,16 @@ public abstract class GXml.BaseCollection : Object, Traversable, Ite _element = value; } } + /** + * {@inheritDoc} + */ + public DomElement parent_element { + get { return _element as DomElement; } + construct set { + if (value is GomElement) + _element = value as GomElement; + } + } /** * {@inheritDoc} */ diff --git a/gxml/Namespace.vala b/gxml/Namespace.vala index 4bacbfc3..e1af7d34 100644 --- a/gxml/Namespace.vala +++ b/gxml/Namespace.vala @@ -23,7 +23,7 @@ using Gee; /** - * Interface to handle XML Namespaces. + * DOM1 Interface to handle XML Namespaces. * * Basic information for a XML document's namespaces and applied to a given * {@link GXml.Node}. @@ -31,6 +31,7 @@ using Gee; * Namespace management is a matter of this or other libraries, implementing * this interfaces. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "")] public interface GXml.Namespace : Object { /** diff --git a/gxml/Node.vala b/gxml/Node.vala index 32daaef9..94fb6154 100644 --- a/gxml/Node.vala +++ b/gxml/Node.vala @@ -25,6 +25,7 @@ using Gee; /** * Base interface providing basic functionalities for DOM1 interfaces. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomNode")] public interface GXml.Node : Object { /** diff --git a/gxml/NodeType.vala b/gxml/NodeType.vala index 45d432b2..08efa504 100644 --- a/gxml/NodeType.vala +++ b/gxml/NodeType.vala @@ -25,14 +25,12 @@ // TODO: want a method to convert NodeType to a string /** - * Enumerates possible NodeTypes. + * DOM1 Enumerates possible NodeTypes. * * For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-1950641247]] */ -public enum GXml.NodeType { // TODO: Rename to DomNodeType - /* NOTE: bug in vala? if I don't have == 0, I fail when creating - this class because I can't set default values for NodeType properties - GLib-GObject-CRITICAL **: g_param_spec_enum: assertion `g_enum_get_value (enum_class, default_value) != NULL' failed */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomNode.NodeType")] +public enum GXml.NodeType { INVALID = 0, ELEMENT = 1, ATTRIBUTE, diff --git a/gxml/Notation.vala b/gxml/Notation.vala index e8a0b876..b5257f07 100644 --- a/gxml/Notation.vala +++ b/gxml/Notation.vala @@ -23,7 +23,7 @@ using Gee; /** - * Interface to handle notation elements + * DOM1 Interface to handle notation elements * * Used in defining {@link GXml.DocumentType}s to declare the format of * {@link GXml.Entity} and {@link GXml.ProcessingInstruction}s. @@ -33,6 +33,7 @@ using Gee; * ProcessingInstruction targets. * For more, see: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-5431D1B9]] */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "")] public interface GXml.Notation : Object, GXml.Node { public abstract string? public_id { get; } @@ -42,4 +43,5 @@ public interface GXml.Notation : Object, GXml.Node /** * Dummy definition for entity. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "")] public interface GXml.Entity : Object, GXml.Node {} diff --git a/gxml/ProcessingInstruction.vala b/gxml/ProcessingInstruction.vala index 2efa5bbf..48e74737 100644 --- a/gxml/ProcessingInstruction.vala +++ b/gxml/ProcessingInstruction.vala @@ -23,8 +23,9 @@ using Gee; /** - * Interface for XML Processing Instruction sections. + * DOM1 Interface for XML Processing Instruction sections. */ +[Version (deprecated = true, deprecated_since = "0.18", replacement = "GXml.DomProcessingInstruction")] public interface GXml.ProcessingInstruction : Object, GXml.Node { /** -- GitLab