Esempio n. 1
0
        public static Resource ToJenaResource(INode n, JenaMapping mapping)
        {
            switch (n.NodeType)
            {
            case NodeType.Uri:
                return(mapping.Model.createResource(n.ToString()));

            case NodeType.Blank:
                if (mapping.OutputMapping.ContainsKey(n))
                {
                    return(mapping.OutputMapping[n]);
                }
                else
                {
                    AnonId   id    = new AnonId(((IBlankNode)n).InternalID);
                    Resource bnode = mapping.Model.createResource(id);
                    mapping.OutputMapping.Add(n, bnode);
                    if (!mapping.InputMapping.ContainsKey(bnode))
                    {
                        mapping.InputMapping.Add(bnode, n);
                    }
                    return(bnode);
                }

            default:
                throw new RdfException("Only URI/Blank Nodes can be converted to Jena Resources");
            }
        }
Esempio n. 2
0
        public static RDFNode ToJenaNode(INode n, JenaMapping mapping)
        {
            switch (n.NodeType)
            {
            case NodeType.Uri:
                return(mapping.Model.createResource(n.ToString()));

            case NodeType.Blank:
                if (mapping.OutputMapping.ContainsKey(n))
                {
                    return(mapping.OutputMapping[n]);
                }
                else
                {
                    AnonId   id    = new AnonId(((IBlankNode)n).InternalID);
                    Resource bnode = mapping.Model.createResource(id);
                    mapping.OutputMapping.Add(n, bnode);
                    if (!mapping.InputMapping.ContainsKey(bnode))
                    {
                        mapping.InputMapping.Add(bnode, n);
                    }
                    return(bnode);
                }

            case NodeType.Literal:
                ILiteralNode lit = (ILiteralNode)n;
                if (lit.DataType != null)
                {
                    return(mapping.Model.createTypedLiteral(lit.Value, TypeMapper.getInstance().getSafeTypeByName(lit.DataType.ToString())));
                }
                else if (!lit.Language.Equals(String.Empty))
                {
                    return(mapping.Model.createLiteral(lit.Value, lit.Language));
                }
                else
                {
                    return(mapping.Model.createLiteral(lit.Value));
                }

            default:
                throw new RdfException("Only URI/Blank/Literal Nodes can be converted to Jena Nodes");
            }
        }
Esempio n. 3
0
 public static RDFNode ToJenaNode(INode n, JenaMapping mapping)
 {
     switch (n.NodeType)
     {
         case NodeType.Uri:
             return mapping.Model.createResource(n.ToString());
         case NodeType.Blank:
             if (mapping.OutputMapping.ContainsKey(n))
             {
                 return mapping.OutputMapping[n];
             }
             else
             {
                 AnonId id = new AnonId(((IBlankNode)n).InternalID);
                 Resource bnode = mapping.Model.createResource(id);
                 mapping.OutputMapping.Add(n, bnode);
                 if (!mapping.InputMapping.ContainsKey(bnode))
                 {
                     mapping.InputMapping.Add(bnode, n);
                 }
                 return bnode;
             }
         case NodeType.Literal:
             ILiteralNode lit = (ILiteralNode)n;
             if (lit.DataType != null)
             {
                 return mapping.Model.createTypedLiteral(lit.Value, TypeMapper.getInstance().getSafeTypeByName(lit.DataType.ToString()));
             } 
             else if (!lit.Language.Equals(String.Empty))
             {
                 return mapping.Model.createLiteral(lit.Value, lit.Language);
             }
             else 
             {
                 return mapping.Model.createLiteral(lit.Value);
             }
         default:
             throw new RdfException("Only URI/Blank/Literal Nodes can be converted to Jena Nodes");
     }
 }
Esempio n. 4
0
 public Resource createResource(AnonId ai)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
 public static Resource ToJenaResource(INode n, JenaMapping mapping)
 {
     switch (n.NodeType)
     {
         case NodeType.Uri:
             return mapping.Model.createResource(n.ToString());
         case NodeType.Blank:
             if (mapping.OutputMapping.ContainsKey(n))
             {
                 return mapping.OutputMapping[n];
             } 
             else 
             {
                 AnonId id = new AnonId(((IBlankNode)n).InternalID);
                 Resource bnode = mapping.Model.createResource(id);
                 mapping.OutputMapping.Add(n, bnode);
                 if (!mapping.InputMapping.ContainsKey(bnode))
                 {
                     mapping.InputMapping.Add(bnode, n);
                 }
                 return bnode;
             }
         default:
             throw new RdfException("Only URI/Blank Nodes can be converted to Jena Resources");
     }
 }
Esempio n. 6
0
 public Resource createResource(AnonId ai)
 {
     throw new NotImplementedException();
 }