Exemplo n.º 1
0
        public ITemplate getTemplate()
        {
            IResource s = getResource(RDF.PropertyType);

            if (s != null && s.isUri())
            {
                return(SPINModuleRegistry.getTemplate(s.Uri, s.getModel()));
            }
            else
            {
                return(null);
            }
        }
        public IResource getFunction()
        {
            // Need to iterate over rdf:types - some may have been inferred
            // Return the most specific type, i.e. the one that does not have
            // any subclasses
            IResource            type = null;
            IEnumerator <Triple> it   = listProperties(RDF.PropertyType).GetEnumerator();

            while (it.MoveNext())
            {
                Triple s = it.Current;
                if (s.Object is IUriNode)
                {
                    IResource candidate = Resource.Get(s.Object, getModel());
                    if (type == null)
                    {
                        type = candidate;
                    }
                    else if (!candidate.getModel().ContainsTriple(null, RDFS.PropertySubClassOf, candidate))
                    {
                        type = candidate;
                    }
                }
            }

            if (type != null)
            {
                if (type.hasProperty(RDFS.PropertySubClassOf, SPIN.ClassFunction))
                {
                    return(type);
                }
                else
                {
                    IResource global = SPINModuleRegistry.getFunction(type.Uri, null);
                    if (global != null)
                    {
                        return(global);
                    }
                    else
                    {
                        return(type);
                    }
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 /**
  * Checks whether a given INode can be cast into TemplateCall, and returns
  * it as a TemplateCall instance if so.
  * @param node  the node to convert
  * @return an instance of TemplateCall or null
  */
 public static ITemplateCall asTemplateCall(IResource resource)
 {
     if (resource == null)
     {
         return(null);
     }
     if (!resource.isLiteral())
     {
         IResource t = resource.getResource(RDF.PropertyType);
         if (t != null && t.isUri())
         {
             ITemplate template = SPINModuleRegistry.getTemplate(t.Uri, t.getModel());
             if (template != null)
             {
                 return((ITemplateCall)resource.As(typeof(TemplateCallImpl)));
             }
         }
     }
     return(null);
 }