signature:
public class ProcessRunner { /** * Executes a process and returns the process output and exit code . */
public static ProcessResult run ( final Process process ) throws InterruptedException { } }

implementation: final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; final StreamGobbler outputGobbler = new StreamGobbler ( process . getInputStream ( ) , baos , OUTPUT_PREFIX ) ; final StreamGobbler errorGobbler = new StreamGobbler ( process . getErrorStream ( ) , baos , ERROR_PREFIX ) ; outputGobbler . start ( ) ; errorGobbler . start ( ) ; final int result = process . waitFor ( ) ; outputGobbler . waitFor ( ) ; errorGobbler . waitFor ( ) ; return new ProcessResult ( result , baos . toString ( ) ) ;


signature:
public class ImapSslServer { /** * Returns email store .
 * @ param session { @ link Session }
 * @ return { @ link com . sun . mail . imap . IMAPSSLStore } */
@ Override protected IMAPSSLStore getStore ( final Session session ) { } }

implementation: SimpleAuthenticator simpleAuthenticator = ( SimpleAuthenticator ) authenticator ; final URLName url ; if ( simpleAuthenticator == null ) { url = new URLName ( PROTOCOL_IMAP , host , port , StringPool . EMPTY , null , null ) ; } else { final PasswordAuthentication pa = simpleAuthenticator . getPasswordAuthentication ( ) ; url = new URLName ( PROTOCOL_IMAP , host , port , StringPool . EMPTY , pa . getUserName ( ) , pa . getPassword ( ) ) ; } return new IMAPSSLStore ( session , url ) ;


signature:
public class PathQuery { /** * Returns < code > true < / code > if path matches the query . */
public boolean matches ( final Path path ) { } }

implementation: int exprNdx = 0 ; int pathNdx = 0 ; int pathLen = path . length ( ) ; int exprLen = expression . length ; while ( pathNdx < pathLen ) { CharSequence current = path . get ( pathNdx ) ; if ( exprNdx < exprLen && expression [ exprNdx ] . equals ( STAR ) ) { exprNdx ++ ; } else if ( exprNdx < exprLen && expression [ exprNdx ] . contentEquals ( current ) ) { pathNdx ++ ; exprNdx ++ ; } else if ( exprNdx - 1 >= 0 && expression [ exprNdx - 1 ] . equals ( STAR ) ) { pathNdx ++ ; } else { return false ; } } if ( exprNdx > 0 && expression [ exprNdx - 1 ] . equals ( STAR ) ) { return pathNdx >= pathLen && exprNdx >= exprLen ; } else { return pathLen != 0 && pathNdx >= pathLen && ( included || exprNdx >= exprLen ) ; }


signature:
public class GzipResponseWrapper { /** * Creates and returns a ServletOutputStream to write the content associated
 * with this Response . */
public ServletOutputStream createOutputStream ( ) throws IOException { } }

implementation: GzipResponseStream gzstream = new GzipResponseStream ( origResponse ) ; gzstream . setBuffer ( threshold ) ; return gzstream ;


signature:
public class AssertValidConstraint { /** * Invokes validation on inner context . Always returns < code > true < / code > since
 * inner context violations will be appended to provided validator . */
@ Override public boolean isValid ( final ValidationConstraintContext vcc , final Object value ) { } }

implementation: if ( value == null ) { return true ; } vcc . validateWithin ( targetValidationContext , value ) ; return true ;


signature:
public class URLSqlType { /** * { @ inheritDoc } */
@ Override public URL get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return rs . getURL ( index ) ;


signature:
public class URLSqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final URL value , final int dbSqlType ) throws SQLException { } }

implementation: st . setURL ( index , value ) ;


signature:
public class ReferenceChunk { /** * - - - - - process */
@ Override public void process ( final StringBuilder out ) { } }

implementation: final DbEntityDescriptor ded ; if ( tableRef != null ) { ded = lookupTableRef ( tableRef ) ; final String tableName = resolveTable ( tableRef , ded ) ; out . append ( tableName ) ; } else { ded = findColumnRef ( columnRef ) ; } if ( onlyId ) { if ( tableRef != null ) { out . append ( '.' ) ; } out . append ( ded . getIdColumnName ( ) ) ; } else if ( columnRef != null ) { DbEntityColumnDescriptor dec = ded . findByPropertyName ( columnRef ) ; templateData . lastColumnDec = dec ; if ( dec == null ) { throw new DbSqlBuilderException ( "Invalid column reference: [" + tableRef + '.' + columnRef + "]" ) ; } if ( tableRef != null ) { out . append ( '.' ) ; } out . append ( dec . getColumnNameForQuery ( ) ) ; }


signature:
public class ColumnsSelectChunk { /** * Counts actual real hints . */
@ Override public void init ( final TemplateData templateData ) { } }

implementation: super . init ( templateData ) ; if ( hint != null ) { templateData . incrementHintsCount ( ) ; }


signature:
public class ColumnsSelectChunk { /** * Appends alias . */
protected void appendAlias ( final StringBuilder query , final DbEntityDescriptor ded , final DbEntityColumnDescriptor dec ) { } }

implementation: final ColumnAliasType columnAliasType = templateData . getColumnAliasType ( ) ; if ( columnAliasType == null || columnAliasType == ColumnAliasType . TABLE_REFERENCE ) { final String tableName = ded . getTableName ( ) ; final String columnName = dec . getColumnNameForQuery ( ) ; templateData . registerColumnDataForTableRef ( tableRef , tableName ) ; query . append ( tableRef ) . append ( columnAliasSeparator ) . append ( columnName ) ; } else if ( columnAliasType == ColumnAliasType . COLUMN_CODE ) { final String tableName = ded . getTableName ( ) ; final String columnName = dec . getColumnName ( ) ; final String code = templateData . registerColumnDataForColumnCode ( tableName , columnName ) ; query . append ( code ) ; } else if ( columnAliasType == ColumnAliasType . TABLE_NAME ) { final String tableName = ded . getTableNameForQuery ( ) ; final String columnName = dec . getColumnNameForQuery ( ) ; query . append ( tableName ) . append ( columnAliasSeparator ) . append ( columnName ) ; }


signature:
public class ColumnsSelectChunk { /** * Simply appends column name with optional table reference and alias . */
protected void appendColumnName ( final StringBuilder query , final DbEntityDescriptor ded , final DbEntityColumnDescriptor dec ) { } }

implementation:
query . append ( resolveTable ( tableRef , ded ) ) . append ( '.' ) . append ( dec . getColumnName ( ) ) ; if ( templateData . getColumnAliasType ( ) != null ) { // create column aliases
query . append ( AS ) ; switch ( templateData . getColumnAliasType ( ) ) { case TABLE_NAME : { final String tableName = ded . getTableNameForQuery ( ) ; query . append ( tableName ) . append ( columnAliasSeparator ) . append ( dec . getColumnNameForQuery ( ) ) ; break ; } case TABLE_REFERENCE : { final String tableName = ded . getTableName ( ) ; templateData . registerColumnDataForTableRef ( tableRef , tableName ) ; query . append ( tableRef ) . append ( columnAliasSeparator ) . append ( dec . getColumnNameForQuery ( ) ) ; break ; } case COLUMN_CODE : { final String tableName = ded . getTableName ( ) ; final String code = templateData . registerColumnDataForColumnCode ( tableName , dec . getColumnName ( ) ) ; query . append ( code ) ; break ; } } }


signature:
public class InExRules { /** * Adds a rule . Duplicates are not allowed and will be ignored . */
protected void addRule ( final D ruleDefinition , final boolean include ) { } }

implementation: if ( rules == null ) { rules = new ArrayList < > ( ) ; } if ( include ) { includesCount ++ ; } else { excludesCount ++ ; } Rule < R > newRule = new Rule < > ( makeRule ( ruleDefinition ) , include ) ; if ( rules . contains ( newRule ) ) { return ; } rules . add ( newRule ) ;


signature:
public class InExRules { /** * Matches value against the set of rules using provided white / black list mode . */
public boolean match ( final V value , final boolean blacklist ) { } }

implementation: if ( rules == null ) { return blacklist ; } boolean include = blacklist ; if ( include ) { include = processExcludes ( value , true ) ; include = processIncludes ( value , include ) ; } else { include = processIncludes ( value , false ) ; include = processExcludes ( value , include ) ; } return include ;


signature:
public class InExRules { /** * Applies rules on given flag . Flag is only changed if at least one rule
 * matched . Otherwise , the same value is returned . This way you can
 * chain several rules and have the rule engine change the flag
 * only when a rule is matched . */
public boolean apply ( final V value , final boolean blacklist , boolean flag ) { } }

implementation: if ( rules == null ) { return flag ; } if ( blacklist ) { flag = processExcludes ( value , flag ) ; flag = processIncludes ( value , flag ) ; } else { flag = processIncludes ( value , flag ) ; flag = processExcludes ( value , flag ) ; } return flag ;


signature:
public class InExRules { /** * Process includes rules . */
protected boolean processIncludes ( final V value , boolean include ) { } }

implementation: if ( includesCount > 0 ) { if ( ! include ) { for ( Rule < R > rule : rules ) { if ( ! rule . include ) { continue ; } if ( inExRuleMatcher . accept ( value , rule . value , true ) ) { include = true ; break ; } } } } return include ;


signature:
public class InExRules { /** * Process excludes rules . */
protected boolean processExcludes ( final V value , boolean include ) { } }

implementation: if ( excludesCount > 0 ) { if ( include ) { for ( Rule < R > rule : rules ) { if ( rule . include ) { continue ; } if ( inExRuleMatcher . accept ( value , rule . value , false ) ) { include = false ; break ; } } } } return include ;


signature:
public class InExRules { /** * Matches value against single rule . By default performs < code > equals < / code > on value
 * against the rule . */
@ Override public boolean accept ( final V value , final R rule , final boolean include ) { } }

implementation: return value . equals ( rule ) ;


signature:
public class PseudoClass { /** * Returns pseudo - class name from simple class name . */
public String getPseudoClassName ( ) { } }

implementation: String name = getClass ( ) . getSimpleName ( ) . toLowerCase ( ) ; name = name . replace ( '_' , '-' ) ; return name ;


signature:
public class SortedArrayList { /** * Adds an Object to sorted list . Object is inserted at correct place , found
 * using binary search . If the same item exist , it will be put to the end of
 * the range .
 * This method breaks original list contract since objects are not
 * added at the list end , but in sorted manner . */
@ Override public boolean add ( final E o ) { } }

implementation: int idx = 0 ; if ( ! isEmpty ( ) ) { idx = findInsertionPoint ( o ) ; } super . add ( idx , o ) ; return true ;


signature:
public class SortedArrayList { /** * Add all of the elements in the given collection to this list . */
@ Override public boolean addAll ( final Collection < ? extends E > c ) { } }

implementation: Iterator < ? extends E > i = c . iterator ( ) ; boolean changed = false ; while ( i . hasNext ( ) ) { boolean ret = add ( i . next ( ) ) ; if ( ! changed ) { changed = ret ; } } return changed ;


signature:
public class SortedArrayList { /** * Conducts a binary search to find the index where Object
 * should be inserted . */
protected int findInsertionPoint ( final E o , int low , int high ) { } }

implementation: while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int delta = compare ( get ( mid ) , o ) ; if ( delta > 0 ) { high = mid - 1 ; } else { low = mid + 1 ; } } return low ;


signature:
public class Log4j2Logger { /** * Converts Jodd logging level to JDK . */
private org . apache . logging . log4j . Level jodd2log4j2 ( final Logger . Level level ) { } }

implementation: switch ( level ) { case TRACE : return org . apache . logging . log4j . Level . TRACE ; case DEBUG : return org . apache . logging . log4j . Level . DEBUG ; case INFO : return org . apache . logging . log4j . Level . INFO ; case WARN : return org . apache . logging . log4j . Level . WARN ; case ERROR : return org . apache . logging . log4j . Level . ERROR ; default : throw new IllegalArgumentException ( ) ; }


signature:
public class AttributeSelector { /** * - - - - - match */
public boolean accept ( final Node node ) { } }

implementation:
if ( ! node . hasAttribute ( name ) ) { return false ; } if ( value == null ) { // just detect if attribute exist
return true ; } String nodeValue = node . getAttribute ( name ) ; if ( nodeValue == null ) { return false ; } return match . compare ( nodeValue , value ) ;


signature:
public class ActionConfigManager { /** * Registers action configuration for given annotation . New { @ link ActionConfig } is created
 * and stored . */
public void registerAnnotation ( final Class < ? extends Annotation > annotationType ) { } }

implementation: final ActionConfiguredBy actionConfiguredBy = annotationType . getAnnotation ( ActionConfiguredBy . class ) ; if ( actionConfiguredBy == null ) { throw new MadvocException ( "Action annotation is missing it's " + ActionConfiguredBy . class . getSimpleName ( ) + " configuration." ) ; } bindAnnotationConfig ( annotationType , actionConfiguredBy . value ( ) ) ;


signature:
public class ActionConfigManager { /** * Binds action annotation and the action config . This can overwrite the default annotation
 * configuration of an annotation . */
public void bindAnnotationConfig ( final Class < ? extends Annotation > annotationType , final Class < ? extends ActionConfig > actionConfigClass ) { } }

implementation:
final ActionConfig actionConfig = registerNewActionConfiguration ( actionConfigClass ) ; actionConfigs . put ( annotationType , actionConfig ) ; for ( final AnnotationParser annotationParser : annotationParsers ) { if ( annotationType . equals ( annotationParser . getAnnotationType ( ) ) ) { // parser already exists
return ; } } annotationParsers = ArraysUtil . append ( annotationParsers , new AnnotationParser ( annotationType , Action . class ) ) ;


signature:
public class ActionConfigManager { /** * Registers action configuration for given type . */
protected ActionConfig registerNewActionConfiguration ( final Class < ? extends ActionConfig > actionConfigClass ) { } }

implementation: final ActionConfig newActionConfig = createActionConfig ( actionConfigClass ) ; actionConfigs . put ( actionConfigClass , newActionConfig ) ; return newActionConfig ;


signature:
public class ActionConfigManager { /** * Lookup for the action configuration . Typically , the input argument is either the action type or annotation type . */
public ActionConfig lookup ( final Class actionTypeOrAnnotationType ) { } }

implementation: final ActionConfig actionConfig = actionConfigs . get ( actionTypeOrAnnotationType ) ; if ( actionConfig == null ) { throw new MadvocException ( "ActionConfiguration not registered:" + actionTypeOrAnnotationType . getName ( ) ) ; } return actionConfig ;


signature:
public class ActionConfigManager { /** * Fetch some action config and consumes it . */
public < T extends ActionConfig > void with ( final Class < T > actionConfigType , final Consumer < T > actionConfigConsumer ) { } }

implementation: final T actionConfig = ( T ) lookup ( actionConfigType ) ; actionConfigConsumer . accept ( actionConfig ) ;


signature:
public class ActionConfigManager { /** * Returns { @ code true } if annotated element as action annotation on it . */
public boolean hasActionAnnotationOn ( final AnnotatedElement annotatedElement ) { } }

implementation: for ( final AnnotationParser annotationParser : annotationParsers ) { if ( annotationParser . hasAnnotationOn ( annotatedElement ) ) { return true ; } } return false ;


signature:
public class MailSession { /** * Setups the system email properties . */
protected static void setupSystemMailProperties ( ) { } }

implementation: System . setProperty ( "mail.mime.encodefilename" , Boolean . valueOf ( Defaults . mailMimeEncodefilename ) . toString ( ) ) ; System . setProperty ( "mail.mime.decodefilename" , Boolean . valueOf ( Defaults . mailMimeDecodefilename ) . toString ( ) ) ;


signature:
public class ValidationConstraintContext { /** * Validates provided context and value withing this constraint content . */
public void validateWithin ( final ValidationContext vctx , final Object value ) { } }

implementation: vtor . validate ( vctx , value , name ) ;


signature:
public class HtmlFosterRules { /** * Returns < code > true < / code > if provided element is one of the table - related elements . */
protected boolean isOneOfTableElements ( final Element element ) { } }

implementation: String elementName = element . getNodeName ( ) . toLowerCase ( ) ; return StringUtil . equalsOne ( elementName , TABLE_ELEMENTS ) != - 1 ;


signature:
public class HtmlFosterRules { /** * Returns < code > true < / code > if given node is a table element . */
protected boolean isTableElement ( final Node node ) { } }

implementation: if ( node . getNodeType ( ) != Node . NodeType . ELEMENT ) { return false ; } String elementName = node . getNodeName ( ) . toLowerCase ( ) ; return elementName . equals ( "table" ) ;


signature:
public class HtmlFosterRules { /** * Returns < code > true < / code > if parent node is one of the table elements . */
protected boolean isParentNodeOneOfFosterTableElements ( final Node parentNode ) { } }

implementation: if ( parentNode == null ) { return false ; } if ( parentNode . getNodeName ( ) == null ) { return false ; } String nodeName = parentNode . getNodeName ( ) . toLowerCase ( ) ; return StringUtil . equalsOne ( nodeName , FOSTER_TABLE_ELEMENTS ) != - 1 ;


signature:
public class HtmlFosterRules { /** * Finds the last table in stack of open elements . */
protected Element findLastTable ( final Node node ) { } }

implementation: Node tableNode = node ; while ( tableNode != null ) { if ( tableNode . getNodeType ( ) == Node . NodeType . ELEMENT ) { String tableNodeName = tableNode . getNodeName ( ) . toLowerCase ( ) ; if ( tableNodeName . equals ( "table" ) ) { break ; } } tableNode = tableNode . getParentNode ( ) ; } return ( Element ) tableNode ;


signature:
public class HtmlFosterRules { /** * Finds foster elements . Returns < code > true < / code > if there was no change in
 * DOM tree of the parent element . Otherwise , returns < code > false < / code >
 * meaning that parent will scan its childs again . */
protected boolean findFosterNodes ( final Node node ) { } }

implementation:
boolean isTable = false ; if ( ! lastTables . isEmpty ( ) ) { // if inside table
if ( node . getNodeType ( ) == Node . NodeType . TEXT ) { String value = node . getNodeValue ( ) ; if ( ! StringUtil . isBlank ( value ) ) { if ( isParentNodeOneOfFosterTableElements ( node . getParentNode ( ) ) ) { fosterTexts . add ( ( Text ) node ) ; } } } } if ( node . getNodeType ( ) == Node . NodeType . ELEMENT ) { Element element = ( Element ) node ; isTable = isTableElement ( node ) ; if ( isTable ) { // if node is a table , add it to the stack - of - last - tables
lastTables . add ( element ) ; } else { // otherwise . . .
// . . . if inside the table
if ( ! lastTables . isEmpty ( ) ) { // check this and parent
Node parentNode = node . getParentNode ( ) ; if ( isParentNodeOneOfFosterTableElements ( parentNode ) && ! isOneOfTableElements ( element ) ) { String elementNodeName = element . getNodeName ( ) . toLowerCase ( ) ; if ( elementNodeName . equals ( "form" ) ) { if ( element . getChildNodesCount ( ) > 0 ) { // if form element , take all its child nodes
// and add after the from element
Node [ ] formChildNodes = element . getChildNodes ( ) ; parentNode . insertAfter ( formChildNodes , element ) ; return false ; } else { // empty form element , leave it where it is
return true ; } } if ( elementNodeName . equals ( "input" ) ) { String inputType = element . getAttribute ( "type" ) ; if ( inputType . equals ( "hidden" ) ) { // input hidden elements remains as they are
return true ; } } // foster element found , remember it to process it later
fosterElements . add ( element ) ; } } else { // . . . if not inside the table , just keep going
} } } allchilds : while ( true ) { int childs = node . getChildNodesCount ( ) ; for ( int i = 0 ; i < childs ; i ++ ) { Node childNode = node . getChild ( i ) ; boolean done = findFosterNodes ( childNode ) ; if ( ! done ) { continue allchilds ; } } break ; } if ( isTable ) { // remove last element
int size = lastTables . size ( ) ; if ( size > 0 ) { lastTables . remove ( size - 1 ) ; // no array copy occurs when the last element is removed
} } return true ;


signature:
public class HtmlFosterRules { /** * Performs the fix for elements . */
protected void fixElements ( ) { } }

implementation:
for ( Element fosterElement : fosterElements ) { // find parent table
Element lastTable = findLastTable ( fosterElement ) ; Node fosterElementParent = fosterElement . getParentNode ( ) ; // filter our foster element
Node [ ] fosterChilds = fosterElement . getChildNodes ( ) ; for ( Node fosterChild : fosterChilds ) { if ( fosterChild . getNodeType ( ) == Node . NodeType . ELEMENT ) { if ( isOneOfTableElements ( ( Element ) fosterChild ) ) { // move all child table elements outside
// the foster element
fosterChild . detachFromParent ( ) ; fosterElementParent . insertBefore ( fosterChild , fosterElement ) ; } } } // finally , move foster element above the table
fosterElement . detachFromParent ( ) ; lastTable . getParentNode ( ) . insertBefore ( fosterElement , lastTable ) ; }


signature:
public class LRUCache { /** * Prune only expired objects , < code > LinkedHashMap < / code > will take care of LRU if needed . */
@ Override protected int pruneCache ( ) { } }

implementation: if ( ! isPruneExpiredActive ( ) ) { return 0 ; } int count = 0 ; Iterator < CacheObject < K , V > > values = cacheMap . values ( ) . iterator ( ) ; while ( values . hasNext ( ) ) { CacheObject < K , V > co = values . next ( ) ; if ( co . isExpired ( ) ) { values . remove ( ) ; onRemove ( co . key , co . cachedObject ) ; count ++ ; } } return count ;


signature:
public class SessionScope { /** * Registers new session destroy callback if not already registered . */
protected Map < String , BeanData > registerSessionBeans ( final HttpSession httpSession ) { } }

implementation: SessionBeans sessionBeans = new SessionBeans ( ) ; httpSession . setAttribute ( SESSION_BEANS_NAME , sessionBeans ) ; return sessionBeans . getBeanMap ( ) ;


signature:
public class SessionScope { /** * Returns instance map from http session . */
@ SuppressWarnings ( "unchecked" ) protected Map < String , BeanData > getSessionMap ( final HttpSession session ) { } }

implementation: SessionBeans sessionBeans = ( SessionBeans ) session . getAttribute ( SESSION_BEANS_NAME ) ; if ( sessionBeans == null ) { return null ; } return sessionBeans . getBeanMap ( ) ;


signature:
public class SessionScope { /** * Returns request from current thread . */
protected HttpSession getCurrentHttpSession ( ) { } }

implementation: HttpServletRequest request = RequestContextListener . getRequest ( ) ; if ( request == null ) { throw new PetiteException ( "No HTTP request bound to the current thread. Is RequestContextListener registered?" ) ; } return request . getSession ( ) ;


signature:
public class WorkData { /** * Work data initialization . */
public void init ( String name , final String superName , final String suffix , final String reqProxyClassName ) { } }

implementation:
int lastSlash = name . lastIndexOf ( '/' ) ; this . targetPackage = lastSlash == - 1 ? StringPool . EMPTY : name . substring ( 0 , lastSlash ) . replace ( '/' , '.' ) ; this . targetClassname = name . substring ( lastSlash + 1 ) ; this . nextSupername = superName ; this . superName = name ; // create proxy name
if ( reqProxyClassName != null ) { if ( reqProxyClassName . startsWith ( DOT ) ) { name = name . substring ( 0 , lastSlash ) + '/' + reqProxyClassName . substring ( 1 ) ; } else if ( reqProxyClassName . endsWith ( DOT ) ) { name = reqProxyClassName . replace ( '.' , '/' ) + this . targetClassname ; } else { name = reqProxyClassName . replace ( '.' , '/' ) ; } } // add optional suffix
if ( suffix != null ) { name += suffix ; } this . thisReference = name ; this . superReference = this . superName ;


signature:
public class WorkData { /** * Saves used static initialization blocks ( clinit ) of advices . */
void addAdviceClinitMethod ( final String name ) { } }

implementation: if ( adviceClinits == null ) { adviceClinits = new ArrayList < > ( ) ; } adviceClinits . add ( name ) ;


signature:
public class WorkData { /** * Saves used constructors of advices . */
void addAdviceInitMethod ( final String name ) { } }

implementation: if ( adviceInits == null ) { adviceInits = new ArrayList < > ( ) ; } adviceInits . add ( name ) ;


signature:
public class ByteSqlType { /** * { @ inheritDoc } */
@ Override public Byte get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return Byte . valueOf ( rs . getByte ( index ) ) ;


signature:
public class ByteSqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final Byte value , final int dbSqlType ) throws SQLException { } }

implementation: st . setByte ( index , value . byteValue ( ) ) ;


signature:
public class BundleAction { /** * Process links . Returns bundle link if this is the first resource
 * of the same type . Otherwise , returns < code > null < / code > indicating
 * that collection is going on and the original link should be removed . */
public String processLink ( final String src ) { } }

implementation:
if ( newAction ) { if ( bundleId == null ) { bundleId = bundlesManager . registerNewBundleId ( ) ; bundleId += '.' + bundleContentType ; } sources . add ( src ) ; } if ( firstScriptTag ) { // this is the first tag , change the url to point to the bundle
firstScriptTag = false ; return buildStaplerUrl ( ) ; } else { // ignore all other script tags
return null ; }


signature:
public class BundleAction { /** * Called on end of parsing . */
public void end ( ) { } }

implementation: if ( newAction ) { bundleId = bundlesManager . registerBundle ( contextPath , actionPath , bundleId , bundleContentType , sources ) ; }


signature:
public class BundleAction { /** * Replaces bundle marker with calculated bundle id .
 * Used for < code > RESOURCE _ ONLY < / code > strategy . */
public char [ ] replaceBundleId ( final char [ ] content ) { } }

implementation: if ( strategy == ACTION_MANAGED || bundleId == null ) { return content ; } int index = ArraysUtil . indexOf ( content , bundleIdMark ) ; if ( index == - 1 ) { return content ; } char [ ] bundleIdChars = bundleId . toCharArray ( ) ; char [ ] result = new char [ content . length - bundleIdMark . length + bundleIdChars . length ] ; System . arraycopy ( content , 0 , result , 0 , index ) ; System . arraycopy ( bundleIdChars , 0 , result , index , bundleIdChars . length ) ; System . arraycopy ( content , index + bundleIdMark . length , result , index + bundleIdChars . length , content . length - bundleIdMark . length - index ) ; return result ;


signature:
public class PropsConverter { /** * Convert Java Properties to Jodd Props format .
 * @ param writer Writer to write Props formatted file content to
 * @ param properties Properties to convert to Props format
 * @ throws IOException On any I / O error when writing to the writer */
public static void convert ( final Writer writer , final Properties properties ) throws IOException { } }

implementation: convert ( writer , properties , Collections . emptyMap ( ) ) ;


signature:
public class PropsConverter { /** * Convert Java Properties to Jodd Props format .
 * @ param writer Writer to write Props formatted file content to
 * @ param properties Properties to convert to Props format
 * @ param profiles Properties per profile to convert and add to the Props format
 * @ throws IOException On any I / O error when writing to the writer */
public static void convert ( final Writer writer , final Properties properties , final Map < String , Properties > profiles ) throws IOException { } }

implementation: final PropertiesToProps toProps = new PropertiesToProps ( ) ; toProps . convertToWriter ( writer , properties , profiles ) ;


signature:
public class PropsParser { /** * Loads properties . */
public void parse ( final String in ) { } }

implementation:
ParseState state = ParseState . TEXT ; ParseState stateOnEscape = null ; boolean insideSection = false ; String currentSection = null ; String key = null ; Operator operator = Operator . ASSIGN ; final StringBuilder sb = new StringBuilder ( ) ; final int len = in . length ( ) ; int ndx = 0 ; while ( ndx < len ) { final char c = in . charAt ( ndx ) ; ndx ++ ; if ( state == ParseState . COMMENT ) { // comment , skip to the end of the line
if ( c == '\r' ) { if ( ( ndx < len ) && ( in . charAt ( ndx ) == '\n' ) ) { ndx ++ ; } state = ParseState . TEXT ; } else if ( c == '\n' ) { state = ParseState . TEXT ; } } else if ( state == ParseState . ESCAPE ) { state = stateOnEscape ; // ParseState . VALUE ;
switch ( c ) { case '\r' : if ( ( ndx < len ) && ( in . charAt ( ndx ) == '\n' ) ) { ndx ++ ; } case '\n' : // need to go 1 step back in order to escape
// the current line ending in the follow - up state
ndx -- ; state = ParseState . ESCAPE_NEWLINE ; break ; // encode UTF character
case 'u' : int value = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { final char hexChar = in . charAt ( ndx ++ ) ; if ( CharUtil . isDigit ( hexChar ) ) { value = ( value << 4 ) + hexChar - '0' ; } else if ( hexChar >= 'a' && hexChar <= 'f' ) { value = ( value << 4 ) + 10 + hexChar - 'a' ; } else if ( hexChar >= 'A' && hexChar <= 'F' ) { value = ( value << 4 ) + 10 + hexChar - 'A' ; } else { throw new IllegalArgumentException ( "Malformed \\uXXXX encoding." ) ; } } sb . append ( ( char ) value ) ; break ; case 't' : sb . append ( '\t' ) ; break ; case 'n' : sb . append ( '\n' ) ; break ; case 'r' : sb . append ( '\r' ) ; break ; case 'f' : sb . append ( '\f' ) ; break ; default : sb . append ( c ) ; } } else if ( state == ParseState . TEXT ) { switch ( c ) { case '\\' : // escape char , take the next char as is
stateOnEscape = state ; state = ParseState . ESCAPE ; break ; // start section
case '[' : if ( sb . length ( ) > 0 ) { if ( StringUtil . isNotBlank ( sb ) ) { sb . append ( c ) ; // previous string is not blank , hence it ' s not the section
break ; } } sb . setLength ( 0 ) ; insideSection = true ; break ; // end section
case ']' : if ( insideSection ) { currentSection = sb . toString ( ) . trim ( ) ; sb . setLength ( 0 ) ; insideSection = false ; if ( currentSection . length ( ) == 0 ) { currentSection = null ; } } else { sb . append ( c ) ; } break ; case '#' : case ';' : state = ParseState . COMMENT ; break ; // copy operator
case '<' : if ( ndx == len || in . charAt ( ndx ) != '=' ) { sb . append ( c ) ; break ; } operator = Operator . COPY ; // ndx + + ;
continue ; // assignment operator
case '+' : if ( ndx == len || in . charAt ( ndx ) != '=' ) { sb . append ( c ) ; break ; } operator = Operator . QUICK_APPEND ; // ndx + + ;
continue ; case '=' : case ':' : if ( key == null ) { key = sb . toString ( ) . trim ( ) ; sb . setLength ( 0 ) ; } else { sb . append ( c ) ; } state = ParseState . VALUE ; break ; case '\r' : case '\n' : add ( currentSection , key , sb , true , operator ) ; sb . setLength ( 0 ) ; key = null ; operator = Operator . ASSIGN ; break ; case ' ' : case '\t' : // ignore whitespaces
break ; default : sb . append ( c ) ; } } else { switch ( c ) { case '\\' : // escape char , take the next char as is
stateOnEscape = state ; state = ParseState . ESCAPE ; break ; case '\r' : if ( ( ndx < len ) && ( in . charAt ( ndx ) == '\n' ) ) { ndx ++ ; } case '\n' : if ( state == ParseState . ESCAPE_NEWLINE ) { sb . append ( escapeNewLineValue ) ; if ( ! ignorePrefixWhitespacesOnNewLine ) { state = ParseState . VALUE ; } } else { add ( currentSection , key , sb , true , operator ) ; sb . setLength ( 0 ) ; key = null ; operator = Operator . ASSIGN ; // end of value , continue to text
state = ParseState . TEXT ; } break ; case ' ' : case '\t' : if ( state == ParseState . ESCAPE_NEWLINE ) { break ; } default : sb . append ( c ) ; state = ParseState . VALUE ; if ( multilineValues ) { if ( sb . length ( ) == 3 ) { // check for ' ' ' beginning
if ( sb . toString ( ) . equals ( "'''" ) ) { sb . setLength ( 0 ) ; int endIndex = in . indexOf ( "'''" , ndx ) ; if ( endIndex == - 1 ) { endIndex = in . length ( ) ; } sb . append ( in , ndx , endIndex ) ; // append
add ( currentSection , key , sb , false , operator ) ; sb . setLength ( 0 ) ; key = null ; operator = Operator . ASSIGN ; // end of value , continue to text
state = ParseState . TEXT ; ndx = endIndex + 3 ; } } } } } } if ( key != null ) { add ( currentSection , key , sb , true , operator ) ; }


signature:
public class PropsParser { /** * Adds accumulated value to key and current section . */
protected void add ( final String section , final String key , final StringBuilder value , final boolean trim , final Operator operator ) { } }

implementation:
// ignore lines without : or =
if ( key == null ) { return ; } String fullKey = key ; if ( section != null ) { if ( fullKey . length ( ) != 0 ) { fullKey = section + '.' + fullKey ; } else { fullKey = section ; } } String v = value . toString ( ) ; if ( trim ) { if ( valueTrimLeft && valueTrimRight ) { v = v . trim ( ) ; } else if ( valueTrimLeft ) { v = StringUtil . trimLeft ( v ) ; } else { v = StringUtil . trimRight ( v ) ; } } if ( v . length ( ) == 0 && skipEmptyProps ) { return ; } extractProfilesAndAdd ( fullKey , v , operator ) ;


signature:
public class PropsParser { /** * Extracts profiles from the key name and adds key - value to them . */
protected void extractProfilesAndAdd ( final String key , final String value , final Operator operator ) { } }

implementation:
String fullKey = key ; int ndx = fullKey . indexOf ( PROFILE_LEFT ) ; if ( ndx == - 1 ) { justAdd ( fullKey , value , null , operator ) ; return ; } // extract profiles
ArrayList < String > keyProfiles = new ArrayList < > ( ) ; while ( true ) { ndx = fullKey . indexOf ( PROFILE_LEFT ) ; if ( ndx == - 1 ) { break ; } final int len = fullKey . length ( ) ; int ndx2 = fullKey . indexOf ( PROFILE_RIGHT , ndx + 1 ) ; if ( ndx2 == - 1 ) { ndx2 = len ; } // remember profile
final String profile = fullKey . substring ( ndx + 1 , ndx2 ) ; keyProfiles . add ( profile ) ; // extract profile from key
ndx2 ++ ; final String right = ( ndx2 == len ) ? StringPool . EMPTY : fullKey . substring ( ndx2 ) ; fullKey = fullKey . substring ( 0 , ndx ) + right ; } if ( fullKey . startsWith ( StringPool . DOT ) ) { // check for special case when only profile is defined in section
fullKey = fullKey . substring ( 1 ) ; } // add value to extracted profiles
justAdd ( fullKey , value , keyProfiles , operator ) ;


signature:
public class PropsParser { /** * Core key - value addition . */
protected void justAdd ( final String key , final String value , final ArrayList < String > keyProfiles , final Operator operator ) { } }

implementation:
if ( operator == Operator . COPY ) { HashMap < String , Object > target = new HashMap < > ( ) ; String [ ] profiles = null ; if ( keyProfiles != null ) { profiles = keyProfiles . toArray ( new String [ 0 ] ) ; } String [ ] sources = StringUtil . splitc ( value , ',' ) ; for ( String source : sources ) { source = source . trim ( ) ; // try to extract profile for parsing
String [ ] lookupProfiles = profiles ; String lookupProfilesString = null ; int leftIndex = source . indexOf ( '<' ) ; if ( leftIndex != - 1 ) { int rightIndex = source . indexOf ( '>' ) ; lookupProfilesString = source . substring ( leftIndex + 1 , rightIndex ) ; source = source . substring ( 0 , leftIndex ) . concat ( source . substring ( rightIndex + 1 ) ) ; lookupProfiles = StringUtil . splitc ( lookupProfilesString , ',' ) ; StringUtil . trimAll ( lookupProfiles ) ; } String [ ] wildcards = new String [ ] { source + ".*" } ; propsData . extract ( target , lookupProfiles , wildcards , null ) ; for ( Map . Entry < String , Object > entry : target . entrySet ( ) ) { String entryKey = entry . getKey ( ) ; String suffix = entryKey . substring ( source . length ( ) ) ; String newKey = key + suffix ; String newValue = "${" + entryKey ; if ( lookupProfilesString != null ) { newValue += "<" + lookupProfilesString + ">" ; } newValue += "}" ; if ( profiles == null ) { propsData . putBaseProperty ( newKey , newValue , false ) ; } else { for ( final String p : profiles ) { propsData . putProfileProperty ( newKey , newValue , p , false ) ; } } } } return ; } boolean append = operator == Operator . QUICK_APPEND ; if ( keyProfiles == null ) { propsData . putBaseProperty ( key , value , append ) ; return ; } for ( final String p : keyProfiles ) { propsData . putProfileProperty ( key , value , p , append ) ; }


signature:
public class MutableShort { /** * Compares value of two same instances . */
@ Override public int compareTo ( final MutableShort other ) { } }

implementation: return value < other . value ? - 1 : ( value == other . value ? 0 : 1 ) ;


signature:
public class AsmUtil { /** * Converts bytecode - like description to java class name that can be loaded
 * with a classloader . Uses less - known feature of class loaders for loading
 * array classes .
 * @ see # typedescToSignature ( String , jodd . mutable . MutableInteger ) */
public static String typedesc2ClassName ( final String desc ) { } }

implementation:
String className = desc ; switch ( desc . charAt ( 0 ) ) { case 'B' : case 'C' : case 'D' : case 'F' : case 'I' : case 'J' : case 'S' : case 'Z' : case 'V' : if ( desc . length ( ) != 1 ) { throw new IllegalArgumentException ( INVALID_BASE_TYPE + desc ) ; } break ; case 'L' : className = className . substring ( 1 , className . length ( ) - 1 ) ; break ; case '[' : // uses less - known feature of class loaders for loading array types
// using bytecode - like signatures .
className = className . replace ( '/' , '.' ) ; break ; default : throw new IllegalArgumentException ( INVALID_TYPE_DESCRIPTION + desc ) ; } return className ;


signature:
public class AsmUtil { /** * Converts type reference to java - name . */
public static String typeref2Name ( final String desc ) { } }

implementation: if ( desc . charAt ( 0 ) != TYPE_REFERENCE ) { throw new IllegalArgumentException ( INVALID_TYPE_DESCRIPTION + desc ) ; } String name = desc . substring ( 1 , desc . length ( ) - 1 ) ; return name . replace ( '/' , '.' ) ;


signature:
public class AsmUtil { /** * Returns java - like signature of a bytecode - like description .
 * Only first description is parsed .
 * The field signature represents the value of an argument to a function or
 * the value of a variable . It is a series of bytes generated by the
 * following grammar :
 * < PRE > { @ code
 * < field _ signature > : : = < field _ type >
 * < field _ type > : : = < base _ type > | < object _ type > | < array _ type >
 * < base _ type > : : = B | C | D | F | I | J | S | Z
 * < object _ type > : : = L < fullclassname > ;
 * < array _ type > : : = [ < field _ type >
 * The meaning of the base types is as follows :
 * B byte signed byte
 * C char character
 * D double double precision IEEE float
 * F float single precision IEEE float
 * I int integer
 * J long long integer
 * L < fullclassname > ; . . . an object of the given class
 * S short signed short
 * Z boolean true or false
 * [ < field sig > . . . array
 * } < / PRE >
 * This method converts this string into a Java type declaration such as
 * < code > String [ ] < / code > . */
public static String typedescToSignature ( final String desc , final MutableInteger from ) { } }

implementation:
int fromIndex = from . get ( ) ; from . value ++ ; // default usage for most cases
switch ( desc . charAt ( fromIndex ) ) { case 'B' : return "byte" ; case 'C' : return "char" ; case 'D' : return "double" ; case 'F' : return "float" ; case 'I' : return "int" ; case 'J' : return "long" ; case 'S' : return "short" ; case 'Z' : return "boolean" ; case 'V' : return "void" ; case 'L' : int index = desc . indexOf ( ';' , fromIndex ) ; if ( index < 0 ) { throw new IllegalArgumentException ( INVALID_TYPE_DESCRIPTION + desc ) ; } from . set ( index + 1 ) ; String str = desc . substring ( fromIndex + 1 , index ) ; return str . replace ( '/' , '.' ) ; case 'T' : return desc . substring ( from . value ) ; case '[' : StringBuilder brackets = new StringBuilder ( ) ; int n = fromIndex ; while ( desc . charAt ( n ) == '[' ) { // count opening brackets
brackets . append ( "[]" ) ; n ++ ; } from . value = n ; String type = typedescToSignature ( desc , from ) ; // the rest of the string denotes a ` < field _ type > '
return type + brackets ; default : if ( from . value == 0 ) { throw new IllegalArgumentException ( INVALID_TYPE_DESCRIPTION + desc ) ; } // generics !
return desc . substring ( from . value ) ; }


signature:
public class AsmUtil { /** * Converts type to byteccode type ref . */
public static String typeToTyperef ( final Class type ) { } }

implementation: if ( ! type . isArray ( ) ) { if ( ! type . isPrimitive ( ) ) { return 'L' + typeToSignature ( type ) + ';' ; } if ( type == int . class ) { return "I" ; } if ( type == long . class ) { return "J" ; } if ( type == boolean . class ) { return "Z" ; } if ( type == double . class ) { return "D" ; } if ( type == float . class ) { return "F" ; } if ( type == short . class ) { return "S" ; } if ( type == void . class ) { return "V" ; } if ( type == byte . class ) { return "B" ; } if ( type == char . class ) { return "C" ; } } return type . getName ( ) ;


signature:
public class AsmUtil { /** * Converts < code > Integer < / code > object to an < code > int < / code > . */
public static void intValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_INTEGER ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_INTEGER , "intValue" , "()I" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Long < / code > object to a < code > long < / code > . */
public static void longValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_LONG ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_LONG , "longValue" , "()J" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Float < / code > object to a < code > float < / code > . */
public static void floatValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_FLOAT ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_FLOAT , "floatValue" , "()F" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Double < / code > object to a < code > double < / code > . */
public static void doubleValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_DOUBLE ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_DOUBLE , "doubleValue" , "()D" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Byte < / code > object to a < code > byte < / code > . */
public static void byteValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_BYTE ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_BYTE , "byteValue" , "()B" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Short < / code > object to a < code > short < / code > . */
public static void shortValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_SHORT ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_SHORT , "shortValue" , "()S" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Boolean < / code > object to a < code > boolean < / code > . */
public static void booleanValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_BOOLEAN ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_BOOLEAN , "booleanValue" , "()Z" , false ) ;


signature:
public class AsmUtil { /** * Converts < code > Character < / code > object to a < code > char < / code > . */
public static void charValue ( final MethodVisitor mv ) { } }

implementation: mv . visitTypeInsn ( CHECKCAST , SIGNATURE_JAVA_LANG_CHARACTER ) ; mv . visitMethodInsn ( INVOKEVIRTUAL , SIGNATURE_JAVA_LANG_CHARACTER , "charValue" , "()C" , false ) ;


signature:
public class Consumers { /** * Registers additional consumers . */
public Consumers < T > addAll ( final Consumer < T > ... consumers ) { } }

implementation: Collections . addAll ( consumerList , consumers ) ; return this ;


signature:
public class Consumers { /** * Consumes all registered consumers . The are executed sequentially , in order of registration .
 * If { @ link # parallel ( boolean ) } flag is set , consumption is going to be parallel . */
@ Override public void accept ( final T t ) { } }

implementation: if ( parallel ) { consumerList . parallelStream ( ) . forEach ( consumer -> consumer . accept ( t ) ) ; } else { consumerList . forEach ( consumer -> consumer . accept ( t ) ) ; }


signature:
public class CollectionConverter { /** * Creates new collection of target component type .
 * Default implementation uses reflection to create
 * an collection of target type . Override it for better performances . */
@ SuppressWarnings ( "unchecked" ) protected Collection < T > createCollection ( final int length ) { } }

implementation:
if ( collectionType . isInterface ( ) ) { if ( collectionType == List . class ) { if ( length > 0 ) { return new ArrayList < > ( length ) ; } else { return new ArrayList < > ( ) ; } } if ( collectionType == Set . class ) { if ( length > 0 ) { return new HashSet < > ( length ) ; } else { return new HashSet < > ( ) ; } } throw new TypeConversionException ( "Unknown collection: " + collectionType . getName ( ) ) ; } if ( length > 0 ) { try { Constructor < Collection < T > > ctor = ( Constructor < Collection < T > > ) collectionType . getConstructor ( int . class ) ; return ctor . newInstance ( Integer . valueOf ( length ) ) ; } catch ( Exception ex ) { // ignore exception
} } try { return collectionType . getDeclaredConstructor ( ) . newInstance ( ) ; } catch ( Exception ex ) { throw new TypeConversionException ( ex ) ; }


signature:
public class CollectionConverter { /** * Creates a collection with single element . */
protected Collection < T > convertToSingleElementCollection ( final Object value ) { } }

implementation:
Collection < T > collection = createCollection ( 0 ) ; // noinspection unchecked
collection . add ( ( T ) value ) ; return collection ;


signature:
public class CollectionConverter { /** * Converts non - collection value to collection . */
protected Collection < T > convertValueToCollection ( Object value ) { } }

implementation:
if ( value instanceof Iterable ) { Iterable iterable = ( Iterable ) value ; Collection < T > collection = createCollection ( 0 ) ; for ( Object element : iterable ) { collection . add ( convertType ( element ) ) ; } return collection ; } if ( value instanceof CharSequence ) { value = CsvUtil . toStringArray ( value . toString ( ) ) ; } Class type = value . getClass ( ) ; if ( type . isArray ( ) ) { // convert arrays
Class componentType = type . getComponentType ( ) ; if ( componentType . isPrimitive ( ) ) { return convertPrimitiveArrayToCollection ( value , componentType ) ; } else { Object [ ] array = ( Object [ ] ) value ; Collection < T > result = createCollection ( array . length ) ; for ( Object a : array ) { result . add ( convertType ( a ) ) ; } return result ; } } // everything else :
return convertToSingleElementCollection ( value ) ;


signature:
public class CollectionConverter { /** * Converts collection value to target collection .
 * Each element is converted to target component type . */
protected Collection < T > convertCollectionToCollection ( final Collection value ) { } }

implementation: Collection < T > collection = createCollection ( value . size ( ) ) ; for ( Object v : value ) { collection . add ( convertType ( v ) ) ; } return collection ;


signature:
public class CollectionConverter { /** * Converts primitive array to target collection . */
@ SuppressWarnings ( "AutoBoxing" ) protected Collection < T > convertPrimitiveArrayToCollection ( final Object value , final Class primitiveComponentType ) { } }

implementation: Collection < T > result = null ; if ( primitiveComponentType == int . class ) { int [ ] array = ( int [ ] ) value ; result = createCollection ( array . length ) ; for ( int a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == long . class ) { long [ ] array = ( long [ ] ) value ; result = createCollection ( array . length ) ; for ( long a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == float . class ) { float [ ] array = ( float [ ] ) value ; result = createCollection ( array . length ) ; for ( float a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == double . class ) { double [ ] array = ( double [ ] ) value ; result = createCollection ( array . length ) ; for ( double a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == short . class ) { short [ ] array = ( short [ ] ) value ; result = createCollection ( array . length ) ; for ( short a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == byte . class ) { byte [ ] array = ( byte [ ] ) value ; result = createCollection ( array . length ) ; for ( byte a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == char . class ) { char [ ] array = ( char [ ] ) value ; result = createCollection ( array . length ) ; for ( char a : array ) { result . add ( convertType ( a ) ) ; } } else if ( primitiveComponentType == boolean . class ) { boolean [ ] array = ( boolean [ ] ) value ; result = createCollection ( array . length ) ; for ( boolean a : array ) { result . add ( convertType ( a ) ) ; } } return result ;


signature:
public class ProxyProxettaFactory { /** * { @ inheritDoc } */
@ Override protected WorkData process ( final ClassReader cr , final TargetClassInfoReader targetClassInfoReader ) { } }

implementation: ProxettaClassBuilder pcb = new ProxettaClassBuilder ( destClassWriter , proxetta . getAspects ( new ProxyAspect [ 0 ] ) , resolveClassNameSuffix ( ) , requestedProxyClassName , targetClassInfoReader ) ; cr . accept ( pcb , 0 ) ; return pcb . getWorkData ( ) ;


signature:
public class Label { /** * Adds a source line number corresponding to this label .
 * @ param lineNumber a source line number ( which should be strictly positive ) . */
final void addLineNumber ( final int lineNumber ) { } }

implementation: if ( this . lineNumber == 0 ) { this . lineNumber = ( short ) lineNumber ; } else { if ( otherLineNumbers == null ) { otherLineNumbers = new int [ LINE_NUMBERS_CAPACITY_INCREMENT ] ; } int otherLineNumberIndex = ++ otherLineNumbers [ 0 ] ; if ( otherLineNumberIndex >= otherLineNumbers . length ) { int [ ] newLineNumbers = new int [ otherLineNumbers . length + LINE_NUMBERS_CAPACITY_INCREMENT ] ; System . arraycopy ( otherLineNumbers , 0 , newLineNumbers , 0 , otherLineNumbers . length ) ; otherLineNumbers = newLineNumbers ; } otherLineNumbers [ otherLineNumberIndex ] = lineNumber ; }


signature:
public class Label { /** * Makes the given visitor visit this label and its source line numbers , if applicable .
 * @ param methodVisitor a method visitor .
 * @ param visitLineNumbers whether to visit of the label ' s source line numbers , if any . */
final void accept ( final MethodVisitor methodVisitor , final boolean visitLineNumbers ) { } }

implementation: methodVisitor . visitLabel ( this ) ; if ( visitLineNumbers && lineNumber != 0 ) { methodVisitor . visitLineNumber ( lineNumber & 0xFFFF , this ) ; if ( otherLineNumbers != null ) { for ( int i = 1 ; i <= otherLineNumbers [ 0 ] ; ++ i ) { methodVisitor . visitLineNumber ( otherLineNumbers [ i ] , this ) ; } } }


signature:
public class Label { /** * Puts a reference to this label in the bytecode of a method . If the bytecode offset of the label
 * is known , the relative bytecode offset between the label and the instruction referencing it is
 * computed and written directly . Otherwise , a null relative offset is written and a new forward
 * reference is declared for this label .
 * @ param code the bytecode of the method . This is where the reference is appended .
 * @ param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the
 * reference to be appended .
 * @ param wideReference whether the reference must be stored in 4 bytes ( instead of 2 bytes ) . */
final void put ( final ByteVector code , final int sourceInsnBytecodeOffset , final boolean wideReference ) { } }

implementation: if ( ( flags & FLAG_RESOLVED ) == 0 ) { if ( wideReference ) { addForwardReference ( sourceInsnBytecodeOffset , FORWARD_REFERENCE_TYPE_WIDE , code . length ) ; code . putInt ( - 1 ) ; } else { addForwardReference ( sourceInsnBytecodeOffset , FORWARD_REFERENCE_TYPE_SHORT , code . length ) ; code . putShort ( - 1 ) ; } } else { if ( wideReference ) { code . putInt ( bytecodeOffset - sourceInsnBytecodeOffset ) ; } else { code . putShort ( bytecodeOffset - sourceInsnBytecodeOffset ) ; } }


signature:
public class Label { /** * Adds a forward reference to this label . This method must be called only for a true forward
 * reference , i . e . only if this label is not resolved yet . For backward references , the relative
 * bytecode offset of the reference can be , and must be , computed and stored directly .
 * @ param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the
 * reference stored at referenceHandle .
 * @ param referenceType either { @ link # FORWARD _ REFERENCE _ TYPE _ SHORT } or { @ link
 * # FORWARD _ REFERENCE _ TYPE _ WIDE } .
 * @ param referenceHandle the offset in the bytecode where the forward reference value must be
 * stored . */
private void addForwardReference ( final int sourceInsnBytecodeOffset , final int referenceType , final int referenceHandle ) { } }

implementation: if ( forwardReferences == null ) { forwardReferences = new int [ FORWARD_REFERENCES_CAPACITY_INCREMENT ] ; } int lastElementIndex = forwardReferences [ 0 ] ; if ( lastElementIndex + 2 >= forwardReferences . length ) { int [ ] newValues = new int [ forwardReferences . length + FORWARD_REFERENCES_CAPACITY_INCREMENT ] ; System . arraycopy ( forwardReferences , 0 , newValues , 0 , forwardReferences . length ) ; forwardReferences = newValues ; } forwardReferences [ ++ lastElementIndex ] = sourceInsnBytecodeOffset ; forwardReferences [ ++ lastElementIndex ] = referenceType | referenceHandle ; forwardReferences [ 0 ] = lastElementIndex ;


signature:
public class Label { /** * Sets the bytecode offset of this label to the given value and resolves the forward references
 * to this label , if any . This method must be called when this label is added to the bytecode of
 * the method , i . e . when its bytecode offset becomes known . This method fills in the blanks that
 * where left in the bytecode by each forward reference previously added to this label .
 * @ param code the bytecode of the method .
 * @ param bytecodeOffset the bytecode offset of this label .
 * @ return { @ literal true } if a blank that was left for this label was too small to store the
 * offset . In such a case the corresponding jump instruction is replaced with an equivalent
 * ASM specific instruction using an unsigned two bytes offset . These ASM specific
 * instructions are later replaced with standard bytecode instructions with wider offsets ( 4
 * bytes instead of 2 ) , in ClassReader . */
final boolean resolve ( final byte [ ] code , final int bytecodeOffset ) { } }

implementation:
this . flags |= FLAG_RESOLVED ; this . bytecodeOffset = bytecodeOffset ; if ( forwardReferences == null ) { return false ; } boolean hasAsmInstructions = false ; for ( int i = forwardReferences [ 0 ] ; i > 0 ; i -= 2 ) { final int sourceInsnBytecodeOffset = forwardReferences [ i - 1 ] ; final int reference = forwardReferences [ i ] ; final int relativeOffset = bytecodeOffset - sourceInsnBytecodeOffset ; int handle = reference & FORWARD_REFERENCE_HANDLE_MASK ; if ( ( reference & FORWARD_REFERENCE_TYPE_MASK ) == FORWARD_REFERENCE_TYPE_SHORT ) { if ( relativeOffset < Short . MIN_VALUE || relativeOffset > Short . MAX_VALUE ) { // Change the opcode of the jump instruction , in order to be able to find it later in
// ClassReader . These ASM specific opcodes are similar to jump instruction opcodes , except
// that the 2 bytes offset is unsigned ( and can therefore represent values from 0 to
// 65535 , which is sufficient since the size of a method is limited to 65535 bytes ) .
int opcode = code [ sourceInsnBytecodeOffset ] & 0xFF ; if ( opcode < Opcodes . IFNULL ) { // Change IFEQ . . . JSR to ASM _ IFEQ . . . ASM _ JSR .
code [ sourceInsnBytecodeOffset ] = ( byte ) ( opcode + Constants . ASM_OPCODE_DELTA ) ; } else { // Change IFNULL and IFNONNULL to ASM _ IFNULL and ASM _ IFNONNULL .
code [ sourceInsnBytecodeOffset ] = ( byte ) ( opcode + Constants . ASM_IFNULL_OPCODE_DELTA ) ; } hasAsmInstructions = true ; } code [ handle ++ ] = ( byte ) ( relativeOffset >>> 8 ) ; code [ handle ] = ( byte ) relativeOffset ; } else { code [ handle ++ ] = ( byte ) ( relativeOffset >>> 24 ) ; code [ handle ++ ] = ( byte ) ( relativeOffset >>> 16 ) ; code [ handle ++ ] = ( byte ) ( relativeOffset >>> 8 ) ; code [ handle ] = ( byte ) relativeOffset ; } } return hasAsmInstructions ;


signature:
public class Label { /** * Finds the basic blocks that belong to the subroutine starting with the basic block
 * corresponding to this label , and marks these blocks as belonging to this subroutine . This
 * method follows the control flow graph to find all the blocks that are reachable from the
 * current basic block WITHOUT following any jsr target .
 * < p > Note : a precondition and postcondition of this method is that all labels must have a null
 * { @ link # nextListElement } .
 * @ param subroutineId the id of the subroutine starting with the basic block corresponding to
 * this label . */
final void markSubroutine ( final short subroutineId ) { } }

implementation:
// Data flow algorithm : put this basic block in a list of blocks to process ( which are blocks
// belonging to subroutine subroutineId ) and , while there are blocks to process , remove one from
// the list , mark it as belonging to the subroutine , and add its successor basic blocks in the
// control flow graph to the list of blocks to process ( if not already done ) .
Label listOfBlocksToProcess = this ; listOfBlocksToProcess . nextListElement = EMPTY_LIST ; while ( listOfBlocksToProcess != EMPTY_LIST ) { // Remove a basic block from the list of blocks to process .
Label basicBlock = listOfBlocksToProcess ; listOfBlocksToProcess = listOfBlocksToProcess . nextListElement ; basicBlock . nextListElement = null ; // If it is not already marked as belonging to a subroutine , mark it as belonging to
// subroutineId and add its successors to the list of blocks to process ( unless already done ) .
if ( basicBlock . subroutineId == 0 ) { basicBlock . subroutineId = subroutineId ; listOfBlocksToProcess = basicBlock . pushSuccessors ( listOfBlocksToProcess ) ; } }


signature:
public class Label { /** * Finds the basic blocks that end a subroutine starting with the basic block corresponding to
 * this label and , for each one of them , adds an outgoing edge to the basic block following the
 * given subroutine call . In other words , completes the control flow graph by adding the edges
 * corresponding to the return from this subroutine , when called from the given caller basic
 * block .
 * < p > Note : a precondition and postcondition of this method is that all labels must have a null
 * { @ link # nextListElement } .
 * @ param subroutineCaller a basic block that ends with a jsr to the basic block corresponding to
 * this label . This label is supposed to correspond to the start of a subroutine . */
final void addSubroutineRetSuccessors ( final Label subroutineCaller ) { } }

implementation:
// Data flow algorithm : put this basic block in a list blocks to process ( which are blocks
// belonging to a subroutine starting with this label ) and , while there are blocks to process ,
// remove one from the list , put it in a list of blocks that have been processed , add a return
// edge to the successor of subroutineCaller if applicable , and add its successor basic blocks
// in the control flow graph to the list of blocks to process ( if not already done ) .
Label listOfProcessedBlocks = EMPTY_LIST ; Label listOfBlocksToProcess = this ; listOfBlocksToProcess . nextListElement = EMPTY_LIST ; while ( listOfBlocksToProcess != EMPTY_LIST ) { // Move a basic block from the list of blocks to process to the list of processed blocks .
Label basicBlock = listOfBlocksToProcess ; listOfBlocksToProcess = basicBlock . nextListElement ; basicBlock . nextListElement = listOfProcessedBlocks ; listOfProcessedBlocks = basicBlock ; // Add an edge from this block to the successor of the caller basic block , if this block is
// the end of a subroutine and if this block and subroutineCaller do not belong to the same
// subroutine .
if ( ( basicBlock . flags & FLAG_SUBROUTINE_END ) != 0 && basicBlock . subroutineId != subroutineCaller . subroutineId ) { basicBlock . outgoingEdges = new Edge ( basicBlock . outputStackSize , // By construction , the first outgoing edge of a basic block that ends with a jsr
// instruction leads to the jsr continuation block , i . e . where execution continues
// when ret is called ( see { @ link # FLAG _ SUBROUTINE _ CALLER } ) .
subroutineCaller . outgoingEdges . successor , basicBlock . outgoingEdges ) ; } // Add its successors to the list of blocks to process . Note that { @ link # pushSuccessors } does
// not push basic blocks which are already in a list . Here this means either in the list of
// blocks to process , or in the list of already processed blocks . This second list is
// important to make sure we don ' t reprocess an already processed block .
listOfBlocksToProcess = basicBlock . pushSuccessors ( listOfBlocksToProcess ) ; } // Reset the { @ link # nextListElement } of all the basic blocks that have been processed to null ,
// so that this method can be called again with a different subroutine or subroutine caller .
while ( listOfProcessedBlocks != EMPTY_LIST ) { Label newListOfProcessedBlocks = listOfProcessedBlocks . nextListElement ; listOfProcessedBlocks . nextListElement = null ; listOfProcessedBlocks = newListOfProcessedBlocks ; }


signature:
public class Label { /** * Adds the successors of this label in the method ' s control flow graph ( except those
 * corresponding to a jsr target , and those already in a list of labels ) to the given list of
 * blocks to process , and returns the new list .
 * @ param listOfLabelsToProcess a list of basic blocks to process , linked together with their
 * { @ link # nextListElement } field .
 * @ return the new list of blocks to process . */
private Label pushSuccessors ( final Label listOfLabelsToProcess ) { } }

implementation:
Label newListOfLabelsToProcess = listOfLabelsToProcess ; Edge outgoingEdge = outgoingEdges ; while ( outgoingEdge != null ) { // By construction , the second outgoing edge of a basic block that ends with a jsr instruction
// leads to the jsr target ( see { @ link # FLAG _ SUBROUTINE _ CALLER } ) .
boolean isJsrTarget = ( flags & Label . FLAG_SUBROUTINE_CALLER ) != 0 && outgoingEdge == outgoingEdges . nextEdge ; if ( ! isJsrTarget && outgoingEdge . successor . nextListElement == null ) { // Add this successor to the list of blocks to process , if it does not already belong to a
// list of labels .
outgoingEdge . successor . nextListElement = newListOfLabelsToProcess ; newListOfLabelsToProcess = outgoingEdge . successor ; } outgoingEdge = outgoingEdge . nextEdge ; } return newListOfLabelsToProcess ;


signature:
public class NaturalOrderComparator { /** * Compare digits at certain position in two strings .
 * The longest run of digits wins . That aside , the greatest
 * value wins .
 * @ return if numbers are different , only 1 element is returned . */
protected int [ ] compareDigits ( final String str1 , int ndx1 , final String str2 , int ndx2 ) { } }

implementation:
// iterate all digits in the first string
int zeroCount1 = 0 ; while ( charAt ( str1 , ndx1 ) == '0' ) { zeroCount1 ++ ; ndx1 ++ ; } int len1 = 0 ; while ( true ) { final char char1 = charAt ( str1 , ndx1 ) ; final boolean isDigitChar1 = CharUtil . isDigit ( char1 ) ; if ( ! isDigitChar1 ) { break ; } len1 ++ ; ndx1 ++ ; } // iterate all digits in the second string and compare with the first
int zeroCount2 = 0 ; while ( charAt ( str2 , ndx2 ) == '0' ) { zeroCount2 ++ ; ndx2 ++ ; } int len2 = 0 ; int ndx1_new = ndx1 - len1 ; int equalNumbers = 0 ; while ( true ) { final char char2 = charAt ( str2 , ndx2 ) ; final boolean isDigitChar2 = CharUtil . isDigit ( char2 ) ; if ( ! isDigitChar2 ) { break ; } if ( equalNumbers == 0 && ( ndx1_new < ndx1 ) ) { equalNumbers = charAt ( str1 , ndx1_new ++ ) - char2 ; } len2 ++ ; ndx2 ++ ; } // compare
if ( len1 != len2 ) { // numbers are not equals size
return new int [ ] { len1 - len2 } ; } if ( equalNumbers != 0 ) { return new int [ ] { equalNumbers } ; } // numbers are equal , but number of zeros is different
return new int [ ] { 0 , zeroCount1 - zeroCount2 , ndx1 , ndx2 } ;


signature:
public class NaturalOrderComparator { /** * Fixes accent char . */
private char fixAccent ( final char c ) { } }

implementation: for ( int i = 0 ; i < ACCENT_CHARS . length ; i += 2 ) { final char accentChar = ACCENT_CHARS [ i ] ; if ( accentChar == c ) { return ACCENT_CHARS [ i + 1 ] ; } } return c ;


signature:
public class NaturalOrderComparator { /** * Safe { @ code charAt } that returns 0 when ndx is out of boundaries . */
private static char charAt ( final String string , final int ndx ) { } }

implementation: if ( ndx >= string . length ( ) ) { return 0 ; } return string . charAt ( ndx ) ;


signature:
public class ByteVector { /** * Puts a byte into this byte vector . The byte vector is automatically enlarged if necessary .
 * @ param byteValue a byte .
 * @ return this byte vector . */
public ByteVector putByte ( final int byteValue ) { } }

implementation: int currentLength = length ; if ( currentLength + 1 > data . length ) { enlarge ( 1 ) ; } data [ currentLength ++ ] = ( byte ) byteValue ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts two bytes into this byte vector . The byte vector is automatically enlarged if necessary .
 * @ param byteValue1 a byte .
 * @ param byteValue2 another byte .
 * @ return this byte vector . */
final ByteVector put11 ( final int byteValue1 , final int byteValue2 ) { } }

implementation: int currentLength = length ; if ( currentLength + 2 > data . length ) { enlarge ( 2 ) ; } byte [ ] currentData = data ; currentData [ currentLength ++ ] = ( byte ) byteValue1 ; currentData [ currentLength ++ ] = ( byte ) byteValue2 ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts a short into this byte vector . The byte vector is automatically enlarged if necessary .
 * @ param shortValue a short .
 * @ return this byte vector . */
public ByteVector putShort ( final int shortValue ) { } }

implementation: int currentLength = length ; if ( currentLength + 2 > data . length ) { enlarge ( 2 ) ; } byte [ ] currentData = data ; currentData [ currentLength ++ ] = ( byte ) ( shortValue >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) shortValue ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts a byte and a short into this byte vector . The byte vector is automatically enlarged if
 * necessary .
 * @ param byteValue a byte .
 * @ param shortValue a short .
 * @ return this byte vector . */
final ByteVector put12 ( final int byteValue , final int shortValue ) { } }

implementation: int currentLength = length ; if ( currentLength + 3 > data . length ) { enlarge ( 3 ) ; } byte [ ] currentData = data ; currentData [ currentLength ++ ] = ( byte ) byteValue ; currentData [ currentLength ++ ] = ( byte ) ( shortValue >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) shortValue ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts two bytes and a short into this byte vector . The byte vector is automatically enlarged if
 * necessary .
 * @ param byteValue1 a byte .
 * @ param byteValue2 another byte .
 * @ param shortValue a short .
 * @ return this byte vector . */
final ByteVector put112 ( final int byteValue1 , final int byteValue2 , final int shortValue ) { } }

implementation: int currentLength = length ; if ( currentLength + 4 > data . length ) { enlarge ( 4 ) ; } byte [ ] currentData = data ; currentData [ currentLength ++ ] = ( byte ) byteValue1 ; currentData [ currentLength ++ ] = ( byte ) byteValue2 ; currentData [ currentLength ++ ] = ( byte ) ( shortValue >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) shortValue ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts an int into this byte vector . The byte vector is automatically enlarged if necessary .
 * @ param intValue an int .
 * @ return this byte vector . */
public ByteVector putInt ( final int intValue ) { } }

implementation: int currentLength = length ; if ( currentLength + 4 > data . length ) { enlarge ( 4 ) ; } byte [ ] currentData = data ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 24 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 16 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) intValue ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts one byte and two shorts into this byte vector . The byte vector is automatically enlarged
 * if necessary .
 * @ param byteValue a byte .
 * @ param shortValue1 a short .
 * @ param shortValue2 another short .
 * @ return this byte vector . */
final ByteVector put122 ( final int byteValue , final int shortValue1 , final int shortValue2 ) { } }

implementation: int currentLength = length ; if ( currentLength + 5 > data . length ) { enlarge ( 5 ) ; } byte [ ] currentData = data ; currentData [ currentLength ++ ] = ( byte ) byteValue ; currentData [ currentLength ++ ] = ( byte ) ( shortValue1 >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) shortValue1 ; currentData [ currentLength ++ ] = ( byte ) ( shortValue2 >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) shortValue2 ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts a long into this byte vector . The byte vector is automatically enlarged if necessary .
 * @ param longValue a long .
 * @ return this byte vector . */
public ByteVector putLong ( final long longValue ) { } }

implementation: int currentLength = length ; if ( currentLength + 8 > data . length ) { enlarge ( 8 ) ; } byte [ ] currentData = data ; int intValue = ( int ) ( longValue >>> 32 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 24 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 16 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) intValue ; intValue = ( int ) longValue ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 24 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 16 ) ; currentData [ currentLength ++ ] = ( byte ) ( intValue >>> 8 ) ; currentData [ currentLength ++ ] = ( byte ) intValue ; length = currentLength ; return this ;


signature:
public class ByteVector { /** * Puts an array of bytes into this byte vector . The byte vector is automatically enlarged if
 * necessary .
 * @ param byteArrayValue an array of bytes . May be { @ literal null } to put { @ code byteLength } null
 * bytes into this byte vector .
 * @ param byteOffset index of the first byte of byteArrayValue that must be copied .
 * @ param byteLength number of bytes of byteArrayValue that must be copied .
 * @ return this byte vector . */
public ByteVector putByteArray ( final byte [ ] byteArrayValue , final int byteOffset , final int byteLength ) { } }

implementation: if ( length + byteLength > data . length ) { enlarge ( byteLength ) ; } if ( byteArrayValue != null ) { System . arraycopy ( byteArrayValue , byteOffset , data , length , byteLength ) ; } length += byteLength ; return this ;


signature:
public class ByteVector { /** * Enlarges this byte vector so that it can receive ' size ' more bytes .
 * @ param size number of additional bytes that this byte vector should be able to receive . */
private void enlarge ( final int size ) { } }

implementation: int doubleCapacity = 2 * data . length ; int minimalCapacity = length + size ; byte [ ] newData = new byte [ doubleCapacity > minimalCapacity ? doubleCapacity : minimalCapacity ] ; System . arraycopy ( data , 0 , newData , 0 , length ) ; data = newData ;


signature:
public class AuthInterceptor { /** * Tries to authenticate user via HTTP session . Returns the token if user is authenticated .
 * Returned token may be rotated . */
protected T authenticateUserViaHttpSession ( final ActionRequest actionRequest ) { } }

implementation:
final HttpServletRequest servletRequest = actionRequest . getHttpServletRequest ( ) ; final UserSession < T > userSession = UserSession . get ( servletRequest ) ; if ( userSession == null ) { return null ; } final T authToken = userSession . getAuthToken ( ) ; if ( authToken == null ) { return null ; } // granted
final T newAuthToken = userAuth ( ) . rotateToken ( authToken ) ; if ( newAuthToken != authToken ) { final UserSession < T > newUserSesion = new UserSession < > ( newAuthToken , userAuth ( ) . tokenValue ( newAuthToken ) ) ; newUserSesion . start ( servletRequest , actionRequest . getHttpServletResponse ( ) ) ; } return newAuthToken ;


signature:
public class AuthInterceptor { /** * Tries to authenticate user via token . Returns the token if user is authenticated .
 * Returned token may be rotated . */
protected T authenticateUserViaToken ( final ActionRequest actionRequest ) { } }

implementation:
final HttpServletRequest servletRequest = actionRequest . getHttpServletRequest ( ) ; // then try the auth token
final String token = ServletUtil . resolveAuthBearerToken ( servletRequest ) ; if ( token == null ) { return null ; } final T authToken = userAuth ( ) . validateToken ( token ) ; if ( authToken == null ) { return null ; } // granted
final T newAuthToken = userAuth ( ) . rotateToken ( authToken ) ; actionRequest . getHttpServletResponse ( ) . setHeader ( "Authentication" , "Bearer: " + userAuth ( ) . tokenValue ( newAuthToken ) ) ; return newAuthToken ;


signature:
public class AuthInterceptor { /** * Tires to authenticate user via the basic authentication . Returns the token if user is authenticated . */
protected T authenticateUserViaBasicAuth ( final ActionRequest actionRequest ) { } }

implementation: final HttpServletRequest servletRequest = actionRequest . getHttpServletRequest ( ) ; final String username = ServletUtil . resolveAuthUsername ( servletRequest ) ; if ( username == null ) { return null ; } final String password = ServletUtil . resolveAuthPassword ( servletRequest ) ; final T authToken = userAuth ( ) . login ( username , password ) ; if ( authToken == null ) { return null ; } return authToken ;


signature:
public class SqlRefSqlType { /** * { @ inheritDoc } */
@ Override public Ref get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return rs . getRef ( index ) ;


signature:
public class SqlRefSqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final Ref value , final int dbSqlType ) throws SQLException { } }

implementation: st . setRef ( index , value ) ;


signature:
public class ResourceBundleMessageResolver { /** * Calculates indexedTextName ( collection [ * ] ) if applicable . */
private String calcIndexKey ( final String key ) { } }

implementation: String indexedKey = null ; if ( key . indexOf ( '[' ) != - 1 ) { int i = - 1 ; indexedKey = key ; while ( ( i = indexedKey . indexOf ( '[' , i + 1 ) ) != - 1 ) { int j = indexedKey . indexOf ( ']' , i ) ; String a = indexedKey . substring ( 0 , i ) ; String b = indexedKey . substring ( j ) ; indexedKey = a + "[*" + b ; } } return indexedKey ;


signature:
public class ResourceBundleMessageResolver { /** * Finds messages in the provided bundle . If message not found , all parent bundles will be
 * examined until the root bundle . At the end , if still no success , all default
 * bundles will be examined . Returns < code > null < / code > if key is not found . */
public String findMessage ( String bundleName , final Locale locale , final String key ) { } }

implementation:
String indexedKey = calcIndexKey ( key ) ; // hierarchy
String name = bundleName ; while ( true ) { String msg = getMessage ( name , locale , key , indexedKey ) ; if ( msg != null ) { return msg ; } if ( bundleName == null || bundleName . length ( ) == 0 ) { break ; } int ndx = bundleName . lastIndexOf ( '.' ) ; if ( ndx == - 1 ) { bundleName = null ; name = fallbackBundlename ; } else { bundleName = bundleName . substring ( 0 , ndx ) ; name = bundleName + '.' + fallbackBundlename ; } } // default bundles
for ( String bname : defaultBundles ) { String msg = getMessage ( bname , locale , key , indexedKey ) ; if ( msg != null ) { return msg ; } } return null ;


signature:
public class ResourceBundleMessageResolver { /** * Finds message in default bundles only , starting from fallback bundlename . */
public String findDefaultMessage ( final Locale locale , final String key ) { } }

implementation: String indexedKey = calcIndexKey ( key ) ; String msg = getMessage ( fallbackBundlename , locale , key , indexedKey ) ; if ( msg != null ) { return msg ; } for ( String bname : defaultBundles ) { msg = getMessage ( bname , locale , key , indexedKey ) ; if ( msg != null ) { return msg ; } } return null ;


signature:
public class ResourceBundleMessageResolver { /** * Gets the message from the named resource bundle . Performs the failback only when
 * bundle name or locale are not specified ( i . e . are < code > null < / code > ) . */
public String getMessage ( final String bundleName , final Locale locale , final String key ) { } }

implementation:
ResourceBundle bundle = findResourceBundle ( bundleName , locale ) ; if ( bundle == null ) { return null ; } /* / / jdk6:
 if ( bundle . containsKey ( key ) = = false ) {
 return null ; */
try { return bundle . getString ( key ) ; } catch ( MissingResourceException mrex ) { return null ; }


signature:
public class ResourceBundleMessageResolver { /** * Finds resource bundle by it ' s name . Missed and founded resource bundles are cached for
 * better performances . Returns < code > null < / code > if resource bundle is missing . */
public ResourceBundle findResourceBundle ( String bundleName , Locale locale ) { } }

implementation: if ( bundleName == null ) { bundleName = fallbackBundlename ; } if ( locale == null ) { locale = fallbackLocale ; } if ( ! cacheResourceBundles ) { try { return getBundle ( bundleName , locale , ClassLoaderUtil . getDefaultClassLoader ( ) ) ; } catch ( MissingResourceException ignore ) { return null ; } } String key = bundleName + '_' + locale . toLanguageTag ( ) ; try { if ( ! misses . contains ( key ) ) { ResourceBundle bundle = notmisses . get ( key ) ; if ( bundle == null ) { bundle = getBundle ( bundleName , locale , ClassLoaderUtil . getDefaultClassLoader ( ) ) ; notmisses . put ( key , bundle ) ; } return bundle ; } } catch ( MissingResourceException ignore ) { misses . add ( key ) ; } return null ;


signature:
public class ResourceBundleMessageResolver { /** * Returns specified bundle . Invoked every time if cache is disabled .
 * Input arguments are always valid . */
protected ResourceBundle getBundle ( final String bundleName , final Locale locale , final ClassLoader classLoader ) { } }

implementation: return ResourceBundle . getBundle ( bundleName , locale , classLoader ) ;


signature:
public class ArraysJsonSerializer { /** * Returns array ' s element at given index . */
protected K get ( final K [ ] array , final int index ) { } }

implementation: return ( K ) Array . get ( array , index ) ;


signature:
public class GenericDao { /** * Returns < code > true < / code > if entity is persistent . */
protected < E > boolean isPersistent ( final DbEntityDescriptor < E > ded , final E entity ) { } }

implementation: final Object key = ded . getIdValue ( entity ) ; if ( key == null ) { return false ; } if ( key instanceof Number ) { final long value = ( ( Number ) key ) . longValue ( ) ; if ( value == 0 ) { return false ; } } return true ;


signature:
public class GenericDao { /** * Sets new ID value for entity . */
protected < E , ID > void setEntityId ( final DbEntityDescriptor < E > ded , final E entity , final ID newIdValue ) { } }

implementation: ded . setIdValue ( entity , newIdValue ) ;


signature:
public class GenericDao { /** * Saves or updates entity . If ID is not < code > null < / code > , entity will be updated .
 * Otherwise , entity will be inserted into the database . */
public < E > E store ( final E entity ) { } }

implementation: final Class type = entity . getClass ( ) ; final DbEntityDescriptor ded = dbOom . entityManager ( ) . lookupType ( type ) ; if ( ded == null ) { throw new DbOomException ( "Not an entity: " + type ) ; } if ( ! isPersistent ( ded , entity ) ) { final DbQuery q ; if ( dbOom . config ( ) . isKeysGeneratedByDatabase ( ) ) { q = query ( dbOom . entities ( ) . insert ( entity ) ) ; q . setGeneratedKey ( ) ; q . executeUpdate ( ) ; final Object nextId = q . getGeneratedKey ( ) ; setEntityId ( ded , entity , nextId ) ; } else { final Object nextId = generateNextId ( ded ) ; setEntityId ( ded , entity , nextId ) ; q = query ( dbOom . entities ( ) . insert ( entity ) ) ; q . executeUpdate ( ) ; } q . close ( ) ; } else { query ( dbOom . entities ( ) . updateAll ( entity ) ) . autoClose ( ) . executeUpdate ( ) ; } return entity ;


signature:
public class GenericDao { /** * Simply inserts object into the database . */
public void save ( final Object entity ) { } }

implementation: final DbQuery q = query ( dbOom . entities ( ) . insert ( entity ) ) ; q . autoClose ( ) . executeUpdate ( ) ;


signature:
public class GenericDao { /** * Updates single entity . */
public void update ( final Object entity ) { } }

implementation: query ( dbOom . entities ( ) . updateAll ( entity ) ) . autoClose ( ) . executeUpdate ( ) ;


signature:
public class GenericDao { /** * Updates single property in database and in the bean . */
public < E > E updateProperty ( final E entity , final String name , final Object newValue ) { } }

implementation: query ( dbOom . entities ( ) . updateColumn ( entity , name , newValue ) ) . autoClose ( ) . executeUpdate ( ) ; BeanUtil . declared . setProperty ( entity , name , newValue ) ; return entity ;


signature:
public class GenericDao { /** * Updates property in the database by storing the current property value . */
public < E > E updateProperty ( final E entity , final String name ) { } }

implementation: Object value = BeanUtil . declared . getProperty ( entity , name ) ; query ( dbOom . entities ( ) . updateColumn ( entity , name , value ) ) . autoClose ( ) . executeUpdate ( ) ; return entity ;


signature:
public class GenericDao { /** * Finds single entity by its id . */
public < E , ID > E findById ( final Class < E > entityType , final ID id ) { } }

implementation: return query ( dbOom . entities ( ) . findById ( entityType , id ) ) . autoClose ( ) . find ( entityType ) ;


signature:
public class GenericDao { /** * Finds single entity by matching property . */
public < E > E findOneByProperty ( final Class < E > entityType , final String name , final Object value ) { } }

implementation: return query ( dbOom . entities ( ) . findByColumn ( entityType , name , value ) ) . autoClose ( ) . find ( entityType ) ;


signature:
public class GenericDao { /** * Finds one entity for given criteria . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public < E > E findOne ( final Object criteria ) { return ( E ) query ( dbOom . entities ( ) . find ( criteria ) ) . autoClose ( ) . find ( criteria . getClass ( ) ) ;


signature:
public class GenericDao { /** * Finds list of entities matching given criteria . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public < E > List < E > find ( final Object criteria ) { return query ( dbOom . entities ( ) . find ( criteria ) ) . autoClose ( ) . list ( criteria . getClass ( ) ) ;


signature:
public class GenericDao { /** * Finds list of entities matching given criteria . */
public < E > List < E > find ( final Class < E > entityType , final Object criteria ) { } }

implementation: return query ( dbOom . entities ( ) . find ( entityType , criteria ) ) . autoClose ( ) . list ( entityType ) ;


signature:
public class GenericDao { /** * Deleted single entity by its id . */
public < ID > void deleteById ( final Class entityType , final ID id ) { } }

implementation: query ( dbOom . entities ( ) . deleteById ( entityType , id ) ) . autoClose ( ) . executeUpdate ( ) ;


signature:
public class GenericDao { /** * Delete single object by its id . Resets ID value . */
public void deleteById ( final Object entity ) { } }

implementation:
if ( entity != null ) { int result = query ( dbOom . entities ( ) . deleteById ( entity ) ) . autoClose ( ) . executeUpdate ( ) ; if ( result != 0 ) { // now reset the ID value
Class type = entity . getClass ( ) ; DbEntityDescriptor ded = dbOom . entityManager ( ) . lookupType ( type ) ; setEntityId ( ded , entity , 0 ) ; } }


signature:
public class GenericDao { /** * Counts number of all entities . */
public long count ( final Class entityType ) { } }

implementation: return query ( dbOom . entities ( ) . count ( entityType ) ) . autoClose ( ) . executeCount ( ) ;


signature:
public class GenericDao { /** * Increases a property . */
public < ID > void increaseProperty ( final Class entityType , final ID id , final String name , final Number delta ) { } }

implementation: query ( dbOom . entities ( ) . increaseColumn ( entityType , id , name , delta , true ) ) . autoClose ( ) . executeUpdate ( ) ;


signature:
public class GenericDao { /** * Decreases a property . */
public < ID > void decreaseProperty ( final Class entityType , final ID id , final String name , final Number delta ) { } }

implementation: query ( dbOom . entities ( ) . increaseColumn ( entityType , id , name , delta , false ) ) . autoClose ( ) . executeUpdate ( ) ;


signature:
public class GenericDao { /** * Finds related entity . */
public < E > List < E > findRelated ( final Class < E > target , final Object source ) { } }

implementation: return query ( dbOom . entities ( ) . findForeign ( target , source ) ) . autoClose ( ) . list ( target ) ;


signature:
public class GenericDao { /** * List all entities . */
public < E > List < E > listAll ( final Class < E > target ) { } }

implementation: return query ( dbOom . entities ( ) . from ( target ) ) . autoClose ( ) . list ( target ) ;


signature:
public class HtmlImplicitClosingRules { /** * Returns < code > true < / code > if parent node tag can be closed implicitly . */
public boolean implicitlyCloseParentTagOnNewTag ( String parentNodeName , String nodeName ) { } }

implementation: if ( parentNodeName == null ) { return false ; } parentNodeName = parentNodeName . toLowerCase ( ) ; nodeName = nodeName . toLowerCase ( ) ; for ( int i = 0 ; i < IMPLIED_ON_START . length ; i += 2 ) { if ( StringUtil . equalsOne ( parentNodeName , IMPLIED_ON_START [ i ] ) != - 1 ) { if ( StringUtil . equalsOne ( nodeName , IMPLIED_ON_START [ i + 1 ] ) != - 1 ) { return true ; } } } return false ;


signature:
public class HtmlImplicitClosingRules { /** * Returns < code > true < / code > if current end tag ( node name ) closes the parent tag . */
public boolean implicitlyCloseParentTagOnTagEnd ( String parentNodeName , String nodeName ) { } }

implementation: if ( parentNodeName == null ) { return false ; } parentNodeName = parentNodeName . toLowerCase ( ) ; nodeName = nodeName . toLowerCase ( ) ; for ( int i = 0 ; i < IMPLIED_ON_END . length ; i += 2 ) { if ( StringUtil . equalsOne ( nodeName , IMPLIED_ON_END [ i ] ) != - 1 ) { if ( StringUtil . equalsOne ( parentNodeName , IMPLIED_ON_END [ i + 1 ] ) != - 1 ) { return true ; } } } return false ;


signature:
public class HtmlImplicitClosingRules { /** * Returns < code > true < / code > if tag should be closed on EOF . */
public boolean implicitlyCloseTagOnEOF ( String nodeName ) { } }

implementation: if ( nodeName == null ) { return false ; } nodeName = nodeName . toLowerCase ( ) ; return StringUtil . equalsOne ( nodeName , CLOSED_ON_EOF ) != - 1 ;


signature:
public class StringKeyedMapAdapter { /** * Removes all attributes from the request as well as clears entries in this map . */
@ Override public void clear ( ) { } }

implementation: entries = null ; Iterator < String > keys = getAttributeNames ( ) ; while ( keys . hasNext ( ) ) { removeAttribute ( keys . next ( ) ) ; }


signature:
public class StringKeyedMapAdapter { /** * Returns a Set of attributes from the http request . */
@ Override public Set < Entry < String , Object > > entrySet ( ) { } }

implementation: if ( entries == null ) { entries = new HashSet < > ( ) ; Iterator < String > iterator = getAttributeNames ( ) ; while ( iterator . hasNext ( ) ) { final String key = iterator . next ( ) ; final Object value = getAttribute ( key ) ; entries . add ( new Entry < String , Object > ( ) { @ Override public boolean equals ( final Object obj ) { if ( obj == null ) { return false ; } if ( this . getClass ( ) != obj . getClass ( ) ) { return false ; } Entry entry = ( Entry ) obj ; return ( ( key == null ) ? ( entry . getKey ( ) == null ) : key . equals ( entry . getKey ( ) ) ) && ( ( value == null ) ? ( entry . getValue ( ) == null ) : value . equals ( entry . getValue ( ) ) ) ; } @ Override public int hashCode ( ) { return ( ( key == null ) ? 0 : key . hashCode ( ) ) ^ ( ( value == null ) ? 0 : value . hashCode ( ) ) ; } @ Override public String getKey ( ) { return key ; } @ Override public Object getValue ( ) { return value ; } @ Override public Object setValue ( final Object obj ) { setAttribute ( key , obj ) ; return value ; } } ) ; } } return entries ;


signature:
public class StringKeyedMapAdapter { /** * Saves an attribute in the request . */
@ Override public Object put ( final String key , final Object value ) { } }

implementation: entries = null ; Object previous = get ( key ) ; setAttribute ( key , value ) ; return previous ;


signature:
public class StringKeyedMapAdapter { /** * Removes the specified request attribute . */
@ Override public Object remove ( final Object key ) { } }

implementation: entries = null ; Object value = get ( key ) ; removeAttribute ( key . toString ( ) ) ; return value ;


signature:
public class ExceptionUtil { /** * Returns current stack trace in form of array of stack trace elements .
 * First stack trace element is removed .
 * Since an exception is thrown internally , this method is slow . */
@ SuppressWarnings ( { } }

implementation: "ThrowCaughtLocally" } ) public static StackTraceElement [ ] getCurrentStackTrace ( ) { StackTraceElement [ ] ste = new Exception ( ) . getStackTrace ( ) ; if ( ste . length > 1 ) { StackTraceElement [ ] result = new StackTraceElement [ ste . length - 1 ] ; System . arraycopy ( ste , 1 , result , 0 , ste . length - 1 ) ; return result ; } else { return ste ; }


signature:
public class ExceptionUtil { /** * Returns stack trace filtered by class names . */
public static StackTraceElement [ ] getStackTrace ( final Throwable t , final String [ ] allow , final String [ ] deny ) { } }

implementation: StackTraceElement [ ] st = t . getStackTrace ( ) ; ArrayList < StackTraceElement > result = new ArrayList < > ( st . length ) ; elementLoop : for ( StackTraceElement element : st ) { String className = element . getClassName ( ) ; if ( allow != null ) { boolean validElemenet = false ; for ( String filter : allow ) { if ( className . contains ( filter ) ) { validElemenet = true ; break ; } } if ( ! validElemenet ) { continue ; } } if ( deny != null ) { for ( String filter : deny ) { if ( className . contains ( filter ) ) { continue elementLoop ; } } } result . add ( element ) ; } st = new StackTraceElement [ result . size ( ) ] ; return result . toArray ( st ) ;


signature:
public class ExceptionUtil { /** * Returns stack trace chain filtered by class names . */
public static StackTraceElement [ ] [ ] getStackTraceChain ( Throwable t , final String [ ] allow , final String [ ] deny ) { } }

implementation: ArrayList < StackTraceElement [ ] > result = new ArrayList < > ( ) ; while ( t != null ) { StackTraceElement [ ] stack = getStackTrace ( t , allow , deny ) ; result . add ( stack ) ; t = t . getCause ( ) ; } StackTraceElement [ ] [ ] allStacks = new StackTraceElement [ result . size ( ) ] [ ] ; for ( int i = 0 ; i < allStacks . length ; i ++ ) { allStacks [ i ] = result . get ( i ) ; } return allStacks ;


signature:
public class ExceptionUtil { /** * Returns exception chain starting from top up to root cause . */
public static Throwable [ ] getExceptionChain ( Throwable throwable ) { } }

implementation: ArrayList < Throwable > list = new ArrayList < > ( ) ; list . add ( throwable ) ; while ( ( throwable = throwable . getCause ( ) ) != null ) { list . add ( throwable ) ; } Throwable [ ] result = new Throwable [ list . size ( ) ] ; return list . toArray ( result ) ;


signature:
public class ExceptionUtil { /** * Prints stack trace into a String . */
public static String exceptionStackTraceToString ( final Throwable t ) { } }

implementation: StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw , true ) ; t . printStackTrace ( pw ) ; StreamUtil . close ( pw ) ; StreamUtil . close ( sw ) ; return sw . toString ( ) ;


signature:
public class ExceptionUtil { /** * Prints full exception stack trace , from top to root cause , into a String . */
public static String exceptionChainToString ( Throwable t ) { } }

implementation: StringWriter sw = new StringWriter ( ) ; PrintWriter pw = new PrintWriter ( sw , true ) ; while ( t != null ) { t . printStackTrace ( pw ) ; t = t . getCause ( ) ; } StreamUtil . close ( pw ) ; StreamUtil . close ( sw ) ; return sw . toString ( ) ;


signature:
public class ExceptionUtil { /** * Build a message for the given base message and its cause . */
public static String buildMessage ( final String message , Throwable cause ) { } }

implementation: if ( cause != null ) { cause = getRootCause ( cause ) ; StringBuilder buf = new StringBuilder ( ) ; if ( message != null ) { buf . append ( message ) . append ( "; " ) ; } buf . append ( "<--- " ) . append ( cause ) ; return buf . toString ( ) ; } else { return message ; }


signature:
public class ExceptionUtil { /** * Introspects the < code > Throwable < / code > to obtain the root cause .
 * This method walks through the exception chain to the last element ,
 * " root " of the tree , and returns that exception . If no root cause found
 * returns provided throwable . */
public static Throwable getRootCause ( final Throwable throwable ) { } }

implementation:
Throwable cause = throwable . getCause ( ) ; if ( cause == null ) { return throwable ; } Throwable t = throwable ; // defend against ( malicious ? ) circularity
for ( int i = 0 ; i < 1000 ; i ++ ) { cause = t . getCause ( ) ; if ( cause == null ) { return t ; } t = cause ; } return throwable ;


signature:
public class ExceptionUtil { /** * Finds throwing cause in exception stack . Returns throwable object if cause class is matched .
 * Otherwise , returns < code > null < / code > . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public static < T extends Throwable > T findCause ( Throwable throwable , final Class < T > cause ) { while ( throwable != null ) { if ( throwable . getClass ( ) . equals ( cause ) ) { return ( T ) throwable ; } throwable = throwable . getCause ( ) ; } return null ;


signature:
public class ExceptionUtil { /** * Rolls up SQL exceptions by taking each proceeding exception
 * and making it a child of the previous using the < code > setNextException < / code >
 * method of SQLException . */
public static SQLException rollupSqlExceptions ( final Collection < SQLException > exceptions ) { } }

implementation: SQLException parent = null ; for ( SQLException exception : exceptions ) { if ( parent != null ) { exception . setNextException ( parent ) ; } parent = exception ; } return parent ;


signature:
public class ExceptionUtil { /** * Returns < code > non - null < / code > message for a throwable . */
public static String message ( final Throwable throwable ) { } }

implementation: String message = throwable . getMessage ( ) ; if ( StringUtil . isBlank ( message ) ) { message = throwable . toString ( ) ; } return message ;


signature:
public class ExceptionUtil { /** * Wraps exception to { @ code RuntimeException } . */
public static RuntimeException wrapToRuntimeException ( final Throwable throwable ) { } }

implementation: if ( throwable instanceof RuntimeException ) { return ( RuntimeException ) throwable ; } return new RuntimeException ( throwable ) ;


signature:
public class ExceptionUtil { /** * Unwraps invocation and undeclared exceptions to real cause . */
public static Throwable unwrapThrowable ( final Throwable wrappedThrowable ) { } }

implementation: Throwable unwrapped = wrappedThrowable ; while ( true ) { if ( unwrapped instanceof InvocationTargetException ) { unwrapped = ( ( InvocationTargetException ) unwrapped ) . getTargetException ( ) ; } else if ( unwrapped instanceof UndeclaredThrowableException ) { unwrapped = ( ( UndeclaredThrowableException ) unwrapped ) . getUndeclaredThrowable ( ) ; } else { return unwrapped ; } }


signature:
public class JSONAnnotationValues { /** * Shortcut for checking the annotation on annotated element and returning either the values or { @ code null } . */
public static JSONAnnotationValues of ( final AnnotationParser annotationParser , final AnnotatedElement annotatedElement ) { } }

implementation: if ( ! annotationParser . hasAnnotationOn ( annotatedElement ) ) { return null ; } return new JSONAnnotationValues ( annotationParser . of ( annotatedElement ) ) ;