public override AnyValue MapSequence(SequenceValue value)
            {
                IList <AnyValue> list = new List <AnyValue>(value.Length());

                value.forEach(v => list.Add(v.map(this)));
                return(VirtualValues.fromList(list));
            }
Example #2
0
            public static AnyValue Convert(IEnumerable <Notification> notifications)
            {
                IList <AnyValue> @out = new List <AnyValue>();

                foreach (Notification notification in notifications)
                {
                    InputPosition   pos             = notification.Position;                // position is optional
                    bool            includePosition = !pos.Equals(InputPosition.empty);
                    int             size            = includePosition ? 5 : 4;
                    MapValueBuilder builder         = new MapValueBuilder(size);

                    builder.Add("code", stringValue(notification.Code));
                    builder.Add("title", stringValue(notification.Title));
                    builder.Add("description", stringValue(notification.Description));
                    builder.Add("severity", stringValue(notification.Severity.ToString()));

                    if (includePosition)
                    {
                        // only add the position if it is not empty
                        builder.Add("position", VirtualValues.map(new string[] { "offset", "line", "column" }, new AnyValue[] { intValue(pos.Offset), intValue(pos.Line), intValue(pos.Column) }));
                    }

                    @out.Add(builder.Build());
                }
                return(VirtualValues.fromList(@out));
            }
        private static ListValue Children(ExecutionPlanDescription plan)
        {
            IList <AnyValue> children = new LinkedList <AnyValue>();

            foreach (ExecutionPlanDescription child in plan.Children)
            {
                children.Add(Convert(child));
            }
            return(VirtualValues.fromList(children));
        }
Example #4
0
        public override ListValue Split(string separator)
        {
            Debug.Assert(!string.ReferenceEquals(separator, null));
            string asString = Value();

            //Cypher has different semantics for the case where the separator
            //is exactly the value, in cypher we expect two empty arrays
            //where as java returns an empty array
            if (separator.Equals(asString))
            {
                return(EmptySplit);
            }
            else if (separator.Length == 0)
            {
                return(VirtualValues.fromArray(Values.CharArray(asString.ToCharArray())));
            }

            IList <AnyValue> split = SplitNonRegex(asString, separator);

            return(VirtualValues.fromList(split));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings({"unchecked", "WeakerAccess"}) public static org.neo4j.values.AnyValue materializeAnyResult(org.neo4j.kernel.impl.core.EmbeddedProxySPI proxySpi, Object anyValue)
        public static AnyValue MaterializeAnyResult(EmbeddedProxySPI proxySpi, object anyValue)
        {
            if (anyValue == null || anyValue == NO_VALUE)
            {
                return(NO_VALUE);
            }
            else if (anyValue is AnyValue)
            {
                return(MaterializeAnyValueResult(proxySpi, anyValue));
            }
            else if (anyValue is System.Collections.IList)
            {
                return(VirtualValues.fromList((IList <AnyValue>)(((System.Collections.IList)anyValue).Select(v => MaterializeAnyResult(proxySpi, v)).ToList())));
            }
            else if (anyValue is System.Collections.IDictionary)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<String,?> incoming = (java.util.Map<String,?>) anyValue;
                IDictionary <string, ?> incoming = (IDictionary <string, ?>)anyValue;
                MapValueBuilder         builder  = new MapValueBuilder(incoming.Count);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<String,?> entry : incoming.entrySet())
                foreach (KeyValuePair <string, ?> entry in incoming.SetOfKeyValuePairs())
                {
                    builder.Add(entry.Key, MaterializeAnyResult(proxySpi, entry.Value));
                }
                return(builder.Build());
            }
            else if (anyValue is PrimitiveNodeStream)
            {
                return(VirtualValues.fromList((( PrimitiveNodeStream )anyValue).LongStream().mapToObj(id => (AnyValue)ValueUtils.fromNodeProxy(proxySpi.NewNodeProxy(id))).collect(Collectors.toList())));
            }
            else if (anyValue is PrimitiveRelationshipStream)
            {
                return(VirtualValues.fromList((( PrimitiveRelationshipStream )anyValue).LongStream().mapToObj(id => (AnyValue)ValueUtils.fromRelationshipProxy(proxySpi.NewRelationshipProxy(id))).collect(Collectors.toList())));
            }
            else if (anyValue is LongStream)
            {
                long[] array = (( LongStream )anyValue).toArray();
                return(Values.longArray(array));
            }
            else if (anyValue is DoubleStream)
            {
                double[] array = (( DoubleStream )anyValue).toArray();
                return(Values.doubleArray(array));
            }
            else if (anyValue is IntStream)
            {
                // IntStream is only used for list of primitive booleans
                return(VirtualValues.fromList((( IntStream )anyValue).mapToObj(i => Values.booleanValue(i != 0)).collect(Collectors.toList())));
            }
            else if (anyValue.GetType().IsArray)
            {
                Type componentType = anyValue.GetType().GetElementType();
                int  length        = Array.getLength(anyValue);

                if (componentType.IsPrimitive)
                {
                    object copy = Array.CreateInstance(componentType, length);
                    //noinspection SuspiciousSystemArraycopy
                    Array.Copy(anyValue, 0, copy, 0, length);
                    return(ValueUtils.of(copy));
                }
                else if (anyValue is string[])
                {
                    return(Values.stringArray(( string[] )anyValue));
                }
                else
                {
                    AnyValue[] copy = new AnyValue[length];
                    for (int i = 0; i < length; i++)
                    {
                        copy[i] = MaterializeAnyResult(proxySpi, Array.get(anyValue, i));
                    }
                    return(VirtualValues.list(copy));
                }
            }
            else
            {
                return(ValueUtils.of(anyValue));
            }
        }