示例#1
0
 public static readonly ResultDataContent public static ResultDataContent[] fromNames(java.util.List <JavaToDotNetGenericWildcard> names)
 {
     if (names == null || names.isEmpty())
     {
         return(null);
     }
     ResultDataContent[] result = new ResultDataContent[names.size()]; java.util.Iterator <JavaToDotNetGenericWildcard> name = names.iterator(); for (int i = 0; i < result.length; i++)
     {
         Object contentName = name.next(); if (contentName instanceof String)
         {
             try { result[i] = valueOf((( String )contentName).toLowerCase()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid result data content specifier: " + contentName); }
         }
示例#2
0
        protected internal override Statement FetchNextOrNull()
        {
            try
            {
                if (_errors != null)
                {
                    return(null);
                }

                switch (_state)
                {
                case Org.Neo4j.Server.rest.transactional.StatementDeserializer.State.BeforeOuterArray:
                    if (!BeginsWithCorrectTokens())
                    {
                        return(null);
                    }
                    _state = State.InBody;
                    goto case IN_BODY;

                case Org.Neo4j.Server.rest.transactional.StatementDeserializer.State.InBody:
                    string statement = null;
                    IDictionary <string, object> parameters = null;
                    IList <object> resultsDataContents      = null;
                    bool           includeStats             = false;
                    JsonToken      tok;

                    while ((tok = _input.nextToken()) != null && tok != END_OBJECT)
                    {
                        if (tok == END_ARRAY)
                        {
                            // No more statements
                            _state = State.Finished;
                            return(null);
                        }

                        _input.nextValue();
                        string currentName = _input.CurrentName;
                        switch (currentName)
                        {
                        case "statement":
                            statement = _input.readValueAs(typeof(string));
                            break;

                        case "parameters":
                            parameters = ReadMap(_input);
                            break;

                        case "resultDataContents":
                            resultsDataContents = ReadArray(_input);
                            break;

                        case "includeStats":
                            includeStats = _input.BooleanValue;
                            break;

                        default:
                            DiscardValue(_input);
                            break;
                        }
                    }

                    if (string.ReferenceEquals(statement, null))
                    {
                        AddError(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, new DeserializationException("No statement provided.")));
                        return(null);
                    }
                    return(new Statement(statement, parameters == null ? _noParameters : parameters, includeStats, ResultDataContent.fromNames(resultsDataContents)));

                case Org.Neo4j.Server.rest.transactional.StatementDeserializer.State.Finished:
                    return(null);

                default:
                    break;
                }
                return(null);
            }
            catch (Exception e) when(e is JsonParseException || e is JsonMappingException)
            {
                AddError(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, new DeserializationException("Unable to deserialize request", e)));
                return(null);
            }
            catch (IOException e)
            {
                AddError(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_Network.CommunicationError, e));
                return(null);
            }
            catch (Exception e)
            {
                AddError(new Neo4jError(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError, e));
                return(null);
            }
        }