Input: Applies proxetta on bean class before bean registration . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) @ Override protected < T > BeanDefinition < T > createBeanDefinitionForRegistration ( final String name , Class < T > type , final Scope scope , final WiringMode wiringMode , final Consumer < T > consumer ) { if ( proxetta != null ) { final Class originalType = type ; final ProxettaFactory builder = proxetta . proxy ( ) ; builder . setTarget ( type ) ; type = builder . define ( ) ; return new ProxettaBeanDefinition ( name , type , scope , wiringMode , originalType , proxetta . getAspects ( new ProxyAspect [ 0 ] ) , consumer ) ; } return super . createBeanDefinitionForRegistration ( name , type , scope , wiringMode , consumer ) ; }


Input: Converter JTX transaction mode to DB transaction mode . [CODESPLIT] public static DbTransactionMode convertToDbMode ( final JtxTransactionMode txMode ) { final int isolation ; switch ( txMode . getIsolationLevel ( ) ) { case ISOLATION_DEFAULT : isolation = DbTransactionMode . ISOLATION_DEFAULT ; break ; case ISOLATION_NONE : isolation = DbTransactionMode . ISOLATION_NONE ; break ; case ISOLATION_READ_COMMITTED : isolation = DbTransactionMode . ISOLATION_READ_COMMITTED ; break ; case ISOLATION_READ_UNCOMMITTED : isolation = DbTransactionMode . ISOLATION_READ_UNCOMMITTED ; break ; case ISOLATION_REPEATABLE_READ : isolation = DbTransactionMode . ISOLATION_REPEATABLE_READ ; break ; case ISOLATION_SERIALIZABLE : isolation = DbTransactionMode . ISOLATION_SERIALIZABLE ; break ; default : throw new IllegalArgumentException ( ) ; } return new DbTransactionMode ( isolation , txMode . isReadOnly ( ) ) ; }


Input: { [CODESPLIT] @ Override public Character get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { if ( TypesUtil . isIntegerType ( dbSqlType ) ) { return Character . valueOf ( ( char ) rs . getInt ( index ) ) ; } String s = rs . getString ( index ) ; if ( s == null ) { return null ; } if ( s . length ( ) > 1 ) { throw new DbSqlException ( "Char column size too long, should be 1" ) ; } return Character . valueOf ( s . charAt ( 0 ) ) ; }


Input: { [CODESPLIT] @ Override public void set ( final PreparedStatement st , final int index , final Character value , final int dbSqlType ) throws SQLException { if ( TypesUtil . isIntegerType ( dbSqlType ) ) { st . setInt ( index , value . charValue ( ) ) ; return ; } st . setString ( index , value . toString ( ) ) ; }


Input: Reads property value and { [CODESPLIT] @ Override protected final void onSerializableProperty ( String propertyName , final PropertyDescriptor propertyDescriptor ) { final Object value ; if ( propertyDescriptor == null ) { // metadata - classname value = source . getClass ( ) . getName ( ) ; } else { value = readProperty ( source , propertyDescriptor ) ; if ( ( value == null ) && jsonContext . isExcludeNulls ( ) ) { return ; } // change name for properties propertyName = typeData . resolveJsonName ( propertyName ) ; } onSerializableProperty ( propertyName , propertyDescriptor == null ? null : propertyDescriptor . getType ( ) , value ) ; }


Input: Invoked on serializable properties that have passed all the rules . Property type is <code > null< / code > for metadata class name property . [CODESPLIT] protected void onSerializableProperty ( final String propertyName , final Class propertyType , final Object value ) { jsonContext . pushName ( propertyName , count > 0 ) ; jsonContext . serialize ( value ) ; if ( jsonContext . isNamePopped ( ) ) { count ++ ; } }


Input: Reads property using property descriptor . [CODESPLIT] private Object readProperty ( final Object source , final PropertyDescriptor propertyDescriptor ) { Getter getter = propertyDescriptor . getGetter ( declared ) ; if ( getter != null ) { try { return getter . invokeGetter ( source ) ; } catch ( Exception ex ) { throw new JsonException ( ex ) ; } } return null ; }


Input: Returns <code > true< / code > if first argument contains provided element . It works for strings collections maps and arrays . s [CODESPLIT] public static boolean containsElement ( final Object obj , final Object element ) { if ( obj == null ) { return false ; } if ( obj instanceof String ) { if ( element == null ) { return false ; } return ( ( String ) obj ) . contains ( element . toString ( ) ) ; } if ( obj instanceof Collection ) { return ( ( Collection ) obj ) . contains ( element ) ; } if ( obj instanceof Map ) { return ( ( Map ) obj ) . values ( ) . contains ( element ) ; } if ( obj instanceof Iterator ) { Iterator iter = ( Iterator ) obj ; while ( iter . hasNext ( ) ) { Object o = iter . next ( ) ; if ( equals ( o , element ) ) { return true ; } } return false ; } if ( obj instanceof Enumeration ) { Enumeration enumeration = ( Enumeration ) obj ; while ( enumeration . hasMoreElements ( ) ) { Object o = enumeration . nextElement ( ) ; if ( equals ( o , element ) ) { return true ; } } return false ; } if ( obj . getClass ( ) . isArray ( ) ) { int len = Array . getLength ( obj ) ; for ( int i = 0 ; i < len ; i ++ ) { Object o = Array . get ( obj , i ) ; if ( equals ( o , element ) ) { return true ; } } } return false ; }


Input: Creates EML string from given { @link Email } . [CODESPLIT] public String compose ( final Email email ) { if ( getSession ( ) == null ) { createSession ( getProperties ( ) ) ; } final OutputStreamTransport ost = new OutputStreamTransport ( getSession ( ) ) ; final SendMailSession sendMailSession = new SendMailSession ( getSession ( ) , ost ) ; sendMailSession . sendMail ( email ) ; return ost . getEml ( ) ; }


Input: Creates EML string from given { @link ReceivedEmail } . [CODESPLIT] public String compose ( final ReceivedEmail receivedEmail ) { Message msg = receivedEmail . originalMessage ( ) ; final ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; try { msg . writeTo ( outputStream ) ; } catch ( IOException | MessagingException e ) { throw new MailException ( e ) ; } return outputStream . toString ( ) ; }


Input: Appends another fast buffer to this one . [CODESPLIT] public FastDoubleBuffer append ( final FastDoubleBuffer buff ) { if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ; }


Input: Rehashes the contents of this map into a new <code > IntHashMap< / code > instance with a larger capacity . This method is called automatically when the number of keys in this map exceeds its capacity and load factor . [CODESPLIT] private void rehash ( ) { int oldCapacity = table . length ; Entry [ ] oldMap = table ; int newCapacity = ( oldCapacity << 1 ) + 1 ; Entry [ ] newMap = new Entry [ newCapacity ] ; modCount ++ ; threshold = ( int ) ( newCapacity * loadFactor ) ; table = newMap ; for ( int i = oldCapacity ; i -- > 0 ; ) { for ( Entry old = oldMap [ i ] ; old != null ; ) { Entry e = old ; old = old . next ; int index = ( e . key & 0x7FFFFFFF ) % newCapacity ; e . next = newMap [ index ] ; newMap [ index ] = e ; } } }


Input: Associates the specified value with the specified key in this map . If the map previously contained a mapping for this key the old value is replaced . [CODESPLIT] public Object put ( final int key , final Object value ) { // makes sure the key is not already in the IntHashMap. Entry [ ] tab = table ; int index = ( key & 0x7FFFFFFF ) % tab . length ; for ( Entry e = tab [ index ] ; e != null ; e = e . next ) { if ( e . key == key ) { Object old = e . value ; e . value = value ; return old ; } } modCount ++ ; if ( count >= threshold ) { // rehash the table if the threshold is exceeded rehash ( ) ; tab = table ; index = ( key & 0x7FFFFFFF ) % tab . length ; } // creates the new entry. tab [ index ] = new Entry ( key , value , tab [ index ] ) ; count ++ ; return null ; }


Input: Copies all of the mappings from the specified map to this one . These mappings replace any mappings that this map had for any of the keys currently in the specified Map . [CODESPLIT] @ Override public void putAll ( final Map t ) { for ( Object o : t . entrySet ( ) ) { Map . Entry e = ( Map . Entry ) o ; put ( e . getKey ( ) , e . getValue ( ) ) ; } }


Input: Removes all mappings from this map . [CODESPLIT] @ Override public void clear ( ) { Entry [ ] tab = table ; modCount ++ ; for ( int index = tab . length ; -- index >= 0 ; ) { tab [ index ] = null ; } count = 0 ; }


Input: Appends another fast buffer to this one . [CODESPLIT] public FastLongBuffer append ( final FastLongBuffer buff ) { if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ; }


Input: Creates { [CODESPLIT] public long [ ] toArray ( final int start , final int len ) { final long [ ] array = new long [ len ] ; if ( len == 0 ) { return array ; } System . arraycopy ( buffer , start , array , 0 , len ) ; return array ; }


Input: Appends string content to buffer . [CODESPLIT] public Buffer append ( final String string ) { ensureLast ( ) ; try { byte [ ] bytes = string . getBytes ( StringPool . ISO_8859_1 ) ; last . append ( bytes ) ; size += bytes . length ; } catch ( UnsupportedEncodingException ignore ) { } return this ; }


Input: Appends { [CODESPLIT] public Buffer append ( final Uploadable uploadable ) { list . add ( uploadable ) ; size += uploadable . getSize ( ) ; last = null ; return this ; }


Input: Appends other buffer to this one . [CODESPLIT] public Buffer append ( final Buffer buffer ) { if ( buffer . list . isEmpty ( ) ) { // nothing to append return buffer ; } list . addAll ( buffer . list ) ; last = buffer . last ; size += buffer . size ; return this ; }


Input: Writes content to the writer . [CODESPLIT] public void writeTo ( final Writer writer ) throws IOException { for ( Object o : list ) { if ( o instanceof FastByteBuffer ) { FastByteBuffer fastByteBuffer = ( FastByteBuffer ) o ; byte [ ] array = fastByteBuffer . toArray ( ) ; writer . write ( new String ( array , StringPool . ISO_8859_1 ) ) ; } else if ( o instanceof Uploadable ) { Uploadable uploadable = ( Uploadable ) o ; InputStream inputStream = uploadable . openInputStream ( ) ; try { StreamUtil . copy ( inputStream , writer , StringPool . ISO_8859_1 ) ; } finally { StreamUtil . close ( inputStream ) ; } } } }


Input: Writes content to the output stream . [CODESPLIT] public void writeTo ( final OutputStream out ) throws IOException { for ( Object o : list ) { if ( o instanceof FastByteBuffer ) { FastByteBuffer fastByteBuffer = ( FastByteBuffer ) o ; out . write ( fastByteBuffer . toArray ( ) ) ; } else if ( o instanceof Uploadable ) { Uploadable uploadable = ( Uploadable ) o ; InputStream inputStream = uploadable . openInputStream ( ) ; try { StreamUtil . copy ( inputStream , out ) ; } finally { StreamUtil . close ( inputStream ) ; } } } }


Input: Writes content to the output stream using progress listener to track the sending progress . [CODESPLIT] public void writeTo ( final OutputStream out , final HttpProgressListener progressListener ) throws IOException { // start final int size = size ( ) ; final int callbackSize = progressListener . callbackSize ( size ) ; int count = 0 ; // total count int step = 0 ; // step is offset in current chunk progressListener . transferred ( count ) ; // loop for ( Object o : list ) { if ( o instanceof FastByteBuffer ) { FastByteBuffer fastByteBuffer = ( FastByteBuffer ) o ; byte [ ] bytes = fastByteBuffer . toArray ( ) ; int offset = 0 ; while ( offset < bytes . length ) { // calc the remaining sending chunk size int chunk = callbackSize - step ; // check if this chunk size fits the bytes array if ( offset + chunk > bytes . length ) { chunk = bytes . length - offset ; } // writes the chunk out . write ( bytes , offset , chunk ) ; offset += chunk ; step += chunk ; count += chunk ; // listener if ( step >= callbackSize ) { progressListener . transferred ( count ) ; step -= callbackSize ; } } } else if ( o instanceof Uploadable ) { Uploadable uploadable = ( Uploadable ) o ; InputStream inputStream = uploadable . openInputStream ( ) ; int remaining = uploadable . getSize ( ) ; try { while ( remaining > 0 ) { // calc the remaining sending chunk size int chunk = callbackSize - step ; // check if this chunk size fits the remaining size if ( chunk > remaining ) { chunk = remaining ; } // writes remaining chunk StreamUtil . copy ( inputStream , out , chunk ) ; remaining -= chunk ; step += chunk ; count += chunk ; // listener if ( step >= callbackSize ) { progressListener . transferred ( count ) ; step -= callbackSize ; } } } finally { StreamUtil . close ( inputStream ) ; } } } // end if ( step != 0 ) { progressListener . transferred ( count ) ; } }


Input: ---------------------------------------------------------------- private [CODESPLIT] private static String encode ( final CharSequence text , final char [ ] [ ] buff , final int bufflen ) { int len ; if ( ( text == null ) || ( ( len = text . length ( ) ) == 0 ) ) { return StringPool . EMPTY ; } StringBuilder buffer = new StringBuilder ( len + ( len >> 2 ) ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = text . charAt ( i ) ; if ( c < bufflen ) { buffer . append ( buff [ c ] ) ; } else { buffer . append ( c ) ; } } return buffer . toString ( ) ; }


Input: Returns the string value with the specified key . [CODESPLIT] public String getString ( final String key ) { CharSequence cs = ( CharSequence ) map . get ( key ) ; return cs == null ? null : cs . toString ( ) ; }


Input: returns the integer value with the specified key . [CODESPLIT] public Integer getInteger ( final String key ) { Number number = ( Number ) map . get ( key ) ; if ( number == null ) { return null ; } if ( number instanceof Integer ) { return ( Integer ) number ; } return number . intValue ( ) ; }


Input: Returns the long value with the specified key . [CODESPLIT] public Long getLong ( final String key ) { Number number = ( Number ) map . get ( key ) ; if ( number == null ) { return null ; } if ( number instanceof Long ) { return ( Long ) number ; } return number . longValue ( ) ; }


Input: Returns the double value with the specified key . [CODESPLIT] public Double getDouble ( final String key ) { Number number = ( Number ) map . get ( key ) ; if ( number == null ) { return null ; } if ( number instanceof Double ) { return ( Double ) number ; } return number . doubleValue ( ) ; }


Input: Returns the float value with the specified key . [CODESPLIT] public Float getFloat ( final String key ) { Number number = ( Number ) map . get ( key ) ; if ( number == null ) { return null ; } if ( number instanceof Float ) { return ( Float ) number ; } return number . floatValue ( ) ; }


Input: Returns the { [CODESPLIT] public JsonObject getJsonObject ( final String key ) { Object val = map . get ( key ) ; if ( val instanceof Map ) { val = new JsonObject ( ( Map ) val ) ; } return ( JsonObject ) val ; }


Input: Returns the { [CODESPLIT] public JsonArray getJsonArray ( final String key ) { Object val = map . get ( key ) ; if ( val instanceof List ) { val = new JsonArray ( ( List ) val ) ; } return ( JsonArray ) val ; }


Input: Returns the binary value with the specified key . <p > JSON itself has no notion of a binary . This extension complies to the RFC - 7493 . THe byte array is Base64 encoded binary . [CODESPLIT] public byte [ ] getBinary ( final String key ) { String encoded = ( String ) map . get ( key ) ; return encoded == null ? null : Base64 . getDecoder ( ) . decode ( encoded ) ; }


Input: Returns the value with the specified key as an object . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public < T > T getValue ( final String key ) { T val = ( T ) map . get ( key ) ; if ( val instanceof Map ) { return ( T ) new JsonObject ( ( Map ) val ) ; } if ( val instanceof List ) { return ( T ) new JsonArray ( ( List ) val ) ; } return val ; }


Input: Like { [CODESPLIT] public String getString ( final String key , final String def ) { String val = getString ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public Integer getInteger ( final String key , final Integer def ) { Integer val = getInteger ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public Long getLong ( final String key , final Long def ) { Long val = getLong ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public Double getDouble ( final String key , final Double def ) { Double val = getDouble ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public Float getFloat ( final String key , final Float def ) { Float val = getFloat ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public Boolean getBoolean ( final String key , final Boolean def ) { Boolean val = getBoolean ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public JsonObject getJsonObject ( final String key , final JsonObject def ) { JsonObject val = getJsonObject ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public JsonArray getJsonArray ( final String key , final JsonArray def ) { JsonArray val = getJsonArray ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public byte [ ] getBinary ( final String key , final byte [ ] def ) { byte [ ] val = getBinary ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Like { [CODESPLIT] public < T > T getValue ( final String key , final T def ) { T val = getValue ( key ) ; if ( val == null ) { if ( map . containsKey ( key ) ) { return null ; } return def ; } return val ; }


Input: Puts an Enum into the JSON object with the specified key . <p > JSON has no concept of encoding Enums so the Enum will be converted to a String using the { [CODESPLIT] public JsonObject put ( final String key , final Enum value ) { Objects . requireNonNull ( key ) ; map . put ( key , value == null ? null : value . name ( ) ) ; return this ; }


Input: Puts an { [CODESPLIT] public JsonObject put ( final String key , final CharSequence value ) { Objects . requireNonNull ( key ) ; map . put ( key , value == null ? null : value . toString ( ) ) ; return this ; }


Input: Puts a string into the JSON object with the specified key . [CODESPLIT] public JsonObject put ( final String key , final String value ) { Objects . requireNonNull ( key ) ; map . put ( key , value ) ; return this ; }


Input: Puts a { [CODESPLIT] public JsonObject putNull ( final String key ) { Objects . requireNonNull ( key ) ; map . put ( key , null ) ; return this ; }


Input: Puts a { [CODESPLIT] public JsonObject put ( final String key , final byte [ ] value ) { Objects . requireNonNull ( key ) ; map . put ( key , value == null ? null : Base64 . getEncoder ( ) . encodeToString ( value ) ) ; return this ; }


Input: Returns array of all { @link Folder } s as { @code String } s . You can use these names in { @link #useFolder ( String ) } method . [CODESPLIT] public String [ ] getAllFolders ( ) { final Folder [ ] folders ; try { folders = getService ( ) . getDefaultFolder ( ) . list ( "*" ) ; } catch ( final MessagingException msgexc ) { throw new MailException ( "Failed to connect to folder" , msgexc ) ; } final String [ ] folderNames = new String [ folders . length ] ; for ( int i = 0 ; i < folders . length ; i ++ ) { final Folder folder = folders [ i ] ; folderNames [ i ] = folder . getFullName ( ) ; } return folderNames ; }


Input: Opens new folder and closes previously opened folder . [CODESPLIT] public void useFolder ( final String folderName ) { closeFolderIfOpened ( folder ) ; try { this . folderName = folderName ; this . folder = getService ( ) . getFolder ( folderName ) ; try { folder . open ( Folder . READ_WRITE ) ; } catch ( final MailException ignore ) { folder . open ( Folder . READ_ONLY ) ; } } catch ( final MessagingException msgexc ) { throw new MailException ( "Failed to connect to folder: " + folderName , msgexc ) ; } }


Input: Just returns a folder w / o opening . [CODESPLIT] public Folder getFolder ( final String folder ) { try { return getService ( ) . getFolder ( folder ) ; } catch ( MessagingException e ) { throw new MailException ( "Folder not found: " + folder , e ) ; } }


Input: Receives all emails that matches given { @link EmailFilter } . Messages are not modified . However servers may set SEEN flag anyway so we force messages to remain unseen . [CODESPLIT] public ReceivedEmail [ ] receiveEmail ( final EmailFilter filter ) { return receiveMessages ( filter , null , null , false , null ) ; }


Input: Receives all emails that matches given { @link EmailFilter } and mark them as seen ( ie read ) . [CODESPLIT] public ReceivedEmail [ ] receiveEmailAndMarkSeen ( final EmailFilter filter ) { final Flags flagsToSet = new Flags ( ) ; flagsToSet . add ( Flags . Flag . SEEN ) ; return receiveMessages ( filter , flagsToSet , null , false , null ) ; }


Input: Receives all emails that matches given { @link EmailFilter } and mark all messages as seen and deleted . [CODESPLIT] public ReceivedEmail [ ] receiveEmailAndDelete ( final EmailFilter filter ) { final Flags flags = new Flags ( ) ; flags . add ( Flags . Flag . SEEN ) ; flags . add ( Flags . Flag . DELETED ) ; return receiveMessages ( filter , flags , null , false , null ) ; }


Input: The main email receiving method . [CODESPLIT] ReceivedEmail [ ] receiveMessages ( final EmailFilter filter , final Flags flagsToSet , final Flags flagsToUnset , final boolean envelope , final Consumer < Message [ ] > processedMessageConsumer ) { useAndOpenFolderIfNotSet ( ) ; final Message [ ] messages ; try { if ( filter == null ) { messages = folder . getMessages ( ) ; } else { messages = folder . search ( filter . getSearchTerm ( ) ) ; } if ( messages . length == 0 ) { return ReceivedEmail . EMPTY_ARRAY ; } if ( envelope ) { final FetchProfile fetchProfile = new FetchProfile ( ) ; fetchProfile . add ( FetchProfile . Item . ENVELOPE ) ; fetchProfile . add ( FetchProfile . Item . FLAGS ) ; folder . fetch ( messages , fetchProfile ) ; } // process messages final ReceivedEmail [ ] emails = new ReceivedEmail [ messages . length ] ; for ( int i = 0 ; i < messages . length ; i ++ ) { final Message msg = messages [ i ] ; // we need to parse message BEFORE flags are set! emails [ i ] = new ReceivedEmail ( msg , envelope , attachmentStorage ) ; if ( ! EmailUtil . isEmptyFlags ( flagsToSet ) ) { emails [ i ] . flags ( flagsToSet ) ; msg . setFlags ( flagsToSet , true ) ; } if ( ! EmailUtil . isEmptyFlags ( flagsToUnset ) ) { emails [ i ] . flags ( ) . remove ( flagsToUnset ) ; msg . setFlags ( flagsToUnset , false ) ; } if ( EmailUtil . isEmptyFlags ( flagsToSet ) && ! emails [ i ] . isSeen ( ) ) { msg . setFlag ( Flags . Flag . SEEN , false ) ; } } if ( processedMessageConsumer != null ) { processedMessageConsumer . accept ( messages ) ; } // if messages were marked to be deleted, we need to expunge the folder if ( ! EmailUtil . isEmptyFlags ( flagsToSet ) ) { if ( flagsToSet . contains ( Flags . Flag . DELETED ) ) { folder . expunge ( ) ; } } return emails ; } catch ( final MessagingException msgexc ) { throw new MailException ( "Failed to fetch messages" , msgexc ) ; } }


Input: Updates the email flags on the server . [CODESPLIT] public void updateEmailFlags ( final ReceivedEmail receivedEmail ) { useAndOpenFolderIfNotSet ( ) ; try { folder . setFlags ( new int [ ] { receivedEmail . messageNumber ( ) } , receivedEmail . flags ( ) , true ) ; } catch ( MessagingException mex ) { throw new MailException ( "Failed to fetch messages" , mex ) ; } }


Input: Closes folder if opened and expunge deleted messages . [CODESPLIT] protected void closeFolderIfOpened ( final Folder folder ) { if ( folder != null ) { try { folder . close ( true ) ; } catch ( final MessagingException ignore ) { } } }


Input: Lookup for named parameter . [CODESPLIT] DbQueryNamedParameter lookupNamedParameter ( final String name ) { DbQueryNamedParameter p = rootNP ; while ( p != null ) { if ( p . equalsName ( name ) ) { return p ; } p = p . next ; } return null ; }


Input: Returns the size of batch parameter . Returns <code > 0< / code > if parameter does not exist . [CODESPLIT] protected int getBatchParameterSize ( final String name ) { if ( batchParams == null ) { return 0 ; } Integer size = batchParams . get ( name ) ; if ( size == null ) { return 0 ; } return size . intValue ( ) ; }


Input: ---------------------------------------------------------------- parser [CODESPLIT] void parseSql ( final String sqlString ) { rootNP = null ; final int stringLength = sqlString . length ( ) ; final StringBuilder pureSql = new StringBuilder ( stringLength ) ; boolean inQuote = false ; int index = 0 ; int paramCount = 0 ; while ( index < stringLength ) { char c = sqlString . charAt ( index ) ; if ( inQuote ) { if ( c == ' ' ) { inQuote = false ; } } else if ( c == ' ' ) { inQuote = true ; } else if ( c == ' ' && index + 1 < stringLength && sqlString . charAt ( index + 1 ) == ' ' ) { // don't treat '::foo' sequence as named parameter; skip this // chunk int right = StringUtil . indexOfChars ( sqlString , SQL_SEPARATORS , index + 2 ) ; if ( right < 0 ) { right = stringLength ; } pureSql . append ( sqlString . substring ( index , right ) ) ; index = right ; continue ; } else if ( c == ' ' ) { int right = StringUtil . indexOfChars ( sqlString , SQL_SEPARATORS , index + 1 ) ; boolean batch = false ; if ( right < 0 ) { right = stringLength ; } else { if ( sqlString . charAt ( right ) == ' ' ) { batch = true ; } } String param = sqlString . substring ( index + 1 , right ) ; if ( ! batch ) { paramCount ++ ; storeNamedParameter ( param , paramCount ) ; pureSql . append ( ' ' ) ; } else { // read batch size right ++ ; int numStart = right ; while ( right < stringLength ) { if ( ! CharUtil . isDigit ( sqlString . charAt ( right ) ) ) { break ; } right ++ ; } String numberValue = sqlString . substring ( numStart , right ) ; int batchSize ; try { batchSize = Integer . parseInt ( numberValue ) ; } catch ( NumberFormatException nfex ) { throw new DbSqlException ( "Batch size is not an integer: " + numberValue , nfex ) ; } saveBatchParameter ( param , batchSize ) ; // create batch parameters for ( int i = 1 ; i <= batchSize ; i ++ ) { if ( i != 1 ) { pureSql . append ( ' ' ) ; } paramCount ++ ; storeNamedParameter ( param + ' ' + i , paramCount ) ; pureSql . append ( ' ' ) ; } } index = right ; continue ; } else if ( c == ' ' ) { // either an ordinal or positional parameter if ( ( index < stringLength - 1 ) && ( Character . isDigit ( sqlString . charAt ( index + 1 ) ) ) ) { // positional parameter int right = StringUtil . indexOfChars ( sqlString , SQL_SEPARATORS , index + 1 ) ; if ( right < 0 ) { right = stringLength ; } String param = sqlString . substring ( index + 1 , right ) ; try { Integer . parseInt ( param ) ; } catch ( NumberFormatException nfex ) { throw new DbSqlException ( "Positional parameter is not an integer: " + param , nfex ) ; } paramCount ++ ; storeNamedParameter ( param , paramCount ) ; pureSql . append ( ' ' ) ; index = right ; continue ; } paramCount ++ ; // ordinal param } pureSql . append ( c ) ; index ++ ; } this . prepared = ( paramCount != 0 ) ; this . sql = pureSql . toString ( ) ; if ( this . sql . startsWith ( "{" ) ) { this . callable = true ; } }


Input: Creates alias . [CODESPLIT] protected String alias ( final String target ) { return StringPool . LEFT_CHEV . concat ( target ) . concat ( StringPool . RIGHT_CHEV ) ; }


Input: Creates alias from target object and target method name . If classname contains a $ sign everything will be stripped after it ( to get the real name if action class is proxified ) . [CODESPLIT] protected String alias ( final Object target , final String targetMethodName ) { String targetClassName = target . getClass ( ) . getName ( ) ; targetClassName = StringUtil . cutToIndexOf ( targetClassName , ' ' ) ; return ' ' + targetClassName + ' ' + targetMethodName + ' ' ; }


Input: Validates action . Profiles are reset after the invocation . [CODESPLIT] protected boolean validateAction ( final String ... profiles ) { prepareValidator ( ) ; vtor . useProfiles ( profiles ) ; vtor . validate ( this ) ; vtor . resetProfiles ( ) ; List < Violation > violations = vtor . getViolations ( ) ; return violations == null ; }


Input: Adds action violation . [CODESPLIT] protected void addViolation ( final String name , final Object invalidValue ) { prepareValidator ( ) ; vtor . addViolation ( new Violation ( name , this , invalidValue ) ) ; }


Input: Returns <code > true< / code > if tag name is a void tag . [CODESPLIT] public boolean isVoidTag ( final CharSequence tagName ) { for ( String html5VoidTag : HTML5_VOID_TAGS ) { if ( CharSequenceUtil . equalsToLowercase ( tagName , html5VoidTag ) ) { return true ; } } return false ; }


Input: Defines mime type by providing real mime type or just extension! [CODESPLIT] public RawData as ( final String mimeOrExtension ) { if ( mimeOrExtension . contains ( StringPool . SLASH ) ) { this . mimeType = mimeOrExtension ; } else { this . mimeType = MimeTypes . getMimeType ( mimeOrExtension ) ; } return this ; }


Input: Defines download file name and mime type from the name extension . [CODESPLIT] public RawData downloadableAs ( final String downloadFileName ) { this . downloadFileName = downloadFileName ; this . mimeType = MimeTypes . getMimeType ( FileNameUtil . getExtension ( downloadFileName ) ) ; return this ; }


Input: Defines class input stream as a target . [CODESPLIT] protected T setTarget ( final InputStream target ) { assertTargetIsNotDefined ( ) ; targetInputStream = target ; targetClass = null ; targetClassName = null ; return _this ( ) ; }


Input: Defines class name as a target . Class will not be loaded by classloader! [CODESPLIT] protected T setTarget ( final String targetName ) { assertTargetIsNotDefined ( ) ; try { targetInputStream = ClassLoaderUtil . getClassAsStream ( targetName ) ; if ( targetInputStream == null ) { throw new ProxettaException ( "Target class not found: " + targetName ) ; } targetClassName = targetName ; targetClass = null ; } catch ( IOException ioex ) { StreamUtil . close ( targetInputStream ) ; throw new ProxettaException ( "Unable to get stream class name: " + targetName , ioex ) ; } return _this ( ) ; }


Input: Defines class as a target . [CODESPLIT] public T setTarget ( final Class target ) { assertTargetIsNotDefined ( ) ; try { targetInputStream = ClassLoaderUtil . getClassAsStream ( target ) ; if ( targetInputStream == null ) { throw new ProxettaException ( "Target class not found: " + target . getName ( ) ) ; } targetClass = target ; targetClassName = target . getName ( ) ; } catch ( IOException ioex ) { StreamUtil . close ( targetInputStream ) ; throw new ProxettaException ( "Unable to stream class: " + target . getName ( ) , ioex ) ; } return _this ( ) ; }


Input: Returns new suffix or <code > null< / code > if suffix is not in use . [CODESPLIT] protected String resolveClassNameSuffix ( ) { String classNameSuffix = proxetta . getClassNameSuffix ( ) ; if ( classNameSuffix == null ) { return null ; } if ( ! proxetta . isVariableClassName ( ) ) { return classNameSuffix ; } suffixCounter ++ ; return classNameSuffix + suffixCounter ; }


Input: Reads the target and creates destination class . [CODESPLIT] protected void process ( ) { if ( targetInputStream == null ) { throw new ProxettaException ( "Target missing: " + targetClassName ) ; } // create class reader final ClassReader classReader ; try { classReader = new ClassReader ( targetInputStream ) ; } catch ( IOException ioex ) { throw new ProxettaException ( "Error reading class input stream" , ioex ) ; } // reads information final TargetClassInfoReader targetClassInfoReader = new TargetClassInfoReader ( proxetta . getClassLoader ( ) ) ; classReader . accept ( targetClassInfoReader , 0 ) ; this . destClassWriter = new ClassWriter ( ClassWriter . COMPUTE_MAXS | ClassWriter . COMPUTE_FRAMES ) ; // create proxy if ( log . isDebugEnabled ( ) ) { log . debug ( "processing: " + classReader . getClassName ( ) ) ; } WorkData wd = process ( classReader , targetClassInfoReader ) ; // store important data proxyApplied = wd . proxyApplied ; proxyClassName = wd . thisReference . replace ( ' ' , ' ' ) ; }


Input: Returns byte array of created class . [CODESPLIT] public byte [ ] create ( ) { process ( ) ; byte [ ] result = toByteArray ( ) ; dumpClassInDebugFolder ( result ) ; if ( ( ! proxetta . isForced ( ) ) && ( ! isProxyApplied ( ) ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Proxy not applied: " + StringUtil . toSafeString ( targetClassName ) ) ; } return null ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Proxy created " + StringUtil . toSafeString ( targetClassName ) ) ; } return result ; }


Input: Defines class . [CODESPLIT] public Class define ( ) { process ( ) ; if ( ( ! proxetta . isForced ( ) ) && ( ! isProxyApplied ( ) ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Proxy not applied: " + StringUtil . toSafeString ( targetClassName ) ) ; } if ( targetClass != null ) { return targetClass ; } if ( targetClassName != null ) { try { return ClassLoaderUtil . loadClass ( targetClassName ) ; } catch ( ClassNotFoundException cnfex ) { throw new ProxettaException ( cnfex ) ; } } } if ( log . isDebugEnabled ( ) ) { log . debug ( "Proxy created: " + StringUtil . toSafeString ( targetClassName ) ) ; } try { ClassLoader classLoader = proxetta . getClassLoader ( ) ; if ( classLoader == null ) { classLoader = ClassLoaderUtil . getDefaultClassLoader ( ) ; if ( ( classLoader == null ) && ( targetClass != null ) ) { classLoader = targetClass . getClassLoader ( ) ; } } final byte [ ] bytes = toByteArray ( ) ; dumpClassInDebugFolder ( bytes ) ; return DefineClass . of ( getProxyClassName ( ) , bytes , classLoader ) ; } catch ( Exception ex ) { throw new ProxettaException ( "Class definition failed" , ex ) ; } }


Input: Creates new instance of created class . Assumes default no - arg constructor . [CODESPLIT] public Object newInstance ( ) { Class type = define ( ) ; try { return ClassUtil . newInstance ( type ) ; } catch ( Exception ex ) { throw new ProxettaException ( "Invalid Proxetta class" , ex ) ; } }


Input: Writes created class content to output folder for debugging purposes . [CODESPLIT] protected void dumpClassInDebugFolder ( final byte [ ] bytes ) { File debugFolder = proxetta . getDebugFolder ( ) ; if ( debugFolder == null ) { return ; } if ( ! debugFolder . exists ( ) || ! debugFolder . isDirectory ( ) ) { log . warn ( "Invalid debug folder: " + debugFolder ) ; } String fileName = proxyClassName ; if ( fileName == null ) { fileName = "proxetta-" + System . currentTimeMillis ( ) ; } fileName += ".class" ; File file = new File ( debugFolder , fileName ) ; try { FileUtil . writeBytes ( file , bytes ) ; } catch ( IOException ioex ) { log . warn ( "Error writing class as " + file , ioex ) ; } }


Input: Sets the FROM address by providing personal name and address . [CODESPLIT] public T from ( final String personalName , final String from ) { return from ( new EmailAddress ( personalName , from ) ) ; }


Input: Appends TO address . [CODESPLIT] public T to ( final EmailAddress to ) { this . to = ArraysUtil . append ( this . to , to ) ; return _this ( ) ; }


Input: Appends TO address by personal name and email address . [CODESPLIT] public T to ( final String personalName , final String to ) { return to ( new EmailAddress ( personalName , to ) ) ; }


Input: Appends REPLY - TO address . [CODESPLIT] public T replyTo ( final EmailAddress replyTo ) { this . replyTo = ArraysUtil . append ( this . replyTo , replyTo ) ; return _this ( ) ; }


Input: Appends REPLY - TO address . [CODESPLIT] public T replyTo ( final String personalName , final String replyTo ) { return replyTo ( new EmailAddress ( personalName , replyTo ) ) ; }


Input: Appends REPLY - TO addresses . [CODESPLIT] public T replyTo ( final EmailAddress ... replyTo ) { this . replyTo = ArraysUtil . join ( this . replyTo , valueOrEmptyArray ( replyTo ) ) ; return _this ( ) ; }


Input: Appends CC address . [CODESPLIT] public T cc ( final EmailAddress to ) { this . cc = ArraysUtil . append ( this . cc , to ) ; return _this ( ) ; }


Input: Appends CC address . [CODESPLIT] public T cc ( final String personalName , final String cc ) { return cc ( new EmailAddress ( personalName , cc ) ) ; }


Input: Appends CC addresses . [CODESPLIT] public T cc ( final EmailAddress ... ccs ) { this . cc = ArraysUtil . join ( this . cc , valueOrEmptyArray ( ccs ) ) ; return _this ( ) ; }


Input: Sets message subject with specified encoding to override default platform encoding . If the subject contains non US - ASCII characters it will be encoded using the specified charset . If the subject contains only US - ASCII characters no encoding is done and it is used as - is . The application must ensure that the subject does not contain any line breaks . See { @link javax . mail . internet . MimeMessage#setSubject ( String String ) } . [CODESPLIT] public T subject ( final String subject , final String encoding ) { subject ( subject ) ; this . subjectEncoding = encoding ; return _this ( ) ; }


Input: Adds a { @link EmailMessage } . [CODESPLIT] public T message ( final String text , final String mimeType , final String encoding ) { return message ( new EmailMessage ( text , mimeType , encoding ) ) ; }


Input: Adds plain message text . [CODESPLIT] public T textMessage ( final String text , final String encoding ) { return message ( new EmailMessage ( text , MimeTypes . MIME_TEXT_PLAIN , encoding ) ) ; }


Input: Adds HTML message . [CODESPLIT] public T htmlMessage ( final String html , final String encoding ) { return message ( new EmailMessage ( html , MimeTypes . MIME_TEXT_HTML , encoding ) ) ; }


Input: Sets header value . [CODESPLIT] public T header ( final String name , final String value ) { headers . put ( name , value ) ; return _this ( ) ; }


Input: Sets headers . [CODESPLIT] public T headers ( final Map < String , String > headersToSet ) { headers . putAll ( headersToSet ) ; return _this ( ) ; }


Input: Sets headers . [CODESPLIT] public T headers ( final Enumeration < Header > headersToSet ) { while ( headersToSet . hasMoreElements ( ) ) { final Header header = headersToSet . nextElement ( ) ; header ( header . getName ( ) , header . getValue ( ) ) ; } return _this ( ) ; }


Input: Adds { @link EmailAttachment } s . [CODESPLIT] protected T storeAttachments ( final List < EmailAttachment < ? extends DataSource > > attachments ) { this . attachments . addAll ( attachments ) ; return _this ( ) ; }


Input: Adds { @link EmailAttachment } s . [CODESPLIT] public T attachments ( final List < EmailAttachment < ? extends DataSource > > attachments ) { for ( final EmailAttachment < ? > attachment : attachments ) { attachment ( attachment ) ; } return _this ( ) ; }


Input: Adds { @link EmailAttachment } . Content ID will be set to { @code null } . [CODESPLIT] public T attachment ( final EmailAttachment < ? extends DataSource > attachment ) { attachment . setContentId ( null ) ; return storeAttachment ( attachment ) ; }


Input: Attaches the embedded attachment : Content ID will be set if missing from attachment s file name . [CODESPLIT] public T embeddedAttachment ( final EmailAttachmentBuilder builder ) { builder . setContentIdFromNameIfMissing ( ) ; // https://github.com/oblac/jodd/issues/546 // https://github.com/oblac/jodd/issues/404#issuecomment-297011351 // content disposition will be set to "inline" builder . inline ( true ) ; return embeddedAttachment ( builder . buildByteArrayDataSource ( ) ) ; }


Input: Embed { @link EmailAttachment } to last message . No header is changed . [CODESPLIT] public T embeddedAttachment ( final EmailAttachment < ? extends DataSource > attachment ) { storeAttachment ( attachment ) ; final List < EmailMessage > messages = messages ( ) ; final int size = messages . size ( ) ; if ( size > 1 ) { // Add to last message final int lastMessagePos = size - 1 ; final EmailMessage lastMessage = messages . get ( lastMessagePos ) ; attachment . setEmbeddedMessage ( lastMessage ) ; } return _this ( ) ; }


Input: ---------------------------------------------------------------- helper [CODESPLIT] protected EmailAddress [ ] valueOrEmptyArray ( EmailAddress [ ] arr ) { if ( arr == null ) { arr = EmailAddress . EMPTY_ARRAY ; } return arr ; }


Input: Returns system property . If key is not available returns the default value . [CODESPLIT] public static String get ( final String name , final String defaultValue ) { Objects . requireNonNull ( name ) ; String value = null ; try { if ( System . getSecurityManager ( ) == null ) { value = System . getProperty ( name ) ; } else { value = AccessController . doPrivileged ( ( PrivilegedAction < String > ) ( ) -> System . getProperty ( name ) ) ; } } catch ( Exception ignore ) { } if ( value == null ) { return defaultValue ; } return value ; }


Input: Returns system property as boolean . [CODESPLIT] public static boolean getBoolean ( final String name , final boolean defaultValue ) { String value = get ( name ) ; if ( value == null ) { return defaultValue ; } value = value . trim ( ) . toLowerCase ( ) ; switch ( value ) { case "true" : case "yes" : case "1" : case "on" : return true ; case "false" : case "no" : case "0" : case "off" : return false ; default : return defaultValue ; } }


Input: Returns system property as an int . [CODESPLIT] public static long getInt ( final String name , final int defaultValue ) { String value = get ( name ) ; if ( value == null ) { return defaultValue ; } value = value . trim ( ) . toLowerCase ( ) ; try { return Integer . parseInt ( value ) ; } catch ( NumberFormatException nfex ) { return defaultValue ; } }


Input: Returns system property as a long . [CODESPLIT] public static long getLong ( final String name , final long defaultValue ) { String value = get ( name ) ; if ( value == null ) { return defaultValue ; } value = value . trim ( ) . toLowerCase ( ) ; try { return Long . parseLong ( value ) ; } catch ( NumberFormatException nfex ) { return defaultValue ; } }


Input: Invokes parsing on { [CODESPLIT] public Jerry parse ( final char [ ] content ) { Document doc = domBuilder . parse ( content ) ; return new Jerry ( domBuilder , doc ) ; }


Input: Invokes parsing on { [CODESPLIT] public Jerry parse ( String content ) { if ( content == null ) { content = StringPool . EMPTY ; } Document doc = domBuilder . parse ( content ) ; return new Jerry ( domBuilder , doc ) ; }


Input: Appends single { [CODESPLIT] public void append ( final float element ) { if ( offset - buffer . length >= 0 ) { grow ( offset ) ; } buffer [ offset ++ ] = element ; }


Input: Appends { [CODESPLIT] public FastFloatBuffer append ( final float [ ] array , final int off , final int len ) { if ( offset + len - buffer . length > 0 ) { grow ( offset + len ) ; } System . arraycopy ( array , off , buffer , offset , len ) ; offset += len ; return this ; }


Input: Appends another fast buffer to this one . [CODESPLIT] public FastFloatBuffer append ( final FastFloatBuffer buff ) { if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ; }


Input: Returns <code > true< / code > if type name equals param type . [CODESPLIT] boolean isEqualTypeName ( final Type argumentType , final Class paramType ) { String s = argumentType . getClassName ( ) ; if ( s . endsWith ( ARRAY ) ) { // arrays detected String prefix = s . substring ( 0 , s . length ( ) - 2 ) ; String bytecodeSymbol = primitives . get ( prefix ) ; if ( bytecodeSymbol != null ) { s = ' ' + bytecodeSymbol ; } else { s = "[L" + prefix + ' ' ; } } return s . equals ( paramType . getName ( ) ) ; }


Input: Returns method parameters once when method is parsed . If method has no parameters an empty array is returned . [CODESPLIT] MethodParameter [ ] getResolvedParameters ( ) { if ( paramExtractor == null ) { return MethodParameter . EMPTY_ARRAY ; } if ( ! paramExtractor . debugInfoPresent ) { throw new ParamoException ( "Parameter names not available for method: " + declaringClass . getName ( ) + ' ' + methodName ) ; } return paramExtractor . getMethodParameters ( ) ; }


Input: Serializes key and a value . [CODESPLIT] protected int serializeKeyValue ( final JsonContext jsonContext , final Path currentPath , final Object key , final Object value , int count ) { if ( ( value == null ) && jsonContext . isExcludeNulls ( ) ) { return count ; } if ( key != null ) { currentPath . push ( key . toString ( ) ) ; } else { currentPath . push ( StringPool . NULL ) ; } // check if we should include the field boolean include = true ; if ( value != null ) { // + all collections are not serialized by default include = jsonContext . matchIgnoredPropertyTypes ( value . getClass ( ) , false , include ) ; // + path queries: excludes/includes include = jsonContext . matchPathToQueries ( include ) ; } // done if ( ! include ) { currentPath . pop ( ) ; return count ; } if ( key == null ) { jsonContext . pushName ( null , count > 0 ) ; } else { jsonContext . pushName ( key . toString ( ) , count > 0 ) ; } jsonContext . serialize ( value ) ; if ( jsonContext . isNamePopped ( ) ) { count ++ ; } currentPath . pop ( ) ; return count ; }


Input: Lookups value as an alias and if not found as a default alias . [CODESPLIT] protected String lookupAlias ( final String alias ) { String value = actionsManager . lookupPathAlias ( alias ) ; if ( value == null ) { ActionRuntime cfg = actionsManager . lookup ( alias ) ; if ( cfg != null ) { value = cfg . getActionPath ( ) ; } } return value ; }


Input: Returns resolved alias result value or passed on if alias doesn t exist . [CODESPLIT] protected String resolveAlias ( final String value ) { final StringBuilder result = new StringBuilder ( value . length ( ) ) ; int i = 0 ; int len = value . length ( ) ; while ( i < len ) { int ndx = value . indexOf ( ' ' , i ) ; if ( ndx == - 1 ) { // alias markers not found if ( i == 0 ) { // try whole string as an alias String alias = lookupAlias ( value ) ; return ( alias != null ? alias : value ) ; } else { result . append ( value . substring ( i ) ) ; } break ; } // alias marked found result . append ( value . substring ( i , ndx ) ) ; ndx ++ ; int ndx2 = value . indexOf ( ' ' , ndx ) ; String aliasName = ( ndx2 == - 1 ? value . substring ( ndx ) : value . substring ( ndx , ndx2 ) ) ; // process alias String alias = lookupAlias ( aliasName ) ; if ( alias != null ) { result . append ( alias ) ; } else { // alias not found if ( log . isWarnEnabled ( ) ) { log . warn ( "Alias not found: " + aliasName ) ; } } i = ndx2 + 1 ; } // fix prefix '//' - may happened when aliases are used i = 0 ; len = result . length ( ) ; while ( i < len ) { if ( result . charAt ( i ) != ' ' ) { break ; } i ++ ; } if ( i > 1 ) { return result . substring ( i - 1 , len ) ; } return result . toString ( ) ; }


Input: Resolves result path . [CODESPLIT] public ResultPath resolveResultPath ( String path , String value ) { boolean absolutePath = false ; if ( value != null ) { // [*] resolve alias in value value = resolveAlias ( value ) ; // [*] absolute paths if ( StringUtil . startsWithChar ( value , ' ' ) ) { absolutePath = true ; int dotNdx = value . indexOf ( ".." ) ; if ( dotNdx != - 1 ) { path = value . substring ( 0 , dotNdx ) ; value = value . substring ( dotNdx + 2 ) ; } else { path = value ; value = null ; } } else { // [*] resolve # in value and path int i = 0 ; while ( i < value . length ( ) ) { if ( value . charAt ( i ) != ' ' ) { break ; } int dotNdx = MadvocUtil . lastIndexOfSlashDot ( path ) ; if ( dotNdx != - 1 ) { // dot found path = path . substring ( 0 , dotNdx ) ; } i ++ ; } if ( i > 0 ) { // remove # from value value = value . substring ( i ) ; // [*] update path and value if ( StringUtil . startsWithChar ( value , ' ' ) ) { value = value . substring ( 1 ) ; } else { int dotNdx = value . indexOf ( ".." ) ; if ( dotNdx != - 1 ) { path += ' ' + value . substring ( 0 , dotNdx ) ; value = value . substring ( dotNdx + 2 ) ; } else { if ( value . length ( ) > 0 ) { if ( StringUtil . endsWithChar ( path , ' ' ) ) { path += value ; } else { path += ' ' + value ; } } value = null ; } } } } } if ( ! absolutePath ) { if ( resultPathPrefix != null ) { path = resultPathPrefix + path ; } } return new ResultPath ( path , value ) ; }


Input: Resolves result path as a string when parts are not important and when only full string matters . Additional alias resolving on full path is done . [CODESPLIT] public String resolveResultPathString ( final String path , final String value ) { final ResultPath resultPath = resolveResultPath ( path , value ) ; final String result = resultPath . pathValue ( ) ; return resolveAlias ( result ) ; }


Input: Locates last dot after the last slash or just slash . [CODESPLIT] public static int lastIndexOfSlashDot ( final String str ) { int slashNdx = str . lastIndexOf ( ' ' ) ; int dotNdx = StringUtil . lastIndexOf ( str , ' ' , str . length ( ) , slashNdx ) ; if ( dotNdx == - 1 ) { if ( slashNdx == - 1 ) { return - 1 ; } slashNdx ++ ; if ( slashNdx < str . length ( ) - 1 ) { dotNdx = slashNdx ; } else { dotNdx = - 1 ; } } return dotNdx ; }


Input: Locates last index of dot after the optional last slash . [CODESPLIT] public static int lastIndexOfDotAfterSlash ( final String str ) { int slashNdx = str . lastIndexOf ( ' ' ) ; slashNdx ++ ; return StringUtil . lastIndexOf ( str , ' ' , str . length ( ) , slashNdx ) ; }


Input: Locates first dot after the last slash . [CODESPLIT] public static int indexOfDotAfterSlash ( final String str ) { int slashNdx = str . lastIndexOf ( ' ' ) ; if ( slashNdx == - 1 ) { slashNdx = 0 ; } return str . indexOf ( ' ' , slashNdx ) ; }


Input: Removes last CamelWord [CODESPLIT] public static String stripLastCamelWord ( String name ) { int ndx = name . length ( ) - 1 ; while ( ndx >= 0 ) { if ( CharUtil . isUppercaseAlpha ( name . charAt ( ndx ) ) ) { break ; } ndx -- ; } if ( ndx >= 0 ) { name = name . substring ( 0 , ndx ) ; } return name ; }


Input: Returns matched name or <code > null< / code > if name is not matched . <p > Matches if attribute name matches the required field name . If the match is positive injection is performed on the field . <p > Parameter name matches field name if param name starts with field name and has either . or [ after the field name . <p > Returns real property name once when name is matched . [CODESPLIT] public String matchedName ( final String value ) { // match if ( ! value . startsWith ( name ) ) { return null ; } final int requiredLen = name . length ( ) ; if ( value . length ( ) >= requiredLen + 1 ) { final char c = value . charAt ( requiredLen ) ; if ( ( c != ' ' ) && ( c != ' ' ) ) { return null ; } } // get param if ( targetName == null ) { return value ; } return targetName + value . substring ( name . length ( ) ) ; }


Input: Encodes the { [CODESPLIT] public String encode ( final SimTok simTok ) { final String json = JsonSerializer . create ( ) . deep ( true ) . serialize ( simTok ) ; final String p1 = Base64 . encodeToString ( "JoddSimTok" + SALT_ROUNDS ) ; final String p2 = Base64 . encodeToString ( json ) ; final String salt = BCrypt . gensalt ( SALT_ROUNDS ) ; final String p3 = BCrypt . hashpw ( p1 + "." + p2 + "." + SECRET , salt ) ; return p1 + "." + p2 + "." + p3 ; }


Input: Decodes the String to the { [CODESPLIT] public SimTok decode ( final String token ) { final int ndx = token . indexOf ( ' ' ) ; final String p1 = token . substring ( 0 , ndx ) ; final int ndx2 = token . indexOf ( ' ' , ndx + 1 ) ; final String p2 = token . substring ( ndx + 1 , ndx2 ) ; final String p3 = token . substring ( ndx2 + 1 ) ; if ( ! BCrypt . checkpw ( p1 + "." + p2 + "." + SECRET , p3 ) ) { return null ; } final String p2Decoded = Base64 . decodeToString ( p2 ) ; return JsonParser . create ( ) . parse ( p2Decoded , SimTok . class ) ; }


Input: Resolves table name from a type . If type is annotated table name will be read from annotation value . If this value is empty or if type is not annotated table name will be set to wildcard pattern * ( to match all tables ) . [CODESPLIT] public static String resolveTableName ( final Class < ? > type , final TableNamingStrategy tableNamingStrategy ) { String tableName = null ; final DbTable dbTable = type . getAnnotation ( DbTable . class ) ; if ( dbTable != null ) { tableName = dbTable . value ( ) . trim ( ) ; } if ( ( tableName == null ) || ( tableName . length ( ) == 0 ) ) { tableName = tableNamingStrategy . convertEntityNameToTableName ( type ) ; } else { if ( ! tableNamingStrategy . isStrictAnnotationNames ( ) ) { tableName = tableNamingStrategy . applyToTableName ( tableName ) ; } } return quoteIfRequired ( tableName , tableNamingStrategy . isAlwaysQuoteNames ( ) , tableNamingStrategy . getQuoteChar ( ) ) ; }


Input: Resolves schema name from a type . Uses default schema name if not specified . [CODESPLIT] public static String resolveSchemaName ( final Class < ? > type , final String defaultSchemaName ) { String schemaName = null ; final DbTable dbTable = type . getAnnotation ( DbTable . class ) ; if ( dbTable != null ) { schemaName = dbTable . schema ( ) . trim ( ) ; } if ( ( schemaName == null ) || ( schemaName . length ( ) == 0 ) ) { schemaName = defaultSchemaName ; } return schemaName ; }


Input: Returns <code > true< / code > if class is annotated with <code > DbTable< / code > annotation . [CODESPLIT] public static boolean resolveIsAnnotated ( final Class < ? > type ) { DbTable dbTable = type . getAnnotation ( DbTable . class ) ; return dbTable != null ; }


Input: Resolves column descriptor from property . If property is annotated value will be read from annotation . If property is not annotated then property will be ignored if entity is annotated . Otherwise column name is generated from the property name . [CODESPLIT] public static DbEntityColumnDescriptor resolveColumnDescriptors ( final DbEntityDescriptor dbEntityDescriptor , final PropertyDescriptor property , final boolean isAnnotated , final ColumnNamingStrategy columnNamingStrategy ) { String columnName = null ; boolean isId = false ; Class < ? extends SqlType > sqlTypeClass = null ; // read ID annotation DbId dbId = null ; if ( property . getFieldDescriptor ( ) != null ) { dbId = property . getFieldDescriptor ( ) . getField ( ) . getAnnotation ( DbId . class ) ; } if ( dbId == null && property . getReadMethodDescriptor ( ) != null ) { dbId = property . getReadMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( DbId . class ) ; } if ( dbId == null && property . getWriteMethodDescriptor ( ) != null ) { dbId = property . getWriteMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( DbId . class ) ; } if ( dbId != null ) { columnName = dbId . value ( ) . trim ( ) ; sqlTypeClass = dbId . sqlType ( ) ; isId = true ; } else { DbColumn dbColumn = null ; if ( property . getFieldDescriptor ( ) != null ) { dbColumn = property . getFieldDescriptor ( ) . getField ( ) . getAnnotation ( DbColumn . class ) ; } if ( dbColumn == null && property . getReadMethodDescriptor ( ) != null ) { dbColumn = property . getReadMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( DbColumn . class ) ; } if ( dbColumn == null && property . getWriteMethodDescriptor ( ) != null ) { dbColumn = property . getWriteMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( DbColumn . class ) ; } if ( dbColumn != null ) { columnName = dbColumn . value ( ) . trim ( ) ; sqlTypeClass = dbColumn . sqlType ( ) ; } else { if ( isAnnotated ) { return null ; } } } if ( StringUtil . isEmpty ( columnName ) ) { // default annotation value columnName = columnNamingStrategy . convertPropertyNameToColumnName ( property . getName ( ) ) ; } else { if ( ! columnNamingStrategy . isStrictAnnotationNames ( ) ) { columnName = columnNamingStrategy . applyToColumnName ( columnName ) ; } } if ( sqlTypeClass == SqlType . class ) { sqlTypeClass = null ; } return new DbEntityColumnDescriptor ( dbEntityDescriptor , quoteIfRequired ( columnName , columnNamingStrategy . isAlwaysQuoteNames ( ) , columnNamingStrategy . getQuoteChar ( ) ) , property . getName ( ) , property . getType ( ) , isId , sqlTypeClass ) ; }


Input: Resolves mapped types from { [CODESPLIT] public static Class [ ] resolveMappedTypes ( final Class type ) { DbMapTo dbMapTo = ( DbMapTo ) type . getAnnotation ( DbMapTo . class ) ; if ( dbMapTo == null ) { return null ; } return dbMapTo . value ( ) ; }


Input: ---------------------------------------------------------------- privates [CODESPLIT] private static String quoteIfRequired ( final String name , final boolean alwaysQuoteNames , final char quoteChar ) { if ( StringUtil . detectQuoteChar ( name ) != 0 ) { return name ; // already quoted } if ( alwaysQuoteNames && quoteChar != 0 ) { return quoteChar + name + quoteChar ; } return name ; }


Input: Initialize the cipher using the key and the tweak value . [CODESPLIT] public void init ( final long [ ] key , final long [ ] tweak ) { final int newNw = key . length ; // only create new arrays if the value of N{w} changes (different key size) if ( nw != newNw ) { nw = newNw ; switch ( nw ) { case WORDS_4 : pi = PI4 ; rpi = RPI4 ; r = R4 ; break ; case WORDS_8 : pi = PI8 ; rpi = RPI8 ; r = R8 ; break ; case WORDS_16 : pi = PI16 ; rpi = RPI16 ; r = R16 ; break ; default : throw new RuntimeException ( "Invalid threefish key" ) ; } this . k = new long [ nw + 1 ] ; // instantiation of these fields here for performance reasons vd = new long [ nw ] ; // v is the intermediate value v{d} at round d ed = new long [ nw ] ; // ed is the value of e{d} at round d fd = new long [ nw ] ; // fd is the value of f{d} at round d ksd = new long [ nw ] ; // ksd is the value of k{s} at round d } System . arraycopy ( key , 0 , this . k , 0 , key . length ) ; long knw = EXTENDED_KEY_SCHEDULE_CONST ; for ( int i = 0 ; i < nw ; i ++ ) { knw ^= this . k [ i ] ; } this . k [ nw ] = knw ; // set tweak values t [ 0 ] = tweak [ 0 ] ; t [ 1 ] = tweak [ 1 ] ; t [ 2 ] = t [ 0 ] ^ t [ 1 ] ; }


Input: Implementation of the E ( K T P ) function . The K and T values should be set previously using the init () method . This version is the 64 bit implementation of Threefish . [CODESPLIT] public void blockEncrypt ( final long [ ] p , final long [ ] c ) { // initial value = plain System . arraycopy ( p , 0 , vd , 0 , nw ) ; for ( int d = 0 ; d < nr ; d ++ ) { // do the rounds // calculate e{d,i} if ( d % SUBKEY_INTERVAL == 0 ) { final int s = d / SUBKEY_INTERVAL ; keySchedule ( s ) ; for ( int i = 0 ; i < nw ; i ++ ) { ed [ i ] = vd [ i ] + ksd [ i ] ; } } else { System . arraycopy ( vd , 0 , ed , 0 , nw ) ; } for ( int j = 0 ; j < nw / 2 ; j ++ ) { x [ 0 ] = ed [ j * 2 ] ; x [ 1 ] = ed [ j * 2 + 1 ] ; mix ( j , d ) ; fd [ j * 2 ] = y [ 0 ] ; fd [ j * 2 + 1 ] = y [ 1 ] ; } for ( int i = 0 ; i < nw ; i ++ ) { vd [ i ] = fd [ pi [ i ] ] ; } } // do the last keyschedule keySchedule ( nr / SUBKEY_INTERVAL ) ; for ( int i = 0 ; i < nw ; i ++ ) { c [ i ] = vd [ i ] + ksd [ i ] ; } }


Input: Implementation of the MIX function . [CODESPLIT] private void mix ( final int j , final int d ) { y [ 0 ] = x [ 0 ] + x [ 1 ] ; final long rotl = r [ d % DEPTH_OF_D_IN_R ] [ j ] ; // java left rotation for a long y [ 1 ] = ( x [ 1 ] << rotl ) | ( x [ 1 ] >>> ( Long . SIZE - rotl ) ) ; y [ 1 ] ^= y [ 0 ] ; }


Input: Implementation of the D ( K T C ) function . The K and T values should be set previously using the init () method . This version is the 64 bit implementation of Threefish . [CODESPLIT] public void blockDecrypt ( final long [ ] c , final long [ ] p ) { // initial value = plain System . arraycopy ( c , 0 , vd , 0 , nw ) ; for ( int d = nr ; d > 0 ; d -- ) { // do the rounds // calculate e{d,i} if ( d % SUBKEY_INTERVAL == 0 ) { final int s = d / SUBKEY_INTERVAL ; keySchedule ( s ) ; // calculate same keys for ( int i = 0 ; i < nw ; i ++ ) { fd [ i ] = vd [ i ] - ksd [ i ] ; } } else { System . arraycopy ( vd , 0 , fd , 0 , nw ) ; } for ( int i = 0 ; i < nw ; i ++ ) { ed [ i ] = fd [ rpi [ i ] ] ; } for ( int j = 0 ; j < nw / 2 ; j ++ ) { y [ 0 ] = ed [ j * 2 ] ; y [ 1 ] = ed [ j * 2 + 1 ] ; demix ( j , d - 1 ) ; vd [ j * 2 ] = x [ 0 ] ; vd [ j * 2 + 1 ] = x [ 1 ] ; } } // do the first keyschedule keySchedule ( 0 ) ; for ( int i = 0 ; i < nw ; i ++ ) { p [ i ] = vd [ i ] - ksd [ i ] ; } }


Input: Implementation of the un - MIX function . [CODESPLIT] private void demix ( final int j , final int d ) { y [ 1 ] ^= y [ 0 ] ; final long rotr = r [ d % DEPTH_OF_D_IN_R ] [ j ] ; // NOTE performance: darn, creation on stack! // right shift x [ 1 ] = ( y [ 1 ] << ( Long . SIZE - rotr ) ) | ( y [ 1 ] >>> rotr ) ; x [ 0 ] = y [ 0 ] - x [ 1 ] ; }


Input: Creates the subkeys . [CODESPLIT] private void keySchedule ( final int s ) { for ( int i = 0 ; i < nw ; i ++ ) { // just put in the main key first ksd [ i ] = k [ ( s + i ) % ( nw + 1 ) ] ; // don't add anything for i = 0,...,Nw - 4 if ( i == nw - 3 ) { // second to last ksd [ i ] += t [ s % TWEAK_VALUES ] ; } else if ( i == nw - 2 ) { // first to last ksd [ i ] += t [ ( s + 1 ) % TWEAK_VALUES ] ; } else if ( i == nw - 1 ) { // last ksd [ i ] += s ; } } }


Input: Initializes cipher in a simple way . [CODESPLIT] public void init ( final String keyMessage , final long tweak1 , final long tweak2 ) { long [ ] tweak = new long [ ] { tweak1 , tweak2 } ; byte [ ] key = new byte [ blockSize / Byte . SIZE ] ; byte [ ] keyData = StringUtil . getBytes ( keyMessage ) ; System . arraycopy ( keyData , 0 , key , 0 , key . length < keyData . length ? key . length : keyData . length ) ; init ( bytesToLongs ( key ) , tweak ) ; }


Input: Encrypts a block . [CODESPLIT] @ Override public byte [ ] encryptBlock ( final byte [ ] content , final int offset ) { long [ ] contentBlock = bytesToLongs ( content , offset , blockSizeInBytes ) ; long [ ] encryptedBlock = new long [ blockSize / Long . SIZE ] ; blockEncrypt ( contentBlock , encryptedBlock ) ; return longsToBytes ( encryptedBlock ) ; }


Input: Converts segment of byte array into long array . [CODESPLIT] protected static long [ ] bytesToLongs ( final byte [ ] ba , final int offset , final int size ) { long [ ] result = new long [ size >> 3 ] ; int i8 = offset ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = Bits . getLong ( ba , i8 ) ; i8 += 8 ; } return result ; }


Input: Converts char digit into integer value . Accepts numeric chars ( 0 - 9 ) as well as letter ( A - z ) . [CODESPLIT] public static int parseDigit ( final char digit ) { if ( ( digit >= ' ' ) && ( digit <= ' ' ) ) { return digit - ' ' ; } if ( CharUtil . isLowercaseAlpha ( digit ) ) { return 10 + digit - ' ' ; } return 10 + digit - ' ' ; }


Input: Filter initialization . [CODESPLIT] @ Override public void init ( final FilterConfig filterConfig ) throws ServletException { final ServletContext servletContext = filterConfig . getServletContext ( ) ; madvoc = Madvoc . get ( servletContext ) ; if ( madvoc != null ) { log = LoggerFactory . getLogger ( this . getClass ( ) ) ; madvocController = madvoc . webapp ( ) . madvocContainer ( ) . requestComponent ( MadvocController . class ) ; return ; } final WebApp webApp = WebApp . get ( servletContext ) ; if ( webApp != null ) { log = LoggerFactory . getLogger ( this . getClass ( ) ) ; madvocController = webApp . madvocContainer ( ) . requestComponent ( MadvocController . class ) ; return ; } throw new ServletException ( "Neither Madvoc or WebApp found! Use MadvocContextListener to create Madvoc or " + "WebApp#withServletContext() to make it available." ) ; }


Input: Builds { [CODESPLIT] @ Override public void doFilter ( final ServletRequest req , final ServletResponse res , final FilterChain chain ) throws IOException , ServletException { HttpServletRequest request = ( HttpServletRequest ) req ; HttpServletResponse response = ( HttpServletResponse ) res ; String actionPath = DispatcherUtil . getServletPath ( request ) ; try { MadvocResponseWrapper madvocResponse = new MadvocResponseWrapper ( response ) ; actionPath = madvocController . invoke ( actionPath , request , madvocResponse ) ; } catch ( Exception ex ) { log . error ( "Invoking action path failed: " + actionPath , ex ) ; throw new ServletException ( ex ) ; } if ( actionPath != null ) { // action path is not consumed boolean pathProcessed = processUnhandledPath ( actionPath , req , res ) ; if ( ! pathProcessed ) { chain . doFilter ( request , response ) ; } } }


Input: Parses email address . Returns { [CODESPLIT] public ParsedAddress parse ( String email ) { email = email . trim ( ) ; // match all final Matcher mailboxMatcher = MAILBOX_PATTERN ( ) . matcher ( email ) ; final boolean mailboxMatcherMatches = mailboxMatcher . matches ( ) ; final String [ ] mailboxMatcherParts = mailboxMatcherMatches ? _calcMatcherParts ( mailboxMatcher ) : null ; final Matcher returnPathMatcher = RETURN_PATH_PATTERN ( ) . matcher ( email ) ; final boolean returnPathMatches = returnPathMatcher . matches ( ) ; // extract String personalName = null ; String localPart = null ; String domain = null ; InternetAddress internetAddress = null ; String returnPathAddress = null ; if ( mailboxMatcherMatches ) { personalName = mailboxMatcherParts [ 0 ] ; localPart = mailboxMatcherParts [ 1 ] ; domain = mailboxMatcherParts [ 2 ] ; internetAddress = pullFromGroups ( mailboxMatcher ) ; } if ( returnPathMatches ) { if ( internetAddress != null ) { returnPathAddress = internetAddress . getAddress ( ) ; } else { returnPathAddress = StringPool . EMPTY ; } } return new ParsedAddress ( mailboxMatcherMatches , personalName , localPart , domain , internetAddress , returnPathMatches , returnPathAddress ) ; }


Input: Convenient shortcut of { [CODESPLIT] public InternetAddress parseToInternetAddress ( final String email ) { final ParsedAddress parsedAddress = parse ( email ) ; if ( ! parsedAddress . isValid ( ) ) { return null ; } return parsedAddress . getInternetAddress ( ) ; }


Input: Convenient shortcut of { [CODESPLIT] public EmailAddress parseToEmailAddress ( final String email ) { final ParsedAddress parsedAddress = parse ( email ) ; if ( ! parsedAddress . isValid ( ) ) { return null ; } return new EmailAddress ( parsedAddress . getPersonalName ( ) , parsedAddress . getLocalPart ( ) + ' ' + parsedAddress . getDomain ( ) ) ; }


Input: Builds all regexp patterns . [CODESPLIT] private void buildPatterns ( ) { // http://tools.ietf.org/html/rfc2822 // RFC 2822 2.2.2 Structured Header Field Bodies final String CRLF = "\\r\\n" ; final String WSP = "[ \\t]" ; final String FWSP = "(?:" + WSP + "*" + CRLF + ")?" + WSP + "+" ; // RFC 2822 3.2.1 Primitive tokens final String D_QUOTE = "\\\"" ; final String NO_WS_CTL = "\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F" ; final String ASCII_TEXT = "[\\x01-\\x09\\x0B\\x0C\\x0E-\\x7F]" ; // RFC 2822 3.2.2 Quoted characters final String QUOTED_PAIR = "(?:\\\\" + ASCII_TEXT + ")" ; // RFC 2822 3.2.3 CFWS specification final String C_TEXT = "[" + NO_WS_CTL + "\\!-\\'\\*-\\[\\]-\\~]" ; final String C_CONTENT = C_TEXT + "|" + QUOTED_PAIR ; // + "|" + comment; final String COMMENT = "\\((?:(?:" + FWSP + ")?" + C_CONTENT + ")*(?:" + FWSP + ")?\\)" ; final String CFWS = "(?:(?:" + FWSP + ")?" + COMMENT + ")*(?:(?:(?:" + FWSP + ")?" + COMMENT + ")|(?:" + FWSP + "))" ; // RFC 2822 3.2.4 Atom final String A_TEXT = "[a-zA-Z0-9\\!\\#-\\'\\*\\+\\-\\/\\=\\?\\^-\\`\\{-\\~" + ( ALLOW_DOT_IN_ATEXT ? "\\." : "" ) + ( ALLOW_SQUARE_BRACKETS_IN_ATEXT ? "\\[\\]" : "" ) + "]" ; final String REGULAR_A_TEXT = "[a-zA-Z0-9\\!\\#-\\'\\*\\+\\-\\/\\=\\?\\^-\\`\\{-\\~]" ; final String ATOM = "(?:" + CFWS + ")?" + A_TEXT + "+" + "(?:" + CFWS + ")?" ; final String DOT_ATOM_TEXT = REGULAR_A_TEXT + "+" + "(?:" + "\\." + REGULAR_A_TEXT + "+)*" ; final String CAP_DOT_ATOM_NO_CFWS = "(?:" + CFWS + ")?(" + DOT_ATOM_TEXT + ")(?:" + CFWS + ")?" ; final String CAP_DOT_ATOM_TRAILING_CFWS = "(?:" + CFWS + ")?(" + DOT_ATOM_TEXT + ")(" + CFWS + ")?" ; // RFC 2822 3.2.5 Quoted strings final String Q_TEXT = "[" + NO_WS_CTL + "\\!\\#-\\[\\]-\\~]" ; final String LOCAL_PART_Q_TEXT = "[" + NO_WS_CTL + ( ALLOW_PARENS_IN_LOCALPART ? "\\!\\#-\\[\\]-\\~]" : "\\!\\#-\\'\\*-\\[\\]-\\~]" ) ; final String Q_CONTENT = "(?:" + Q_TEXT + "|" + QUOTED_PAIR + ")" ; final String LOCAL_PART_Q_CONTENT = "(?>" + LOCAL_PART_Q_TEXT + "|" + QUOTED_PAIR + ")" ; final String QUOTED_STRING_WOCFWS = D_QUOTE + "(?>(?:" + FWSP + ")?" + Q_CONTENT + ")*(?:" + FWSP + ")?" + D_QUOTE ; final String QUOTED_STRING = "(?:" + CFWS + ")?" + QUOTED_STRING_WOCFWS + "(?:" + CFWS + ")?" ; final String LOCAL_PART_QUOTED_STRING = "(?:" + CFWS + ")?(" + D_QUOTE + "(?:(?:" + FWSP + ")?" + LOCAL_PART_Q_CONTENT + ")*(?:" + FWSP + ")?" + D_QUOTE + ")(?:" + CFWS + ")?" ; // RFC 2822 3.2.6 Miscellaneous tokens final String WORD = "(?:(?:" + ATOM + ")|(?:" + QUOTED_STRING + "))" ; // by 2822: phrase = 1*word / obs-phrase // implemented here as: phrase = word (FWS word)* // so that aaaa can't be four words, which can cause tons of recursive backtracking final String PHRASE = WORD + "(?:(?:" + FWSP + ")" + WORD + ")*" ; // RFC 1035 tokens for domain names final String LETTER = "[a-zA-Z]" ; final String LET_DIG = "[a-zA-Z0-9]" ; final String LET_DIG_HYP = "[a-zA-Z0-9-]" ; final String RFC_LABEL = LET_DIG + "(?:" + LET_DIG_HYP + "{0,61}" + LET_DIG + ")?" ; final String RFC_1035_DOMAIN_NAME = RFC_LABEL + "(?:\\." + RFC_LABEL + ")*\\." + LETTER + "{2,6}" ; // RFC 2822 3.4 Address specification final String D_TEXT = "[" + NO_WS_CTL + "\\!-Z\\^-\\~]" ; final String D_CONTENT = D_TEXT + "|" + QUOTED_PAIR ; final String CAP_DOMAIN_LITERAL_NO_CFWS = "(?:" + CFWS + ")?" + "(\\[" + "(?:(?:" + FWSP + ")?(?:" + D_CONTENT + ")+)*(?:" + FWSP + ")?\\])" + "(?:" + CFWS + ")?" ; final String CAP_DOMAIN_LITERAL_TRAILING_CFWS = "(?:" + CFWS + ")?" + "(\\[" + "(?:(?:" + FWSP + ")?(?:" + D_CONTENT + ")+)*(?:" + FWSP + ")?\\])" + "(" + CFWS + ")?" ; final String RFC_2822_DOMAIN = "(?:" + CAP_DOT_ATOM_NO_CFWS + "|" + CAP_DOMAIN_LITERAL_NO_CFWS + ")" ; final String CAP_CFWSR_FC2822_DOMAIN = "(?:" + CAP_DOT_ATOM_TRAILING_CFWS + "|" + CAP_DOMAIN_LITERAL_TRAILING_CFWS + ")" ; final String DOMAIN = ALLOW_DOMAIN_LITERALS ? RFC_2822_DOMAIN : "(?:" + CFWS + ")?(" + RFC_1035_DOMAIN_NAME + ")(?:" + CFWS + ")?" ; final String CAP_CFWS_DOMAIN = ALLOW_DOMAIN_LITERALS ? CAP_CFWSR_FC2822_DOMAIN : "(?:" + CFWS + ")?(" + RFC_1035_DOMAIN_NAME + ")(" + CFWS + ")?" ; final String LOCAL_PART = "(" + CAP_DOT_ATOM_NO_CFWS + "|" + LOCAL_PART_QUOTED_STRING + ")" ; // uniqueAddrSpec exists so we can have a duplicate tree that has a capturing group // instead of a non-capturing group for the trailing CFWS after the domain token // that we wouldn't want if it was inside // an angleAddr. The matching should be otherwise identical. final String ADDR_SPEC = LOCAL_PART + "@" + DOMAIN ; final String UNIQUE_ADDR_SPEC = LOCAL_PART + "@" + CAP_CFWS_DOMAIN ; final String ANGLE_ADDR = "(?:" + CFWS + ")?<" + ADDR_SPEC + ">(" + CFWS + ")?" ; final String NAME_ADDR = "(" + PHRASE + ")??(" + ANGLE_ADDR + ")" ; final String MAIL_BOX = ( ALLOW_QUOTED_IDENTIFIERS ? "(" + NAME_ADDR + ")|" : "" ) + "(" + UNIQUE_ADDR_SPEC + ")" ; final String RETURN_PATH = "(?:(?:" + CFWS + ")?<((?:" + CFWS + ")?|" + ADDR_SPEC + ")>(?:" + CFWS + ")?)" ; //private static final String mailboxList = "(?:(?:" + mailbox + ")(?:,(?:" + mailbox + "))*)"; //private static final String groupPostfix = "(?:" + CFWS + "|(?:" + mailboxList + ")" + ")?;(?:" + CFWS + ")?"; //private static final String groupPrefix = phrase + ":"; //private static final String group = groupPrefix + groupPostfix; //private static final String address = "(?:(?:" + mailbox + ")|(?:" + group + "))" // Java regex pattern for 2822 _MAILBOX_PATTERN = Pattern . compile ( MAIL_BOX ) ; _ADDR_SPEC_PATTERN = Pattern . compile ( ADDR_SPEC ) ; //final Pattern MAILBOX_LIST_PATTERN = Pattern.compile(mailboxList); _COMMENT_PATTERN = Pattern . compile ( COMMENT ) ; _QUOTED_STRING_WO_CFWS_PATTERN = Pattern . compile ( QUOTED_STRING_WOCFWS ) ; _RETURN_PATH_PATTERN = Pattern . compile ( RETURN_PATH ) ; }


Input: ---------------------------------------------------------------- utilities [CODESPLIT] private InternetAddress pullFromGroups ( final Matcher m ) { InternetAddress currentInternetAddress ; final String [ ] parts = _calcMatcherParts ( m ) ; if ( parts [ 1 ] == null || parts [ 2 ] == null ) { return null ; } // if for some reason you want to require that the result be re-parsable by // InternetAddress, you // could uncomment the appropriate stuff below, but note that not all the utility // functions use pullFromGroups; some call getMatcherParts directly. try { //currentInternetAddress = new InternetAddress(parts[0] + " <" + parts[1] + "@" + //                                 parts[2]+ ">", true); // so it parses it OK, but since javamail doesn't extract too well // we make sure that the consistent parts // are correct currentInternetAddress = new InternetAddress ( ) ; currentInternetAddress . setPersonal ( parts [ 0 ] ) ; currentInternetAddress . setAddress ( parts [ 1 ] + "@" + parts [ 2 ] ) ; } catch ( final UnsupportedEncodingException uee ) { currentInternetAddress = null ; } return currentInternetAddress ; }


Input: Given a string extract the first matched comment token as defined in 2822 trimmed ; return null on all errors or non - findings . <p > Note for future improvement : if COMMENT_PATTERN could handle nested comments then this should be able to as well but if this method were to be used to find the CFWS personal name ( see boolean option ) then such a nested comment would probably not be the one you were looking for? [CODESPLIT] private String getFirstComment ( final String text ) { if ( text == null ) { return null ; // important } final Matcher m = _COMMENT_PATTERN . matcher ( text ) ; if ( ! m . find ( ) ) { return null ; } return m . group ( ) . trim ( ) ; // must trim }


Input: If the string starts and ends with start and end char remove them otherwise return the string as it was passed in . [CODESPLIT] private static String removeAnyBounding ( final char s , final char e , final String str ) { if ( str == null || str . length ( ) < 2 ) { return str ; } if ( str . startsWith ( String . valueOf ( s ) ) && str . endsWith ( String . valueOf ( e ) ) ) { return str . substring ( 1 , str . length ( ) - 1 ) ; } return str ; }


Input: Wraps action class and returns <code > MethRef< / code > object ( proxified target ) so user can choose the method . [CODESPLIT] protected < T > Methref < T > wrapTargetToMethref ( final Class < T > target ) { return Methref . on ( target ) ; }


Input: Returns path value . [CODESPLIT] public String path ( ) { if ( methref != null ) { final String methodName = methref . ref ( ) ; return target . getName ( ) + ' ' + methodName ; } return path ; }


Input: Compresses a file into zlib archive . [CODESPLIT] public static File zlib ( final File file ) throws IOException { if ( file . isDirectory ( ) ) { throw new IOException ( "Can't zlib folder" ) ; } FileInputStream fis = new FileInputStream ( file ) ; Deflater deflater = new Deflater ( Deflater . BEST_COMPRESSION ) ; String zlibFileName = file . getAbsolutePath ( ) + ZLIB_EXT ; DeflaterOutputStream dos = new DeflaterOutputStream ( new FileOutputStream ( zlibFileName ) , deflater ) ; try { StreamUtil . copy ( fis , dos ) ; } finally { StreamUtil . close ( dos ) ; StreamUtil . close ( fis ) ; } return new File ( zlibFileName ) ; }


Input: Compresses a file into gzip archive . [CODESPLIT] public static File gzip ( final File file ) throws IOException { if ( file . isDirectory ( ) ) { throw new IOException ( "Can't gzip folder" ) ; } FileInputStream fis = new FileInputStream ( file ) ; String gzipName = file . getAbsolutePath ( ) + GZIP_EXT ; GZIPOutputStream gzos = new GZIPOutputStream ( new FileOutputStream ( gzipName ) ) ; try { StreamUtil . copy ( fis , gzos ) ; } finally { StreamUtil . close ( gzos ) ; StreamUtil . close ( fis ) ; } return new File ( gzipName ) ; }


Input: Decompress gzip archive . [CODESPLIT] public static File ungzip ( final File file ) throws IOException { String outFileName = FileNameUtil . removeExtension ( file . getAbsolutePath ( ) ) ; File out = new File ( outFileName ) ; out . createNewFile ( ) ; FileOutputStream fos = new FileOutputStream ( out ) ; GZIPInputStream gzis = new GZIPInputStream ( new FileInputStream ( file ) ) ; try { StreamUtil . copy ( gzis , fos ) ; } finally { StreamUtil . close ( fos ) ; StreamUtil . close ( gzis ) ; } return out ; }


Input: Zips a file or a folder . If adding a folder all its content will be added . [CODESPLIT] public static File zip ( final File file ) throws IOException { String zipFile = file . getAbsolutePath ( ) + ZIP_EXT ; return ZipBuilder . createZipFile ( zipFile ) . add ( file ) . recursive ( ) . save ( ) . toZipFile ( ) ; }


Input: Lists zip content . [CODESPLIT] public static List < String > listZip ( final File zipFile ) throws IOException { List < String > entries = new ArrayList <> ( ) ; ZipFile zip = new ZipFile ( zipFile ) ; Enumeration zipEntries = zip . entries ( ) ; while ( zipEntries . hasMoreElements ( ) ) { ZipEntry entry = ( ZipEntry ) zipEntries . nextElement ( ) ; String entryName = entry . getName ( ) ; entries . add ( entryName ) ; } return Collections . unmodifiableList ( entries ) ; }


Input: Extracts zip file content to the target directory . [CODESPLIT] public static void unzip ( final String zipFile , final String destDir , final String ... patterns ) throws IOException { unzip ( new File ( zipFile ) , new File ( destDir ) , patterns ) ; }


Input: Adds single entry to ZIP output stream . [CODESPLIT] public static void addToZip ( final ZipOutputStream zos , final File file , String path , final String comment , final boolean recursive ) throws IOException { if ( ! file . exists ( ) ) { throw new FileNotFoundException ( file . toString ( ) ) ; } if ( path == null ) { path = file . getName ( ) ; } while ( path . length ( ) != 0 && path . charAt ( 0 ) == ' ' ) { path = path . substring ( 1 ) ; } boolean isDir = file . isDirectory ( ) ; if ( isDir ) { // add folder record if ( ! StringUtil . endsWithChar ( path , ' ' ) ) { path += ' ' ; } } ZipEntry zipEntry = new ZipEntry ( path ) ; zipEntry . setTime ( file . lastModified ( ) ) ; if ( comment != null ) { zipEntry . setComment ( comment ) ; } if ( isDir ) { zipEntry . setSize ( 0 ) ; zipEntry . setCrc ( 0 ) ; } zos . putNextEntry ( zipEntry ) ; if ( ! isDir ) { InputStream is = new FileInputStream ( file ) ; try { StreamUtil . copy ( is , zos ) ; } finally { StreamUtil . close ( is ) ; } } zos . closeEntry ( ) ; // continue adding if ( recursive && file . isDirectory ( ) ) { boolean noRelativePath = StringUtil . isEmpty ( path ) ; final File [ ] children = file . listFiles ( ) ; if ( children != null && children . length != 0 ) { for ( File child : children ) { String childRelativePath = ( noRelativePath ? StringPool . EMPTY : path ) + child . getName ( ) ; addToZip ( zos , child , childRelativePath , comment , recursive ) ; } } } }


Input: Adds byte content into the zip as a file . [CODESPLIT] public static void addToZip ( final ZipOutputStream zos , final byte [ ] content , String path , final String comment ) throws IOException { while ( path . length ( ) != 0 && path . charAt ( 0 ) == ' ' ) { path = path . substring ( 1 ) ; } if ( StringUtil . endsWithChar ( path , ' ' ) ) { path = path . substring ( 0 , path . length ( ) - 1 ) ; } ZipEntry zipEntry = new ZipEntry ( path ) ; zipEntry . setTime ( System . currentTimeMillis ( ) ) ; if ( comment != null ) { zipEntry . setComment ( comment ) ; } zos . putNextEntry ( zipEntry ) ; InputStream is = new ByteArrayInputStream ( content ) ; try { StreamUtil . copy ( is , zos ) ; } finally { StreamUtil . close ( is ) ; } zos . closeEntry ( ) ; }


Input: Returns field descriptor . [CODESPLIT] public FieldDescriptor getFieldDescriptor ( final String name , final boolean declared ) { final FieldDescriptor fieldDescriptor = getFields ( ) . getFieldDescriptor ( name ) ; if ( fieldDescriptor != null ) { if ( ! fieldDescriptor . matchDeclared ( declared ) ) { return null ; } } return fieldDescriptor ; }


Input: Returns { [CODESPLIT] public MethodDescriptor getMethodDescriptor ( final String name , final boolean declared ) { final MethodDescriptor methodDescriptor = getMethods ( ) . getMethodDescriptor ( name ) ; if ( ( methodDescriptor != null ) && methodDescriptor . matchDeclared ( declared ) ) { return methodDescriptor ; } return methodDescriptor ; }


Input: Returns property descriptor . Declared flag is matched on both read and write methods . [CODESPLIT] public PropertyDescriptor getPropertyDescriptor ( final String name , final boolean declared ) { PropertyDescriptor propertyDescriptor = getProperties ( ) . getPropertyDescriptor ( name ) ; if ( ( propertyDescriptor != null ) && propertyDescriptor . matchDeclared ( declared ) ) { return propertyDescriptor ; } return null ; }


Input: Returns the default ctor or <code > null< / code > if not found . [CODESPLIT] public CtorDescriptor getDefaultCtorDescriptor ( final boolean declared ) { CtorDescriptor defaultCtor = getCtors ( ) . getDefaultCtor ( ) ; if ( ( defaultCtor != null ) && defaultCtor . matchDeclared ( declared ) ) { return defaultCtor ; } return null ; }


Input: Returns the constructor identified by arguments or <code > null< / code > if not found . [CODESPLIT] public CtorDescriptor getCtorDescriptor ( final Class [ ] args , final boolean declared ) { CtorDescriptor ctorDescriptor = getCtors ( ) . getCtorDescriptor ( args ) ; if ( ( ctorDescriptor != null ) && ctorDescriptor . matchDeclared ( declared ) ) { return ctorDescriptor ; } return null ; }


Input: Sets bundle name for provided servlet request . [CODESPLIT] public static void setRequestBundleName ( final ServletRequest request , final String bundleName ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Bundle name for this request: " + bundleName ) ; } request . setAttribute ( REQUEST_BUNDLE_NAME_ATTR , bundleName ) ; }


Input: Saves Locale to HTTP session . [CODESPLIT] public static void setSessionLocale ( final HttpSession session , final String localeCode ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Locale stored to session: " + localeCode ) ; } Locale locale = Locale . forLanguageTag ( localeCode ) ; session . setAttribute ( SESSION_LOCALE_ATTR , locale ) ; }


Input: Returns current locale from session . s [CODESPLIT] public static Locale getSessionLocale ( final HttpSession session ) { Locale locale = ( Locale ) session . getAttribute ( SESSION_LOCALE_ATTR ) ; return locale == null ? MESSAGE_RESOLVER . getFallbackLocale ( ) : locale ; }


Input: Creates new { [CODESPLIT] @ Override public void contextInitialized ( final ServletContextEvent servletContextEvent ) { ServletContext servletContext = servletContextEvent . getServletContext ( ) ; madvoc = new Madvoc ( ) ; madvoc . configureWith ( servletContext ) ; madvoc . startWebApplication ( servletContext ) ; }


Input: Returns an array of param keys that belongs to provided bean . Optionally resolves the value of returned parameters . [CODESPLIT] public String [ ] filterParametersForBeanName ( String beanName , final boolean resolveReferenceParams ) { beanName = beanName + ' ' ; List < String > list = new ArrayList <> ( ) ; for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( ! key . startsWith ( beanName ) ) { continue ; } list . add ( key ) ; if ( ! resolveReferenceParams ) { continue ; } // resolve all references String value = PropertiesUtil . resolveProperty ( params , key ) ; entry . setValue ( value ) ; } if ( list . isEmpty ( ) ) { return StringPool . EMPTY_ARRAY ; } else { return list . toArray ( new String [ 0 ] ) ; } }


Input: ----------------------------------------------------------------------------------------------- [CODESPLIT] @ Override public void visit ( final String name , final Object value ) { // Case of an element_value with a const_value_index, class_info_index or array_index field. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1. ++ numElementValuePairs ; if ( useNamedValues ) { annotation . putShort ( symbolTable . addConstantUtf8 ( name ) ) ; } if ( value instanceof String ) { annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( ( String ) value ) ) ; } else if ( value instanceof Byte ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( ( ( Byte ) value ) . byteValue ( ) ) . index ) ; } else if ( value instanceof Boolean ) { int booleanValue = ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ; annotation . put12 ( ' ' , symbolTable . addConstantInteger ( booleanValue ) . index ) ; } else if ( value instanceof Character ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( ( ( Character ) value ) . charValue ( ) ) . index ) ; } else if ( value instanceof Short ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( ( ( Short ) value ) . shortValue ( ) ) . index ) ; } else if ( value instanceof Type ) { annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( ( ( Type ) value ) . getDescriptor ( ) ) ) ; } else if ( value instanceof byte [ ] ) { byte [ ] byteArray = ( byte [ ] ) value ; annotation . put12 ( ' [ ' , byteArray . length ) ; for ( byte byteValue : byteArray ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( byteValue ) . index ) ; } } else if ( value instanceof boolean [ ] ) { boolean [ ] booleanArray = ( boolean [ ] ) value ; annotation . put12 ( ' [ ' , booleanArray . length ) ; for ( boolean booleanValue : booleanArray ) { annotation . put12 ( ' Z ' , symbolTable . addConstantInteger ( booleanValue ? 1 : 0 ) . index ) ; } } else if ( value instanceof short [ ] ) { short [ ] shortArray = ( short [ ] ) value ; annotation . put12 ( ' [ ' , shortArray . length ) ; for ( short shortValue : shortArray ) { annotation . put12 ( ' S ' , symbolTable . addConstantInteger ( shortValue ) . index ) ; } } else if ( value instanceof char [ ] ) { char [ ] charArray = ( char [ ] ) value ; annotation . put12 ( ' [ ' , charArray . length ) ; for ( char charValue : charArray ) { annotation . put12 ( ' ' , symbolTable . addConstantInteger ( charValue ) . index ) ; } } else if ( value instanceof int [ ] ) { int [ ] intArray = ( int [ ] ) value ; annotation . put12 ( ' [ ' , intArray . length ) ; for ( int intValue : intArray ) { annotation . put12 ( ' I ' , symbolTable . addConstantInteger ( intValue ) . index ) ; } } else if ( value instanceof long [ ] ) { long [ ] longArray = ( long [ ] ) value ; annotation . put12 ( ' [ ' , longArray . length ) ; for ( long longValue : longArray ) { annotation . put12 ( ' J ' , symbolTable . addConstantLong ( longValue ) . index ) ; } } else if ( value instanceof float [ ] ) { float [ ] floatArray = ( float [ ] ) value ; annotation . put12 ( ' [ ' , floatArray . length ) ; for ( float floatValue : floatArray ) { annotation . put12 ( ' ' , symbolTable . addConstantFloat ( floatValue ) . index ) ; } } else if ( value instanceof double [ ] ) { double [ ] doubleArray = ( double [ ] ) value ; annotation . put12 ( ' [ ' , doubleArray . length ) ; for ( double doubleValue : doubleArray ) { annotation . put12 ( ' ' , symbolTable . addConstantDouble ( doubleValue ) . index ) ; } } else { Symbol symbol = symbolTable . addConstant ( value ) ; annotation . put12 ( ".s.IFJDCS" . charAt ( symbol . tag ) , symbol . index ) ; } } @ Override public void visitEnum ( final String name , final String descriptor , final String value ) { // Case of an element_value with an enum_const_value field. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1. ++ numElementValuePairs ; if ( useNamedValues ) { annotation . putShort ( symbolTable . addConstantUtf8 ( name ) ) ; } annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( descriptor ) ) . putShort ( symbolTable . addConstantUtf8 ( value ) ) ; } @ Override public AnnotationVisitor visitAnnotation  ( final String name , final String descriptor ) { // Case of an element_value with an annotation_value field. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.16.1. ++ numElementValuePairs ; if ( useNamedValues ) { annotation . putShort ( symbolTable . addConstantUtf8 ( name ) ) ; } // Write tag and type_index, and reserve 2 bytes for num_element_value_pairs. annotation . put12 ( ' ' , symbolTable . addConstantUtf8 ( descriptor ) ) . putShort ( 0 ) ; return new AnnotationWriter ( symbolTable , annotation , null ) ; }


Input: Returns the size of a Runtime [ In ] Visible [ Type ] Annotations attribute containing this annotation and all its <i > predecessors< / i > ( see { @link #previousAnnotation } . Also adds the attribute name to the constant pool of the class ( if not null ) . [CODESPLIT] int computeAnnotationsSize ( final String attributeName ) { if ( attributeName != null ) { symbolTable . addConstantUtf8 ( attributeName ) ; } // The attribute_name_index, attribute_length and num_annotations fields use 8 bytes. int attributeSize = 8 ; AnnotationWriter annotationWriter = this ; while ( annotationWriter != null ) { attributeSize += annotationWriter . annotation . length ; annotationWriter = annotationWriter . previousAnnotation ; } return attributeSize ; }


Input: Puts a Runtime [ In ] Visible [ Type ] Annotations attribute containing this annotations and all its <i > predecessors< / i > ( see { @link #previousAnnotation } in the given ByteVector . Annotations are put in the same order they have been visited . [CODESPLIT] void putAnnotations ( final int attributeNameIndex , final ByteVector output ) { int attributeLength = 2 ; // For num_annotations. int numAnnotations = 0 ; AnnotationWriter annotationWriter = this ; AnnotationWriter firstAnnotation = null ; while ( annotationWriter != null ) { // In case the user forgot to call visitEnd(). annotationWriter . visitEnd ( ) ; attributeLength += annotationWriter . annotation . length ; numAnnotations ++ ; firstAnnotation = annotationWriter ; annotationWriter = annotationWriter . previousAnnotation ; } output . putShort ( attributeNameIndex ) ; output . putInt ( attributeLength ) ; output . putShort ( numAnnotations ) ; annotationWriter = firstAnnotation ; while ( annotationWriter != null ) { output . putByteArray ( annotationWriter . annotation . data , 0 , annotationWriter . annotation . length ) ; annotationWriter = annotationWriter . nextAnnotation ; } }


Input: Returns the size of a Runtime [ In ] VisibleParameterAnnotations attribute containing all the annotation lists from the given AnnotationWriter sub - array . Also adds the attribute name to the constant pool of the class . [CODESPLIT] static int computeParameterAnnotationsSize ( final String attributeName , final AnnotationWriter [ ] annotationWriters , final int annotableParameterCount ) { // Note: attributeName is added to the constant pool by the call to computeAnnotationsSize // below. This assumes that there is at least one non-null element in the annotationWriters // sub-array (which is ensured by the lazy instantiation of this array in MethodWriter). // The attribute_name_index, attribute_length and num_parameters fields use 7 bytes, and each // element of the parameter_annotations array uses 2 bytes for its num_annotations field. int attributeSize = 7 + 2 * annotableParameterCount ; for ( int i = 0 ; i < annotableParameterCount ; ++ i ) { AnnotationWriter annotationWriter = annotationWriters [ i ] ; attributeSize += annotationWriter == null ? 0 : annotationWriter . computeAnnotationsSize ( attributeName ) - 8 ; } return attributeSize ; }


Input: Puts a Runtime [ In ] VisibleParameterAnnotations attribute containing all the annotation lists from the given AnnotationWriter sub - array in the given ByteVector . [CODESPLIT] static void putParameterAnnotations ( final int attributeNameIndex , final AnnotationWriter [ ] annotationWriters , final int annotableParameterCount , final ByteVector output ) { // The num_parameters field uses 1 byte, and each element of the parameter_annotations array // uses 2 bytes for its num_annotations field. int attributeLength = 1 + 2 * annotableParameterCount ; for ( int i = 0 ; i < annotableParameterCount ; ++ i ) { AnnotationWriter annotationWriter = annotationWriters [ i ] ; attributeLength += annotationWriter == null ? 0 : annotationWriter . computeAnnotationsSize ( null ) - 8 ; } output . putShort ( attributeNameIndex ) ; output . putInt ( attributeLength ) ; output . putByte ( annotableParameterCount ) ; for ( int i = 0 ; i < annotableParameterCount ; ++ i ) { AnnotationWriter annotationWriter = annotationWriters [ i ] ; AnnotationWriter firstAnnotation = null ; int numAnnotations = 0 ; while ( annotationWriter != null ) { // In case user the forgot to call visitEnd(). annotationWriter . visitEnd ( ) ; numAnnotations ++ ; firstAnnotation = annotationWriter ; annotationWriter = annotationWriter . previousAnnotation ; } output . putShort ( numAnnotations ) ; annotationWriter = firstAnnotation ; while ( annotationWriter != null ) { output . putByteArray ( annotationWriter . annotation . data , 0 , annotationWriter . annotation . length ) ; annotationWriter = annotationWriter . nextAnnotation ; } } }


Input: Enables profiles to iterate . [CODESPLIT] public PropsEntries profile ( final String ... profiles ) { if ( profiles == null ) { return this ; } for ( String profile : profiles ) { addProfiles ( profile ) ; } return this ; }


Input: Gets a long from a byte buffer in little endian byte order . [CODESPLIT] public static long getLongLittleEndian ( final byte [ ] buf , final int offset ) { return ( ( long ) buf [ offset + 7 ] << 56 ) // no mask needed | ( ( buf [ offset + 6 ] & 0xff L ) << 48 ) | ( ( buf [ offset + 5 ] & 0xff L ) << 40 ) | ( ( buf [ offset + 4 ] & 0xff L ) << 32 ) | ( ( buf [ offset + 3 ] & 0xff L ) << 24 ) | ( ( buf [ offset + 2 ] & 0xff L ) << 16 ) | ( ( buf [ offset + 1 ] & 0xff L ) << 8 ) | ( ( buf [ offset ] & 0xff L ) ) ; // no shift needed }


Input: Returns the MurmurHash3_x64_128 hash . [CODESPLIT] public static HashValue murmurhash3_x64_128 ( final byte [ ] key , final int offset , final int len , final int seed ) { // The original algorithm does have a 32 bit unsigned seed. // We have to mask to match the behavior of the unsigned types and prevent sign extension. long h1 = seed & 0x00000000FFFFFFFF  L ; long h2 = seed & 0x00000000FFFFFFFF  L ; final long c1 = 0x87c37b91114253d5  L ; final long c2 = 0x4cf5ad432745937f  L ; int roundedEnd = offset + ( len & 0xFFFFFFF0 ) ; // round down to 16 byte block for ( int i = offset ; i < roundedEnd ; i += 16 ) { long k1 = getLongLittleEndian ( key , i ) ; long k2 = getLongLittleEndian ( key , i + 8 ) ; k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 31 ) ; k1 *= c2 ; h1 ^= k1 ; h1 = Long . rotateLeft ( h1 , 27 ) ; h1 += h2 ; h1 = h1 * 5 + 0x52dce729 ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 33 ) ; k2 *= c1 ; h2 ^= k2 ; h2 = Long . rotateLeft ( h2 , 31 ) ; h2 += h1 ; h2 = h2 * 5 + 0x38495ab5 ; } long k1 = 0 ; long k2 = 0 ; switch ( len & 15 ) { case 15 : k2 = ( key [ roundedEnd + 14 ] & 0xff L ) << 48 ; case 14 : k2 |= ( key [ roundedEnd + 13 ] & 0xff L ) << 40 ; case 13 : k2 |= ( key [ roundedEnd + 12 ] & 0xff L ) << 32 ; case 12 : k2 |= ( key [ roundedEnd + 11 ] & 0xff L ) << 24 ; case 11 : k2 |= ( key [ roundedEnd + 10 ] & 0xff L ) << 16 ; case 10 : k2 |= ( key [ roundedEnd + 9 ] & 0xff L ) << 8 ; case 9 : k2 |= ( key [ roundedEnd + 8 ] & 0xff L ) ; k2 *= c2 ; k2 = Long . rotateLeft ( k2 , 33 ) ; k2 *= c1 ; h2 ^= k2 ; case 8 : k1 = ( ( long ) key [ roundedEnd + 7 ] ) << 56 ; case 7 : k1 |= ( key [ roundedEnd + 6 ] & 0xff L ) << 48 ; case 6 : k1 |= ( key [ roundedEnd + 5 ] & 0xff L ) << 40 ; case 5 : k1 |= ( key [ roundedEnd + 4 ] & 0xff L ) << 32 ; case 4 : k1 |= ( key [ roundedEnd + 3 ] & 0xff L ) << 24 ; case 3 : k1 |= ( key [ roundedEnd + 2 ] & 0xff L ) << 16 ; case 2 : k1 |= ( key [ roundedEnd + 1 ] & 0xff L ) << 8 ; case 1 : k1 |= ( key [ roundedEnd ] & 0xff L ) ; k1 *= c1 ; k1 = Long . rotateLeft ( k1 , 31 ) ; k1 *= c2 ; h1 ^= k1 ; } //---------- // finalization h1 ^= len ; h2 ^= len ; h1 += h2 ; h2 += h1 ; h1 = fmix64 ( h1 ) ; h2 = fmix64 ( h2 ) ; h1 += h2 ; h2 += h1 ; return new HashValue ( h1 , h2 ) ; }


Input: Reads the given input stream and returns its content as a byte array . [CODESPLIT] private static byte [ ] readStream ( final InputStream inputStream , final boolean close ) throws IOException { if ( inputStream == null ) { throw new IOException ( "Class not found" ) ; } try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; byte [ ] data = new byte [ INPUT_STREAM_DATA_CHUNK_SIZE ] ; int bytesRead ; while ( ( bytesRead = inputStream . read ( data , 0 , data . length ) ) != - 1 ) { outputStream . write ( data , 0 , bytesRead ) ; } outputStream . flush ( ) ; return outputStream . toByteArray ( ) ; } finally { if ( close ) { inputStream . close ( ) ; } } }


Input: Returns the internal names of the implemented interfaces ( see { @link Type#getInternalName () } ) . [CODESPLIT] public String [ ] getInterfaces ( ) { // interfaces_count is after the access_flags, this_class and super_class fields (2 bytes each). int currentOffset = header + 6 ; int interfacesCount = readUnsignedShort ( currentOffset ) ; String [ ] interfaces = new String [ interfacesCount ] ; if ( interfacesCount > 0 ) { char [ ] charBuffer = new char [ maxStringLength ] ; for ( int i = 0 ; i < interfacesCount ; ++ i ) { currentOffset += 2 ; interfaces [ i ] = readClass ( currentOffset , charBuffer ) ; } } return interfaces ; }