signature:
public class MetricHelper { /** * Increment when result set row is read */
public void markResultSetRowMeter ( Query query ) { } }

implementation: ensureSqlId ( query ) ; String name = metricNamingStrategy . getResultSetRowMeter ( query . getSql ( ) , query . getSqlId ( ) ) ; markMeter ( name ) ;


signature:
public class JdbcProxyFactory { /** * Create a proxy for given JDBC proxy handler
 * @ param < T > Proxy type
 * @ param proxyHandler Proxy handler
 * @ return Proxy */
private < T > T newProxy ( JdbcProxyHandler < T > proxyHandler ) { } }

implementation: return proxyFactory . newProxy ( proxyHandler , proxyHandler . getProxyClass ( ) ) ;


signature:
public class JdbcProxyFactory { /** * Wrap a connection to monitor it .
 * @ param wrappedConnection Connection to wrap
 * @ return Wrapped connection */
public Connection wrapConnection ( Connection wrappedConnection ) { } }

implementation: Timer . Context lifeTimerContext = metricHelper . startConnectionLifeTimer ( ) ; return newProxy ( new ConnectionProxyHandler ( wrappedConnection , this , lifeTimerContext ) ) ;


signature:
public class JdbcProxyFactory { /** * Wrap a simple statement to monitor it .
 * @ param statement Statement to wrap
 * @ return Wrapped statement */
public Statement wrapStatement ( Statement statement ) { } }

implementation: Timer . Context lifeTimerContext = getMetricHelper ( ) . startStatementLifeTimer ( ) ; return newProxy ( new StatementProxyHandler ( statement , this , lifeTimerContext ) ) ;


signature:
public class JdbcProxyFactory { /** * Wrap a prepared statement to monitor it .
 * @ param preparedStatement Prepared statement to wrap
 * @ param sql SQL
 * @ return Wrapped prepared statement */
public PreparedStatement wrapPreparedStatement ( PreparedStatement preparedStatement , String sql ) { } }

implementation: Query query = new Query ( sql ) ; Timer . Context lifeTimerContext = getMetricHelper ( ) . startPreparedStatementLifeTimer ( query ) ; return newProxy ( new PreparedStatementProxyHandler ( preparedStatement , this , query , lifeTimerContext ) ) ;


signature:
public class JdbcProxyFactory { /** * Wrap a callable statement to monitor it .
 * @ param callableStatement Prepared statement to wrap
 * @ param sql SQL
 * @ return Wrapped prepared statement */
public CallableStatement wrapCallableStatement ( CallableStatement callableStatement , String sql ) { } }

implementation: Query query = new Query ( sql ) ; Timer . Context lifeTimerContext = getMetricHelper ( ) . startCallableStatementLifeTimer ( query ) ; return newProxy ( new CallableStatementProxyHandler ( callableStatement , this , query , lifeTimerContext ) ) ;


signature:
public class JdbcProxyFactory { /** * Wrap a result set to monitor it .
 * @ param resultSet set to wrap
 * @ param sql SQL related to Result set
 * @ return Wrapped prepared statement */
public ResultSet wrapResultSet ( ResultSet resultSet , String sql ) { } }

implementation: Query query = new Query ( sql ) ; Timer . Context lifeTimerContext = metricHelper . startResultSetLifeTimer ( query ) ; return ( ResultSet ) newProxy ( new ResultSetProxyHandler ( resultSet , getResultSetType ( resultSet ) , this , query , lifeTimerContext ) ) ;


signature:
public class JdbcProxyFactory { /** * Wrap a result set to monitor it .
 * @ param resultSet set to wrap
 * @ param query SQL query of result set
 * @ param lifeTimerContext Started timer
 * @ return Wrapped prepared statement */
public ResultSet wrapResultSet ( ResultSet resultSet , Query query , Timer . Context lifeTimerContext ) { } }

implementation: return ( ResultSet ) newProxy ( new ResultSetProxyHandler ( resultSet , getResultSetType ( resultSet ) , this , query , lifeTimerContext ) ) ;


signature:
public class JdbcProxyFactory { /** * Determine the interface implemented by this result set
 * @ param resultSet Result set */
private Class < ? extends ResultSet > getResultSetType ( ResultSet resultSet ) { } }

implementation: Class < ? extends ResultSet > resultSetType ; if ( resultSet instanceof RowSet ) { if ( resultSet instanceof CachedRowSet ) { if ( resultSet instanceof WebRowSet ) { if ( resultSet instanceof FilteredRowSet ) { resultSetType = FilteredRowSet . class ; } else if ( resultSet instanceof JoinRowSet ) { resultSetType = JoinRowSet . class ; } else { resultSetType = WebRowSet . class ; } } else { resultSetType = CachedRowSet . class ; } } else if ( resultSet instanceof JdbcRowSet ) { resultSetType = JdbcRowSet . class ; } else { resultSetType = RowSet . class ; } } else { resultSetType = ResultSet . class ; } return resultSetType ;


signature:
public class SqlObjectNameFactory { /** * Event */
@ Override public ObjectName createName ( String type , String domain , String name ) { } }

implementation:
Matcher matcher = PATTERN . matcher ( name ) ; ObjectName objectName = null ; if ( matcher . matches ( ) ) { String className = matcher . group ( 1 ) ; String database = matcher . group ( 2 ) ; String sql = matcher . group ( 3 ) ; String event = matcher . group ( 4 ) ; Hashtable < String , String > props = new Hashtable < > ( ) ; props . put ( "class" , className ) ; props . put ( "database" , database ) ; if ( sql != null ) { // , and \ are not allowed
props . put ( "sql" , sql . replaceAll ( "[:=*?,\\n\\\\]" , " " ) . replaceAll ( "[\\s]+" , " " ) ) ; } if ( event != null ) { props . put ( "event" , event ) ; } if ( type != null ) { props . put ( "metricType" , type ) ; } try { objectName = new ObjectName ( domain , props ) ; } catch ( MalformedObjectNameException malformedObjectNameException ) { } } if ( objectName == null ) { objectName = defaultObjectFactory . createName ( type , domain , name ) ; } return objectName ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc }
 * Example : java . sql . Statement . database . [ sqlId ] . exec */
public String getStatementExecuteTimer ( String sql , String sqlId ) { } }

implementation: return getStatementExecuteTimer ( Statement . class , sql , sqlId ) ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc }
 * Example : java . sql . PreparedStatement . database . [ sqlId ] */
public String getPreparedStatementLifeTimer ( String sql , String sqlId ) { } }

implementation: return getStatementTimer ( PreparedStatement . class , sql , sqlId ) ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc }
 * Example : java . sql . PreparedStatement . database . [ sqlId ] . exec */
public String getPreparedStatementExecuteTimer ( String sql , String sqlId ) { } }

implementation: return getStatementExecuteTimer ( PreparedStatement . class , sql , sqlId ) ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc }
 * Example : java . sql . CallableStatement . database . [ sqlId ] */
public String getCallableStatementLifeTimer ( String sql , String sqlId ) { } }

implementation: return getStatementTimer ( CallableStatement . class , sql , sqlId ) ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc }
 * Example : java . sql . CallableStatement . database . [ sqlId ] . exec */
public String getCallableStatementExecuteTimer ( String sql , String sqlId ) { } }

implementation: return getStatementExecuteTimer ( CallableStatement . class , sql , sqlId ) ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc } */
public String getResultSetLifeTimer ( String sql , String sqlId ) { } }

implementation: return MetricRegistry . name ( ResultSet . class , databaseName , sqlId ) ;


signature:
public class DefaultMetricNamingStrategy { /** * { @ inheritDoc } */
@ Override public String getResultSetRowMeter ( String sql , String sqlId ) { } }

implementation: return MetricRegistry . name ( ResultSet . class , databaseName , sqlId , "rows" ) ;


signature:
public class CowExecutor { /** * Build an args array that can be passed to cowsay .
 * @ return commandline args */
protected String [ ] buildArgs ( ) { } }

implementation: String result [ ] = new String [ 0 ] ; List < String > args = new ArrayList < String > ( ) ; if ( lang != null && lang . length ( ) > 0 ) { args . add ( flagify ( CowsayCli . Opt . LANG . toString ( ) ) ) ; args . add ( lang ) ; } if ( html ) { args . add ( flagify ( CowsayCli . Opt . HTML . toString ( ) ) ) ; } if ( alt != null && alt . length ( ) > 0 ) { args . add ( flagify ( CowsayCli . Opt . ALT . toString ( ) ) ) ; args . add ( alt ) ; } if ( wrap != null ) { args . add ( flagify ( CowsayCli . Opt . WRAP_AT . toString ( ) ) ) ; args . add ( wrap ) ; } buildFaceArgs ( args ) ; args . add ( message ) ; return args . toArray ( result ) ;


signature:
public class CowExecutor { /** * Face specific flags , either a face mode or face customizations .
 * @ param args The arg line to add to . */
private void buildFaceArgs ( final List < String > args ) { } }

implementation: if ( mode != null && CowFace . isKnownMode ( mode ) ) { args . add ( flagify ( mode ) ) ; } else { if ( eyes != null ) { args . add ( flagify ( CowsayCli . Opt . EYES . toString ( ) ) ) ; args . add ( eyes ) ; } if ( tongue != null ) { args . add ( flagify ( CowsayCli . Opt . TONGUE . toString ( ) ) ) ; args . add ( tongue ) ; } if ( cowfile != null ) { args . add ( flagify ( CowsayCli . Opt . COWFILE . toString ( ) ) ) ; args . add ( cowfile ) ; } }


signature:
public class CowExecutor { /** * Run cowsay with the provided properties .
 * @ return The formatted cow message .
 * @ throws IllegalStateException If mandatory properties have not been set . */
public String execute ( ) throws IllegalStateException { } }

implementation: validate ( ) ; String [ ] args = buildArgs ( ) ; String result ; if ( think ) { result = Cowsay . think ( args ) ; } else { result = Cowsay . say ( args ) ; } return result ;


signature:
public class CowsayTask { /** * Run cowsay with the provided attributes .
 * @ throws BuildException If something goes wrong during execution . */
@ Override public void execute ( ) throws BuildException { } }

implementation: try { String moo = executor . execute ( ) ; if ( this . property != null && this . property . length ( ) > 0 ) { getProject ( ) . setProperty ( this . property , moo ) ; } else { System . out . println ( moo ) ; } } catch ( IllegalStateException ex ) { throw new BuildException ( ex . getMessage ( ) , ex ) ; }


signature:
public class I18n { /** * Set the language .
 * @ param language A BCP47 language , e . g . " en " , " fr " . */
public static void setLanguage ( final String language ) { } }

implementation: currentLocale = new Locale ( language ) ; messages = ResourceBundle . getBundle ( "MessagesBundle" , currentLocale ) ;


signature:
public class I18n { /** * Get a message in the correct language .
 * @ param key The lookup key for the message .
 * @ return The message in the correct language , if found , otherwise in the default language . */
protected static String getMessage ( final String key ) { } }

implementation: if ( messages == null ) { setLanguage ( DEFAULT_LANG ) ; } return messages . getString ( key ) ;


signature:
public class Cowsay { /** * Do some cowsaying or cowthinking .
 * @ param args the command line arguments
 * @ param think if true will think instead of say ( the - - cowthink flag can also invoke thinking ) */
private static String sayOrThink ( final String [ ] args , final boolean think ) { } }

implementation:
try { boolean isThought = think ; String wordwrap = null ; CommandLine commandLine = CowsayCli . parseCmdArgs ( args ) ; if ( commandLine != null ) { if ( commandLine . hasOption ( CowsayCli . Opt . HELP . toString ( ) ) ) { CowsayCli . showCmdLineHelp ( ) ; } else if ( commandLine . hasOption ( CowsayCli . Opt . LIST_COWS . toString ( ) ) ) { String [ ] files = Cowloader . listAllCowfiles ( ) ; if ( files != null ) { return StringUtils . join ( files , System . getProperty ( "line.separator" ) ) ; } } else { String cowfileSpec = null ; CowFace cowFace = null ; if ( commandLine . hasOption ( CowsayCli . Opt . WRAP_AT . toString ( ) ) ) { wordwrap = commandLine . getOptionValue ( CowsayCli . Opt . WRAP_AT . toString ( ) ) ; } else if ( commandLine . hasOption ( CowsayCli . Opt . NOWRAP . toString ( ) ) ) { wordwrap = "0" ; } cowFace = getCowFaceByMode ( commandLine ) ; if ( cowFace == null ) { // if we are in here no modes were set
if ( commandLine . hasOption ( CowsayCli . Opt . COWFILE . toString ( ) ) ) { cowfileSpec = commandLine . getOptionValue ( CowsayCli . Opt . COWFILE . toString ( ) ) ; } cowFace = getCowFace ( commandLine ) ; } if ( commandLine . hasOption ( CowsayCli . Opt . THINK . toString ( ) ) ) { isThought = true ; } if ( cowfileSpec == null ) { cowfileSpec = Cowloader . DEFAULT_COW ; } String cowTemplate = Cowloader . load ( cowfileSpec ) ; if ( cowTemplate != null ) { String moosages [ ] = commandLine . getArgs ( ) ; String moosage = StringUtils . join ( moosages , " " ) ; if ( moosage != null && moosage . length ( ) > 0 ) { Message message = new Message ( moosage , isThought ) ; if ( wordwrap != null ) { message . setWordwrap ( wordwrap ) ; } String cow = CowFormatter . formatCow ( cowTemplate , cowFace , message ) ; cow = formatHtml ( commandLine , cow , moosage , isThought ) ; return cow ; } } } } } catch ( CowParseException ex ) { Logger . getLogger ( Cowsay . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } return "" ;


signature:
public class Cowsay { /** * May apply HTML markup to the cow , if requested in the command line .
 * @ param commandLine The command line with user options .
 * @ param plainCow The cow formatted in plain text .
 * @ param moosage The message the cow is saying .
 * @ param isThought true if this is cowthink instead of cowsay .
 * @ return Either the plaintext cow or an HTML marked up version , depending on command line . */
private static String formatHtml ( final CommandLine commandLine , final String plainCow , final String moosage , final boolean isThought ) { } }

implementation:
String cow = plainCow ; if ( commandLine . hasOption ( CowsayCli . Opt . HTML . toString ( ) ) ) { cow = StringEscapeUtils . escapeHtml4 ( cow ) ; cow = "

" + cow + "

" ; String alt ; if ( commandLine . hasOption ( CowsayCli . Opt . ALT . toString ( ) ) ) { alt = commandLine . getOptionValue ( CowsayCli . Opt . ALT . toString ( ) ) ; } else { alt = isThought ? I18n . getMessage ( "altthink" ) : I18n . getMessage ( "altsay" ) ; } String escaped = StringEscapeUtils . escapeHtml4 ( moosage ) ; cow += String . format ( alt , escaped ) ; cow += "

" ; } return cow ;


signature:
public class Cowsay { /** * If a pre - defined cow mode has been set on the command line then use that face .
 * @ param commandLine The command line with user options .
 * @ return The cowface for the mode selected on the command line or null if no mode set . */
private static CowFace getCowFaceByMode ( final CommandLine commandLine ) { } }

implementation: CowFace cowFace = null ; Set < String > modes = CowFace . COW_MODES . keySet ( ) ; for ( String mode : modes ) { if ( commandLine . hasOption ( mode ) ) { cowFace = CowFace . getByMode ( mode ) ; break ; } } return cowFace ;


signature:
public class Cowsay { /** * Get a regular cow face optionally formatted with custom eyes and tongue from the command line .
 * @ param commandLine The command line with user options .
 * @ return A regular cowface , possibly formatted with custom tongue and / or eyes . */
private static CowFace getCowFace ( final CommandLine commandLine ) { } }

implementation: CowFace cowFace ; cowFace = new CowFace ( ) ; if ( commandLine . hasOption ( CowsayCli . Opt . EYES . toString ( ) ) ) { cowFace . setEyes ( commandLine . getOptionValue ( CowsayCli . Opt . EYES . toString ( ) ) ) ; } if ( commandLine . hasOption ( CowsayCli . Opt . TONGUE . toString ( ) ) ) { cowFace . setTongue ( commandLine . getOptionValue ( CowsayCli . Opt . TONGUE . toString ( ) ) ) ; } return cowFace ;


signature:
public class Cowsay { /** * Will cowsay ( or cowthink if the - - cowthink flag is set )
 * @ param args the command line arguments */
public static void main ( final String [ ] args ) { } }

implementation: CowsayCli . addCowthinkOption ( ) ; String cowsay = say ( args ) ; if ( cowsay != null && cowsay . length ( ) > 0 ) { System . out . println ( cowsay ) ; }


signature:
public class CowFormatter { /** * Extracts the ascii art part of the cowfile , removing any before or after PERL comments , variable assignments , weird EOC markers etc .
 * @ param cow The raw cowfile content .
 * @ return The ascii art portion of the cowfile .
 * @ throws CowParseException if the cowfile cannot be parsed . */
private static String extractCowTemplate ( final String cow ) throws CowParseException { } }

implementation: Matcher matcher = COWSTART_RE . matcher ( cow ) ; if ( matcher . find ( 0 ) ) { String result = matcher . replaceFirst ( "" ) ; return result ; } else { throw new CowParseException ( "Could not parse cow " + cow ) ; }


signature:
public class CowFormatter { /** * Processes the cow template ( the raw content of a cowfile ) inserting face and message as appropriate .
 * @ param cow The content of a cowfile .
 * @ param face The face to apply to this cow .
 * @ param message The message the cow is saying or thinking .
 * @ return The formatted cow .
 * @ throws CowParseException If the cow could not be parsed . */
public static String formatCow ( final String cow , final CowFace face , final Message message ) throws CowParseException { } }

implementation:
String result = extractCowTemplate ( cow ) ; String tongue = face . getTongue ( ) ; String eyes = face . getEyes ( ) ; result = result . replaceAll ( "\\\\\\\\" , "\\\\" ) ; // do this first
result = result . replace ( "\\@" , "@" ) ; result = result . replace ( "\\$" , "$" ) ; result = result . replace ( "${tongue}" , tongue ) ; result = result . replace ( "$tongue" , tongue ) ; result = result . replace ( "$thoughts" , message . getThoughts ( ) ) ; result = result . replace ( "${eyes}" , eyes ) ; // sheep - doesn ' t help that i know zero perl
result = result . replace ( "$eyes" , eyes ) ; result = result . replaceAll ( "EOC\\s*$" , "" ) ; result = message . getMessage ( ) + result ; return result ;


signature:
public class Cowloader { /** * Call this with the provided cowfileSpec - that is the value passed to ` - f ` on the commandline .
 * @ param cowfileSpec If cowfileSpec contains a filepath separator it is interpreted as relative to CWD
 * otherwise the COWPATH will be searched . If not found on the COWPATH we will search for a bundled cowfile .
 * @ return The content of the specified cowfile ( or default cowfile if cowfileSpec is null or empty ) . */
public static String load ( final String cowfileSpec ) { } }

implementation:
String effectiveCowfileSpec = ( cowfileSpec != null ) ? cowfileSpec . trim ( ) : DEFAULT_COW ; if ( effectiveCowfileSpec . length ( ) > 0 ) { if ( ! effectiveCowfileSpec . endsWith ( COWFILE_EXT ) ) { effectiveCowfileSpec += COWFILE_EXT ; } InputStream cowInputStream ; if ( effectiveCowfileSpec . indexOf ( File . separatorChar ) >= 0 ) { cowInputStream = getCowFromPath ( effectiveCowfileSpec ) ; } else { cowInputStream = getCowFromCowPath ( effectiveCowfileSpec ) ; } if ( cowInputStream == null ) { // Maybe there should be a verbose mode where we log this sort of error instead of silently failing ?
cowInputStream = getCowFromResources ( DEFAULT_COW + COWFILE_EXT ) ; } if ( cowInputStream != null ) { String cow = cowInputStreamToString ( cowInputStream ) ; return cow ; } } return null ; // should never happen


signature:
public class Cowloader { /** * Reads a cowfile from an InputStream and returns a string .
 * @ param cowInputStream The InputStream instance to read into a String .
 * @ return A String representing the result of reading the entire InputStream . */
private static String cowInputStreamToString ( final InputStream cowInputStream ) { } }

implementation: BufferedReader reader = new BufferedReader ( new InputStreamReader ( cowInputStream ) ) ; StringBuilder sb = new StringBuilder ( ) ; String line ; try { String newLine = System . getProperty ( "line.separator" ) ; while ( ( line = reader . readLine ( ) ) != null ) { sb . append ( line ) ; sb . append ( newLine ) ; } reader . close ( ) ; } catch ( IOException ex ) { Logger . getLogger ( Cowloader . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } finally { if ( cowInputStream != null ) { try { cowInputStream . close ( ) ; } catch ( IOException ex ) { Logger . getLogger ( Cowloader . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } } } return sb . toString ( ) ;


signature:
public class Cowloader { /** * In the case that the cowfileSpec is a filesystem path call this method to attempt to load the cowfile .
 * It will attempt to load the cowfile relative to CWD and if that fails it will try as an absolute path .
 * @ param path A path to a cowfile either relative to CWD or an absolute path .
 * @ return An InputStream to the cowfile if it exists . */
private static InputStream getCowFromPath ( final String path ) { } }

implementation:
String cwd = System . getProperty ( "user.dir" ) ; // TODO is this really CWD ?
if ( cwd != null ) { File cowfile = new File ( cwd , path ) ; if ( isCowfile ( cowfile ) ) { return cowfileToCowInputStream ( cowfile ) ; } } // maybe it ' s an absolute path ?
File cowfile = new File ( path ) ; if ( isCowfile ( cowfile ) ) { return cowfileToCowInputStream ( cowfile ) ; } return null ;


signature:
public class Cowloader { /** * This will attempt to load a cowfile , by name , from the COWPATH environment variable or bundled cowfiles .
 * Note that bundled cowfiles are considered part of the COWPATH since this is how to original ` cowsay ` worked .
 * COWPATH takes precedence and bundled cowfiles are only considered after searching the COWPATH .
 * @ param cowName The name of a cowfile , e . g . " sheep " or " sheep . cow " .
 * @ return An InputStream to the first matching cowfile found . */
private static InputStream getCowFromCowPath ( final String cowName ) { } }

implementation: String cowPath = System . getenv ( "COWPATH" ) ; if ( cowPath != null ) { String [ ] paths = cowPath . split ( File . pathSeparator ) ; if ( paths != null ) { for ( String path : paths ) { File cowfile = getCowfile ( path , cowName ) ; if ( cowfile != null ) { return cowfileToCowInputStream ( cowfile ) ; } } } } return getCowFromResources ( cowName ) ;


signature:
public class Cowloader { /** * List the names of all cowfiles found when searching COWPATH ( including bundled cowfiles ) .
 * Primarily useful for the " - l " commandline flag and also handy for unit testing .
 * @ return The names of available cowfiles . */
public static String [ ] listAllCowfiles ( ) { } }

implementation:
String [ ] resultAsArray ; String [ ] bundled = null ; String cowfileExtRe = "\\" + COWFILE_EXT + "$" ; InputStream bundleStream = Cowloader . class . getResourceAsStream ( "/cowfile-list.csv" ) ; if ( bundleStream != null ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( bundleStream ) ) ; StringBuilder sb = new StringBuilder ( ) ; try { String line ; while ( ( line = reader . readLine ( ) ) != null ) { sb . append ( line ) ; } reader . close ( ) ; String bundleList = sb . toString ( ) ; bundled = bundleList . split ( "," ) ; } catch ( IOException ex ) { Logger . getLogger ( Cowloader . class . getName ( ) ) . log ( Level . WARNING , null , ex ) ; } finally { try { bundleStream . close ( ) ; } catch ( IOException ex ) { Logger . getLogger ( Cowloader . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } } } Set < String > result = new HashSet < String > ( ) ; if ( bundled != null ) { for ( String cowfile : bundled ) { if ( cowfile . endsWith ( COWFILE_EXT ) ) { // mech - and - cow for example is not a cowfile and should be excluded
result . add ( cowfile . replaceAll ( cowfileExtRe , "" ) ) ; } } } String cowPath = System . getenv ( "COWPATH" ) ; if ( cowPath != null ) { String [ ] paths = cowPath . split ( File . pathSeparator ) ; if ( paths != null ) { for ( String path : paths ) { File [ ] cowfiles = getCowFiles ( path ) ; if ( cowfiles != null ) { for ( File cowfile : cowfiles ) { result . add ( cowfile . getName ( ) . replaceAll ( cowfileExtRe , "" ) ) ; } } } } } resultAsArray = result . toArray ( new String [ result . size ( ) ] ) ; Arrays . sort ( resultAsArray ) ; return resultAsArray ;


signature:
public class Cowloader { /** * Determine if this File appears to be a genuine cowfile .
 * This is not a deep check , more rigor will be applied later .
 * @ param cowfile A potential cowfile .
 * @ return true if this File seems to be a cowfile . */
private static boolean isCowfile ( final File cowfile ) { } }

implementation: if ( cowfile != null && cowfile . exists ( ) ) { return cowfile . getName ( ) . endsWith ( COWFILE_EXT ) ; } return false ;


signature:
public class Cowloader { /** * Reads a File to an InputStream .
 * Not sure why I thought this should be a separate method , I guess it made sense at the time .
 * @ param cowfile The cowfile to read .
 * @ return An InputStream which can be used to read the File . */
private static InputStream cowfileToCowInputStream ( final File cowfile ) { } }

implementation: InputStream cowInputStream = null ; try { cowInputStream = new FileInputStream ( cowfile ) ; } catch ( FileNotFoundException ex ) { Logger . getLogger ( Cowloader . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } return cowInputStream ;


signature:
public class Cowloader { /** * Get a cowfile , by name , from the given directory .
 * @ param folder The absolute path to the filesystem folder .
 * @ param cowName The name of the cowfile to load ( without the " . cow " extension ) .
 * @ return A File if the cowfile is found in this directory otherwise null . */
private static File getCowfile ( final String folder , final String cowName ) { } }

implementation: File [ ] cowfiles = getCowFiles ( folder ) ; for ( File cowfile : cowfiles ) { if ( cowfile . getName ( ) . equals ( cowName ) ) { return cowfile ; } } return null ;


signature:
public class Cowloader { /** * Gets all cowfiles found in the given directory .
 * @ param folder The absolute path to the filesystem folder .
 * @ return A list of all cowfiles found in this directory . */
private static File [ ] getCowFiles ( final String folder ) { } }

implementation: File dir = new File ( folder ) ; File [ ] files ; files = dir . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( final File dir , final String name ) { return name . endsWith ( ".cow" ) ; } } ) ; return files ;


signature:
public class CowFace { /** * Get cow args by mode .
 * @ param mode A mode key , " b " for Borg , " d " for dead , " g " for greedy etc
 * @ return The CowArgs for the given mode or null if not found */
protected static CowFace getByMode ( final String mode ) { } }

implementation: if ( mode != null ) { return COW_MODES . get ( mode ) ; } return null ;


signature:
public class CowFace { /** * Set custom cow eyes .
 * @ param eyes The eyes to use - if more than two characters long the first two will be used . */
public final void setEyes ( final String eyes ) { } }

implementation: if ( eyes != null && eyes . length ( ) > 0 ) { if ( eyes . length ( ) > 2 ) { this . eyes = eyes . substring ( 0 , 2 ) ; } else { this . eyes = eyes ; } }


signature:
public class CowFace { /** * Set custom cow tongue .
 * @ param tongue The tongue to use - if more than two characters long the first two will be used . */
public final void setTongue ( final String tongue ) { } }

implementation: if ( tongue != null && tongue . length ( ) > 0 ) { if ( tongue . length ( ) > 2 ) { this . tongue = tongue . substring ( 0 , 2 ) ; } else { this . tongue = tongue ; } }


signature:
public class CowFace { /** * Determine if the given mode flag is known and mapped to a particular cow face .
 * @ param mode The key to the mode , generally a single character , e . g . " b " for " Borg " mode .
 * @ return true if this is a known mode . */
public static final boolean isKnownMode ( final String mode ) { } }

implementation: Set < String > modes = COW_MODES . keySet ( ) ; return modes . contains ( mode ) ;


signature:
public class CowsayCli { /** * Calling this method results in adding the non - standard " - - cowthink " option to the accepted commandline flags .
 * This is useful if calling cowsay as an executable JAR where there is no other way to determine a
 * ` cowsay ` or a ` cowthink ` invocation . */
protected static void addCowthinkOption ( ) { } }

implementation: if ( ! options . hasOption ( null ) ) { options . addOption ( null , Opt . THINK . text , false , "" ) ; }


signature:
public class CowsayCli { /** * Parses an array of arguments .
 * @ param argv Arguments array .
 * @ return The parsed arguments . */
public static CommandLine parseCmdArgs ( final String [ ] argv ) { } }

implementation: final CommandLineParser cmdLineParser = new DefaultParser ( ) ; try { CommandLine parsed = cmdLineParser . parse ( options , argv , true ) ; if ( parsed . hasOption ( Opt . LANG . text ) ) { String language = parsed . getOptionValue ( Opt . LANG . text ) ; if ( language != null ) { I18n . setLanguage ( language ) ; } } return parsed ; } catch ( MissingArgumentException ex ) { Option option = ex . getOption ( ) ; String flag = option . getOpt ( ) ; if ( flag == null ) { flag = option . getLongOpt ( ) ; } Logger . getLogger ( CowsayCli . class . getName ( ) ) . log ( Level . INFO , I18n . getMessage ( "missingarg" ) , flag ) ; } catch ( ParseException ex ) { Logger . getLogger ( CowsayCli . class . getName ( ) ) . log ( Level . FINEST , null , ex ) ; } return null ;


signature:
public class CowsayCli { /** * Call to add options descriptions to the command line options .
 * This is deferred so that language / locale changes will be reflected . */
private static void updateOptionDescriptions ( ) { } }

implementation: Collection < Option > allOptions = options . getOptions ( ) ; for ( Option option : allOptions ) { String key = option . getOpt ( ) ; if ( key == null ) { key = option . getLongOpt ( ) ; } if ( key != null ) { String description = I18n . getMessage ( key ) ; if ( description != null ) { if ( key . equals ( Opt . COWFILE . text ) ) { description = String . format ( description , File . separatorChar ) ; } option . setDescription ( description ) ; } } }


signature:
public class CowsayCli { /** * Displays help message to user . */
public static void showCmdLineHelp ( ) { } }

implementation: HelpFormatter formatter = new HelpFormatter ( ) ; updateOptionDescriptions ( ) ; formatter . printHelp ( I18n . getMessage ( "usage" ) , options ) ;


signature:
public class Bubble { /** * Draws a complete bubble around a line - wrapped message .
 * @ param bubble The BubbleWrap to use ( e . g . SPEECH _ BUBBLE or THOUGHT _ BUBBLE )
 * @ param message The message to wrap , it should already be line - wrapped if appropriate .
 * @ param longestLine The length of the longest line in the message .
 * @ return The message , wrapped in a bubble . */
private static String formatBubble ( final BubbleWrap bubble , final String message , final int longestLine ) { } }

implementation: String newLine = System . getProperty ( "line.separator" ) ; String [ ] lines = message . split ( newLine ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( bubble . buildTop ( longestLine ) ) ; if ( lines . length > 1 ) { sb . append ( bubble . formatMultiOpen ( lines [ 0 ] , longestLine ) ) ; for ( int i = 1 ; i < ( lines . length - 1 ) ; i ++ ) { sb . append ( bubble . formatMultiMid ( lines [ i ] , longestLine ) ) ; } sb . append ( bubble . formatMultiEnd ( lines [ ( lines . length - 1 ) ] , longestLine ) ) ; } else { sb . append ( bubble . formatSingle ( lines [ 0 ] ) ) ; } sb . append ( bubble . buildBottom ( longestLine ) ) ; return sb . toString ( ) ;


signature:
public class Message { /** * Applies word wrapping to the message to handle long lines .
 * @ param message The raw input message .
 * @ return The message with long lines wrapped . */
private String wrapMessage ( final String message ) { } }

implementation:
// Note that the original cowsay wraps lines mid - word .
// This version differs in that it wraps between words if possible .
int wrap = getWordwrap ( ) ; if ( wrap <= 0 ) { return message ; } final List < String > result = new ArrayList < String > ( ) ; String newLine = System . getProperty ( "line.separator" ) ; String [ ] lines = message . split ( newLine ) ; for ( String line : lines ) { result . add ( WordUtils . wrap ( line , wrap , null , true ) ) ; } return StringUtils . join ( result , newLine ) ;


signature:
public class Message { /** * Builds the bubble around the message .
 * @ param message The plain message as provided by the user .
 * @ return The message , line - wrapped and bubble - wrapped . */
private String formatMessage ( final String message ) { } }

implementation: String result ; if ( message != null ) { result = wrapMessage ( message ) ; int longestLine = getLongestLineLen ( result ) ; if ( ! isThought ) { result = Bubble . formatSpeech ( result , longestLine ) ; } else { result = Bubble . formatThought ( result , longestLine ) ; } return result ; } return "" ;


signature:
public class Message { /** * Set the length of the wordwrap , default is " 40 " , zero disables line - wrap .
 * @ param wordwrap A number indicating where ( approximately ) to line - wrap the message . */
public void setWordwrap ( final String wordwrap ) { } }

implementation:
try { int ww = Integer . parseInt ( wordwrap ) ; if ( ww >= 0 ) { this . wordwrap = ww ; } } catch ( Throwable ignore ) { // ignore
}


signature:
public class Message { /** * For a given multiline message determines the character count of the longest line .
 * @ param message The message after line - wrap has been applied but before any bubble wrapping .
 * @ return The count of characters in the longest line . */
private static int getLongestLineLen ( final String message ) { } }

implementation: String newLine = System . getProperty ( "line.separator" ) ; String [ ] lines = message . split ( newLine ) ; int maxLen = 0 ; for ( String line : lines ) { maxLen = Math . max ( maxLen , line . length ( ) ) ; } return maxLen ;


signature:
public class LogglyClient { /** * Sets the tags to use for Loggly messages . The list of
 * strings are converted into a single CSV ( trailing / leading
 * spaces stripped from each entry ) .
 * @ param tags CSV or list of tags */
public void setTags ( String ... tags ) { } }

implementation:
StringBuilder builder = new StringBuilder ( ) ; boolean first = true ; for ( String s : tags ) { for ( String t : s . split ( "," ) ) { t = t . trim ( ) ; if ( ! t . isEmpty ( ) ) { if ( ! first ) { builder . append ( "," ) ; } builder . append ( t ) ; } first = false ; } } // " tags " field must be null for Retrofit to exclude Loggly tags header .
// Empty header string is not acceptable .
this . tags = builder . length ( ) > 0 ? builder . toString ( ) : null ;


signature:
public class LogglyClient { /** * Posts a log message to Loggly
 * @ param message message to be logged
 * @ return { @ code true } if successful ; { @ code false } otherwise */
public boolean log ( String message ) { } }

implementation: if ( message == null ) return false ; boolean ok ; try { ok = loggly . log ( token , tags , message ) . isExecuted ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; ok = false ; } return ok ;


signature:
public class LogglyClient { /** * Posts a log message asynchronously to Loggly
 * @ param message message to be logged
 * @ param callback callback to be invoked on completion of the post */
public void log ( String message , final Callback callback ) { } }

implementation: if ( message == null ) return ; loggly . log ( token , tags , message , new retrofit2 . Callback < LogglyResponse > ( ) { @ Override public void onResponse ( Call < LogglyResponse > call , Response < LogglyResponse > response ) { callback . success ( ) ; } @ Override public void onFailure ( Call < LogglyResponse > call , Throwable throwable ) { callback . failure ( throwable . getMessage ( ) ) ; } } ) ;


signature:
public class LogglyClient { /** * Posts several log messages in bulk to Loggly
 * @ param messages messages to be logged
 * @ return { @ code true } if successful ; { @ code false } otherwise */
public boolean logBulk ( String ... messages ) { } }

implementation: if ( messages == null ) return false ; return logBulk ( Arrays . asList ( messages ) ) ;


signature:
public class LogglyClient { /** * Posts several log messages in bulk to Loggly
 * @ param messages messages to be logged
 * @ return { @ code true } if successful ; { @ code false } otherwise */
public boolean logBulk ( Collection < String > messages ) { } }

implementation: if ( messages == null ) return false ; String parcel = joinStrings ( messages ) ; if ( parcel . isEmpty ( ) ) return false ; boolean ok ; try { ok = loggly . logBulk ( token , tags , parcel ) . isExecuted ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; ok = false ; } return ok ;


signature:
public class LogglyClient { /** * Posts several log messages in bulk to Loggly asynchronously
 * @ param messages messages to be logged
 * @ param callback callback to be invoked on completion of the post */
public void logBulk ( Collection < String > messages , final Callback callback ) { } }

implementation: if ( messages == null ) return ; String parcel = joinStrings ( messages ) ; if ( parcel . isEmpty ( ) ) return ; loggly . logBulk ( token , tags , parcel , new retrofit2 . Callback < LogglyResponse > ( ) { @ Override public void onResponse ( Call < LogglyResponse > call , Response < LogglyResponse > response ) { callback . success ( ) ; } @ Override public void onFailure ( Call < LogglyResponse > call , Throwable throwable ) { callback . failure ( throwable . getMessage ( ) ) ; } } ) ;


signature:
public class LogglyClient { /** * Combines a collection of messages to be sent to Loggly .
 * In order to preserve event boundaries , the new lines in
 * each message are replaced with ' \ r ' , which get stripped
 * by Loggly .
 * @ param messages messages to be combined
 * @ return a single string containing all the messages */
private String joinStrings ( Collection < String > messages ) { } }

implementation:
StringBuilder b = new StringBuilder ( ) ; for ( String s : messages ) { if ( s == null || s . isEmpty ( ) ) { continue ; } // Preserve new - lines in this event by replacing them
// with " \ r " . Otherwise , they ' re processed as event
// delimiters , resulting in unintentional multiple events .
b . append ( s . replaceAll ( "[\r\n]" , "\r" ) ) . append ( '\n' ) ; } return b . toString ( ) ;


signature:
public class LogglyClientDemo { /** * Runs a demo of the Loggly client
 * @ param args command - line arguments . The first and only argument
 * should be your Loggly customer token .
 * http : / / loggly . com / docs / customer - token - authentication - token / */
public static void main ( String ... args ) { } }

implementation: if ( args . length == 0 || args [ 0 ] . trim ( ) . isEmpty ( ) ) { System . err . println ( "missing argument: loggly token\nsee http://loggly.com/docs/customer-token-authentication-token/" ) ; System . exit ( 1 ) ; } final String TOKEN = args [ 0 ] ; final ILogglyClient loggly = new LogglyClient ( TOKEN ) ; System . out . println ( "posting single event to Loggly asynchronously..." ) ; loggly . log ( "Hello!\nThis is a\nmulti-line event!\n" , new LogglyClient . Callback ( ) { public void success ( ) { System . out . println ( "callback succeeded" ) ; } public void failure ( String error ) { System . err . println ( "callback failed: " + error ) ; } } ) ; System . out . println ( "posting bulk events to Loggly asynchronously..." ) ; loggly . logBulk ( Arrays . asList ( "E1" , "E2" ) , new LogglyClient . Callback ( ) { public void success ( ) { System . out . println ( "bulk callback succeeded" ) ; } public void failure ( String error ) { System . err . println ( "bulk callback failed: " + error ) ; } } ) ; System . out . println ( "posting single event to Loggly..." ) ; boolean ok = loggly . log ( "Hello!\nThis is a\nmulti-line event!\n" ) ; System . out . println ( ok ? "ok" : "err" ) ; System . out . println ( "posting single JSON event to Loggly..." ) ; final String json = "{ \"timestamp\": \"2015-01-01T12:34:00Z\", \"message\": \"Event 100\", \"count\": 100 }" ; ok = loggly . log ( json ) ; System . out . println ( ok ? "ok" : "err" ) ; System . out . println ( "posting bulk events to Loggly..." ) ; ok = loggly . logBulk ( "This is a\nmulti-line event 1" , "Event 2" , "Event 3" ) ; System . out . println ( ok ? "ok" : "err" ) ; System . out . println ( "setting log tags to 'foo', 'bar', and 'baz'..." ) ; loggly . setTags ( "foo" , "bar,baz" ) ; ok = loggly . log ( "This should be tagged with 'foo', 'bar', and 'baz'" ) ; System . out . println ( ok ? "ok" : "err" ) ;


signature:
public class Catalog { /** * Gets all schemas for this catalog keyed by unique name .
 * @ see java . sql . DatabaseMetaData # getSchemas ( ) */
public SortedMap < String , Schema > getSchemas ( ) throws SQLException { } }

implementation:
synchronized ( getSchemasLock ) { if ( getSchemasCache == null ) { SortedMap < String , Schema > newSchemas = new TreeMap < > ( DatabaseMetaData . getCollator ( ) ) ; try ( ResultSet results = metaData . getMetaData ( ) . getSchemas ( ) ) { ResultSetMetaData resultsMeta = results . getMetaData ( ) ; while ( results . next ( ) ) { int colCount = resultsMeta . getColumnCount ( ) ; // System . err . println ( " DEBUG : Catalog : getSchemas ( ) : colCount = " + colCount ) ;
// for ( int i = 1 ; i < = colCount ; i + + ) {
// resultsMeta . getColumnName ( i ) ;
// System . err . println ( " DEBUG : Catalog : getSchemas ( ) : resultsMeta . getColumnName ( " + i + " ) = " + resultsMeta . getColumnName ( i ) ) ;
// System . err . println ( " DEBUG : Catalog : getSchemas ( ) : results . getString ( \ " table _ catalog \ " ) = " + results . getString ( " table _ catalog " ) ) ;
// System . err . println ( " DEBUG : Catalog : getSchemas ( ) : results . getString ( \ " TABLE _ CATALOG \ " ) = " + results . getString ( " TABLE _ CATALOG " ) ) ;
if ( colCount == 1 // PostgreSQL 8.3 only returns one column
|| results . getString ( "TABLE_CATALOG" ) == null // PostgreSQL 9.4 driver returns null
|| name . equals ( results . getString ( "TABLE_CATALOG" ) ) // Other driver
) { Schema newSchema = new Schema ( this , results . getString ( "TABLE_SCHEM" ) ) ; if ( newSchemas . put ( newSchema . getName ( ) , newSchema ) != null ) throw new AssertionError ( "Duplicate schema: " + newSchema ) ; } } } getSchemasCache = AoCollections . optimalUnmodifiableSortedMap ( newSchemas ) ; } return getSchemasCache ; }


signature:
public class Catalog { /** * Gets the schema of the provided name .
 * @ throws NoRowException if the schema doesn ' t exist */
public Schema getSchema ( String name ) throws NoRowException , SQLException { } }

implementation: Schema schema = getSchemas ( ) . get ( name ) ; if ( schema == null ) throw new NoRowException ( "name=" + name ) ; return schema ;


signature:
public class Catalog { /** * Gets a graph view of the imported / exported table relationships within this catalog .
 * TODO : Check is symmetric in JUnit test
 * @ param the set of tables types or < code > null < / code > for all types */
public SymmetricGraph < Table , Edge < Table > , SQLException > getForeignKeyGraph ( final Set < String > tableTypes ) { } }

implementation: return new SymmetricGraph < Table , Edge < Table > , SQLException > ( ) { @ Override public Set < Table > getVertices ( ) throws SQLException { Set < Table > vertices = new LinkedHashSet < > ( ) ; for ( Schema schema : getSchemas ( ) . values ( ) ) { for ( Table table : schema . getTables ( ) . values ( ) ) { if ( tableTypes == null || tableTypes . contains ( table . getTableType ( ) ) ) vertices . add ( table ) ; } } return AoCollections . optimalUnmodifiableSet ( vertices ) ; } @ Override public Set < Edge < Table > > getEdgesFrom ( Table from ) throws SQLException { Set < ? extends Table > tos = from . getImportedTables ( ) ; Set < Edge < Table > > edges = new LinkedHashSet < > ( tos . size ( ) * 4 / 3 + 1 ) ; for ( Table to : tos ) { if ( tableTypes == null || tableTypes . contains ( from . getTableType ( ) ) || tableTypes . contains ( to . getTableType ( ) ) ) edges . add ( new Edge < > ( from , to ) ) ; } return AoCollections . optimalUnmodifiableSet ( edges ) ; } @ Override public Set < Edge < Table > > getEdgesTo ( Table to ) throws SQLException { Set < ? extends Table > froms = to . getExportedTables ( ) ; Set < Edge < Table > > edges = new LinkedHashSet < > ( froms . size ( ) * 4 / 3 + 1 ) ; for ( Table from : froms ) { if ( tableTypes == null || tableTypes . contains ( from . getTableType ( ) ) || tableTypes . contains ( to . getTableType ( ) ) ) edges . add ( new Edge < > ( from , to ) ) ; } return AoCollections . optimalUnmodifiableSet ( edges ) ; } } ;


signature:
public class AutoGitContextListener { /** * Set to null when context shutdown */
@ Override public void contextInitialized ( ServletContextEvent sce ) { } }

implementation:
try { ServletContext sc ; synchronized ( servletContextLock ) { servletContext = sce . getServletContext ( ) ; sc = servletContext ; } // Find the top level directory
String gitToplevelPath = sc . getInitParameter ( GIT_TOPLEVEL_CONTEXT_PARAM ) ; File gitToplevelRaw ; if ( gitToplevelPath == null || gitToplevelPath . isEmpty ( ) ) { // Default to web root
String rootRealPath = sc . getRealPath ( "/" ) ; if ( rootRealPath == null ) throw new IllegalStateException ( "Unable to find web root and " + GIT_TOPLEVEL_CONTEXT_PARAM + " context parameter not provided" ) ; gitToplevelRaw = new File ( rootRealPath ) ; } else { if ( gitToplevelPath . startsWith ( "~/" ) ) { gitToplevelRaw = new File ( System . getProperty ( "user.home" ) , gitToplevelPath . substring ( 2 ) ) ; } else { gitToplevelRaw = new File ( gitToplevelPath ) ; } } if ( DEBUG ) sc . log ( "gitToplevelRaw: " + gitToplevelRaw ) ; Path gtl ; synchronized ( gitToplevelLock ) { gitToplevel = gitToplevelRaw . getCanonicalFile ( ) . toPath ( ) ; gtl = gitToplevel ; } if ( DEBUG ) sc . log ( "gitToplevel: " + gtl ) ; // Make sure root exists and is readable
if ( ! Files . isDirectory ( gtl , LinkOption . NOFOLLOW_LINKS ) ) throw new IOException ( "Git toplevel is not a directory: " + gtl ) ; if ( ! Files . isReadable ( gtl ) ) throw new IOException ( "Unable to read Git toplevel directory: " + gtl ) ; // Recursively watch for any changes in the directory
if ( DEBUG ) sc . log ( "Starting watcher" ) ; WatchService w ; synchronized ( watcherLock ) { watcher = gtl . getFileSystem ( ) . newWatchService ( ) ; w = watcher ; } resync ( ) ; if ( DEBUG ) sc . log ( "Starting watchThread" ) ; synchronized ( watcherThreadLock ) { watcherThread = new Thread ( watcherRunnable ) ; watcherThread . start ( ) ; } if ( DEBUG ) sc . log ( "Starting changeThread" ) ; synchronized ( changedThreadLock ) { changedThread = new Thread ( changedRunnable ) ; changedThread . start ( ) ; } sc . setAttribute ( APPLICATION_SCOPE_KEY , this ) ; } catch ( IOException e ) { throw new WrappedException ( e ) ; }


signature:
public class AutoGitContextListener { /** * Resyncs the entire directory recursively , registering and canceling any
 * discrepancies found . */
private void resync ( ) throws IOException { } }

implementation: Path gtl ; synchronized ( gitToplevelLock ) { gtl = gitToplevel ; } WatchService w ; synchronized ( watcherLock ) { w = watcher ; } if ( gtl != null && w != null ) { synchronized ( registered ) { Set < Path > extraKeys = new HashSet < > ( registered . keySet ( ) ) ; resync ( w , gtl , extraKeys ) ; for ( Path extraKey : extraKeys ) { if ( DEBUG ) log ( "Canceling watch key: " + extraKey ) ; registered . remove ( extraKey ) . cancel ( ) ; } } }


signature:
public class Schema { /** * Gets all tables for this schema keyed by unique name .
 * @ see java . sql . DatabaseMetaData # getTables ( ) */
public SortedMap < String , Table > getTables ( ) throws SQLException { } }

implementation: synchronized ( getTablesLock ) { if ( getTablesCache == null ) { SortedMap < String , Table > newTables = new TreeMap < > ( DatabaseMetaData . getCollator ( ) ) ; try ( ResultSet results = catalog . getMetaData ( ) . getMetaData ( ) . getTables ( catalog . getName ( ) , name , null , null ) ) { while ( results . next ( ) ) { Table newTable = new Table ( this , results . getString ( "TABLE_NAME" ) , results . getString ( "TABLE_TYPE" ) ) ; if ( newTables . put ( newTable . getName ( ) , newTable ) != null ) throw new AssertionError ( "Duplicate table: " + newTable ) ; } } getTablesCache = AoCollections . optimalUnmodifiableSortedMap ( newTables ) ; } return getTablesCache ; }


signature:
public class Schema { /** * Gets the table of the provided name .
 * @ throws NoRowException if the table doesn ' t exist */
public Table getTable ( String name ) throws NoRowException , SQLException { } }

implementation: Table table = getTables ( ) . get ( name ) ; if ( table == null ) throw new NoRowException ( ) ; return table ;


signature:
public class DatabaseConnection { /** * Gets a user - friendly description of the provided result in a string formatted like
 * < code > ( ' value ' , ' value ' , int _ value , . . . ) < / code > . This must not be used generate
 * SQL statements - it is just to provider user display . */
@ SuppressWarnings ( "deprecation" ) private static String getRow ( ResultSet result ) throws SQLException { } }

implementation:
StringBuilder sb = new StringBuilder ( ) ; sb . append ( '(' ) ; ResultSetMetaData metaData = result . getMetaData ( ) ; int colCount = metaData . getColumnCount ( ) ; for ( int c = 1 ; c <= colCount ; c ++ ) { if ( c > 1 ) sb . append ( ", " ) ; int colType = metaData . getColumnType ( c ) ; switch ( colType ) { case Types . BIGINT : case Types . BIT : case Types . BOOLEAN : case Types . DECIMAL : case Types . DOUBLE : case Types . FLOAT : case Types . INTEGER : case Types . NUMERIC : case Types . REAL : case Types . SMALLINT : case Types . TINYINT : sb . append ( result . getObject ( c ) ) ; break ; case Types . CHAR : case Types . DATE : case Types . LONGNVARCHAR : case Types . LONGVARCHAR : case Types . NCHAR : case Types . NVARCHAR : case Types . TIME : case Types . TIMESTAMP : case Types . VARCHAR : default : sb . append ( '\'' ) ; SQLUtility . escapeSQL ( result . getString ( c ) , sb ) ; sb . append ( '\'' ) ; break ; // default :
// throw new SQLException ( " Unexpected column type : " + colType ) ;
} } sb . append ( ')' ) ; return sb . toString ( ) ;


signature:
public class TempFileResult { /** * Implementation of writeTo
 * @ param out
 * @ param writeStart The absolute index to write from
 * @ param writeEnd The absolute index one past last character to write
 * @ throws IOException */
private void writeToImpl ( Writer out , long writeStart , long writeEnd ) throws IOException { } }

implementation:
try ( // TODO : If copying to another SegmentedBufferedWriter or AutoTempFileWriter , we have a chance here for disk - to - disk block level copying instead of going through all the conversions .
RandomAccessFile raf = new RandomAccessFile ( tempFile . getFile ( ) , "r" ) ) { byte [ ] bytes = BufferManager . getBytes ( ) ; try { char [ ] chars = BufferManager . getChars ( ) ; try { long index = writeStart ; raf . seek ( index << 1 ) ; while ( index < writeEnd ) { // Read a block
long blockSizeLong = ( writeEnd - index ) << 1 ; int blockSize = blockSizeLong > BufferManager . BUFFER_SIZE ? BufferManager . BUFFER_SIZE : ( int ) blockSizeLong ; assert ( blockSize & 1 ) == 0 : "Must be an even number for UTF-16 conversion" ; raf . readFully ( bytes , 0 , blockSize ) ; // Convert to characters
for ( int bpos = 0 , cpos = 0 ; bpos < blockSize ; bpos += 2 , cpos ++ ) { chars [ cpos ] = IoUtils . bufferToChar ( bytes , bpos ) ; } // Write to output
out . write ( chars , 0 , blockSize >> 1 ) ; // Update location
index += blockSize >> 1 ; } } finally { BufferManager . release ( chars , false ) ; } } finally { BufferManager . release ( bytes , false ) ; } }


signature:
public class DatabaseMetaData { /** * Gets all catalogs for this database keyed by unique name .
 * @ see java . sql . DatabaseMetaData # getCatalogs ( ) */
public SortedMap < String , Catalog > getCatalogs ( ) throws SQLException { } }

implementation: synchronized ( getCatalogsLock ) { if ( getCatalogsCache == null ) { SortedMap < String , Catalog > newCatalogs = new TreeMap < > ( englishCollator ) ; try ( ResultSet results = metaData . getCatalogs ( ) ) { while ( results . next ( ) ) { Catalog newCatalog = new Catalog ( this , results . getString ( 1 ) ) ; if ( newCatalogs . put ( newCatalog . getName ( ) , newCatalog ) != null ) throw new AssertionError ( "Duplicate catalog: " + newCatalog ) ; } } getCatalogsCache = AoCollections . optimalUnmodifiableSortedMap ( newCatalogs ) ; } return getCatalogsCache ; }


signature:
public class DatabaseMetaData { /** * Gets the catalog of the provided name .
 * @ throws NoRowException if the catalog doesn ' t exist */
public Catalog getCatalog ( String name ) throws NoRowException , SQLException { } }

implementation: Catalog catalog = getCatalogs ( ) . get ( name ) ; if ( catalog == null ) throw new NoRowException ( ) ; return catalog ;


signature:
public class CharArrayBufferWriter { /** * Grows as - needed to fit the provided new capacity .
 * @ returns the possibly new buffer . */
private char [ ] getBuffer ( int additional ) throws IOException { } }

implementation:
long newLen = ( long ) length + additional ; if ( newLen > MAX_LENGTH ) throw new IOException ( "Maximum buffer length is " + MAX_LENGTH + ", " + newLen + " requested" ) ; char [ ] buf = this . buffer ; int bufLen = buf . length ; if ( newLen > bufLen ) { // Find the next power of two that will hold all of the contents
int newBufLen = bufLen == 0 ? BufferManager . BUFFER_SIZE : ( bufLen << 1 ) ; while ( newBufLen < newLen ) { newBufLen <<= 1 ; } char [ ] newBuf = ( newBufLen == BufferManager . BUFFER_SIZE ) ? BufferManager . getChars ( ) : new char [ newBufLen ] ; System . arraycopy ( buf , 0 , newBuf , 0 , length ) ; // Recycle buffer
if ( bufLen == BufferManager . BUFFER_SIZE ) { BufferManager . release ( buf , false ) ; } buf = newBuf ; this . buffer = buf ; } return buf ;


signature:
public class LoggingResult { /** * Provides detailed logging for a media encoder . */
private void log ( Encoder encoder ) throws IOException { } }

implementation:
if ( encoder == null ) log . write ( "null" ) ; else { String className = encoder . getClass ( ) . getName ( ) ; // Some shortcuts from the ao - encoding project , classnames used here to avoid hard dependency
if ( "com.aoindustries.encoding.JavaScriptInXhtmlAttributeEncoder" . equals ( className ) ) { log . write ( "javaScriptInXhtmlAttributeEncoder" ) ; } else if ( "com.aoindustries.encoding.JavaScriptInXhtmlEncoder" . equals ( className ) ) { log . write ( "javaScriptInXhtmlEncoder" ) ; } else if ( "com.aoindustries.encoding.TextInXhtmlAttributeEncoder" . equals ( className ) ) { log . write ( "textInXhtmlAttributeEncoder" ) ; } else { log . write ( className ) ; } }


signature:
public class LoggingResult { /** * Provides detailed logging for a writer . */
private void log ( Writer writer ) throws IOException { } }

implementation: if ( writer == null ) { log . write ( "null" ) ; } else if ( writer instanceof LoggingWriter ) { LoggingWriter loggingWriter = ( LoggingWriter ) writer ; log . write ( "writer[" ) ; log . write ( Long . toString ( loggingWriter . getId ( ) ) ) ; log . write ( ']' ) ; } else if ( writer instanceof EncoderWriter ) { EncoderWriter encoderWriter = ( EncoderWriter ) writer ; log . write ( "new EncoderWriter(" ) ; log ( encoderWriter . getEncoder ( ) ) ; log . write ( ", " ) ; log ( encoderWriter . getOut ( ) ) ; log . write ( ')' ) ; } else { String classname = writer . getClass ( ) . getName ( ) ; if ( classname . equals ( "org.apache.jasper.runtime.BodyContentImpl" ) ) log . write ( "bodyContent" ) ; else if ( classname . equals ( "org.apache.jasper.runtime.JspWriterImpl" ) ) log . write ( "jspWriter" ) ; else log . write ( classname ) ; }


signature:
public class LexicalPositions { /** * Construct a lexical position at line 0 , column 0 , with the given file .
 * @ param file The type name
 * @ param < F > The type of file names
 * @ return A lexical position */
public static < F > LexicalPosition < F > zeroWithFile ( final F file ) { } }

implementation: return LexicalPosition . of ( 0 , 0 , Optional . of ( file ) ) ;


signature:
public class SegmentedResult { /** * Appends the full segment ( with original offset and length ) to the buffer . */
private void append ( int segmentIndex , StringBuilder buffer ) { } }

implementation: switch ( segmentTypes [ segmentIndex ] ) { case SegmentedWriter . TYPE_STRING : int off = segmentOffsets [ segmentIndex ] ; buffer . append ( ( String ) segmentValues [ segmentIndex ] , off , off + segmentLengths [ segmentIndex ] ) ; break ; case SegmentedWriter . TYPE_CHAR_NEWLINE : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; buffer . append ( '\n' ) ; break ; case SegmentedWriter . TYPE_CHAR_QUOTE : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; buffer . append ( '"' ) ; break ; case SegmentedWriter . TYPE_CHAR_APOS : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; buffer . append ( '\'' ) ; break ; case SegmentedWriter . TYPE_CHAR_OTHER : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; buffer . append ( ( ( Character ) segmentValues [ segmentIndex ] ) . charValue ( ) ) ; break ; default : throw new AssertionError ( ) ; }


signature:
public class SegmentedResult { /** * Appends the given range of a segment . to the buffer . */
private void append ( int segmentIndex , int off , int len , StringBuilder buffer ) { } }

implementation: switch ( segmentTypes [ segmentIndex ] ) { case SegmentedWriter . TYPE_STRING : buffer . append ( ( String ) segmentValues [ segmentIndex ] , off , off + len ) ; break ; case SegmentedWriter . TYPE_CHAR_NEWLINE : assert off == 0 ; assert len == 1 ; buffer . append ( '\n' ) ; break ; case SegmentedWriter . TYPE_CHAR_QUOTE : assert off == 0 ; assert len == 1 ; buffer . append ( '"' ) ; break ; case SegmentedWriter . TYPE_CHAR_APOS : assert off == 0 ; assert len == 1 ; buffer . append ( '\'' ) ; break ; case SegmentedWriter . TYPE_CHAR_OTHER : assert off == 0 ; assert len == 1 ; buffer . append ( ( ( Character ) segmentValues [ segmentIndex ] ) . charValue ( ) ) ; break ; default : throw new AssertionError ( ) ; }


signature:
public class SegmentedResult { /** * Writes the full segment ( with original offset and length ) to the given writer using the given encoder . */
private void writeSegment ( int segmentIndex , Encoder encoder , Writer out ) throws IOException { } }

implementation: switch ( segmentTypes [ segmentIndex ] ) { case SegmentedWriter . TYPE_STRING : encoder . write ( ( String ) segmentValues [ segmentIndex ] , segmentOffsets [ segmentIndex ] , segmentLengths [ segmentIndex ] , out ) ; break ; case SegmentedWriter . TYPE_CHAR_NEWLINE : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; encoder . write ( '\n' , out ) ; break ; case SegmentedWriter . TYPE_CHAR_QUOTE : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; encoder . write ( '"' , out ) ; break ; case SegmentedWriter . TYPE_CHAR_APOS : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; encoder . write ( '\'' , out ) ; break ; case SegmentedWriter . TYPE_CHAR_OTHER : assert segmentOffsets [ segmentIndex ] == 0 ; assert segmentLengths [ segmentIndex ] == 1 ; encoder . write ( ( Character ) segmentValues [ segmentIndex ] , out ) ; break ; default : throw new AssertionError ( ) ; }


signature:
public class SegmentedResult { /** * Writes the given range of a segment to the given writer using the given encoder . */
private void writeSegment ( int segmentIndex , int off , int len , Encoder encoder , Writer out ) throws IOException { } }

implementation: switch ( segmentTypes [ segmentIndex ] ) { case SegmentedWriter . TYPE_STRING : encoder . write ( ( String ) segmentValues [ segmentIndex ] , off , len , out ) ; break ; case SegmentedWriter . TYPE_CHAR_NEWLINE : assert off == 0 ; assert len == 1 ; encoder . write ( '\n' , out ) ; break ; case SegmentedWriter . TYPE_CHAR_QUOTE : assert off == 0 ; assert len == 1 ; encoder . write ( '"' , out ) ; break ; case SegmentedWriter . TYPE_CHAR_APOS : assert off == 0 ; assert len == 1 ; encoder . write ( '\'' , out ) ; break ; case SegmentedWriter . TYPE_CHAR_OTHER : assert off == 0 ; assert len == 1 ; encoder . write ( ( Character ) segmentValues [ segmentIndex ] , out ) ; break ; default : throw new AssertionError ( ) ; }


signature:
public class SegmentedResult { /** * Gets the character at the given index in a segment .
 * This is the absolute index , the offset is not added - in . */
private static char charAt ( byte type , Object value , int charIndex ) { } }

implementation: switch ( type ) { case SegmentedWriter . TYPE_STRING : return ( ( String ) value ) . charAt ( charIndex ) ; case SegmentedWriter . TYPE_CHAR_NEWLINE : assert charIndex == 0 ; return '\n' ; case SegmentedWriter . TYPE_CHAR_QUOTE : assert charIndex == 0 ; return '"' ; case SegmentedWriter . TYPE_CHAR_APOS : assert charIndex == 0 ; return '\'' ; case SegmentedWriter . TYPE_CHAR_OTHER : assert charIndex == 0 ; return ( Character ) value ; default : throw new AssertionError ( ) ; }


signature:
public class Database { /** * Loads the custom types when first needed and caches the results . */
private Map < String , Class < ? > > getSqlDataTypes ( ) throws SQLException { } }

implementation:
if ( sqlDataTypes == null ) { // Load custom types from ServiceLoader
Map < String , Class < ? > > newMap = new LinkedHashMap < > ( ) ; Iterator < SQLData > iter = ServiceLoader . load ( SQLData . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { SQLData sqlData = iter . next ( ) ; newMap . put ( sqlData . getSQLTypeName ( ) , sqlData . getClass ( ) ) ; } sqlDataTypes = newMap ; } return sqlDataTypes ;


signature:
public class Database { /** * @ see # executeTransaction ( com . aoindustries . sql . DatabaseCallableE )
 * @ see # isInTransaction ( ) */
public void executeTransaction ( final DatabaseRunnable runnable ) throws SQLException { } }

implementation: executeTransaction ( RuntimeException . class , new DatabaseCallableE < Void , RuntimeException > ( ) { @ Override public Void call ( DatabaseConnection db ) throws SQLException { runnable . run ( db ) ; return null ; } } ) ;


signature:
public class Database { /** * @ see # executeTransaction ( com . aoindustries . sql . DatabaseCallableE )
 * @ see # isInTransaction ( ) */
public < E extends Exception > void executeTransaction ( Class < E > eClass , final DatabaseRunnableE < E > runnable ) throws SQLException , E { } }

implementation: executeTransaction ( eClass , new DatabaseCallableE < Void , E > ( ) { @ Override public Void call ( DatabaseConnection db ) throws SQLException , E { runnable . run ( db ) ; return null ; } } ) ;


signature:
public class Database { /** * @ see # executeTransaction ( com . aoindustries . sql . DatabaseCallableE )
 * @ see # isInTransaction ( ) */
public < V > V executeTransaction ( final DatabaseCallable < V > callable ) throws SQLException { } }

implementation: return executeTransaction ( RuntimeException . class , new DatabaseCallableE < V , RuntimeException > ( ) { @ Override public V call ( DatabaseConnection db ) throws SQLException { return callable . call ( db ) ; } } ) ;


signature:
public class Database { /** * Executes an arbitrary transaction , providing automatic commit , rollback , and connection management .
 * Rolls - back the transaction on RuntimeException .
 * Rolls - back the transaction on NoRowException on the outer - most transaction only .
 * Rolls - back and closes the connection on all SQLException except NoRowException .
 * Rolls - back the transaction on E .
 * The connection allocated is stored as a ThreadLocal and will be automatically reused if
 * another transaction is performed within this transaction . Any nested transaction will automatically
 * become part of the enclosing transaction . For safety , a nested transaction will still rollback the
 * entire transaction on any exception .
 * @ see # isInTransaction ( ) */
public < V , E extends Exception > V executeTransaction ( Class < E > eClass , DatabaseCallableE < V , E > callable ) throws SQLException , E { } }

implementation:
DatabaseConnection conn = transactionConnection . get ( ) ; if ( conn != null ) { // Reuse existing connection
try { return callable . call ( conn ) ; } catch ( RuntimeException err ) { conn . rollback ( ) ; throw err ; } catch ( NoRowException err ) { throw err ; } catch ( SQLException err ) { conn . rollbackAndClose ( ) ; throw err ; } catch ( Exception e ) { conn . rollback ( ) ; if ( eClass . isInstance ( e ) ) throw eClass . cast ( e ) ; throw new SQLException ( e ) ; } } else { // Create new connection
conn = createDatabaseConnection ( ) ; try { transactionConnection . set ( conn ) ; try { V result = callable . call ( conn ) ; conn . commit ( ) ; return result ; } finally { transactionConnection . remove ( ) ; } } catch ( RuntimeException | NoRowException err ) { conn . rollback ( ) ; throw err ; } catch ( SQLException err ) { conn . rollbackAndClose ( ) ; throw err ; } catch ( Exception e ) { conn . rollback ( ) ; if ( eClass . isInstance ( e ) ) throw eClass . cast ( e ) ; throw new SQLException ( e ) ; } finally { conn . releaseConnection ( ) ; } }


signature:
public class AutoObjectFactory { /** * Gets the < code > valueOf ( int ) < / code > for the provided class or < code > null < / code > if doesn ' t
 * exist or is non - static or non - public . */
public static Method getValueOfIntMethod ( Class < ? > clazz ) { } }

implementation: Method existing = valueOfIntMethods . get ( clazz ) ; if ( existing == null ) { Method newMethod ; try { newMethod = clazz . getMethod ( "valueOf" , Integer . TYPE ) ; int mod = newMethod . getModifiers ( ) ; if ( ! Modifier . isStatic ( mod ) || ! Modifier . isPublic ( mod ) ) newMethod = notExists ; } catch ( NoSuchMethodException err ) { newMethod = notExists ; } existing = valueOfIntMethods . put ( clazz , newMethod ) ; if ( existing == null ) existing = newMethod ; } return existing == notExists ? null : existing ;


signature:
public class AutoObjectFactory { /** * Gets the < code > valueOf ( String ) < / code > for the provided class or < code > null < / code > if doesn ' t
 * exist or is non - static or non - public . */
public static Method getValueOfStringMethod ( Class < ? > clazz ) { } }

implementation:
// System . err . println ( " clazz = " + clazz ) ;
Method existing = valueOfStringMethods . get ( clazz ) ; if ( existing == null ) { Method newMethod ; try { newMethod = clazz . getMethod ( "valueOf" , String . class ) ; int mod = newMethod . getModifiers ( ) ; if ( ! Modifier . isStatic ( mod ) || ! Modifier . isPublic ( mod ) ) newMethod = notExists ; } catch ( NoSuchMethodException err ) { newMethod = notExists ; } existing = valueOfStringMethods . put ( clazz , newMethod ) ; if ( existing == null ) existing = newMethod ; } return existing == notExists ? null : existing ;


signature:
public class AutoObjectFactory { /** * Creates one object from the current values in the ResultSet . Looks for a
 * constructor that is assignable to the prefixParams and the result set values .
 * The constructor must exactly match the number of prefixParams plus the
 * result set . */
@ Override public T createObject ( ResultSet result ) throws SQLException { } }

implementation:
try { ResultSetMetaData metaData = result . getMetaData ( ) ; int numColumns = metaData . getColumnCount ( ) ; int numParams = prefixParams . length + numColumns ; Object [ ] params = new Object [ numParams ] ; // Find the candidate constructor
List < String > warnings = null ; Constructor < ? > [ ] constructors = clazz . getConstructors ( ) ; CONSTRUCTORS : for ( Constructor < ? > constructor : constructors ) { Class < ? > [ ] paramTypes = constructor . getParameterTypes ( ) ; if ( paramTypes . length == numParams ) { for ( int i = 0 ; i < prefixParams . length ; i ++ ) { Class < ? > paramType = paramTypes [ i ] ; if ( ! paramType . isAssignableFrom ( prefixParams [ i ] . getClass ( ) ) ) continue CONSTRUCTORS ; params [ i ] = prefixParams [ i ] ; // System . err . println ( paramType . getName ( ) + " ? " + ( params [ i ] = = null ? " null " : params [ i ] . getClass ( ) ) ) ;
} // All remaining columns must be assignable from JDBC
for ( int c = 1 ; c <= numColumns ; c ++ ) { int i = prefixParams . length + c - 1 ; Class < ? > paramType = paramTypes [ i ] ; // String first because it is commonly used
if ( paramType == String . class ) { params [ i ] = result . getString ( c ) ; // Primitives
} else if ( paramType == Integer . TYPE ) { int value = result . getInt ( c ) ; if ( result . wasNull ( ) ) throw new SQLException ( c + ": " + metaData . getColumnName ( c ) + ": null int" ) ; params [ i ] = value ; } else if ( paramType == Short . TYPE ) { short value = result . getShort ( c ) ; if ( result . wasNull ( ) ) throw new SQLException ( c + ": " + metaData . getColumnName ( c ) + ": null short" ) ; params [ i ] = value ; } else if ( paramType == Boolean . TYPE ) { boolean b = result . getBoolean ( c ) ; if ( result . wasNull ( ) ) throw new SQLException ( c + ": " + metaData . getColumnName ( c ) + ": null boolean" ) ; params [ i ] = b ; } else if ( paramType == Float . TYPE ) { float value = result . getFloat ( c ) ; if ( result . wasNull ( ) ) throw new SQLException ( c + ": " + metaData . getColumnName ( c ) + ": null float" ) ; params [ i ] = value ; } else if ( paramType == Long . TYPE ) { long value = result . getLong ( c ) ; if ( result . wasNull ( ) ) throw new SQLException ( c + ": " + metaData . getColumnName ( c ) + ": null long" ) ; params [ i ] = value ; // Other types
} else if ( paramType == Date . class ) { params [ i ] = result . getDate ( c ) ; } else if ( paramType == Boolean . class ) { boolean b = result . getBoolean ( c ) ; params [ i ] = result . wasNull ( ) ? null : b ; } else if ( paramType == Timestamp . class ) { params [ i ] = result . getTimestamp ( c ) ; } else if ( paramType == Integer . class ) { int value = result . getInt ( c ) ; params [ i ] = result . wasNull ( ) ? null : value ; } else if ( paramType == Float . class ) { float value = result . getFloat ( c ) ; params [ i ] = result . wasNull ( ) ? null : value ; } else if ( paramType == Short . class ) { short value = result . getShort ( c ) ; params [ i ] = result . wasNull ( ) ? null : value ; } else if ( paramType == Long . class ) { long value = result . getLong ( c ) ; params [ i ] = result . wasNull ( ) ? null : value ; } else { // Try to find valueOf ( int ) for unknown types
Method valueOfIntMethod = getValueOfIntMethod ( paramType ) ; if ( valueOfIntMethod != null ) { int value = result . getInt ( c ) ; if ( result . wasNull ( ) ) params [ i ] = null ; params [ i ] = valueOfIntMethod . invoke ( null , value ) ; } else { // Try to find valueOf ( String ) for unknown types
Method valueOfStringMethod = getValueOfStringMethod ( paramType ) ; if ( valueOfStringMethod != null ) { String value = result . getString ( c ) ; params [ i ] = result . wasNull ( ) ? null : valueOfStringMethod . invoke ( null , value ) ; } else { if ( warnings == null ) warnings = new ArrayList < > ( ) ; warnings . add ( "Unexpected parameter class: " + paramType . getName ( ) ) ; continue CONSTRUCTORS ; } } } // System . err . println ( paramType . getName ( ) + " ? " + ( params [ i ] = = null ? " null " : params [ i ] . getClass ( ) ) ) ;
} Object newInstance = constructor . newInstance ( params ) ; // System . err . println ( newInstance . getClass ( ) . getName ( ) + " : " + newInstance ) ;
return clazz . cast ( newInstance ) ; } } StringBuilder message = new StringBuilder ( "Unable to find matching constructor" ) ; if ( warnings != null ) for ( String warning : warnings ) message . append ( EOL ) . append ( warning ) ; throw new SQLException ( message . toString ( ) ) ; } catch ( InstantiationException | IllegalAccessException | InvocationTargetException err ) { throw new SQLException ( err ) ; } }


signature:
public class Table { /** * Gets all columns for this schema keyed by unique name .
 * @ see java . sql . DatabaseMetaData # getColumns ( java . lang . String , java . lang . String , java . lang . String , java . lang . String ) */
public SortedMap < String , Column > getColumnMap ( ) throws SQLException { } }

implementation: synchronized ( getColumnMapLock ) { if ( getColumnMapCache == null ) { SortedMap < String , Column > newColumnMap = new TreeMap < > ( DatabaseMetaData . getCollator ( ) ) ; try ( ResultSet results = schema . getCatalog ( ) . getMetaData ( ) . getMetaData ( ) . getColumns ( schema . getCatalog ( ) . getName ( ) , schema . getName ( ) , name , null ) ) { while ( results . next ( ) ) { Column newColumn = new Column ( this , results . getString ( "COLUMN_NAME" ) , results . getInt ( "DATA_TYPE" ) , results . getString ( "TYPE_NAME" ) , getInteger ( results , "COLUMN_SIZE" ) , getInteger ( results , "DECIMAL_DIGITS" ) , results . getInt ( "NULLABLE" ) , results . getString ( "COLUMN_DEF" ) , getInteger ( results , "CHAR_OCTET_LENGTH" ) , results . getInt ( "ORDINAL_POSITION" ) , results . getString ( "IS_NULLABLE" ) , results . getString ( "IS_AUTOINCREMENT" ) ) ; if ( newColumnMap . put ( newColumn . getName ( ) , newColumn ) != null ) throw new AssertionError ( "Duplicate column: " + newColumn ) ; } } getColumnMapCache = AoCollections . optimalUnmodifiableSortedMap ( newColumnMap ) ; } return getColumnMapCache ; }


signature:
public class Table { /** * Gets the column of the provided name .
 * @ throws NoRowException if the column doesn ' t exist */
public Column getColumn ( String name ) throws NoRowException , SQLException { } }

implementation: Column column = getColumnMap ( ) . get ( name ) ; if ( column == null ) throw new NoRowException ( ) ; return column ;


signature:
public class Table { /** * Gets all columns for this schema in their ordinal position order .
 * Column with ordinal position one is at index zero .
 * @ see # getColumnMap ( ) */
public List < Column > getColumns ( ) throws SQLException { } }

implementation: synchronized ( getColumnsLock ) { if ( getColumnsCache == null ) { SortedMap < String , Column > columnMap = getColumnMap ( ) ; List < Column > newColumns = new ArrayList < > ( columnMap . size ( ) ) ; for ( int i = 0 ; i < columnMap . size ( ) ; i ++ ) newColumns . add ( null ) ; for ( Column column : columnMap . values ( ) ) { int ordinalPosition = column . getOrdinalPosition ( ) ; if ( newColumns . set ( ordinalPosition - 1 , column ) != null ) throw new SQLException ( "Duplicate ordinal position: " + ordinalPosition ) ; } for ( int i = 0 ; i < newColumns . size ( ) ; i ++ ) { if ( newColumns . get ( i ) == null ) throw new SQLException ( "Missing ordinal position: " + ( i + 1 ) ) ; } getColumnsCache = AoCollections . optimalUnmodifiableList ( newColumns ) ; } return getColumnsCache ; }


signature:
public class Table { /** * Gets the column of the provided ordinal position , where positions start at one .
 * @ throws NoRowException if the column doesn ' t exist */
public Column getColumn ( int ordinalPosition ) throws NoRowException , SQLException { } }

implementation: try { return getColumns ( ) . get ( ordinalPosition - 1 ) ; } catch ( IndexOutOfBoundsException exc ) { throw new NoRowException ( exc ) ; }


signature:
public class Table { /** * Gets the primary key for this table or < code > null < / code > if not found . */
public Index getPrimaryKey ( ) throws SQLException { } }

implementation:
synchronized ( getPrimaryKeyLock ) { if ( ! getPrimaryKeyCached ) { String pkName = null ; List < Column > columns = new AutoGrowArrayList < > ( ) ; try ( ResultSet results = schema . getCatalog ( ) . getMetaData ( ) . getMetaData ( ) . getPrimaryKeys ( schema . getCatalog ( ) . getName ( ) , schema . getName ( ) , name ) ) { while ( results . next ( ) ) { String columnName = results . getString ( "COLUMN_NAME" ) ; int keySeq = results . getInt ( "KEY_SEQ" ) ; String newPkName = results . getString ( "PK_NAME" ) ; if ( newPkName != null ) { if ( pkName == null ) pkName = newPkName ; else if ( ! newPkName . equals ( pkName ) ) throw new SQLException ( "Mismatched PK_NAME values: " + newPkName + "!=" + pkName ) ; } if ( columns . set ( keySeq - 1 , getColumn ( columnName ) ) != null ) throw new SQLException ( "Duplicate key sequence: " + keySeq ) ; } } if ( columns . isEmpty ( ) ) { getPrimaryKeyCache = null ; getPrimaryKeyCached = true ; } else { // Make sure no gaps in the key sequence
for ( int i = 0 ; i < columns . size ( ) ; i ++ ) { if ( columns . get ( i ) == null ) throw new SQLException ( "Missing key sequence in index: " + ( i + 1 ) ) ; } getPrimaryKeyCache = new Index ( this , pkName , IndexType . PRIMARY_KEY , columns ) ; getPrimaryKeyCached = true ; } } return getPrimaryKeyCache ; }


signature:
public class Table { /** * Gets the set of tables that this table depends on .
 * This is based on getImportedKeys */
public Set < ? extends Table > getImportedTables ( ) throws SQLException { } }

implementation: synchronized ( getImportedTablesLock ) { if ( getImportedTablesCache == null ) { Set < Table > newImportedTables = new LinkedHashSet < > ( ) ; Catalog catalog = schema . getCatalog ( ) ; DatabaseMetaData metaData = catalog . getMetaData ( ) ; try ( ResultSet results = schema . getCatalog ( ) . getMetaData ( ) . getMetaData ( ) . getImportedKeys ( schema . getCatalog ( ) . getName ( ) , schema . getName ( ) , name ) ) { while ( results . next ( ) ) { String pkCat = results . getString ( "PKTABLE_CAT" ) ; Catalog pkCatalog = pkCat == null ? catalog : metaData . getCatalog ( pkCat ) ; newImportedTables . add ( pkCatalog . getSchema ( results . getString ( "PKTABLE_SCHEM" ) ) . getTable ( results . getString ( "PKTABLE_NAME" ) ) ) ; } } getImportedTablesCache = AoCollections . optimalUnmodifiableSet ( newImportedTables ) ; } return getImportedTablesCache ; }


signature:
public class Table { /** * Gets the set of tables that depend on this table .
 * This is based on getExportedKeys */
public Set < ? extends Table > getExportedTables ( ) throws SQLException { } }

implementation: synchronized ( getExportedTablesLock ) { if ( getExportedTablesCache == null ) { Set < Table > newExportedTables = new LinkedHashSet < > ( ) ; Catalog catalog = schema . getCatalog ( ) ; DatabaseMetaData metaData = catalog . getMetaData ( ) ; try ( ResultSet results = schema . getCatalog ( ) . getMetaData ( ) . getMetaData ( ) . getExportedKeys ( schema . getCatalog ( ) . getName ( ) , schema . getName ( ) , name ) ) { while ( results . next ( ) ) { String fkCat = results . getString ( "FKTABLE_CAT" ) ; Catalog fkCatalog = fkCat == null ? catalog : metaData . getCatalog ( fkCat ) ; newExportedTables . add ( fkCatalog . getSchema ( results . getString ( "FKTABLE_SCHEM" ) ) . getTable ( results . getString ( "FKTABLE_NAME" ) ) ) ; } } getExportedTablesCache = AoCollections . optimalUnmodifiableSet ( newExportedTables ) ; } return getExportedTablesCache ; }


signature:
public class SegmentedWriter { /** * Adds a new segment . */
private void addSegment ( byte type , Object value , int off , int len ) { } }

implementation:
assert ! isClosed ; assert len > 0 : "Empty segments should never be added" ; final int arraylen = segmentValues . length ; if ( segmentCount == arraylen ) { // Need to grow
if ( arraylen == 0 ) { this . segmentTypes = new byte [ START_LEN ] ; this . segmentValues = new Object [ START_LEN ] ; this . segmentOffsets = new int [ START_LEN ] ; this . segmentLengths = new int [ START_LEN ] ; } else { // Double capacity and copy
int newLen = arraylen << 1 ; byte [ ] newTypes = new byte [ newLen ] ; System . arraycopy ( segmentTypes , 0 , newTypes , 0 , arraylen ) ; this . segmentTypes = newTypes ; Object [ ] newValues = new Object [ newLen ] ; System . arraycopy ( segmentValues , 0 , newValues , 0 , arraylen ) ; this . segmentValues = newValues ; int [ ] newOffsets = new int [ newLen ] ; System . arraycopy ( segmentOffsets , 0 , newOffsets , 0 , arraylen ) ; this . segmentOffsets = newOffsets ; int [ ] newLengths = new int [ newLen ] ; System . arraycopy ( segmentLengths , 0 , newLengths , 0 , arraylen ) ; this . segmentLengths = newLengths ; } } segmentTypes [ segmentCount ] = type ; segmentValues [ segmentCount ] = value ; segmentOffsets [ segmentCount ] = off ; segmentLengths [ segmentCount ++ ] = len ;


signature:
public class LoggingWriter { /** * Writes a character , unicode escaping as needed . */
private void log ( char ch ) throws IOException { } }

implementation: if ( ch == '\t' ) log . write ( "'\\t'" ) ; else if ( ch == '\b' ) log . write ( "'\\b'" ) ; else if ( ch == '\n' ) log . write ( "'\\n'" ) ; else if ( ch == '\r' ) log . write ( "'\\r'" ) ; else if ( ch == '\f' ) log . write ( "'\\f'" ) ; else if ( ch == '\'' ) log . write ( "'\\'" ) ; else if ( ch == '\\' ) log . write ( "'\\\\'" ) ; else if ( ch == '"' ) log . write ( "'\\\"'" ) ; else if ( ch < ' ' ) { log . write ( "'\\u" ) ; String hex = Integer . toHexString ( ch ) ; for ( int l = hex . length ( ) ; l < 4 ; l ++ ) log . write ( '0' ) ; log . write ( hex ) ; log . write ( '\'' ) ; } else { log . write ( '\'' ) ; log . write ( ch ) ; log . write ( '\'' ) ; }


signature:
public class LoggingWriter { /** * Writes a String , unicode escaping as needed . */
private void log ( String value ) throws IOException { } }

implementation: if ( value == null ) { log . write ( "(String)null" ) ; } else { log . write ( '"' ) ; for ( int i = 0 , len = value . length ( ) ; i < len ; i ++ ) { char ch = value . charAt ( i ) ; if ( ch == '\t' ) log . write ( "\\t" ) ; else if ( ch == '\b' ) log . write ( "\\b" ) ; else if ( ch == '\n' ) log . write ( "\\n" ) ; else if ( ch == '\r' ) log . write ( "\\r" ) ; else if ( ch == '\f' ) log . write ( "\\f" ) ; else if ( ch == '\\' ) log . write ( "\\\\" ) ; else if ( ch == '"' ) log . write ( "\\\"" ) ; else if ( ch < ' ' ) { log . write ( "\\u" ) ; String hex = Integer . toHexString ( ch ) ; for ( int l = hex . length ( ) ; l < 4 ; l ++ ) log . write ( '0' ) ; log . write ( hex ) ; } else { log . write ( ch ) ; } } log . write ( '"' ) ; }


signature:
public class BeanManagerProvider { /** * Looks up the current bean manager in JNDI , or returns the value set by
 * { @ link # setBeanManager ( BeanManager ) } as fallback .
 * @ return */
public static BeanManager getBeanManager ( ) { } }

implementation: try { InitialContext initialContext = new InitialContext ( ) ; return ( BeanManager ) initialContext . lookup ( "java:comp/BeanManager" ) ; } catch ( NamingException e ) { if ( beanManager != null ) { return beanManager ; } throw new IllegalStateException ( "BeanManager not found in JNDI and not set via setBeanManager()" ) ; }


signature:
public class Values { /** * Get an empty set of values from the pool . Make sure to
 * { @ link # release ( ContentValues ) release } it back to the pool when you no longer need it . */
public static ContentValues acquire ( ) { } }

implementation: ContentValues vals = sPool . acquire ( ) ; return vals != null ? vals : new ContentValues ( ) ;


signature:
public class Values { /** * Put all of the values into the existing set .
 * @ param values length must be a multiple of two : { @ code String key , Object value , . . . }
 * @ throws IllegalArgumentException if a value type is not supported */
public static ContentValues putAll ( ContentValues target , Object ... values ) { } }

implementation: int length = values . length ; checkArgument ( length % 2 == 0 , "values length must be a multiple of two" ) ; for ( int i = 0 ; i < length ; i += 2 ) { String key = ( String ) values [ i ] ; Object val = values [ i + 1 ] ; if ( val == null ) { target . putNull ( key ) ; } else if ( val instanceof String ) { target . put ( key , ( String ) val ) ; } else if ( val instanceof Long ) { target . put ( key , ( Long ) val ) ; } else if ( val instanceof Integer ) { target . put ( key , ( Integer ) val ) ; } else if ( val instanceof Boolean ) { target . put ( key , ( Boolean ) val ) ; } else if ( val instanceof Double ) { target . put ( key , ( Double ) val ) ; } else if ( val instanceof Float ) { target . put ( key , ( Float ) val ) ; } else if ( val instanceof byte [ ] ) { target . put ( key , ( byte [ ] ) val ) ; } else if ( val instanceof Byte ) { target . put ( key , ( Byte ) val ) ; } else if ( val instanceof Short ) { target . put ( key , ( Short ) val ) ; } else { throw new IllegalArgumentException ( "ContentValues does not support values of type " + val . getClass ( ) . getName ( ) + " (provided for key '" + key + "')" ) ; }


signature:
public class RealmBindingAdapter { /** * Update the contents of the binding to reflect the item at the position . Any payload info can
 * be used to run an efficient partial update . */
public void onBind ( B binding , E item , int position , List < Object > payloads ) { } }

implementation: onBind ( binding , item , position ) ;


signature:
public class GoogleMaps { /** * Move and zoom to the most recently reported location .
 * @ see CameraUpdateFactory # newLatLngZoom ( LatLng , float ) */
public void moveCameraToLastLocation ( GoogleMap map , float zoom ) { } }

implementation: mProvider . getLastLocation ( ) . subscribe ( location -> map . moveCamera ( CameraUpdateFactory . newLatLngZoom ( new LatLng ( location . getLatitude ( ) , location . getLongitude ( ) ) , zoom ) ) ) ;


signature:
public class GoogleMaps { /** * If the position is not visible on the map , animate the camera to include it , after the delay . */
public void animateCameraToIncludePosition ( GoogleMap map , LatLng position , long delay ) { } }

implementation: if ( ! map . getProjection ( ) . getVisibleRegion ( ) . latLngBounds . contains ( position ) ) { if ( delay > 0 ) { new Handler ( Looper . getMainLooper ( ) ) . postDelayed ( ( ) -> doAnimateCameraToIncludePosition ( map , position ) , delay ) ; } else { doAnimateCameraToIncludePosition ( map , position ) ; } }


signature:
public class SprocketsActivity { /** * If { @ link # onSaveInstanceState ( Bundle ) onSaveInstanceState } hasn ' t been called yet , post the
 * action now . Otherwise save the action and run it when the Activity resumes . */
@ UiThread public void postWhenResumed ( Runnable action ) { } }

implementation: if ( ! mStateSaved ) { if ( mHandler == null ) { mHandler = new Handler ( ) ; } mHandler . post ( action ) ; } else { if ( mPosts == null ) { mPosts = new ArrayDeque < > ( ) ; } mPosts . offer ( action ) ; }


signature:
public class Uris { /** * Append the cursor ' s { @ link BaseColumns # _ ID _ ID } value to the URI .
 * @ throws IllegalArgumentException if the cursor does not have an _ id column */
public static Uri appendId ( Uri uri , Cursor cursor ) { } }

implementation: return ContentUris . withAppendedId ( uri , cursor . getLong ( cursor . getColumnIndexOrThrow ( _ID ) ) ) ;


signature:
public class Uris { /** * Append a { @ link Content # GROUP _ BY group _ by } query parameter to the URI .
 * @ since 2.4.0 */
public static Uri groupBy ( Uri uri , String groupBy ) { } }

implementation: return groupByHavingLimit ( uri , groupBy , null , null ) ;


signature:
public class Uris { /** * Append { @ link Content # GROUP _ BY group _ by } and { @ link Content # HAVING having } query parameters
 * to the URI .
 * @ since 2.4.0 */
public static Uri groupByHaving ( Uri uri , String groupBy , String having ) { } }

implementation: return groupByHavingLimit ( uri , groupBy , having , null ) ;


signature:
public class Uris { /** * Append a { @ link Content # LIMIT limit } query parameter to the URI .
 * @ since 2.4.0 */
public static Uri limit ( Uri uri , int limit ) { } }

implementation: return limit ( uri , String . valueOf ( limit ) ) ;


signature:
public class Uris { /** * Append a { @ link Content # LIMIT limit } query parameter to the URI . */
public static Uri limit ( Uri uri , String limit ) { } }

implementation: return groupByHavingLimit ( uri , null , null , limit ) ;


signature:
public class Uris { /** * Append { @ link Content # GROUP _ BY group _ by } , { @ link Content # HAVING having } , and
 * { @ link Content # LIMIT limit } query parameters to the URI . Any null or empty parameters are
 * skipped .
 * @ since 2.4.0 */
public static Uri groupByHavingLimit ( Uri uri , String groupBy , String having , String limit ) { } }

implementation: Builder builder = uri . buildUpon ( ) ; if ( ! TextUtils . isEmpty ( groupBy ) ) { builder . appendQueryParameter ( GROUP_BY , groupBy ) ; } if ( ! TextUtils . isEmpty ( having ) ) { builder . appendQueryParameter ( HAVING , having ) ; } if ( ! TextUtils . isEmpty ( limit ) ) { builder . appendQueryParameter ( LIMIT , limit ) ; } return builder . build ( ) ;


signature:
public class Uris { /** * Append the ID , if it is greater than zero , and a { @ link Content # NOTIFY _ CHANGE notify _ change }
 * query parameter to the URI .
 * @ since 2.1.0 */
public static Uri notifyChange ( Uri uri , long id , boolean notify ) { } }

implementation: Builder builder = uri . buildUpon ( ) ; if ( id > 0 ) { ContentUris . appendId ( builder , id ) ; } return builder . appendQueryParameter ( NOTIFY_CHANGE , notify ? "1" : "0" ) . build ( ) ;


signature:
public class Uris { /** * Get a { @ code mailto } Uri with the headers . Any null or empty parameters are skipped . The
 * subject and body will be encoded . */
public static Uri mailto ( List < String > to , List < String > cc , List < String > bcc , String subject , String body ) { } }

implementation:
String encSubject = Uri . encode ( subject ) ; String encBody = Uri . encode ( body ) ; StringBuilder ssp = new StringBuilder ( CollectionUtils . size ( to ) * 34 + CollectionUtils . size ( cc ) * 34 + CollectionUtils . size ( bcc ) * 34 + StringUtils . length ( encSubject ) + StringUtils . length ( encBody ) ) ; Joiner joiner = Joiner . on ( ',' ) ; if ( CollectionUtils . isNotEmpty ( to ) ) { joiner . appendTo ( ssp , to ) ; } boolean start = true ; if ( CollectionUtils . isNotEmpty ( cc ) ) { // noinspection ConstantConditions
joiner . appendTo ( ssp . append ( separator ( start ) ) . append ( "cc=" ) , cc ) ; start = false ; } if ( CollectionUtils . isNotEmpty ( bcc ) ) { joiner . appendTo ( ssp . append ( separator ( start ) ) . append ( "bcc=" ) , bcc ) ; start = false ; } if ( ! TextUtils . isEmpty ( encSubject ) ) { ssp . append ( separator ( start ) ) . append ( "subject=" ) . append ( encSubject ) ; start = false ; } if ( ! TextUtils . isEmpty ( encBody ) ) { ssp . append ( separator ( start ) ) . append ( "body=" ) . append ( encBody ) ; // noinspection UnusedAssignment
start = false ; } return new Builder ( ) . scheme ( "mailto" ) . encodedOpaquePart ( ssp . toString ( ) ) . build ( ) ;


signature:
public class SprocketsComponent { /** * Called by { @ link InitProvider } . */
static void init ( Context context ) { } }

implementation: Context app = context . getApplicationContext ( ) ; sProvider = DoubleCheck . provider ( ( ) -> ( app . getApplicationInfo ( ) . flags & FLAG_DEBUGGABLE ) == FLAG_DEBUGGABLE ? DaggerSprocketsComponent_Debug . builder ( ) . context ( app ) . build ( ) : DaggerSprocketsComponent_Release . builder ( ) . context ( app ) . build ( ) ) ;


signature:
public class Reveals { /** * Get an Animator that reveals the rectangular View from the circular View .
 * @ param circle to start reveal from
 * @ param rect to reveal , probably should already be { @ link View # INVISIBLE invisible } */
public static Animator circleToRect ( View circle , View rect ) { } }

implementation: return circleRect ( circle , rect , true ) ;


signature:
public class Reveals { /** * Get an Animator that " unreveals " the rectangular View to the circular View .
 * @ param circle to end " unreveal " at
 * @ param rect to " unreveal " , will be { @ link View # INVISIBLE invisible } when the animation
 * ends */
public static Animator circleFromRect ( View circle , View rect ) { } }

implementation: return circleRect ( circle , rect , false ) ;


signature:
public class UserHeaderNavigationFragment { /** * Display the Drawable as the header background . */
public static UserHeaderNavigationFragment newInstance ( @ DrawableRes int headerBackground ) { } }

implementation: UserHeaderNavigationFragment frag = new UserHeaderNavigationFragment ( ) ; Bundle args = Fragments . arguments ( frag ) ; args . putInt ( HEADER_BACKGROUND , headerBackground ) ; return frag ;


signature:
public class ProgressBarFragment { /** * Create a ProgressBar with the style of the theme attribute . */
public static ProgressBarFragment newInstance ( @ AttrRes int style ) { } }

implementation: ProgressBarFragment frag = new ProgressBarFragment ( ) ; Bundle args = Fragments . arguments ( frag ) ; args . putInt ( STYLE , style ) ; return frag ;


signature:
public class Transitions { /** * { @ link TransitionManager # beginDelayedTransition ( ViewGroup ) Begin a delayed transition } if
 * one is not already running . */
@ UiThread public static void tryDelayed ( ViewGroup sceneRoot ) { } }

implementation:
if ( ! sceneRoot . isLaidOut ( ) ) { // transition won ' t run
return ; } if ( sDelayedTransition == null ) { sDelayedTransition = new AutoTransition ( ) . addListener ( new SimpleTransitionListener ( ) { @ Override public void onTransitionEnd ( Transition transition ) { super . onTransitionEnd ( transition ) ; sDelayedTransitionRunning = false ; } } ) ; } if ( ! sDelayedTransitionRunning ) { sDelayedTransitionRunning = true ; TransitionManager . beginDelayedTransition ( sceneRoot , sDelayedTransition ) ; }


signature:
public class Transitions { /** * Get a cached arc motion transition . */
public static Transition arcMotion ( Context context ) { } }

implementation: if ( sArc == null ) { sArc = TransitionInflater . from ( context ) . inflateTransition ( R . transition . sprockets_arc_motion ) ; } return sArc ;


signature:
public class Spans { /** * Get a cached bold span .
 * @ param i starts at zero
 * @ since 2.6.0 */
public static StyleSpan bold ( int i ) { } }

implementation: if ( sBolds == null ) { sBolds = new ArrayList < > ( ) ; sBolds . add ( bold ( ) ) ; } if ( i < sBolds . size ( ) ) { return sBolds . get ( i ) ; } else { StyleSpan bold = new StyleSpan ( Typeface . BOLD ) ; sBolds . add ( bold ) ; return bold ; }


signature:
public class Spans { /** * Get a cached foreground color span .
 * @ param i starts at zero
 * @ since 3.0.0 */
public static ForegroundColorSpan foregroundColor ( @ ColorInt int color , int i ) { } }

implementation: if ( sForeColors == null ) { sForeColors = new SparseArray < > ( ) ; } List < ForegroundColorSpan > spans = sForeColors . get ( color ) ; if ( spans == null ) { spans = new ArrayList < > ( ) ; sForeColors . put ( color , spans ) ; } if ( i < spans . size ( ) ) { return spans . get ( i ) ; } else { ForegroundColorSpan span = new ForegroundColorSpan ( color ) ; spans . add ( span ) ; return span ; }


signature:
public class Animators { /** * Scale in the View to full size .
 * @ since 4.0.0 */
public static ViewPropertyAnimator scaleIn ( View view ) { } }

implementation: return scale ( view , 1.0f , enterScreen ( ) , R . integer . anim_duration_enter ) ;


signature:
public class Animators { /** * Scale out the View to zero size .
 * @ since 4.0.0 */
public static ViewPropertyAnimator scaleOut ( View view ) { } }

implementation: return scale ( view , 0.0f , exitScreen ( ) , R . integer . anim_duration_exit ) ;


signature:
public class Animators { /** * Scale out the image , swap in the Drawable resource , and scale it back in .
 * < strong > Note : < / strong > The returned animator ' s { @ code endAction } is already set , so don ' t
 * overwrite it with your own . To perform an action after the image is scaled back in , call
 * { @ link # scaleSwap ( ImageView , int , Runnable ) } instead .
 * @ since 4.0.0 */
public static ViewPropertyAnimator scaleSwap ( ImageView image , @ DrawableRes int drawableId ) { } }

implementation: return scaleSwap ( image , drawableId , null ) ;


signature:
public class Animators { /** * Scale out the image , swap in the Drawable resource , scale it back in , and run the action .
 * @ since 4.0.0 */
public static ViewPropertyAnimator scaleSwap ( ImageView image , @ DrawableRes int drawableId , Runnable endAction ) { } }

implementation: return scale ( image , ( ) -> image . setImageResource ( drawableId ) , endAction ) ;


signature:
public class Animators { /** * Scale out the ViewSwitcher , show the next View , scale it back in , and run the action .
 * @ since 4.0.0 */
public static ViewPropertyAnimator scaleShowNext ( ViewSwitcher view , Runnable endAction ) { } }

implementation: return scale ( view , view :: showNext , endAction ) ;


signature:
public class Animators { /** * Scale the Activity down to the rectangle provided by its
 * { @ link Intent # getSourceBounds ( ) getIntent ( ) . getSourceBounds ( ) } . To see the Activity behind
 * this one , you must include the below attributes [ 1 ] in your Activity theme . You may further
 * modify the animator , for example to fade out the Activity by decreasing its
 * { @ link ViewPropertyAnimator # alpha ( float ) alpha } and / or set an
 * { @ link ViewPropertyAnimator # withEndAction ( Runnable ) end action } that finishes the Activity .
 * When finishing the Activity in this way , you may wish to also call
 * { @ link Activity # overridePendingTransition ( int , int ) Activity . overridePendingTransition ( 0,
 * 0 ) } in order to prevent the system Activity close animation from running .
 * 1 . Activity theme attributes
 * { @ code < item name = " android : windowBackground " > @ android : color / transparent < / item > } < br / >
 * { @ code < item name = " android : windowIsTranslucent " > true < / item > }
 * @ return null when the Activity ' s Intent does not have
 * { @ link Intent # getSourceBounds ( ) source bounds }
 * @ see ActivityOptions # makeScaleUpAnimation ( View , int , int , int , int ) */
@ Nullable public static ViewPropertyAnimator makeScaleDownAnimation ( Activity a ) { } }

implementation: Rect to = a . getIntent ( ) . getSourceBounds ( ) ; return to != null ? makeScaleDownAnimation ( a , to ) : null ;