Exemple #1
0
        override public void Print(ISparqlPrinter p)
        {
            String name = getName();

            if (name.StartsWith("?"))
            {
                p.print("_:");
                p.print(name.Substring(1));
            }
            else
            {
                p.printVariable(name);
            }
        }
        override public void Print(ISparqlPrinter p)
        {
            p.printKeyword("SERVICE");
            IVariable var = getServiceVariable();

            if (var != null)
            {
                p.print(" ");
                p.printVariable(var.getName());
            }
            else
            {
                Uri uri = getServiceURI();
                if (uri != null)
                {
                    p.print(" ");
                    p.printURIResource(Resource.Get(RDFUtil.CreateUriNode(uri), getModel()));
                }
            }
            printNestedElementList(p);
        }
        override public void Print(ISparqlPrinter p)
        {
            p.printKeyword("VALUES");
            p.print(" ");
            List <String> varNames = getVarNames();

            if (varNames.Count == 1)
            {
                p.printVariable(varNames[0]);
            }
            else
            {
                p.print("(");
                IEnumerator <String> vit = varNames.GetEnumerator();
                while (vit.MoveNext())
                {
                    p.printVariable(vit.Current);
                    if (vit.MoveNext())
                    {
                        p.print(" ");
                    }
                }
                p.print(")");
            }
            p.print(" {");
            p.println();
            foreach (Dictionary <String, IResource> binding in getBindings())
            {
                p.printIndentation(p.getIndentation() + 1);
                if (varNames.Count != 1)
                {
                    p.print("(");
                }
                IEnumerator <String> vit = varNames.GetEnumerator();
                while (vit.MoveNext())
                {
                    String    varName = vit.Current;
                    IResource value   = binding[varName];
                    if (value == null)
                    {
                        p.printKeyword("UNDEF");
                    }
                    else if (value.isUri())
                    {
                        p.printURIResource(value);
                    }
                    else
                    {
                        TupleImpl.print(getModel(), Resource.Get(value, getModel()), p);
                    }
                    if (vit.MoveNext())
                    {
                        p.print(" ");
                    }
                }
                if (varNames.Count != 1)
                {
                    p.print(")");
                }
                p.println();
            }
            p.printIndentation(p.getIndentation());
            p.print("}");
        }