public static Node cloneNode ( Node node ) { if ( node == null ) { return null ; } IIOMetadataNode newNode = new IIOMetadataNode ( node . getNodeName ( ) ) ; //clone user object if ( node instanceof IIOMetadataNode ) { IIOMetadataNode iioNode = ( IIOMetadataNode ) node ; Object obj = iioNode . getUserObject ( ) ; if ( obj instanceof byte [ ] ) { byte [ ] copyBytes = ( ( byte [ ] ) obj ) . clone ( ) ; newNode . setUserObject ( copyBytes ) ; } } //clone attributes NamedNodeMap attrs = node . getAttributes ( ) ; for ( int i = 0 ; i < attrs . getLength ( ) ; i ++ ) { Node attr = attrs . item ( i ) ; newNode . setAttribute ( attr . getNodeName ( ) , attr . getNodeValue ( ) ) ; } //clone children NodeList children = node . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node child = children . item ( i ) ; newNode . appendChild ( cloneNode ( child ) ) ; } return newNode ; }
Currently only use by GIFStreamMetadata and GIFImageMetadata