示例#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);
        }
示例#2
0
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (!node.IsLeaf)
            {
                IList <IQueryNode> children = node.GetChildren();
                bool removeBoolean          = false;

                if (children == null || children.Count == 0)
                {
                    removeBoolean = true;
                }
                else
                {
                    removeBoolean = true;

                    foreach (var child in children)
                    {
                        if (!(child is DeletedQueryNode))
                        {
                            removeBoolean = false;
                            break;
                        }
                    }
                }

                if (removeBoolean)
                {
                    return(new DeletedQueryNode());
                }
            }

            return(node);
        }
示例#3
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;
                }
            }
        }
示例#4
0
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (node is BooleanQueryNode)
            {
                IList <IQueryNode> children = node.GetChildren();

                if (children != null && children.Count == 1)
                {
                    IQueryNode child = children[0];

                    if (child is ModifierQueryNode modNode)
                    {
                        if (modNode is BooleanModifierNode ||
                            modNode.Modifier == Modifier.MOD_NONE)
                        {
                            return(child);
                        }
                    }
                    else
                    {
                        return(child);
                    }
                }
            }

            return(node);
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (!node.IsLeaf)
            {
                IList <IQueryNode> children = node.GetChildren();
                bool removeBoolean          = false;

                if (children == null || children.Count == 0)
                {
                    removeBoolean = true;
                }
                else
                {
                    removeBoolean = true;

                    for (IEnumerator <IQueryNode> it = children.GetEnumerator(); it.MoveNext();)
                    {
                        if (!(it.Current is DeletedQueryNode))
                        {
                            removeBoolean = false;
                            break;
                        }
                    }
                }

                if (removeBoolean)
                {
                    return(new DeletedQueryNode());
                }
            }

            return(node);
        }
        /// <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;
                }
            }
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (node is BooleanQueryNode)
            {
                IList<IQueryNode> children = node.GetChildren();

                if (children != null && children.Count == 1)
                {
                    IQueryNode child = children[0];

                    if (child is ModifierQueryNode)
                    {
                        ModifierQueryNode modNode = (ModifierQueryNode)child;

                        if (modNode is BooleanModifierNode
                            || modNode.Modifier == Modifier.MOD_NONE)
                        {
                            return child;
                        }
                    }
                    else
                    {
                        return child;
                    }
                }
            }

            return node;
        }
示例#8
0
        private void ReadTree(IQueryNode node)
        {
            if (node is BooleanQueryNode)
            {
                IList <IQueryNode> children = node.GetChildren();

                if (children != null && children.Count > 0)
                {
                    for (int i = 0; i < children.Count - 1; i++)
                    {
                        ReadTree(children[i]);
                    }

                    ProcessNode(node);
                    ReadTree(children[children.Count - 1]);
                }
                else
                {
                    ProcessNode(node);
                }
            }
            else
            {
                ProcessNode(node);
            }
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (!node.IsLeaf)
            {
                IList <IQueryNode> children = node.GetChildren();
                bool removeBoolean; // LUCENENET: IDE0059: Remove unnecessary value assignment

                if (children is null || children.Count == 0)
                {
                    removeBoolean = true;
                }
                else
                {
                    removeBoolean = true;

                    foreach (var child in children)
                    {
                        if (!(child is DeletedQueryNode))
                        {
                            removeBoolean = false;
                            break;
                        }
                    }
                }

                if (removeBoolean)
                {
                    return(new DeletedQueryNode());
                }
            }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (!node.IsLeaf)
            {
                IList<IQueryNode> children = node.GetChildren();
                bool removeBoolean = false;

                if (children == null || children.Count == 0)
                {
                    removeBoolean = true;
                }
                else
                {
                    removeBoolean = true;

                    for (IEnumerator<IQueryNode> it = children.GetEnumerator(); it.MoveNext();)
                    {

                        if (!(it.Current is DeletedQueryNode))
                        {
                            removeBoolean = false;
                            break;
                        }
                    }
                }

                if (removeBoolean)
                {
                    return new DeletedQueryNode();
                }
            }

            return node;
        }
 protected virtual void ProcessChildren(IQueryNode queryTree)
 {
     IList<IQueryNode> children = queryTree.GetChildren();
     if (children != null && children.Count > 0)
     {
         foreach (IQueryNode child in children)
         {
             /*child = */
             ProcessIteration(child);
         }
     }
 }
示例#12
0
        protected virtual void ProcessChildren(IQueryNode queryTree)
        {
            IList <IQueryNode> children = queryTree.GetChildren();

            if (children != null && children.Count > 0)
            {
                foreach (IQueryNode child in children)
                {
                    /*child = */
                    ProcessIteration(child);
                }
            }
        }
        public override IQueryNode Process(IQueryNode queryTree)
        {
            queryTree = base.Process(queryTree);

            if (!queryTree.IsLeaf)
            {
                IList<IQueryNode> children = queryTree.GetChildren();

                if (children == null || children.Count == 0)
                {
                    return new MatchNoDocsQueryNode();
                }
            }

            return queryTree;
        }
示例#14
0
        public override IQueryNode Process(IQueryNode queryTree)
        {
            queryTree = base.Process(queryTree);

            if (!queryTree.IsLeaf)
            {
                IList <IQueryNode> children = queryTree.GetChildren();

                if (children == null || children.Count == 0)
                {
                    return(new MatchNoDocsQueryNode());
                }
            }

            return(queryTree);
        }
示例#15
0
 protected virtual void FillChildrenBufferAndApplyModifiery(IQueryNode parent)
 {
     foreach (IQueryNode node in parent.GetChildren())
     {
         if (node.ContainsTag(TAG_REMOVE))
         {
             FillChildrenBufferAndApplyModifiery(node);
         }
         else if (node.ContainsTag(TAG_MODIFIER))
         {
             childrenBuffer.Add(ApplyModifier(node,
                                              (Modifier)node.GetTag(TAG_MODIFIER)));
         }
         else
         {
             childrenBuffer.Add(node);
         }
     }
 }
示例#16
0
        private void Process(IQueryNode node)
        {
            if (node != null)
            {
                IQueryBuilder <TQuery> builder = GetBuilder(node);

                if (!(builder is QueryTreeBuilder <TQuery>))
                {
                    IList <IQueryNode> children = node.GetChildren();

                    if (children != null)
                    {
                        foreach (IQueryNode child in children)
                        {
                            Process(child);
                        }
                    }
                }

                ProcessNode(node, builder);
            }
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (node is BooleanQueryNode || node is BoostQueryNode
                || node is TokenizedPhraseQueryNode
                || node is ModifierQueryNode)
            {
                IList<IQueryNode> children = node.GetChildren();

                if (children != null && children.Count > 0)
                {
                    foreach (IQueryNode child in children)
                    {
                        if (!(child is DeletedQueryNode))
                        {
                            return node;
                        }
                    }
                }

                return new MatchNoDocsQueryNode();
            }

            return node;
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (node is BooleanQueryNode || node is BoostQueryNode ||
                node is TokenizedPhraseQueryNode ||
                node is ModifierQueryNode)
            {
                IList <IQueryNode> children = node.GetChildren();

                if (children != null && children.Count > 0)
                {
                    foreach (IQueryNode child in children)
                    {
                        if (!(child is DeletedQueryNode))
                        {
                            return(node);
                        }
                    }
                }

                return(new MatchNoDocsQueryNode());
            }

            return(node);
        }
示例#19
0
        private void ReadTree(IQueryNode node)
        {
            if (node is BooleanQueryNode)
            {
                IList<IQueryNode> children = node.GetChildren();

                if (children != null && children.Count > 0)
                {
                    for (int i = 0; i < children.Count - 1; i++)
                    {
                        ReadTree(children[i]);
                    }

                    ProcessNode(node);
                    ReadTree(children[children.Count - 1]);
                }
                else
                {
                    ProcessNode(node);
                }
            }
            else
            {
                ProcessNode(node);
            }
        }
 protected virtual void FillChildrenBufferAndApplyModifiery(IQueryNode parent)
 {
     foreach (IQueryNode node in parent.GetChildren())
     {
         if (node.ContainsTag(TAG_REMOVE))
         {
             FillChildrenBufferAndApplyModifiery(node);
         }
         else if (node.ContainsTag(TAG_MODIFIER))
         {
             childrenBuffer.Add(ApplyModifier(node,
                 (Modifier)node.GetTag(TAG_MODIFIER)));
         }
         else
         {
             childrenBuffer.Add(node);
         }
     }
 }