private boolean checkElement ( final StartElement mEvent ) throws TTIOException { assert mEvent != null ; boolean retVal = false ; // Matching element names? if ( mWtx . getNode ( ) . getKind ( ) == IConstants . ELEMENT && mWtx . getQNameOfCurrentNode ( ) . equals ( mEvent . getName ( ) ) ) { // Check if atts and namespaces are the same. final long nodeKey = mWtx . getNode ( ) . getDataKey ( ) ; // Check attributes. boolean foundAtts = false ; boolean hasAtts = false ; for ( final Iterator < ? > it = mEvent . getAttributes ( ) ; it . hasNext ( ) ; ) { hasAtts = true ; final Attribute attribute = ( Attribute ) it . next ( ) ; for ( int i = 0 , attCount = ( ( ElementNode ) mWtx . getNode ( ) ) . getAttributeCount ( ) ; i < attCount ; i ++ ) { mWtx . moveToAttribute ( i ) ; if ( attribute . getName ( ) . equals ( mWtx . getQNameOfCurrentNode ( ) ) && attribute . getValue ( ) . equals ( mWtx . getValueOfCurrentNode ( ) ) ) { foundAtts = true ; mWtx . moveTo ( nodeKey ) ; break ; } mWtx . moveTo ( nodeKey ) ; } if ( ! foundAtts ) { break ; } } if ( ! hasAtts && ( ( ElementNode ) mWtx . getNode ( ) ) . getAttributeCount ( ) == 0 ) { foundAtts = true ; } // Check namespaces. boolean foundNamesps = false ; boolean hasNamesps = false ; for ( final Iterator < ? > namespIt = mEvent . getNamespaces ( ) ; namespIt . hasNext ( ) ; ) { hasNamesps = true ; final Namespace namespace = ( Namespace ) namespIt . next ( ) ; for ( int i = 0 , namespCount = ( ( ElementNode ) mWtx . getNode ( ) ) . getNamespaceCount ( ) ; i < namespCount ; i ++ ) { mWtx . moveToNamespace ( i ) ; final ITreeNameData namenode = ( ITreeNameData ) mWtx . getNode ( ) ; if ( namespace . getNamespaceURI ( ) . equals ( mWtx . nameForKey ( namenode . getURIKey ( ) ) ) && namespace . getPrefix ( ) . equals ( mWtx . nameForKey ( namenode . getNameKey ( ) ) ) ) { foundNamesps = true ; mWtx . moveTo ( nodeKey ) ; break ; } mWtx . moveTo ( nodeKey ) ; } if ( ! foundNamesps ) { break ; } } if ( ! hasNamesps && ( ( ElementNode ) mWtx . getNode ( ) ) . getNamespaceCount ( ) == 0 ) { foundNamesps = true ; } // Check if atts and namespaces are the same. if ( foundAtts && foundNamesps ) { retVal = true ; } else { retVal = false ; } } return retVal ; }
Check if current element matches the element in the shreddered file .