signature:
public class ChronosConnector { /** * GUI client should call this method in its own onCreate ( ) method .
 * @ param client a client that holds the helper
 * @ param savedInstanceState parameter from the corresponding client method */
public final void onCreate ( @ NonNull final Object client , @ Nullable final Bundle savedInstanceState ) { } }

implementation: mGUIClient = client ; if ( savedInstanceState != null ) { mChronosListener = ChronosListenerManager . getInstance ( ) . getListener ( savedInstanceState . getInt ( KEY_CHRONOS_LISTENER_ID ) ) ; } else { mChronosListener = ChronosListenerManager . getInstance ( ) . createListener ( ) ; }


signature:
public class ChronosConnector { /** * GUI client should call this method in its own onSaveInstanceState ( ) method .
 * @ param outState parameter from the corresponding client method */
public final void onSaveInstanceState ( @ Nullable final Bundle outState ) { } }

implementation: if ( outState != null ) { outState . putInt ( KEY_CHRONOS_LISTENER_ID , mChronosListener . getId ( ) ) ; }


signature:
public class ChronosConnector { /** * Runs an operation in a background thread . Only one operation with the given tag may run in a
 * single moment of time . The result will be delivered to { @ link Chronos # OWN _ CALLBACK _ METHOD _ NAME }
 * method . If { @ code broadcast } is { @ code true } all other Chronos clients will receive the
 * result in { @ link Chronos # BROADCAST _ CALLBACK _ METHOD _ NAME } method . Both method must have only
 * one parameter of type { @ link ChronosOperation # getResultClass ( ) } to receive a result .
 * @ param operation an operation to be run in background
 * @ param tag value which prohibits running new operations with the same tag while there
 * is a running one
 * @ param broadcast { @ code true } if any other Chronos clients should be able to receive a
 * result ; { @ code false } otherwise
 * @ return a unique launch id , may be the same with the previous run with the same tag , if the
 * operation is still running
 * @ see # runOperation ( ChronosOperation , boolean )
 * @ see # cancelOperation ( int , boolean )
 * @ see # cancelOperation ( String , boolean ) */
public final int runOperation ( @ NonNull final ChronosOperation operation , @ NonNull final String tag , final boolean broadcast ) { } }

implementation: return mChronosListener . invoke ( operation , tag , broadcast ) ;


signature:
public class ChronosService { /** * Runs operation , handling all the exceptions that may ne thrown while running .
 * @ param operation an operation to be executed
 * @ param operationResult an empty result object to be filled with business - logic content
 * @ param < Output > class of the result , returned by the Operations ' { @ code run } method */
private static < Output > void silentRun ( @ NonNull final ChronosOperation < Output > operation , @ NonNull final ChronosOperationResult < Output > operationResult ) { } }

implementation: try { final Output output = operation . run ( ) ; operationResult . setOutput ( output ) ; } catch ( Exception e ) { operationResult . setException ( e ) ; }


signature:
public class ChronosService { /** * Creates a template object for storing operations ' run result .
 * @ param operation an operation to create a result for
 * @ param broadcastResult { @ code true } if the result should be broadcasted , { @ code false }
 * otherwise
 * @ param < Output > class of the result , returned by the Operations ' { @ code run } method
 * @ return an empty OperationResult without business - logic content */
@ NonNull @ Contract ( pure = true ) private < Output > ChronosOperationResult < Output > createEmptyResult ( @ NonNull final ChronosOperation < Output > operation , final boolean broadcastResult ) { } }

implementation: final ChronosOperationResult < Output > operationResult ; final Class < ? extends ChronosOperationResult < Output > > resultClass = operation . getResultClass ( ) ; try { operationResult = resultClass . newInstance ( ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( "Can't create a new instance of " + resultClass . getName ( ) ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( resultClass . getName ( ) + " constructor is not accessible" ) ; } operationResult . setId ( mLastOperationId . incrementAndGet ( ) ) ; operationResult . setOperation ( operation ) ; operationResult . setBroadcast ( broadcastResult ) ; return operationResult ;


signature:
public class ChronosService { /** * Runs operation in background .
 * @ param operation an operation to be executed
 * @ param < Output > class of the result , returned by the Operations ' { @ code run } method
 * @ param broadcastResult { @ code true } if the result should be broadcasted , { @ code false }
 * otherwise
 * @ return the unique id of the launch */
final < Output > int runAsync ( @ NonNull final ChronosOperation < Output > operation , final boolean broadcastResult ) { } }

implementation: final ChronosOperationResult < Output > result = createEmptyResult ( operation , broadcastResult ) ; final int id = result . getId ( ) ; synchronized ( ChronosService . this ) { RunningOperationStorage . getInstance ( ) . operationStarted ( id , operation , mExecutorService . submit ( new Runnable ( ) { @ Override public void run ( ) { silentRun ( operation , result ) ; mEventBus . post ( result ) ; synchronized ( ChronosService . this ) { RunningOperationStorage . getInstance ( ) . operationFinished ( id ) ; } } } ) ) ; } return id ;


signature:
public class ChronosService { /** * Runs operation in the same thread .
 * @ param operation an operation to be executed
 * @ param < Output > class of the result , returned by the Operations ' { @ code run } method
 * @ param broadcastResult { @ code true } if the result should be broadcasted , { @ code false }
 * otherwise
 * @ return operations ' result */
@ NonNull final < Output > ChronosOperationResult < Output > runSync ( @ NonNull final ChronosOperation < Output > operation , final boolean broadcastResult ) { } }

implementation: final ChronosOperationResult < Output > result = createEmptyResult ( operation , broadcastResult ) ; silentRun ( operation , result ) ; mEventBus . post ( result ) ; return result ;


signature:
public class DataLoadCancel { /** * cancelling in the place it happened */
public void onOperationFinished ( final SimpleOperation . Result result ) { } }

implementation: if ( result . isSuccessful ( ) ) { mData = result . getOutput ( ) ; showData ( ) ; } else { mTextOutput . setText ( result . getErrorMessage ( ) ) ; }


signature:
public class Main { /** * Subclass specific entry point .
 * @ param main The actual main class implementation to use .
 * @ param args The command line arguments . */
protected static void main ( Main main , String ... args ) { } }

implementation: main . getInjector ( ) . getInstance ( main . getMainClass ( ) ) . doMain ( args ) ;


signature:
public class Main { /** * Get the Guice modules to be used in injecting dependencies .
 * @ return The modules . */
protected Module [ ] getModules ( ) { } }

implementation: Module [ ] modules = { new WireModule ( new EventHandlerModule ( ) , new SpaceModule ( new URLClassSpace ( Main . class . getClassLoader ( ) ) ) ) } ; return modules ;


signature:
public class Main { /** * Actual main implementation .
 * @ param args The command line arguments . These should be URLs that point to the configuration file ( s ) . */
protected void doMain ( String ... args ) { } }

implementation:
properties = new MergeableProperties ( ) ; properties . putAll ( System . getProperties ( ) ) ; for ( String arg : args ) { properties . merge ( arg ) ; } // Read event handling configuration
Map < String , List < EventHandler > > eventHandlers = new LinkedHashMap < > ( ) ; MergeableProperties allProperties = properties . getPrefixed ( "willow-event-handler.handlers" ) ; int i = 0 ; while ( true ) { MergeableProperties handlerProperties = allProperties . getPrefixed ( "[" + i ++ + "]" ) ; if ( handlerProperties . isEmpty ( ) ) { break ; } String handlerClassName = handlerProperties . getProperty ( "handler" ) ; String eventClassName = handlerProperties . getProperty ( "event" ) ; try { EventHandler eventHandler = ( EventHandler ) injector . getInstance ( Class . forName ( handlerClassName ) ) ; MergeableProperties beanProperties = handlerProperties . getPrefixed ( "properties" ) ; for ( String propertyName : beanProperties . stringPropertyNames ( ) ) { String propertyValue = beanProperties . getProperty ( propertyName ) ; BeanUtils . setProperty ( eventHandler , propertyName , propertyValue ) ; } List < EventHandler > eventHandlersForType = eventHandlers . get ( eventClassName ) ; if ( eventHandlersForType == null ) { eventHandlersForType = new ArrayList < > ( ) ; eventHandlers . put ( eventClassName , eventHandlersForType ) ; } eventHandlersForType . add ( eventHandler ) ; } catch ( ClassNotFoundException | IllegalAccessException | InvocationTargetException e ) { logger . log ( Level . SEVERE , "Error instantiating handler" , e ) ; System . exit ( 1 ) ; } } if ( eventHandlers . isEmpty ( ) ) { logger . info ( "No event handlers configured. Exiting." ) ; System . exit ( 0 ) ; } Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { @ Override public void run ( ) { Main . this . stop ( ) ; } } ) ; // Start polling events
String uri = properties . getProperty ( "willow-event-handler.eventsUri" ) ; try { logger . info ( "Initializing event poller" ) ; eventPoller . initialize ( eventHandlers , new URI ( uri ) ) ; } catch ( URISyntaxException e ) { logger . log ( Level . SEVERE , "Invalid URI: " + uri , e ) ; System . exit ( 1 ) ; }


signature:
public class LoggingOutputStream { /** * Checks if the end of the buffer contains a newline and if so , flushes the stream */
private void checkLine ( ) { } }

implementation: String endStr = new String ( buf , count - LINE_SEPERATOR . length ( ) , LINE_SEPERATOR . length ( ) , charset ) ; if ( LINE_SEPERATOR . equals ( endStr ) ) { flush ( ) ; }


signature:
public class LoggingOutputStream { /** * Flushes this output stream and forces any buffered output bytes
 * to be written out . The general contract of < code > flush < / code > is
 * that calling it is an indication that , if any bytes previously
 * written have been buffered by the implementation of the output
 * stream , such bytes should immediately be written to their
 * intended destination . */
@ Override @ SuppressWarnings ( "PMD.UselessParentheses" ) public void flush ( ) { } }

implementation:
if ( count == 0 ) { return ; } // don ' t print out blank lines ; flushing from PrintStream puts out these
if ( ( count == LINE_SEPERATOR . length ( ) ) && ( ( char ) buf [ 0 ] ) == LINE_SEPERATOR . charAt ( 0 ) && ( ( count == 1 ) || // < - Unix & Mac , - > Windows
( ( count == 2 ) && ( ( char ) buf [ 1 ] ) == LINE_SEPERATOR . charAt ( 1 ) ) ) ) { reset ( ) ; return ; } final byte [ ] theBytes = new byte [ count ] ; System . arraycopy ( buf , 0 , theBytes , 0 , count ) ; String message = new String ( theBytes , charset ) ; if ( message . endsWith ( LINE_SEPERATOR ) ) { message = message . substring ( 0 , message . length ( ) - LINE_SEPERATOR . length ( ) ) ; } logger . log ( level , message ) ; reset ( ) ;


signature:
public class UrlPacScriptSource { /** * getScriptContent
 * @ see com . btr . proxy . selector . pac . PacScriptSource # getScriptContent ( ) */
@ Override public synchronized String getScriptContent ( ) throws IOException { } }

implementation:
if ( this . scriptContent == null || this . expireAtMillis > 0 && this . expireAtMillis < System . currentTimeMillis ( ) ) { ProxySelector old = ProxySelector . getDefault ( ) ; try { // Reset it again with next download we should get a new expire info
this . expireAtMillis = 0 ; ProxySelector . setDefault ( new ProxySelector ( ) { @ Override public List < Proxy > select ( URI uri ) { return Arrays . asList ( Proxy . NO_PROXY ) ; } @ Override public void connectFailed ( URI uri , SocketAddress sa , IOException ioe ) { } } ) ; this . scriptContent = readPacFileContent ( this . scriptUrl ) ; } finally { ProxySelector . setDefault ( old ) ; } } return this . scriptContent ;


signature:
public class UrlPacScriptSource { /** * Reads a PAC script from a local file .
 * @ param scriptUrl
 * @ return the content of the script file .
 * @ throws IOException
 * @ throws URISyntaxException */
private String readPacFileContent ( String scriptUrl ) throws IOException { } }

implementation: try ( InputStream in = new URL ( scriptUrl ) . openConnection ( Proxy . NO_PROXY ) . getInputStream ( ) ; BufferedReader r = new BufferedReader ( new InputStreamReader ( in , StandardCharsets . UTF_8 ) ) ) { StringBuilder result = new StringBuilder ( ) ; try { String line ; while ( ( line = r . readLine ( ) ) != null ) { result . append ( line ) . append ( "\n" ) ; } } finally { r . close ( ) ; } return result . toString ( ) ; }


signature:
public class UrlPacScriptSource { /** * isScriptValid
 * @ see com . btr . proxy . selector . pac . PacScriptSource # isScriptValid ( ) */
@ Override public boolean isScriptValid ( ) { } }

implementation: try { String script = getScriptContent ( ) ; if ( script . trim ( ) . length ( ) == 0 ) { log . log ( Level . FINE , "PAC script is empty. Skipping script!" ) ; return false ; } if ( script . indexOf ( "FindProxyForURL" ) == - 1 ) { log . log ( Level . FINE , "PAC script entry point FindProxyForURL not found. Skipping script!" ) ; return false ; } return true ; } catch ( IOException e ) { log . log ( Level . FINE , "File reading error" , e ) ; return false ; }


signature:
public class EventPoller { /** * Initialize the event poller .
 * @ param eventHandlers The handlers for different event types .
 * @ param uri The web socket connection URI . */
public void initialize ( Map < String , List < EventHandler > > eventHandlers , URI uri ) { } }

implementation: this . eventHandlers = eventHandlers ; EventListener listener = new EventListener ( uri ) ; executorService . submit ( listener ) ; logger . fine ( "Started event listener" ) ;


signature:
public class AbstractJMXStatisticsSender { /** * Return the MBean server connection to the child process .
 * @ return MBean server connection . */
protected MBeanServerConnection getMBeanServerConnection ( String childName ) { } }

implementation: MBeanConnectionInfo connInfo = connections . get ( childName ) ; if ( connInfo == null ) { connInfo = new MBeanConnectionInfo ( ) ; connections . put ( childName , connInfo ) ; } long childPid = main . getFirstJavaChildPid ( childName ) ; if ( childPid > 0 && childPid != connInfo . childPid && connInfo . connector != null ) { try { connInfo . connector . close ( ) ; } catch ( IOException e ) { logger . log ( Level . FINE , "Failed to close JMXConnector" , e ) ; } connInfo . connector = null ; connInfo . server = null ; } if ( childPid > 0 ) { try { if ( connInfo . connector == null ) { connInfo . connector = DeployerControl . getJMXConnector ( childPid ) ; } if ( connInfo . connector != null && connInfo . server == null ) { connInfo . server = connInfo . connector . getMBeanServerConnection ( ) ; connInfo . childPid = childPid ; } } catch ( IOException e ) { logger . log ( Level . FINE , "Failed to get JMX connection" , e ) ; try { connInfo . connector . close ( ) ; } catch ( Exception e2 ) { logger . log ( Level . FINE , "Failed to close JMXConnector" , e2 ) ; } connInfo . connector = null ; connInfo . server = null ; } } return connInfo . server ;


signature:
public class AbstractJMXStatisticsSender { /** * Close the MBean server connection . */
protected void closeMBeanServerConnection ( String childName ) { } }

implementation: MBeanConnectionInfo connInfo = connections . get ( childName ) ; if ( connInfo != null && connInfo . connector != null ) { try { connInfo . connector . close ( ) ; } catch ( IOException e ) { logger . log ( Level . FINE , "Failed to close JMXConnector" , e ) ; } connInfo . connector = null ; }


signature:
public class YamlProcessor { /** * Provide an opportunity for subclasses to process the Yaml parsed from the supplied
 * URIs . Each URI is parsed in turn and the documents inside checked against
 * the { @ link # setDocumentMatchers ( DocumentMatcher . . . ) matchers } . If a document
 * matches it is passed into the callback , along with its representation as
 * Properties . Depending on the { @ link # setResolutionMethod ( ResolutionMethod ) } not all
 * of the documents will be parsed .
 * @ param callback a callback to delegate to once matching documents are found
 * @ see # createYaml ( ) */
protected void process ( MatchCallback callback ) { } }

implementation: Yaml yaml = createYaml ( ) ; for ( InputStream next : this . resources ) { boolean found = process ( callback , yaml , next ) ; if ( this . resolutionMethod == ResolutionMethod . FIRST_FOUND && found ) { return ; } }


signature:
public class AutoScalingGroupStatus { /** * Returns a list of auto scaling policies that have triggered , e . g . value is past threshold .
 * Considers a policy triggered if there a few data points consistently past the threshold .
 * @ return */
public List < AutoScalingPolicy > getTriggeredPolicies ( ) { } }

implementation: List < AutoScalingPolicy > triggeredPolicies = new ArrayList < > ( ) ; for ( AutoScalingPolicy policy : group . getScalingPolicies ( ) ) { List < TimePoint < Double > > metricValues = getMetricValues ( policy . getMetricName ( ) ) ; int triggerCount = 0 ; int triggerThreshold = 3 ; int inspectCount = 0 ; if ( metricValues != null && metricValues . size ( ) > 2 ) { List < TimePoint < Double > > reverse = new ArrayList < > ( metricValues ) ; Collections . reverse ( reverse ) ; for ( TimePoint < Double > p : reverse ) { ComparisonOperation op = ComparisonOperation . fromSymbol ( policy . getMetricComparison ( ) ) ; if ( op . compare ( p . getValue ( ) , Double . valueOf ( policy . getMetricThreshold ( ) ) ) ) { triggerCount ++ ; } inspectCount ++ ; if ( inspectCount >= 3 ) { break ; } } if ( triggerCount >= triggerThreshold ) { triggeredPolicies . add ( policy ) ; } } } return triggeredPolicies ;


signature:
public class PacScriptMethods { /** * Tries to resolve the host name . Returns true if succeeds .
 * @ param host
 * is the host name from the URL .
 * @ return true if resolvable else false . */
@ Override public boolean isResolvable ( String host ) { } }

implementation: try { InetAddress . getByName ( host ) . getHostAddress ( ) ; return true ; } catch ( UnknownHostException ex ) { log . log ( Level . FINE , "Hostname not resolveable {0}." , host ) ; } return false ;


signature:
public class PacScriptMethods { /** * Returns true if the IP address of the host matches the specified IP address
 * pattern . Pattern and mask specification is done the same way as for SOCKS
 * configuration .
 * Example : isInNet ( host , " 198.95.0.0 " , " 255.255.0.0 " ) is true if the IP
 * address of the host matches 198.95 . * . * .
 * @ param host
 * a DNS host name , or IP address . If a host name is passed , it will
 * be resolved into an IP address by this function .
 * @ param pattern
 * an IP address pattern in the dot - separated format .
 * @ param mask
 * mask for the IP address pattern informing which parts of the IP
 * address should be matched against . 0 means ignore , 255 means
 * match .
 * @ return true if it matches else false . */
@ Override public boolean isInNet ( String host , String pattern , String mask ) { } }

implementation: host = dnsResolve ( host ) ; if ( host == null || host . length ( ) == 0 ) { return false ; } long lhost = parseIpAddressToLong ( host ) ; long lpattern = parseIpAddressToLong ( pattern ) ; long lmask = parseIpAddressToLong ( mask ) ; return ( lhost & lmask ) == lpattern ;


signature:
public class PacScriptMethods { /** * Convert a string representation of a IP to a long .
 * @ param address
 * to convert .
 * @ return the address as long . */
private long parseIpAddressToLong ( String address ) { } }

implementation: long result = 0 ; String [ ] parts = address . split ( "\\." ) ; long shift = 24 ; for ( String part : parts ) { long lpart = Long . parseLong ( part ) ; result |= lpart << shift ; shift -= 8 ; } return result ;


signature:
public class PacScriptMethods { /** * Resolves the given DNS host name into an IP address , and returns it in the
 * dot separated format as a string .
 * @ param host
 * the host to resolve .
 * @ return the resolved IP , empty string if not resolvable . */
@ Override public String dnsResolve ( String host ) { } }

implementation: try { return InetAddress . getByName ( host ) . getHostAddress ( ) ; } catch ( UnknownHostException e ) { log . log ( Level . FINE , "DNS name not resolvable {0}." , host ) ; } return "" ;


signature:
public class PacScriptMethods { /** * Get the current IP address of the computer . This will return the first
 * address of the first network interface that is a " real " IP address of the
 * given type .
 * @ param cl
 * the type of address we are searching for .
 * @ return the address as string or " " if not found . */
private String getLocalAddressOfType ( Class < ? extends InetAddress > cl ) { } }

implementation: try { String overrideIP = System . getProperty ( OVERRIDE_LOCAL_IP ) ; if ( overrideIP != null && overrideIP . trim ( ) . length ( ) > 0 ) { return overrideIP . trim ( ) ; } Enumeration < NetworkInterface > interfaces = NetworkInterface . getNetworkInterfaces ( ) ; while ( interfaces . hasMoreElements ( ) ) { NetworkInterface current = interfaces . nextElement ( ) ; if ( ! current . isUp ( ) || current . isLoopback ( ) || current . isVirtual ( ) ) { continue ; } Enumeration < InetAddress > addresses = current . getInetAddresses ( ) ; while ( addresses . hasMoreElements ( ) ) { InetAddress adr = addresses . nextElement ( ) ; if ( cl . isInstance ( adr ) ) { log . log ( Level . FINER , "Local address resolved to {0}" , adr ) ; return adr . getHostAddress ( ) ; } } } return "" ; } catch ( IOException e ) { log . log ( Level . FINE , "Local address not resolvable." ) ; return "" ; }


signature:
public class PacScriptMethods { /** * Returns the number of DNS domain levels ( number of dots ) in the host name .
 * @ param host
 * is the host name from the URL .
 * @ return number of DNS domain levels . */
@ Override public int dnsDomainLevels ( String host ) { } }

implementation: int count = 0 ; int startPos = 0 ; while ( ( startPos = host . indexOf ( "." , startPos + 1 ) ) > - 1 ) { count ++ ; } return count ;


signature:
public class PacScriptMethods { /** * Returns true if the string matches the specified shell expression .
 * Actually , currently the patterns are shell expressions , not regular
 * expressions .
 * @ param str
 * is any string to compare ( e . g . the URL , or the host name ) .
 * @ param shexp
 * is a shell expression to compare against .
 * @ return true if the string matches , else false . */
@ Override public boolean shExpMatch ( String str , String shexp ) { } }

implementation:
StringTokenizer tokenizer = new StringTokenizer ( shexp , "*" ) ; int startPos = 0 ; while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; int temp = str . indexOf ( token , startPos ) ; // Must start with first token
if ( startPos == 0 && ! shexp . startsWith ( "*" ) && temp != 0 ) { return false ; } // Last one ends with last token
if ( ! tokenizer . hasMoreTokens ( ) && ! shexp . endsWith ( "*" ) && ! str . endsWith ( token ) ) { return false ; } if ( temp == - 1 ) { return false ; } else { startPos = temp + token . length ( ) ; } } return true ;


signature:
public class PacScriptMethods { /** * Only the first parameter is mandatory . Either the second , the third , or
 * both may be left out . If only one parameter is present , the function yields
 * a true value on the weekday that the parameter represents . If the string
 * " GMT " is specified as a second parameter , times are taken to be in GMT ,
 * otherwise in local time zone . If both wd1 and wd2 are defined , the
 * condition is true if the current weekday is in between those two weekdays .
 * Bounds are inclusive . If the " GMT " parameter is specified , times are taken
 * to be in GMT , otherwise the local time zone is used .
 * @ param wd1
 * weekday 1 is one of SUN MON TUE WED THU FRI SAT
 * @ param wd2
 * weekday 2 is one of SUN MON TUE WED THU FRI SAT
 * @ param gmt
 * " GMT " for gmt time format else " undefined "
 * @ return true if current day matches the criteria . */
@ Override public boolean weekdayRange ( String wd1 , String wd2 , String gmt ) { } }

implementation: boolean useGmt = GMT . equalsIgnoreCase ( wd2 ) || GMT . equalsIgnoreCase ( gmt ) ; Calendar cal = getCurrentTime ( useGmt ) ; int currentDay = cal . get ( Calendar . DAY_OF_WEEK ) - 1 ; int from = DAYS . indexOf ( wd1 == null ? null : wd1 . toUpperCase ( Locale . ENGLISH ) ) ; int to = DAYS . indexOf ( wd2 == null ? null : wd2 . toUpperCase ( Locale . ENGLISH ) ) ; if ( to == - 1 ) { to = from ; } if ( to < from ) { return currentDay >= from || currentDay <= to ; } else { return currentDay >= from && currentDay <= to ; }


signature:
public class PacScriptMethods { /** * Gets a calendar set to the current time . This is used by the date and time
 * based methods .
 * @ param useGmt
 * flag to indicate if the calendar is to be created in GMT time or
 * local time .
 * @ return a Calendar set to the current time . */
private Calendar getCurrentTime ( boolean useGmt ) { } }

implementation:
if ( this . currentTime != null ) { // Only used for unit tests
return ( Calendar ) this . currentTime . clone ( ) ; } return Calendar . getInstance ( useGmt ? TimeZone . getTimeZone ( GMT ) : TimeZone . getDefault ( ) ) ;


signature:
public class PacScriptMethods { /** * Only the first parameter is mandatory . All other parameters can be left out
 * therefore the meaning of the parameters changes . The method definition
 * shows the version with the most possible parameters filled . The real
 * meaning of the parameters is guessed from it ' s value . If " from " and " to "
 * are specified then the bounds are inclusive . If the " GMT " parameter is
 * specified , times are taken to be in GMT , otherwise the local time zone is
 * used .
 * @ param day1
 * is the day of month between 1 and 31 ( as an integer ) .
 * @ param month1
 * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
 * @ param year1
 * is the full year number , for example 1995 ( but not 95 ) . Integer .
 * @ param day2
 * is the day of month between 1 and 31 ( as an integer ) .
 * @ param month2
 * one of JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
 * @ param year2
 * is the full year number , for example 1995 ( but not 95 ) . Integer .
 * @ param gmt
 * " GMT " for gmt time format else " undefined "
 * @ return true if the current date matches the given range . */
@ Override public boolean dateRange ( Object day1 , Object month1 , Object year1 , Object day2 , Object month2 , Object year2 , Object gmt ) { } }

implementation:
// Guess the parameter meanings .
Map < String , Integer > params = new HashMap < String , Integer > ( ) ; parseDateParam ( params , day1 ) ; parseDateParam ( params , month1 ) ; parseDateParam ( params , year1 ) ; parseDateParam ( params , day2 ) ; parseDateParam ( params , month2 ) ; parseDateParam ( params , year2 ) ; parseDateParam ( params , gmt ) ; // Get current date
boolean useGmt = params . get ( "gmt" ) != null ; Calendar cal = getCurrentTime ( useGmt ) ; Date current = cal . getTime ( ) ; // Build the " from " date
if ( params . get ( "day1" ) != null ) { cal . set ( Calendar . DAY_OF_MONTH , params . get ( "day1" ) ) ; } if ( params . get ( "month1" ) != null ) { cal . set ( Calendar . MONTH , params . get ( "month1" ) ) ; } if ( params . get ( "year1" ) != null ) { cal . set ( Calendar . YEAR , params . get ( "year1" ) ) ; } Date from = cal . getTime ( ) ; // Build the " to " date
Date to ; if ( params . get ( "day2" ) != null ) { cal . set ( Calendar . DAY_OF_MONTH , params . get ( "day2" ) ) ; } if ( params . get ( "month2" ) != null ) { cal . set ( Calendar . MONTH , params . get ( "month2" ) ) ; } if ( params . get ( "year2" ) != null ) { cal . set ( Calendar . YEAR , params . get ( "year2" ) ) ; } to = cal . getTime ( ) ; // Need to increment to the next month ?
if ( to . before ( from ) ) { cal . add ( Calendar . MONTH , + 1 ) ; to = cal . getTime ( ) ; } // Need to increment to the next year ?
if ( to . before ( from ) ) { cal . add ( Calendar . YEAR , + 1 ) ; cal . add ( Calendar . MONTH , - 1 ) ; to = cal . getTime ( ) ; } return current . compareTo ( from ) >= 0 && current . compareTo ( to ) <= 0 ;


signature:
public class PacScriptMethods { /** * Try to guess the type of the given parameter and put it into the params
 * map .
 * @ param params
 * a map to put the parsed parameters into .
 * @ param value
 * to parse and specify the type for . */
private void parseDateParam ( Map < String , Integer > params , Object value ) { } }

implementation:
if ( value instanceof Number ) { int n = ( ( Number ) value ) . intValue ( ) ; if ( n <= 31 ) { // Its a day
if ( params . get ( "day1" ) == null ) { params . put ( "day1" , n ) ; } else { params . put ( "day2" , n ) ; } } else { // Its a year
if ( params . get ( "year1" ) == null ) { params . put ( "year1" , n ) ; } else { params . put ( "year2" , n ) ; } } } if ( value instanceof String ) { int n = MONTH . indexOf ( ( ( String ) value ) . toUpperCase ( Locale . ENGLISH ) ) ; if ( n > - 1 ) { // Its a month
if ( params . get ( "month1" ) == null ) { params . put ( "month1" , n ) ; } else { params . put ( "month2" , n ) ; } } } if ( GMT . equalsIgnoreCase ( String . valueOf ( value ) ) ) { params . put ( "gmt" , 1 ) ; }


signature:
public class PacScriptMethods { /** * Some parameters can be left out therefore the meaning of the parameters
 * changes . The method definition shows the version with the most possible
 * parameters filled . The real meaning of the parameters is guessed from it ' s
 * value . If " from " and " to " are specified then the bounds are inclusive . If
 * the " GMT " parameter is specified , times are taken to be in GMT , otherwise
 * the local time zone is used . < br / >
 * < pre >
 * timeRange ( hour )
 * timeRange ( hour1 , hour2)
 * timeRange ( hour1 , min1 , hour2 , min2)
 * timeRange ( hour1 , min1 , sec1 , hour2 , min2 , sec2)
 * timeRange ( hour1 , min1 , sec1 , hour2 , min2 , sec2 , gmt )
 * < / pre >
 * @ param hour1
 * is the hour from 0 to 23 . ( 0 is midnight , 23 is 11 pm . )
 * @ param min1
 * minutes from 0 to 59.
 * @ param sec1
 * seconds from 0 to 59.
 * @ param hour2
 * is the hour from 0 to 23 . ( 0 is midnight , 23 is 11 pm . )
 * @ param min2
 * minutes from 0 to 59.
 * @ param sec2
 * seconds from 0 to 59.
 * @ param gmt
 * " GMT " for gmt time format else " undefined "
 * @ return true if the current time matches the given range . */
@ Override public boolean timeRange ( Object hour1 , Object min1 , Object sec1 , Object hour2 , Object min2 , Object sec2 , Object gmt ) { } }

implementation: boolean useGmt = GMT . equalsIgnoreCase ( String . valueOf ( min1 ) ) || GMT . equalsIgnoreCase ( String . valueOf ( sec1 ) ) || GMT . equalsIgnoreCase ( String . valueOf ( min2 ) ) || GMT . equalsIgnoreCase ( String . valueOf ( gmt ) ) ; Calendar cal = getCurrentTime ( useGmt ) ; cal . set ( Calendar . MILLISECOND , 0 ) ; Date current = cal . getTime ( ) ; Date from ; Date to ; if ( sec2 instanceof Number ) { cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) hour1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , ( ( Number ) min1 ) . intValue ( ) ) ; cal . set ( Calendar . SECOND , ( ( Number ) sec1 ) . intValue ( ) ) ; from = cal . getTime ( ) ; cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) hour2 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , ( ( Number ) min2 ) . intValue ( ) ) ; cal . set ( Calendar . SECOND , ( ( Number ) sec2 ) . intValue ( ) ) ; to = cal . getTime ( ) ; } else if ( hour2 instanceof Number ) { cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) hour1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , ( ( Number ) min1 ) . intValue ( ) ) ; cal . set ( Calendar . SECOND , 0 ) ; from = cal . getTime ( ) ; cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) sec1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , ( ( Number ) hour2 ) . intValue ( ) ) ; cal . set ( Calendar . SECOND , 59 ) ; to = cal . getTime ( ) ; } else if ( min1 instanceof Number ) { cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) hour1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , 0 ) ; cal . set ( Calendar . SECOND , 0 ) ; from = cal . getTime ( ) ; cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) min1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , 59 ) ; cal . set ( Calendar . SECOND , 59 ) ; to = cal . getTime ( ) ; } else { cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) hour1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , 0 ) ; cal . set ( Calendar . SECOND , 0 ) ; from = cal . getTime ( ) ; cal . set ( Calendar . HOUR_OF_DAY , ( ( Number ) hour1 ) . intValue ( ) ) ; cal . set ( Calendar . MINUTE , 59 ) ; cal . set ( Calendar . SECOND , 59 ) ; to = cal . getTime ( ) ; } if ( to . before ( from ) ) { cal . setTime ( to ) ; cal . add ( Calendar . DATE , + 1 ) ; to = cal . getTime ( ) ; } return current . compareTo ( from ) >= 0 && current . compareTo ( to ) <= 0 ;


signature:
public class PacScriptMethods { /** * dnsResolveEx
 * @ see com . btr . proxy . selector . pac . ScriptMethods # dnsResolveEx ( java . lang . String ) */
@ Override public String dnsResolveEx ( String host ) { } }

implementation: StringBuilder result = new StringBuilder ( ) ; try { InetAddress [ ] list = InetAddress . getAllByName ( host ) ; for ( InetAddress inetAddress : list ) { result . append ( inetAddress . getHostAddress ( ) ) ; result . append ( "; " ) ; } } catch ( UnknownHostException e ) { log . log ( Level . FINE , "DNS name not resolvable {0}." , host ) ; } return result . toString ( ) ;


signature:
public class PacScriptMethods { /** * sortIpAddressList
 * @ see com . btr . proxy . selector . pac . ScriptMethods # sortIpAddressList ( java . lang . String ) */
@ Override public String sortIpAddressList ( String ipAddressList ) { } }

implementation: if ( ipAddressList == null || ipAddressList . trim ( ) . length ( ) == 0 ) { return "" ; } String [ ] ipAddressToken = ipAddressList . split ( ";" ) ; List < InetAddress > parsedAddresses = new ArrayList < InetAddress > ( ) ; for ( String ip : ipAddressToken ) { try { parsedAddresses . add ( InetAddress . getByName ( ip ) ) ; } catch ( UnknownHostException e ) { log . log ( Level . FINE , "Ip address not resolveable {0}." , ip ) ; } } Collections . sort ( parsedAddresses , null ) ; return ipAddressList ;


signature:
public class ScriptAvailability { /** * Checks whether javax . script is available or not . Completely done per
 * Reflection to allow compilation under Java 1.5
 * @ return true if javax . script is available ; false otherwise */
public static boolean isJavaxScriptingAvailable ( ) { } }

implementation: Object engine = null ; try { Class < ? > managerClass = Class . forName ( "javax.script.ScriptEngineManager" ) ; Method m = managerClass . getMethod ( "getEngineByMimeType" , String . class ) ; engine = m . invoke ( managerClass . newInstance ( ) , "text/javascript" ) ; } catch ( ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e ) { return false ; } return engine != null ;


signature:
public class PacProxySelector { /** * Selects one of the available PAC parser engines .
 * @ param pacSource
 * to use as input . */
private void selectEngine ( PacScriptSource pacSource ) { } }

implementation: try { log . log ( Level . INFO , "Using javax.script JavaScript engine." ) ; this . pacScriptParser = new JavaxPacScriptParser ( pacSource ) ; } catch ( Exception e ) { log . log ( Level . INFO , "PAC parser error." , e ) ; }


signature:
public class PacProxySelector { /** * select
 * @ see java . net . ProxySelector # select ( java . net . URI ) */
@ Override public List < Proxy > select ( URI uri ) { } }

implementation:
if ( uri == null ) { throw new IllegalArgumentException ( "URI must not be null." ) ; } // Fix for Java 1.6.16 + where we get a infinite loop because
// URL . connect ( Proxy . NO _ PROXY ) does not work as expected .
if ( ! enabled ) { return noProxyList ( ) ; } return findProxy ( uri ) ;


signature:
public class PacProxySelector { /** * Evaluation of the given URL with the PAC - file .
 * Two cases can be handled here : DIRECT Fetch the object directly from the
 * content HTTP server denoted by its URL PROXY name : port Fetch the object via
 * the proxy HTTP server at the given location ( name and port )
 * @ param uri
 * < code > URI < / code > to be evaluated .
 * @ return < code > Proxy < / code > - object list as result of the evaluation . */
private List < Proxy > findProxy ( URI uri ) { } }

implementation: try { List < Proxy > proxies = new ArrayList < Proxy > ( ) ; String parseResult = this . pacScriptParser . evaluate ( uri . toString ( ) , uri . getHost ( ) ) ; String [ ] proxyDefinitions = parseResult . split ( "[;]" ) ; for ( String proxyDef : proxyDefinitions ) { if ( ! StringUtils . isBlank ( proxyDef ) ) { proxies . add ( buildProxyFromPacResult ( proxyDef ) ) ; } } return proxies ; } catch ( ProxyEvaluationException e ) { log . log ( Level . INFO , "PAC resolving error." , e ) ; return noProxyList ( ) ; }


signature:
public class PacProxySelector { /** * The proxy evaluator will return a proxy string . This method will take this
 * string and build a matching < code > Proxy < / code > for it .
 * @ param pacResult
 * the result from the PAC parser .
 * @ return a Proxy */
public static Proxy buildProxyFromPacResult ( String pacResult ) { } }

implementation:
if ( StringUtils . isBlank ( pacResult ) || pacResult . trim ( ) . toUpperCase ( Locale . ENGLISH ) . startsWith ( PAC_DIRECT ) ) { return Proxy . NO_PROXY ; } String proxyDef = pacResult . trim ( ) ; Proxy . Type type = Proxy . Type . HTTP ; if ( proxyDef . toUpperCase ( Locale . ENGLISH ) . startsWith ( PAC_SOCKS ) ) { type = Proxy . Type . SOCKS ; } else if ( ! proxyDef . toUpperCase ( Locale . ENGLISH ) . startsWith ( PAC_PROXY ) ) { return Proxy . NO_PROXY ; } String host = proxyDef . substring ( PROXY_TYPE_LEN ) ; Integer port = DEFAULT_PROXY_PORT ; // Split port from host
int indexOfPort = host . indexOf ( ':' ) ; if ( indexOfPort != - 1 ) { port = Integer . parseInt ( host . substring ( indexOfPort + 1 ) . trim ( ) ) ; host = host . substring ( 0 , indexOfPort ) . trim ( ) ; } SocketAddress adr = InetSocketAddress . createUnresolved ( host , port ) ; return new Proxy ( type , adr ) ;


signature:
public class PacProxySelector { /** * Gets an unmodifiable proxy list that will have as it ' s only entry an DIRECT
 * proxy .
 * @ return a list with a DIRECT proxy in it . */
public static synchronized List < Proxy > noProxyList ( ) { } }

implementation: if ( noProxyList == null ) { ArrayList < Proxy > list = new ArrayList < Proxy > ( 1 ) ; list . add ( Proxy . NO_PROXY ) ; noProxyList = Collections . unmodifiableList ( list ) ; } return noProxyList ;


signature:
public class PacProxySelector { /** * Build a PAC proxy selector for the given URL .
 * @ param url
 * to fetch the PAC script from .
 * @ return a PacProxySelector or null if it is not possible to build a working
 * selector . */
public static PacProxySelector buildPacSelectorForUrl ( String url ) { } }

implementation: PacProxySelector result = null ; PacScriptSource pacSource = new UrlPacScriptSource ( url ) ; if ( pacSource . isScriptValid ( ) ) { result = new PacProxySelector ( pacSource ) ; } return result ;


signature:
public class JavaxPacScriptParser { /** * Initializes the JavaScript engine and adds aliases for the functions
 * defined in ScriptMethods .
 * @ throws ProxyEvaluationException
 * on error . */
private ScriptEngine setupEngine ( ) throws ProxyEvaluationException { } }

implementation:
ScriptEngineManager mng = new ScriptEngineManager ( ) ; ScriptEngine newEngine = mng . getEngineByMimeType ( "text/javascript" ) ; assert newEngine != null : "Javascript engine not available" ; newEngine . put ( SCRIPT_METHODS_OBJECT , new PacScriptMethods ( ) ) ; Class < ? > scriptMethodsClazz = ScriptMethods . class ; Method [ ] scriptMethods = scriptMethodsClazz . getMethods ( ) ; for ( Method method : scriptMethods ) { String name = method . getName ( ) ; int args = method . getParameterTypes ( ) . length ; StringBuilder toEval = new StringBuilder ( name ) . append ( " = function(" ) ; for ( int i = 0 ; i < args ; i ++ ) { if ( i > 0 ) { toEval . append ( "," ) ; } toEval . append ( "arg" ) . append ( i ) ; } toEval . append ( ") {return " ) ; String functionCall = buildFunctionCallCode ( name , args ) ; // If return type is java . lang . String convert it to a JS string
if ( String . class . isAssignableFrom ( method . getReturnType ( ) ) ) { functionCall = "String(" + functionCall + ")" ; } toEval . append ( functionCall ) . append ( "; }" ) ; try { newEngine . eval ( toEval . toString ( ) ) ; } catch ( ScriptException e ) { log . log ( Level . INFO , "JS evaluation error when creating alias for " + name + "." , e ) ; throw new ProxyEvaluationException ( "Error setting up script engine" , e ) ; } } return newEngine ;


signature:
public class JavaxPacScriptParser { /** * Builds a JavaScript code snippet to call a function that we bind .
 * @ param functionName
 * of the bound function
 * @ param args
 * of the bound function
 * @ return the JS code to invoke the method . */
private String buildFunctionCallCode ( String functionName , int args ) { } }

implementation: StringBuilder functionCall = new StringBuilder ( ) ; functionCall . append ( SCRIPT_METHODS_OBJECT ) . append ( "." ) . append ( functionName ) . append ( "(" ) ; for ( int i = 0 ; i < args ; i ++ ) { if ( i > 0 ) { functionCall . append ( "," ) ; } functionCall . append ( "arg" ) . append ( i ) ; } functionCall . append ( ")" ) ; return functionCall . toString ( ) ;


signature:
public class JavaxPacScriptParser { /** * Evaluates the given URL and host against the PAC script .
 * @ param url
 * the URL to evaluate .
 * @ param host
 * the host name part of the URL .
 * @ return the script result .
 * @ throws ProxyEvaluationException
 * on execution error . */
@ Override public String evaluate ( String url , String host ) throws ProxyEvaluationException { } }

implementation: try { StringBuilder script = new StringBuilder ( this . source . getScriptContent ( ) ) ; String evalMethod = " ;FindProxyForURL (\"" + url + "\",\"" + host + "\")" ; script . append ( evalMethod ) ; Object result = this . engine . eval ( script . toString ( ) ) ; return ( String ) result ; } catch ( Exception e ) { log . log ( Level . INFO , "JS evaluation error." , e ) ; throw new ProxyEvaluationException ( "Error while executing PAC script: " + e . getMessage ( ) , e ) ; }


signature:
public class FakeSearchView { /** * Inflate the layout to this FrameLayout wrapper
 * @ param context for inflate views */
protected void init ( Context context ) { } }

implementation: LayoutInflater . from ( context ) . inflate ( R . layout . fake_search_view , this , true ) ; wrappedEditText = ( EditText ) findViewById ( R . id . wrapped_search ) ; wrappedEditText . addTextChangedListener ( this ) ; wrappedEditText . setOnEditorActionListener ( this ) ;


signature:
public class UniversalRunner { /** * The main program which actually runs JMeter .
 * @ param args the command line arguments */
public static void main ( String [ ] args ) throws Throwable { } }

implementation:
try { Class < ? > initialClass ; // make it independent - get class name & method from props / manifest
initialClass = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( "kg.apc.cmdtools.PluginsCMD" ) ; Object instance = initialClass . newInstance ( ) ; Method startup = initialClass . getMethod ( "processParams" , ( new String [ 0 ] ) . getClass ( ) ) ; Object res = startup . invoke ( instance , new Object [ ] { args } ) ; int rc = ( Integer ) res ; if ( rc != 0 ) { System . exit ( rc ) ; } } catch ( Throwable e ) { if ( e . getCause ( ) != null ) { System . err . println ( "ERROR: " + e . getCause ( ) . toString ( ) ) ; System . err . println ( "*** Problem's technical details go below ***" ) ; System . err . println ( "Home directory was detected as: " + jarDirectory ) ; throw e . getCause ( ) ; } else { System . err . println ( "Home directory was detected as: " + jarDirectory ) ; throw e ; } }


signature:
public class JacksonSchema { /** * Lazy intialization of validator instance
 * @ return
 * @ throws ProcessingException */
private com . github . fge . jsonschema . main . JsonSchema getValidator ( ) throws ProcessingException { } }

implementation: if ( validator == null ) { synchronized ( this ) { if ( validator == null ) { ValidationConfigurationBuilder cfgBuilder = ValidationConfiguration . newBuilder ( ) ; cfgBuilder . addLibrary ( "http://brutusin.org/json/json-schema-spec" , DraftV3Library . get ( ) ) ; validator = JsonSchemaFactory . newBuilder ( ) . setValidationConfiguration ( cfgBuilder . freeze ( ) ) . freeze ( ) . getJsonSchema ( getNode ( ) ) ; } } } return validator ;


signature:
public class Table { /** * get the list of arguments used in find stored procedure
 * @ return */
public List < Column > getFindColumnList ( ) { } }

implementation: List < Column > findColumnList = new ArrayList < Column > ( ) ; List < Column > tempColumnList = new ArrayList < Column > ( ) ; for ( int i = 1 ; i <= this . cardinality ; i ++ ) { if ( this . columns . get ( i ) . referenceTable != null ) { tempColumnList = this . columns . get ( i ) . referenceTable . getFindColumnList ( ) ; for ( int j = 0 ; j < tempColumnList . size ( ) ; j ++ ) { Column column = new Column ( ) ; column . name = columns . get ( i ) . name . replace ( "_ID" , "_" ) . replace ( "_id" , "_" ) + tempColumnList . get ( j ) . name ; column . dataType = tempColumnList . get ( j ) . dataType ; column . nullable = this . columns . get ( i ) . nullable ; findColumnList . add ( column ) ; } } else { Column column = new Column ( ) ; column . name = columns . get ( i ) . name ; column . dataType = columns . get ( i ) . dataType ; column . nullable = this . columns . get ( i ) . nullable ; findColumnList . add ( column ) ; } } return findColumnList ;


signature:
public class Table { /** * get the list of arguments used in insert by code stored procedure
 * @ return */
public List < Column > getInsertColumnList ( ) { } }

implementation: List < Column > result = new ArrayList < > ( ) ; List < Column > tempColumnList = new ArrayList < > ( ) ; for ( Column currentColumn : this . columns ) { if ( currentColumn . referenceTable != null ) { tempColumnList = currentColumn . referenceTable . getFindColumnList ( ) ; for ( Column tempColumn : tempColumnList ) { Column column = new Column ( ) ; column . name = currentColumn . name . replace ( "_ID" , "_" ) . replace ( "_id" , "_" ) + tempColumn . name ; column . dataType = tempColumn . dataType ; column . nullable = currentColumn . nullable ; result . add ( column ) ; } } else { Column column = new Column ( ) ; column . name = currentColumn . name ; column . dataType = currentColumn . dataType ; column . nullable = currentColumn . nullable ; result . add ( column ) ; } } return result ;


signature:
public class ProjectMetaData { /** * recursive method to get all packages including children packages */
@ XmlTransient public List < PackageMetaData > getAllPackages ( ) { } }

implementation: List < PackageMetaData > result = new ArrayList < > ( ) ; if ( packages != null ) { for ( PackageMetaData pack : packages ) { result . addAll ( getPackages ( pack ) ) ; } } return result ;


signature:
public class DatabaseBuilderLauncher { /** * main method to be executed
 * @ param args 0 - > the workspace folder where the " data - model " folder will be detected
 * @ param args 1 - > the database name , declared in / data - model / CONTEXT / datasource - context . xml */
public static void main ( String [ ] args ) { } }

implementation: if ( args . length < 2 ) { throw new IllegalArgumentException ( "Path and datasource are Mandatory" ) ; } String workspacePath = args [ 0 ] ; String databaseName = args [ 1 ] ; String sourcePath = workspacePath + File . separator + ProjectMetaDataDao . DATA_MODEL_FOLDER_NAME ; try ( FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext ( "classpath:applicationContext-generator-bash.xml" , "file:" + sourcePath + File . separator + DATASOURCE_CONTEXT_FILE ) ; ) { logger . info ( "Context loaded" ) ; Project project ; try { logger . info ( "start loading project" ) ; ProjectMetaDataService projectMetaDataService = appContext . getBean ( ProjectMetaDataService . class ) ; ProjectLoader projectLoader = appContext . getBean ( ProjectLoader . class ) ; ProjectMetaData projectMetaData = projectMetaDataService . loadProjectMetaData ( workspacePath ) ; ProjectValidationReport report = projectMetaDataService . validate ( projectMetaData ) ; ValidationPrompter . promptOnValidation ( report ) ; project = projectLoader . loadProject ( projectMetaData ) ; logger . info ( "loading project " + project . projectName + " completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } try { OutputDataSourceProvider outputDataSourceProvider = appContext . getBean ( OutputDataSourceProvider . class ) ; DataSource dataSource = outputDataSourceProvider . getDataSource ( databaseName ) ; DatabaseBuilder databaseBuilder = appContext . getBean ( DatabaseBuilder . class ) ; databaseBuilder . buildDatabase ( dataSource , project ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } }


signature:
public class JavaModelFactory { /** * determines whether the bean will have several tabs in the detail view ( Mode Page ) */
private boolean hasTabsInDetailView ( Bean bean ) { } }

implementation: return bean . oneToManyComponentList . size ( ) > 0 || bean . oneToManyList . size ( ) > 0 || bean . oneToOneComponentList . size ( ) > 0 || bean . oneToOneList . size ( ) > 0 ;


signature:
public class PostgresqlTableFkDefinitionFileWriteCommand { /** * create fks and indexes */
private void createTableFks ( ) { } }

implementation: writeLine ( "-- table foreign keys and indexes --" ) ; int i = 0 ; for ( Column column : table . columns ) { if ( column . referenceTable != null ) { write ( "ALTER TABLE " + table . name + " ADD CONSTRAINT FK_" + table . name + "_" + i + " FOREIGN KEY (" + column . name + ") REFERENCES " + column . referenceTable . name ) ; if ( this . table . columns . get ( i ) . deleteCascade ) { write ( " ON DELETE CASCADE" ) ; } writeLine ( ";" ) ; writeLine ( "/" ) ; skipLine ( ) ; } i ++ ; } i = 0 ; for ( Column column : table . columns ) { if ( column . referenceTable != null ) { writeLine ( "CREATE INDEX FK_" + table . name + "_" + i + " ON " + this . table . name + "(" + column . name + ");" ) ; writeLine ( "/" ) ; skipLine ( ) ; } i ++ ; }


signature:
public class JavaProjectFactory { /** * ( non - Javadoc )
 * @ see com . skeleton . generator . bl . factory . interfaces . ProjectFactory # buildProject ( com . skeleton . generator . model . metadata . ProjectMetaData ) */
public Project buildProject ( ProjectMetaData projectMetaData ) { } }

implementation: Project project = new Project ( ) ; project . domainName = projectMetaData . getDomainName ( ) ; project . projectName = projectMetaData . getProjectName ( ) ; project . sourceFolder = projectMetaData . getSourceFolder ( ) ; project . workspaceFolder = projectMetaData . getWorkspaceFolder ( ) ; project . skeleton = projectMetaData . getSkeleton ( ) ; project . databaseEngine = projectMetaData . getDatabaseEngine ( ) ; project . databaseName = projectMetaData . getDatabaseName ( ) ; project . databaseDNS = projectMetaData . getDatabaseDNS ( ) ; project . databasePort = projectMetaData . getDatabasePort ( ) ; project . databaseUserName = projectMetaData . getDatabaseUserName ( ) ; project . databasePassword = projectMetaData . getDatabasePassword ( ) ; project . audited = projectMetaData . getAudited ( ) ; logger . trace ( "start building model" ) ; project . model = modelFactory . buildModel ( projectMetaData , project ) ; logger . trace ( "end building model" ) ; return project ;


signature:
public class OracleTableDefinitionFileWriteCommand { /** * create audit table */
private void createAuditTable ( ) { } }

implementation: writeLine ( "-- create audit table --" ) ; writeLine ( "CREATE TABLE " + table . name + "_AUD" ) ; writeLine ( "(" ) ; writeLine ( "ID int NOT NULL," ) ; writeLine ( "REV int NOT NULL," ) ; writeLine ( "REVTYPE smallint NOT NULL," ) ; for ( Column column : table . columns ) { writeLine ( column . name + " " + getOracleType ( column . dataType ) + " NULL," ) ; } writeLine ( "CONSTRAINT PK_" + table . name + "_AUD PRIMARY KEY (ID, REV)," ) ; writeLine ( "CONSTRAINT FK_" + table . name + "_AUD FOREIGN KEY (REV)" ) ; writeLine ( "REFERENCES AUDITENTITY (ID)" ) ; writeLine ( ") TABLESPACE " + table . myPackage . model . project . databaseName + "_AUD" ) ; writeLine ( "/" ) ; skipLine ( ) ; writeLine ( "CREATE INDEX FK_" + table . name + "_AUD ON " + this . table . name + "_AUD(REV)" ) ; writeLine ( "/" ) ; skipLine ( ) ;


signature:
public class CodeGeneratorLauncher { /** * main method to be executed
 * @ param args
 * 0 - > the workspace folder where the " data - model " folder will be
 * detected */
public static void main ( String [ ] args ) { } }

implementation: if ( args . length < 1 ) { throw new IllegalArgumentException ( "Path is Mandatory" ) ; } String folderPath = args [ 0 ] ; try ( FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext ( "classpath:applicationContext-generator-bash.xml" ) ; ) { logger . info ( "Context loaded" ) ; Project project ; try { logger . info ( "start loading project" ) ; ProjectMetaDataService projectMetaDataService = appContext . getBean ( ProjectMetaDataService . class ) ; ProjectLoader projectLoader = appContext . getBean ( ProjectLoader . class ) ; ProjectMetaData projectMetaData = projectMetaDataService . loadProjectMetaData ( folderPath ) ; ProjectValidationReport report = projectMetaDataService . validate ( projectMetaData ) ; ValidationPrompter . promptOnValidation ( report ) ; project = projectLoader . loadProject ( projectMetaData ) ; logger . info ( "loading project " + project . projectName + " completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } try { logger . info ( "start executing code writing" ) ; CodeGenerator codeGenerator = appContext . getBean ( CodeGenerator . class ) ; codeGenerator . generateCode ( project ) ; logger . info ( "executing code writing completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } }


signature:
public class PostgresqlTableDefinitionFileWriteCommand { /** * create table */
private void createTable ( ) { } }

implementation: writeLine ( "-- create table --" ) ; writeLine ( "CREATE TABLE " + table . name ) ; writeLine ( "(" ) ; write ( "id " + getPostgresqlType ( table . idType ) ) ; for ( Column column : table . columns ) { writeLine ( "," ) ; write ( column . name + " " + getPostgresqlType ( column . dataType ) ) ; if ( column . nullable ) { write ( " NULL" ) ; } else { write ( " NOT NULL" ) ; } } skipLine ( ) ; writeLine ( ");" ) ; writeLine ( "/" ) ; skipLine ( ) ; writeLine ( "ALTER TABLE " + table . name + " ADD CONSTRAINT PK_" + table . name + " PRIMARY KEY (ID);" ) ; writeLine ( "/" ) ; skipLine ( ) ; if ( table . idGeneratorType . equals ( IdGeneratorType . SEQUENCE ) ) { writeLine ( "-- create sequence --" ) ; writeLine ( "CREATE SEQUENCE " + sequenceName ) ; writeLine ( "INCREMENT 1" ) ; writeLine ( "MINVALUE 0" ) ; writeLine ( "MAXVALUE 9223372036854775807" ) ; writeLine ( "START 0" ) ; writeLine ( "CACHE 1;" ) ; writeLine ( "/" ) ; skipLine ( ) ; }


signature:
public class PostgresqlTableDefinitionFileWriteCommand { /** * create constraints */
private void createConstraints ( ) { } }

implementation: if ( table . cardinality > 0 ) { write ( "ALTER TABLE " + table . name + " ADD CONSTRAINT UC_" + table . name + " UNIQUE (" + this . table . columns . get ( 0 ) . name ) ; for ( int i = 1 ; i < this . table . cardinality ; i ++ ) { write ( "," + this . table . columns . get ( i ) . name ) ; } writeLine ( ");" ) ; writeLine ( "/" ) ; skipLine ( ) ; } for ( UniqueConstraint uniqueConstraint : table . uniqueConstraints ) { write ( "ALTER TABLE " + table . name + " ADD CONSTRAINT UC_" + uniqueConstraint . name + " UNIQUE (" + uniqueConstraint . columns . get ( 0 ) . name ) ; for ( int i = 1 ; i < uniqueConstraint . columns . size ( ) ; i ++ ) { write ( "," + uniqueConstraint . columns . get ( i ) . name ) ; } writeLine ( ");" ) ; writeLine ( "/" ) ; skipLine ( ) ; }


signature:
public class PostgresqlTableDefinitionFileWriteCommand { /** * create audit table */
private void createAuditTable ( ) { } }

implementation: writeLine ( "-- table d'audit des elements --" ) ; writeLine ( "CREATE TABLE " + table . name + "_aud" ) ; writeLine ( "(" ) ; writeLine ( "id integer NOT NULL," ) ; writeLine ( "rev integer NOT NULL," ) ; writeLine ( "revtype smallint NOT NULL," ) ; for ( Column column : table . columns ) { writeLine ( column . name + " " + getPostgresqlType ( column . dataType ) + " NULL," ) ; } writeLine ( "CONSTRAINT " + table . name + "_aud_pkey PRIMARY KEY (id, rev)," ) ; writeLine ( "CONSTRAINT " + table . name + "_aud_rev FOREIGN KEY (rev)" ) ; writeLine ( "REFERENCES auditentity (id) MATCH SIMPLE" ) ; writeLine ( "ON UPDATE NO ACTION ON DELETE NO ACTION" ) ; writeLine ( ")" ) ; writeLine ( ";" ) ; skipLine ( ) ;


signature:
public class SingleFileWriteCommand { /** * ( non - Javadoc )
 * @ see com . skeleton . generator . bl . command . file . interfaces . FileWriteCommand # execute ( ) */
@ Override public void execute ( ) throws IOException { } }

implementation: Path folderPath = Paths . get ( folderName ) ; if ( ! Files . exists ( folderPath ) ) { Files . createDirectories ( folderPath ) ; } writeContent ( ) ; try ( BufferedWriter fileWriter = Files . newBufferedWriter ( filePath , fileType . getEncoding ( ) ) ; ) { fileWriter . write ( writer . toString ( ) ) ; fileWriter . flush ( ) ; }


signature:
public class SingleFileWriteCommand { /** * extract non generated content from a file to keep it after next generation
 * @ return
 * @ throws IOException */
private final String getNotOverridableContent ( ) throws IOException { } }

implementation: if ( Files . exists ( filePath ) ) { List < String > lines = Files . readAllLines ( filePath , fileType . getEncoding ( ) ) ; boolean isNotOverridable = false ; StringWriter notOverridableContentWriter = new StringWriter ( ) ; for ( String line : lines ) { if ( line . contains ( fileType . getSpecificCodeStartMark ( ) ) ) { isNotOverridable = true ; } else if ( line . contains ( fileType . getSpecificCodeEndMark ( ) ) ) { isNotOverridable = false ; } else { if ( isNotOverridable ) { notOverridableContentWriter . append ( line + SKIP_LINE ) ; } } } return notOverridableContentWriter . toString ( ) ; } return "" ;


signature:
public class SingleFileWriteCommand { /** * appends non generated content to be kept at next generation
 * @ throws IOException */
protected final void writeNotOverridableContent ( ) throws IOException { } }

implementation: String content = getNotOverridableContent ( ) ; writeLine ( fileType . getSpecificCodeStartMark ( ) ) ; write ( content ) ; writeLine ( fileType . getSpecificCodeEndMark ( ) ) ;


signature:
public class ProjectInitializerLauncher { /** * main method to be executed
 * @ param args 0 - > the workspace folder where to put the " data - model " folder
 * @ param args 1 - > the domain name of your project ( org . foo for example )
 * @ param args 2 - > your project name ( myproject for example )
 * @ param args 3 - > the skeleton type of your project @ see SkeletonType
 * @ param args 4 - > the database engine to be used @ see DatabaseEngine
 * @ param args 5 - > your database name ( MYDATABASE for example )
 * @ param args 6 - > your database hostname
 * @ param args 7 - > your database port
 * @ param args 8 - > your database connection username
 * @ param args 9 - > your database connection password
 * @ param args 10 - > a boolean string representation ( True / False ) to indicate whereas you want to activate hibernate auditing functionnality or not ( envers ) */
public static void main ( String [ ] args ) { } }

implementation: try ( FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext ( "classpath:applicationContext-generator-bash.xml" ) ; ) { logger . info ( "Context loaded" ) ; ProjectMetaData projectMetaData = buildProjectMetaData ( args ) ; Project project ; CodeGenerator codeGenerator = appContext . getBean ( CodeGenerator . class ) ; try { logger . info ( "start loading project" ) ; ProjectLoader projectLoader = appContext . getBean ( ProjectLoader . class ) ; project = projectLoader . loadProject ( projectMetaData ) ; logger . info ( "loading project " + project . projectName + " completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } try { logger . info ( "start persisting project" ) ; ProjectMetaDataService projectMetaDataService = appContext . getBean ( ProjectMetaDataService . class ) ; projectMetaDataService . initProjectMetaData ( projectMetaData ) ; logger . info ( "persisting project completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } try { logger . info ( "start copying resources" ) ; codeGenerator . initResources ( project ) ; logger . info ( "copying resources completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } try { logger . info ( "start writing configuration" ) ; codeGenerator . initConfiguration ( project ) ; logger . info ( "writing configuration completed" ) ; } catch ( Exception e ) { logger . error ( "failed" , e ) ; return ; } }


signature:
public class Model { /** * run through all the tables until it is found
 * @ param tableName
 * @ return
 * @ throws TableNotFoundException if no table with the corresponding name is found */
public Table findTable ( String tableName ) { } }

implementation: if ( tableName == null ) { return null ; } if ( tableName . isEmpty ( ) ) { return null ; } for ( Package myPackage : this . packages ) { for ( Table table : myPackage . tables ) { if ( table . originalName . equals ( tableName ) ) { return table ; } } } throw new TableNotFoundException ( "Invalid table reference : " + tableName ) ;


signature:
public class Model { /** * run through all the beans until it is found
 * @ param tableOriginalName the original table name
 * @ return
 * @ throws BeanNotFoundException if no bean which associated table has the corresponding name */
public Bean findBean ( String tableOriginalName ) { } }

implementation: for ( Package myPackage : this . packages ) { for ( Bean bean : myPackage . beans ) { if ( bean . table . originalName . equals ( tableOriginalName ) ) { return bean ; } } } throw new BeanNotFoundException ( "invalid table reference : " + tableOriginalName ) ;


signature:
public class JavaClassNaming { /** * converts a table name to the corresponding class name < br / >
 * java conventions are used */
public static String getClassName ( String tableName ) { } }

implementation: String [ ] elements = tableName . toLowerCase ( ) . split ( DATABASE_NAMING_SEPARATOR ) ; String result = "" ; for ( int i = 0 ; i < elements . length ; i ++ ) { elements [ i ] = elements [ i ] . substring ( 0 , 1 ) . toUpperCase ( ) + elements [ i ] . substring ( 1 , elements [ i ] . length ( ) ) ; result = result + elements [ i ] ; } return result ;


signature:
public class CsvFileParserImpl { /** * ( non - Javadoc )
 * @ see com . skeleton . generator . repository . dao . interfaces . MetaDataFileManager # readMataDataFile ( java . lang . String ) */
@ Override public CsvFile readData ( String filePath ) throws IOException , InvalidFileException { } }

implementation: Path path = Paths . get ( filePath ) ; List < Object [ ] > tokensList = new ArrayList < Object [ ] > ( ) ; try ( BufferedReader reader = Files . newBufferedReader ( path , charset ) ; ) { String line = null ; while ( ! StringUtils . isEmpty ( line = reader . readLine ( ) ) ) { String [ ] tokens = line . split ( separator , - 1 ) ; tokensList . add ( tokens ) ; } } CsvFile result = new CsvFile ( ) ; result . setData ( tokensList ) ; return result ;


signature:
public class JavaViewPropertiesFactory { /** * get the list of properties that will be used in bean views to show
 * references to other beans
 * @ return */
public List < ViewProperty > getReferenceProperties ( Bean bean ) { } }

implementation: List < ViewProperty > result = new ArrayList < > ( ) ; for ( int i = 0 ; i < bean . cardinality ; i ++ ) { Property property = bean . properties . get ( i ) ; result . addAll ( property . viewProperties ) ; } return result ;


signature:
public class JavaViewPropertiesFactory { /** * get the list of properties that will be available in a view bean < br >
 * Excludes a field name . Usefull for handling one to many views where we want to exclude reference to parent bean in a view */
private List < ViewProperty > getViewPropertiesExcludingField ( Bean bean , String excludedFieldName ) { } }

implementation: List < ViewProperty > result = new ArrayList < > ( ) ; for ( Property property : bean . properties ) { if ( ! property . relation . isComponentLink ( ) && ! property . name . equals ( excludedFieldName ) ) { result . addAll ( property . viewProperties ) ; } } return result ;


signature:
public class JavaViewPropertiesFactory { /** * get the list of properties that will be available in a basic view bean
 * @ return */
private List < ViewProperty > getVisibleProperties ( OneToMany oneToMany ) { } }

implementation: return getViewPropertiesExcludingField ( oneToMany . referenceBean , oneToMany . referenceProperty . name ) ;


signature:
public class XAbstractProcessor { /** * { @ inheritDoc } */
@ Override public synchronized void init ( ProcessingEnvironment processingEnv ) { } }

implementation: super . init ( processingEnv ) ; messager = processingEnv . getMessager ( ) ; types = processingEnv . getTypeUtils ( ) ; elements = processingEnv . getElementUtils ( ) ; filer = processingEnv . getFiler ( ) ; isDebug = processingEnv . getOptions ( ) . containsKey ( "debug" ) ; error = new Log ( Kind . ERROR , true ) ; warning = new Log ( Kind . WARNING , true ) ; debug = new Log ( Kind . NOTE , isDebug ) ;


signature:
public class XAbstractProcessor { /** * Use { @ link # processActual ( Set , RoundEnvironment ) } */
@ Override public final boolean process ( Set < ? extends TypeElement > annotations , RoundEnvironment roundEnv ) { } }

implementation: handleAssert ( ( ) -> processActual ( annotations , roundEnv ) ) ; return false ;


signature:
public class XAbstractProcessor { /** * Override this method to do something for { @ link AssertException } . < br >
 * The default behavior is log the message as error if present .
 * @ param task task who will throw AssertException */
protected void handleAssert ( Runnable task ) { } }

implementation: try { task . run ( ) ; } catch ( AssertException e ) { if ( e . getMessage ( ) != null && ! e . getMessage ( ) . isEmpty ( ) ) { error ( ) . log ( e . getMessage ( ) ) ; } }


signature:
public class XAbstractProcessor { /** * If the processor class is annotated with { @ link SupportedAnnotation } or
 * { @ link SupportedAnnotationTypes } , return an unmodifiable set with the same
 * set of strings as the annotation . If the class is not so annotated , an
 * empty set is returned . */
@ Override public Set < String > getSupportedAnnotationTypes ( ) { } }

implementation:
Set < String > set = new HashSet < > ( ) ; // Analyze @ SupportedAnnotationTypes
SupportedAnnotationTypes sat = this . getClass ( ) . getAnnotation ( SupportedAnnotationTypes . class ) ; if ( sat != null ) { Arrays . stream ( sat . value ( ) ) . forEach ( set :: add ) ; } // Analyze @ SupportedAnnotation
SupportedAnnotation sa = this . getClass ( ) . getAnnotation ( SupportedAnnotation . class ) ; if ( sa != null ) { Arrays . stream ( sa . value ( ) ) . map ( Class :: getCanonicalName ) . forEach ( set :: add ) ; } if ( set . isEmpty ( ) && isInitialized ( ) ) { debug ( ) . log ( "No SupportedAnnotationTypes annotation found on " + this . getClass ( ) . getName ( ) + ", returning an empty set." ) ; } return Collections . unmodifiableSet ( set ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is greater than { @ code
 * in _ lower } ( named { @ code lower _ name } ) . < / p >
 * @ param x The checked value
 * @ param in _ lower The lower bound
 * @ param x _ name The name of the checked value
 * @ param lower _ name The name of the lower bound
 * @ return x
 * @ since 2.0.0 */
public static long checkGreaterLong ( final long x , final String x_name , final long in_lower , final String lower_name ) { } }

implementation: Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( lower_name , "Lower bound name" ) ; if ( x > in_lower ) { return x ; } @ SuppressWarnings ( "boxing" ) final var message = String . format ( "%s (%d) <= %s (%d)" , x_name , x , lower_name , in_lower ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is greater than { @ code
 * in _ lower } ( named { @ code lower _ name } ) . < / p >
 * @ param x The checked value
 * @ param in _ lower The lower bound
 * @ param x _ name The name of the checked value
 * @ param lower _ name The name of the lower bound
 * @ return x */
public static BigInteger checkGreaterBig ( final BigInteger x , final String x_name , final BigInteger in_lower , final String lower_name ) { } }

implementation: Objects . requireNonNull ( x , "Value" ) ; Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( in_lower , "Lower" ) ; Objects . requireNonNull ( lower_name , "Lower bound name" ) ; if ( x . compareTo ( in_lower ) > 0 ) { return x ; } final var message = String . format ( "%s (%s) <= %s (%s)" , x_name , x , lower_name , in_lower ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is included in the given
 * range { @ code range } ( named { @ code range _ name } ) . < / p >
 * @ param x The checked value
 * @ param x _ name The name of the checked value
 * @ param range The inclusive range
 * @ param range _ name The name of the inclusive range
 * @ return x
 * @ since 2.0.0 */
public static long checkIncludedInLong ( final long x , final String x_name , final RangeInclusiveL range , final String range_name ) { } }

implementation: Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( range , "Range" ) ; Objects . requireNonNull ( range_name , "Range name" ) ; if ( range . includesValue ( x ) ) { return x ; } final var message = String . format ( "%s <= %s (%s) <= %s (%s) == false" , Long . valueOf ( range . lower ( ) ) , x_name , Long . valueOf ( x ) , Long . valueOf ( range . upper ( ) ) , range_name ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is included in the given
 * range { @ code range } ( named { @ code range _ name } ) . < / p >
 * @ param x The checked value
 * @ param x _ name The name of the checked value
 * @ param range The inclusive range
 * @ param range _ name The name of the inclusive range
 * @ return x
 * @ since 2.0.0 */
public static int checkIncludedInInteger ( final int x , final String x_name , final RangeInclusiveI range , final String range_name ) { } }

implementation: Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( range , "Range" ) ; Objects . requireNonNull ( range_name , "Range name" ) ; if ( range . includesValue ( x ) ) { return x ; } final var message = String . format ( "%s <= %s (%s) <= %s (%s) == false" , Integer . valueOf ( range . lower ( ) ) , x_name , Integer . valueOf ( x ) , Integer . valueOf ( range . upper ( ) ) , range_name ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is included in the given
 * range { @ code range } ( named { @ code range _ name } ) . < / p >
 * @ param x The checked value
 * @ param x _ name The name of the checked value
 * @ param range The inclusive range
 * @ param range _ name The name of the inclusive range
 * @ return x */
public static BigInteger checkIncludedInBig ( final BigInteger x , final String x_name , final RangeInclusiveB range , final String range_name ) { } }

implementation: Objects . requireNonNull ( x , "Value" ) ; Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( range , "Range" ) ; Objects . requireNonNull ( range_name , "Range name" ) ; if ( range . includesValue ( x ) ) { return x ; } final var message = String . format ( "%s <= %s (%s) <= %s (%s) == false" , range . lower ( ) , x_name , x , range . upper ( ) , range_name ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is less than { @ code
 * in _ upper } ( named { @ code upper _ name } ) . < / p >
 * @ param x The checked value
 * @ param in _ upper The upper bound
 * @ param x _ name The name of the checked value
 * @ param upper _ name The name of the upper bound
 * @ return x
 * @ since 2.0.0 */
public static long checkLessLong ( final long x , final String x_name , final long in_upper , final String upper_name ) { } }

implementation: Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( upper_name , "Upper bound name" ) ; if ( x < in_upper ) { return x ; } @ SuppressWarnings ( "boxing" ) final var message = String . format ( "%s (%d) >= %s (%d)" , x_name , x , upper_name , in_upper ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code x } ( named { @ code x _ name } ) is less than or equal to
 * { @ code in _ upper } ( named { @ code upper _ name } ) . < / p >
 * @ param x The checked value
 * @ param in _ upper The upper bound
 * @ param x _ name The name of the checked value
 * @ param upper _ name The name of the upper bound
 * @ return x */
public static BigInteger checkLessEqualBig ( final BigInteger x , final String x_name , final BigInteger in_upper , final String upper_name ) { } }

implementation: Objects . requireNonNull ( x , "Value" ) ; Objects . requireNonNull ( x_name , "Value name" ) ; Objects . requireNonNull ( in_upper , "Upper" ) ; Objects . requireNonNull ( upper_name , "Upper bound name" ) ; if ( x . compareTo ( in_upper ) <= 0 ) { return x ; } final var message = String . format ( "%s (%s) > %s (%s)" , x_name , x , upper_name , in_upper ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code inner } ( named { @ code inner _ name } ) is included in the
 * given range { @ code outer } ( named { @ code outer _ name } ) . < / p >
 * @ param inner The checked range
 * @ param inner _ name The name of the checked range
 * @ param outer The outer range
 * @ param outer _ name The name of the outer range
 * @ return inner
 * @ since 2.0.0 */
public static RangeInclusiveL checkRangeIncludedInLong ( final RangeInclusiveL inner , final String inner_name , final RangeInclusiveL outer , final String outer_name ) { } }

implementation: Objects . requireNonNull ( inner , "Inner range" ) ; Objects . requireNonNull ( inner_name , "Inner range name" ) ; Objects . requireNonNull ( outer , "Outer range" ) ; Objects . requireNonNull ( outer_name , "Outer range name" ) ; if ( inner . isIncludedIn ( outer ) ) { return inner ; } final var message = String . format ( "Inner range %s (%s) not included in outer range %s (%s)" , inner_name , inner , outer_name , outer ) ; throw new RangeCheckException ( message ) ;


signature:
public class RangeCheck { /** * < p > Assert that { @ code inner } ( named { @ code inner _ name } ) is included in the
 * given range { @ code outer } ( named { @ code outer _ name } ) . < / p >
 * @ param inner The checked range
 * @ param inner _ name The name of the checked range
 * @ param outer The outer range
 * @ param outer _ name The name of the outer range
 * @ return inner
 * @ since 2.0.0 */
public static RangeInclusiveI checkRangeIncludedInInteger ( final RangeInclusiveI inner , final String inner_name , final RangeInclusiveI outer , final String outer_name ) { } }


signature:
public class RangeCheck { /** * < p > Assert that { @ code inner } ( named { @ code inner _ name } ) is included in the
 * given range { @ code outer } ( named { @ code outer _ name } ) . < / p >
 * @ param inner The checked range
 * @ param inner _ name The name of the checked range
 * @ param outer The outer range
 * @ param outer _ name The name of the outer range
 * @ return inner */
public static RangeInclusiveB checkRangeIncludedInBig ( final RangeInclusiveB inner , final String inner_name , final RangeInclusiveB outer , final String outer_name ) { } }


signature:
public class VMWebService { /** * Web service operation
 * @ param username Username
 * @ param password Password
 * @ return User with provided credentials or null if invalid .
 * @ throws com . validation . manager . core . VMException */
@ WebMethod ( operationName = "getVMUser" ) public VmUser getVMUser ( @ WebParam ( name = "user" ) final String username , @ WebParam ( name = "pass" ) final String password ) throws VMException { } }

implementation: VmUser user = isValidUser ( username , password ) ; if ( user == null ) { throw new VMException ( "Invalid username and/or password!" ) ; } return user ;


signature:
public class VMWebService { /** * Web service operation
 * @ param project Project to retrieve
 * @ param user User requesting the information .
 * @ return Update project .
 * @ throws com . validation . manager . core . VMException */
@ WebMethod ( operationName = "getProject" ) public Project getProject ( @ WebParam ( name = "project" ) final Project project , @ WebParam ( name = "user" ) final VmUser user ) throws VMException { } }

implementation: Project p = null ; if ( isValidUser ( user . getUsername ( ) , user . getPassword ( ) ) != null ) { p = new ProjectServer ( project ) . getEntity ( ) ; } return p ;


signature:
public class VMWebService { /** * Web service operation
 * @ param user User requesting the information .
 * @ return List of root projects .
 * @ throws com . validation . manager . core . VMException */
@ WebMethod ( operationName = "getRootProjects" ) public List < Project > getRootProjects ( @ WebParam ( name = "user" ) final VmUser user ) throws VMException { } }

implementation: List < Project > projects = new ArrayList < > ( ) ; if ( isValidUser ( user . getUsername ( ) , user . getPassword ( ) ) != null ) { ProjectJpaController controller = new ProjectJpaController ( DataBaseManager . getEntityManagerFactory ( ) ) ; controller . findProjectEntities ( ) . stream ( ) . filter ( ( p ) -> ( p . getParentProjectId ( ) == null ) ) . forEachOrdered ( ( p ) -> { projects . add ( p ) ; } ) ;


signature:
public class Versionable { /** * Increase major version . */
public void increaseMajorVersion ( ) { } }

implementation: try { updateInternalHistory ( ) ; setMajorVersion ( getMajorVersion ( ) + 1 ) ; setMidVersion ( 0 ) ; setMinorVersion ( 0 ) ; updateInternalHistory ( ) ; } catch ( Exception ex ) { Exceptions . printStackTrace ( ex ) ; }


signature:
public class Versionable { /** * Increase major version . */
public void increaseMidVersion ( ) { } }

implementation: try { updateInternalHistory ( ) ; setMidVersion ( getMidVersion ( ) + 1 ) ; setMinorVersion ( 0 ) ; updateInternalHistory ( ) ; } catch ( Exception ex ) { Exceptions . printStackTrace ( ex ) ; }


signature:
public class Versionable { /** * Increase minor is done by default when updating a record .
 * @ param target Target of the update .
 * @ param source Source of the update */
public void update ( Versionable target , Versionable source ) { } }

implementation: target . setDirty ( source . getDirty ( ) ) ; target . setMajorVersion ( source . getMajorVersion ( ) ) ; target . setMidVersion ( source . getMidVersion ( ) ) ; target . setMinorVersion ( source . getMinorVersion ( ) ) ; target . setModifierId ( source . getModifierId ( ) ) ; target . setReason ( source . getReason ( ) ) ; target . setModificationTime ( source . getModificationTime ( ) ) ; target . setHistoryList ( source . getHistoryList ( ) ) ; try { target . updateHistory ( ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , ex . getLocalizedMessage ( ) , ex ) ; }


signature:
public class Versionable { /** * Add history to this entity .
 * @ param history History to add . */
public void addHistory ( History history ) { } }

implementation: if ( getHistoryList ( ) == null ) { setHistoryList ( new ArrayList < > ( ) ) ; } getHistoryList ( ) . add ( history ) ;


signature:
public class Tool { /** * Builder of unique id ' s for items .
 * @ param item Item to get the id from
 * @ param postfix postfix to add to the key
 * @ param usePrefix Use the prefix ?
 * @ return key for the object */
public static Object buildId ( Object item , Object postfix , boolean usePrefix ) { } }

implementation: Object pf ; Object key = null ; String prefix ; if ( postfix == null ) { pf = "" ; } else { pf = "-" + postfix ; } if ( item instanceof TestCase ) { TestCase tc = ( TestCase ) item ; prefix = "tc" ; key = ( usePrefix ? prefix + "-" : "" ) + tc . getTestCasePK ( ) . getId ( ) + "-" + tc . getTestCasePK ( ) . getTestCaseTypeId ( ) + pf ; } else if ( item instanceof Requirement ) { Requirement r = ( Requirement ) item ; key = r . getUniqueId ( ) + pf ; } else if ( item instanceof ExecutionStep ) { ExecutionStep es = ( ExecutionStep ) item ; prefix = "es" ; key = ( usePrefix ? prefix + "-" : "" ) + es . getExecutionStepPK ( ) . getStepId ( ) + "-" + es . getExecutionStepPK ( ) . getStepTestCaseId ( ) + "-" + es . getExecutionStepPK ( ) . getTestCaseExecutionId ( ) + pf ; } else if ( item instanceof Issue ) { Issue issue = ( Issue ) item ; prefix = "issue" ; key = ( usePrefix ? prefix + "-" : "" ) + issue . getIssuePK ( ) . getId ( ) + pf ; } else if ( item instanceof TestCaseExecution ) { TestCaseExecution tce = ( TestCaseExecution ) item ; prefix = "tce" ; key = ( usePrefix ? prefix + "-" : "" ) + tce . getId ( ) + pf ; } return key ;


signature:
public class Tool { /** * Builder of unique id ' s for items .
 * @ param item Item to get the id from
 * @ param postfix postfix to add to the key
 * @ return key for the object */
public static Object buildId ( Object item , Object postfix ) { } }

implementation: return buildId ( item , postfix , true ) ;


signature:
public class JPAEclipseLinkSessionCustomizer { /** * Get a dataSource connection and set it on the session with
 * lookupType = STRING _ LOOKUP
 * @ param session Session
 * @ throws java . lang . Exception If an error occurs . */
@ Override public void customize ( Session session ) throws Exception { } }

implementation:
JNDIConnector connector ; // Initialize session customizer
DataSource dataSource ; try { Context context = new InitialContext ( ) ; if ( null == context ) { throw new VMException ( "Context is null" ) ; } connector = ( JNDIConnector ) session . getLogin ( ) . getConnector ( ) ; // possible CCE
// Lookup this new dataSource
dataSource = ( DataSource ) context . lookup ( JNDI_DATASOURCE_NAME ) ; connector . setDataSource ( dataSource ) ; // Change from COMPOSITE _ NAME _ LOOKUP to STRING _ LOOKUP
// Note : if both jta and non - jta elements exist this will only change the first one - and may still result in the COMPOSITE _ NAME _ LOOKUP being set
// Make sure only jta - data - source is in persistence . xml with no non - jta - data - source property set
connector . setLookupType ( JNDIConnector . STRING_LOOKUP ) ; // if you are specifying both JTA and non - JTA in your persistence . xml then set both connectors to be safe
JNDIConnector writeConnector = ( JNDIConnector ) session . getLogin ( ) . getConnector ( ) ; writeConnector . setLookupType ( JNDIConnector . STRING_LOOKUP ) ; JNDIConnector readConnector = ( JNDIConnector ) ( ( DatabaseLogin ) ( ( ServerSession ) session ) . getReadConnectionPool ( ) . getLogin ( ) ) . getConnector ( ) ; readConnector . setLookupType ( JNDIConnector . STRING_LOOKUP ) ; // Set the new connection on the session
session . getLogin ( ) . setConnector ( connector ) ; } catch ( Exception e ) { LOG . log ( Level . SEVERE , JNDI_DATASOURCE_NAME , e ) ; }


signature:
public class RequirementSpecServer { /** * Add a node to this spec .
 * This is equivalent to a section in a document .
 * Although database might allow a requirement being on different nodes ,
 * this constraint is imposed via software .
 * @ param name name of new node
 * @ param description description of node
 * @ param scope scope of node
 * @ return Created node .
 * @ throws Exception if errors creating the node occur */
public RequirementSpecNodeServer addSpecNode ( String name , String description , String scope ) throws Exception { } }

implementation: RequirementSpecNodeServer sns = new RequirementSpecNodeServer ( new RequirementSpecJpaController ( getEntityManagerFactory ( ) ) . findRequirementSpec ( getRequirementSpecPK ( ) ) , name , description , scope ) ; sns . write2DB ( ) ; getRequirementSpecNodeList ( ) . add ( new RequirementSpecNodeJpaController ( getEntityManagerFactory ( ) ) . findRequirementSpecNode ( sns . getRequirementSpecNodePK ( ) ) ) ; write2DB ( ) ; return sns ;


signature:
public class SetCharacterEncodingFilter { /** * Select and set ( if specified ) the character encoding to be used to
 * interpret request parameters for this request .
 * @ param request The servlet request we are processing
 * @ param response The servlet response we are creating
 * @ param chain The filter chain we are processing
 * @ exception IOException if an input / output error occurs
 * @ exception ServletException if a servlet error occurs */
@ Override public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { } }

implementation:
// Conditionally select and set the character encoding to be used
if ( ignore || ( request . getCharacterEncoding ( ) == null ) ) { String tempEncoding = selectEncoding ( request ) ; if ( tempEncoding != null ) { request . setCharacterEncoding ( tempEncoding ) ; } } // Pass control on to the next filter
chain . doFilter ( request , response ) ;


signature:
public class VMIdServer { /** * write to db */
@ Override public int write2DB ( ) throws VMException { } }

implementation: try { VmIdJpaController controller = new VmIdJpaController ( getEntityManagerFactory ( ) ) ; VmId vmId ; if ( getId ( ) == null ) { vmId = new VmId ( ) ; update ( vmId , this ) ; controller . create ( vmId ) ; setId ( vmId . getId ( ) ) ; } else { vmId = getEntity ( ) ; update ( vmId , this ) ; controller . edit ( vmId ) ; } update ( ) ; return getId ( ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , null , ex ) ; throw new VMException ( ex ) ; }


signature:
public class IssueTypeServer { /** * Get an Issue Type by name .
 * @ param typename name to search for
 * @ return Issue Type for the specified name or null if not found . */
public static IssueType getType ( String typename ) { } }

implementation: IssueType result = null ; for ( IssueType type : new IssueTypeJpaController ( DataBaseManager . getEntityManagerFactory ( ) ) . findIssueTypeEntities ( ) ) { if ( type . getTypeName ( ) . equals ( typename ) ) { result = type ; break ; } } return result ;


signature:
public class VMSettingServer { /** * Get setting from database
 * @ param s Setting name to retrieve
 * @ return Setting with the specified name . */
@ SuppressWarnings ( "unchecked" ) public static VmSetting getSetting ( String s ) { } }

implementation: PARAMETERS . clear ( ) ; PARAMETERS . put ( "setting" , s ) ; result = namedQuery ( "VmSetting.findBySetting" , PARAMETERS ) ; if ( result . isEmpty ( ) ) { return null ; } else { return ( VmSetting ) result . get ( 0 ) ; }


signature:
public class DataEntryServer { /** * Create a default string field
 * @ param name Field name
 * @ param expected Expected result .
 * @ param matchCase True if answer must match the case of the expected
 * result . False otherwise .
 * @ return DataEntry . The entry is not persisted into the database yet . */
public static DataEntry getStringField ( String name , String expected , boolean matchCase ) { } }

implementation: DataEntry de = new DataEntry ( ) ; DataEntryType det = DataEntryTypeServer . getType ( "type.string.name" ) ; de . setEntryName ( name ) ; de . setDataEntryPropertyList ( getDefaultProperties ( det ) ) ; de . setDataEntryType ( det ) ; if ( expected != null ) { getProperty ( de , "property.expected.result" ) . setPropertyValue ( expected ) ; getProperty ( de , "property.match.case" ) . setPropertyValue ( matchCase ? "true" : "false" ) ; } return de ;


signature:
public class DataEntryServer { /** * Create a boolean field
 * @ param name Field name
 * @ return DataEntry . The entry is not persisted into the database yet . */
public static DataEntry getBooleanField ( String name ) { } }

implementation: DataEntry de = new DataEntry ( ) ; de . setEntryName ( name ) ; DataEntryType det = DataEntryTypeServer . getType ( "type.boolean.name" ) ; de . setDataEntryPropertyList ( getDefaultProperties ( det ) ) ; de . setDataEntryType ( det ) ; return de ;


signature:
public class DataEntryServer { /** * Create a numeric field .
 * @ param name Field name
 * @ param min Minimum value . Set as null for no limit .
 * @ param max Maximum value . Set as null for no limit .
 * @ return DataEntry . The entry is not persisted into the database yet . */
public static DataEntry getNumericField ( String name , Float min , Float max ) { } }

implementation:
DataEntry de = new DataEntry ( ) ; de . setEntryName ( name ) ; DataEntryType det = DataEntryTypeServer . getType ( "type.numeric.name" ) ; de . setDataEntryPropertyList ( getDefaultProperties ( det ) ) ; de . setDataEntryType ( det ) ; for ( DataEntryProperty dep : de . getDataEntryPropertyList ( ) ) { if ( dep . getPropertyName ( ) . equals ( "property.min" ) && min != null ) { // Set minimum
dep . setPropertyValue ( min . toString ( ) ) ; } if ( dep . getPropertyName ( ) . equals ( "property.max" ) && max != null ) { // Set minimum
dep . setPropertyValue ( max . toString ( ) ) ; } } return de ;


signature:
public class WorkflowViewer { /** * Create workflow from database
 * @ param w workflow to create from */
private void displayWorkflow ( Workflow w ) { } }

implementation:
Graph graph = new Graph ( w . getWorkflowName ( ) , Graph . DIGRAPH ) ; nodes . clear ( ) ; // Create the nodes
w . getWorkflowStepList ( ) . forEach ( step -> { addStep ( step , graph ) ; // Now add the links
step . getSourceTransitions ( ) . forEach ( t -> { addStep ( t . getWorkflowStepSource ( ) , graph ) ; addStep ( t . getWorkflowStepTarget ( ) , graph ) ; Subgraph . Edge edge = graph . addEdge ( nodes . get ( t . getWorkflowStepSource ( ) . getWorkflowStepPK ( ) . getId ( ) ) , nodes . get ( t . getWorkflowStepTarget ( ) . getWorkflowStepPK ( ) . getId ( ) ) ) ; edge . setParam ( "label" , TRANSLATOR . translate ( t . getTransitionName ( ) ) ) ; // Workaround https : / / github . com / pontusbostrom / VaadinGraphvizComponent / issues / 9
edge . setDest ( nodes . get ( t . getWorkflowStepTarget ( ) . getWorkflowStepPK ( ) . getId ( ) ) ) ; edges . put ( TRANSLATOR . translate ( t . getTransitionName ( ) ) , new AbstractMap . SimpleEntry < > ( nodes . get ( t . getWorkflowStepSource ( ) . getWorkflowStepPK ( ) . getId ( ) ) , edge ) ) ; } ) ; } ) ; diagram . drawGraph ( graph ) ;


signature:
public class WorkflowViewer { /** * Recreate graph with the edited values */
private void refreshWorkflow ( ) { } }

implementation: Graph graph = new Graph ( ( ( Workflow ) workflows . getValue ( ) ) . getWorkflowName ( ) , Graph . DIGRAPH ) ; nodes . values ( ) . forEach ( node -> { graph . addNode ( node ) ; } ) ; edges . values ( ) . forEach ( edge -> { graph . addEdge ( edge . getKey ( ) , edge . getValue ( ) . getDest ( ) ) ; } ) ; diagram . drawGraph ( graph ) ; selected = null ; updateControls ( ) ;


signature:
public class VaadinUtils { /** * recursively walk the Component true */
private static void walkComponentTree ( Component c , Consumer < Component > visitor ) { } }

implementation: visitor . accept ( c ) ; if ( c instanceof HasComponents ) { for ( Component child : ( ( HasComponents ) c ) ) { walkComponentTree ( child , visitor ) ; } }


signature:
public class FileUploader { /** * Callback method to begin receiving the upload . */
@ Override public OutputStream receiveUpload ( String filename , String MIMEType ) { } }

implementation:
FileOutputStream fos ; // Output stream to write to
try { file = File . createTempFile ( "upload" , filename . substring ( filename . lastIndexOf ( '.' ) ) ) ; // Open the file for writing .
fos = new FileOutputStream ( getFile ( ) ) ; } catch ( FileNotFoundException ex ) { // Error while opening the file . Not reported here .
LOG . log ( Level . SEVERE , null , ex ) ; return null ; } catch ( IOException ex ) { // Error while opening the file . Not reported here .
LOG . log ( Level . SEVERE , null , ex ) ; return null ; } return fos ; // Return the output stream to write to


signature:
public class PersonDetails { /** * Gets the risk of this particular address .
 * @ return the risk factor */
@ Nullable public ResultStrength getAddressRisk ( ) { } }

implementation: if ( addressRisk == null ) { return null ; } return ResultStrength . toEnum ( addressRisk . toLowerCase ( ) ) ;


signature:
public class AbstractFileResolver { /** * Takes an optional descriptor and transforms it to file descriptor .
 * @ param descriptor
 * The descriptor , if < code > null < / code > a new descriptor is created .
 * @ param type
 * The required type .
 * @ param path
 * The path ( to set as file name ) .
 * @ param context
 * The scanner context .
 * @ param < D >
 * The required type .
 * @ return The file descriptor .
 * @ deprecated migrate to
 * { @ link # getOrCreateAs ( String , Class , Function , ScannerContext ) } . */
@ Deprecated protected < D extends FileDescriptor > D toFileDescriptor ( Descriptor descriptor , Class < D > type , String path , ScannerContext context ) { } }

implementation: if ( descriptor == null ) { D result = context . getStore ( ) . create ( type ) ; result . setFileName ( path ) ; return result ; } return migrateOrCast ( descriptor , type , context ) ;


signature:
public class AbstractFileResolver { /** * Get an existing { @ link FileDescriptor } or create a new one . If an existing
 * { @ link FileDescriptor } exists it will be migrated on demand .
 * @ param path
 * The path .
 * @ param type
 * The requested type .
 * @ param existing
 * A { @ link Function } to resolve an existing { @ link FileDescriptor } .
 * @ param context
 * The { @ link ScannerContext } .
 * @ param < D >
 * The requested type .
 * @ return The { @ link FileDescriptor } . */
protected < D extends FileDescriptor > D getOrCreateAs ( String path , Class < D > type , Function < String , FileDescriptor > existing , ScannerContext context ) { } }

implementation: FileDescriptor descriptor = cache . get ( path , p -> { FileDescriptor fileDescriptor = existing . apply ( p ) ; if ( fileDescriptor != null ) { return fileDescriptor ; } fileDescriptor = context . getStore ( ) . create ( type ) ; fileDescriptor . setFileName ( path ) ; return fileDescriptor ; } ) ; return migrateOrCast ( descriptor , type , context ) ;


signature:
public class AbstractFileResolver { /** * Ensures if the given { @ link FileDescriptor } implements the requested type by
 * migrating or just casting it .
 * @ param descriptor
 * The { @ link FileDescriptor } .
 * @ param type
 * The requested type .
 * @ param context
 * The { @ link ScannerContext } .
 * @ param < D >
 * The requested type .
 * @ return The { @ link FileDescriptor } that implements the requested type . */
private < D extends FileDescriptor > D migrateOrCast ( Descriptor descriptor , Class < D > type , ScannerContext context ) { } }

implementation: return type . isAssignableFrom ( descriptor . getClass ( ) ) ? type . cast ( descriptor ) : context . getStore ( ) . addDescriptorType ( descriptor , type ) ;


signature:
public class BlockscoreError { /** * Converts a Retrofit Error into a Blockscore Error .
 * @ param cause the Retrofit error to convert
 * @ return the Blockscore Error */
@ Nullable public static BlockscoreError getBlockscoreError ( @ NotNull final RetrofitError cause ) { } }

implementation: Object rawError = cause . getBodyAs ( BlockscoreError . class ) ; if ( rawError instanceof BlockscoreError ) { return ( BlockscoreError ) rawError ; } else { return null ; }


signature:
public class QuestionSet { /** * Scores a question set .
 * @ param answers the answers to the QuestionSet */
@ NotNull public void score ( @ NotNull final AnswerSet answers ) { } }

implementation: QuestionSet scoredSet = restAdapter . scoreQuestionSet ( getId ( ) , answers ) ; expired = scoredSet . isExpired ( ) ; score = scoredSet . getScore ( ) ;


signature:
public class MD5DigestDelegate { /** * Calculate the MD5 hash sum for the given input stream using the given
 * operation .
 * @ param stream
 * The stream .
 * @ param digestOperation
 * The operation .
 * @ param < D >
 * The MD5 descriptor type .
 * @ return The MD5 descriptor .
 * @ throws IOException
 * If reading the stream fails . */
public < D extends MD5Descriptor > D digest ( InputStream stream , DigestOperation < D > digestOperation ) throws IOException { } }

implementation: DigestInputStream digestInputStream = new DigestInputStream ( stream , md5Digest ) ; D md5Descriptor = digestOperation . execute ( digestInputStream ) ; String md5 = DatatypeConverter . printHexBinary ( md5Digest . digest ( ) ) ; md5Descriptor . setMd5 ( md5 ) ; return md5Descriptor ;