signature:
public class ReceiveMailSession { /** * The main email receiving method . */
ReceivedEmail [ ] receiveMessages ( final EmailFilter filter , final Flags flagsToSet , final Flags flagsToUnset , final boolean envelope , final Consumer < Message [ ] > processedMessageConsumer ) { } }

implementation:
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 ) ; }


signature:
public class ReceiveMailSession { /** * Updates the email flags on the server . */
public void updateEmailFlags ( final ReceivedEmail receivedEmail ) { } }

implementation: useAndOpenFolderIfNotSet ( ) ; try { folder . setFlags ( new int [ ] { receivedEmail . messageNumber ( ) } , receivedEmail . flags ( ) , true ) ; } catch ( MessagingException mex ) { throw new MailException ( "Failed to fetch messages" , mex ) ; }


signature:
public class ReceiveMailSession { /** * Closes folder if opened and expunge deleted messages . */
protected void closeFolderIfOpened ( final Folder folder ) { } }

implementation: if ( folder != null ) { try { folder . close ( true ) ; } catch ( final MessagingException ignore ) { } }


signature:
public class DbQueryParser { /** * Lookup for named parameter . */
DbQueryNamedParameter lookupNamedParameter ( final String name ) { } }

implementation: DbQueryNamedParameter p = rootNP ; while ( p != null ) { if ( p . equalsName ( name ) ) { return p ; } p = p . next ; } return null ;


signature:
public class DbQueryParser { /** * Returns the size of batch parameter . Returns < code > 0 < / code >
 * if parameter does not exist . */
protected int getBatchParameterSize ( final String name ) { } }

implementation: if ( batchParams == null ) { return 0 ; } Integer size = batchParams . get ( name ) ; if ( size == null ) { return 0 ; } return size . intValue ( ) ;


signature:
public class DbQueryParser { /** * - - - - - parser */
void parseSql ( final String sqlString ) { } }

implementation:
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 ; }


signature:
public class AppAction { /** * Creates alias . */
protected String alias ( final String target ) { } }

implementation: return StringPool . LEFT_CHEV . concat ( target ) . concat ( StringPool . RIGHT_CHEV ) ;


signature:
public class AppAction { /** * 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 ) . */
protected String alias ( final Object target , final String targetMethodName ) { } }

implementation: String targetClassName = target . getClass ( ) . getName ( ) ; targetClassName = StringUtil . cutToIndexOf ( targetClassName , '$' ) ; return '<' + targetClassName + '#' + targetMethodName + '>' ;


signature:
public class AppAction { /** * Validates action . Profiles are reset after the invocation .
 * @ return < code > true < / code > if validation is successful , otherwise returns < code > false < / code > */
protected boolean validateAction ( final String ... profiles ) { } }

implementation: prepareValidator ( ) ; vtor . useProfiles ( profiles ) ; vtor . validate ( this ) ; vtor . resetProfiles ( ) ; List < Violation > violations = vtor . getViolations ( ) ; return violations == null ;


signature:
public class AppAction { /** * Adds action violation . */
protected void addViolation ( final String name , final Object invalidValue ) { } }

implementation: prepareValidator ( ) ; vtor . addViolation ( new Violation ( name , this , invalidValue ) ) ;


signature:
public class HtmlVoidRules { /** * Returns < code > true < / code > if tag name is a void tag . */
public boolean isVoidTag ( final CharSequence tagName ) { } }

implementation: for ( String html5VoidTag : HTML5_VOID_TAGS ) { if ( CharSequenceUtil . equalsToLowercase ( tagName , html5VoidTag ) ) { return true ; } } return false ;


signature:
public class RawData { /** * Defines mime type by providing real mime type or just extension ! */
public RawData as ( final String mimeOrExtension ) { } }

implementation: if ( mimeOrExtension . contains ( StringPool . SLASH ) ) { this . mimeType = mimeOrExtension ; } else { this . mimeType = MimeTypes . getMimeType ( mimeOrExtension ) ; } return this ;


signature:
public class RawData { /** * Defines download file name and mime type from the name extension . */
public RawData downloadableAs ( final String downloadFileName ) { } }

implementation: this . downloadFileName = downloadFileName ; this . mimeType = MimeTypes . getMimeType ( FileNameUtil . getExtension ( downloadFileName ) ) ; return this ;


signature:
public class ProxettaFactory { /** * Defines class input stream as a target . */
protected T setTarget ( final InputStream target ) { } }

implementation: assertTargetIsNotDefined ( ) ; targetInputStream = target ; targetClass = null ; targetClassName = null ; return _this ( ) ;


signature:
public class ProxettaFactory { /** * Defines class name as a target .
 * Class will not be loaded by classloader ! */
protected T setTarget ( final String targetName ) { } }

implementation: 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 ( ) ;


signature:
public class ProxettaFactory { /** * Defines class as a target . */
public T setTarget ( final Class target ) { } }

implementation: 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 ( ) ;


signature:
public class ProxettaFactory { /** * Returns new suffix or < code > null < / code > if suffix is not in use . */
protected String resolveClassNameSuffix ( ) { } }

implementation: String classNameSuffix = proxetta . getClassNameSuffix ( ) ; if ( classNameSuffix == null ) { return null ; } if ( ! proxetta . isVariableClassName ( ) ) { return classNameSuffix ; } suffixCounter ++ ; return classNameSuffix + suffixCounter ;


signature:
public class ProxettaFactory { /** * Reads the target and creates destination class . */
protected void process ( ) { } }

implementation:
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 ( '/' , '.' ) ;


signature:
public class ProxettaFactory { /** * Returns byte array of created class . */
public byte [ ] create ( ) { } }

implementation: 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 ;


signature:
public class ProxettaFactory { /** * Defines class . */
public Class define ( ) { } }

implementation: 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 ) ; }


signature:
public class ProxettaFactory { /** * Creates new instance of created class .
 * Assumes default no - arg constructor . */
public Object newInstance ( ) { } }

implementation: Class type = define ( ) ; try { return ClassUtil . newInstance ( type ) ; } catch ( Exception ex ) { throw new ProxettaException ( "Invalid Proxetta class" , ex ) ; }


signature:
public class ProxettaFactory { /** * Writes created class content to output folder for debugging purposes . */
protected void dumpClassInDebugFolder ( final byte [ ] bytes ) { } }

implementation: 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 ) ; }


signature:
public class CommonEmail { /** * Sets the FROM address by providing personal name and address .
 * @ param personalName personal name .
 * @ param from email address .
 * @ return this
 * @ see # from ( EmailAddress ) */
public T from ( final String personalName , final String from ) { } }

implementation: return from ( new EmailAddress ( personalName , from ) ) ;


signature:
public class CommonEmail { /** * Appends TO address .
 * @ param to { @ link EmailAddress } to add .
 * @ return this */
public T to ( final EmailAddress to ) { } }

implementation: this . to = ArraysUtil . append ( this . to , to ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Appends TO address by personal name and email address .
 * @ param personalName personal name .
 * @ param to email address .
 * @ return this
 * @ see # to ( EmailAddress ) */
public T to ( final String personalName , final String to ) { } }

implementation: return to ( new EmailAddress ( personalName , to ) ) ;


signature:
public class CommonEmail { /** * Appends REPLY - TO address .
 * @ param replyTo { @ link EmailAddress } to add .
 * @ return this */
public T replyTo ( final EmailAddress replyTo ) { } }

implementation: this . replyTo = ArraysUtil . append ( this . replyTo , replyTo ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Appends REPLY - TO address .
 * @ param personalName personal name .
 * @ param replyTo email address .
 * @ return this
 * @ see # replyTo ( EmailAddress ) */
public T replyTo ( final String personalName , final String replyTo ) { } }

implementation: return replyTo ( new EmailAddress ( personalName , replyTo ) ) ;


signature:
public class CommonEmail { /** * Appends REPLY - TO addresses .
 * @ param replyTo vararg of { @ link EmailAddress } es to set .
 * @ return this */
public T replyTo ( final EmailAddress ... replyTo ) { } }

implementation: this . replyTo = ArraysUtil . join ( this . replyTo , valueOrEmptyArray ( replyTo ) ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Appends CC address .
 * @ param to { @ link EmailAddress } to add .
 * @ return this */
public T cc ( final EmailAddress to ) { } }

implementation: this . cc = ArraysUtil . append ( this . cc , to ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Appends CC address .
 * @ param personalName personal name .
 * @ param cc email address .
 * @ return this
 * @ see # cc ( EmailAddress ) */
public T cc ( final String personalName , final String cc ) { } }

implementation: return cc ( new EmailAddress ( personalName , cc ) ) ;


signature:
public class CommonEmail { /** * Appends CC addresses .
 * @ param ccs vararg of { @ link EmailAddress } es to set .
 * @ return this */
public T cc ( final EmailAddress ... ccs ) { } }

implementation: this . cc = ArraysUtil . join ( this . cc , valueOrEmptyArray ( ccs ) ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * 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 ) } .
 * @ param subject The message subject
 * @ param encoding The encoding for the message subject .
 * @ return this */
public T subject ( final String subject , final String encoding ) { } }

implementation: subject ( subject ) ; this . subjectEncoding = encoding ; return _this ( ) ;


signature:
public class CommonEmail { /** * Adds a { @ link EmailMessage } .
 * @ param text The text to add as a { @ link String } .
 * @ param mimeType The MIME type as a { @ link String } .
 * @ param encoding The encoding as a { @ link String } .
 * @ return this
 * @ see # message ( EmailMessage ) */
public T message ( final String text , final String mimeType , final String encoding ) { } }

implementation: return message ( new EmailMessage ( text , mimeType , encoding ) ) ;


signature:
public class CommonEmail { /** * Adds plain message text .
 * @ param text The text to add as a { @ link String } .
 * @ param encoding The encoding as a { @ link String } .
 * @ return this
 * @ see # message ( EmailMessage ) */
public T textMessage ( final String text , final String encoding ) { } }

implementation: return message ( new EmailMessage ( text , MimeTypes . MIME_TEXT_PLAIN , encoding ) ) ;


signature:
public class CommonEmail { /** * Adds HTML message .
 * @ param html The HTML to add as a { @ link String } .
 * @ param encoding The encoding as a { @ link String } .
 * @ return this
 * @ see # message ( EmailMessage ) */
public T htmlMessage ( final String html , final String encoding ) { } }

implementation: return message ( new EmailMessage ( html , MimeTypes . MIME_TEXT_HTML , encoding ) ) ;


signature:
public class CommonEmail { /** * Sets header value .
 * @ param name The name of the header .
 * @ param value The value of the header .
 * @ return this */
public T header ( final String name , final String value ) { } }

implementation: headers . put ( name , value ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Sets headers .
 * @ param headersToSet Headers to set .
 * @ return this */
public T headers ( final Map < String , String > headersToSet ) { } }

implementation: headers . putAll ( headersToSet ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Sets headers .
 * @ param headersToSet Headers to set .
 * @ return this
 * @ see # header ( String , String ) */
public T headers ( final Enumeration < Header > headersToSet ) { } }

implementation: while ( headersToSet . hasMoreElements ( ) ) { final Header header = headersToSet . nextElement ( ) ; header ( header . getName ( ) , header . getValue ( ) ) ; } return _this ( ) ;


signature:
public class CommonEmail { /** * Adds { @ link EmailAttachment } s .
 * @ param attachments { @ link List } of { @ link EmailAttachment } s to add .
 * @ return this */
protected T storeAttachments ( final List < EmailAttachment < ? extends DataSource > > attachments ) { } }

implementation: this . attachments . addAll ( attachments ) ; return _this ( ) ;


signature:
public class CommonEmail { /** * Adds { @ link EmailAttachment } s .
 * @ param attachments { @ link List } of { @ link EmailAttachment } s to add .
 * @ return this */
public T attachments ( final List < EmailAttachment < ? extends DataSource > > attachments ) { } }

implementation: for ( final EmailAttachment < ? > attachment : attachments ) { attachment ( attachment ) ; } return _this ( ) ;


signature:
public class CommonEmail { /** * Adds { @ link EmailAttachment } . Content ID will be set to { @ code null } .
 * @ param attachment { @ link EmailAttachment } to add .
 * @ return this */
public T attachment ( final EmailAttachment < ? extends DataSource > attachment ) { } }

implementation: attachment . setContentId ( null ) ; return storeAttachment ( attachment ) ;


signature:
public class CommonEmail { /** * Attaches the embedded attachment : Content ID will be set if missing from attachment ' s file name .
 * @ param builder { @ link EmailAttachmentBuilder }
 * @ return this
 * @ see # embeddedAttachment ( EmailAttachment ) */
public T embeddedAttachment ( final EmailAttachmentBuilder builder ) { } }

implementation:
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 ( ) ) ;


signature:
public class CommonEmail { /** * Embed { @ link EmailAttachment } to last message . No header is changed .
 * @ param attachment { @ link EmailAttachment }
 * @ return this
 * @ see # storeAttachment ( EmailAttachment ) */
public T embeddedAttachment ( final EmailAttachment < ? extends DataSource > attachment ) { } }

implementation:
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 ( ) ;


signature:
public class CommonEmail { /** * - - - - - helper */
protected EmailAddress [ ] valueOrEmptyArray ( EmailAddress [ ] arr ) { } }

implementation: if ( arr == null ) { arr = EmailAddress . EMPTY_ARRAY ; } return arr ;


signature:
public class SystemUtil { /** * Returns system property . If key is not available , returns the default value . */
public static String get ( final String name , final String defaultValue ) { } }

implementation: 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 ;


signature:
public class SystemUtil { /** * Returns system property as boolean . */
public static boolean getBoolean ( final String name , final boolean defaultValue ) { } }

implementation: 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 ; }


signature:
public class SystemUtil { /** * Returns system property as an int . */
public static long getInt ( final String name , final int defaultValue ) { } }

implementation: String value = get ( name ) ; if ( value == null ) { return defaultValue ; } value = value . trim ( ) . toLowerCase ( ) ; try { return Integer . parseInt ( value ) ; } catch ( NumberFormatException nfex ) { return defaultValue ; }


signature:
public class SystemUtil { /** * Returns system property as a long . */
public static long getLong ( final String name , final long defaultValue ) { } }

implementation: String value = get ( name ) ; if ( value == null ) { return defaultValue ; } value = value . trim ( ) . toLowerCase ( ) ; try { return Long . parseLong ( value ) ; } catch ( NumberFormatException nfex ) { return defaultValue ; }


signature:
public class JerryParser { /** * Invokes parsing on { @ link DOMBuilder } . */
public Jerry parse ( final char [ ] content ) { } }

implementation: Document doc = domBuilder . parse ( content ) ; return new Jerry ( domBuilder , doc ) ;


signature:
public class JerryParser { /** * Invokes parsing on { @ link DOMBuilder } . */
public Jerry parse ( String content ) { } }

implementation: if ( content == null ) { content = StringPool . EMPTY ; } Document doc = domBuilder . parse ( content ) ; return new Jerry ( domBuilder , doc ) ;


signature:
public class FastFloatBuffer { /** * Appends single { @ code float } to buffer . */
public void append ( final float element ) { } }

implementation: if ( offset - buffer . length >= 0 ) { grow ( offset ) ; } buffer [ offset ++ ] = element ;


signature:
public class FastFloatBuffer { /** * Appends { @ code float } array to buffer . */
public FastFloatBuffer append ( final float [ ] array , final int off , final int len ) { } }

implementation: if ( offset + len - buffer . length > 0 ) { grow ( offset + len ) ; } System . arraycopy ( array , off , buffer , offset , len ) ; offset += len ; return this ;


signature:
public class FastFloatBuffer { /** * Appends another fast buffer to this one . */
public FastFloatBuffer append ( final FastFloatBuffer buff ) { } }

implementation: if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ;


signature:
public class MethodFinder { /** * Returns < code > true < / code > if type name equals param type . */
boolean isEqualTypeName ( final Type argumentType , final Class paramType ) { } }

implementation:
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 ( ) ) ;


signature:
public class MethodFinder { /** * Returns method parameters once when method is parsed .
 * If method has no parameters , an empty array is returned . */
MethodParameter [ ] getResolvedParameters ( ) { } }

implementation: 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 ( ) ;


signature:
public class KeyValueJsonSerializer { /** * Serializes key and a value . */
protected int serializeKeyValue ( final JsonContext jsonContext , final Path currentPath , final Object key , final Object value , int count ) { } }

implementation:
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 ;


signature:
public class ResultMapper { /** * Lookups value as an alias and , if not found , as a default alias . */
protected String lookupAlias ( final String alias ) { } }

implementation: String value = actionsManager . lookupPathAlias ( alias ) ; if ( value == null ) { ActionRuntime cfg = actionsManager . lookup ( alias ) ; if ( cfg != null ) { value = cfg . getActionPath ( ) ; } } return value ;


signature:
public class ResultMapper { /** * Returns resolved alias result value or passed on , if alias doesn ' t exist . */
protected String resolveAlias ( final String value ) { } }

implementation:
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 ( ) ;


signature:
public class ResultMapper { /** * Resolves result path . */
public ResultPath resolveResultPath ( String path , String value ) { } }

implementation:
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 ) ;


signature:
public class ResultMapper { /** * 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 . */
public String resolveResultPathString ( final String path , final String value ) { } }

implementation: final ResultPath resultPath = resolveResultPath ( path , value ) ; final String result = resultPath . pathValue ( ) ; return resolveAlias ( result ) ;


signature:
public class MadvocUtil { /** * Locates last dot after the last slash or just slash . */
public static int lastIndexOfSlashDot ( final String str ) { } }

implementation: 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 ;


signature:
public class MadvocUtil { /** * Locates last index of dot after the optional last slash . */
public static int lastIndexOfDotAfterSlash ( final String str ) { } }

implementation: int slashNdx = str . lastIndexOf ( '/' ) ; slashNdx ++ ; return StringUtil . lastIndexOf ( str , '.' , str . length ( ) , slashNdx ) ;


signature:
public class MadvocUtil { /** * Locates first dot after the last slash . */
public static int indexOfDotAfterSlash ( final String str ) { } }

implementation: int slashNdx = str . lastIndexOf ( '/' ) ; if ( slashNdx == - 1 ) { slashNdx = 0 ; } return str . indexOf ( '.' , slashNdx ) ;


signature:
public class MadvocUtil { /** * Removes last CamelWord */
public static String stripLastCamelWord ( String name ) { } }

implementation: 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 ;


signature:
public class InjectionPoint { /** * Returns matched name or < code > null < / code > if name is not matched .
 * Matches if attribute name matches the required field name . If the match is positive ,
 * injection is performed on the field .
 * Parameter name matches field name if param name starts with field name and has
 * either ' . ' or ' [ ' after the field name .
 * Returns real property name , once when name is matched . */
public String matchedName ( final String value ) { } }

implementation:
// 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 ( ) ) ;


signature:
public class SimTokCoder { /** * Encodes the { @ link SimTok } to JSON string . */
public String encode ( final SimTok simTok ) { } }

implementation: 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 ;


signature:
public class SimTokCoder { /** * Decodes the String to the { @ link SimTok } .
 * Returns { @ code null } if decoded token is NOT valid . */
public SimTok decode ( final String token ) { } }

implementation: 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 ) ;


signature:
public class DbMetaUtil { /** * 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 ) . */
public static String resolveTableName ( final Class < ? > type , final TableNamingStrategy tableNamingStrategy ) { } }

implementation: 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 ( ) ) ;


signature:
public class DbMetaUtil { /** * Resolves schema name from a type . Uses default schema name if not specified . */
public static String resolveSchemaName ( final Class < ? > type , final String defaultSchemaName ) { } }

implementation: 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 ;


signature:
public class DbMetaUtil { /** * Returns < code > true < / code > if class is annotated with < code > DbTable < / code > annotation . */
public static boolean resolveIsAnnotated ( final Class < ? > type ) { } }

implementation: DbTable dbTable = type . getAnnotation ( DbTable . class ) ; return dbTable != null ;


signature:
public class DbMetaUtil { /** * 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 . */
public static DbEntityColumnDescriptor resolveColumnDescriptors ( final DbEntityDescriptor dbEntityDescriptor , final PropertyDescriptor property , final boolean isAnnotated , final ColumnNamingStrategy columnNamingStrategy ) { } }

implementation:
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 ) ;


signature:
public class DbMetaUtil { /** * Resolves mapped types from { @ link jodd . db . oom . meta . DbMapTo } annotation . */
public static Class [ ] resolveMappedTypes ( final Class type ) { } }

implementation: DbMapTo dbMapTo = ( DbMapTo ) type . getAnnotation ( DbMapTo . class ) ; if ( dbMapTo == null ) { return null ; } return dbMapTo . value ( ) ;


signature:
public class DbMetaUtil { /** * - - - - - privates */
private static String quoteIfRequired ( final String name , final boolean alwaysQuoteNames , final char quoteChar ) { } }

implementation:
if ( StringUtil . detectQuoteChar ( name ) != 0 ) { return name ; // already quoted
} if ( alwaysQuoteNames && quoteChar != 0 ) { return quoteChar + name + quoteChar ; } return name ;


signature:
public class Threefish { /** * Initialize the cipher using the key and the tweak value .
 * @ param key the Threefish key to use
 * @ param tweak the tweak values to use */
public void init ( final long [ ] key , final long [ ] tweak ) { } }

implementation:
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 ] ;


signature:
public class Threefish { /** * 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 .
 * @ param p the initial plain text
 * @ param c the final value defined as value v { d } where d = N { r } */
public void blockEncrypt ( final long [ ] p , final long [ ] c ) { } }

implementation:
// 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 ] ; }


signature:
public class Threefish { /** * Implementation of the MIX function .
 * @ param j the index in the rotation constants
 * @ param d the round */
private void mix ( final int j , final int d ) { } }

implementation:
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 ] ;


signature:
public class Threefish { /** * 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 .
 * @ param c the cipher text
 * @ param p the plain text */
public void blockDecrypt ( final long [ ] c , final long [ ] p ) { } }

implementation:
// 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 ] ; }


signature:
public class Threefish { /** * Implementation of the un - MIX function . */
private void demix ( final int j , final int d ) { } }

implementation:
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 ] ;


signature:
public class Threefish { /** * Creates the subkeys .
 * @ param s the value of the round devided by 4 */
private void keySchedule ( final int s ) { } }

implementation:
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 ; } }


signature:
public class Threefish { /** * Initializes cipher in a simple way . */
public void init ( final String keyMessage , final long tweak1 , final long tweak2 ) { } }

implementation: 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 ) ;


signature:
public class Threefish { /** * Encrypts a block . */
@ Override public byte [ ] encryptBlock ( final byte [ ] content , final int offset ) { } }

implementation: long [ ] contentBlock = bytesToLongs ( content , offset , blockSizeInBytes ) ; long [ ] encryptedBlock = new long [ blockSize / Long . SIZE ] ; blockEncrypt ( contentBlock , encryptedBlock ) ; return longsToBytes ( encryptedBlock ) ;


signature:
public class Threefish { /** * Converts segment of byte array into long array . */
protected static long [ ] bytesToLongs ( final byte [ ] ba , final int offset , final int size ) { } }

implementation: 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 ;


signature:
public class MathUtil { /** * Converts char digit into integer value .
 * Accepts numeric chars ( 0 - 9 ) as well as letter ( A - z ) . */
public static int parseDigit ( final char digit ) { } }

implementation: if ( ( digit >= '0' ) && ( digit <= '9' ) ) { return digit - '0' ; } if ( CharUtil . isLowercaseAlpha ( digit ) ) { return 10 + digit - 'a' ; } return 10 + digit - 'A' ;


signature:
public class MadvocServletFilter { /** * Filter initialization . */
@ Override public void init ( final FilterConfig filterConfig ) throws ServletException { } }

implementation: 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." ) ;


signature:
public class MadvocServletFilter { /** * Builds { @ link ActionRequest } and invokes it . If action result is a chain , it repeats the process . */
@ Override public void doFilter ( final ServletRequest req , final ServletResponse res , final FilterChain chain ) throws IOException , ServletException { } }

implementation:
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 ) ; } }


signature:
public class RFC2822AddressParser { /** * Parses email address . Returns { @ link ParsedAddress parsed address } , that might be valid or not . */
public ParsedAddress parse ( String email ) { } }

implementation:
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 ) ;


signature:
public class RFC2822AddressParser { /** * Convenient shortcut of { @ link # parse ( String ) } that returns { @ code InternetAddress } or { @ code null } . */
public InternetAddress parseToInternetAddress ( final String email ) { } }

implementation: final ParsedAddress parsedAddress = parse ( email ) ; if ( ! parsedAddress . isValid ( ) ) { return null ; } return parsedAddress . getInternetAddress ( ) ;


signature:
public class RFC2822AddressParser { /** * Convenient shortcut of { @ link # parse ( String ) } that returns { @ link EmailAddress } or { @ code null } . */
public EmailAddress parseToEmailAddress ( final String email ) { } }

implementation: final ParsedAddress parsedAddress = parse ( email ) ; if ( ! parsedAddress . isValid ( ) ) { return null ; } return new EmailAddress ( parsedAddress . getPersonalName ( ) , parsedAddress . getLocalPart ( ) + '@' + parsedAddress . getDomain ( ) ) ;


signature:
public class RFC2822AddressParser { /** * Builds all regexp patterns . */
private void buildPatterns ( ) { } }

implementation:
// 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 ) ;


signature:
public class RFC2822AddressParser { /** * - - - - - utilities */
private InternetAddress pullFromGroups ( final Matcher m ) { } }

implementation:
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 ;


signature:
public class RFC2822AddressParser { /** * Given a string , extract the first matched comment token as defined in 2822 , trimmed ;
 * return null on all errors or non - findings .
 * 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 ? */
private String getFirstComment ( final String text ) { } }

implementation:
if ( text == null ) { return null ; // important
} final Matcher m = _COMMENT_PATTERN . matcher ( text ) ; if ( ! m . find ( ) ) { return null ; } return m . group ( ) . trim ( ) ; // must trim


signature:
public class RFC2822AddressParser { /** * If the string starts and ends with start and end char , remove them ,
 * otherwise return the string as it was passed in . */
private static String removeAnyBounding ( final char s , final char e , final String str ) { } }

implementation: 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 ;


signature:
public class PathResult { /** * Wraps action class and returns < code > MethRef < / code > object
 * ( proxified target ) so user can choose the method . */
protected < T > Methref < T > wrapTargetToMethref ( final Class < T > target ) { } }

implementation: return Methref . on ( target ) ;


signature:
public class PathResult { /** * Returns path value . */
public String path ( ) { } }

implementation: if ( methref != null ) { final String methodName = methref . ref ( ) ; return target . getName ( ) + '#' + methodName ; } return path ;


signature:
public class ZipUtil { /** * Compresses a file into zlib archive . */
public static File zlib ( final File file ) throws IOException { } }

implementation: 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 ) ;


signature:
public class ZipUtil { /** * Compresses a file into gzip archive . */
public static File gzip ( final File file ) throws IOException { } }

implementation: 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 ) ;


signature:
public class ZipUtil { /** * Decompress gzip archive . */
public static File ungzip ( final File file ) throws IOException { } }

implementation: 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 ;


signature:
public class ZipUtil { /** * Zips a file or a folder . If adding a folder , all its content will be added . */
public static File zip ( final File file ) throws IOException { } }

implementation: String zipFile = file . getAbsolutePath ( ) + ZIP_EXT ; return ZipBuilder . createZipFile ( zipFile ) . add ( file ) . recursive ( ) . save ( ) . toZipFile ( ) ;


signature:
public class ZipUtil { /** * Lists zip content . */
public static List < String > listZip ( final File zipFile ) throws IOException { } }

implementation: 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 ) ;


signature:
public class ZipUtil { /** * Extracts zip file content to the target directory .
 * @ see # unzip ( java . io . File , java . io . File , String . . . ) */
public static void unzip ( final String zipFile , final String destDir , final String ... patterns ) throws IOException { } }

implementation: unzip ( new File ( zipFile ) , new File ( destDir ) , patterns ) ;


signature:
public class ZipUtil { /** * Adds single entry to ZIP output stream .
 * @ param zos zip output stream
 * @ param file file or folder to add
 * @ param path relative path of file entry ; if < code > null < / code > files name will be used instead
 * @ param comment optional comment
 * @ param recursive when set to < code > true < / code > content of added folders will be added , too */
public static void addToZip ( final ZipOutputStream zos , final File file , String path , final String comment , final boolean recursive ) throws IOException { } }

implementation:
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 ) ; } } }


signature:
public class ZipUtil { /** * Adds byte content into the zip as a file . */
public static void addToZip ( final ZipOutputStream zos , final byte [ ] content , String path , final String comment ) throws IOException { } }

implementation: 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 ( ) ;


signature:
public class ClassDescriptor { /** * Returns field descriptor . */
public FieldDescriptor getFieldDescriptor ( final String name , final boolean declared ) { } }

implementation: final FieldDescriptor fieldDescriptor = getFields ( ) . getFieldDescriptor ( name ) ; if ( fieldDescriptor != null ) { if ( ! fieldDescriptor . matchDeclared ( declared ) ) { return null ; } } return fieldDescriptor ;


signature:
public class ClassDescriptor { /** * Returns { @ link MethodDescriptor method descriptor } identified by name and parameters . */
public MethodDescriptor getMethodDescriptor ( final String name , final boolean declared ) { } }

implementation: final MethodDescriptor methodDescriptor = getMethods ( ) . getMethodDescriptor ( name ) ; if ( ( methodDescriptor != null ) && methodDescriptor . matchDeclared ( declared ) ) { return methodDescriptor ; } return methodDescriptor ;


signature:
public class ClassDescriptor { /** * Returns property descriptor . Declared flag is matched on both read and write
 * methods . */
public PropertyDescriptor getPropertyDescriptor ( final String name , final boolean declared ) { } }

implementation: PropertyDescriptor propertyDescriptor = getProperties ( ) . getPropertyDescriptor ( name ) ; if ( ( propertyDescriptor != null ) && propertyDescriptor . matchDeclared ( declared ) ) { return propertyDescriptor ; } return null ;


signature:
public class ClassDescriptor { /** * Returns the default ctor or < code > null < / code > if not found . */
public CtorDescriptor getDefaultCtorDescriptor ( final boolean declared ) { } }

implementation: CtorDescriptor defaultCtor = getCtors ( ) . getDefaultCtor ( ) ; if ( ( defaultCtor != null ) && defaultCtor . matchDeclared ( declared ) ) { return defaultCtor ; } return null ;


signature:
public class ClassDescriptor { /** * Returns the constructor identified by arguments or < code > null < / code > if not found . */
public CtorDescriptor getCtorDescriptor ( final Class [ ] args , final boolean declared ) { } }

implementation: CtorDescriptor ctorDescriptor = getCtors ( ) . getCtorDescriptor ( args ) ; if ( ( ctorDescriptor != null ) && ctorDescriptor . matchDeclared ( declared ) ) { return ctorDescriptor ; } return null ;


signature:
public class LocalizationUtil { /** * Sets bundle name for provided servlet request . */
public static void setRequestBundleName ( final ServletRequest request , final String bundleName ) { } }

implementation: if ( log . isDebugEnabled ( ) ) { log . debug ( "Bundle name for this request: " + bundleName ) ; } request . setAttribute ( REQUEST_BUNDLE_NAME_ATTR , bundleName ) ;


signature:
public class LocalizationUtil { /** * Saves Locale to HTTP session . */
public static void setSessionLocale ( final HttpSession session , final String localeCode ) { } }

implementation: if ( log . isDebugEnabled ( ) ) { log . debug ( "Locale stored to session: " + localeCode ) ; } Locale locale = Locale . forLanguageTag ( localeCode ) ; session . setAttribute ( SESSION_LOCALE_ATTR , locale ) ;


signature:
public class LocalizationUtil { /** * Returns current locale from session . */
public static Locale getSessionLocale ( final HttpSession session ) { } }

implementation: Locale locale = ( Locale ) session . getAttribute ( SESSION_LOCALE_ATTR ) ; return locale == null ? MESSAGE_RESOLVER . getFallbackLocale ( ) : locale ;


signature:
public class MadvocContextListener { /** * Creates new { @ link Madvoc } { @ link WebApp } that is configured
 * by context init parameters . */
@ Override public void contextInitialized ( final ServletContextEvent servletContextEvent ) { } }

implementation: ServletContext servletContext = servletContextEvent . getServletContext ( ) ; madvoc = new Madvoc ( ) ; madvoc . configureWith ( servletContext ) ; madvoc . startWebApplication ( servletContext ) ;


signature:
public class ParamManager { /** * Returns an array of param keys that belongs to provided bean .
 * Optionally resolves the value of returned parameters . */
public String [ ] filterParametersForBeanName ( String beanName , final boolean resolveReferenceParams ) { } }

implementation:
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 ] ) ; }


signature: public class AnnotationWriter { @ Override public void visit ( final String name , final Object value ) { } }

implementation:
// 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 ( 's' , symbolTable . addConstantUtf8 ( ( String ) value ) ) ; } else if ( value instanceof Byte ) { annotation . put12 ( 'B' , symbolTable . addConstantInteger ( ( ( Byte ) value ) . byteValue ( ) ) . index ) ; } else if ( value instanceof Boolean ) { int booleanValue = ( ( Boolean ) value ) . booleanValue ( ) ? 1 : 0 ; annotation . put12 ( 'Z' , symbolTable . addConstantInteger ( booleanValue ) . index ) ; } else if ( value instanceof Character ) { annotation . put12 ( 'C' , symbolTable . addConstantInteger ( ( ( Character ) value ) . charValue ( ) ) . index ) ; } else if ( value instanceof Short ) { annotation . put12 ( 'S' , symbolTable . addConstantInteger ( ( ( Short ) value ) . shortValue ( ) ) . index ) ; } else if ( value instanceof Type ) { annotation . put12 ( 'c' , symbolTable . addConstantUtf8 ( ( ( Type ) value ) . getDescriptor ( ) ) ) ; } else if ( value instanceof byte [ ] ) { byte [ ] byteArray = ( byte [ ] ) value ; annotation . put12 ( '[' , byteArray . length ) ; for ( byte byteValue : byteArray ) { annotation . put12 ( 'B' , 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 ( 'C' , 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 ( 'F' , symbolTable . addConstantFloat ( floatValue ) . index ) ; } } else if ( value instanceof double [ ] ) { double [ ] doubleArray = ( double [ ] ) value ; annotation . put12 ( '[' , doubleArray . length ) ; for ( double doubleValue : doubleArray ) { annotation . put12 ( 'D' , 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 ( 'e' , 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 ) ;


signature:
public class AnnotationWriter { /** * 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 ) .
 * @ param attributeName one of " Runtime [ In ] Visible [ Type ] Annotations " , or null .
 * @ return the size in bytes of a Runtime [ In ] Visible [ Type ] Annotations attribute containing this
 * annotation and all its predecessors . This includes the size of the attribute _ name _ index and
 * attribute _ length fields . */
int computeAnnotationsSize ( final String attributeName ) { } }

implementation:
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 ;


signature:
public class AnnotationWriter { /** * 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 .
 * @ param attributeNameIndex the constant pool index of the attribute name ( one of
 * " Runtime [ In ] Visible [ Type ] Annotations " ) .
 * @ param output where the attribute must be put . */
void putAnnotations ( final int attributeNameIndex , final ByteVector output ) { } }

implementation:
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 ; }


signature:
public class AnnotationWriter { /** * 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 .
 * @ param attributeName one of " Runtime [ In ] VisibleParameterAnnotations " .
 * @ param annotationWriters an array of AnnotationWriter lists ( designated by their < i > last < / i >
 * element ) .
 * @ param annotableParameterCount the number of elements in annotationWriters to take into account
 * ( elements [ 0 . . annotableParameterCount [ are taken into account ) .
 * @ return the size in bytes of a Runtime [ In ] VisibleParameterAnnotations attribute corresponding
 * to the given sub - array of AnnotationWriter lists . This includes the size of the
 * attribute _ name _ index and attribute _ length fields . */
static int computeParameterAnnotationsSize ( final String attributeName , final AnnotationWriter [ ] annotationWriters , final int annotableParameterCount ) { } }

implementation:
// 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 ;


signature:
public class AnnotationWriter { /** * Puts a Runtime [ In ] VisibleParameterAnnotations attribute containing all the annotation lists
 * from the given AnnotationWriter sub - array in the given ByteVector .
 * @ param attributeNameIndex constant pool index of the attribute name ( one of
 * Runtime [ In ] VisibleParameterAnnotations ) .
 * @ param annotationWriters an array of AnnotationWriter lists ( designated by their < i > last < / i >
 * element ) .
 * @ param annotableParameterCount the number of elements in annotationWriters to put ( elements
 * [ 0 . . annotableParameterCount [ are put ) .
 * @ param output where the attribute must be put . */
static void putParameterAnnotations ( final int attributeNameIndex , final AnnotationWriter [ ] annotationWriters , final int annotableParameterCount , final ByteVector output ) { } }

implementation:
// 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 ; } }


signature:
public class PropsEntries { /** * Enables profiles to iterate . */
public PropsEntries profile ( final String ... profiles ) { } }

implementation: if ( profiles == null ) { return this ; } for ( String profile : profiles ) { addProfiles ( profile ) ; } return this ;


signature:
public class MurmurHash3 { /** * Gets a long from a byte buffer in little endian byte order . */
public static long getLongLittleEndian ( final byte [ ] buf , final int offset ) { } }

implementation:
return ( ( long ) buf [ offset + 7 ] << 56 ) // no mask needed
| ( ( buf [ offset + 6 ] & 0xffL ) << 48 ) | ( ( buf [ offset + 5 ] & 0xffL ) << 40 ) | ( ( buf [ offset + 4 ] & 0xffL ) << 32 ) | ( ( buf [ offset + 3 ] & 0xffL ) << 24 ) | ( ( buf [ offset + 2 ] & 0xffL ) << 16 ) | ( ( buf [ offset + 1 ] & 0xffL ) << 8 ) | ( ( buf [ offset ] & 0xffL ) ) ; // no shift needed


signature:
public class MurmurHash3 { /** * Returns the MurmurHash3 _ x64_128 hash . */
public static HashValue murmurhash3_x64_128 ( final byte [ ] key , final int offset , final int len , final int seed ) { } }

implementation:
// 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 & 0x00000000FFFFFFFFL ; long h2 = seed & 0x00000000FFFFFFFFL ; final long c1 = 0x87c37b91114253d5L ; final long c2 = 0x4cf5ad432745937fL ; 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 ] & 0xffL ) << 48 ; case 14 : k2 |= ( key [ roundedEnd + 13 ] & 0xffL ) << 40 ; case 13 : k2 |= ( key [ roundedEnd + 12 ] & 0xffL ) << 32 ; case 12 : k2 |= ( key [ roundedEnd + 11 ] & 0xffL ) << 24 ; case 11 : k2 |= ( key [ roundedEnd + 10 ] & 0xffL ) << 16 ; case 10 : k2 |= ( key [ roundedEnd + 9 ] & 0xffL ) << 8 ; case 9 : k2 |= ( key [ roundedEnd + 8 ] & 0xffL ) ; 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 ] & 0xffL ) << 48 ; case 6 : k1 |= ( key [ roundedEnd + 5 ] & 0xffL ) << 40 ; case 5 : k1 |= ( key [ roundedEnd + 4 ] & 0xffL ) << 32 ; case 4 : k1 |= ( key [ roundedEnd + 3 ] & 0xffL ) << 24 ; case 3 : k1 |= ( key [ roundedEnd + 2 ] & 0xffL ) << 16 ; case 2 : k1 |= ( key [ roundedEnd + 1 ] & 0xffL ) << 8 ; case 1 : k1 |= ( key [ roundedEnd ] & 0xffL ) ; 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 ) ;


signature:
public class ClassReader { /** * Reads the given input stream and returns its content as a byte array .
 * @ param inputStream an input stream .
 * @ param close true to close the input stream after reading .
 * @ return the content of the given input stream .
 * @ throws IOException if a problem occurs during reading . */
private static byte [ ] readStream ( final InputStream inputStream , final boolean close ) throws IOException { } }

implementation: 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 ( ) ; } }


signature:
public class ClassReader { /** * Returns the internal names of the implemented interfaces ( see { @ link Type # getInternalName ( ) } ) .
 * @ return the internal names of the directly implemented interfaces . Inherited implemented
 * interfaces are not returned .
 * @ see ClassVisitor # visit ( int , int , String , String , String , String [ ] ) */
public String [ ] getInterfaces ( ) { } }

implementation:
// 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 ;