Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Triple"/> struct.
 /// </summary>
 public Triple(Node subject, IriNode predicate, Node obj)
     : this()
 {
     Subject = subject;
     Predicate = predicate;
     Object = obj;
 }
 /// <summary>
 /// Handles matched predicate
 /// </summary>
 public override void PredicateMatched(IriNode predicateNode)
 {
     Parser.State = new PredicateMatchedState(Parser, CurrentLine, _subjectNode, predicateNode);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PredicateMatchedState"/> class.
 /// </summary>
 public PredicateMatchedState(NQuadsParser parser, int currentLine, Node subjectNode, IriNode predicateNode)
     : base(parser, currentLine)
 {
     _subjectNode = subjectNode;
     _predicateNode = predicateNode;
 }
Example #4
0
        bool TryReadQuad(string line, out Edge edge)
        {
            edge = null;

            line = line.Trim();
            if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
            {
                return(false);
            }

            string temp = "";

            INode subject;

            if (TryReadIri(line, ref temp, ref line))
            {
                subject = new IriNode(new Iri(temp));
            }
            else if (TryReadBlankNode(line, ref temp, ref line))
            {
                subject = GetOrCreateBlankNode(temp);
            }
            else
            {
                return(false);
            }

            line = line.TrimStart();

            INode predicate;

            if (TryReadIri(line, ref temp, ref line))
            {
                predicate = new IriNode(new Iri(temp));
            }
            else
            {
                return(false);
            }

            line = line.TrimStart();

            INode obj;

            if (TryReadIri(line, ref temp, ref line))
            {
                obj = new IriNode(new Iri(temp));
            }
            else if (TryReadBlankNode(line, ref temp, ref line))
            {
                obj = GetOrCreateBlankNode(temp);
            }
            else if (line.StartsWith("\""))
            {
                string value = "", languageCode = "";
                Iri    dataType = null;
                if (!TryReadLiteral(line, ref value, ref dataType, ref languageCode, ref line))
                {
                    return(false);
                }
                if (dataType == null)
                {
                    obj = new LiteralNode(value, languageCode);
                }
                else
                {
                    obj = new LiteralNode(value, dataType);
                }
            }
            else
            {
                return(false);
            }

            line = line.TrimStart();

            INode context = null;

            if (TryReadIri(line, ref temp, ref line))
            {
                context = new IriNode(new Iri(temp));
            }
            else if (TryReadBlankNode(line, ref temp, ref line))
            {
                context = GetOrCreateBlankNode(temp);
            }

            edge = new Edge(subject, predicate, obj, context);

            return(true);
        }