@ Override public void readFrom ( InputStream is ) throws IOException { this . currentItem = 0 ; // read from source and write into tempfile // open temp file depending on options compressed/encrypted OutputStream tempOS = null ; if ( ( this . ca != null ) || ( this . compressTempFile ) ) { tempOS = new FileOutputStream ( this . tempFile ) ; if ( this . ca != null ) { // encrypt file if configured tempOS = new CipherOutputStream ( tempOS , this . ciEncrypt ) ; } if ( this . compressTempFile ) { // compress file if configured tempOS = new GZIPOutputStream ( tempOS , EncryptedCachedDiskStringsTable . compressBufferSize ) ; } } else { // not encrypted and not compressed: configure a random access file for // writing/reading = highest performance this . tempRAF = new RandomAccessFile ( this . tempFile , "rw" ) ; } // read from source // use Stax event reader XMLEventReader xer = null ; try { xer = StaxHelper . newXMLInputFactory ( ) . createXMLEventReader ( this . originalIS ) ; while ( xer . hasNext ( ) ) { XMLEvent xe = xer . nextEvent ( ) ; // check if it is a string item (entry in string table) if ( xe . isStartElement ( ) && xe . asStartElement ( ) . getName ( ) . getLocalPart ( ) . equalsIgnoreCase ( "si" ) ) { String siText = this . parseSIText ( xer ) ; // add string to temp file this . addString ( siText , tempOS ) ; this . count ++ ; } } // close tempfile // make tempFile available as a reader } catch ( XMLStreamException e ) { LOG . error ( "Cannot read original SharedStringTable from document. Exception " + e ) ; throw new IOException ( e ) ; } catch ( FormatNotUnderstoodException e ) { LOG . error ( "Cannot read properly SharedStringTable from document. Exception " + e ) ; throw new IOException ( e ) ; } finally { // close temporary Stream (tempfile should be deleted using the close method of // this class and not here) if ( tempOS != null ) { tempOS . close ( ) ; } } // open the input stream towards the temp file this . accessTempFile ( 0L ) ; }
Reads from the original Excel document the string table and puts it into a compressed and encrypted file .