signature:
public class TradeOrderProc { /** * Record the trade request by making all related updates */
private void frame4 ( ) { } }

implementation:
long currentTime = System . currentTimeMillis ( ) ; // XXX : Lots of dummy value
// Record trade information in TRADE table .
// INSERT INTO trade ( t _ id , t _ dts , t _ st _ id , t _ tt _ id , t _ is _ cash ,
// t _ s _ symb , t _ qty , t _ bid _ price , t _ ca _ id , t _ exec _ name , t _ trade _ price ,
// t _ chrg , t _ comm , t _ tax , t _ lifo ) VALUES ( . . . )
String sql = String . format ( "INSERT INTO trade (t_id, t_dts, t_st_id, t_tt_id, " + "t_is_cash, t_s_symb, t_qty, t_bid_price, t_ca_id, t_exec_name, " + "t_trade_price, t_chrg, t_comm, t_tax, t_lifo) VALUES (%d, %d, '%s', " + "'%s', %d, '%s', %d, %f, %d, '%s', %f, %f, %f, %f, %d)" , paramHelper . getTradeId ( ) , currentTime , statusId , paramHelper . getTradeTypeId ( ) , 1 , paramHelper . getSymbol ( ) , paramHelper . getTradeQty ( ) , marketPrice , paramHelper . getAcctId ( ) , "exec_name" , paramHelper . getTradePrice ( ) , 0.0 , 0.0 , 0.0 , 1 ) ; executeUpdate ( sql ) ; // TODO : Implement this ( not in the simplified version )
// Record pending trade information in TRADE _ REQUEST table
// if this trade is a limit trade
// INSERT INTO trade _ request ( tr _ t _ id , tr _ tt _ id , tr _ s _ symb , tr _ qty ,
// tr _ bid _ price , tr _ b _ id ) VALUES ( . . . )
// Record trade information in TRADE _ HISTORY table
// INSERT INTO trade _ history ( th _ t _ id , th _ dts , th _ st _ id ) VALUES ( . . . )
sql = String . format ( "INSERT INTO trade_history (th_t_id, th_dts, th_st_id) VALUES " + "(%d, %d, '%s')" , paramHelper . getTradeId ( ) , currentTime , statusId ) ; executeUpdate ( sql ) ;


signature:
public class RandomPermutationGenerator { /** * It produces the next random permutation */
public void next ( ) { } }

implementation: for ( int k = a . length - 1 ; k > 0 ; k -- ) { int w = ( int ) Math . floor ( Math . random ( ) * ( k + 1 ) ) ; int temp = a [ w ] ; a [ w ] = a [ k ] ; a [ k ] = temp ; }


signature:
public class RandomNonRepeatGenerator { /** * Not repeat , randomly choose a number from 1 to the initinalized size */
public int next ( ) { } }

implementation:
// int rndIndex = ( int ) ( ( array . length - 1 - curIndex ) * rg . nextDouble ( ) )
// + curIndex ;
// int tmp = array [ rndIndex ] ;
// array [ rndIndex ] = array [ curIndex ] ;
// array [ curIndex ] = tmp ;
// curIndex + + ;
// return tmp ;
int number ; do { number = rg . nextInt ( size ) + 1 ; } while ( ! numberSet . add ( number ) ) ; return number ;


signature:
public class MicrobenchmarkParamGen { /** * a main application for debugging */
public static void main ( String [ ] args ) { } }

implementation: MicrobenchmarkParamGen executor = new MicrobenchmarkParamGen ( ) ; System . out . println ( "Parameters:" ) ; System . out . println ( "Read Write Tx Rate: " + RW_TX_RATE ) ; System . out . println ( "Long Read Tx Rate: " + LONG_READ_TX_RATE ) ; System . out . println ( "Total Read Count: " + TOTAL_READ_COUNT ) ; System . out . println ( "Local Hot Count: " + LOCAL_HOT_COUNT ) ; System . out . println ( "Write Ratio in RW Tx: " + WRITE_RATIO_IN_RW_TX ) ; System . out . println ( "Hot Conflict Rate: " + HOT_CONFLICT_RATE ) ; System . out . println ( "# of items: " + DATA_SIZE ) ; System . out . println ( "# of hot items: " + HOT_DATA_SIZE ) ; System . out . println ( "# of cold items: " + COLD_DATA_SIZE ) ; System . out . println ( ) ; for ( int i = 0 ; i < 1000 ; i ++ ) { Object [ ] params = executor . generateParameter ( ) ; System . out . println ( Arrays . toString ( params ) ) ; }


signature:
public class TpccValueGenerator { /** * Return an integer in the ( inclusive ) range [ min , max ] .
 * @ param min
 * @ param max
 * @ return */
public int number ( int min , int max ) { } }

implementation: if ( min > max ) throw new IllegalArgumentException ( ) ; int value = rng . nextInt ( max - min + 1 ) ; value += min ; return value ;


signature:
public class TpccValueGenerator { /** * Return an integer in the ( inclusive ) range [ minimum , maximum ] excluding
 * exclusivedVal . */
public int numberExcluding ( int min , int max , int exclusivedVal ) { } }

implementation: if ( min > max ) throw new IllegalArgumentException ( ) ; if ( min > exclusivedVal || exclusivedVal > max ) throw new IllegalArgumentException ( ) ; int value = number ( min , max - 1 ) ; if ( value >= exclusivedVal ) value ++ ; return value ;


signature:
public class TpccValueGenerator { /** * Return an fixed decimal double value in the ( inclusive ) range [ minimum ,
 * maximum ] . For example , [ 0.01 . . 100.00 ] with decimal 2 has 10,000 unique
 * values . */
public double fixedDecimalNumber ( int decimal , double min , double max ) { } }

implementation: if ( min > max ) throw new IllegalArgumentException ( ) ; if ( decimal < 0 ) throw new IllegalArgumentException ( ) ; int multiplier = 1 ; for ( int i = 0 ; i < decimal ; ++ i ) { multiplier *= 10 ; } int top = ( int ) ( min * multiplier ) ; int bottom = ( int ) ( max * multiplier ) ; return ( double ) number ( top , bottom ) / ( double ) multiplier ;


signature:
public class TpccValueGenerator { /** * Return a last name as defined by TPC - C 4.3.2.3. */
public String makeLastName ( int number ) { } }

implementation: if ( number < 0 && number > TpccConstants . NUM_DISTINCT_CLAST - 1 ) throw new IllegalArgumentException ( ) ; int indicies [ ] = { number / 100 , ( number / 10 ) % 10 , number % 10 } ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < indicies . length ; ++ i ) { sb . append ( TOKENS [ indicies [ i ] ] ) ; } return sb . toString ( ) ;


signature:
public class TpccValueGenerator { /** * Return a string of random alphanumeric characters of a random length
 * between [ minLength , maxLength ] . */
public String randomAString ( int minLength , int maxLength ) { } }

implementation: int length = number ( minLength , maxLength ) ; return randomAString ( length ) ;


signature:
public class RandomValueGenerator { /** * Return the result of a random choose from a given distribution .
 * @ param probs
 * @ return */
public int randomChooseFromDistribution ( double ... probs ) { } }

implementation: int result = - 1 ; int [ ] range = new int [ probs . length ] ; double accuracy = 1000 ; int total = 0 ; for ( int i = 0 ; i < probs . length ; i ++ ) { range [ i ] = ( int ) ( probs [ i ] * accuracy ) ; total += range [ i ] ; } int randNum = ( int ) ( rng . nextDouble ( ) * total ) ; for ( int i = 0 ; i < range . length ; i ++ ) { randNum -= range [ i ] ; if ( randNum <= 0 ) { result = i ; break ; } } return result ;


signature:
public class RandomValueGenerator { /** * Return a long in the ( inclusive ) range [ min , max ] . */
public long randomLongRange ( long min , long max ) { } }

implementation: if ( max <= min ) return min ; long width = max - min ; return ( long ) ( rng . nextDouble ( ) * width ) + min ;


signature:
public class RandomValueGenerator { /** * Return a double in the ( inclusive ) range [ min , max ] , with the increase
 * precision . */
public double randomDoubleIncrRange ( double min , double max , double incr ) { } }

implementation: long width = ( long ) ( ( max - min ) / incr ) ; return randomLongRange ( 0 , width ) * incr + min ;


signature:
public class FilterInjector { /** * { @ inheritDoc } */
@ Override public void inject ( Class < ? > klass ) throws DataException { } }

implementation: Method [ ] classMethods = klass . getMethods ( ) ; for ( Method method : classMethods ) { Filter annotation = ( Filter ) method . getAnnotation ( Filter . class ) ; if ( annotation != null ) { injectFilterMethod ( method , annotation ) ; } }


signature:
public class GitFileSystemObject { /** * Returns a file , with path relative to git working tree
 * @ param in
 * input < code > File < / code > object
 * repositoryPath
 * path to git repository
 * @ return
 * < code > File < / code > object with relative path
 * @ throws JavaGitException
 * input file does not belong to git working tree / repo */
public static File getRelativePath ( File in , File repositoryPath ) throws JavaGitException { } }

implementation:
String path = in . getPath ( ) ; String absolutePath = in . getAbsolutePath ( ) ; // check if the path is relative or absolute
if ( path . equals ( absolutePath ) ) { // if absolute , make sure it belongs to working tree
String workingTreePath = repositoryPath . getAbsolutePath ( ) ; if ( ! path . startsWith ( workingTreePath ) ) { throw new JavaGitException ( 999 , "Invalid path :" + path + ". Does not belong to the git working tree/ repository: " + workingTreePath ) ; } // make path relative
if ( ! path . equals ( workingTreePath ) ) { path = path . substring ( workingTreePath . length ( ) + 1 ) ; } } return new File ( path ) ;


signature:
public class GitFileSystemObject { /** * Gets parent directory of this < code > GitFileSystemObject < / code > object
 * @ return parent directory ( null if invalid ) */
public GitDirectory getParent ( ) { } }

implementation:
// NOTE : file . getParentFile ( ) returns null if there is no parent .
if ( file . getParentFile ( ) == null ) { return null ; } try { return new GitDirectory ( file . getParentFile ( ) , workingTree ) ; } catch ( JavaGitException e ) { // invalid git parent
return null ; }


signature:
public class GitFileSystemObject { /** * Adds the object to the git index
 * @ return response from git add */
public GitAddResponse add ( ) throws IOException , JavaGitException { } }

implementation:
GitAdd gitAdd = new GitAdd ( ) ; // create a list of filenames and add yourself to it
List < File > list = new ArrayList < File > ( ) ; File relativeFilePath ; if ( relativePath . isDirectory ( ) ) { for ( File f : relativePath . listFiles ( ) ) { if ( ! f . isHidden ( ) && ! f . getName ( ) . startsWith ( "." ) ) { relativeFilePath = this . getRelativePath ( f , this . getWorkingTree ( ) . getPath ( ) ) ; list . add ( relativeFilePath ) ; } } } else { list . add ( relativePath ) ; } // run git - add command
return gitAdd . add ( workingTree . getPath ( ) , null , list ) ;


signature:
public class GitFileSystemObject { /** * Commits the file system object
 * @ param comment
 * Developer ' s comment
 * @ return response from git commit */
public GitCommitResponse commit ( String comment ) throws IOException , JavaGitException { } }

implementation:
// first add the file
add ( ) ; // create a list of filenames and add yourself to it
List < File > list = new ArrayList < File > ( ) ; list . add ( relativePath ) ; GitCommit gitCommit = new GitCommit ( ) ; return gitCommit . commitOnly ( workingTree . getPath ( ) , comment , list ) ;


signature:
public class GitFileSystemObject { /** * Moves or renames the object
 * @ param dest
 * destination path ( relative to the Git Repository )
 * @ return response from git mv */
public GitMvResponse mv ( File dest ) throws IOException , JavaGitException { } }

implementation:
// source ; current location ( relative )
File source = relativePath ; // get relative path for destination
File relativeDest = getRelativePath ( dest , workingTree . getPath ( ) ) ; // perform git - mv
GitMv gitMv = new GitMv ( ) ; GitMvResponse response = gitMv . mv ( workingTree . getPath ( ) , source , relativeDest ) ; // file has changed ; update
file = dest ; relativePath = relativeDest ; return response ;


signature:
public class GitFileSystemObject { /** * Removes the file system object from the working tree and the index
 * @ return response from git rm */
public GitRmResponse rm ( ) throws IOException , JavaGitException { } }

implementation:
GitRm gitRm = new GitRm ( ) ; // run git rm command
return gitRm . rm ( workingTree . getPath ( ) , relativePath ) ;


signature:
public class GitStatus { /** * It returns a < code > GitStatusResponse < / code > object that contains all the details of the
 * output of & lt ; git - status & gt ; command .
 * @ param repositoryPath
 * Directory pointing to the root of the repository .
 * @ param options
 * Options that are passed to & lt ; git - status & gt ; command .
 * @ param paths
 * List of paths or patterns
 * @ return < code > GitStatusResponse < / code > object
 * @ throws JavaGitException
 * Exception thrown if the repositoryPath is null or if options or paths are invalid .
 * @ throws IOException
 * Exception is thrown if any of the IO operations fail . */
public GitStatusResponse status ( File repositoryPath , GitStatusOptions options , List < File > paths ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitStatus gitStatus = client . getGitStatusInstance ( ) ; return gitStatus . status ( repositoryPath , options , paths ) ;


signature:
public class GitStatus { /** * It returns a < code > GitStatusResonse < / code > object that contains all the details of the output
 * of & lt ; git - status & gt ; command , but filters output for a single file
 * @ param repositoryPath
 * Directory path to the root of the repository .
 * @ param path
 * @ return < code > GitStatusResponse < / code > object
 * @ throws JavaGitException
 * Exception thrown if the repositoryPath is null
 * @ throws IOException
 * Exception is thrown if any of the IO operations fail . */
public GitStatusResponse getSingleFileStatus ( File repositoryPath , File path ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitStatus gitStatus = client . getGitStatusInstance ( ) ; return gitStatus . getSingleFileStatus ( repositoryPath , null , path ) ;


signature:
public class GitStatus { /** * It returns a < code > GitFileSystemObject . Status < / code > for a single file
 * @ param repositoryPath
 * Directory path to the root of the repository .
 * @ param path
 * @ return < code > GitFileSystemObject . Status < / code >
 * @ throws JavaGitException
 * Exception thrown if the repositoryPath is null
 * @ throws IOException
 * Exception is thrown if any of the IO operations fail . */
public GitFileSystemObject . Status getFileStatus ( File repositoryPath , File path ) throws JavaGitException , IOException { } }

implementation:
// check validity of a repository path
CheckUtilities . checkFileValidity ( repositoryPath ) ; // run git status
IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitStatus gitStatus = client . getGitStatusInstance ( ) ; GitStatusResponse response = gitStatus . status ( repositoryPath ) ; return response . getFileStatus ( path ) ; /* * TODO : quote from Michael Schidlowsky : " this block of if statements is a little smelly . . . I ' d
 * prefer to see something like return response . asStatus ( ) . . . */
/* if ( response . getUntrackedFilesSize ( ) > 0 ) {
 return Status . UNTRACKED ;
 if ( response . getNewFilesToCommitSize ( ) > 0 ) {
 return Status . NEW _ TO _ COMMIT ;
 if ( response . getDeletedFilesNotUpdatedSize ( ) > 0 ) {
 return Status . DELETED ;
 if ( response . getDeletedFilesToCommitSize ( ) > 0 ) {
 return Status . DELETED _ TO _ COMMIT ;
 if ( response . getModifiedFilesNotUpdatedSize ( ) > 0 ) {
 return Status . MODIFIED ;
 if ( response . getModifiedFilesToCommitSize ( ) > 0 ) {
 return Status . MODIFIED _ TO _ COMMIT ;
 / / default
 return Status . IN _ REPOSITORY ; */


signature:
public class GitStatusOptions { /** * Sets the ' - a ' options to & lt ; git - status & gt ; command . If any one of the optOnly or OptInclude
 * options are set then optAll should not be set . While setting optAll to true , if optOnly or
 * optInclude is set set then < code > IllegalArgumentException < / code > is thrown .
 * @ param all */
public void setOptAll ( boolean all ) { } }

implementation: if ( all && ( optOnly || optInclude ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000100" ) + "  The \"all\" option can not be set when the \"only\" or \"include\" option is set." ) ; } this . optAll = all ;


signature:
public class CheckUtilities { /** * Checks that the specified filename exists . This assumes that the above check for string
 * validity has already been run and the path / filename is neither null or of size 0.
 * @ param filename
 * File or directory path */
public static void checkFileValidity ( String filename ) throws IOException { } }

implementation: File file = new File ( filename ) ; if ( ! file . exists ( ) ) { throw new IOException ( ExceptionMessageMap . getMessage ( "020001" ) + "  { filename=[" + filename + "] }" ) ; }


signature:
public class CheckUtilities { /** * Checks that the specified file exists .
 * @ param file
 * File or directory path */
public static void checkFileValidity ( File file ) throws IOException { } }

implementation: if ( ! file . exists ( ) ) { throw new IOException ( ExceptionMessageMap . getMessage ( "020001" ) + "  { filename=[" + file . getName ( ) + "] }" ) ; }


signature:
public class CheckUtilities { /** * Checks that the int to check is greater than < code > lowerBound < / code > . If the int to check is
 * not greater than < code > lowerBound < / code > , an < code > IllegalArgumentException < / code > is
 * thrown .
 * @ param toCheck
 * The int to check .
 * @ param lowerBound
 * The lower bound to check against .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void checkIntArgumentGreaterThan ( int toCheck , int lowerBound , String variableName ) { } }

implementation: if ( lowerBound >= toCheck ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000004" ) + "  { toCheck=[" + toCheck + "], lowerBound=[" + lowerBound + "], variableName=[" + variableName + "] }" ) ; }


signature:
public class CheckUtilities { /** * Performs a null check on the specified object . If the object is null , a
 * < code > NullPointerException < / code > is thrown .
 * @ param obj
 * The object to check .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void checkNullArgument ( Object obj , String variableName ) { } }

implementation: if ( null == obj ) { throw new NullPointerException ( ExceptionMessageMap . getMessage ( "000003" ) + "  { variableName=[" + variableName + "] }" ) ; }


signature:
public class CheckUtilities { /** * Checks a < code > List & lt ; ? & gt ; < / code > argument to make sure it is not null , has length > 0 , and
 * none of its elements are null . If the < code > List & lt ; ? & gt ; < / code > or any contained instance is
 * null , a < code > NullPointerException < / code > is thrown . If the < code > List & lt ; ? & gt ; < / code > or
 * any contained instance has length zero , an < code > IllegalArgumentException < / code > is thrown .
 * @ param list
 * The list to check .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void checkNullListArgument ( List < ? > list , String variableName ) { } }

implementation:
// TODO ( jhl388 ) : Write a unit test for this method .
if ( null == list ) { throw new NullPointerException ( ExceptionMessageMap . getMessage ( "000005" ) + "  { variableName=[" + variableName + "] }" ) ; } if ( list . size ( ) == 0 ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000005" ) + "  { variableName=[" + variableName + "] }" ) ; } for ( int i = 0 ; i < list . size ( ) ; i ++ ) { checkNullArgument ( list . get ( i ) , variableName ) ; }


signature:
public class CheckUtilities { /** * Checks that two lists are equal , specifically : they are both null or the both contain the same
 * elements .
 * @ param l1
 * The first list to check .
 * @ param l2
 * The second list to check .
 * @ return True if one of the following conditions hold :
 * < ol >
 * < li > Both lists are null < / li >
 * < li > a ) Neither list is null ; b ) for each element in list 1 an equivalent element
 * exists in list 2 ; and c ) for each element in list 2 , an equivalent element exists in
 * list 1 < / li >
 * < / ol > */
public static boolean checkListsEqual ( List < ? > l1 , List < ? > l2 ) { } }

implementation:
// TODO ( jhl388 ) : write a test case for this method .
if ( null != l1 && null == l2 ) { return false ; } if ( null == l1 && null != l2 ) { return false ; } if ( null != l1 ) { for ( Object e : l1 ) { if ( ! l2 . contains ( e ) ) { return false ; } } for ( Object e : l2 ) { if ( ! l1 . contains ( e ) ) { return false ; } } } return true ;


signature:
public class CheckUtilities { /** * Checks to see if two objects are equal . The Object . equal ( ) method is used to check for
 * equality .
 * @ param o1
 * The first object to check .
 * @ param o2
 * The second object to check .
 * @ return True if the two objects are equal . False if the objects are not equal . */
public static boolean checkObjectsEqual ( Object o1 , Object o2 ) { } }

implementation: if ( null != o1 && ! o1 . equals ( o2 ) ) { return false ; } if ( null == o1 && null != o2 ) { return false ; } return true ;


signature:
public class CheckUtilities { /** * Checks a < code > String < / code > argument to make sure it is not null and contains one or more
 * characters . If the < code > String < / code > is null , a < code > NullPointerException < / code > is
 * thrown . If the < code > String < / code > has length zero , an < code > IllegalArgumentException < / code >
 * is thrown .
 * @ param str
 * The string to check .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void checkStringArgument ( String str , String variableName ) { } }

implementation: if ( null == str ) { throw new NullPointerException ( ExceptionMessageMap . getMessage ( "000001" ) + "  { variableName=[" + variableName + "] }" ) ; } if ( str . length ( ) == 0 ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000001" ) + "  { variableName=[" + variableName + "] }" ) ; }


signature:
public class CheckUtilities { /** * Checks a < code > List & lt ; String & gt ; < / code > argument to make sure it is not null , none of its
 * elements are null , and all its elements contain one or more characters . If the
 * < code > List & lt ; String & gt ; < / code > or a contained < code > String < / code > is null , a
 * < code > NullPointerException < / code > is thrown . If the < code > List & lt ; String & gt ; < / code > or a
 * contained < code > String < / code > has length zero , an < code > IllegalArgumentException < / code > is
 * thrown .
 * @ param str
 * The < code > List & lt ; String & gt ; < / code > to check .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void checkStringListArgument ( List < String > str , String variableName ) { } }

implementation: if ( null == str ) { throw new NullPointerException ( ExceptionMessageMap . getMessage ( "000002" ) + "  { variableName=[" + variableName + "] }" ) ; } if ( str . size ( ) == 0 ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000002" ) + "  { variableName=[" + variableName + "] }" ) ; } for ( int i = 0 ; i < str . size ( ) ; i ++ ) { checkStringArgument ( str . get ( i ) , variableName ) ; }


signature:
public class CheckUtilities { /** * Checks if two unordered lists are equal .
 * @ param l1
 * The first list to test .
 * @ param l2
 * The second list to test .
 * @ return True if :
 * < ul >
 * < li > both lists are null or < / li >
 * < li > both lists are the same length , there exists an equivalent object in l2 for all
 * objects in l1 , and there exists an equivalent object in l1 for all objects in l2 < / li >
 * < / ul >
 * False otherwise . */
public static boolean checkUnorderedListsEqual ( List < ? > l1 , List < ? > l2 ) { } }

implementation: if ( null == l1 && null != l2 ) { return false ; } if ( null != l1 && null == l2 ) { return false ; } if ( l1 . size ( ) != l2 . size ( ) ) { return false ; } for ( Object o : l1 ) { if ( ! l2 . contains ( o ) ) { return false ; } } for ( Object o : l2 ) { if ( ! l1 . contains ( o ) ) { return false ; } } return true ;


signature:
public class CheckUtilities { /** * A general range check utility for checking whether a given & lt ; integer & gt ; value is between a
 * given start and end indexes . This is a helper method for other methods such as
 * checkIntIndexInListRange or can also be used independently by external objects .
 * @ param index
 * Given index that is being checked for validity between start and end .
 * @ param start
 * index should be greater than or equal to start .
 * @ param end
 * index should be less than end . */
public static void checkIntInRange ( int index , int start , int end ) { } }

implementation: if ( index < start ) { throw new IndexOutOfBoundsException ( ExceptionMessageMap . getMessage ( "000006" ) + "  { index=[" + index + "], start=[" + start + "], end=[" + end + "] }" ) ; } if ( index >= end ) { throw new IndexOutOfBoundsException ( ExceptionMessageMap . getMessage ( "000006" ) + "  { index=[" + index + "], start=[" + start + "], end=[" + end + "] }" ) ; }


signature:
public class CheckUtilities { /** * Checks a < code > List < / code > argument to make sure that all the < code > Ref < / code > in the list
 * are of same < code > refType < / code > type . If there is a mismatch
 * < code > IllegalArgumentException < / code > is thrown .
 * @ param list
 * The < code > List < / code > to check .
 * @ param type
 * The < code > refType < / code > check against .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void validateListRefType ( List < Ref > list , Ref . RefType type , String variableName ) { } }

implementation:
// TODO ( ns1344 ) : Write a unit test for this method .
checkNullListArgument ( list , variableName ) ; for ( Ref ref : list ) { validateArgumentRefType ( ref , type , variableName ) ; }


signature:
public class CheckUtilities { /** * Checks a < code > Ref < / code > argument to make sure that it is of given < code > refType < / code > type .
 * If not < code > IllegalArgumentException < / code > is thrown .
 * @ param name
 * The argument to check .
 * @ param type
 * The < code > refType < / code > to check against .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void validateArgumentRefType ( Ref name , Ref . RefType type , String variableName ) { } }

implementation: checkNullArgument ( name , variableName ) ; if ( name . getRefType ( ) != type ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "100000" ) + "  { variableName=[" + variableName + "] }" ) ; }


signature:
public class CheckUtilities { /** * Checks a < code > File < / code > argument to make sure that it is a directory . If not
 * < code > IllegalArgumentException < / code > is thrown .
 * @ param fileName
 * The < code > File < / code > to be checked .
 * @ param variableName
 * The name of the variable being checked ; for use in exception messages . */
public static void checkDirectoryArgument ( File fileName , String variableName ) { } }

implementation: checkNullArgument ( fileName , variableName ) ; if ( ! fileName . isDirectory ( ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000007" ) + "  { variableName=[" + variableName + "] }" ) ; }


signature:
public class ClientManager { /** * Gets an instance of the specified client type .
 * @ param clientType
 * The type of client to get .
 * @ return An instance of the specified client type . */
public IClient getClientInstance ( ClientType clientType ) { } }

implementation: IClient clientInstance = clientImpls . get ( clientType ) ; if ( null == clientInstance ) { if ( ClientType . CLI == clientType ) { clientInstance = new CliClient ( ) ; } if ( null != clientInstance ) { clientImpls . put ( clientType , clientInstance ) ; } } return clientInstance ;


signature:
public class ClientManager { /** * Sets the preferred client type .
 * @ param preferredClientType
 * The type to set as the preferred client type . If the value is null , then the preferred
 * client type is set to < code > ClientType . CLI < / code > . */
public void setPreferredClientType ( ClientType preferredClientType ) { } }

implementation: if ( null == preferredClientType ) { this . preferredClientType = ClientType . CLI ; } else { this . preferredClientType = preferredClientType ; }


signature:
public class CliGitAdd { /** * Implementations of & lt ; git - add & gt ; with options and list of files provided . */
public GitAddResponse add ( File repositoryPath , GitAddOptions options , List < File > paths ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; GitAddParser parser = new GitAddParser ( ) ; List < String > command = buildCommand ( repositoryPath , options , paths ) ; GitAddResponseImpl response = ( GitAddResponseImpl ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ; if ( options != null ) { addDryRun ( options , response ) ; } return ( GitAddResponse ) response ;


signature:
public class CliGitAdd { /** * Adds a list of files with no GitAddOptions . */
public GitAddResponse add ( File repositoryPath , List < File > files ) throws JavaGitException , IOException { } }

implementation: GitAddOptions options = null ; return add ( repositoryPath , options , files ) ;


signature:
public class CliGitAdd { /** * Adds one file to the index with no GitAddOptions . */
public GitAddResponse add ( File repositoryPath , File file ) throws JavaGitException , IOException { } }

implementation: List < File > filePaths = new ArrayList < File > ( ) ; filePaths . add ( file ) ; GitAddOptions options = null ; return add ( repositoryPath , options , filePaths ) ;


signature:
public class CliGitAdd { /** * Implementations of & lt ; git - add & gt ; with options and one file to be added to index . */
public GitAddResponse add ( File repositoryPath , GitAddOptions options , File file ) throws JavaGitException , IOException { } }

implementation: List < File > paths = new ArrayList < File > ( ) ; paths . add ( file ) ; return add ( repositoryPath , options , paths ) ;


signature:
public class CliGitAdd { /** * Implementation of & lt ; git - add & gt ; dry run . */
public GitAddResponse addDryRun ( File repositoryPath , List < File > paths ) throws JavaGitException , IOException { } }

implementation: GitAddOptions options = new GitAddOptions ( ) ; options . setDryRun ( true ) ; return add ( repositoryPath , options , paths ) ;


signature:
public class CliGitAdd { /** * Implementations of & lt ; git - add & gt ; in verbose mode . */
public GitAddResponse addVerbose ( File repositoryPath , List < File > paths ) throws JavaGitException , IOException { } }

implementation: GitAddOptions options = new GitAddOptions ( ) ; options . setVerbose ( true ) ; return add ( repositoryPath , options , paths ) ;


signature:
public class CliGitAdd { /** * Implementations of & lt ; git - add & gt ; with force option set . */
public GitAddResponse addWithForce ( File repositoryPath , List < File > paths ) throws JavaGitException , IOException { } }

implementation: GitAddOptions options = new GitAddOptions ( ) ; options . setForce ( true ) ; return add ( repositoryPath , options , paths ) ;


signature:
public class CliGitAdd { /** * if the dry run option was selected then set the flag in response .
 * @ param options < code > GitAddOptions < / code >
 * @ param response < code > gitAddResponse < / code > */
private void addDryRun ( GitAddOptions options , GitAddResponseImpl response ) { } }

implementation: if ( options . dryRun ( ) ) { response . setDryRun ( true ) ; }


signature:
public class GitVersion { /** * Compares minor releases values given that git version contains no tag
 * for none of GitVersion objects
 * @ param that
 * @ return SAME if both are equal , LATER if that is previous to this or PREVIOUS otherwise */
private int compareToReleaseMinor ( GitVersion that ) { } }

implementation: if ( this . containsReleaseMinor ( ) && that . containsReleaseMinor ( ) ) return compareToInt ( this . getReleaseMinor ( ) , that . getReleaseMinor ( ) ) ; else if ( ! this . containsReleaseMinor ( ) && ! that . containsReleaseMinor ( ) ) return SAME ; else if ( this . containsReleaseMinor ( ) && ! that . containsReleaseMinor ( ) ) return LATER ; else return PREVIOUS ;


signature:
public class GitVersion { /** * Compares tag values given that git version contains no minor release
 * for none of GitVersion objects
 * When both contain a tag or not contain it the comparison is easy but
 * if only one of them contains it the release that doesn ' t contains it
 * is the one released earlier
 * e . g . v1.8.0 - rc0 is previous to v1.8.0
 * @ param that
 * @ return SAME if both are equal , LATER if that is previous to this or PREVIOUS otherwise */
private int compareToTag ( GitVersion that ) { } }

implementation: if ( this . containsTag ( ) && that . containsTag ( ) ) return this . getTag ( ) . compareTo ( that . getTag ( ) ) ; else if ( ! this . containsTag ( ) && ! that . containsTag ( ) ) return SAME ; else if ( this . containsTag ( ) && ! that . containsTag ( ) ) return PREVIOUS ; else return LATER ;


signature:
public class CursorUtil { /** * Convert a standard Android { @ link Cursor } into a { @ link org . droitateddb . cursor . ObjectCursor } . < br >
 * This is only possible for { @ link Cursor } s that where queried over a { @ link ContentResolver } from a
 * { @ link ContentProvider } derived by { @ link BaseContentProvider } .
 * @ param < T > Entity class represented within the Cursor
 * @ param cursor Android { @ link Cursor }
 * @ return The { @ link org . droitateddb . cursor . ObjectCursor } representation of the given Android { @ link Cursor }
 * @ throws NullPointerException When the given cursor is null
 * @ throws IllegalArgumentException When the given cursor is not of the type { @ link CursorWrapper } , which will be returned by a
 * { @ link ContentResolver }
 * @ throws IllegalStateException When the wrapped cursor within the given cursor is not of type { @ link org . droitateddb . cursor . ObjectCursor } . This indicates
 * that the given cursor was not queried from a derivation { @ link BaseContentProvider } */
@ SuppressWarnings ( "unchecked" ) public static < T > ObjectCursor < T > getObjectCursor ( final Cursor cursor ) { } }

implementation: if ( cursor == null ) { throw new NullPointerException ( "The given cursor is null" ) ; } if ( ! ( cursor instanceof CursorWrapper ) ) { throw new IllegalArgumentException ( "The given cursor is not of type " + CursorWrapper . class . getCanonicalName ( ) + ". It has type " + cursor . getClass ( ) . getCanonicalName ( ) + ". Was it queried with a ContentResolver?" ) ; } CursorWrapper wrapper = ( CursorWrapper ) cursor ; Cursor wrappedCursor = wrapper . getWrappedCursor ( ) ; if ( ! ( wrappedCursor instanceof ObjectCursor ) ) { throw new IllegalStateException ( "The wrapped cursor of the given CursorWrapper is not of type " + ObjectCursor . class . getCanonicalName ( ) + ". It has type " + wrappedCursor . getClass ( ) . getCanonicalName ( ) + ". Was it queried over a ContentResolver from BaseContentProvider derived ContentProvider?" ) ; } return ( ObjectCursor < T > ) wrappedCursor ;


signature:
public class GitAdd { /** * This command adds the current content of new or modified files to the index , thus staging that
 * content for inclusion in the next commit .
 * @ param repositoryPath
 * The path to the repository to commit against . A non - zero length argument is required
 * for this parameter , otherwise a < code > NullPointerException < / code > or
 * < code > IllegalArgumentException < / code > will be thrown .
 * @ param options
 * GitAddOptions that are passed to the & lt ; git - add & gt ; command .
 * @ param paths
 * List of file paths that will be added to the index .
 * @ return GitAddResponse Response generated by the add command .
 * @ exception IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown if -
 * < ul >
 * < li > repositoryPath is not valid < / li >
 * < li > filenames assigned do not exist < / li >
 * < li > files or repository path does not have access rights < / li >
 * < / ul >
 * @ exception JavaGitException
 * Exception thrown
 * < ul >
 * < li > if the repositoryPath is null . < / li >
 * < li > if the & lt ; git - add & gt ; command generates error . < / li >
 * < / ul > */
public GitAddResponse add ( File repositoryPath , GitAddOptions options , List < File > paths ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath . getAbsoluteFile ( ) ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitAdd gitAdd = client . getGitAddInstance ( ) ; return gitAdd . add ( repositoryPath , options , paths ) ;


signature:
public class GitAdd { /** * This command adds the current content of new or modified files to the index , with verbose
 * option set .
 * @ param repositoryPath
 * The path to the repository to commit against . A non - zero length argument is required
 * for this parameter , otherwise a < code > NullPointerException < / code > or
 * < code > IllegalArgumentException < / code > will be thrown .
 * @ param paths
 * List of file paths that will be added to the index .
 * @ return GitAddResponse Response generated by the add command .
 * @ exception IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown if -
 * < ul >
 * < li > repositoryPath is not valid < / li >
 * < li > filenames assigned do not exist < / li >
 * < li > files or repository path does not have access rights < / li >
 * < / ul >
 * @ exception JavaGitException
 * Exception thrown
 * < ul >
 * < li > if the repositoryPath is null . < / li >
 * < li > if the & lt ; git - add & gt ; command generates error . < / li >
 * < / ul > */
public GitAddResponse addVerbose ( File repositoryPath , List < File > paths ) throws IOException , JavaGitException { } }

implementation: IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitAdd gitAdd = client . getGitAddInstance ( ) ; return gitAdd . addVerbose ( repositoryPath , paths ) ;


signature:
public class CliGitCommit { /** * Processes the commit .
 * @ param repository A < code > File < / code > instance for the path to the repository root ( the parent
 * directory of the . git directory ) or a sub - directory in the working tree of the
 * repository to commit against . This argument must represent the absolute path to the
 * desired directory as returned by the < code > File . getPath ( ) < / code > method . If null is
 * passed , a < code > NullPointerException < / code > will be thrown .
 * @ param options The options to commit with .
 * @ param message The message to attach to the commit . A non - zero length argument is required for this
 * parameter , otherwise a < code > NullPointerException < / code > or
 * < code > IllegalArgumentException < / code > will be thrown .
 * @ param paths A list of folders and / or files to commit . The paths specified in this list must all be
 * relative to the path specified in the < code > repository < / code > parameter as returned
 * by < code > File . getPath ( ) < / code > .
 * @ return The results from the commit .
 * @ throws IOException There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < li > a directory doesn ' t exist < / li >
 * < li > access to a file is denied < / li >
 * < li > a command is not found on the PATH < / li >
 * < / ul >
 * @ throws JavaGitException Thrown when there is an error making the commit . */
protected GitCommitResponseImpl commitProcessor ( File repository , GitCommitOptions options , String message , List < File > paths ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repository , "repository" ) ; CheckUtilities . checkStringArgument ( message , "message" ) ; List < String > commandLine = buildCommand ( options , message , paths ) ; GitCommitParser parser = new GitCommitParser ( repository . getAbsolutePath ( ) ) ; return ( GitCommitResponseImpl ) ProcessUtilities . runCommand ( repository , commandLine , parser ) ;


signature:
public class CliGitCommit { /** * Builds a list of command arguments to pass to < code > ProcessBuilder < / code > .
 * @ param options The options to include on the command line .
 * @ param message The message for the commit .
 * @ return A list of the individual arguments to pass to < code > ProcessBuilder < / code > . */
protected List < String > buildCommand ( GitCommitOptions options , String message , List < File > paths ) { } }

implementation:
// TODO ( jhl388 ) : Add a unit test for this method ( CliGitCommit . buildCommand ( ) ) .
List < String > cmd = new ArrayList < String > ( ) ; cmd . add ( JavaGitConfiguration . getGitCommand ( ) ) ; cmd . add ( "commit" ) ; if ( null != options ) { if ( options . isOptAll ( ) ) { cmd . add ( "-a" ) ; } if ( options . isOptInclude ( ) ) { cmd . add ( "-i" ) ; } if ( options . isOptNoVerify ( ) ) { cmd . add ( "--no-verify" ) ; } if ( options . isOptOnly ( ) ) { cmd . add ( "-o" ) ; } if ( options . isOptSignoff ( ) ) { cmd . add ( "-s" ) ; } String author = options . getAuthor ( ) ; if ( null != author && author . length ( ) > 0 ) { cmd . add ( "--author" ) ; cmd . add ( options . getAuthor ( ) ) ; } } cmd . add ( "-m" ) ; cmd . add ( message ) ; if ( null != paths ) { cmd . add ( "--" ) ; for ( File f : paths ) { cmd . add ( f . getPath ( ) ) ; } } return cmd ;


signature:
public class JavaGitConfiguration { /** * Sets the { @ link # gitVersion } field .
 * < br / >
 * This function gets called in one of two ways :
 * < br / >
 * 1 ) When client code sets the path to the git binaries explicitly by calling { @ link # setGitPath ( java . io . File ) } ,
 * this function is used to determine if the path is usable or not . In this case , the
 * < code > File < / code > path argument will be the new path to the git binaries .
 * < br / >
 * 2 ) When client code calls { @ link # getGitVersion ( ) } and the path has not been set explicitly , we
 * call this function to figure out the version . In this case , the < code > File < / code > path
 * argument will be null .
 * @ param path
 * < code > File < / code > object representing the directory containing the git binaries . If
 * null , the previously - set path is used ( if any ) . It must contain either an absolute
 * path , or a valid path relative to the current working directory .
 * @ throws JavaGitException
 * Thrown if git is not found at the provided path . */
private static void determineGitVersion ( File path ) throws JavaGitException { } }

implementation:
/* * If they already set the path explicitly , or are in the process of doing so ( via the path
 * argument ) , make sure to prefix the git call with it . If they didn ' t , assume it ' s blank . */
String gitPrefix = "" ; if ( path != null ) { // We got a path passed in as an argument .
gitPrefix = path . getAbsolutePath ( ) + File . separator ; } else if ( gitPath != null ) { // They didn ' t pass in a path , but previously set it explicitly via setGitPath .
gitPrefix = getGitCommandPrefix ( ) ; } String gitCommand = gitPrefix + "git" ; if ( ! ( gitPrefix . equals ( "" ) ) ) { // If we ' ve got a full path to the git binary here , ensure it actually exists .
if ( ! ( new File ( gitCommand ) . exists ( ) ) ) { throw new JavaGitException ( 100002 , ExceptionMessageMap . getMessage ( "100002" ) ) ; } } List < String > commandLine = new ArrayList < String > ( ) ; commandLine . add ( gitCommand ) ; commandLine . add ( "--version" ) ; // Now run the actual git version command .
try { // We ' re passing in a working directory of null , which is " don ' t care " to runCommand
gitVersion = ( GitVersion ) ProcessUtilities . runCommand ( null , commandLine , new GitVersionParser ( ) ) ; } catch ( Exception e ) { throw new JavaGitException ( 100001 , ExceptionMessageMap . getMessage ( "100001" ) ) ; } String version = gitVersion . toString ( ) ; if ( ! ( isValidVersionString ( version ) ) ) { throw new JavaGitException ( 100001 , ExceptionMessageMap . getMessage ( "100001" ) ) ; }


signature:
public class JavaGitConfiguration { /** * Judge the validity of a given git version string . This can be difficult to do , as there seems
 * to be no deliberately - defined git version format . So , here we do a minimal sanity check for two
 * things : 1 . The first character in the version is a number . 2 . There ' s at least one period in
 * the version string .
 * @ param version
 * @ return true if the version passed as argument is valid */
private static boolean isValidVersionString ( String version ) { } }

implementation:
/* * Git version strings can vary , so let ' s do a minimal sanity check for two things : 1 . The first
 * character in the version is a number . 2 . There ' s at least one period in the version string .
 * TODO ( rs2705 ) : Make this more sophisticated by parsing out a major / minor version number , and
 * ensuring it ' s > = some minimally - required version . */
try { Integer . parseInt ( version . substring ( 0 , 1 ) ) ; } catch ( NumberFormatException e ) { // First character in the version string was not a valid number !
return false ; } if ( version . indexOf ( "." ) == - 1 ) { // The version string doesn ' t contain a period !
return false ; } return true ;


signature:
public class JavaGitConfiguration { /** * Called when client code wants to explicitly tell us where to find git on their filesystem . If
 * never called , we assume that git is in a directory in the PATH environment variable for this
 * process . Passing null as the path argument will unset an explicitly - set path and revert to
 * looking for git in the PATH .
 * @ param path
 * < code > File < / code > object representing the directory containing the git binaries . It
 * must contain either an absolute path , or a valid path relative to the current working
 * directory .
 * @ throws IOException
 * Thrown if the provided path does not exist .
 * @ throws JavaGitException
 * Thrown if git does not exist at the provided path , or the provided path is not a
 * directory . */
public static void setGitPath ( File path ) throws IOException , JavaGitException { } }

implementation:
if ( path != null ) { CheckUtilities . checkFileValidity ( path ) ; if ( ! ( path . isDirectory ( ) ) ) { throw new JavaGitException ( 020002 , ExceptionMessageMap . getMessage ( "020002" ) + " { path=[" + path . getPath ( ) + "] }" ) ; } } try { determineGitVersion ( path ) ; } catch ( Exception e ) { // The path that was passed in doesn ' t work . Catch any errors and throw this one instead .
throw new JavaGitException ( 100002 , ExceptionMessageMap . getMessage ( "100002" ) + " { path=[" + path . getPath ( ) + "] }" , e ) ; } // Make sure we ' re hanging onto an absolute path .
gitPath = ( path != null ) ? path . getAbsoluteFile ( ) : null ;


signature:
public class JavaGitConfiguration { /** * Convenience method for setting the path with a < code > String < / code > instead of a
 * < code > File < / code > .
 * TODO ( rs2705 ) : Enforce the requirement below that the path be absolute . Is there a simple way
 * to do this in an OS - independent fashion ?
 * @ param path
 * Absolute path to git binaries installed on the system . The path must be absolute since
 * it needs to persist for the life of the client code , even if the working directory
 * changes . Throws a NullPointerException if path is null , or an IllegalArgumentException
 * if it ' s the empty string .
 * @ throws IOException
 * Thrown if the provided path does not exist .
 * @ throws JavaGitException
 * Thrown if we cannot find git at the path provided . */
public static void setGitPath ( String path ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkStringArgument ( path , "path" ) ; setGitPath ( new File ( path ) ) ;


signature:
public class ParameterMarshaller { /** * Creates the list of BinderVariables given a method obtained through
 * reflection .
 * @ param method
 * The method
 * @ return The list of BinderVariables */
private static List < IParameter > createList ( Method method ) { } }

implementation:
List < IParameter > parameters = new ArrayList < IParameter > ( ) ; Class < ? > paramTypes [ ] = method . getParameterTypes ( ) ; Annotation [ ] [ ] methodAnnotations = method . getParameterAnnotations ( ) ; for ( int i = 0 ; i < methodAnnotations . length ; i ++ ) { // defaults
boolean paramRequired = true ; String paramName = "" ; Class < ? > paramClass = paramTypes [ i ] ; for ( Annotation a : methodAnnotations [ i ] ) { if ( a instanceof Binder ) { paramName = ( ( Binder ) a ) . name ( ) ; paramRequired = ( ( Binder ) a ) . required ( ) ; break ; } // else if ( a instanceof Environment ) {
// paramName = ( ( Environment ) a ) . name ( ) ;
// paramRequired = ( ( Environment ) a ) . required ( ) ;
// break ;
} parameters . add ( Parameter . create ( paramName , paramClass , paramRequired ) ) ; } return parameters ;


signature:
public class ParameterMarshaller { /** * Returns an array of types for use with reflection method . invoke ( ) .
 * @ return */
public Class < ? > [ ] getTypeArray ( ) { } }

implementation: Class < ? > [ ] typeArray = new Class [ this . parameters . size ( ) ] ; for ( int i = 0 ; i < this . parameters . size ( ) ; i ++ ) { typeArray [ i ] = this . parameters . get ( i ) . getType ( ) ; } return typeArray ;


signature:
public class ParameterMarshaller { /** * Return the m _ functionDefinition compatible array .
 * @ param maxParams
 * @ return */
public int [ ] getFunctionDefinitionArray ( int functionOffset , int maxParams , int returnType ) { } }

implementation:
int [ ] definition = new int [ maxParams + EXTRA_FUNC_DEF_VALUES ] ; int paramCount = getParameterCount ( false ) ; int fullParamCount = getParameterCount ( true ) ; definition [ 0 ] = functionOffset ; if ( paramCount > maxParams ) { throw new IllegalStateException ( "Attempted to get function definition table when supplied " + "max parameter count " + maxParams + " is smaller than real param count " + paramCount ) ; } definition [ 1 ] = paramCount ; int j = 2 ; for ( int i = 0 ; i < fullParamCount ; i ++ ) { // add grammar element if it is NOT an injected type
if ( ( this . parameters . get ( i ) instanceof InjectedParameter ) == false ) { definition [ j ] = this . parameters . get ( i ) . getGrammarElementType ( ) ; j ++ ; } } // pad out unspecified param types
for ( ; j < definition . length - 1 ; j ++ ) { definition [ j ] = Parameter . GRAMMAR_ELEMENT_UNSPECIFIED ; } // return type as last value
definition [ definition . length - 1 ] = returnType ; return definition ;


signature:
public class ParameterMarshaller { /** * Returns an array of values given an array of script arguments for use with
 * the reflection method . invoke ( ) , injecting known service / user / context data .
 * @ return
 * @ throws IllegalAccessException */
public Object [ ] getValueArray ( Object [ ] arguments , Service service ) { } }

implementation:
Object [ ] paramArray = new Object [ this . parameters . size ( ) ] ; int argumentIndex = 0 ; for ( int i = 0 ; i < this . parameters . size ( ) ; i ++ ) { // inject params if needed
IParameter p = this . parameters . get ( i ) ; try { if ( p instanceof InjectedParameter ) { paramArray [ i ] = p . getArgumentValue ( null , service ) ; } else { paramArray [ i ] = p . getArgumentValue ( arguments [ argumentIndex ] , service ) ; argumentIndex ++ ; } } catch ( ClassCastException e ) { SystemUtils . trace ( "twine" , "getArgumentValue failed on parameter " + ( i + 1 ) + ": " + e . getMessage ( ) ) ; } } return paramArray ;


signature:
public class ParameterMarshaller { /** * Returns an array of values given a filter execution context
 * @ param ws
 * The system workspace
 * @ param binder
 * The current binder
 * @ param ctx
 * The current execution context
 * @ return */
public Object [ ] getValueArray ( Workspace ws , DataBinder binder , ExecutionContext ctx ) { } }

implementation:
Object [ ] paramArray = new Object [ this . parameters . size ( ) ] ; for ( int i = 0 ; i < this . parameters . size ( ) ; i ++ ) { // inject params if needed
IParameter p = this . parameters . get ( i ) ; try { if ( p . getType ( ) == Workspace . class ) { paramArray [ i ] = ws ; } else if ( p . getType ( ) == DataBinder . class ) { paramArray [ i ] = binder ; } else if ( p . getType ( ) . isAssignableFrom ( ExecutionContext . class ) ) { paramArray [ i ] = ctx ; } else { paramArray [ i ] = null ; } } catch ( ClassCastException e ) { SystemUtils . trace ( "twine" , "getArgumentValue failed on parameter " + ( i + 1 ) + ": " + e . getMessage ( ) ) ; } } return paramArray ;


signature:
public class ParameterMarshaller { /** * Returns an array of values for use with the reflection method . invoke ( ) ,
 * injecting known service / user / context data .
 * @ return
 * @ throws IllegalAccessException */
public Object [ ] getValueArray ( Service service ) { } }

implementation: Object [ ] paramArray = new Object [ this . parameters . size ( ) ] ; for ( int i = 0 ; i < this . parameters . size ( ) ; i ++ ) { IParameter p = this . parameters . get ( i ) ; try { paramArray [ i ] = p . getBinderValue ( service ) ; } catch ( IllegalAccessException e ) { SystemUtils . trace ( "twine" , "getValue failed on parameter " + ( i + 1 ) + ": " + e . getMessage ( ) ) ; } } return paramArray ;


signature:
public class DotGit { /** * Checks if there is a DotGit instance for a given path
 * @ param path
 * < code > File < / code > object representing the path to the repository .
 * @ return
 * true if exits , false otherwise ; */
public static synchronized boolean existsInstance ( File path ) { } }

implementation:
String canonicalPath = "" ; try { canonicalPath = path . getCanonicalPath ( ) ; } catch ( IOException e ) { // obviously , the answer is NO
return false ; } return INSTANCES . containsKey ( canonicalPath ) ;


signature:
public class DotGit { /** * Static factory method for retrieving an instance of this class .
 * @ param path
 * < code > File < / code > object representing the path to the repository .
 * @ return The < code > DotGit < / code > instance for this path */
public static synchronized DotGit getInstance ( File path ) { } }

implementation:
DotGit dotGit ; // TODO ( rs2705 ) : make sure that path is valid
/* * We want to make sure we ' re dealing with the canonical path here , since there are multiple
 * ways to refer to the same dir with different strings . */
String canonicalPath = "" ; try { canonicalPath = path . getCanonicalPath ( ) ; } catch ( Exception e ) { /* * TODO ( rs2705 ) : Figure out which exception to throw here , and throw it - or should we simply
 * let it propogate up as - is ? */
// Temporary placeholder
return null ; } if ( ! ( INSTANCES . containsKey ( canonicalPath ) ) ) { dotGit = new DotGit ( path , canonicalPath ) ; INSTANCES . put ( canonicalPath , dotGit ) ; } else { dotGit = INSTANCES . get ( canonicalPath ) ; } return dotGit ;


signature:
public class DotGit { /** * Creates a new branch
 * @ param name
 * The name of the branch to create
 * @ return The new branch */
public Ref createBranch ( String name ) throws IOException , JavaGitException { } }

implementation: Ref newBranch = Ref . createBranchRef ( name ) ; GitBranch gitBranch = new GitBranch ( ) ; gitBranch . createBranch ( path , newBranch ) ; return newBranch ;


signature:
public class DotGit { /** * Deletes a branch
 * @ param branch
 * The branch to delete
 * @ param forceDelete
 * True if force delete option - D should be used ,
 * false if - d should be used .
 * @ throws IOException
 * Thrown in case of I / O operation failure
 * @ throws JavaGitException
 * Thrown when there is an error executing git - branch . */
public void deleteBranch ( Ref branch , boolean forceDelete ) throws IOException , JavaGitException { } }

implementation: GitBranch gitBranch = new GitBranch ( ) ; gitBranch . deleteBranch ( path , forceDelete , false , branch ) ; branch = null ;


signature:
public class DotGit { /** * Renames a branch
 * @ param branchFrom
 * The branch to rename
 * @ param nameTo
 * New branch name
 * @ param forceRename
 * True if force rename option - M should be used .
 * False if - m should be used .
 * @ return new < code > Ref < / code > instance
 * @ throws IOException
 * Thrown in case of I / O operation failure
 * @ throws JavaGitException
 * Thrown when there is an error executing git - branch . */
public Ref renameBranch ( Ref branchFrom , String nameTo , boolean forceRename ) throws IOException , JavaGitException { } }

implementation: Ref newBranch = Ref . createBranchRef ( nameTo ) ; GitBranch gitBranch = new GitBranch ( ) ; gitBranch . renameBranch ( path , forceRename , branchFrom , newBranch ) ; return newBranch ;


signature:
public class DotGit { /** * Gets a list of the branches in the repository .
 * @ return The branches in the repository . */
public Iterator < Ref > getBranches ( ) throws IOException , JavaGitException { } }

implementation: GitBranch gitBranch = new GitBranch ( ) ; GitBranchOptions options = new GitBranchOptions ( ) ; GitBranchResponse response = gitBranch . branch ( path , options ) ; return response . getBranchListIterator ( ) ;


signature:
public class DotGit { /** * Show commit logs
 * @ return List of commits for the working directory
 * @ throws IOException
 * @ throws JavaGitException */
public List < Commit > getLog ( ) throws JavaGitException , IOException { } }

implementation: GitLog gitLog = new GitLog ( ) ; return gitLog . log ( this . getPath ( ) ) ;


signature:
public class GitCommit { /** * Automatically stage all tracked files that have been changed and then commit all files staged
 * in the git repository ' s index .
 * @ param repository
 * A < code > File < / code > instance for the path to the repository root ( the parent
 * directory of the . git directory ) or a sub - directory in the working tree of the
 * repository to commit against . This argument must represent the absolute path to the
 * desired directory as returned by the < code > File . getPath ( ) < / code > method . If null is
 * passed , a < code > NullPointerException < / code > will be thrown .
 * @ param message
 * The message to attach to the commit . A non - zero length argument is required for this
 * parameter , otherwise a < code > NullPointerException < / code > or
 * < code > IllegalArgumentException < / code > will be thrown .
 * @ return The results from the commit .
 * @ exception IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < li > a directory doesn ' t exist < / li >
 * < li > access to a file is denied < / li >
 * < li > a command is not found on the PATH < / li >
 * < / ul >
 * @ exception JavaGitException
 * Thrown when there is an error making the commit . */
public GitCommitResponseImpl commitAll ( File repository , String message ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repository , "repository" ) ; CheckUtilities . checkStringArgument ( message , "message" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitCommit gitCommit = client . getGitCommitInstance ( ) ; return gitCommit . commitAll ( repository , message ) ;


signature:
public class BooleanParameter { /** * { @ inheritDoc } */
@ Override public Object getBinderValue ( Service service ) { } }

implementation: String binderValue = getStringValue ( service . getBinder ( ) ) ; return parseStringValue ( binderValue ) ;


signature:
public class ObjectConverter { /** * Convert the given object value to the given class .
 * @ param from
 * The object value to be converted .
 * @ param to
 * The type class which the given object should be converted to .
 * @ return The converted object value .
 * @ throws NullPointerException
 * If ' to ' is null .
 * @ throws UnsupportedOperationException
 * If no suitable converter can be found .
 * @ throws RuntimeException
 * If conversion failed somehow . This can be caused by at least an
 * ExceptionInInitializerError , IllegalAccessException or
 * InvocationTargetException . */
@ SuppressWarnings ( "unchecked" ) public static < T > T convert ( Object from , Class < T > to ) { } }

implementation:
// Null is just null .
if ( from == null ) { return null ; } // Can we cast ? Then just do it .
if ( to . isAssignableFrom ( from . getClass ( ) ) ) { return to . cast ( from ) ; } // Lookup the suitable converter .
String converterId = from . getClass ( ) . getName ( ) + "_" + to . getName ( ) ; Method converter = CONVERTERS . get ( converterId ) ; if ( converter == null ) { throw new UnsupportedOperationException ( "Cannot convert from " + from . getClass ( ) . getName ( ) + " to " + to . getName ( ) + ". Requested converter does not exist." ) ; } // Convert the value .
try { // primitives don ' t appear to have a . cast ( ) method , which causes a null
// pointer exception
if ( to . isPrimitive ( ) ) { return ( T ) converter . invoke ( to , from ) ; } return to . cast ( converter . invoke ( to , from ) ) ; } catch ( Exception e ) { throw new RuntimeException ( "Cannot convert from " + from . getClass ( ) . getName ( ) + " to " + to . getName ( ) + ". Conversion failed with " + e . getMessage ( ) , e ) ; }


signature:
public class ObjectConverter { /** * Converts Integer to Boolean . If integer value is 0 , then return FALSE , else
 * return TRUE .
 * @ param value
 * The Integer to be converted .
 * @ return The converted Boolean value . */
public static Boolean integerToBoolean ( Integer value ) { } }

implementation: return value . intValue ( ) == 0 ? Boolean . FALSE : Boolean . TRUE ;


signature:
public class ObjectConverter { /** * Converts Boolean to Integer . If boolean value is TRUE , then return 1 , else
 * return 0.
 * @ param value
 * The Boolean to be converted .
 * @ return The converted Integer value . */
public static Integer booleanToInteger ( Boolean value ) { } }

implementation: return value . booleanValue ( ) ? Integer . valueOf ( 1 ) : Integer . valueOf ( 0 ) ;


signature:
public class ObjectConverter { /** * Converts Date to String .
 * @ param value
 * The value to be converted .
 * @ return Converted value . */
public static String longToString ( Date value ) { } }

implementation: if ( value == null ) { return null ; } SimpleDateFormat sdf = new SimpleDateFormat ( ) ; return sdf . format ( value ) ;


signature:
public class BaseContentProvider { /** * Returns a { @ link Uri } for the using it with a { @ link ContentResolver } to access this { @ link ContentProvider } . The { @ link Uri } allows CRUD operations
 * on a
 * single { @ link Entity } element , qualified by its primary key .
 * @ param tableName Name of the Table ( simple { @ link Entity } name ) the data should be retrieved from .
 * @ param id Primary key of the { @ link Entity } to be accessed
 * @ return Uri to access the specific item in the table */
public static Uri uriForItem ( final String tableName , final long id ) { } }

implementation: return REGISTRY . getItemUri ( tableName , Long . toString ( id ) ) ;


signature:
public class ExceptionMessageMap { /** * Gets the error message for the specified code .
 * @ param code
 * The error code for which to get the associated error message .
 * @ return The error message for the specified code . */
public static String getMessage ( String code ) { } }

implementation: String str = MESSAGE_MAP . get ( code ) ; if ( null == str ) { return "NO MESSAGE FOR ERROR CODE. { code=[" + code + "] }" ; } return str ;


signature:
public class GitResetResponse { /** * Gets the file at the specified index from the list of files needing update .
 * @ param index
 * The index of the file to get . It must fall in the range :
 * < code > 0 & lt ; = index & lt ; getRemovedFilesSize ( ) < / code > .
 * @ return The file at the specified index . */
public File getFileNeedingUpdate ( int index ) { } }

implementation: CheckUtilities . checkIntIndexInListRange ( filesNeedingUpdate , index ) ; return filesNeedingUpdate . get ( index ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to list of files that are deleted and will be committed next time
 * & lt ; git - commit & gt ; is run .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToDeletedFilesToCommit ( File file ) { } }

implementation: deletedFilesToCommit . add ( file ) ; fileToStatus . put ( file , Status . DELETED_TO_COMMIT ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to the list of files that are deleted locally but not yet deleted from index using
 * & lt ; git - rm & gt ; command .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToDeletedFilesNotUpdated ( File file ) { } }

implementation: deletedFilesNotUpdated . add ( file ) ; fileToStatus . put ( file , Status . DELETED ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to list of files that are modified and will be committed next time
 * & lt ; git - commit & gt ; is run .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToModifiedFilesToCommit ( File file ) { } }

implementation: modifiedFilesToCommit . add ( file ) ; fileToStatus . put ( file , Status . MODIFIED_TO_COMMIT ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to the list of files that are modified files but not yet updated .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToModifiedFilesNotUpdated ( File file ) { } }

implementation: modifiedFilesNotUpdated . add ( file ) ; fileToStatus . put ( file , Status . MODIFIED ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to the list of new files that are ready to be committed next time & lt ; git - commit & gt ;
 * command is run .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToNewFilesToCommit ( File file ) { } }

implementation: newFilesToCommit . add ( file ) ; fileToStatus . put ( file , Status . NEW_TO_COMMIT ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to the list of renamed files that are ready to be committed next time & lt ; git - commit & gt ;
 * command is run .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToRenamedFilesToCommit ( File file ) { } }

implementation: renamedFilesToCommit . add ( file ) ; fileToStatus . put ( file , Status . RENAMED_TO_COMMIT ) ;


signature:
public class GitStatusResponseImpl { /** * Adds a file to list of files that have been added locally but not yet added to the index .
 * @ param file
 * < code > File < / code > to be added to the list . */
public void addToUntrackedFiles ( File file ) { } }

implementation: untrackedFiles . add ( file ) ; fileToStatus . put ( file , Status . UNTRACKED ) ;


signature:
public class Parameter { /** * Factory method to create the concrete variable type .
 * @ param name
 * The name in the binder of the variable .
 * @ return */
public static Parameter create ( String name , Class < ? > type , boolean required ) throws IllegalArgumentException { } }

implementation: if ( InjectedParameter . isValidType ( type ) ) { return new InjectedParameter ( name , type ) ; } if ( type . isPrimitive ( ) && ! required ) { String msg = "Parameter [" + name + "] found with non-nullable type. Use a wrapper type or change to required" ; throw new IllegalArgumentException ( msg ) ; } Parameter p ; if ( type == String . class ) { p = new StringParameter ( name , type ) ; } else if ( type == Integer . class || type == int . class ) { p = new IntegerParameter ( name , type ) ; } else if ( type == Long . class || type == long . class ) { p = new LongParameter ( name , type ) ; } else if ( type == Float . class || type == float . class ) { p = new FloatParameter ( name , type ) ; } else if ( type == Double . class || type == double . class ) { p = new DoubleParameter ( name , type ) ; } else if ( type == Date . class ) { p = new DateParameter ( name , type ) ; } else if ( type == ResultSet . class || type == DataResultSet . class ) { p = new ResultSetParameter ( name , type ) ; } else if ( type == Boolean . class || type == boolean . class ) { p = new BooleanParameter ( name , type ) ; } else if ( type == Provider . class ) { p = new ProviderParameter ( name ) ; } else { throw new IllegalArgumentException ( "Parameter type " + type . getName ( ) + " is not valid" ) ; } p . setRequired ( required ) ; return p ;


signature:
public class Parameter { /** * Get the string value from binder . */
public String getStringValue ( DataBinder binder ) { } }

implementation:
// binder can ' t get a non existent param
if ( this . name == null || this . name . equals ( "" ) ) { return null ; } String value = ( String ) binder . getLocal ( this . name ) ; if ( value == null && this . required ) { throw new IllegalArgumentException ( "Parameter " + name + " is required" ) ; } return value ;


signature:
public class Parameter { /** * { @ inheritDoc } */
public Object getArgumentValue ( Object object , Service service ) throws ClassCastException { } }

implementation: return ObjectConverter . convert ( object , type ) ;


signature:
public class GitBranchOptions { /** * Checks whether the verbose option should be set and sets it .
 * @ param optVerbose
 * True if the verbose option should be used , false otherwise . */
public void setOptVerbose ( boolean optVerbose ) { } }

implementation: checkCanSetNoArgOption ( "--verbose" ) ; if ( ( false == optVerbose ) && ( optAbbrev || optNoAbbrev ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --no-abbrev or --abbrev can only be used with --verbose." ) ; } this . optVerbose = optVerbose ;


signature:
public class GitBranchOptions { /** * Checks whether the - - abbrev option should be set and sets it .
 * @ param optAbbrev True if the - - abbrev option should be used , false otherwise . */
public void setOptAbbrev ( boolean optAbbrev ) { } }

implementation: if ( optVerbose ) { if ( optAbbrev && optNoAbbrev ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --abbrev cannot be used with --no-abbrev." ) ; } this . optAbbrev = optAbbrev ; }


signature:
public class GitBranchOptions { /** * Checks whether the - - no - abbrev option should be set and sets it .
 * @ param optNoAbbrev True if the - - no - abbrev option should be used , false otherwise . */
public void setOptNoAbbrev ( boolean optNoAbbrev ) { } }

implementation: if ( optVerbose ) { if ( optAbbrev && optNoAbbrev ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --no-abbrev cannot be used with --abbrev." ) ; } this . optNoAbbrev = optNoAbbrev ; }


signature:
public class GitBranchOptions { /** * Checks whether the - - track option should be set and sets it .
 * @ param optTrack True if the - - track option should be used , false otherwise . */
public void setOptTrack ( boolean optTrack ) { } }

implementation: checkCanSetCreateOption ( "--track" ) ; if ( optNoTrack && optTrack ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --track cannot be used with --no-track." ) ; } this . optTrack = optTrack ;


signature:
public class GitBranchOptions { /** * Checks whether the - - no - track option should be set and sets it .
 * @ param optNoTrack True if the - - no - track option should be used , false otherwise . */
public void setOptNoTrack ( boolean optNoTrack ) { } }

implementation: checkCanSetNoArgOption ( "--no-track" ) ; if ( optNoTrack && optTrack ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --no-track cannot be used with --track." ) ; } this . optNoTrack = optNoTrack ;


signature:
public class GitBranchOptions { /** * Checks whether the - - color option should be set and sets it .
 * @ param optColor True if the - - color option should be used , false otherwise . */
public void setOptColor ( boolean optColor ) { } }

implementation: checkCanSetNoArgOption ( "--color" ) ; if ( optNoColor && optColor ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --color cannot be used with --no-color." ) ; } this . optColor = optColor ;


signature:
public class GitBranchOptions { /** * Checks whether the - - no - color option should be set and sets it .
 * @ param optNoColor True if the - - no - color option should be used , false otherwise . */
public void setOptNoColor ( boolean optNoColor ) { } }

implementation: checkCanSetNoArgOption ( "--no-color" ) ; if ( optNoColor && optColor ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --no-color cannot be used with --color." ) ; } this . optNoColor = optNoColor ;


signature:
public class GitBranchOptions { /** * Checks whether the - - merged option should be set and sets it .
 * @ param optMerged True if the - - merged option should be used , false otherwise . */
public void setOptMerged ( boolean optMerged ) { } }

implementation: checkCanSetNoArgOption ( "--merged" ) ; if ( optNoMerged && optMerged ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --merged cannot be used with --no-merged." ) ; } this . optMerged = optMerged ;


signature:
public class GitBranchOptions { /** * Checks whether the - - no - merged option should be set and sets it .
 * @ param optNoMerged True if the - - no - merged option should be used , false otherwise . */
public void setOptNoMerged ( boolean optNoMerged ) { } }

implementation: checkCanSetNoArgOption ( "--no-merged" ) ; if ( optNoMerged && optMerged ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  --no-merged cannot be used with --merged." ) ; } this . optNoMerged = optNoMerged ;


signature:
public class GitBranchOptions { /** * Checks whether the - d option should be set and sets it .
 * @ param optDLower True if the - d option should be used , false otherwise . */
public void setOptDLower ( boolean optDLower ) { } }

implementation: checkCanSetDeleteOption ( "-d" ) ; if ( optDLower && optDUpper ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  -d cannot be used with -D." ) ; } this . optDLower = optDLower ;


signature:
public class GitBranchOptions { /** * Checks whether the - D option should be set and sets it .
 * @ param optDUpper True if the - D option should be used , false otherwise . */
public void setOptDUpper ( boolean optDUpper ) { } }

implementation: checkCanSetDeleteOption ( "-D" ) ; if ( optDLower && optDUpper ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  -D cannot be used with -d." ) ; } this . optDUpper = optDUpper ;


signature:
public class GitBranchOptions { /** * Checks whether the - m option should be set and sets it .
 * @ param optMLower True if the - m option should be used , false otherwise . */
public void setOptMLower ( boolean optMLower ) { } }

implementation: checkCanSetRenameOption ( "-m" ) ; if ( optMLower && optMUpper ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  -m cannot be used with -M." ) ; } this . optMLower = optMLower ;


signature:
public class GitBranchOptions { /** * Checks whether the - M option should be set and sets it .
 * @ param optMUpper True if the - M option should be used , false otherwise . */
public void setOptMUpper ( boolean optMUpper ) { } }

implementation: checkCanSetRenameOption ( "-M" ) ; if ( optMLower && optMUpper ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + "  -M cannot be used with -m." ) ; } this . optMUpper = optMUpper ;


signature:
public class GitBranchOptions { /** * Checks whether an option for displaying branches can be set . If not , throws an
 * < code > IllegalArgumentException < / code > .
 * @ param option
 * The name of the option being checked ; for use in exception messages . */
public void checkCanSetNoArgOption ( String option ) { } }

implementation: if ( isOptTrack ( ) || isOptNoTrack ( ) || isOptL ( ) || isOptF ( ) || isOptDLower ( ) || isOptDUpper ( ) || isOptMLower ( ) || isOptMUpper ( ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + option + " should be used without arguments, to display branches" ) ; }


signature:
public class GitBranchOptions { /** * Checks whether an option for creating a branch can be set . If not , throws an
 * < code > IllegalArgumentException < / code > .
 * @ param option
 * The name of the option being checked ; for use in exception messages . */
public void checkCanSetCreateOption ( String option ) { } }

implementation: if ( isOptColor ( ) || isOptNoColor ( ) || isOptR ( ) || isOptA ( ) || isOptVerbose ( ) || isOptMerged ( ) || isOptNoMerged ( ) || ( null != getOptContains ( ) ) || isOptMLower ( ) || isOptMUpper ( ) || isOptDLower ( ) || isOptDUpper ( ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + option + " should be used with a branch name and optional start point, to create a branch" ) ; }


signature:
public class GitBranchOptions { /** * Checks whether an option for deleting a branch or branch list can be set . If not , throws an
 * < code > IllegalArgumentException < / code > .
 * @ param option
 * The name of the option being checked ; for use in exception messages . */
public void checkCanSetDeleteOption ( String option ) { } }

implementation: if ( isOptColor ( ) || isOptNoColor ( ) || isOptA ( ) || isOptVerbose ( ) || isOptMerged ( ) || isOptNoMerged ( ) || ( null != getOptContains ( ) ) || isOptTrack ( ) || isOptNoTrack ( ) || isOptL ( ) || isOptF ( ) || isOptMLower ( ) || isOptMUpper ( ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + option + " should be used with branch(es), to delete the branch(es)." ) ; }


signature:
public class GitBranchOptions { /** * Checks whether an option for renaming a branch can be set . If not , throws an
 * < code > IllegalArgumentException < / code > .
 * @ param option
 * The name of the option being checked ; for use in exception messages . */
public void checkCanSetRenameOption ( String option ) { } }

implementation: if ( isOptColor ( ) || isOptNoColor ( ) || isOptR ( ) || isOptA ( ) || isOptVerbose ( ) || isOptMerged ( ) || isOptNoMerged ( ) || ( null != getOptContains ( ) ) || isOptTrack ( ) || isOptNoTrack ( ) || isOptL ( ) || isOptF ( ) || isOptDLower ( ) || isOptDUpper ( ) ) { throw new IllegalArgumentException ( ExceptionMessageMap . getMessage ( "000120" ) + option + " should be used with optional oldbranch and newbranch, to rename oldbranch/current branch" + "to newbranch." ) ; }


signature:
public class ScriptProxy { /** * Configuration data for functions . This list must align with the
 * " m _ functionTable " list . In order the values are " id number " ,
 * " Number of arguments " , " First argument type " , " Second argument type " ,
 * " Return Type " . Return type has the following possible values : 0 generic
 * object ( such as strings ) 1 boolean 2 integer 3 double . The value " - 1 " means
 * the value is unspecified .
 * @ param klass
 * The annotated class */
private void generateDefinitions ( ) { } }

implementation: functionParameterTypes = new ArrayList < Class < ? > [ ] > ( ) ; functionMethodNames = new ArrayList < String > ( ) ; variableParameterTypes = new ArrayList < Class < ? > [ ] > ( ) ; variableMethodNames = new ArrayList < String > ( ) ; List < String > functionNames = new ArrayList < String > ( ) ; List < ParameterMarshaller > functionParams = new ArrayList < ParameterMarshaller > ( ) ; List < Integer > functionReturnTypes = new ArrayList < Integer > ( ) ; List < String > variableNames = new ArrayList < String > ( ) ; List < Integer > variableReturnTypes = new ArrayList < Integer > ( ) ; Method ms [ ] = m_class . getDeclaredMethods ( ) ; functionMethods = new Method [ ms . length ] ; Map < String , Method > methods = new TreeMap < String , Method > ( ) ; for ( Method m : ms ) { methods . put ( m . getName ( ) , m ) ; } int functionCounter = 0 ; for ( String methodName : methods . keySet ( ) ) { Method m = methods . get ( methodName ) ; IdocFunction functionInfo = m . getAnnotation ( IdocFunction . class ) ; if ( functionInfo != null ) { if ( functionInfo . name ( ) . equals ( "" ) ) { functionNames . add ( m . getName ( ) ) ; } else { functionNames . add ( functionInfo . name ( ) ) ; } functionMethodNames . add ( m . getName ( ) ) ; functionMethods [ functionCounter ] = m ; functionParams . add ( new ParameterMarshaller ( m ) ) ; functionReturnTypes . add ( getFunctionReturnType ( m ) ) ; functionParameterTypes . add ( m . getParameterTypes ( ) ) ; functionCounter ++ ; } else { IdocVariable varInfo = m . getAnnotation ( IdocVariable . class ) ; if ( varInfo != null ) { if ( varInfo . name ( ) . equals ( "" ) ) { variableNames . add ( m . getName ( ) ) ; } else { variableNames . add ( varInfo . name ( ) ) ; } variableMethodNames . add ( m . getName ( ) ) ; variableReturnTypes . add ( getVariableReturnType ( m ) ) ; variableParameterTypes . add ( m . getParameterTypes ( ) ) ; } } } writeVariableTables ( variableNames , variableReturnTypes ) ; writeFunctionTables ( functionNames , functionParams , functionReturnTypes ) ;


signature:
public class ScriptProxy { /** * Build a static int [ m ] [ 2 ] array of variable info where the int array is
 * < code > { variable _ index , return _ type } < / code > .
 * @ param functionParams */
private void writeVariableTables ( List < String > variableNames , List < Integer > variableReturnTypes ) { } }

implementation: m_variableTable = variableNames . toArray ( new String [ variableNames . size ( ) ] ) ; m_variableDefinitionTable = new int [ variableNames . size ( ) ] [ 2 ] ; for ( int i = 0 ; i < variableNames . size ( ) ; i ++ ) { m_variableDefinitionTable [ i ] [ 0 ] = i ; m_variableDefinitionTable [ i ] [ 1 ] = variableReturnTypes . get ( i ) ; }


signature:
public class ScriptProxy { /** * Build a static int [ m ] [ n ] array of function info from a dynamic array where
 * n changes size . The last parameter will always remain the last parameter
 * but any short rows will pad their parameter types as - 1 ( type not
 * specified )
 * @ param functionParams */
private void writeFunctionTables ( List < String > functionNames , List < ParameterMarshaller > functionParams , List < Integer > returnTypes ) { } }

implementation:
m_functionTable = functionNames . toArray ( new String [ functionNames . size ( ) ] ) ; int maxParams = 0 ; // find the max of all parameter counts
for ( int i = 0 ; i < functionParams . size ( ) ; i ++ ) { int paramCount = functionParams . get ( i ) . getParameterCount ( false ) ; if ( paramCount > maxParams ) { maxParams = paramCount ; } } m_functionDefinitionTable = new int [ functionParams . size ( ) ] [ maxParams + ParameterMarshaller . EXTRA_FUNC_DEF_VALUES ] ; // output params now
for ( int i = 0 ; i < functionParams . size ( ) ; i ++ ) { m_functionDefinitionTable [ i ] = functionParams . get ( i ) . getFunctionDefinitionArray ( i , maxParams , returnTypes . get ( i ) ) ; }


signature:
public class ScriptProxy { /** * Get idoc function return type .
 * @ param m
 * @ return */
public Integer getFunctionReturnType ( Method m ) { } }

implementation: Class < ? > type = m . getReturnType ( ) ; if ( type == Void . class || type == void . class ) { return RETURN_VOID ; } if ( type == Boolean . class || type == boolean . class ) { return RETURN_BOOLEAN ; } if ( type == Integer . class || type == int . class || type == Long . class || type == long . class ) { return RETURN_INTEGER ; } if ( type == Float . class || type == float . class || type == Double . class || type == double . class ) { return RETURN_FLOAT ; } return RETURN_STRING ;


signature:
public class ScriptProxy { /** * Get idoc variable type ( limited to string or conditional ) .
 * @ param m
 * @ return */
public Integer getVariableReturnType ( Method m ) { } }

implementation: if ( m . getReturnType ( ) == Boolean . class || m . getReturnType ( ) == boolean . class ) { return RETURN_BOOLEAN ; } return RETURN_STRING ;


signature:
public class ScriptProxy { /** * Enumerates the correct parameters for the delegated method . Injects any
 * autowired types if present in the method signature .
 * @ param method
 * @ param args
 * @ param ctx
 * @ return
 * @ throws IllegalArgumentException
 * @ throws ServiceException */
public Object [ ] getInjectedValueArray ( Method method , Object [ ] args , ExecutionContext ctx ) throws IllegalArgumentException , ServiceException { } }

implementation: ParameterMarshaller marshaller = new ParameterMarshaller ( method ) ; if ( ( ctx instanceof Service ) == false ) { throw new ServiceException ( "Tried to create parameters with injection and not inside a service." ) ; } return marshaller . getValueArray ( args , ( Service ) ctx ) ;


signature:
public class ScriptProxy { /** * Executes the annotated method .
 * @ param functionIndex
 * @ param args
 * @ param ctx
 * @ return
 * @ throws IllegalArgumentException
 * @ throws ServiceException
 * @ throws SecurityException
 * @ throws NoSuchMethodException
 * @ throws IllegalAccessException
 * @ throws InvocationTargetException */
public Object runFunctionMethod ( int functionIndex , Object [ ] args , ExecutionContext ctx ) throws SecurityException , NoSuchMethodException , IllegalArgumentException , ServiceException , IllegalAccessException , InvocationTargetException { } }

implementation:
Method method = functionMethods [ functionIndex ] ; Object params [ ] = getInjectedValueArray ( method , args , ctx ) ; Object result ; try { result = method . invoke ( m_class . newInstance ( ) , params ) ; } catch ( InstantiationException e ) { // TODO catch and re - throw ewwwww
throw new ServiceException ( "Cannot delegate instantiate script context: " + e . getMessage ( ) ) ; } if ( result == null ) { return result ; } return convertReturnValue ( result ) ;


signature:
public class ScriptProxy { /** * Convert the method return value into a PageMerger internal type of String ,
 * Long or Double
 * @ param result
 * @ return */
private Object convertReturnValue ( Object result ) { } }

implementation:
if ( boolean . class . isInstance ( result ) || result instanceof Boolean ) { return ScriptExtensionUtils . computeReturnObject ( 1 , ( ( Boolean ) result ) . booleanValue ( ) , 0 , 0.0 , null ) ; } else if ( long . class . isInstance ( result ) ) { return ( Long ) result ; } else if ( int . class . isInstance ( result ) || result instanceof Integer ) { return new Long ( ( Integer ) result ) ; } else if ( double . class . isInstance ( result ) ) { return ( Double ) result ; } // String / Double / Long / Float
return result ;


signature:
public class CliGitStatus { /** * Implementation of < code > IGitStatus < / code > method for getting the status of a list of files */
public GitStatusResponse status ( File repositoryPath , GitStatusOptions options , List < File > paths ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkNullArgument ( repositoryPath , "RepositoryPath" ) ; CheckUtilities . checkFileValidity ( repositoryPath ) ; List < String > command = buildCommandLine ( options , paths ) ; GitStatusParser parser ; if ( inputFile != null ) { parser = new GitStatusParser ( repositoryPath . getPath ( ) + File . separator , inputFile ) ; } else { parser = new GitStatusParser ( repositoryPath . getPath ( ) + File . separator ) ; } GitStatusResponse response = ( GitStatusResponseImpl ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ; return response ;


signature:
public class CliGitStatus { /** * Implementation of < code > IGitStatus < / code > method for getting the status of a file . */
public GitStatusResponse status ( File repositoryPath , GitStatusOptions options , File file ) throws JavaGitException , IOException { } }

implementation: List < File > paths = new ArrayList < File > ( ) ; paths . add ( file ) ; return status ( repositoryPath , options , paths ) ;


signature:
public class CliGitStatus { /** * Implementation of < code > IGitStatus < / code > method with only options passed to & lt ; git - status & gt ; command . */
public GitStatusResponse status ( File repositoryPath , GitStatusOptions options ) throws JavaGitException , IOException { } }

implementation: List < File > paths = null ; return status ( repositoryPath , options , paths ) ;


signature:
public class CliGitStatus { /** * Implementation of < code > IGitStatus < / code > method with options set to all ( - a ) */
public GitStatusResponse statusAll ( File repositoryPath ) throws JavaGitException , IOException { } }

implementation: GitStatusOptions options = new GitStatusOptions ( ) ; options . setOptAll ( true ) ; return status ( repositoryPath , options ) ;


signature:
public class CliGitStatus { /** * Return status for a single < code > File < / code >
 * @ param repositoryPath
 * Directory path to the root of the repository .
 * @ param options
 * Options that are passed to & lt ; git - status & gt ; command .
 * @ param file
 * < code > File < / code > instance
 * @ return < code > GitStatusResponse < / code > object
 * @ throws JavaGitException
 * Exception thrown if the repositoryPath is null
 * @ throws IOException
 * Exception is thrown if any of the IO operations fail . */
public GitStatusResponse getSingleFileStatus ( File repositoryPath , GitStatusOptions options , File file ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkNullArgument ( repositoryPath , "RepositoryPath" ) ; CheckUtilities . checkFileValidity ( repositoryPath ) ; List < String > command = buildCommandLine ( options , null ) ; GitStatusParser parser = new GitStatusParser ( repositoryPath . getPath ( ) + File . separator , file ) ; return ( GitStatusResponseImpl ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ;


signature:
public class CliGitStatus { /** * Parses options provided by the < code > GitStatusOptions < / code > object and adds them to the
 * command .
 * @ param options
 * < code > GitStatusOptions < / code > provided by & lt ; gitclipse & gt ; .
 * @ param paths
 * List of file paths .
 * @ return command to be executed . */
private List < String > buildCommandLine ( GitStatusOptions options , List < File > paths ) { } }

implementation: List < String > command = new ArrayList < String > ( ) ; command . add ( JavaGitConfiguration . getGitCommand ( ) ) ; command . add ( "status" ) ; if ( options != null ) { setOptions ( command , options ) ; } if ( paths != null ) { for ( File file : paths ) { command . add ( file . getPath ( ) ) ; } } return command ;


signature:
public class GitBranch { /** * Does a basic git - branch without any options .
 * @ param repositoryPath
 * A < code > File < / code > instance for the path to the repository . If null is passed ,
 * a < code > NullPointerException < / code > will be thrown .
 * @ return The result of the git branch .
 * @ throws IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < li > a directory doesn ' t exist < / li >
 * < li > a command is not found on the PATH < / li >
 * < / ul >
 * @ throws JavaGitException
 * Thrown when there is an error executing git - branch . */
public GitBranchResponse branch ( File repositoryPath ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repositoryPath , "repository path" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitBranch gitBranch = client . getGitBranchInstance ( ) ; return gitBranch . branch ( repositoryPath ) ;


signature:
public class GitBranch { /** * This method deletes the specified branch using the - d command line option .
 * @ param repositoryPath
 * A < code > File < / code > instance for the path to the repository . If null is passed ,
 * a < code > NullPointerException < / code > will be thrown .
 * @ param forceDelete
 * True if force delete option - D should be used , false if - d should be used .
 * @ param remote
 * True if delete branch should be acted upon a remote branch .
 * @ param branchName
 * A branch to be deleted .
 * @ return The result of the git - branch with delete option .
 * @ throws IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < li > a directory doesn ' t exist < / li >
 * < li > access to a file is denied < / li >
 * < li > a command is not found on the PATH < / li >
 * < / ul >
 * @ throws JavaGitException
 * Thrown when there is an error executing git - branch . */
public GitBranchResponse deleteBranch ( File repositoryPath , boolean forceDelete , boolean remote , Ref branchName ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repositoryPath , "repository path" ) ; CheckUtilities . checkNullArgument ( branchName , "branch name" ) ; CheckUtilities . validateArgumentRefType ( branchName , Ref . RefType . BRANCH , "branch name" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitBranch gitBranch = client . getGitBranchInstance ( ) ; return gitBranch . deleteBranch ( repositoryPath , forceDelete , remote , branchName ) ;


signature:
public class GitBranch { /** * Deletes the specified branches using the - d command line option .
 * @ param repositoryPath
 * A < code > File < / code > instance for the path to the repository . If null is passed ,
 * a < code > NullPointerException < / code > will be thrown .
 * @ param forceDelete
 * True if force delete option - D should be used , false if - d should be used .
 * @ param remote
 * True if delete branch should be acted upon a remote branch list .
 * @ param branchList
 * The list of branches to be deleted .
 * @ return The result of the git - branch with - d option .
 * @ throws IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < li > a directory doesn ' t exist < / li >
 * < li > access to a file is denied < / li >
 * < li > a command is not found on the PATH < / li >
 * < / ul >
 * @ throws JavaGitException
 * Thrown when there is an error executing git - branch . */
public GitBranchResponse deleteBranch ( File repositoryPath , boolean forceDelete , boolean remote , List < Ref > branchList ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repositoryPath , "repository path" ) ; CheckUtilities . checkNullListArgument ( branchList , "branch list" ) ; CheckUtilities . validateListRefType ( branchList , Ref . RefType . BRANCH , "branch list" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitBranch gitBranch = client . getGitBranchInstance ( ) ; return gitBranch . deleteBranches ( repositoryPath , forceDelete , remote , branchList ) ;


signature:
public class GitBranch { /** * Renames the current branch to new branch .
 * @ param repositoryPath
 * A < code > File < / code > instance for the path to the repository . If null is passed ,
 * a < code > NullPointerException < / code > will be thrown .
 * @ param forceRename
 * True if force rename option - M should be used . False if - m should be used .
 * @ param newName
 * When renaming the current branch to a new branch name , this is the new branch name .
 * @ return The result of the git branch with - m option .
 * @ throws IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < li > a directory doesn ' t exist < / li >
 * < li > access to a file is denied < / li >
 * < li > a command is not found on the PATH < / li >
 * < / ul >
 * @ throws JavaGitException
 * Thrown when there is an error executing git - branch . */
public GitBranchResponse renameBranch ( File repositoryPath , boolean forceRename , Ref newName ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repositoryPath , "repository path" ) ; CheckUtilities . checkNullArgument ( newName , "new name" ) ; CheckUtilities . validateArgumentRefType ( newName , Ref . RefType . BRANCH , "new name" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitBranch gitBranch = client . getGitBranchInstance ( ) ; return gitBranch . renameBranch ( repositoryPath , forceRename , newName ) ;


signature:
public class WorkingTree { /** * Static factory method for retrieving an instance of this class .
 * @ param path
 * < code > File < / code > object representing the path to the repository .
 * @ return The < code > WorkingTree < / code > instance for this path */
public static synchronized WorkingTree getInstance ( File path ) { } }

implementation:
WorkingTree workingTree ; // TODO ( rs2705 ) : make sure that path is valid
/* * We want to make sure we ' re dealing with the canonical path here , since there are multiple
 * ways to refer to the same dir with different strings . */
String canonicalPath = "" ; try { canonicalPath = path . getCanonicalPath ( ) ; } catch ( Exception e ) { /* * TODO ( rs2705 ) : Figure out which exception to throw here , and throw it - or should we simply
 * let it propogate up as - is ? */
return null ; // Temporary placeholder
} if ( ! ( INSTANCES . containsKey ( canonicalPath ) ) ) { workingTree = new WorkingTree ( path , canonicalPath ) ; INSTANCES . put ( canonicalPath , workingTree ) ; } else { workingTree = INSTANCES . get ( canonicalPath ) ; } return workingTree ;


signature:
public class WorkingTree { /** * Commits the objects specified in the index to the repository .
 * @ param comment
 * Developer ' s comment about the change
 * @ return response from git commit */
public GitCommitResponse commit ( String comment ) throws IOException , JavaGitException { } }

implementation: GitCommit gitCommit = new GitCommit ( ) ; return gitCommit . commit ( path , comment ) ;


signature:
public class WorkingTree { /** * Gets the currently checked - out branch of the working directory .
 * @ return The currently checked - out branch of the working directory . */
public Ref getCurrentBranch ( ) throws IOException , JavaGitException { } }

implementation: GitBranch gitBranch = new GitBranch ( ) ; GitBranchOptions options = new GitBranchOptions ( ) ; GitBranchResponse response = gitBranch . branch ( path , options ) ; return response . getCurrentBranch ( ) ;