/*
@see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
358930
@Override
    public void endElement(String uri, String localName, String qName) throws SAXException {

        // <context-param>
        if (elements("web-app", "context-param")) {
            if (currentName != null && currentValue != null) {
                entries.put(currentName, currentValue);
            }
        }

        // remove the element from the stack
        String removedName = stack.pop();

        // check if the removed name is the expected one
        if (!removedName.equals(localName)) {
            throw new IllegalStateException("Found '" + removedName + "' but expected '" + localName + "' on the stack!");
        }

    }
921568
public void endDocument() throws SAXException
  {

    if (DEBUG)
      System.out.println("TransformerHandlerImpl#endDocument");

    m_insideParse = false;
    
    if (m_contentHandler != null)
    {
      m_contentHandler.endDocument();
    }
    
    if(m_incremental)
    {
      m_transformer.waitTransformThread();
    }
    else
    {
      m_transformer.setSourceTreeDocForThread(m_dtm.getDocument());
      m_transformer.run();
    }
   /* Thread transformThread = m_transformer.getTransformThread();

    if (null != transformThread)
    {
      try
      {

        // This should wait until the transformThread is considered not alive.
        transformThread.join();

        if (!m_transformer.hasTransformThreadErrorCatcher())
        {
          Exception e = m_transformer.getExceptionThrown();

          if (null != e)
            throw new org.xml.sax.SAXException(e);
        }

        m_transformer.setTransformThread(null);
      }
      catch (InterruptedException ie){}
    }*/
  }
34284
public TypeUsage.Builder end(int end) {
    this.end = end;
    _unsetProperties.remove(Property.END);
    return (TypeUsage.Builder) this;
  }
1035208
@Override
    public void endElement( String uri, String localName, String qName )
        throws SAXException
    {
        flushCharacters();
        if ( stack.isEmpty() )
        {
            throw new IllegalStateException( "Stack must not be empty when closing the element " + qName
                + " around line " + locator.getLineNumber() + " and column " + locator.getColumnNumber() );
        }
        IndentCheckSaxHandler.ElementEntry startEntry = stack.pop();
        int indentDiff = lastIndent.size - startEntry.expectedIndent.size;
        int expectedIndent = startEntry.expectedIndent.size;
        if ( lastIndent.lineNumber != startEntry.foundIndent.lineNumber && indentDiff != 0 )
        {
            /*
             * diff should be zero unless we are on the same line as start element
             */
            int opValue = expectedIndent - lastIndent.size;
            String op = opValue > 0 ? "Insert" : "Delete";
            String units = opValue == 1 ? "space" : "spaces";
            String message = op + " " + Math.abs( opValue ) + " " + units + ". Expected " + expectedIndent + " found "
                + lastIndent.size + " spaces before end element </" + qName + ">";
            XmlFormatViolation violation =
                new XmlFormatViolation( file, locator.getLineNumber(), locator.getColumnNumber(), message );
            violationHandler.handle( violation );
        }
    }
311007
@Override
    public void endElement(String uri, String name, String qName) {
	setContent(content.toString().trim());
	content = new StringBuilder();
	inside = "";
	if (qName.equals("function")) endFunction();
	else if (qName.equals("argument")) endArg();
	else if (qName.equals("return")) endReturn();
	else if (qName.equals("bundle")) endBundle();

    }
613312
public final void endElement(
        final String namespaceURI,
        final String localName,
        final String name)
        throws org.xml.sax.SAXException
    {
        // deal with any pending issues
        if (m_cdataTagOpen)
            closeCDATA();

        // if the element has a namespace, treat it like XML, not HTML
        if (null != namespaceURI && namespaceURI.length() > 0)
        {
            super.endElement(namespaceURI, localName, name);

            return;
        }

        try
        {

            ElemContext elemContext = m_elemContext;
            final ElemDesc elemDesc = elemContext.m_elementDesc;
            final int elemFlags = elemDesc.getFlags();
            final boolean elemEmpty = (elemFlags & ElemDesc.EMPTY) != 0;

            // deal with any indentation issues
            if (m_doIndent)
            {
                final boolean isBlockElement = (elemFlags&ElemDesc.BLOCK) != 0;
                boolean shouldIndent = false;

                if (m_ispreserve)
                {
                    m_ispreserve = false;
                }
                else if (m_doIndent && (!m_inBlockElem || isBlockElement))
                {
                    m_startNewLine = true;
                    shouldIndent = true;
                }
                if (!elemContext.m_startTagOpen && shouldIndent)
                    indent(elemContext.m_currentElemDepth - 1);
                m_inBlockElem = !isBlockElement;
            }

            final java.io.Writer writer = m_writer;
            if (!elemContext.m_startTagOpen)
            {
                writer.write("</");
                writer.write(name);
                writer.write('>');
            }
            else
            {
                // the start-tag open when this method was called,
                // so we need to process it now.
                
                if (m_tracer != null)
                    super.fireStartElem(name);

                // the starting tag was still open when we received this endElement() call
                // so we need to process any gathered attributes NOW, before they go away.
                int nAttrs = m_attributes.getLength();
                if (nAttrs > 0)
                {
                    processAttributes(m_writer, nAttrs);
                    // clear attributes object for re-use with next element
                    m_attributes.clear();
                }
                if (!elemEmpty)
                {
                    // As per Dave/Paul recommendation 12/06/2000
                    // if (shouldIndent)
                    // writer.write('>');
                    //  indent(m_currentIndent);

                    writer.write("></");
                    writer.write(name);
                    writer.write('>');
                }
                else
                {
                    writer.write('>');
                }
            }
            
            // clean up because the element has ended
            if ((elemFlags & ElemDesc.WHITESPACESENSITIVE) != 0)
                m_ispreserve = true;
            m_isprevtext = false;

            // fire off the end element event
            if (m_tracer != null)
                super.fireEndElem(name);            
                           
            // OPTIMIZE-EMPTY                
            if (elemEmpty)
            {
                // a quick exit if the HTML element had no children.
                // This block of code can be removed if the corresponding block of code
                // in startElement() also labeled with "OPTIMIZE-EMPTY" is also removed
                m_elemContext = elemContext.m_prev;
                return;
            }

            // some more clean because the element has ended. 
            if (!elemContext.m_startTagOpen)
            {
                if (m_doIndent && !m_preserves.isEmpty())
                    m_preserves.pop();
            }
            m_elemContext = elemContext.m_prev;
//            m_isRawStack.pop();
        }
        catch (IOException e)
        {
            throw new SAXException(e);
        }
    }
79843
public void endElement(String namespaceURI, String localName,
                           String qName) throws SAXException {
        trace("endElement:" + localName + "~" + qName);
        if (currentElement==null) {
            warn(qName + ": endElement before any startElement");
            return;
        }

        Node parentNode;
        boolean atDocumentRoot = false, foundTagToEnd = false;
        Element startElement = currentElement;

        while (!(foundTagToEnd || atDocumentRoot)) {
            parentNode = currentElement.getParentNode();

            if (parentNode.getNodeType()==Node.ELEMENT_NODE) {
                foundTagToEnd = isElementMatching(currentElement, qName);
                currentElement = (Element) parentNode;
            } else if (parentNode.getNodeType()==Node.DOCUMENT_NODE) {
                atDocumentRoot = true;
                if (startElement==currentDocument.getDocumentElement()) {
                    foundTagToEnd = isElementMatching(startElement, qName);
                } else {
                    currentElement = startElement;
                }
            } else {
                throw new IllegalArgumentException("Closing element " + qName
                                                   + ": expecting a parent ELEMENT_NODE but found " + parentNode);
            }
        }
        if (!foundTagToEnd) {
            warn(qName + ": endElement does not match startElement!");
        }
    }
490401
public void endDocument() throws org.xml.sax.SAXException
  {

    try
    {
      if (null != getStylesheetRoot())
      {
        if (0 == m_stylesheetLevel)
          getStylesheetRoot().recompose();        
      }
      else
        throw new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_STYLESHEETROOT, null)); //"Did not find the stylesheet root!");

      XSLTElementProcessor elemProcessor = getCurrentProcessor();

      if (null != elemProcessor)
        elemProcessor.startNonText(this);

      m_stylesheetLevel--;			
      
      popSpaceHandling();

      // WARNING: This test works only as long as stylesheets are parsed
      // more or less recursively. If we switch to an iterative "work-list"
      // model, this will become true prematurely. In that case,
      // isStylesheetParsingComplete() will have to be adjusted to be aware
      // of the worklist.
      m_parsingComplete = (m_stylesheetLevel < 0);
    }
    catch (TransformerException te)
    {
      throw new org.xml.sax.SAXException(te);
    }
  }
123777
@Override
    public void endElement(CMLStack xpath, String uri, String name, String raw) {
        if (name.equals("molecule")) {
            //			System.out.println("Ending element mdmolecule");
            // add chargeGroup, and then delete them
            if (currentChargeGroup != null) {
                if (currentMolecule instanceof MDMolecule) {
                    ((MDMolecule) currentMolecule).addChargeGroup(currentChargeGroup);
                } else {
                    logger.error("Need to store a charge group, but the current molecule is not a MDMolecule!");
                }
                currentChargeGroup = null;
            } else

            // add chargeGroup, and then delete them
            if (currentResidue != null) {
                if (currentMolecule instanceof MDMolecule) {
                    ((MDMolecule) currentMolecule).addResidue(currentResidue);
                } else {
                    logger.error("Need to store a residue group, but the current molecule is not a MDMolecule!");
                }
                currentResidue = null;
            } else {
                //				System.out.println("OK, that was the last end mdmolecule");
                super.endElement(xpath, uri, name, raw);
            }
        } else if ("atomArray".equals(name)) {
            if (xpath.length() == 2 && xpath.endsWith("molecule", "atomArray")) {
                storeAtomData();
                newAtomData();
            } else if (xpath.length() > 2 && xpath.endsWith("cml", "molecule", "atomArray")) {
                storeAtomData();
                newAtomData();
            }
        } else if ("bondArray".equals(name)) {
            if (xpath.length() == 2 && xpath.endsWith("molecule", "bondArray")) {
                storeBondData();
                newBondData();
            } else if (xpath.length() > 2 && xpath.endsWith("cml", "molecule", "bondArray")) {
                storeBondData();
                newBondData();
            }
        } else if ("scalar".equals(name)) {
            //Residue number
            if ("md:resNumber".equals(DICTREF)) {
                int myInt = Integer.parseInt(currentChars);
                currentResidue.setNumber(myInt);
            }
            //ChargeGroup number
            else if ("md:cgNumber".equals(DICTREF)) {
                int myInt = Integer.parseInt(currentChars);
                currentChargeGroup.setNumber(myInt);
            }
        } else {
            super.endElement(xpath, uri, name, raw);
        }
    }
880848
public void endElement(String uri, String lname, String name) {
        // System.err.println("End: " + name);
    	name = name.toLowerCase();
        if (ElementTags.PARAGRAPH.equals(name)) {
            try {
                document.add((Element) stack.pop());
                return;
            } catch (DocumentException e) {
                throw new ExceptionConverter(e);
            }
        }
        if (HtmlTagMap.isHead(name)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isTitle(name)) {
            if (currentChunk != null) {
                bodyAttributes.put(ElementTags.TITLE, currentChunk.getContent());
            }
            return;
        }
        if (HtmlTagMap.isMeta(name)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isLink(name)) {
            // we do nothing
            return;
        }
        if (HtmlTagMap.isBody(name)) {
            // we do nothing
            return;
        }
        if (myTags.containsKey(name)) {
            XmlPeer peer = (XmlPeer) myTags.get(name);
            if (ElementTags.TABLE.equals(peer.getTag())) {
                tableBorder = false;
            }
            super.handleEndingTags(peer.getTag());
            return;
        }
        // super.handleEndingTags is replaced with handleEndingTags
        // suggestion by Ken Auer
        handleEndingTags(name);
    }
66746
def end_element(self, name):
        """"""
        self.in_tag = False
        if name == self.tag:
            self.add_url()
1213876
@Override
    public void endElement(String uri, String name, String qName) {
	setContent(content.toString().trim());
	content = new StringBuffer();
	inside = "";
	/*
	 * if(tag!=null && tag.getName().equalsIgnoreCase("input")) {
	 * print.ln(tag.getName()+"-"+att.getName()+":"+inside+"-"+insideTag+"-"+insideAtt);
	 * 
	 * }
	 */
	if (qName.equals("tag")) endTag();
	else if (qName.equals("attribute")) endAtt();
	else if (qName.equals("script")) endScript();

    }
450074
protected void endNode(int node) throws org.xml.sax.SAXException
  {
    super.endNode(node);
    if(DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
    {
      m_transformer.getXPathContext().popCurrentNode();
    }
  }
349248
public int validateEndElement()
        throws XMLStreamException
    {
        if (mValidator == null) { // should never be null if we get here
            return XMLValidator.CONTENT_ALLOW_ANY_TEXT;
        }
        int result =  mValidator.validateElementEnd
            (mCurrElement.mLocalName, mCurrElement.mNamespaceURI, mCurrElement.mPrefix);
        if (mDepth == 1) { // root closing
            mValidator.validationCompleted(true);
        }
        return result;
    }
1105349
public void writeEndElement() throws SAXException {
        processStartElement();
        final QName qName = elementStack.remove(); // pop
        transformer.endElement(qName.uri, qName.localName, qName.qName);
        for (final NamespaceMapping p: qName.mappings) {
            if (p.newMapping) {
                transformer.endPrefixMapping(p.prefix);
            }
        }
    }
449651
public void endElement(String namespaceURI, String localName, String qName)
        throws SAXException
    {
        if (m_firstTagNotEmitted)
        {
            flush();
            if (namespaceURI == null && m_firstElementURI != null)
                namespaceURI = m_firstElementURI;


            if (localName == null && m_firstElementLocalName != null)
                localName = m_firstElementLocalName;
        }
        
        m_handler.endElement(namespaceURI, localName, qName);
    }
1118791
public final void mEND() throws RecognitionException {
		try {
			int _type = END;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// hql.g:24:5: ( 'end' )
			// hql.g:24:7: 'end'
			{
			match("end"); if (state.failed) return;

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}