Esempio n. 1
0
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (node is AndQueryNode)
            {
                this.childrenBuffer.Clear();
                IList <IQueryNode> children = node.GetChildren();

                foreach (IQueryNode child in children)
                {
                    this.childrenBuffer.Add(ApplyModifier(child, Modifier.MOD_REQ));
                }

                node.Set(this.childrenBuffer);
            }
            else if (this.usingAnd && node is BooleanQueryNode &&
                     !(node is OrQueryNode))
            {
                this.childrenBuffer.Clear();
                IList <IQueryNode> children = node.GetChildren();

                foreach (IQueryNode child in children)
                {
                    this.childrenBuffer.Add(ApplyModifier(child, Modifier.MOD_REQ));
                }

                node.Set(this.childrenBuffer);
            }

            return(node);
        }
Esempio n. 2
0
        /// <summary>
        /// This method is called every time a child is processed.
        /// </summary>
        /// <param name="queryTree">the query node child to be processed</param>
        /// <exception cref="QueryNodeException">if something goes wrong during the query node processing</exception>
        protected virtual void ProcessChildren(IQueryNode queryTree)
        {
            IList <IQueryNode> children = queryTree.GetChildren();
            ChildrenList       newChildren;

            if (children != null && children.Count > 0)
            {
                newChildren = AllocateChildrenList();

                try
                {
                    foreach (IQueryNode child in children)
                    {
                        var child2 = ProcessIteration(child);

                        if (child2 == null)
                        {
                            // LUCENENET: Changed from NullPointerException to InvalidOperationException (which isn't caught anywhere outside of tests)
                            throw IllegalStateException.Create($"{this.GetType().Name}.PostProcessNode() must not return 'null'.");
                        }

                        newChildren.Add(child2);
                    }

                    IList <IQueryNode> orderedChildrenList = SetChildrenOrder(newChildren);

                    queryTree.Set(orderedChildrenList);
                }
                finally
                {
                    newChildren.beingUsed = false;
                }
            }
        }
        /// <summary>
        /// This method is called every time a child is processed.
        /// </summary>
        /// <param name="queryTree">the query node child to be processed</param>
        /// <exception cref="QueryNodeException">if something goes wrong during the query node processing</exception>
        protected virtual void ProcessChildren(IQueryNode queryTree)
        {
            IList <IQueryNode> children = queryTree.GetChildren();
            ChildrenList       newChildren;

            if (children != null && children.Count > 0)
            {
                newChildren = AllocateChildrenList();

                try
                {
                    foreach (IQueryNode child in children)
                    {
                        var child2 = ProcessIteration(child);

                        if (child2 == null)
                        {
                            throw new NullReferenceException(); // LUCENENET TODO: Change to ArgumentException ?
                        }

                        newChildren.Add(child2);
                    }

                    IList <IQueryNode> orderedChildrenList = SetChildrenOrder(newChildren);

                    queryTree.Set(orderedChildrenList);
                }
                finally
                {
                    newChildren.beingUsed = false;
                }
            }
        }
Esempio n. 4
0
 protected virtual IQueryNode PostProcessNode(IQueryNode node)
 {
     if (node.ContainsTag(TAG_BOOLEAN_ROOT))
     {
         this.childrenBuffer.Clear();
         FillChildrenBufferAndApplyModifiery(node);
         node.Set(childrenBuffer);
     }
     return(node);
 }
Esempio n. 5
0
        public virtual IQueryNode Process(IQueryNode queryTree)
        {
            Operator?defaultOperator = GetQueryConfigHandler().Get(ConfigurationKeys.DEFAULT_OPERATOR);

            if (defaultOperator == null)
            {
                throw new ArgumentException(
                          "DEFAULT_OPERATOR should be set on the QueryConfigHandler");
            }

            this.usingAnd = Operator.AND == defaultOperator;

            if (queryTree is GroupQueryNode groupQueryNode)
            {
                queryTree = groupQueryNode.GetChild();
            }

            this.queryNodeList      = new List <IQueryNode>();
            this.latestNodeVerified = false;
            ReadTree(queryTree);

            List <IQueryNode> actualQueryNodeList = this.queryNodeList;

            for (int i = 0; i < actualQueryNodeList.Count; i++)
            {
                IQueryNode node = actualQueryNodeList[i];

                if (node is GroupQueryNode)
                {
                    actualQueryNodeList[i] = Process(node);
                }
            }

            this.usingAnd = false;

            if (queryTree is BooleanQueryNode)
            {
                queryTree.Set(actualQueryNodeList);

                return(queryTree);
            }
            else
            {
                return(new BooleanQueryNode(actualQueryNodeList));
            }
        }
        public virtual IQueryNode Process(IQueryNode queryTree)
        {
            Operator? defaultOperator = GetQueryConfigHandler().Get(ConfigurationKeys.DEFAULT_OPERATOR);

            if (defaultOperator == null)
            {
                throw new ArgumentException(
                    "DEFAULT_OPERATOR should be set on the QueryConfigHandler");
            }

            this.usingAnd = Operator.AND == defaultOperator;

            if (queryTree is GroupQueryNode)
            {
                queryTree = ((GroupQueryNode)queryTree).GetChild();
            }

            this.queryNodeList = new List<IQueryNode>();
            this.latestNodeVerified = false;
            ReadTree(queryTree);

            List<IQueryNode> actualQueryNodeList = this.queryNodeList;

            for (int i = 0; i < actualQueryNodeList.Count; i++)
            {
                IQueryNode node = actualQueryNodeList[i];

                if (node is GroupQueryNode)
                {
                    actualQueryNodeList[i] = Process(node);
                }
            }

            this.usingAnd = false;

            if (queryTree is BooleanQueryNode)
            {
                queryTree.Set(actualQueryNodeList);

                return queryTree;
            }
            else
            {
                return new BooleanQueryNode(actualQueryNodeList);
            }
        }
 protected virtual IQueryNode PostProcessNode(IQueryNode node)
 {
     if (node.ContainsTag(TAG_BOOLEAN_ROOT))
     {
         this.childrenBuffer.Clear();
         FillChildrenBufferAndApplyModifiery(node);
         node.Set(childrenBuffer);
     }
     return node;
 }