public Range registerString ( BytecodeContext bc , String str ) throws IOException { boolean append = true ; if ( staticTextLocation == null ) { if ( bc . getPageSource ( ) == null ) return null ; PageSource ps = bc . getPageSource ( ) ; Mapping m = ps . getMapping ( ) ; staticTextLocation = m . getClassRootDirectory ( ) ; staticTextLocation . mkdirs ( ) ; staticTextLocation = staticTextLocation . getRealResource ( ps . getClassName ( ) . replace ( ' ' , ' ' ) + ".txt" ) ; if ( staticTextLocation . exists ( ) ) append = false ; else staticTextLocation . createFile ( true ) ; off = 0 ; } IOUtil . write ( staticTextLocation , str , CharsetUtil . UTF8 , append ) ; Range r = new Range ( off , str . length ( ) ) ; off += str . length ( ) ; return r ; }
return null if not possible to register