Poll() protected method

protected Poll ( ) : StackKeeper
return StackKeeper
コード例 #1
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.pipeline.IPipeline#close(com.itextpdf.tool
         * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
        {
            HtmlPipelineContext hcc = (HtmlPipelineContext)GetLocalContext(context);
            ITagProcessor       tp;

            try {
                if (t.LastMarginBottom != null)
                {
                    hcc.GetMemory()[HtmlPipelineContext.LAST_MARGIN_BOTTOM] = t.LastMarginBottom;
                }
                else
                {
                    hcc.GetMemory().Remove(HtmlPipelineContext.LAST_MARGIN_BOTTOM);
                }
                tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
                IList <IElement> elems = null;
                if (tp.IsStackOwner())
                {
                    // remove the element from the StackKeeper Queue if end tag is
                    // found
                    StackKeeper tagStack;
                    try {
                        tagStack = hcc.Poll();
                    } catch (NoStackException e) {
                        throw new PipelineException(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.STACK_404), t.ToString()), e);
                    }
                    elems = tp.EndElement(context, t, tagStack.GetElements());
                }
                else
                {
                    elems = tp.EndElement(context, t, hcc.CurrentContent());
                    hcc.CurrentContent().Clear();
                }
                if (elems.Count > 0)
                {
                    StackKeeper stack = hcc.Peek();

                    if (stack != null)
                    {
                        foreach (IElement elem in elems)
                        {
                            stack.Add(elem);
                        }
                    }
                    else
                    {
                        WritableElement writableElement = new WritableElement();
                        po.Add(writableElement);
                        writableElement.AddAll(elems);
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }