dotgnu-libs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-libs-commits] CVS: dotgnu.rdf RdfEdge.cs,NONE,1.1 RdfNode.cs,NO


From: James Michael DuPont <address@hidden>
Subject: [Dotgnu-libs-commits] CVS: dotgnu.rdf RdfEdge.cs,NONE,1.1 RdfNode.cs,NONE,1.1
Date: Sat, 08 Feb 2003 04:36:02 -0500

Update of /cvsroot/dotgnu-libs/dotgnu.rdf
In directory subversions:/tmp/cvs-serv31578

Added Files:
        RdfEdge.cs RdfNode.cs 
Log Message:
cleaned up



--- NEW FILE ---
/*
 * RdfNode.cs - Implementation of the "DotGNU.Rdf.RdfNode" class.
 *
 * Copyright (C) 2003  Adam Ballai, Cannibutter Software.
 *
 * This program 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 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Original Author: Rahul Singh (address@hidden) 
 * Thank you Rahul Singh.
 */

namespace DotGNU.Rdf
{
        /// <summary>
        /// This class represents an RDFEdge in the RDFGraph
        /// </summary>
        public class RdfEdge
        {
                /// <summary>
                /// This constant indicates that this edge is an incoming edge. 
This constant is used in the RdfNode class
                /// </summary>
                public const int EdgeTypeIncoming = 0;
                /// <summary>
                /// This constant indicates that this edge is an outgoing edge. 
This constant is used in the RdfNode class
                /// </summary>
                public const int EdgeTypeOutgoing = 1;

                /// <summary>
                /// This member variable points to the RdfNode that this edge 
originates from. i.e. the subject of this predicate
                /// </summary>
                public RdfNode SourceNode;
                /// <summary>
                /// This member variable points to the RdfNode that this edge 
point to. i.e. the object of this predicate
                /// </summary>
                public RdfNode DestNode;

                /// <summary>
                /// The local name of this edge. This value is obtained from 
the local name of the XMLElement denoting this edge.
                /// </summary>
                public String EdgeLocalName;
                /// <summary>
                /// This is the Namespace prefix associated with the XML 
element denoting this edge
                /// </summary>
                public String EdgePrefix;
                /// <summary>
                /// This is the XMLNamespace associated with the XML element 
denoting this edge
                /// </summary>
                public String NameSpace;
                
                public String LangID;
                public String Datatype;
                public RdfNode reifiedNode;
                /// <summary>
                /// This is the main constructor for the RdfEdge class.
                /// </summary>
                public RdfEdge()
                {
                        NameSpace = "";
                        LangID = null;
                        Datatype = null;
        
                        reifiedNode = null; // this needs RdfNode to be defined
                }
        }
}

--- NEW FILE ---
/*
 * RdfNode.cs - Implementation of the "DotGNU.Rdf.RdfNode" class.
 *
 * Copyright (C) 2003  Adam Ballai, Cannibutter Software.
 *
 * This program 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 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Original Author: Rahul Singh (address@hidden) 
 * Thank you Rahul Singh.
 */

namespace DotGNU.Rdf
{
        using System;
        using System.Xml;
        using System.Collections;

        public class RdfNode
        {
                public String nodeID;
                public Hashtable edges;
                public String nameSpacePrefix;
                public String nameSpace;
                public bool isBlankNode;
                public String nodeData;
                public String langID;
                public String bagID;
                        
                
                public RdfNode()
                {
                        nameSpace = "";
                        edges = new Hashtable();
                        isBlankNode = true;
                        bagID = null;
                }

                public ArrayList GetEdges()
                {
                        try
                        {
                                ArrayList edgeList = new ArrayList();
                                IDictionaryEnumerator enumerator = 
edges.GetEnumerator();
                                while(enumerator.MoveNext())
                                {
                                        edgeList.Add(enumerator.Key);
                                }
                                return edgeList;
                        }
                        catch(NullReferenceException e)
                        {
                                return null;
                        }
                }
                
                public ArrayList GetIncomingEdges()
                {
                        try
                        {
                                ArrayList edgeList = new ArrayList();
                                IDictionaryEnumerator enumerator = 
edges.GetEnumerator();
                                while(enumerator.MoveNext())
                                {
                                        if((int)enumerator.Value == 
RdfEdge.EdgeTypeIncoming)
                                                edgeList.Add(enumerator.Key);
                                }
                                return edgeList;
                        }
                        catch(NullReferenceException e)
                        {
                                return null;
                        }
                }

                public ArrayList GetOutgoingEdges()
                {
                        try
                        {
                                ArrayList edgeList = new ArrayList();
                                IDictionaryEnumerator enumerator = 
edges.GetEnumerator();
                                while(enumerator.MoveNext())
                                {
                                        if((int)enumerator.Value == 
RdfEdge.EdgeTypeOutgoing)
                                                edgeList.Add(enumerator.Key);
                                }
//TODO: no conversion from `System.Collections.Hashtable' to 
`System.Collections.ArrayList'
                                return edgeList;
                        }
                        catch(NullReferenceException e)
                        {
                                return null;
                        }
                }

                public bool IsEdge(RdfEdge rdfEdge)
                {
                        try
                        {
                                if(edges.ContainsKey(rdfEdge))
                                {
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }
                        }
                        catch(NullReferenceException e)
                        {
                                return false;
                        }
                        catch(ArgumentNullException e)
                        {
                                return false;
                        }

                }

                public bool IsIncomingEdge(RdfEdge rdfEdge)
                {
                        try
                        {
                                if((int)edges[rdfEdge] == 
RdfEdge.EdgeTypeIncoming)
                                {
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }

                        }
                        catch(NullReferenceException e)
                        {
                                return false;
                        }
                        catch(ArgumentNullException e)
                        {
                                return false;
                        }

                }
                
                public bool IsOutgoingEdge(RdfEdge rdfEdge)
                {
                        try
                        {
                                if((int)edges[rdfEdge] == 
RdfEdge.EdgeTypeOutgoing)
                                {
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }
                        }
                        catch(NullReferenceException e)
                        {
                                return false;
                        }
                        catch(ArgumentNullException e)
                        {
                                return false;

                        }
                }

                public bool AddRdfEdge(RdfEdge rdfEdge, int edgeType)
                {
                        try
                        {
                                edges.Add(rdfEdge, edgeType);
                                return true;    
                        }
                        catch(ArgumentException e)
                        {
                                throw new ArgumentException(
                                        //TODO : implement S
                                        //S._("ArgumentException"), 
                                        "ArgumentException",
                                        "RdfEdge");
                                return false;
                        }
                }
        }

}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]