signature:
public class WorkingTree { /** * Switches to a new branch
 * @ param ref
 * Git branch / sha1 to switch to */
public void checkout ( Ref ref ) throws IOException , JavaGitException { } }

implementation:
GitCheckout gitCheckout = new GitCheckout ( ) ; gitCheckout . checkout ( path , null , ref ) ; /* * TODO ( rs2705 ) : Figure out why this function is setting this . path . When does the WorkingTree
 * path change ? */
// this . path = branch . getBranchRoot ( ) . getPath ( ) ;


signature:
public class WorkingTree { /** * Gets the status of all files in the working directory
 * @ return < code > GitStatusResponse < / code > object
 * @ throws IOException
 * Exception is thrown if any of the IO operations fail .
 * @ throws JavaGitException
 * Exception thrown if the repositoryPath is null */
public GitStatusResponse getStatus ( ) throws IOException , JavaGitException { } }

implementation: GitStatus gitStatus = new GitStatus ( ) ; return gitStatus . status ( path ) ;


signature:
public class GitRm { /** * Remove files relative to the path within the repository .
 * @ 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 run rm 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 path
 * A single file to remove . The specified path must be relative to the path specified in
 * the < code > repository < / code > parameter as returned by < code > File . getPath ( ) < / code > .
 * If null is passed , a < code > NullPointerException < / code > will be thrown .
 * @ 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 GitRmResponse rm ( File repository , File path ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repository , "repository" ) ; CheckUtilities . checkNullArgument ( path , "path" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitRm GitRm = client . getGitRmInstance ( ) ; return GitRm . rm ( repository , path ) ;


signature:
public class GitStatusResponse { /** * Get the name of the file from newFilesToCommit list at a given index .
 * @ param index
 * Index in the list must be positive and less than the number of new files to commit .
 * @ return the name of the file . */
public File getFileFromNewFilesToCommit ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Get the name of the deleted file that will be committed next time git - commit is executed
 * currently located at the given index in the list .
 * @ param index
 * Index in the list must be positive and less than the number of new files to commit
 * @ return the name of the file . */
public File getFileFromDeletedFilesToCommit ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Get the name of the file that is modified and added to the repository by & lt ; git - add & gt ;
 * command and will be committed to repository next time & lt ; git - commit & gt ; is executed . This file
 * is at the given index in the list of the files .
 * @ param index
 * Index in the list of files must be positive and less than the number of new files to
 * commit
 * @ return the name of the file . */
public File getFileFromModifiedFilesToCommit ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Returns the name of the deleted file that is removed locally but not yet removed from
 * repository .
 * @ param index
 * Index in the list must be positive and less than the number of new files to commit
 * @ return the name of the file . */
public File getFileFromDeletedFilesNotUpdated ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Returns the name of the file that is existing in the repository and has been locally modified .
 * This file is one of the files that has been locally modified and is located at given index in
 * the list .
 * @ param index
 * Index in the list must be positive and less than the number of new files to commit
 * @ return the name of the file */
public File getFileFromModifiedFilesNotUpdated ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Returns the name of the file at the specified index that has been created locally but has not
 * yet been added to the repository by & lt ; git - add & gt ; .
 * @ param index
 * Index in the list must be positive and less than the number of new files to commit
 * @ return the name of the file */
public File getFileFromUntrackedFiles ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Returns the file at the specified index in the list of renamed files .
 * @ param index
 * Index in the list must be positive and less than the number of new files to commit
 * @ return the name of the file */
public File getFileFromRenamedFiles ( int index ) { } }

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


signature:
public class GitStatusResponse { /** * Creates a copy of newFilesToCommit list and returns the < code > Iterable < / code > on this new list .
 * @ return Iterable New files to commit list . */
public Iterable < File > getNewFilesToCommit ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( newFilesToCommit ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Creates a copy of deletedFilesToCommit list and returns the < code > Iterable < / code > on this new
 * list .
 * @ return Iterable Deleted Files to commit list . */
public Iterable < File > getDeletedFilesToCommit ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( deletedFilesToCommit ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Creates a copy of modifiedFilesToComit list and returns the < code > Iterable < / code > on this new
 * list .
 * @ return Iterable Modified files to commit list . */
public Iterable < File > getModifiedFilesToCommit ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( modifiedFilesToCommit ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Creates a copy of deletedFilesNotUpdated list and returns the < code > Iterable < / code > on this
 * new list .
 * @ return Iterable Deleted files not updated list . */
public Iterable < File > getDeletedFilesNotUpdated ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( deletedFilesNotUpdated ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Creates a copy of modifiedFilesNotUpdated list and returns the < code > Iterable < / code > on this
 * new list .
 * @ return Iterable Modified files not updated list . */
public Iterable < File > getModifiedFilesNotUpdated ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( modifiedFilesNotUpdated ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Creates a copy of renamedFiles list and returns the < code > Iterable < / code > to this new list .
 * @ return Iterable Renamed files list . */
public Iterable < File > getRenamedFilesToCommit ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( renamedFilesToCommit ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Creates a copy of untrackedFiles list and returns the < code > Iterable < / code > on this new list .
 * @ return Iterable Untracked files list . */
public Iterable < File > getUntrackedFiles ( ) { } }

implementation: Iterator < File > fileIterator = new ArrayList < File > ( untrackedFiles ) . iterator ( ) ; return ( new IterableIterator < File > ( fileIterator ) ) ;


signature:
public class GitStatusResponse { /** * Returns the error message otherwise returns null ;
 * @ return error message */
public String getError ( int index ) { } }

implementation: if ( index < errors . size ( ) ) { ErrorDetails errorDetails = errors . get ( index ) ; return errorDetails . lineNumber + ". " + errorDetails . error ; } return null ;


signature:
public class GitStatusResponse { /** * Gets all the errors generated by & lt ; git - status & gt ; command and returns them in String format .
 * @ return < code > String < / code > errors concatenated together . */
public String getError ( ) { } }

implementation: StringBuilder strBuilder = new StringBuilder ( ) ; for ( int i = 0 ; i < errors . size ( ) ; i ++ ) { strBuilder . append ( getError ( i ) + " " ) ; } return strBuilder . toString ( ) ;


signature:
public class GitReset { /** * Perform a reset on the repository . The results of this method are what one would get by running
 * & quote ; git - reset & quote ; against the repository .
 * @ 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 perform reset 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 .
 * @ return The results of the reset .
 * @ 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 static GitResetResponse gitReset ( File repository ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repository , "repository" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitReset gitReset = client . getGitResetInstance ( ) ; return gitReset . gitReset ( repository ) ;


signature:
public class GitReset { /** * Perform a hard reset on the repository to the specified < code > CommitName < / code > .
 * @ 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 perform reset 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 commitName
 * The name of the commit to reset to . If the value is null , a
 * < code > NullPointerException < / code > will be thrown .
 * @ return The results of the reset .
 * @ 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 static GitResetResponse gitResetHard ( File repository , Ref commitName ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repository , "repository" ) ; CheckUtilities . checkNullArgument ( commitName , "commitName" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitReset gitReset = client . getGitResetInstance ( ) ; return gitReset . gitResetHard ( repository , commitName ) ;


signature:
public class GitCommitResponseImpl { /** * Add the information about a newly added file in the repository for a given commit .
 * @ param pathToFile
 * The path to the file from the root of the repository .
 * @ param mode
 * The mode of the file .
 * @ return False if the < code > pathToFile < / code > is null or length zero . True otherwise . */
public boolean addAddedFile ( File pathToFile , String mode ) { } }

implementation: if ( null == pathToFile ) { return false ; } return addedFiles . add ( new AddedOrDeletedFile ( pathToFile , mode ) ) ;


signature:
public class GitCommitResponseImpl { /** * Add the information about a newly copied file in the repository for a given commit .
 * @ param sourceFilePath
 * The path to the source file .
 * @ param destinationFilePath
 * The path to the destination file .
 * @ param percentage
 * The percentage .
 * @ return False if < code > sourceFilePath < / code > or < code > destinationFilePath < / code > is null or
 * length zero . True otherwise . */
public boolean addCopiedFile ( File sourceFilePath , File destinationFilePath , int percentage ) { } }

implementation: if ( null == sourceFilePath || null == destinationFilePath ) { return false ; } return copiedFiles . add ( new CopiedOrMovedFile ( sourceFilePath , destinationFilePath , percentage ) ) ;


signature:
public class GitCommitResponseImpl { /** * Add the information about a file deleted from the repository for a given commit .
 * @ param pathToFile
 * The path to the file from the root of the repository .
 * @ param mode
 * The mode of the file .
 * @ return False if the < code > pathToFile < / code > is null or length zero . True otherwise . */
public boolean addDeletedFile ( File pathToFile , String mode ) { } }

implementation: if ( null == pathToFile ) { return false ; } return deletedFiles . add ( new AddedOrDeletedFile ( pathToFile , mode ) ) ;


signature:
public class GitCommitResponseImpl { /** * Add the information about a moved / renamed file in the repository for a given commit .
 * @ param sourceFilePath
 * The path to the source file .
 * @ param destinationFilePath
 * The path to the destination file .
 * @ param percentage
 * The percentage .
 * @ return False if < code > sourceFilePath < / code > or < code > destinationFilePath < / code > is null or
 * length zero . True otherwise . */
public boolean addRenamedFile ( File sourceFilePath , File destinationFilePath , int percentage ) { } }

implementation: if ( null == sourceFilePath || null == destinationFilePath ) { return false ; } return renamedFiles . add ( new CopiedOrMovedFile ( sourceFilePath , destinationFilePath , percentage ) ) ;


signature:
public class GitCommitResponseImpl { /** * Sets the number of files changed during a commit .
 * @ param filesChangedStr
 * The number of files changed in < code > String < / code > format .
 * @ return True if the < code > filesChangedStr < / code > parameter is a < code > String < / code >
 * representing a number . False if the < code > String < / code > does not contain a parsable
 * integer . */
public boolean setFilesChanged ( String filesChangedStr ) { } }

implementation: try { this . filesChanged = Integer . parseInt ( filesChangedStr ) ; return true ; } catch ( NumberFormatException e ) { return false ; }


signature:
public class GitCommitResponseImpl { /** * Sets the number of lines deleted in a commit .
 * @ param linesDeletedStr
 * The number of lines deleted in < code > String < / code > format .
 * @ return True if the < code > linesDeletedStr < / code > parameter is a < code > String < / code >
 * representing a number . False if the < code > String < / code > does not contain a parsable
 * integer . */
public boolean setLinesDeleted ( String linesDeletedStr ) { } }

implementation: try { this . linesDeleted = Integer . parseInt ( linesDeletedStr ) ; return true ; } catch ( NumberFormatException e ) { return false ; }


signature:
public class GitCommitResponseImpl { /** * Sets the number of lines inserted in a commit .
 * @ param linesInsertedStr
 * The number of lines inserted in < code > String < / code > format .
 * @ return True if the < code > linesInsertedStr < / code > parameter is a < code > String < / code >
 * representing a number . False if the < code > String < / code > does not contain a parsable
 * integer . */
public boolean setLinesInserted ( String linesInsertedStr ) { } }

implementation: try { this . linesInserted = Integer . parseInt ( linesInsertedStr ) ; return true ; } catch ( NumberFormatException e ) { return false ; }


signature:
public class CliGitMv { /** * Exec of git - mv command
 * @ param repoPath
 * 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 move / rename 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 git - mv command .
 * @ param source
 * The < code > List < / code > of source file / folder / symlink which are to be moved to a
 * different location . 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 > . A non - zero length argument is required for this
 * parameter , otherwise a < code > NullPointerException < / code > or
 * < code > IllegalArgumentException < / code > will be thrown .
 * @ param destination
 * The destination file / folder / symlink which the source is renamed or moved to . It
 * should be relative to the path specified in the < code > repository < / code >
 * parameter as returned by < code > File . getPath ( ) < / code > . 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 git - mv .
 * It is expected that GitMv does not notify when a move was successful . This follows
 * the response that git - mv itself gives . If the move / rename fails for any reason ,
 * proper exception messages are generated and thrown .
 * @ exception IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < 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 executing git - mv . */
public GitMvResponseImpl mvProcess ( File repoPath , GitMvOptions options , List < File > source , File destination ) throws IOException , JavaGitException { } }

implementation: List < String > commandLine = buildCommand ( options , source , destination ) ; GitMvParser parser = new GitMvParser ( ) ; return ( GitMvResponseImpl ) ProcessUtilities . runCommand ( repoPath , commandLine , parser ) ;


signature:
public class CliGitMv { /** * Builds a list of command arguments to pass to < code > ProcessBuilder < / code > .
 * @ param options
 * The options to include on the command line .
 * @ param source
 * The source file / directory / symlink to rename / move .
 * @ param destination
 * The destination file / directory / symlink to rename / move to .
 * @ return A list of the individual arguments to pass to < code > ProcessBuilder < / code > . */
protected List < String > buildCommand ( GitMvOptions options , List < File > source , File destination ) { } }

implementation: List < String > cmd = new ArrayList < String > ( ) ; cmd . add ( JavaGitConfiguration . getGitCommand ( ) ) ; cmd . add ( "mv" ) ; if ( null != options ) { if ( options . isOptF ( ) ) { cmd . add ( "-f" ) ; } if ( options . isOptK ( ) ) { cmd . add ( "-k" ) ; } if ( options . isOptN ( ) ) { cmd . add ( "-n" ) ; setDryRun ( true ) ; } } for ( File file : source ) { cmd . add ( file . getPath ( ) ) ; } cmd . add ( destination . getPath ( ) ) ; return cmd ;


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

implementation: return getInjectedValue ( service ) ;


signature:
public class InjectedParameter { /** * Special case for Injectable type . Injects the required parameter from the
 * ExecutionContext ( service )
 * @ param service
 * @ return */
protected Object getInjectedValue ( Service service ) { } }

implementation: if ( type == UserData . class ) { return service . getUserData ( ) ; } else if ( type == PageMerger . class ) { return service . getPageMerger ( ) ; } else if ( type == DataBinder . class ) { return service . getBinder ( ) ; } else if ( type == HttpImplementor . class ) { return service . getHttpImplementor ( ) ; } else if ( type == ServiceRequestImplementor . class ) { return service . getRequestImplementor ( ) ; } else if ( type == Workspace . class ) { return service . getWorkspace ( ) ; } else if ( ExecutionContext . class . isAssignableFrom ( type ) ) { return service ; } throw new IllegalStateException ( "Injectable type " + type . getName ( ) + " not known." ) ;


signature:
public class GitMv { /** * Moves the specified source files / symlinks / directories to the destination directory .
 * @ param repositoryPath
 * 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 move / rename 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 sources
 * The < code > List < / code > of source file / folder / symlink which are to be moved to a
 * different location . 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 > . A non - zero length argument is required for this
 * parameter , otherwise a < code > NullPointerException < / code > or
 * < code > IllegalArgumentException < / code > will be thrown .
 * @ param destination
 * The destination file / folder / symlink which the source is renamed or moved to . It
 * should be relative to the path specified in the < code > repository < / code >
 * parameter as returned by < code > File . getPath ( ) < / code > . 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 git - mv .
 * It is expected that GitMv does not notify when a move was successful . This follows
 * the response that git - mv itself gives . If the move / rename fails for any reason ,
 * proper exception messages are generated and thrown .
 * @ exception IOException
 * There are many reasons for which an < code > IOException < / code > may be thrown .
 * Examples include :
 * < ul >
 * < 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 executing git - mv . */
public GitMvResponse mv ( File repositoryPath , List < File > sources , File destination ) throws IOException , JavaGitException { } }

implementation:
CheckUtilities . checkNullArgument ( repositoryPath , "repository path" ) ; CheckUtilities . checkNullListArgument ( sources , "sources" ) ; CheckUtilities . checkNullArgument ( destination , "destination" ) ; // CheckUtilities . checkDirectoryArgument ( destination , " destination " ) ;
IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitMv gitMv = client . getGitMvInstance ( ) ; return gitMv . mv ( repositoryPath , sources , destination ) ;


signature:
public class StringUtilities { /** * Returns the position for char ' c ' in string ' str ' starting from position ' pos '
 * and searching towards the string beginning
 * @ param str
 * @ param from
 * @ param c
 * @ return char ' c ' position or - 1 if char is not found */
public static int indexOfLeft ( String str , int from , char c ) { } }

implementation: int pos = - 1 ; int f = from ; while ( f >= 0 && pos == - 1 ) if ( str . charAt ( f -- ) == c ) pos = f + 1 ; return pos ;


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

implementation:
String providerName = getStringValue ( service . getBinder ( ) ) ; Provider provider = Providers . getProvider ( providerName ) ; if ( this . required && provider == null ) { throw new IllegalArgumentException ( "Provider '" + providerName + "' could not be found." ) ; } // providers that are in error will throw an exception if they are required
if ( provider != null && provider . isInError ( ) && this . required ) { throw new IllegalArgumentException ( "The provider '" + providerName + "' is not configured correctly!" ) ; } return provider ;


signature:
public class ProviderParameter { /** * Returns a result set found by the passed in string value . */
@ Override public Object getArgumentValue ( Object object , Service service ) throws ClassCastException { } }

implementation:
if ( object instanceof String ) { Provider provider = Providers . getProvider ( ( String ) object ) ; if ( provider != null ) { return provider ; } } return null ; // throw new
// ClassCastException ( " Must supply the name of a provider as a string " ) ;


signature:
public class EntityService { /** * Gets a specific { @ link Entity } according to the given id
 * @ param id primary key of the { @ link Entity }
 * @ return The { @ link Entity } to the given id , or null if non was found */
public E get ( final long id ) { } }

implementation: SQLiteDatabase database = openDB ( ) ; try { Cursor cursor = database . query ( tableName , null , primaryKey . getName ( ) + " = ?" , new String [ ] { Long . toString ( id ) } , null , null , null ) ; if ( cursor . getCount ( ) == 0 ) { return null ; } return CursorOperation . tryOnCursor ( cursor , new CursorOperation < E > ( ) { @ Override public E execute ( final Cursor cursor ) { return CombinedCursorImpl . create ( context , cursor , entityInfo , entityClass ) . getCurrent ( ) ; } } ) ; } finally { closeDB ( database ) ; }


signature:
public class EntityService { /** * Search for { @ link Entity } s in the database with basic SQL WHERE statements .
 * @ param selection SQL WHERE statement
 * @ param selectionArgs Arguments for the WHERE statement
 * @ param order Sort order of the result
 * @ return All found { @ link Entity } s or an empty list of non are found */
public List < E > find ( final String selection , final String [ ] selectionArgs , final String order ) { } }

implementation: SQLiteDatabase database = openDB ( ) ; try { Cursor cursor = database . query ( tableName , null , selection , selectionArgs , null , null , order ) ; return CursorOperation . tryOnCursor ( cursor , new CursorOperation < List < E > > ( ) { @ Override public List < E > execute ( final Cursor cursor ) { return new ArrayList < E > ( CombinedCursorImpl . create ( context , cursor , entityInfo , entityClass ) . getAll ( ) ) ; } } ) ; } finally { closeDB ( database ) ; }


signature:
public class EntityService { /** * Resolves the associations to a given { @ link Entity } object and all underlying associations within the object
 * graph .
 * @ param data { @ link Entity } on which the associations should be resolved */
public void resolveAssociations ( final E data ) { } }

implementation: SQLiteDatabase database = openDB ( ) ; try { new DatabaseResolver ( context , database ) . resolve ( data , 0 , Integer . MAX_VALUE ) ; } finally { closeDB ( database ) ; }


signature:
public class EntityService { /** * Resolves the associations to a given { @ link Entity } object . The associations will only be resolved to the given
 * depth within the object graph .
 * @ param data { @ link Entity } on which the associations should be resolved
 * @ param maxDepth The maximum depth to which the associations should be resolved */
public void resolveAssociations ( final E data , final int maxDepth ) { } }

implementation: SQLiteDatabase database = openDB ( ) ; try { new DatabaseResolver ( context , database ) . resolve ( data , 0 , maxDepth ) ; } finally { closeDB ( database ) ; }


signature:
public class EntityService { /** * Stores the given { @ link Entity } to the database . Associated objects will be saved to the given maxDepth . < br >
 * maxDepth of 0 means that only the given { @ link Entity } itself will be saved without associations .
 * @ param data { @ link Entity } which should be stored
 * @ param maxDepth The maximum depth of the associated objects which should also be saved .
 * @ return The primary key of the given data .
 * @ throws IllegalStateException When the { @ link PrimaryKey } field and its value of the { @ link Entity } could
 * not be determined
 * @ throws org . droitateddb . validation . InvalidEntityException when the given entity is invalid . */
public long save ( final E data , final int maxDepth ) { } }

implementation: if ( toggle == ValidationToggle . ON ) { AccumulatedValidationResult validationResult = databaseValidator . validate ( data , maxDepth ) ; if ( ! validationResult . isValid ( ) ) { throw new InvalidEntityException ( validationResult ) ; } } final SQLiteDatabase database = openDB ( ) ; try { return transactional ( database , new DatabaseOperation < Number > ( ) { @ Override public Number execute ( ) { return new DatabaseSaver ( database , maxDepth ) . save ( data ) ; } } ) . longValue ( ) ; } finally { closeDB ( database ) ; }


signature:
public class EntityService { /** * Stores all given { @ link Entity } s in the { @ link Collection } to the database . Associated objects will be saved to
 * the given maxDepth . < br >
 * maxDepth of 0 means that only the given { @ link Entity } itself will be saved without associations .
 * @ param data { @ link Entity } which should be stored
 * @ param maxDepth The maximum depth of the associated objects which should also be saved .
 * @ throws IllegalStateException When the { @ link PrimaryKey } field and its value of the { @ link Entity } could
 * not be determined
 * @ throws org . droitateddb . validation . InvalidEntityException when at least one of the given entities is invalid . */
public void save ( final Collection < E > data , final int maxDepth ) { } }

implementation: if ( toggle == ValidationToggle . ON ) { AccumulatedValidationResult validationResult = databaseValidator . validate ( data , maxDepth ) ; if ( ! validationResult . isValid ( ) ) { throw new InvalidEntityException ( validationResult ) ; } } SQLiteDatabase database = openDB ( ) ; try { final DatabaseSaver databaseSaver = new DatabaseSaver ( database , maxDepth ) ; transactional ( database , new DatabaseOperation < Void > ( ) { @ Override public Void execute ( ) { for ( E object : data ) { databaseSaver . save ( object ) ; } return null ; } } ) ; } finally { closeDB ( database ) ; }


signature:
public class EntityService { /** * Deletes the given { @ link Entity } from the database
 * @ param data { @ link Entity } that should be deleted
 * @ return < code > true < / code > if the { @ link Entity } could be deleted , < code > false < / code > otherwise
 * @ throws IllegalStateException When the { @ link PrimaryKey } field and its value of the { @ link Entity } could not be determined
 * @ throws IllegalArgumentException When the value of the { @ link PrimaryKey } field is null */
public boolean delete ( final E data ) { } }

implementation: Number id = getFieldValue ( data , primaryKey ) ; if ( id == null ) { throw new IllegalArgumentException ( "The @PrimaryKey of the given @Entity can not be null" ) ; } return delete ( id . longValue ( ) ) ;


signature:
public class EntityService { /** * Deletes the data of the { @ link Entity } for the given id
 * @ param id primary key of the { @ link Entity } to be deleted
 * @ return < code > true < / code > if the { @ link Entity } could be deleted , < code > false < / code > otherwise */
public boolean delete ( final long id ) { } }

implementation: SQLiteDatabase database = openDB ( ) ; try { int delete = database . delete ( tableName , EntityData . getEntityData ( entityClass ) . primaryKey . getName ( ) + "= ?" , new String [ ] { Long . toString ( id ) } ) ; return delete == 1 ; } finally { closeDB ( database ) ; }


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

implementation:
// loads function def table from annotated class
ScriptExtensions extensions = new ScriptProxy ( klass ) ; // load func def table and set parent to the default script context
ScriptContext defaultScriptContext = ( ScriptContext ) AppObjectRepository . getObject ( "DefaultScriptContext" ) ; extensions . load ( defaultScriptContext ) ; // register these extensions
defaultScriptContext . registerExtension ( extensions ) ;


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

implementation: DataResultSet drs = getResultSet ( this . name , service ) ; if ( this . required && drs == null ) { throw new IllegalArgumentException ( "ResultSet " + this . name + " is required." ) ; } return drs ;


signature:
public class ResultSetParameter { /** * Returns a result set found by the passed in string value . */
@ Override public Object getArgumentValue ( Object object , Service service ) throws ClassCastException { } }

implementation: if ( object instanceof String ) { DataResultSet drs = getResultSet ( ( String ) object , service ) ; if ( drs != null ) { return drs ; } } return null ; // throw new ClassCastException ( " Must supply the name of a result set as a string " ) ;


signature:
public class ResultSetParameter { /** * Find a result set in the service binder .
 * @ param name
 * @ param service
 * @ return */
private DataResultSet getResultSet ( String name , Service service ) { } }

implementation: ResultSet rs = service . getBinder ( ) . getResultSet ( name ) ; DataResultSet drs = new DataResultSet ( ) ; if ( rs != null ) { drs . copy ( rs ) ; return drs ; } return null ;


signature:
public class CliGitLog { /** * Implementations of & lt ; git log & gt ; with options and one file to be added to index . */
public List < Commit > log ( File repositoryPath , GitLogOptions options ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; GitLogParser parser = new GitLogParser ( ) ; List < String > command = buildCommand ( repositoryPath , options ) ; GitLogResponse response = ( GitLogResponse ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ; if ( response . containsError ( ) ) { int line = response . getError ( 0 ) . getLineNumber ( ) ; String error = response . getError ( 0 ) . error ( ) ; throw new JavaGitException ( 420001 , "Line " + line + ", " + error ) ; } return response . getLog ( ) ;


signature:
public class GitLogResponse { /** * This add a newly created commit object to the list of commits for a log . */
public void addCommit ( ) { } }

implementation:
if ( this . sha != null ) { Commit commit = new Commit ( this . sha , this . mergeDetails , this . author , this . dateString , this . message , this . files ) ; if ( commitList == null ) { commitList = new ArrayList < Commit > ( ) ; } this . commitList . add ( commit ) ; // reset variables for future commits .
this . files = null ; this . mergeDetails = null ; this . message = null ; }


signature:
public class GitLogResponse { /** * This adds a file to the list of files affected by a particular commit .
 * @ param filename The filename affected by the commit .
 * @ param linesAddedNumber of lines added in the above file in that particular commit .
 * @ param linesDeletedNumber of lines deleted in the above file in that particular commit . */
public void addFile ( String filename , int linesAdded , int linesDeleted ) { } }

implementation: CommitFile commitFile = new CommitFile ( filename , linesAdded , linesDeleted ) ; if ( files == null ) { files = new ArrayList < CommitFile > ( ) ; } this . files . add ( commitFile ) ;


signature:
public class CliGitCheckout { /** * Git checkout with options and base branch information provided to & lt ; git - checkout & gt ; command . */
public GitCheckoutResponse checkout ( File repositoryPath , GitCheckoutOptions options , Ref ref ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; checkRefAgainstRefType ( ref , RefType . HEAD ) ; List < String > command = buildCommand ( options , ref ) ; GitCheckoutParser parser = new GitCheckoutParser ( ) ; GitCheckoutResponse response = ( GitCheckoutResponse ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ; return response ;


signature:
public class CliGitCheckout { /** * Git checkout without any options and branch information provided . Just a basic checkout
 * command . */
public GitCheckoutResponse checkout ( File repositoryPath ) throws JavaGitException , IOException { } }

implementation: GitCheckoutOptions options = null ; return checkout ( repositoryPath , options , null ) ;


signature:
public class CliGitCheckout { /** * Checks out a branch from the git repository with a given branch name . */
public GitCheckoutResponse checkout ( File repositoryPath , Ref branch ) throws JavaGitException , IOException { } }

implementation: return checkout ( repositoryPath , null , branch ) ;


signature:
public class CliGitCheckout { /** * Checks out a list of files from repository , no checkout options provided . */
public GitCheckoutResponse checkout ( File repositoryPath , List < File > paths ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; CheckUtilities . checkNullListArgument ( paths , "list of file paths" ) ; GitCheckoutParser parser = new GitCheckoutParser ( ) ; List < String > command = buildCommand ( null , null , paths ) ; GitCheckoutResponse response = ( GitCheckoutResponse ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ; return response ;


signature:
public class CliGitCheckout { /** * Checks out a list of file from repository , with & lt ; tree - ish & gt ; options provided . */
public GitCheckoutResponse checkout ( File repositoryPath , GitCheckoutOptions options , Ref ref , List < File > paths ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; if ( ref != null && ref . getRefType ( ) == RefType . HEAD ) { throw new IllegalArgumentException ( "Invalid ref type passed as argument to checkout" ) ; } GitCheckoutParser parser = new GitCheckoutParser ( ) ; List < String > command = buildCommand ( options , ref , paths ) ; return ( GitCheckoutResponse ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ;


signature:
public class CliGitCheckout { /** * Checks out a file from repository from a particular branch */
public GitCheckoutResponse checkout ( File repositoryPath , GitCheckoutOptions options , Ref branch , File path ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; GitCheckoutParser parser = new GitCheckoutParser ( ) ; List < File > paths = new ArrayList < File > ( ) ; paths . add ( path ) ; List < String > command = buildCommand ( options , branch , paths ) ; GitCheckoutResponse response = ( GitCheckoutResponse ) ProcessUtilities . runCommand ( repositoryPath , command , parser ) ; return response ;


signature:
public class CliGitCheckout { /** * This is just a test method for verifying that a given ref is not of refType provided as one of the parameters .
 * @ param ref This could be branch , sha1 etc .
 * @ param refType This is the < code > RefType < / code > which the ref should not match . */
private void checkRefAgainstRefType ( Ref ref , RefType refType ) { } }

implementation: if ( ref != null && ref . getRefType ( ) == refType ) { throw new IllegalArgumentException ( "Invalid ref type passed as argument to checkout" ) ; }


signature:
public class CliGitCheckout { /** * builds a & lt ; git - checkout & gt ; command in sth < code > List < String > < / code > format .
 * @ param options < code > GitCheckoutOptions < / code > options passed to the & lt ; git - checkout & gt ; command .
 * @ param treeIsh either a branch type or sha1 type object
 * @ param paths List of files that are to be checked out
 * @ return Command to be executed as a list of String
 * @ throws JavaGitException */
private List < String > buildCommand ( GitCheckoutOptions options , Ref treeIsh , List < File > paths ) throws JavaGitException { } }

implementation:
List < String > command = new ArrayList < String > ( ) ; command . add ( JavaGitConfiguration . getGitCommand ( ) ) ; command . add ( "checkout" ) ; // Process options
if ( options != null ) { processOptions ( command , options ) ; } // Process tree - ish
if ( treeIsh != null ) { command . add ( treeIsh . getName ( ) ) ; } // return if no file - paths are provided
if ( paths == null ) { return command ; } command . add ( "--" ) ; for ( File file : paths ) { command . add ( file . getName ( ) ) ; } return command ;


signature:
public class GitDirectory { /** * Gets the children of this directory .
 * @ return The children of this directory . */
public List < GitFileSystemObject > getChildren ( ) throws IOException , JavaGitException { } }

implementation:
List < GitFileSystemObject > children = new ArrayList < GitFileSystemObject > ( ) ; // get all of the file system objects currently located under this directory
for ( File memberFile : file . listFiles ( ) ) { // check if this file is hidden also some times the . git and
// other unix hidden directories are not hidden in Windows
if ( memberFile . isHidden ( ) || memberFile . getName ( ) . startsWith ( "." ) ) { // ignore ( could be . git directory )
continue ; } // now , just check for the type of the filesystem object
if ( memberFile . isDirectory ( ) ) { children . add ( new GitDirectory ( memberFile , workingTree ) ) ; } else { children . add ( new GitFile ( memberFile , workingTree ) ) ; } } return children ;


signature:
public class GitRmResponse { /** * Gets the file at the specified index from the removed file list .
 * @ 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 getRemovedFile ( int index ) { } }

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


signature:
public class GitCheckout { /** * For checking a file or list of files from a branch .
 * @ param repositoryPath
 * path to the Git repository .
 * @ param paths
 * List of file paths that are to be checked out .
 * @ return GitCheckoutResponse object
 * @ throws JavaGitException thrown if -
 * < li > if the output for & lt ; git - checkout & gt ; command generated an error . < / li >
 * < li > if processBuilder not able to run the command . < / li >
 * < / ul >
 * @ throws IOException
 * thrown if -
 * < ul >
 * < li > paths given do not have proper permissions . < / li >
 * < li > paths given do not exist at all . < / li >
 * < / ul > */
public GitCheckoutResponse checkout ( File repositoryPath , List < File > paths ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; CheckUtilities . checkNullListArgument ( paths , "List of Paths" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitCheckout gitCheckout = client . getGitCheckoutInstance ( ) ; return gitCheckout . checkout ( repositoryPath , paths ) ;


signature:
public class GitCheckout { /** * Checks out files from the repository when a tree - ish object is given as the reference .
 * @ param repositoryPath
 * Path to the Git repository .
 * @ param ref
 * A branch , or sha1 object .
 * @ param paths
 * < code > List < / code > of file paths that are to be checked out .
 * @ return < code > GitCheckoutResponse < / code > object
 * @ throws JavaGitException
 * Thrown if -
 * < li > the output for & lt ; git - checkout & gt ; command generated an error . < / li >
 * < li > processBuilder not able to run the command . < / li >
 * < / ul >
 * @ throws IOException
 * Thrown if -
 * < ul >
 * < li > paths given do not have proper permissions . < / li >
 * < li > paths given do not exist at all . < / li >
 * < / ul > */
public GitCheckoutResponse checkout ( File repositoryPath , Ref ref , List < File > paths ) throws JavaGitException , IOException { } }

implementation: CheckUtilities . checkFileValidity ( repositoryPath ) ; if ( ref != null && ( ref . getRefType ( ) != RefType . BRANCH && ref . getRefType ( ) != RefType . SHA1 ) ) { throw new JavaGitException ( 100000 , ExceptionMessageMap . getMessage ( "100000" ) + " RefType passed: " + ref . getRefType ( ) ) ; } CheckUtilities . checkNullListArgument ( paths , "List of files" ) ; IClient client = ClientManager . getInstance ( ) . getPreferredClient ( ) ; IGitCheckout gitCheckout = client . getGitCheckoutInstance ( ) ; return gitCheckout . checkout ( repositoryPath , ref , paths ) ;


signature:
public class GitAddResponseImpl { /** * Sets the non - error message generated in the output of the & lt ; git - add & gt ; command .
 * @ param lineNumber
 * line number at which the message appeared in output .
 * @ param commentString
 * message itself . */
public void setComment ( int lineNumber , String commentString ) { } }

implementation: ResponseString comment = new ResponseString ( lineNumber , commentString ) ; comments . add ( comment ) ;


signature:
public class CliGitBranch { /** * Process the git - branch command , to show / delete / create / rename branches .
 * @ param repoPath
 * A < code > File < / code > instance for the path to the repository . If null is passed , a
 * < code > NullPointerException < / code > will be thrown .
 * @ param options
 * The options to include on the command line .
 * @ param arg1
 * When renaming a branch to a different name , this is the old branch . When creating a
 * branch this the branch name .
 * @ param arg2
 * When renaming a branch to a new branch name , this is the new branch name . When
 * creating a branch , this is the head to start from .
 * @ param branchList
 * List of branches need to be deleted .
 * @ 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 GitBranchResponseImpl branchProcess ( File repoPath , GitBranchOptions options , Ref arg1 , Ref arg2 , List < Ref > branchList ) throws IOException , JavaGitException { } }

implementation: CheckUtilities . checkNullArgument ( repoPath , "repository path" ) ; List < String > commandLine = buildCommand ( options , arg1 , arg2 , branchList ) ; GitBranchParser parser = new GitBranchParser ( ) ; return ( GitBranchResponseImpl ) ProcessUtilities . runCommand ( repoPath , commandLine , parser ) ;


signature:
public class CliGitBranch { /** * Builds a list of command arguments to pass to < code > ProcessBuilder < / code > .
 * @ param options
 * The options to include on the command line .
 * @ param arg1
 * When renaming a branch to a different name , this is the old branch . When creating a
 * branch this the branch name .
 * @ param arg2
 * When renaming a branch to a new branch name , this is the new branch name . When
 * creating a branch , this is the head to start from .
 * @ param branchList
 * List of branches need to be deleted .
 * @ return A list of the individual arguments to pass to < code > ProcessBuilder < / code > . */
protected List < String > buildCommand ( GitBranchOptions options , Ref arg1 , Ref arg2 , List < Ref > branchList ) { } }

implementation: List < String > cmd = new ArrayList < String > ( ) ; cmd . add ( JavaGitConfiguration . getGitCommand ( ) ) ; cmd . add ( "branch" ) ; if ( null != options ) { Ref commit = options . getOptContains ( ) ; if ( null != commit ) { cmd . add ( "--contains" ) ; cmd . add ( commit . getName ( ) ) ; } if ( options . isOptVerbose ( ) ) { cmd . add ( "--verbose" ) ; } if ( options . isOptAbbrev ( ) ) { if ( options . getOptAbbrevLen ( ) != GitBranchOptions . DEFAULT_ABBREV_LEN ) { cmd . add ( "--abbrev=" + Integer . toString ( options . getOptAbbrevLen ( ) ) ) ; } else { cmd . add ( "--abbrev" ) ; } } if ( options . isOptNoAbbrev ( ) ) { cmd . add ( "--no-abbrev" ) ; } if ( options . isOptA ( ) ) { cmd . add ( "-a" ) ; } if ( options . isOptDLower ( ) ) { cmd . add ( "-d" ) ; } if ( options . isOptMLower ( ) ) { cmd . add ( "-m" ) ; } if ( options . isOptDUpper ( ) ) { cmd . add ( "-D" ) ; } if ( options . isOptMUpper ( ) ) { cmd . add ( "-M" ) ; } if ( options . isOptColor ( ) ) { cmd . add ( "--color" ) ; } if ( options . isOptNoColor ( ) ) { cmd . add ( "--no-color" ) ; } if ( options . isOptF ( ) ) { cmd . add ( "-f" ) ; } if ( options . isOptL ( ) ) { cmd . add ( "-l" ) ; } if ( options . isOptMerged ( ) ) { cmd . add ( "--merged" ) ; } if ( options . isOptNoMerged ( ) ) { cmd . add ( "--no-merged" ) ; } if ( options . isOptR ( ) ) { cmd . add ( "-r" ) ; } if ( options . isOptTrack ( ) ) { cmd . add ( "--track" ) ; } if ( options . isOptNoTrack ( ) ) { cmd . add ( "--no-track" ) ; } } if ( null != branchList ) { if ( ( null != arg1 ) || ( null != arg2 ) ) { throw new IllegalArgumentException ( ) ; } for ( Ref branch : branchList ) { cmd . add ( branch . getName ( ) ) ; } } else { if ( null != arg1 ) { cmd . add ( arg1 . getName ( ) ) ; } if ( null != arg2 ) { cmd . add ( arg2 . getName ( ) ) ; } } return cmd ;


signature:
public class CliGitBranch { /** * Sets the options for delete .
 * @ param options
 * The < code > GitBranchOptions < / code > object .
 * @ param forceDelete
 * The forceDelete boolean flag . True if branch to be force deleted , false otherwise .
 * @ param remote
 * The remote boolean flag . True if a remote branch is being deleted , false otherwise . */
public void setDeleteOptions ( GitBranchOptions options , boolean forceDelete , boolean remote ) { } }

implementation: if ( forceDelete ) { options . setOptDUpper ( true ) ; } else { options . setOptDLower ( true ) ; } if ( remote ) { options . setOptR ( true ) ; }


signature:
public class ServiceInjector { /** * Inject a service into the service manager registry .
 * @ param klass
 * Class to inject
 * @ throws DataException
 * @ throws IllegalAccessException
 * @ throws InstantiationException */
@ Override public void inject ( Class < ? > klass ) throws DataException { } }

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


signature:
public class ServiceInjector { /** * Injects a single UCMService annotation into the ServiceManager registry .
 * @ param className
 * Fully qualified class name
 * @ param annotation
 * A reference to a UCMService annotation
 * @ throws DataException */
private static void injectServiceMethod ( Method method , ServiceMethod annotation ) throws DataException { } }

implementation:
ServiceData serviceData = new ServiceData ( ) ; String template = annotation . template ( ) ; int accessLevel = annotation . accessLevel ( ) ; String serviceType = ( ! annotation . type ( ) . equals ( "" ) ) ? annotation . type ( ) : null ; String errorMessage = annotation . errorMessage ( ) ; String subjects = annotation . subjects ( ) ; String serviceName = annotation . name ( ) ; try { serviceData . init ( serviceName , ServiceProxy . class . getName ( ) , accessLevel , template , serviceType , errorMessage , subjects ) ; } catch ( Exception e ) { throw new DataException ( "Cannot create ServiceData object for " + serviceName + " - " + e . getMessage ( ) ) ; } // action parameters , none by default
String controlFlags = "" ; String methodHashCode = MethodRegistry . addMethod ( method ) ; if ( methodHashCode == null ) { throw new DataException ( "Cannot register method " + method . toString ( ) + " because it has a null hashCode" ) ; } try { serviceData . addAction ( Action . CODE_TYPE , "delegateWithParameters" , methodHashCode , controlFlags , "" ) ; } catch ( DataException e ) { throw new DataException ( "Cannot add defaut action to service" + serviceName + " - " + e . getMessage ( ) ) ; } // inject service
ServiceManager . putService ( serviceName , serviceData ) ;


signature:
public class Ref { /** * Creates a < code > Ref < / code > of type < code > BRANCH < / code > .
 * @ param name
 * The branch name of this ref . If the value is null , a < code > NullPointerException < / code >
 * is thrown . If the value has length zero , an < code > IllegalArgumentException < / code > is
 * thrown .
 * @ return A < code > Ref < / code > instance of type < code > BRANCH < / code > . */
public static Ref createBranchRef ( String name ) { } }

implementation: CheckUtilities . checkStringArgument ( name , "name" ) ; Ref cn = new Ref ( ) ; cn . refType = RefType . BRANCH ; cn . name = name ; return cn ;


signature:
public class Ref { /** * Creates a < code > Ref < / code > of type < code > HEAD < / code > .
 * @ param headOffset
 * The offset of the commit back from the HEAD commit on the current working branch . If
 * the value is less than zero , an < code > IllegalArgumentException < / code > is thrown .
 * @ return A < code > Ref < / code > instance of type < code > HEAD < / code > . */
public static Ref createHeadRef ( int headOffset ) { } }

implementation: CheckUtilities . checkIntArgumentGreaterThan ( headOffset , - 1 , "headOffset" ) ; if ( 0 == headOffset ) { return HEAD ; } else if ( 1 == headOffset ) { return HEAD_1 ; } Ref cn = new Ref ( ) ; cn . refType = RefType . HEAD ; cn . headOffset = headOffset ; return cn ;


signature:
public class Ref { /** * Creates a < code > Ref < / code > of type < code > REMOTE < / code > .
 * @ param repositoryName
 * The remote repository name of this ref . If the value is blank or null , the value will
 * be maintained as null .
 * @ param name
 * The remote branch name of this ref . If the value is null , a
 * < code > NullPointerException < / code > is thrown . If the value has length zero , an
 * < code > IllegalArgumentException < / code > is thrown .
 * @ return A < code > Ref < / code > instance of type < code > REMOTE < / code > . */
public static Ref createRemoteRef ( String repositoryName , String name ) { } }

implementation: CheckUtilities . checkStringArgument ( name , "name" ) ; Ref cn = new Ref ( ) ; cn . refType = RefType . REMOTE ; cn . name = name ; if ( null != repositoryName && repositoryName . length ( ) > 0 ) { cn . repositoryName = repositoryName ; } return cn ;


signature:
public class Ref { /** * Creates a < code > Ref < / code > of type < code > SHA1 < / code > .
 * @ param name
 * The SHA1 name of this ref . The value can be a short name or the full SHA1 value . If
 * the value is null , a < code > NullPointerException < / code > is thrown . If the value has
 * length zero , an < code > IllegalArgumentException < / code > is thrown .
 * @ return A < code > Ref < / code > instance of type < code > SHA1 < / code > . */
public static Ref createSha1Ref ( String name ) { } }

implementation: CheckUtilities . checkStringArgument ( name , "name" ) ; Ref cn = new Ref ( ) ; cn . refType = RefType . SHA1 ; cn . name = name ; return cn ;


signature:
public class Ref { /** * Creates a < code > Ref < / code > of type < code > TAG < / code > .
 * @ param name
 * The tag name of this ref . If the value is null , a < code > NullPointerException < / code >
 * is thrown . If the value has length zero , an < code > IllegalArgumentException < / code > is
 * thrown .
 * @ return A < code > Ref < / code > instance of type < code > TAG < / code > . */
public static Ref createTagRef ( String name ) { } }

implementation: CheckUtilities . checkStringArgument ( name , "name" ) ; Ref cn = new Ref ( ) ; cn . refType = RefType . TAG ; cn . name = name ; return cn ;


signature:
public class GitCheckoutOptions { /** * Sets the name of the new branch that need to be created from the base branch .
 * @ param newBranch
 * New branch of type < code > Ref < / code > that will be created by & lt ; git - checkout & gt ; . */
public void setOptB ( Ref newBranch ) { } }

implementation: CheckUtilities . validateArgumentRefType ( newBranch , RefType . BRANCH , "New Branch Name" ) ; optB = newBranch ;


signature:
public class CliGitClone { /** * Process the git - clone command , to make a clone of the git repository .
 * @ param workingDirectoryPath
 * A < code > File < / code > instance for the path to the working directory . 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 for the git - clone command . If the value is null , a
 * < code > NullPointerException < / code > will be thrown .
 * @ param repository
 * A < code > URL < / code > instance for the repository to be cloned . If null is passed , a
 * < code > NullPointerException < / code > will be thrown .
 * @ param directory
 * A < code > File < / code > instance for the directory where the repository is to be cloned .
 * If null is passed , a < code > NullPointerException < / code > will be thrown .
 * @ return The result of the git clone .
 * @ 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 - clone . */
public GitCloneResponseImpl cloneProcess ( File workingDirectoryPath , GitCloneOptions options , URL repository , File directory ) throws IOException , JavaGitException { } }

implementation: List < String > commandLine = buildCommand ( options , repository , directory ) ; GitCloneParser parser = new GitCloneParser ( ) ; return ( GitCloneResponseImpl ) ProcessUtilities . runCommand ( workingDirectoryPath , commandLine , parser ) ;


signature:
public class CliGitClone { /** * Builds a list of command arguments to pass to < code > ProcessBuilder < / code > .
 * @ param options
 * The options for the git - clone command . If the value is null , a
 * < code > NullPointerException < / code > will be thrown .
 * @ param repository
 * A < code > URL < / code > instance for the repository to be cloned . If null is passed , a
 * < code > NullPointerException < / code > will be thrown .
 * @ param directory
 * A < code > File < / code > instance for the directory where the repository is to be cloned .
 * If null is passed , a < code > NullPointerException < / code > will be thrown .
 * @ return The result of the git clone . */
protected List < String > buildCommand ( GitCloneOptions options , URL repository , File directory ) { } }

implementation: List < String > cmd = new ArrayList < String > ( ) ; cmd . add ( JavaGitConfiguration . getGitCommand ( ) ) ; cmd . add ( "clone" ) ; return cmd ;


signature:
public class Bootstrapper { /** * Begins injection of filters , including the Service and IdocScript injectors
 * required to load other ucm entities . */
public int doFilter ( Workspace ws , DataBinder binder , ExecutionContext ctx ) throws DataException , ServiceException { } }

implementation:
String configFileName = ( String ) ctx . getCachedObject ( "filterParameter" ) ; try { ClassLoader cl = getClass ( ) . getClassLoader ( ) ; Enumeration < URL > propFiles = cl . getResources ( configFileName ) ; // There should be at least one entry ( TwineLib contains an example file )
if ( ! propFiles . hasMoreElements ( ) ) { propFiles = getResources11g ( cl , configFileName ) ; } while ( propFiles . hasMoreElements ( ) ) { URL propFile = propFiles . nextElement ( ) ; if ( SystemUtils . m_verbose ) { SystemUtils . trace ( "twine" , "Loading config file: " + propFile . toString ( ) ) ; } IClassInjector filterInjector = new FilterInjector ( ) ; filterInjector . injectClasses ( propFile ) ; IClassInjector serviceInjector = new ServiceInjector ( ) ; serviceInjector . injectClasses ( propFile ) ; IClassInjector scriptInjector = new IdocScriptInjector ( ) ; scriptInjector . injectClasses ( propFile ) ; } } catch ( IOException e ) { // TODO Auto - generated catch block
e . printStackTrace ( ) ; } return CONTINUE ;


signature:
public class Bootstrapper { /** * Replacement for getResources which works on 11g .
 * The UCM 11G { @ link ClassLoader } does not load component jars in the
 * standard manner , which means you cannot use
 * { @ link ClassLoader # getResources ( String ) } to find all instances of a
 * specific file in the jar path , instead we inspect the m _ zipfiles map , where
 * we can query each zip file for the properties file .
 * Instead , we use reflection to find all the loaded component jar files and
 * search manually
 * @ param classLoader
 * @ param configFileName
 * @ throws MalformedURLException */
private Enumeration < URL > getResources11g ( ClassLoader classLoader , String configFileName ) { } }

implementation:
List < URL > newProps = new ArrayList < URL > ( ) ; if ( classLoader . getClass ( ) . getSimpleName ( ) . equalsIgnoreCase ( "IdcClassLoader" ) ) { try { Field field = classLoader . getClass ( ) . getField ( "m_zipfiles" ) ; @ SuppressWarnings ( "unchecked" ) Map < String , IdcZipFile > zipFiles = ( Map < String , IdcZipFile > ) field . get ( classLoader ) ; for ( Entry < String , IdcZipFile > entry : zipFiles . entrySet ( ) ) { if ( entry . getValue ( ) . m_entries . get ( configFileName ) != null ) { String jarFile = entry . getKey ( ) ; // windows needs a slash before the C : /
if ( ! jarFile . startsWith ( "/" ) ) { jarFile = "/" + jarFile ; } try { URL u = new URL ( "jar:file:" + entry . getKey ( ) + "!/" + configFileName ) ; newProps . add ( u ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } } } } catch ( Exception e ) { // If there is any exception the ClassLoader is an unrecognised format
e . printStackTrace ( ) ; } } return Collections . enumeration ( newProps ) ;


signature:
public class CliGitInit { /** * Build the command to be executed using the Git Init method */
private List < String > buildCommand ( File repoDirectory , GitInitOptions options ) { } }

implementation: List < String > command = new ArrayList < String > ( ) ; command . add ( JavaGitConfiguration . getGitCommand ( ) ) ; command . add ( "init" ) ; if ( options != null ) { if ( options . isOptBare ( ) ) { command . add ( "--bare" ) ; } if ( options . isOptTemplate ( ) ) { command . add ( "--template=" + options . getOptTemplateDirecory ( ) ) ; } if ( options . isOptSharedUmask ( ) ) { command . add ( "--shared=" ) ; } if ( options . isOptSharedGroup ( ) ) { command . add ( "--shared=" + options . getOptSharedGroupName ( ) ) ; } if ( options . isOptSharedAll ( ) ) { command . add ( "--shared=" ) ; } if ( options . isOptSharedOctal ( ) ) { command . add ( "--shared=" + options . getOptSharedOctalValue ( ) ) ; } } return command ;


signature:
public class GitResetOptions { /** * Central instance construction setup method .
 * @ param resetType
 * The type of reset to perform .
 * @ param commitName
 * The name of the commit to reset to . */
private void setup ( ResetType resetType , Ref commitName ) { } }

implementation: CheckUtilities . checkNullArgument ( resetType , "resetType" ) ; CheckUtilities . checkNullArgument ( commitName , "commitName" ) ; this . resetType = resetType ; this . commitName = commitName ;


signature:
public class MethodRegistry { /** * Adds a method to the registry and returns the UUID .
 * @ return */
public static String addMethod ( Method m ) { } }

implementation: if ( methods == null ) { methods = new HashMap < String , Method > ( ) ; } String hashCode = String . valueOf ( m . hashCode ( ) ) ; if ( ! methods . containsKey ( hashCode ) ) { methods . put ( hashCode , m ) ; } return String . valueOf ( m . hashCode ( ) ) ;


signature:
public class BaseInjector { /** * { @ inheritDoc } */
public List < Class < ? > > enumerateClasses ( URL propertiesFile , String prefix ) { } }

implementation:
// find mapped service classes in service . properties
Properties properties = new Properties ( ) ; InputStream is = null ; try { is = propertiesFile . openStream ( ) ; if ( is != null ) { properties . load ( is ) ; } } catch ( IOException e ) { Log . warn ( e . getMessage ( ) ) ; } finally { if ( is != null ) { try { is . close ( ) ; } catch ( IOException ignore ) { } } } List < Class < ? > > classes = new ArrayList < Class < ? > > ( ) ; if ( properties . size ( ) > 0 ) { for ( Object key : properties . keySet ( ) ) { if ( key . toString ( ) . startsWith ( prefix ) ) { try { // does the class resolve ?
Class < ? > klass = Class . forName ( properties . get ( key ) . toString ( ) ) ; // if so , add it
classes . add ( klass ) ; } catch ( ClassNotFoundException e ) { Log . warn ( "Unable to find class [" + properties . get ( key ) . toString ( ) + "]" ) ; } } } } return classes ;


signature:
public class BaseInjector { /** * { @ inheritDoc } */
public void injectClasses ( List < Class < ? > > classes ) { } }

implementation: for ( Class < ? > klass : classes ) { try { inject ( klass ) ; } catch ( Exception e ) { String msg = "Failed to inject: " + klass . getName ( ) . toString ( ) + " - " + e . getMessage ( ) ; Log . warn ( msg ) ; SystemUtils . trace ( "twine" , msg ) ; } }


signature:
public class BaseInjector { /** * { @ inheritDoc } */
public void injectClasses ( URL propertiesFile , String prefix ) { } }

implementation: List < Class < ? > > classes = enumerateClasses ( propertiesFile , prefix ) ; injectClasses ( classes ) ;


signature:
public class FilterProxy { /** * Main entry point which will delegate to the filter method with dependency
 * injection . */
public int doFilter ( Workspace ws , DataBinder binder , ExecutionContext ctx ) throws DataException , ServiceException { } }

implementation: Object returnVal = null ; try { String methodID = ( String ) ctx . getCachedObject ( "filterParameter" ) ; Method m = MethodRegistry . getMethod ( methodID ) ; ParameterMarshaller marshaller = new ParameterMarshaller ( m ) ; Object [ ] params = marshaller . getValueArray ( ws , binder , ctx ) ; Object context = m . getDeclaringClass ( ) . newInstance ( ) ; returnVal = m . invoke ( context , params ) ; } catch ( IllegalArgumentException e ) { throw new DataException ( e . getMessage ( ) , e ) ; } catch ( Exception e ) { throw new ServiceException ( e . getMessage ( ) , e ) ; } if ( returnVal != null && returnVal instanceof Integer ) { return ( ( Integer ) returnVal ) . intValue ( ) ; } return CONTINUE ;


signature:
public class DbCreator { /** * Gives you a database connection you can access the database with . < br >
 * Don ' t forget to call reduceDatabaseConnection when you are done with the connection .
 * @ return Connection to the local SQLite database */
public SQLiteDatabase getDatabaseConnection ( ) { } }

implementation: synchronized ( LOCK ) { if ( dbConnection == null ) { OPEN_CONNECTIONS . set ( 0 ) ; dbConnection = super . getWritableDatabase ( ) ; } OPEN_CONNECTIONS . incrementAndGet ( ) ; return dbConnection ; }


signature:
public class DbCreator { /** * Reduce the connection opened . This should always be called after calling getDatabaseConnection and only after that . */
public void reduceDatabaseConnection ( ) { } }

implementation: synchronized ( LOCK ) { int numberOfOpenConnections = OPEN_CONNECTIONS . decrementAndGet ( ) ; if ( numberOfOpenConnections == 0 && dbConnection != null ) { dbConnection . close ( ) ; dbConnection = null ; } }


signature:
public class DbCreator { /** * Execute a function on the database , to return some values . The opening and closing of the database connection is handled for you . < br >
 * Note if you want to query a cursor from the database consider using the { @ code DbCreator # query } or { @ code DbCreator # rawQuery } method . < br >
 * This can be useful when working with { @ code CursorAdapter }
 * @ param < T > Resulting type
 * @ param dbFunction Function you want to execute on the database
 * @ return The result of the function call */
public < T > T functionOnDatabase ( DbFunction < T > dbFunction ) { } }

implementation: SQLiteDatabase db = getDatabaseConnection ( ) ; try { return dbFunction . apply ( db ) ; } finally { reduceDatabaseConnection ( ) ; }


signature:
public class DbCreator { /** * Execute an action on the database . The opening and closing of the database connection is handled for you .
 * @ param dbConsumer Action you want to execute on the database */
public void consumeDatabase ( DbConsumer dbConsumer ) { } }

implementation: SQLiteDatabase db = getDatabaseConnection ( ) ; try { dbConsumer . consume ( db ) ; } finally { reduceDatabaseConnection ( ) ; }


signature:
public class DbCreator { /** * Executes a query on the database . Note that when calling close on the returned cursor the database connection count is reduces as well .
 * @ param table Name of the table
 * @ param columns Used columns of the queried table
 * @ param selection Selection statement
 * @ param selectionArgs Selection arguments
 * @ param groupBy SQL group by
 * @ param having SQL having
 * @ param orderBy SQL order by
 * @ return A Cursor containing the result , which reduces the database connection count when closed */
public Cursor query ( String table , String [ ] columns , String selection , String [ ] selectionArgs , String groupBy , String having , String orderBy ) { } }

implementation: SQLiteDatabase db = getDatabaseConnection ( ) ; return new DbClosingCursor ( db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy ) , this ) ;


signature:
public class DbCreator { /** * Executes a raw query on the database . Note that when calling close on the returned cursor the database connection count is reduces as well .
 * @ param sql Raw SQL statement
 * @ return A Cursor containing the result , which reduces the database connection count when closed */
public Cursor rawQuery ( String sql ) { } }

implementation: SQLiteDatabase db = getDatabaseConnection ( ) ; return new DbClosingCursor ( db . rawQuery ( sql , null ) , this ) ;


signature:
public class CliGitRm { /** * TODO ( jhl388 ) : Add test cases for this class . */
public GitRmResponse rm ( File repository , File path ) throws IOException , JavaGitException { } }

implementation: return processRm ( repository , null , path , null ) ;


signature:
public class CliGitRm { /** * Processes an incoming < code > GitRm < / code > request .
 * @ param repository
 * The path to the repository .
 * @ param options
 * The options to use in constructing the command line .
 * @ param path
 * A single file / directory to delete . This should be null if there is a list of paths to
 * delete .
 * @ param paths
 * A list of files / paths to delete . This should be null if there is a single path to
 * delete .
 * @ return The response from running the command .
 * @ 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 . */
private GitRmResponse processRm ( File repository , GitRmOptions options , File path , List < File > paths ) throws IOException , JavaGitException { } }

implementation: List < String > cmdline = buildCommandLine ( options , path , paths ) ; GitRmParser parser = new GitRmParser ( ) ; return ( GitRmResponse ) ProcessUtilities . runCommand ( repository , cmdline , parser ) ;


signature:
public class CliGitRm { /** * Builds the command line .
 * @ param options
 * The options to build with .
 * @ param path
 * If just a single path , this is it .
 * @ param paths
 * If there are multiple paths , these are they . < code > path < / code > must be null for
 * these paths to be used .
 * @ return The list of arguments for the command line . */
private List < String > buildCommandLine ( GitRmOptions options , File path , List < File > paths ) { } }

implementation: List < String > cmdline = new ArrayList < String > ( ) ; cmdline . add ( JavaGitConfiguration . getGitCommand ( ) ) ; cmdline . add ( "rm" ) ; if ( null != options ) { if ( options . isOptCached ( ) ) { cmdline . add ( "--cached" ) ; } if ( options . isOptF ( ) ) { cmdline . add ( "-f" ) ; } if ( options . isOptN ( ) ) { cmdline . add ( "-n" ) ; } if ( options . isOptQ ( ) ) { cmdline . add ( "-q" ) ; } if ( options . isOptR ( ) ) { cmdline . add ( "-r" ) ; } } if ( null != path ) { cmdline . add ( path . getPath ( ) ) ; } else { for ( File f : paths ) { cmdline . add ( f . getPath ( ) ) ; } } return cmdline ;


signature:
public class GitCheckoutResponse { /** * Returns the file at a given location in the addedFiles list
 * @ param index
 * in the list and should be positive and less than no . of files added .
 * @ return added file at the index in addedFiles list . */
public File getAddedFile ( int index ) { } }

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


signature:
public class GitCheckoutResponse { /** * Returns the file at a given location in the deletedFiles list
 * @ param index
 * in the list and should be positive and less than no . of files deleted .
 * @ return deleted file at the index in deleteFiles list . */
public File getDeletedFile ( int index ) { } }

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


signature:
public class GitCheckoutResponse { /** * Returns the file at a given location in the modifiedFiles list .
 * @ param index
 * in the list and it should be positive and less than total no . of files modified .
 * @ return modified file at the index in modifiedFiles list . */
public File getModifiedFile ( int index ) { } }

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


signature:
public class GitFile { /** * Show object ' s status in the working directory
 * @ return Object ' s status in the working directory ( untracked , changed but not updated , etc ) . */
public Status getStatus ( ) throws IOException , JavaGitException { } }

implementation:
GitStatus gitStatus = new GitStatus ( ) ; // run git - status command
return gitStatus . getFileStatus ( workingTree . getPath ( ) , relativePath ) ;


signature:
public class GitFile { /** * 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 ( ) ; GitLogOptions options = new GitLogOptions ( ) ; options . setOptRelative ( true , this . relativePath . toString ( ) ) ; return gitLog . log ( this . file ) ;


signature:
public class AbstractInjector { /** * Gets the document header .
 * @ return the document header */
protected static HeadElement getHead ( ) { } }

implementation: if ( head == null ) { final Element element = Document . get ( ) . getElementsByTagName ( "head" ) . getItem ( 0 ) ; assert element != null : "HTML Head element required" ; final HeadElement head = HeadElement . as ( element ) ; AbstractInjector . head = head ; } return AbstractInjector . head ;


signature:
public class JavaScriptInjector { /** * Injects the JavaScript code into a
 * { @ code < script type = " text / javascript " > . . . < / script > } element in the
 * document header .
 * @ param javascript the JavaScript code */
public static void inject ( String javascript ) { } }

implementation: HeadElement head = getHead ( ) ; ScriptElement element = createScriptElement ( ) ; element . setText ( javascript ) ; head . appendChild ( element ) ;


signature:
public class Dropzone { /** * Add file information manually to Dropzone . Added file is not uploaded , it is just shown in the dropzone .
 * This feature is useful for displaying e . g . files that already exists on the server .
 * @ param fileName name of file to add
 * @ param fileSize size of file to add
 * @ param thumbnailUrl thumbnail image for file */
public void addFile ( String fileName , Integer fileSize , String thumbnailUrl ) { } }

implementation: addFileNative ( getElement ( ) , fileName , fileSize , thumbnailUrl ) ;


signature:
public class Dropzone { /** * Return array if all files added to dropzone .
 * @ return all files added to dropzone . */
public ArrayList < File > getFiles ( ) { } }

implementation:
// TODO Why ArrayList , change to list when in a proper IDE
final JsArray < FileJS > filesJS = getFilesNative ( getElement ( ) ) ; final ArrayList < File > files = new ArrayList < File > ( ) ; if ( filesJS != null ) { for ( int i = 0 ; i < filesJS . length ( ) ; i ++ ) { files . add ( filesJS . get ( i ) ) ; } } return files ;


signature:
public class Dropzone { /** * Return number of added files .
 * @ return number of files */
public int getFilesCount ( ) { } }

implementation: final JsArray < FileJS > files = getFilesNative ( getElement ( ) ) ; return files != null ? files . length ( ) : 0 ;


signature:
public class Glob { /** * Match the given string . */
public boolean matches ( String string ) { } }

implementation:
String src = string ; final boolean result ; if ( _compiledPattern . length == 1 ) { // Shortcut for pattern ' * ' , ' ? ' and patterns not containing any wildcard
final GlobPattern pattern = _compiledPattern [ 0 ] ; if ( pattern . getType ( ) == GLOB_MULTIPLE ) { result = true ; } else if ( pattern . getType ( ) == GLOB_SINGLE ) { result = src . length ( ) == 1 ; } else { if ( _caseInSensitive ) { result = src . equalsIgnoreCase ( pattern . getText ( ) ) ; } else { result = src . equals ( pattern . getText ( ) ) ; } } } else if ( _compiledPattern . length == 2 ) { // Shortcuts for common patterns ' * something ' and ' something * '
final GlobPattern pattern1 = _compiledPattern [ 0 ] ; final GlobPattern pattern2 = _compiledPattern [ 1 ] ; if ( _caseInSensitive ) { src = src . toLowerCase ( ) ; } if ( pattern1 . getType ( ) == TEXT ) { result = src . startsWith ( pattern1 . getText ( ) ) && ( pattern2 . getType ( ) == GLOB_MULTIPLE || src . length ( ) == pattern1 . getTextLength ( ) + 1 ) ; } else { result = src . endsWith ( pattern2 . getText ( ) ) && ( pattern1 . getType ( ) == GLOB_MULTIPLE || src . length ( ) == pattern2 . getTextLength ( ) + 1 ) ; } } else { result = matches ( src . toCharArray ( ) ) ; } return result ;


signature:
public class Glob { /** * Compile the pattern into the strings [ ] and wildcard [ ] arrays . */
private void compilePattern ( ) throws ParseException { } }

implementation:
StringBuilder sb = new StringBuilder ( ) ; boolean escaped = false ; final List < GlobPattern > patterns = new ArrayList < > ( ) ; for ( int a = 0 ; a < _patternSource . length ( ) ; a ++ ) { final char c = _patternSource . charAt ( a ) ; // Test escape - char
if ( c == '\\' ) { if ( escaped ) { sb . append ( '\\' ) ; escaped = false ; } else { escaped = true ; } } else { if ( escaped ) { if ( c != GLOB_SINGLE && c != GLOB_MULTIPLE ) { sb . append ( "\\" ) ; } else { // Globbing chars escaped
sb . append ( c ) ; escaped = false ; } } else { // No escape character , test whether it matches on of the globbing characters .
if ( c == GLOB_MULTIPLE || c == GLOB_SINGLE ) { if ( sb . length ( ) > 0 ) { patterns . add ( new GlobPattern ( TEXT , sb . toString ( ) ) ) ; sb = new StringBuilder ( ) ; } patterns . add ( new GlobPattern ( c ) ) ; } else { sb . append ( c ) ; } } } } if ( sb . length ( ) > 0 ) { patterns . add ( new GlobPattern ( TEXT , sb . toString ( ) ) ) ; } // Add meta information and correct the elements
addMetaInformation ( patterns ) ; _compiledPattern = new GlobPattern [ patterns . size ( ) ] ; patterns . toArray ( _compiledPattern ) ;


signature:
public class LruCache { /** * Add the new CacheEntry < b > before < / b > the rest . */
@ Override @ OverridingMethodsMustInvokeSuper protected void updateListAfterPut ( CacheEntry < K , V > newEntry ) { } }

implementation: if ( _last == null ) { _last = newEntry ; _first = newEntry ; } else { _first . setPrevious ( newEntry ) ; newEntry . setNext ( _first ) ; setFirst ( newEntry ) ; }


signature:
public class LruCache { /** * Move the entry to the beginning of the LinkedList . */
@ Override protected void updateListAfterHit ( CacheEntry < K , V > entry ) { } }

implementation: if ( entry != null && ! entry . equals ( _first ) ) { if ( entry . equals ( _last ) ) { setLast ( entry . getPrevious ( ) ) ; } else { final CacheEntry < K , V > previous = entry . getPrevious ( ) ; final CacheEntry < K , V > next = entry . getNext ( ) ; previous . setNext ( next ) ; next . setPrevious ( previous ) ; } _first . setPrevious ( entry ) ; entry . setNext ( _first ) ; setFirst ( entry ) ; }


signature:
public class InMemoryBasedCacheSupport { /** * Remove the last element from the cache . */
protected void removeLast ( ) { } }

implementation: final CacheEntry < K , V > entry ; synchronized ( _lock ) { if ( _last != null ) { entry = _entries . remove ( _last . getKey ( ) ) ; setLast ( _last . getPrevious ( ) ) ; } else { entry = null ; } if ( size ( ) == 0 ) { _first = null ; _last = null ; } } if ( entry != null ) { handleRemove ( entry ) ; }


signature:
public class InMemoryBasedCacheSupport { /** * Remove entries that are out of their maxLifetime . */
@ SuppressWarnings ( "UnnecessaryUnboxing" ) public void cleanUpLifetimeExpired ( ) { } }

implementation:
final long currentTime = currentTimeMillis ( ) ; // Test whether there could be an element that has to be removed
if ( _nearstExpiringTime > 0 && _nearstExpiringTime <= currentTime ) { // Go through all elements and remove elements that are outdated
final List < K > keysToRemove = new ArrayList < > ( ) ; synchronized ( _lock ) { _nearstExpiringTime = 0 ; for ( final CacheEntry < K , V > cacheEntry : _entries . values ( ) ) { final Long expire = cacheEntry . getExpire ( ) ; if ( expire != null ) { final long unboxedExpire = expire . longValue ( ) ; if ( unboxedExpire <= currentTime ) { keysToRemove . add ( cacheEntry . getKey ( ) ) ; } else if ( _nearstExpiringTime == 0 || unboxedExpire < _nearstExpiringTime ) { _nearstExpiringTime = unboxedExpire ; } } } for ( final K key : keysToRemove ) { removeInternal ( key ) ; } } }


signature:
public class DnsServer { /** * Note : a null return value means that the caller doesn ' t need to do
 * anything . Currently this only happens if this is an AXFR request over
 * TCP . */
byte [ ] generateReply ( Message query , byte [ ] in , int length , Socket s ) throws IOException { } }

implementation: final Header header ; final int maxLength ; int flags = 0 ; header = query . getHeader ( ) ; if ( header . getFlag ( Flags . QR ) ) { return null ; } if ( header . getRcode ( ) != Rcode . NOERROR ) { return errorMessage ( query , Rcode . FORMERR ) ; } if ( header . getOpcode ( ) != Opcode . QUERY ) { return errorMessage ( query , Rcode . NOTIMP ) ; } final Record queryRecord = query . getQuestion ( ) ; final TSIGRecord queryTSIG = query . getTSIG ( ) ; TSIG tsig = null ; if ( queryTSIG != null ) { tsig = _tsigs . get ( queryTSIG . getName ( ) ) ; if ( tsig == null || tsig . verify ( query , in , length , null ) != Rcode . NOERROR ) { return formerrMessage ( in ) ; } } final OPTRecord queryOPT = query . getOPT ( ) ; if ( queryOPT != null && queryOPT . getVersion ( ) > 0 ) { } if ( s != null ) { maxLength = 65535 ; } else if ( queryOPT != null ) { maxLength = Math . max ( queryOPT . getPayloadSize ( ) , 512 ) ; } else { maxLength = 512 ; } if ( queryOPT != null && ( queryOPT . getFlags ( ) & ExtendedFlags . DO ) != 0 ) { flags = FLAG_DNSSECOK ; } final Message response = new Message ( query . getHeader ( ) . getID ( ) ) ; response . getHeader ( ) . setFlag ( Flags . QR ) ; if ( query . getHeader ( ) . getFlag ( Flags . RD ) ) { response . getHeader ( ) . setFlag ( Flags . RD ) ; } response . addRecord ( queryRecord , Section . QUESTION ) ; final Name name = queryRecord . getName ( ) ; final int type = queryRecord . getType ( ) ; final int dclass = queryRecord . getDClass ( ) ; if ( type == Type . AXFR && s != null ) { return doAXFR ( name , query , tsig , queryTSIG , s ) ; } if ( ! Type . isRR ( type ) && type != Type . ANY ) { return errorMessage ( query , Rcode . NOTIMP ) ; } final byte rcode = addAnswer ( response , name , type , dclass , 0 , flags ) ; if ( rcode != Rcode . NOERROR && rcode != Rcode . NXDOMAIN ) { return errorMessage ( query , rcode ) ; } addAdditional ( response , flags ) ; if ( queryOPT != null ) { final int optflags = ( flags == FLAG_DNSSECOK ) ? ExtendedFlags . DO : 0 ; final OPTRecord opt = new OPTRecord ( ( short ) 4096 , rcode , ( byte ) 0 , optflags ) ; response . addRecord ( opt , Section . ADDITIONAL ) ; } response . setTSIG ( tsig , Rcode . NOERROR , queryTSIG ) ; return response . toWire ( maxLength ) ;


signature:
public class LfuCache { /** * Adds the new cache entry after < code > this & # 46 ; _ last < / code > . */
@ Override protected void updateListAfterPut ( CacheEntry < K , V > newEntry ) { } }

implementation: newEntry . setPrevious ( _last ) ; if ( _last != null ) { _last . setNext ( newEntry ) ; } setLast ( newEntry ) ;


signature:
public class LfuCache { /** * Resort the linked list . If this CacheEntry has more hits than the previous one move it up . */
@ Override protected void updateListAfterHit ( CacheEntry < K , V > entry ) { } }

implementation:
if ( entry != null && ! entry . equals ( _first ) ) { if ( entry . getHits ( ) > entry . getPrevious ( ) . getHits ( ) ) { // Swap the positions
final CacheEntry < K , V > beforePrevious = entry . getPrevious ( ) . getPrevious ( ) ; final CacheEntry < K , V > previous = entry . getPrevious ( ) ; final CacheEntry < K , V > next = entry . getNext ( ) ; if ( beforePrevious != null ) { beforePrevious . setNext ( entry ) ; } else { _first = entry ; } entry . setPrevious ( beforePrevious ) ; previous . setPrevious ( entry ) ; previous . setNext ( next ) ; entry . setNext ( previous ) ; if ( next == null ) { setLast ( previous ) ; } else { next . setPrevious ( previous ) ; } } }


signature:
public class CollectionUtils { /** * Returns a the given map enriched
 * with the mappings < code > a [ 0 ] = > a [ 1 ] , a [ 2 ] = > a [ 3 ] , . . . < / code > .
 * @ param a the elements to construct a { @ link Map } from .
 * @ return a { @ link Map } constructed of the specified elements . */
@ Nonnull public static < K , V > Map < K , V > putAll ( @ Nonnull Map < K , V > original , @ Nullable Object ... a ) { } }

implementation:
if ( a != null ) { final int length = a . length ; if ( length % 2 == 1 ) { throw new IllegalArgumentException ( "You must provide an even number of arguments." ) ; } for ( int i = 0 ; i < length ; i += 2 ) { // noinspection unchecked
original . put ( ( K ) a [ i ] , ( V ) a [ i + 1 ] ) ; } } return original ;


signature:
public class CollectionUtils { /** * Returns a { @ link LinkedHashMap }
 * with the mappings < code > a [ 0 ] = > a [ 1 ] , a [ 2 ] = > a [ 3 ] , . . . < / code > .
 * @ param a the elements to construct a { @ link Map } from .
 * @ return a { @ link Map } constructed of the specified elements . */
@ Nonnull public static < K , V > Map < K , V > asMap ( @ Nullable Object ... a ) { } }

implementation: return putAll ( new LinkedHashMap < K , V > ( ) , a ) ;


signature:
public class CollectionUtils { /** * Returns a the given map enriched
 * with the mappings < code > a [ 0 ] = > a [ 1 ] , a [ 2 ] = > a [ 3 ] , . . . < / code > .
 * @ param a the elements to construct a { @ link Map } from .
 * @ return a immutable { @ link Map } constructed of the specified elements . */
@ Nonnull public static < K , V > Map < K , V > putAllAndMakeImmutable ( @ Nonnull Map < K , V > original , @ Nullable Object ... a ) { } }

implementation: return asImmutableMap ( CollectionUtils . putAll ( original , a ) ) ;


signature:
public class CollectionUtils { /** * Returns a { @ link LinkedHashMap }
 * with the mappings < code > a [ 0 ] = > a [ 1 ] , a [ 2 ] = > a [ 3 ] , . . . < / code > .
 * @ param a the elements to construct a { @ link Map } from .
 * @ return a immutable { @ link Map } constructed of the specified elements . */
@ Nonnull public static < K , V > Map < K , V > asImmutableMap ( @ Nullable Object ... a ) { } }

implementation: return putAllAndMakeImmutable ( new LinkedHashMap < K , V > ( ) , a ) ;


signature:
public class CollectionUtils { /** * Returns a { @ link Collection } containing the given < code > objects < / code > ,
 * returns an empty List , if < code > objects < / code > is null . */
@ Nonnull public static < T > Collection < T > asCollection ( @ Nullable T ... objects ) { } }

implementation: return asList ( objects ) ;


signature:
public class CollectionUtils { /** * Returns an unmodifiable { @ link Collection } containing the given < code > objects < / code > ,
 * returns an empty { @ link Collection } , if < code > objects < / code > is null . */
@ Nonnull public static < T > Collection < T > asImmutableCollection ( @ Nullable T ... objects ) { } }

implementation: return unmodifiableCollection ( asCollection ( objects ) ) ;


signature:
public class CollectionUtils { /** * Returns a { @ link List } containing the given < code > objects < / code > ,
 * returns an empty List , if < code > objects < / code > is null . */
@ Nonnull public static < T > List < T > asList ( @ Nullable T ... objects ) { } }

implementation: final List < T > result ; if ( objects == null ) { result = new ArrayList < > ( ) ; } else { final int initialCapacity = Math . max ( 16 , ( ( objects . length + 2 ) / 3 ) * 4 ) ; result = new ArrayList < > ( initialCapacity ) ; result . addAll ( new ArrayWrapper < > ( objects ) ) ; } return result ;


signature:
public class CollectionUtils { /** * Returns an unmodifiable { @ link List } containing the given < code > objects < / code > ,
 * returns an empty { @ link List } , if < code > objects < / code > is null . */
@ Nonnull public static < T > List < T > asImmutableList ( @ Nullable T ... objects ) { } }

implementation: return unmodifiableList ( asList ( objects ) ) ;


signature:
public class CollectionUtils { /** * Returns a { @ link Set } containing the given < code > objects < / code > ,
 * returns an empty Set , if < code > objects < / code > is null . */
@ Nonnull public static < T > Set < T > asSet ( @ Nullable T ... objects ) { } }

implementation: final Set < T > result ; if ( objects == null ) { result = new LinkedHashSet < > ( ) ; } else { final int initialCapacity = Math . max ( 16 , ( ( objects . length + 2 ) / 3 ) * 4 ) ; result = new LinkedHashSet < > ( initialCapacity ) ; result . addAll ( new ArrayWrapper < > ( objects ) ) ; } return result ;


signature:
public class CollectionUtils { /** * Returns an unmodifiable { @ link Set } containing the given < code > objects < / code > ,
 * returns an empty Set , if < code > objects < / code > is null . */
@ Nonnull public static < T > Set < T > asImmutableSet ( @ Nullable T ... objects ) { } }

implementation: return addAllAndMakeImmutable ( new HashSet < T > ( ) , objects ) ;


signature:
public class CollectionUtils { /** * Returns an unmodifiable { @ link Set } containing the given < code > objects < / code > . */
@ Nonnull public static < T > Set < T > addAllAndMakeImmutable ( @ Nonnull Set < T > original , @ Nullable T ... objects ) { } }

implementation: return unmodifiableSet ( addAll ( original , objects ) ) ;


signature:
public class StringUtils { /** * Count the number of occurrences of sub in s */
@ Nonnegative public static int countSubString ( @ Nonnull String string , @ Nonnull String sub ) { } }

implementation: int count = 0 ; int pos = 0 ; do { pos = string . indexOf ( sub , pos ) ; if ( pos != - 1 ) { count ++ ; pos += sub . length ( ) ; } } while ( pos != - 1 ) ; return count ;


signature:
public class StringUtils { /** * Split a string and return the values as an array .
 * @ param delimiters delimiters that are accepted by StringTokenizer */
@ Nonnull public static List < String > splitToList ( @ Nonnull String source , @ Nonnull String delimiters , boolean returnDelimiters , boolean trim ) { } }

implementation: final List < String > values = new ArrayList < > ( ) ; if ( source != null ) { final StringTokenizer st = new StringTokenizer ( source , delimiters , returnDelimiters ) ; while ( st . hasMoreTokens ( ) ) { String value = st . nextToken ( ) ; if ( trim ) { value = trim ( value ) ; } values . add ( value ) ; } } return values ;


signature:
public class StringUtils { /** * Split a string and return the values as an array .
 * @ param delimiters delimiters that are accepted by StringTokenizer */
@ Nonnull public static String [ ] split ( @ Nonnull String source , @ Nonnull String delimiters , boolean returnDelimiters , boolean trim ) { } }

implementation: final List < String > values = splitToList ( source , delimiters , returnDelimiters , trim ) ; final String [ ] result = new String [ values . size ( ) ] ; values . toArray ( result ) ; return result ;


signature:
public class StringUtils { /** * Appends the separator string , if < code > { @ link StringBuilder # length ( ) buf . lenght ( ) } & gt ; 0 < / code > and then appends the element . */
public static void addElement ( @ Nonnull StringBuilder buf , @ Nonnull String separator , @ Nonnull String element ) { } }

implementation: if ( buf . length ( ) > 0 ) { buf . append ( separator ) ; } buf . append ( element ) ;


signature:
public class StringUtils { /** * Convert a string to lower case . ( Faster than String . toLowerCase ) */
public static void toLowerCase ( char [ ] chars ) { } }

implementation: for ( int a = 0 ; a < chars . length ; a ++ ) { chars [ a ] = Character . toLowerCase ( chars [ a ] ) ; }


signature:
public class StringUtils { /** * Test whether ' find ' can be found at position ' startPos ' in the string ' src ' . */
public static boolean startsWith ( char [ ] src , char [ ] find , int startAt ) { } }

implementation:
int startPos = startAt ; boolean result = true ; // Check ranges
if ( src . length < startPos + find . length ) { result = false ; } else { final int max = find . length ; for ( int a = 0 ; a < max && result ; a ++ ) { if ( src [ startPos ] != find [ a ] ) { result = false ; } startPos ++ ; } } return result ;


signature:
public class StringUtils { /** * Same as String . indexOf but ( slightly ) faster ; )
 * Hint : Performance optimized code - so some warnings are suppressed . */
@ SuppressWarnings ( { } }

implementation:
"MethodWithMultipleReturnPoints" , "LabeledStatement" , "ValueOfIncrementOrDecrementUsed" , "ContinueStatement" , "ContinueStatementWithLabel" } ) public static int indexOf ( char [ ] src , char [ ] find , int startAt ) { int startPos = startAt ; final int max = src . length - find . length ; if ( startPos > max ) { return - 1 ; } final char find0 = find [ 0 ] ; final int len = find . length ; int j ; int k ; // Find the first character
startOver : while ( startPos <= max ) { if ( src [ startPos ++ ] == find0 ) { // First character found - look for the rest
j = startPos ; k = 1 ; while ( k < len ) { if ( src [ j ++ ] != find [ k ++ ] ) { continue startOver ; } } return startPos - 1 ; } } return - 1 ;


signature:
public class Slf4jUtils { /** * < p > Log a message at the given < code > level < / code > according to the specified format and argument . < / p >
 * < p > This form avoids superfluous object creation when the logger is disabled for the given < code > level < / code > . < / p >
 * @ param format the format string
 * @ param arg the argument */
public static void log ( @ Nonnull Logger logger , @ Nonnull LogLevel level , @ Nonnull String format , @ Nullable Object arg ) { } }

implementation: if ( logger instanceof LocationAwareLogger ) { log ( ( LocationAwareLogger ) logger , level , FQCN , null , format , new Object [ ] { arg } , null ) ; } else if ( trace . equals ( level ) ) { logger . trace ( format , arg ) ; } else if ( debug . equals ( level ) ) { logger . debug ( format , arg ) ; } else if ( info . equals ( level ) ) { logger . info ( format , arg ) ; } else if ( warning . equals ( level ) ) { logger . warn ( format , arg ) ; } else if ( error . equals ( level ) || fatal . equals ( level ) ) { logger . error ( format , arg ) ; } else { log ( logger , normalize ( level ) , format , arg ) ; }