@Override
    public void endElement(String uri, String localName, String qName)
            throws SAXException {
        //==================
        // INLINE XML...
        //==================
        if (m_inXMLMetadata) {
            //=====================
            // AUDIT DATASTREAM...
            //=====================
            if (m_gotAudit) {
                // Pick up audit records from the current ds version
                // and instantiate audit records array in digital object.
                if (localName.equals("action")) {
                    m_auditAction = (m_elementContent != null) ?
                            m_elementContent.toString() : "";
                    //} else if (localName.equals("recordID")) {
                    //    m_auditRecordID=m_elementContent.toString();
                } else if (localName.equals("componentID")) {
                    m_auditComponentID = (m_elementContent != null) ?
                            m_elementContent.toString() : "";
                } else if (localName.equals("responsibility")) {
                    m_auditResponsibility = (m_elementContent != null) ?
                            m_elementContent.toString() : "";
                } else if (localName.equals("date")) {
                    m_auditDate = (m_elementContent != null) ?
                            m_elementContent.toString() : "";
                } else if (localName.equals("justification")) {
                    m_auditJustification = (m_elementContent != null) ?
                            m_elementContent.toString() : "";
                } else if (localName.equals("record")) {
                    //m_auditRec.id=m_auditRecordID;
                    m_auditRec.processType = m_auditProcessType;
                    m_auditRec.action = m_auditAction;
                    m_auditRec.componentID = m_auditComponentID;
                    m_auditRec.responsibility = m_auditResponsibility;
                    m_auditRec.date =
                            DateUtility.convertStringToDate(m_auditDate);
                    m_auditRec.justification = m_auditJustification;
                    // add the audit records to the digital object
                    m_obj.getAuditRecords().add(m_auditRec);
                    // reinit variables for next audit record
                    m_auditProcessType = "";
                    m_auditAction = "";
                    m_auditComponentID = "";
                    m_auditResponsibility = "";
                    m_auditDate = "";
                    m_auditJustification = "";
                } else if (localName.equals("auditTrail")) {
                    m_gotAudit = false;
                }
                // process end of xmlContent ONLY if it is NOT embedded within inline XML!
            } else if (uri.equals(FOXML.uri) && localName.equals("xmlContent")
                    && m_xmlDataLevel == 0) {
                //=====================
                // AUDIT DATASTREAM...
                //=====================
                if (m_dsId.equals("AUDIT")) {
                    // if we are in the inline XML of the AUDIT datastream just
                    // end processing and move on.  Audit datastream handled elsewhere.
                    m_inXMLMetadata = false; // other stuff is re-initted upon
                    // startElement for next xml metadata
                    // element
                    //========================
                    // ALL OTHER INLINE XML...
                    //========================
                } else {
                    // Create the right kind of datastream and add to the object
                    DatastreamXMLMetadata ds = new DatastreamXMLMetadata();
                    instantiateXMLDatastream(ds);
                    m_inXMLMetadata = false;
                    m_localPrefixMap.clear();
                }
            } else {
                // finished an element within inline xml metadata
                m_dsXMLBuffer.append("</").append(qName).append('>');
                // make sure we know when to pay attention to FOXML again
                if (uri.equals(FOXML.uri) && localName.equals("xmlContent")) {
                    m_xmlDataLevel--;
                }
            }
            //========================================
            // ALL OTHER ELEMENTS (NOT INLINE XML)...
            //========================================
        } else if (uri.equals(FOXML.uri) && localName.equals("binaryContent")) {
            if (m_binaryContentTempFile != null) {
                try {
                    FileOutputStream os =
                            new FileOutputStream(m_binaryContentTempFile);
                    // remove all spaces and newlines, this might not be necessary.
                    byte elementBytes[] = Base64.decode(m_elementContent.toInputStream());
                    os.write(elementBytes);
                    os.close();
                    m_dsLocationType = Datastream.DS_LOCATION_TYPE_INTERNAL;
                    m_dsLocation =
                        DatastreamManagedContent.TEMP_SCHEME
                                    + m_binaryContentTempFile.getAbsolutePath();
                    instantiateDatastream(new DatastreamManagedContent());
                } catch (FileNotFoundException fnfe) {
                    throw new SAXException(new StreamIOException("Unable to open temporary file created for binary content"));
                } catch (IOException fnfe) {
                    throw new SAXException(new StreamIOException("Error writing to temporary file created for binary content"));
                }
            }
            m_binaryContentTempFile = null;
            m_readingBinaryContent = false;
        } else if (uri.equals(FOXML.uri)
                && localName.equals("datastreamVersion")) {
            // reinitialize datastream version-level attributes...
            if (m_dsVersId.equals("AUDIT.0")) {
                m_gotAudit = false;
            }
            m_dsVersId = "";
            m_dsLabel = "";
            m_dsCreateDate = null;
            m_dsAltIds = EMPTY_STRING_ARRAY;
            m_dsFormatURI = "";
            m_dsMimeType = "";
            m_dsSize = -1;
            //m_dsAdmIds=new HashMap();
            //m_dsDmdIds=null;
        } else if (uri.equals(FOXML.uri) && localName.equals("datastream")) {
            // reinitialize datastream attributes ...
            m_dsId = "";
            m_dsVersionable = true;
            m_dsState = "";
            m_dsInfoType = "";
            m_dsOtherInfoType = "";
            m_dsMDClass = 0;
        } else if (m_format.equals(FOXML1_0)) {
            endDisseminators(uri, localName);
        }
    }
@ Override public void endElement ( String uri , String localName , String qName ) throws SAXException { if ( m_inXMLMetadata ) { if ( m_gotAudit ) { if ( localName . equals ( "action" ) ) { m_auditAction = ( m_elementContent != null ) ? m_elementContent . toString ( ) : "" ; } else if ( localName . equals ( "componentID" ) ) { m_auditComponentID = ( m_elementContent != null ) ? m_elementContent . toString ( ) : "" ; } else if ( localName . equals ( "responsibility" ) ) { m_auditResponsibility = ( m_elementContent != null ) ? m_elementContent . toString ( ) : "" ; } else if ( localName . equals ( "date" ) ) { m_auditDate = ( m_elementContent != null ) ? m_elementContent . toString ( ) : "" ; } else if ( localName . equals ( "justification" ) ) { m_auditJustification = ( m_elementContent != null ) ? m_elementContent . toString ( ) : "" ; } else if ( localName . equals ( "record" ) ) { m_auditRec . processType = m_auditProcessType ; m_auditRec . action = m_auditAction ; m_auditRec . componentID = m_auditComponentID ; m_auditRec . responsibility = m_auditResponsibility ; m_auditRec . date = DateUtility . convertStringToDate ( m_auditDate ) ; m_auditRec . justification = m_auditJustification ; m_obj . getAuditRecords ( ) . add ( m_auditRec ) ; m_auditProcessType = "" ; m_auditAction = "" ; m_auditComponentID = "" ; m_auditResponsibility = "" ; m_auditDate = "" ; m_auditJustification = "" ; } else if ( localName . equals ( "auditTrail" ) ) { m_gotAudit = false ; } } else if ( uri . equals ( FOXML . uri ) && localName . equals ( "xmlContent" ) && m_xmlDataLevel == 0 ) { if ( m_dsId . equals ( "AUDIT" ) ) { m_inXMLMetadata = false ; } else { DatastreamXMLMetadata ds = new DatastreamXMLMetadata ( ) ; instantiateXMLDatastream ( ds ) ; m_inXMLMetadata = false ; m_localPrefixMap . clear ( ) ; } } else { m_dsXMLBuffer . append ( "</" ) . append ( qName ) . append ( '>' ) ; if ( uri . equals ( FOXML . uri ) && localName . equals ( "xmlContent" ) ) { m_xmlDataLevel -- ; } } } else if ( uri . equals ( FOXML . uri ) && localName . equals ( "binaryContent" ) ) { if ( m_binaryContentTempFile != null ) { try { FileOutputStream os = new FileOutputStream ( m_binaryContentTempFile ) ; byte elementBytes [ ] = Base64 . decode ( m_elementContent . toInputStream ( ) ) ; os . write ( elementBytes ) ; os . close ( ) ; m_dsLocationType = Datastream . DS_LOCATION_TYPE_INTERNAL ; m_dsLocation = DatastreamManagedContent . TEMP_SCHEME + m_binaryContentTempFile . getAbsolutePath ( ) ; instantiateDatastream ( new DatastreamManagedContent ( ) ) ; } catch ( FileNotFoundException fnfe ) { throw new SAXException ( new StreamIOException ( "Unable to open temporary file created for binary content" ) ) ; } catch ( IOException fnfe ) { throw new SAXException ( new StreamIOException ( "Error writing to temporary file created for binary content" ) ) ; } } m_binaryContentTempFile = null ; m_readingBinaryContent = false ; } else if ( uri . equals ( FOXML . uri ) && localName . equals ( "datastreamVersion" ) ) { if ( m_dsVersId . equals ( "AUDIT.0" ) ) { m_gotAudit = false ; } m_dsVersId = "" ; m_dsLabel = "" ; m_dsCreateDate = null ; m_dsAltIds = EMPTY_STRING_ARRAY ; m_dsFormatURI = "" ; m_dsMimeType = "" ; m_dsSize = - 1 ; } else if ( uri . equals ( FOXML . uri ) && localName . equals ( "datastream" ) ) { m_dsId = "" ; m_dsVersionable = true ; m_dsState = "" ; m_dsInfoType = "" ; m_dsOtherInfoType = "" ; m_dsMDClass = 0 ; } else if ( m_format . equals ( FOXML1_0 ) ) { endDisseminators ( uri , localName ) ; } }
{@inheritDoc}