signature:
public class SimpleGMService { /** * { @ inheritDoc } */
@ Override public String execute ( @ Nonnull String command , String ... arguments ) throws GMException , GMServiceException , IOException { } }

implementation: final GMConnection connection = getConnection ( ) ; try { return connection . execute ( command , arguments ) ; } finally { connection . close ( ) ; }


signature:
public class SimpleGMService { /** * { @ inheritDoc } */
@ Override public String execute ( List < String > command ) throws GMException , GMServiceException , IOException { } }

implementation: final GMConnection connection = getConnection ( ) ; try { return connection . execute ( command ) ; } finally { connection . close ( ) ; }


signature:
public class SimpleGMService { /** * { @ inheritDoc }
 * This implementation creates a new instance . */
@ Override @ Nonnull public GMConnection getConnection ( ) throws GMServiceException { } }

implementation: try { return new BasicGMConnection ( factory . getProcess ( ) ) ; } catch ( IOException e ) { throw new GMServiceException ( e . getMessage ( ) , e ) ; }


signature:
public class GMOperation { /** * Limits the number of threads used by the GraphicsMagick process during execution . Note that no validation is
 * made , so ensure that the value is a non - positive integer presumably less than the maximum CPU cores on the host .
 * @ param threadsPerProcess
 * Number of threads to use per process .
 * @ return Builder object for chained options setup . */
public GMOperation limitThreads ( final int threadsPerProcess ) { } }

implementation: final List < String > args = getCmdArgs ( ) ; args . add ( "-limit" ) ; args . add ( "threads" ) ; args . add ( Integer . toString ( threadsPerProcess ) ) ; return this ;


signature:
public class GMOperation { /** * Resize source to desired target dimensions , using default resizing filter algorithm .
 * @ param width
 * Length in pixels of the target image ' s width .
 * @ param height
 * Length in pixels of the target image ' s height .
 * @ param annotations
 * Geometry annotations to define how the { @ code width } and { @ code height } options are to be interpreted .
 * @ return Builder object for chained options setup . */
public GMOperation resize ( final int width , final int height , final Collection < GeometryAnnotation > annotations ) { } }

implementation: final List < String > args = getCmdArgs ( ) ; args . add ( "-resize" ) ; args . add ( resample ( width , height , annotations ) ) ; return this ;


signature:
public class GMOperation { /** * Rotates the image , with empty triangles back - filled using default background color .
 * @ param degrees
 * The angle by which the image should be rotated . Positive numbers indicate clockwise direction ;
 * negative numbers indicate counterclockwise direction .
 * @ param annotation
 * Rotate annotation to define when rotation should happen .
 * @ return Builder object for chained options setup . */
public GMOperation rotate ( final double degrees , final RotationAnnotation annotation ) { } }

implementation: if ( annotation == null ) { throw new IllegalArgumentException ( "Rotation annotation must be defined" ) ; } final List < String > args = getCmdArgs ( ) ; args . add ( "-rotate" ) ; args . add ( String . format ( Locale . ENGLISH , "%.1f%s" , degrees , annotation . asAnnotation ( ) ) ) ; return this ;


signature:
public class GMOperation { /** * Defines the gravity for geometry - based operations . See documentation for more details , as this option works in
 * conjunction with various options in different ways .
 * @ param value
 * Gravity value to use , defining the coordinate system to use .
 * @ return Builder object for chained options setup . */
public GMOperation gravity ( final Gravity value ) { } }

implementation: if ( value == null ) { throw new IllegalArgumentException ( "Gravity value must be defined" ) ; } gravity ( value . toString ( ) ) ; return this ;


signature:
public class GMOperation { /** * Strips out ICC profiles .
 * @ return Builder object for chained options setup . */
public GMOperation stripProfiles ( ) { } }

implementation: final List < String > args = getCmdArgs ( ) ; args . add ( "+profile" ) ; args . add ( "*" ) ; return this ;


signature:
public class GMOperation { /** * Defines font for text overlay .
 * @ param style
 * Text font style ( system - dependent based on installed fonts ) .
 * @ param size
 * Text point size .
 * @ param color
 * Text color , either named or { @ code # RGB } variant .
 * @ return Builder object for chained options setup . */
public GMOperation font ( final String style , final int size , final String color ) { } }

implementation: if ( isBlank ( style ) ) { throw new IllegalArgumentException ( "Text font style must be defined" ) ; } if ( isBlank ( color ) ) { throw new IllegalArgumentException ( "Text font color must be defined" ) ; } font ( style ) ; pointsize ( size ) ; fill ( color ) ; return this ;


signature:
public class GMOperation { /** * Draws text overlay on image with the upper - right corner defined by the { @ code offsetX } and { @ code offsetY }
 * parameters . Note that { @ link # gravity ( Gravity ) } will affect how the offset values are interpreted .
 * @ param text
 * Text to write .
 * @ param offsetX
 * Offset value in the horizontal direction .
 * @ param offsetY
 * Offset value in the vertical direction .
 * @ return Builder object for chained options setup . */
public GMOperation drawText ( final String text , final int offsetX , final int offsetY ) { } }

implementation: if ( isBlank ( text ) ) { throw new IllegalArgumentException ( "Text string must be defined" ) ; } draw ( String . format ( Locale . ENGLISH , "text %d %d '%s'" , offsetX , offsetY , text ) ) ; return this ;


signature:
public class GMOperation { /** * Specifies the source image to convert .
 * @ param file
 * Source image file to convert .
 * @ param width
 * Length in pixels of the source image ' s width ; if { @ code null } or negative , the in - memory size
 * definition is omitted . Optional .
 * @ param height
 * Length in pixels of the source image ' s height ; if { @ code null } or negative , the in - memory size
 * definition is omitted . Optional .
 * @ return Builder object for chained options setup .
 * @ throws IOException
 * when the source file does not exist . */
public GMOperation source ( final File file , @ CheckForNull final Integer width , @ CheckForNull final Integer height ) throws IOException { } }

implementation: if ( file != null && ! file . exists ( ) ) { throw new IOException ( "Source file '" + file + "' does not exist" ) ; } if ( ( width != null ) && ( height != null ) && ( width > 0 ) && ( height > 0 ) ) { size ( width , height ) ; } return addImage ( file ) ;


signature:
public class GMOperation { /** * Add image to operation .
 * @ param file
 * image file to be added .
 * @ return Builder object for chained options setup . */
public GMOperation addImage ( final File file ) { } }

implementation: if ( file == null ) { throw new IllegalArgumentException ( "file must be defined" ) ; } getCmdArgs ( ) . add ( file . getPath ( ) ) ; return this ;


signature:
public class GMOperation { /** * Add option - quality to the GraphicsMagick commandline ( see the documentation of GraphicsMagick for details ) .
 * @ param quality
 * the quality of the image from 0 - 100
 * @ return Builder object for chained options setup */
public GMOperation quality ( double quality ) { } }

implementation: final List < String > args = getCmdArgs ( ) ; args . add ( "-quality" ) ; args . add ( Double . toString ( quality ) ) ; return this ;


signature:
public class HistogramFactory { /** * Time histogram .
 * @ param name The name of the histogram , without prefix and suffix .
 * @ return A histogram for http requests , identified by the given name . Histograms with the same name are shared . */
public @ NotNull Histogram timeSeconds ( @ NotNull String name ) { } }

implementation: return histograms . computeIfAbsent ( "vertx_" + name + "_time_seconds" , key -> register ( Histogram . build ( key , "Processing time in seconds" ) . labelNames ( "local_address" ) . create ( ) ) ) ;


signature:
public class GaugeFactory { /** * HTTP requests gauge .
 * @ param name The name of the gauge , without prefix and suffix .
 * @ return A gauge for http requests , identified by the given name . Gauges with the same name are shared . */
public @ NotNull Gauge httpRequests ( @ NotNull String name ) { } }

implementation: return gauges . computeIfAbsent ( "vertx_" + name + "_requests" , key -> register ( Gauge . build ( key , "HTTP requests number" ) . labelNames ( "local_address" , "method" , "path" , "state" ) . create ( ) ) ) ;


signature:
public class CounterFactory { /** * Bytes counter .
 * @ param name The name of the counter , without prefix and suffix .
 * @ return A counter of bytes for the given name . Counters with the same name are shared . */
public @ NotNull Counter bytes ( @ NotNull String name ) { } }

implementation: return counters . computeIfAbsent ( "vertx_" + name + "_bytes" , key -> register ( Counter . build ( key , "Read/written bytes" ) . labelNames ( "local_address" , "type" ) . create ( ) ) ) ;


signature:
public class Args { /** * Parse a set of arguments and populate the target with the appropriate values .
 * @ param target Either an instance or a class
 * @ param args The arguments you want to parse and populate
 * @ return The list of arguments that were not consumed */
public static List < String > parse ( Object target , String [ ] args ) { } }

implementation:
List < String > arguments = new ArrayList < String > ( ) ; arguments . addAll ( Arrays . asList ( args ) ) ; Class < ? > clazz ; if ( target instanceof Class ) { clazz = ( Class ) target ; } else { clazz = target . getClass ( ) ; try { BeanInfo info = Introspector . getBeanInfo ( clazz ) ; for ( PropertyDescriptor pd : info . getPropertyDescriptors ( ) ) { processProperty ( target , pd , arguments ) ; } } catch ( IntrospectionException e ) { // If its not a JavaBean we ignore it
} } // Check fields of ' target ' class and its superclasses
for ( Class < ? > currentClazz = clazz ; currentClazz != null ; currentClazz = currentClazz . getSuperclass ( ) ) { for ( Field field : currentClazz . getDeclaredFields ( ) ) { processField ( target , field , arguments ) ; } } for ( String argument : arguments ) { if ( argument . startsWith ( "-" ) ) { throw new IllegalArgumentException ( "Invalid argument: " + argument ) ; } } return arguments ;


signature:
public class Args { /** * Generate usage information based on the target annotations .
 * @ param errStream A { @ link java . io . PrintStream } to print the usage information to .
 * @ param target An instance or class . */
public static void usage ( PrintStream errStream , Object target ) { } }

implementation:
Class < ? > clazz ; if ( target instanceof Class ) { clazz = ( Class ) target ; } else { clazz = target . getClass ( ) ; } errStream . println ( "Usage: " + clazz . getName ( ) ) ; for ( Class < ? > currentClazz = clazz ; currentClazz != null ; currentClazz = currentClazz . getSuperclass ( ) ) { for ( Field field : currentClazz . getDeclaredFields ( ) ) { fieldUsage ( errStream , target , field ) ; } } try { BeanInfo info = Introspector . getBeanInfo ( clazz ) ; for ( PropertyDescriptor pd : info . getPropertyDescriptors ( ) ) { propertyUsage ( errStream , target , pd ) ; } } catch ( IntrospectionException e ) { // If its not a JavaBean we ignore it
}


signature:
public class UnitConverter { /** * Extracts and returns the time unit from a string . If the string
 * doesn ' t include a unit , it returns null .
 * @ param timeString the string that contains a time unit
 * @ return the extracted time unit . If the string
 * doesn ' t include a unit , it returns null . */
public static TimeUnit extractTimeUnitFromString ( String timeString ) { } }

implementation: timeString = timeString . toLowerCase ( ) ; if ( timeString . contains ( "minute" ) ) { return TimeUnit . MINUTES ; } else if ( timeString . contains ( "microsecond" ) ) { return TimeUnit . MICROSECONDS ; } else if ( timeString . contains ( "millisecond" ) ) { return TimeUnit . MILLISECONDS ; } else if ( timeString . contains ( "second" ) ) { return TimeUnit . SECONDS ; } else if ( timeString . contains ( "hour" ) ) { return TimeUnit . HOURS ; } else if ( timeString . toLowerCase ( ) . contains ( "day" ) ) { return TimeUnit . DAYS ; } else return null ;


signature:
public class PropertiesArgs { /** * Parse properties instead of String arguments . Any additional arguments need to be passed some other way .
 * This is often used in a second pass when the property filename is passed on the command line . Because of
 * required properties you must be careful to set them all in the property file .
 * @ param target Either an instance or a class
 * @ param arguments The properties that contain the arguments */
public static void parse ( Object target , Properties arguments ) { } }

implementation:
Class clazz ; if ( target instanceof Class ) { clazz = ( Class ) target ; } else { clazz = target . getClass ( ) ; } for ( Field field : clazz . getDeclaredFields ( ) ) { processField ( target , field , arguments ) ; } try { BeanInfo info = Introspector . getBeanInfo ( clazz ) ; for ( PropertyDescriptor pd : info . getPropertyDescriptors ( ) ) { processProperty ( target , pd , arguments ) ; } } catch ( IntrospectionException e ) { // If its not a JavaBean we ignore it
}


signature:
public class Zip { /** * src : http : / / stackoverflow . com / questions / 1399126 / java - util - zip - recreating - directory - structure */
public static void zipDir ( File directory , File zipfile ) throws IOException { } }

implementation: URI base = directory . toURI ( ) ; Deque < File > queue = new LinkedList < File > ( ) ; queue . push ( directory ) ; OutputStream out = new FileOutputStream ( zipfile ) ; Closeable res = out ; try { ZipOutputStream zout = new ZipOutputStream ( out ) ; res = zout ; while ( ! queue . isEmpty ( ) ) { directory = queue . pop ( ) ; for ( File kid : directory . listFiles ( ) ) { String name = base . relativize ( kid . toURI ( ) ) . getPath ( ) ; if ( kid . isDirectory ( ) ) { queue . push ( kid ) ; name = name . endsWith ( "/" ) ? name : name + "/" ; zout . putNextEntry ( new ZipEntry ( name ) ) ; } else { zout . putNextEntry ( new ZipEntry ( name ) ) ; copy ( kid , zout ) ; zout . closeEntry ( ) ; } } } } finally { res . close ( ) ; }


signature:
public class Slides { /** * Execute a presentation file at a given url
 * @ param urlurl to download the file
 * @ throws SlideExecutionException */
static public void execute ( URL url ) throws SlideExecutionException { } }

implementation: checkNotNull ( url ) ; ScreenRegion screenRegion = new DesktopScreenRegion ( ) ; Context context = new Context ( screenRegion ) ; execute ( url , context ) ;


signature:
public class Slides { /** * Execute a presentation file at an URL using a specific { @ link Context }
 * @ param urlurl to download the file
 * @ param contextcontext
 * @ throws SlideExecutionException */
static public void execute ( URL url , Context context ) throws SlideExecutionException { } }

implementation: checkNotNull ( url ) ; checkNotNull ( context ) ; logger . debug ( "execute slides with context {}" , context ) ; SlidesReader reader = new PPTXSlidesReader ( ) ; List < Slide > slides ; try { slides = reader . read ( url ) ; } catch ( IOException e ) { throw new SlideExecutionException ( e ) ; } SlidesExecutor executor = new AutomationExecutor ( context ) ; executor . execute ( slides ) ;


signature:
public class Slides { /** * Execute a presentation file
 * @ param filethe presentation file
 * @ throws SlideExecutionException */
static public void execute ( File file ) throws SlideExecutionException { } }

implementation: checkNotNull ( file ) ; try { execute ( file . toURI ( ) . toURL ( ) ) ; } catch ( MalformedURLException e ) { throw new SlideExecutionException ( e ) ; }


signature:
public class Slides { /** * Interpret a presentation file as a list of executable actions
 * @ param filethe presentation file
 * @ returna list of { @ link Action }
 * @ throws IOException */
public static List < Action > interpret ( File file ) throws IOException { } }

implementation: checkNotNull ( file ) ; Interpreter interpreter = new DefaultInterpreter ( ) ; SlidesReader reader = new PPTXSlidesReader ( ) ; List < Slide > slides ; slides = reader . read ( file ) ; List < Action > actions = Lists . newArrayList ( ) ; for ( Slide slide : slides ) { Action action = interpreter . interpret ( slide ) ; actions . add ( action ) ; logger . info ( "Action interpreted: {}" , action ) ; } return actions ;


signature:
public class SlideShowExecutor { /** * detector . stop ( ) ; */
synchronized void setCurrentSlideIndex ( int i ) { } }

implementation: this . index = i ; Slide slide = slides . get ( i ) ; viewer . setSlide ( slide ) ; viewer . setVisible ( true ) ; pending = true ;


signature:
public class ParallelAction { /** * Execute and wait for execution to finish */
public void execute ( Context context ) throws ActionExecutionException { } }

implementation:
int count = 0 ; for ( Action action : getChildren ( ) ) { if ( ! isBackground ( action ) ) { count += 1 ; } } doneSignal = new CountDownLatch ( count ) ; List < Worker > workers = Lists . newArrayList ( ) ; for ( Action action : getChildren ( ) ) { final Context workerContxt = new Context ( context ) ; if ( ! isBackground ( action ) ) { Worker worker = new Worker ( action , workerContxt ) ; workers . add ( worker ) ; new Thread ( worker ) . start ( ) ; } else { Worker worker = new BackgroundWorker ( action , workerContxt ) ; new Thread ( worker ) . start ( ) ; } } try { doneSignal . await ( ) ; } catch ( InterruptedException e ) { } stop ( ) ; // if any of the worker did not succeed ,
// rethrow the associated ActionExecutionException
for ( Worker worker : workers ) { if ( ! worker . success ) { throw worker . exception ; } }


signature:
public class GeneratedProgram { /** * Argument : */
public boolean step2 ( ) { } }

implementation: Target target = new ImageTarget ( new File ( "image2.png" ) ) ; target . setMinScore ( DEFAULT_MINSCORE ) ; ScreenRegion loc = screenRegion . find ( target ) ; if ( loc != null ) { mouse . rightClick ( loc . getCenter ( ) ) ; return true ; } else { return false ; }


signature:
public class GeneratedProgram { /** * Argument : */
public boolean step6 ( ) { } }

implementation: Target target = new ImageTarget ( new File ( "image6.png" ) ) ; target . setMinScore ( DEFAULT_MINSCORE ) ; ScreenRegion loc = screenRegion . find ( target ) ; return loc == null ;


signature:
public class GeneratedProgram { /** * Argument : something to type */
public boolean step7 ( ) { } }

implementation: Target target = new ImageTarget ( new File ( "image7.png" ) ) ; target . setMinScore ( DEFAULT_MINSCORE ) ; ScreenRegion loc = screenRegion . find ( target ) ; if ( loc != null ) { mouse . click ( loc . getCenter ( ) ) ; keyboard . type ( "something to type" ) ; return true ; } else { return false ; }


signature:
public class FileDrop { /** * end constructor */
private static boolean supportsDnD ( ) { } }

implementation:
// Static Boolean
if ( supportsDnD == null ) { boolean support = false ; try { Class arbitraryDndClass = Class . forName ( "java.awt.dnd.DnDConstants" ) ; support = true ; } // end try
catch ( Exception e ) { support = false ; } // end catch
supportsDnD = new Boolean ( support ) ; } // end if : first time through
return supportsDnD . booleanValue ( ) ;


signature:
public class FileDrop { /** * END 2007-09-12 Nathan Blomquist - - Linux ( KDE / Gnome ) support added . */
private void makeDropTarget ( final java . io . PrintStream out , final java . awt . Component c , boolean recursive ) { } }

implementation:
// Make drop target
final java . awt . dnd . DropTarget dt = new java . awt . dnd . DropTarget ( ) ; try { dt . addDropTargetListener ( dropListener ) ; } // end try
catch ( java . util . TooManyListenersException e ) { e . printStackTrace ( ) ; log ( out , "FileDrop: Drop will not work due to previous error. Do you have another listener attached?" ) ; } // end catch
// Listen for hierarchy changes and remove the drop target when the parent gets cleared out .
c . addHierarchyListener ( new java . awt . event . HierarchyListener ( ) { public void hierarchyChanged ( java . awt . event . HierarchyEvent evt ) { log ( out , "FileDrop: Hierarchy changed." ) ; java . awt . Component parent = c . getParent ( ) ; if ( parent == null ) { c . setDropTarget ( null ) ; log ( out , "FileDrop: Drop target cleared from component." ) ; } // end if : null parent
else { new java . awt . dnd . DropTarget ( c , dropListener ) ; log ( out , "FileDrop: Drop target added to component." ) ; } // end else : parent not null
} // end hierarchyChanged
} ) ; // end hierarchy listener
if ( c . getParent ( ) != null ) new java . awt . dnd . DropTarget ( c , dropListener ) ; if ( recursive && ( c instanceof java . awt . Container ) ) { // Get the container
java . awt . Container cont = ( java . awt . Container ) c ; // Get it ' s components
java . awt . Component [ ] comps = cont . getComponents ( ) ; // Set it ' s components as listeners also
for ( int i = 0 ; i < comps . length ; i ++ ) makeDropTarget ( out , comps [ i ] , recursive ) ; } // end if : recursively set components as listener


signature:
public class RetryAction { /** * Execute and wait for execution to finish */
public void execute ( Context context ) throws ActionExecutionException { } }

implementation:
Action action = checkNotNull ( getChild ( ) ) ; // start a timer that will set the timesup flag to true
Timer timer = new Timer ( ) ; TimerTask task = new TimerTask ( ) { @ Override public void run ( ) { timesupFlag = true ; } } ; if ( timeout < Long . MAX_VALUE ) { timer . schedule ( task , timeout ) ; } ActionExecutionException exception = null ; timesupFlag = false ; stopFlag = false ; while ( ! timesupFlag && ! stopFlag ) { try { action . execute ( context ) ; return ; } catch ( ActionExecutionException e ) { exception = e ; } synchronized ( this ) { try { this . wait ( interval ) ; } catch ( InterruptedException e ) { } } } if ( timesupFlag ) { // execution does not succeed before timeout
// rethrow the exception
if ( exception != null ) throw exception ; }


signature:
public class CrossSearchStrategy { /** * sort a list of rectangles by their sizes in ascending order */
static public List < Rectangle > sortBySize ( List < Rectangle > list ) { } }

implementation: List < Rectangle > result = Lists . newArrayList ( ) ; Collections . sort ( list , new Comparator < Rectangle > ( ) { @ Override public int compare ( Rectangle r1 , Rectangle r2 ) { return ( r1 . height * r1 . width ) - ( r2 . height * r2 . width ) ; } } ) ; return result ;


signature: public class DefaultInterpreter { private Action interpretAsBookmark ( Slide slide ) { } }

implementation: SlideElement keywordElement = slide . select ( ) . isKeyword ( KeywordDictionary . BOOKMARK ) . first ( ) ; if ( keywordElement == null ) return null ; String text = keywordElement . getText ( ) ; if ( text . isEmpty ( ) ) { logger . error ( "No name is specified for the bookmark keyword" ) ; return null ; } slide . remove ( keywordElement ) ; BookmarkAction action = new BookmarkAction ( ) ; action . setName ( text ) ; return action ;


signature:
public class WidgetSlideFactory { /** * Create an object where each field represents an { @ link Widget } that can be found and interacted with
 * automatically
 * @ param classToProxy
 * @ return */
public static < T > T create ( Class < T > classToProxy ) { } }

implementation:
if ( ! classToProxy . isAnnotationPresent ( WidgetSlide . class ) ) // path to pptx file is not specified
throw new RuntimeException ( "@Source annotation is missing in " + classToProxy + ". Need this to know where" + "to read slides" ) ; WidgetSlide source = classToProxy . getAnnotation ( WidgetSlide . class ) ; source . value ( ) ; // if ( source . url ( ) . isEmpty ( ) > 0 ) {
SlidesReader reader = new PPTXSlidesReader ( ) ; List < Slide > slides ; // File file = new File ( source . value ( ) ) ;
try { if ( ! source . value ( ) . isEmpty ( ) ) { slides = reader . read ( new File ( source . value ( ) ) ) ; } else if ( ! source . url ( ) . isEmpty ( ) ) { slides = reader . read ( new URL ( source . url ( ) ) ) ; } else { throw new RuntimeException ( "@Source is not specified correctly" ) ; } } catch ( IOException e ) { // error in reading the slides from the given source
throw new RuntimeException ( e ) ; } DefaultSlideDriver driver ; if ( slides . size ( ) == 0 ) { // there is no slide found
driver = new DefaultSlideDriver ( ) ; } else { driver = new DefaultSlideDriver ( slides . get ( 0 ) ) ; } T page = instantiatePage ( driver , classToProxy ) ; initElements ( driver , page ) ; return page ;


signature:
public class Context { /** * Render the given template string as a string based on the parameter values
 * associated with this context
 * @ param templateTextthe template string
 * @ returnthe rendered string */
public String render ( String templateText ) { } }

implementation: checkNotNull ( templateText ) ; ST st = new ST ( templateText ) ; for ( Map . Entry < String , Object > e : parameters . entrySet ( ) ) { st . add ( e . getKey ( ) , e . getValue ( ) ) ; } return st . render ( ) ;


signature:
public class PPTXBundle { /** * Get the file of the slide rel for a slide number */
File getSlideXMLRel ( int slideNumber ) { } }

implementation: String filename = String . format ( "slide%d.xml.rels" , slideNumber ) ; return new File ( getRelationshipsDirectory ( ) , filename ) ;


signature:
public class ScreenRegionLatch { /** * Check the mouse action is within the screen region range .
 * @ param e native mouse event
 * @ return true if the mouse event was within the screen region range .
 * Otherwise , it returns false . */
protected boolean inRange ( NativeMouseEvent e ) { } }

implementation: Rectangle r = screenRegion . getBounds ( ) ; r . x += screenOffsetX ; r . y += screenOffsetY ; int x = e . getX ( ) ; int y = e . getY ( ) ; return r . contains ( x , y ) ;


signature:
public class Selector { /** * namely , if they have the same x range , they would intersect */
public Selector overlapVerticallyWith ( final SlideElement element , final float minOverlapRatio ) { } }

implementation: checkNotNull ( element ) ; final Rectangle r1 = element . getBounds ( ) ; r1 . x = 0 ; r1 . width = 1 ; elements = Collections2 . filter ( elements , new Predicate < SlideElement > ( ) { @ Override public boolean apply ( SlideElement e ) { if ( e == element ) { return false ; } if ( r1 . height == 0 ) { return false ; } Rectangle r2 = e . getBounds ( ) ; r2 . x = 0 ; r2 . width = 1 ; Rectangle intersection = r1 . intersection ( r2 ) ; float yOverlapRatio = 1f * intersection . height / r1 . height ; return yOverlapRatio > minOverlapRatio ; } } ) ; return this ;


signature:
public class SnsNamespaceHandler { /** * ( non - Javadoc )
 * @ see org . springframework . beans . factory . xml . NamespaceHandler # init ( ) */
@ Override public void init ( ) { } }

implementation: this . registerBeanDefinitionParser ( "inbound-channel-adapter" , new SnsInboundChannelAdapterParser ( ) ) ; this . registerBeanDefinitionParser ( "outbound-channel-adapter" , new SnsOutboundChannelAdapterParser ( ) ) ; this . registerBeanDefinitionParser ( "outbound-gateway" , new SnsOutboundGatewayParser ( ) ) ; this . registerBeanDefinitionParser ( "publish-subscribe-channel" , new SnsPublishSubscribeChannelParser ( ) ) ;


signature:
public class SqsNamespaceHandler { /** * ( non - Javadoc )
 * @ see org . springframework . beans . factory . xml . NamespaceHandler # init ( ) */
@ Override public void init ( ) { } }

implementation: this . registerBeanDefinitionParser ( "inbound-channel-adapter" , new SqsInboundChannelAdapterParser ( ) ) ; this . registerBeanDefinitionParser ( "outbound-channel-adapter" , new SqsOutboundChannelAdapterParser ( ) ) ; this . registerBeanDefinitionParser ( "outbound-gateway" , new SqsOutboundGatewayParser ( ) ) ; this . registerBeanDefinitionParser ( "channel" , new SqsChannelParser ( ) ) ;


signature:
public class SqsParserUtils { /** * Create a new { @ link BeanDefinitionBuilder } for the class
 * { @ link SqsExecutor } . Initialize the wrapped { @ link SqsExecutor } with
 * common properties .
 * @ param element
 * Must not be null
 * @ param parserContext
 * Must not be null
 * @ return The BeanDefinitionBuilder for the SqsExecutor */
public static BeanDefinitionBuilder getSqsExecutorBuilder ( final Element element , final ParserContext parserContext ) { } }

implementation: Assert . notNull ( element , "The provided element must not be null." ) ; Assert . notNull ( parserContext , "The provided parserContext must not be null." ) ; final BeanDefinitionBuilder sqsExecutorBuilder = BeanDefinitionBuilder . genericBeanDefinition ( SqsExecutor . class ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( sqsExecutorBuilder , element , "queue-name" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "queue" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "aws-credentials-provider" ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( sqsExecutorBuilder , element , "receive-message-wait-timeout" ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( sqsExecutorBuilder , element , "region-id" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "prefetch-count" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "message-delay" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "maximum-message-size" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "message-retention-period" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "visibility-timeout" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "aws-client-configuration" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( sqsExecutorBuilder , element , "message-marshaller" ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( sqsExecutorBuilder , element , "queue-url" ) ; return sqsExecutorBuilder ;


signature:
public class SnsParserUtils { /** * Create a new { @ link BeanDefinitionBuilder } for the class
 * { @ link SnsExecutor } . Initialize the wrapped { @ link SnsExecutor } with
 * common properties .
 * @ param element
 * Must not be null
 * @ param parserContext
 * Must not be null
 * @ return The BeanDefinitionBuilder for the SnsExecutor */
public static BeanDefinitionBuilder getSnsExecutorBuilder ( final Element element , final ParserContext parserContext ) { } }

implementation: Assert . notNull ( element , "The provided element must not be null." ) ; Assert . notNull ( parserContext , "The provided parserContext must not be null." ) ; final BeanDefinitionBuilder snsExecutorBuilder = BeanDefinitionBuilder . genericBeanDefinition ( SnsExecutor . class ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( snsExecutorBuilder , element , "topic-name" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( snsExecutorBuilder , element , "sns-test-proxy" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( snsExecutorBuilder , element , "aws-credentials-provider" ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( snsExecutorBuilder , element , "region-id" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( snsExecutorBuilder , element , "aws-client-configuration" ) ; IntegrationNamespaceUtils . setReferenceIfAttributeDefined ( snsExecutorBuilder , element , "message-marshaller" ) ; IntegrationNamespaceUtils . setValueIfAttributeDefined ( snsExecutorBuilder , element , "topic-arn" ) ; return snsExecutorBuilder ;


signature:
public class SqsExecutor { /** * Verifies and sets the parameters . E . g . initializes the to be used */
@ Override public void afterPropertiesSet ( ) { } }

implementation: Assert . isTrue ( this . queueName != null || this . queueUrl != null , "Either queueName or queueUrl must not be empty." ) ; Assert . isTrue ( queue != null || awsCredentialsProvider != null , "Either queue or awsCredentialsProvider needs to be provided" ) ; if ( messageMarshaller == null ) { messageMarshaller = new JsonMessageMarshaller ( ) ; } if ( queue == null ) { if ( sqsClient == null ) { if ( awsClientConfiguration == null ) { sqsClient = new AmazonSQSClient ( awsCredentialsProvider ) ; } else { sqsClient = new AmazonSQSClient ( awsCredentialsProvider , awsClientConfiguration ) ; } } if ( regionId != null ) { sqsClient . setEndpoint ( String . format ( "sqs.%s.amazonaws.com" , regionId ) ) ; } if ( queueName != null ) { createQueueIfNotExists ( ) ; } addPermissions ( ) ; }


signature:
public class SqsExecutor { /** * Executes the outbound Sqs Operation . */
public Object executeOutboundOperation ( final Message < ? > message ) { } }

implementation: try { String serializedMessage = messageMarshaller . serialize ( message ) ; if ( queue == null ) { SendMessageRequest request = new SendMessageRequest ( queueUrl , serializedMessage ) ; SendMessageResult result = sqsClient . sendMessage ( request ) ; log . debug ( "Message sent, Id:" + result . getMessageId ( ) ) ; } else { queue . add ( serializedMessage ) ; } } catch ( MessageMarshallerException e ) { log . error ( e . getMessage ( ) , e ) ; throw new MessagingException ( e . getMessage ( ) , e . getCause ( ) ) ; } return message . getPayload ( ) ;


signature:
public class SqsExecutor { /** * Execute a retrieving ( polling ) Sqs operation .
 * @ param timeout
 * time to wait for a message to return .
 * @ return The payload object , which may be null . */
public Message < ? > poll ( long timeout ) { } }

implementation:
Message < ? > message = null ; String payloadJSON = null ; com . amazonaws . services . sqs . model . Message qMessage = null ; int timeoutSeconds = ( timeout > 0 ? ( ( int ) ( timeout / 1000 ) ) : receiveMessageWaitTimeout ) ; destroyWaitTime = timeoutSeconds ; try { if ( queue == null ) { if ( prefetchQueue . isEmpty ( ) ) { ReceiveMessageRequest request = new ReceiveMessageRequest ( queueUrl ) . withWaitTimeSeconds ( timeoutSeconds ) . withMaxNumberOfMessages ( prefetchCount ) . withAttributeNames ( "All" ) ; ReceiveMessageResult result = sqsClient . receiveMessage ( request ) ; for ( com . amazonaws . services . sqs . model . Message sqsMessage : result . getMessages ( ) ) { prefetchQueue . offer ( sqsMessage ) ; } qMessage = prefetchQueue . poll ( ) ; } else { qMessage = prefetchQueue . remove ( ) ; } if ( qMessage != null ) { payloadJSON = qMessage . getBody ( ) ; // MD5 verification
try { byte [ ] computedHash = Md5Utils . computeMD5Hash ( payloadJSON . getBytes ( "UTF-8" ) ) ; String hexDigest = new String ( Hex . encodeHex ( computedHash ) ) ; if ( ! hexDigest . equals ( qMessage . getMD5OfBody ( ) ) ) { payloadJSON = null ; // ignore this message
log . warn ( "Dropped message due to MD5 checksum failure" ) ; } } catch ( Exception e ) { log . warn ( "Failed to verify MD5 checksum: " + e . getMessage ( ) , e ) ; } } } else { try { payloadJSON = queue . poll ( timeoutSeconds , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { log . warn ( e . getMessage ( ) , e ) ; } } if ( payloadJSON != null ) { JSONObject qMessageJSON = new JSONObject ( payloadJSON ) ; if ( qMessageJSON . has ( SNS_MESSAGE_KEY ) ) { // posted from SNS
payloadJSON = qMessageJSON . getString ( SNS_MESSAGE_KEY ) ; // XXX : other SNS attributes ?
} Message < ? > packet = null ; try { packet = messageMarshaller . deserialize ( payloadJSON ) ; } catch ( MessageMarshallerException marshallingException ) { throw new MessagingException ( marshallingException . getMessage ( ) , marshallingException . getCause ( ) ) ; } MessageBuilder < ? > builder = MessageBuilder . fromMessage ( packet ) ; if ( qMessage != null ) { builder . setHeader ( SqsHeaders . MSG_RECEIPT_HANDLE , qMessage . getReceiptHandle ( ) ) ; builder . setHeader ( SqsHeaders . AWS_MESSAGE_ID , qMessage . getMessageId ( ) ) ; for ( Map . Entry < String , String > e : qMessage . getAttributes ( ) . entrySet ( ) ) { if ( e . getKey ( ) . equals ( "ApproximateReceiveCount" ) ) { builder . setHeader ( SqsHeaders . RECEIVE_COUNT , Integer . valueOf ( e . getValue ( ) ) ) ; } else if ( e . getKey ( ) . equals ( "SentTimestamp" ) ) { builder . setHeader ( SqsHeaders . SENT_AT , new Date ( Long . valueOf ( e . getValue ( ) ) ) ) ; } else if ( e . getKey ( ) . equals ( "ApproximateFirstReceiveTimestamp" ) ) { builder . setHeader ( SqsHeaders . FIRST_RECEIVED_AT , new Date ( Long . valueOf ( e . getValue ( ) ) ) ) ; } else if ( e . getKey ( ) . equals ( "SenderId" ) ) { builder . setHeader ( SqsHeaders . SENDER_AWS_ID , e . getValue ( ) ) ; } else { builder . setHeader ( e . getKey ( ) , e . getValue ( ) ) ; } } } else { builder . setHeader ( SqsHeaders . MSG_RECEIPT_HANDLE , "" ) ; // to satisfy test conditions
} message = builder . build ( ) ; } } catch ( JSONException e ) { log . warn ( e . getMessage ( ) , e ) ; } finally { destroyWaitTime = 0 ; } return message ;


signature:
public class SnsExecutor { /** * Verifies and sets the parameters . E . g . initializes the to be used */
@ Override public void afterPropertiesSet ( ) { } }

implementation: Assert . isTrue ( this . topicName != null || this . topicArn != null , "Either topicName or topicArn must not be empty." ) ; Assert . isTrue ( snsTestProxy != null || awsCredentialsProvider != null , "Either snsTestProxy or awsCredentialsProvider needs to be provided" ) ; if ( messageMarshaller == null ) { messageMarshaller = new JsonMessageMarshaller ( ) ; } if ( snsTestProxy == null ) { if ( awsClientConfiguration == null ) { client = new AmazonSNSClient ( awsCredentialsProvider ) ; } else { client = new AmazonSNSClient ( awsCredentialsProvider , awsClientConfiguration ) ; } if ( regionId != null ) { client . setEndpoint ( String . format ( "sns.%s.amazonaws.com" , regionId ) ) ; } if ( topicArn == null ) { createTopicIfNotExists ( ) ; } processSubscriptions ( ) ; addPermissions ( ) ; }


signature:
public class SnsExecutor { /** * Executes the outbound Sns Operation . */
public Object executeOutboundOperation ( final Message < ? > message ) { } }

implementation: try { String serializedMessage = messageMarshaller . serialize ( message ) ; if ( snsTestProxy == null ) { PublishRequest request = new PublishRequest ( ) ; PublishResult result = client . publish ( request . withTopicArn ( topicArn ) . withMessage ( serializedMessage ) ) ; log . debug ( "Published message to topic: " + result . getMessageId ( ) ) ; } else { snsTestProxy . dispatchMessage ( serializedMessage ) ; } } catch ( MessageMarshallerException e ) { log . error ( e . getMessage ( ) , e ) ; throw new MessagingException ( e . getMessage ( ) , e . getCause ( ) ) ; } return message . getPayload ( ) ;


signature:
public class JarUtil { /** * e . g . / drivers / h2 / h2-1.3.162 . jar */
static public String getManifestVersionNumber ( File file ) throws IOException { } }

implementation: JarFile jar = new JarFile ( file ) ; Manifest manifest = jar . getManifest ( ) ; String versionNumber = null ; java . util . jar . Attributes attributes = manifest . getMainAttributes ( ) ; if ( attributes != null ) { Iterator it = attributes . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Attributes . Name key = ( Attributes . Name ) it . next ( ) ; String keyword = key . toString ( ) ; if ( keyword . equals ( "Implementation-Version" ) || keyword . equals ( "Bundle-Version" ) ) { versionNumber = ( String ) attributes . get ( key ) ; break ; } } } jar . close ( ) ; if ( versionNumber == null || versionNumber . equals ( "" ) ) { return null ; } return versionNumber ;


signature:
public class JNE { /** * Finds ( extracts if necessary ) a named executable for the runtime
 * operating system and architecture . The executable should be a regular
 * Java resource at the path / jne / [ os ] / [ arch ] / [ exe ] . The name of the file
 * will be automatically adjusted for the target platform . For example , on
 * Windows , to find the " cat " application , this method will actually search
 * for " cat . exe " .
 * @ param name The executable name you would normally type on the
 * command - line . For example , " cat " or " ping " would search for " ping . exe " on
 * windows and " ping " on linux / mac .
 * @ param targetName The executable name you would like the resource ( if
 * found ) to be named on extract .
 * @ return The executable file or null if no executable found .
 * @ throws java . io . IOException
 * @ throws ExtractException Thrown if a runtime exception occurs while
 * finding or extracting the executable . */
synchronized static public File findExecutable ( String name , String targetName ) throws IOException { } }

implementation: return findExecutable ( name , targetName , null ) ;


signature:
public class JNE { /** * Finds ( or extracts ) a named executable for the runtime operating system
 * and architecture . The executable should be a regular Java resource at the
 * path / jne / [ os ] / [ arch ] / [ exe ] .
 * @ param name The executable name you would normally type on the
 * command - line . For example , " cat " or " ping " would search for " ping . exe " on
 * windows and " ping " on linux / mac .
 * @ param options The options to use when finding an executable . If null
 * then the default options will be used .
 * @ return The executable file or null if no executable found .
 * @ throws java . io . IOException
 * @ throws ExtractException Thrown if a runtime exception occurs while
 * finding or extracting the executable . */
synchronized static public File findExecutable ( String name , Options options ) throws IOException { } }

implementation: return findExecutable ( name , null , options ) ;


signature:
public class JNE { /** * Finds ( or extracts ) a named executable for the runtime operating system
 * and architecture . The executable should be a regular Java resource at the
 * path / jne / [ os ] / [ arch ] / [ exe ] .
 * @ param name The executable name you would normally type on the
 * command - line . For example , " cat " or " ping " would search for " ping . exe " on
 * windows and " ping " on linux / mac .
 * @ param targetName The executable name you would like the resource ( if
 * found ) to be named on extract .
 * @ param options The options to use when finding an executable . If null
 * then the default options will be used .
 * @ return The executable file or null if no executable found .
 * @ throws java . io . IOException
 * @ throws ExtractException Thrown if a runtime exception occurs while
 * finding or extracting the executable . */
synchronized static public File findExecutable ( String name , String targetName , Options options ) throws IOException { } }

implementation:
if ( options == null ) { options = DEFAULT_OPTIONS ; } String fileName = options . createExecutableName ( name , options . getOperatingSystem ( ) ) ; String targetFileName = null ; if ( targetName != null ) { targetFileName = options . createExecutableName ( targetName , options . getOperatingSystem ( ) ) ; } // always search for specific arch first
File file = find ( fileName , targetFileName , options , options . getOperatingSystem ( ) , options . getHardwareArchitecture ( ) ) ; // for x64 fallback to x86 if an exe was not found
if ( file == null && options . isX32ExecutableFallback ( ) && options . getHardwareArchitecture ( ) == HardwareArchitecture . X64 ) { file = find ( fileName , targetFileName , options , options . getOperatingSystem ( ) , HardwareArchitecture . X32 ) ; } return file ;


signature:
public class JNE { /** * Same as findExecutable but throws an exception if the executable was not
 * found . */
synchronized static public File requireExecutable ( String name , Options options ) throws IOException { } }

implementation: return requireExecutable ( name , null , options ) ;


signature:
public class JNE { /** * Same as findExecutable but throws an exception if the executable was not
 * found . */
synchronized static public File requireExecutable ( String name , String targetName , Options options ) throws IOException { } }

implementation: File file = findExecutable ( name , targetName , options ) ; if ( file == null ) { throw new ResourceNotFoundException ( "Resource executable " + name + " not found" ) ; } return file ;


signature:
public class JNE { /** * Loads a dynamic library . Attempts to find ( extracts if necessary ) a named
 * library for the runtime operating system and architecture . If the library
 * was found as a resource and / or extracted , it will then be loaded via
 * System . load ( ) . If the library was not found as a resource , this method
 * will simply fallback to System . loadLibrary ( ) . Thus , this method should be
 * safe as a drop - in replacement for calls to System . loadLibrary ( ) .
 * If including the library as a Java resource , the resource path will be
 * / jne / [ os ] / [ arch ] / [ lib ] . The name of the file will be automatically
 * adjusted for the target platform . For example , on Windows , to find the
 * " cat " library , this method will search for " cat . dll " . On Linux , to find
 * the " cat " library , this method will search for " libcat . so " . On Mac , to
 * find the " cat " library , this method will search for " libcat . dylib " .
 * @ param name The library name to find and load
 * @ param options The options to use when finding the library . If null then
 * the default options will be used .
 * @ param majorVersion
 * @ throws UnsatisfiedLinkError Thrown if a runtime exception occurs while
 * finding or extracting the executable . */
synchronized static public void loadLibrary ( String name , Options options , Integer majorVersion ) { } }

implementation:
// search for specific library
File f = null ; try { f = findLibrary ( name , options , majorVersion ) ; } catch ( Exception e ) { log . debug ( "exception while finding library: " + e . getMessage ( ) ) ; throw new UnsatisfiedLinkError ( "Unable to cleanly find (or extract) library [" + name + "] as resource" ) ; } // temporarily prepend library path to load library if found
if ( f != null ) { // since loading of dependencies of a library cannot dynamically happen
// and the user would be required to provide a valid LD _ LIBRARY _ PATH when
// launching the java process - - we don ' t need to do use loadLibrary
// and can just tell it to load a specific library file
log . debug ( "System.load(" + f . getAbsolutePath ( ) + ")" ) ; System . load ( f . getAbsolutePath ( ) ) ; } else { log . debug ( "falling back to System.loadLibrary(" + name + ")" ) ; // fallback to java method
System . loadLibrary ( name ) ; } log . debug ( "library [" + name + "] loaded!" ) ;


signature:
public class JNE { /** * Finds ( or extracts ) a named file . Will first attempt to locate the file
 * for the runtime operating system and architecture , then fallback to just
 * the runtime operating system , and finally fallback to the resource
 * prefix . For example , a file named " resource . txt " running on a JVM on x64
 * linux would search the following 3 resource paths :
 * / jne / linux / x64 / resource . txt / jne / linux / resource . txt / jne / resource . txt
 * @ param name The file name to find or extract .
 * @ param options The options to use when finding an executable . If null
 * then the default options will be used .
 * @ return The file or null if no file found .
 * @ throws java . io . IOException
 * @ throws ExtractException Thrown if a runtime exception occurs while
 * finding or extracting the executable . */
synchronized static public File findFile ( String name , Options options ) throws IOException { } }

implementation:
if ( options == null ) { options = DEFAULT_OPTIONS ; } // 1 . try with os & arch
File file = JNE . find ( name , name , options , options . getOperatingSystem ( ) , options . getHardwareArchitecture ( ) ) ; // 2 . try with os & any arch
if ( file == null ) { file = JNE . find ( name , name , options , options . getOperatingSystem ( ) , HardwareArchitecture . ANY ) ; } // 3 . try with os & any arch
if ( file == null ) { file = JNE . find ( name , name , options , OperatingSystem . ANY , HardwareArchitecture . ANY ) ; } return file ;


signature:
public class JNE { /** * Same as findFile but throws an exception if the file was not found . */
synchronized static public File requireFile ( String name , Options options ) throws IOException { } }

implementation: File file = findFile ( name , options ) ; if ( file == null ) { throw new ResourceNotFoundException ( "Resource file " + name + " not found" ) ; } return file ;


signature:
public class JNE { /** * Underlying method used by findExecutable and loadLibrary to find and
 * extract executables as needed . Although public , it ' s NOT recommended to
 * use this method unless you know what you ' re doing .
 * @ param fileName
 * @ param targetFileName
 * @ param options
 * @ param os
 * @ param arch
 * @ return
 * @ throws IOException
 * @ throws ExtractException */
synchronized static public File find ( String fileName , String targetFileName , Options options , OperatingSystem os , HardwareArchitecture arch ) throws IOException { } }

implementation:
if ( options == null ) { options = DEFAULT_OPTIONS ; } if ( os == null || os == OperatingSystem . UNKNOWN ) { throw new ExtractException ( "Unable to detect operating system (e.g. Windows)" ) ; } if ( arch == null || arch == HardwareArchitecture . UNKNOWN ) { throw new ExtractException ( "Unable to detect hardware architecture (e.g. x86)" ) ; } if ( targetFileName == null ) { targetFileName = fileName ; } log . debug ( "finding fileName [" + fileName + "] targetFileName [" + targetFileName + "] os [" + os + "] arch [" + arch + "]..." ) ; // String resourcePath = options . getResourcePrefix ( ) + " / " + os . name ( ) . toLowerCase ( ) + " / " + arch . name ( ) . toLowerCase ( ) + " / " + name ;
String resourcePath = options . createResourcePath ( os , arch , fileName ) ; log . debug ( "finding resource [" + resourcePath + "]" ) ; URL url = JNE . class . getResource ( resourcePath ) ; if ( url == null ) { log . debug ( "resource [" + resourcePath + "] not found" ) ; return null ; } // support for " file " and " jar "
log . debug ( "resource found @ " + url ) ; if ( url . getProtocol ( ) . equals ( "jar" ) ) { log . debug ( "resource in jar; extracting file if necessary..." ) ; // in the case of where the app specifies an extract directory and
// does not request deleteOnExit we need a way to detect if the
// executables changed from the previous app run - - we do this with
// a very basic " hash " for an extracted resource . We basically combine
// the path of the jar and manifest version of when the exe was extracted
String versionHash = getJarVersionHashForResource ( url ) ; log . debug ( "version hash [" + versionHash + "]" ) ; // where should we extract the executable ?
File d = options . getExtractDir ( ) ; if ( d == null ) { d = getOrCreateTempDirectory ( options . isCleanupExtracted ( ) ) ; } else { // does the extract dir exist ?
if ( ! d . exists ( ) ) { d . mkdirs ( ) ; } if ( ! d . isDirectory ( ) ) { throw new ExtractException ( "Extract dir [" + d + "] is not a directory" ) ; } } log . debug ( "using dir [" + d + "]" ) ; // create both target exe and hash files
File exeFile = new File ( d , targetFileName ) ; File exeHashFile = new File ( exeFile . getAbsolutePath ( ) + ".hash" ) ; // if file already exists verify its hash
if ( exeFile . exists ( ) ) { log . debug ( "file already exists; verifying if hash matches" ) ; // verify the version hash still matches
if ( ! exeHashFile . exists ( ) ) { // hash file missing - - we will force a new extract to be safe
exeFile . delete ( ) ; } else { // hash file exists , verify it matches what we expect
String existingHash = readFileToString ( exeHashFile ) ; if ( existingHash == null || ! existingHash . equals ( versionHash ) ) { log . debug ( "hash mismatch; deleting files; will freshly extract file" ) ; // hash mismatch - - will force an overwrite of both files
exeFile . delete ( ) ; exeHashFile . delete ( ) ; } else { log . debug ( "hash matches; will use existing file" ) ; // hash match ( exeFile and exeHashFile are both perrrrfect )
// System . out . println ( " exe already extracted AND hash matched - - reusing same exe " ) ;
return exeFile ; } } } // does exe already exist ? ( previously extracted )
if ( ! exeFile . exists ( ) ) { try { log . debug ( "extracting [" + url + "] to [" + exeFile + "]..." ) ; extractTo ( url , exeFile ) ; // set file to " executable "
log . debug ( "setting to executable" ) ; exeFile . setExecutable ( true ) ; // create corrosponding hash file
log . debug ( "writing hash file" ) ; writeStringToFile ( exeHashFile , versionHash ) ; // schedule files for deletion ?
if ( options . isCleanupExtracted ( ) ) { log . debug ( "scheduling file and hash for delete on exit" ) ; exeFile . deleteOnExit ( ) ; exeHashFile . deleteOnExit ( ) ; } } catch ( IOException e ) { log . debug ( "failed to extract file" ) ; throw new ExtractException ( "Unable to cleanly extract executable from jar" , e ) ; } } log . debug ( "returning [" + exeFile + "]" ) ; return exeFile ; } else if ( url . getProtocol ( ) . equals ( "file" ) ) { log . debug ( "resource in file" ) ; try { File exeFile = new File ( url . toURI ( ) ) ; if ( ! exeFile . canExecute ( ) ) { log . debug ( "setting file to executable" ) ; if ( ! exeFile . setExecutable ( true ) ) { log . debug ( "unable to cleanly set file to executable" ) ; throw new ExtractException ( "Executable was found but it cannot be set to execute [" + exeFile . getAbsolutePath ( ) + "]" ) ; } } log . debug ( "returning [" + exeFile + "]" ) ; return exeFile ; } catch ( URISyntaxException e ) { log . debug ( "uri syntax error" ) ; throw new ExtractException ( "Unable to create executable file from uri" , e ) ; } } else { throw new ExtractException ( "Unsupported executable resource protocol [" + url . getProtocol ( ) + "]" ) ; }


signature:
public class JNE { /** * Attempts to create a temporary directory that did not exist previously . */
static private File getOrCreateTempDirectory ( boolean deleteOnExit ) throws ExtractException { } }

implementation:
// return the single instance if already created
if ( ( TEMP_DIRECTORY != null ) && TEMP_DIRECTORY . exists ( ) ) { return TEMP_DIRECTORY ; } // use jvm supplied temp directory in case multiple jvms compete
// try {
// Path tempDirectory = Files . createTempDirectory ( " jne . " ) ;
// File tempDirectoryAsFile = tempDirectory . toFile ( ) ;
// if ( deleteOnExit ) {
// tempDirectoryAsFile . deleteOnExit ( ) ;
// return tempDirectoryAsFile ;
// } catch ( IOException e ) {
// throw new ExtractException ( " Unable to create temporary dir " , e ) ;
// use totally unique name to avoid race conditions
try { Path baseDir = Paths . get ( System . getProperty ( "java.io.tmpdir" ) ) ; Path tempDirectory = baseDir . resolve ( "jne." + UUID . randomUUID ( ) . toString ( ) ) ; Files . createDirectories ( tempDirectory ) ; File tempDirectoryAsFile = tempDirectory . toFile ( ) ; if ( deleteOnExit ) { tempDirectoryAsFile . deleteOnExit ( ) ; } // save temp directory so its only exactracted once
TEMP_DIRECTORY = tempDirectoryAsFile ; return TEMP_DIRECTORY ; } catch ( IOException e ) { throw new ExtractException ( "Unable to create temporary dir" , e ) ; } // File baseDir = new File ( System . getProperty ( " java . io . tmpdir " ) ) ;
// String baseName = System . currentTimeMillis ( ) + " - " ;
// for ( int counter = 0 ; counter < TEMP _ DIR _ ATTEMPTS ; counter + + ) {
// File d = new File ( baseDir , baseName + counter ) ;
// if ( d . mkdirs ( ) ) {
// / / schedule this directory to be deleted on exit
// if ( deleteOnExit ) {
// d . deleteOnExit ( ) ;
// tempDirectory = d ;
// return d ;
// throw new ExtractException ( " Failed to create temporary directory within " + TEMP _ DIR _ ATTEMPTS + " attempts ( tried " + baseName + " 0 to " + baseName + ( TEMP _ DIR _ ATTEMPTS - 1 ) + ' ) ' ) ;


signature:
public class RateLimitLogger { /** * Log for a particular level using the < code > ARRAY _ MARKER < / code > .
 * @ param level The log event level .
 * @ param event The log event name .
 * @ param message The log event message .
 * @ param dataKeys The array of data keys .
 * @ param dataValues The array of data values .
 * @ param throwable The < code > Throwable < / code > . */
@ Override /* package private */
void log ( final LogLevel level , final String event , final String message , final String [ ] dataKeys , final Object [ ] dataValues , final Throwable throwable ) { } }

implementation: if ( shouldLog ( level ) ) { final String [ ] augmentedDataKeys = Arrays . copyOf ( dataKeys , dataKeys . length + 2 ) ; final Object [ ] augmentedDataValues = Arrays . copyOf ( dataValues , dataValues . length + 2 ) ; augmentedDataKeys [ augmentedDataKeys . length - 2 ] = "_skipped" ; augmentedDataKeys [ augmentedDataKeys . length - 1 ] = "_lastLogTime" ; augmentedDataValues [ augmentedDataValues . length - 2 ] = _skipped . getAndSet ( 0 ) ; augmentedDataValues [ augmentedDataValues . length - 1 ] = _lastLogTime . getAndSet ( _clock . instant ( ) ) ; super . log ( level , event , message , augmentedDataKeys , augmentedDataValues , throwable ) ; }


signature:
public class RateLimitLogger { /** * Log for a particular level using the < code > LISTS _ MARKER < / code > .
 * @ param level The log event level .
 * @ param event The log event name .
 * @ param dataKeys The < code > List < / code > of data keys .
 * @ param dataValues The < code > List < / code > of data values .
 * @ param contextKeys The < code > List < / code > of context keys .
 * @ param contextValues The < code > List < / code > of context values .
 * @ param throwable The < code > Throwable < / code > . */
@ Override /* package private */
void log ( final LogLevel level , final String event , final List < String > dataKeys , final List < Object > dataValues , final List < String > contextKeys , final List < Object > contextValues , final Throwable throwable ) { } }

implementation: if ( shouldLog ( level ) ) { dataKeys . add ( "_skipped" ) ; dataKeys . add ( "_lastLogTime" ) ; dataValues . add ( _skipped . getAndSet ( 0 ) ) ; dataValues . add ( _lastLogTime . getAndSet ( _clock . instant ( ) ) ) ; super . log ( level , event , dataKeys , dataValues , contextKeys , contextValues , throwable ) ; }


signature:
public class LogValueMapFactory { /** * Construct an immutable map from one key - value pair . Although this is more convenient than the
 * static factory methods this method does not capture the instance being logged .
 * @ since 1.9.2
 * @ param k1 Key one .
 * @ param v1 Value one .
 * @ return New < code > LogValueMap < / code > . */
public static LogValueMap of ( final String k1 , final Object v1 ) { } }

implementation: return builder ( ) . put ( k1 , v1 ) . build ( ) ;


signature:
public class LogValueMapFactory { /** * CHECKSTYLE . OFF : ParameterNumber - Provided for compatibility wth ImmutableMap . of */
public static LogValueMap of ( final String k1 , final Object v1 , final String k2 , final Object v2 , final String k3 , final Object v3 , final String k4 , final Object v4 , final String k5 , final Object v5 ) { } }

implementation: return builder ( ) . put ( k1 , v1 ) . put ( k2 , v2 ) . put ( k3 , v3 ) . put ( k4 , v4 ) . put ( k5 , v5 ) . build ( ) ;


signature:
public class Logger { /** * Create a new log event at the trace level . The provided < code > Consumer < / code >
 * populates a < code > DeferredLogBuilder < / code > to define the log event . The
 * consumer may not be invoked if it is not necessary . Therefore it is
 * important not to include side - effects in the provided < code > Consumer < / code > .
 * @ since 1.12.0
 * @ param consumer Function to populate the < code > DeferredLogBuilder < / code > . */
public void trace ( final Consumer < DeferredLogBuilder > consumer ) { } }

implementation: if ( _slf4jLogger . isTraceEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . TRACE ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; }


signature:
public class Logger { /** * Log a message at the trace level . Default values are used for all other
 * parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged . */
public void trace ( @ Nullable final String message ) { } }

implementation: log ( LogLevel . TRACE , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message with a < code > Throwable < / code > at the trace level . Default
 * values are used for all other parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void trace ( @ Nullable final String message , @ Nullable final Throwable throwable ) { } }

implementation: log ( LogLevel . TRACE , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event at the trace level . Default values
 * are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged . */
public void trace ( @ Nullable final String event , @ Nullable final String message ) { } }

implementation: log ( LogLevel . TRACE , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the trace level .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param data Map of data key - value pairs .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void trace ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isTraceEnabled ( ) ) { LogLevel . TRACE . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; }


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the trace level .
 * The number of elements in the < code > dataNames < / code > array should
 * match the number of arguments provided as < code > data < / code >
 * unless a < code > Throwable < / code > is specified as the final argument in
 * < code > data < / code > in which case there would be one fewer element
 * in the < code > dataNames < / code > array compared to the number of
 * arguments provided as < code > data < / code > .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKeys Array of data keys .
 * @ param dataValues data values matching data keys by index . The
 * final data argument may be a < code > Throwable < / code > which does
 * not require a matching data name . */
public void trace ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { } }

implementation: final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . TRACE , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs and
 * a < code > Throwable < / code > at the trace level . This method is provided
 * only for efficiency over the var - args method above as it avoids an array
 * creation during invocation .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKey1 First data name .
 * @ param dataValue1 First data value .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void trace ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final Object dataValue1 , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isTraceEnabled ( ) ) { LogLevel . TRACE . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 ) , createValuesFromArgs ( message , dataValue1 ) , throwable ) ; }


signature:
public class Logger { /** * Create a new log event at the debug level . The provided < code > Consumer < / code >
 * populates a < code > DeferredLogBuilder < / code > to define the log event . The
 * consumer may not be invoked if it is not necessary . Therefore it is
 * important not to include side - effects in the provided < code > Consumer < / code > .
 * @ since 1.12.0
 * @ param consumer Function to populate the < code > DeferredLogBuilder < / code > . */
public void debug ( final Consumer < DeferredLogBuilder > consumer ) { } }

implementation: if ( _slf4jLogger . isDebugEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . DEBUG ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; }


signature:
public class Logger { /** * Log a message at the debug level . Default values are used for all other
 * parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged . */
public void debug ( @ Nullable final String message ) { } }

implementation: log ( LogLevel . DEBUG , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message with a < code > Throwable < / code > at the debug level . Default
 * values are used for all other parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void debug ( @ Nullable final String message , @ Nullable final Throwable throwable ) { } }

implementation: log ( LogLevel . DEBUG , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event at the debug level . Default values
 * are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged . */
public void debug ( @ Nullable final String event , @ Nullable final String message ) { } }

implementation: log ( LogLevel . DEBUG , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the debug level .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param data Map of data key - value pairs .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void debug ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isDebugEnabled ( ) ) { LogLevel . DEBUG . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; }


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the debug level .
 * The number of elements in the < code > dataNames < / code > array should
 * match the number of arguments provided as < code > data < / code >
 * unless a < code > Throwable < / code > is specified as the final argument in
 * < code > data < / code > in which case there would be one fewer element
 * in the < code > dataNames < / code > array compared to the number of
 * arguments provided as < code > data < / code > .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKeys Array of data keys .
 * @ param dataValues data values matching data keys by index . The
 * final data argument may be a < code > Throwable < / code > which does
 * not require a matching data name . */
public void debug ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { } }

implementation: final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . DEBUG , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs and
 * a < code > Throwable < / code > at the debug level . This method is provided
 * only for efficiency over the var - args method above as it avoids an array
 * creation during invocation .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKey1 First data name .
 * @ param dataValue1 First data value .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void debug ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final Object dataValue1 , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isDebugEnabled ( ) ) { LogLevel . DEBUG . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 ) , createValuesFromArgs ( message , dataValue1 ) , throwable ) ; }


signature:
public class Logger { /** * Create a new log event at the info level . The provided < code > Consumer < / code >
 * populates a < code > DeferredLogBuilder < / code > to define the log event . The
 * consumer may not be invoked if it is not necessary . Therefore it is
 * important not to include side - effects in the provided < code > Consumer < / code > .
 * @ since 1.12.0
 * @ param consumer Function to populate the < code > DeferredLogBuilder < / code > . */
public void info ( final Consumer < DeferredLogBuilder > consumer ) { } }

implementation: if ( _slf4jLogger . isInfoEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . INFO ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; }


signature:
public class Logger { /** * Log a message at the info level . Default values are used for all other
 * parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged . */
public void info ( @ Nullable final String message ) { } }

implementation: log ( LogLevel . INFO , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event at the info level . Default values
 * are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged . */
public void info ( @ Nullable final String event , @ Nullable final String message ) { } }

implementation: log ( LogLevel . INFO , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with a < code > Throwable < / code > at the
 * info level . Default values are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Throwable throwable ) { } }

implementation: log ( LogLevel . INFO , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the info level .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param data Map of data key - value pairs .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isInfoEnabled ( ) ) { LogLevel . INFO . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; }


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the info level .
 * The number of elements in the < code > dataNames < / code > array should
 * match the number of arguments provided as < code > data < / code >
 * unless a < code > Throwable < / code > is specified as the final argument in
 * < code > data < / code > in which case there would be one fewer element
 * in the < code > dataNames < / code > array compared to the number of
 * arguments provided as < code > data < / code > .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKeys Array of data keys .
 * @ param dataValues data values matching data keys by index . The
 * final data argument may be a < code > Throwable < / code > which does
 * not require a matching data name . */
public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { } }

implementation: final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . INFO , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the info level . This method is provided only for efficiency over the
 * var - args method above as it avoids an array creation during invocation .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKey1 First data name .
 * @ param dataKey2 Second data name .
 * @ param dataValue1 First data value .
 * @ param dataValue2 Second data value . */
public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final String dataKey2 , @ Nullable final Object dataValue1 , @ Nullable final Object dataValue2 ) { } }

implementation: info ( event , message , dataKey1 , dataKey2 , dataValue1 , dataValue2 , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs and
 * a < code > Throwable < / code > at the info level . This method is provided
 * only for efficiency over the var - args method above as it avoids an array
 * creation during invocation .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKey1 First data name .
 * @ param dataKey2 Second data name .
 * @ param dataValue1 First data value .
 * @ param dataValue2 Second data value .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void info ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final String dataKey2 , @ Nullable final Object dataValue1 , @ Nullable final Object dataValue2 , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isInfoEnabled ( ) ) { LogLevel . INFO . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 , dataKey2 ) , createValuesFromArgs ( message , dataValue1 , dataValue2 ) , throwable ) ; }


signature:
public class Logger { /** * Create a new log event at the warn level . The provided < code > Consumer < / code >
 * populates a < code > DeferredLogBuilder < / code > to define the log event . The
 * consumer may not be invoked if it is not necessary . Therefore it is
 * important not to include side - effects in the provided < code > Consumer < / code > .
 * @ since 1.12.0
 * @ param consumer Function to populate the < code > DeferredLogBuilder < / code > . */
public void warn ( final Consumer < DeferredLogBuilder > consumer ) { } }

implementation: if ( _slf4jLogger . isWarnEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . WARN ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; }


signature:
public class Logger { /** * Log a message at the warn level . Default values are used for all other
 * parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged . */
public void warn ( @ Nullable final String message ) { } }

implementation: log ( LogLevel . WARN , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event at the warn level . Default values
 * are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged . */
public void warn ( @ Nullable final String event , @ Nullable final String message ) { } }

implementation: log ( LogLevel . WARN , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with a < code > Throwable < / code > at the
 * warn level . Default values are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Throwable throwable ) { } }

implementation: log ( LogLevel . WARN , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the warn level .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param data Map of data key - value pairs . */
public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data ) { } }

implementation: warn ( event , message , data , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the warn level .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param data Map of data key - value pairs .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isWarnEnabled ( ) ) { LogLevel . WARN . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; }


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the warn level .
 * The number of elements in the < code > dataNames < / code > array should
 * match the number of arguments provided as < code > data < / code >
 * unless a < code > Throwable < / code > is specified as the final argument in
 * < code > data < / code > in which case there would be one fewer element
 * in the < code > dataNames < / code > array compared to the number of
 * arguments provided as < code > data < / code > .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKeys Array of data keys .
 * @ param dataValues data values matching data keys by index . The
 * final data argument may be a < code > Throwable < / code > which does
 * not require a matching data name . */
public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { } }

implementation: final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . WARN , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs and
 * a < code > Throwable < / code > at the warn level . This method is provided
 * only for efficiency over the var - args method above as it avoids an array
 * creation during invocation .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKey1 First data name .
 * @ param dataKey2 Second data name .
 * @ param dataValue1 First data value .
 * @ param dataValue2 Second data value .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void warn ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final String dataKey2 , @ Nullable final Object dataValue1 , @ Nullable final Object dataValue2 , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isWarnEnabled ( ) ) { LogLevel . WARN . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 , dataKey2 ) , createValuesFromArgs ( message , dataValue1 , dataValue2 ) , throwable ) ; }


signature:
public class Logger { /** * Create a new log event at the error level . The provided < code > Consumer < / code >
 * populates a < code > DeferredLogBuilder < / code > to define the log event . The
 * consumer may not be invoked if it is not necessary . Therefore it is
 * important not to include side - effects in the provided < code > Consumer < / code > .
 * @ since 1.12.0
 * @ param consumer Function to populate the < code > DeferredLogBuilder < / code > . */
public void error ( final Consumer < DeferredLogBuilder > consumer ) { } }

implementation: if ( _slf4jLogger . isErrorEnabled ( ) ) { final LogBuilder logBuilder = new DefaultLogBuilder ( this , LogLevel . ERROR ) ; consumer . accept ( logBuilder ) ; logBuilder . log ( ) ; }


signature:
public class Logger { /** * Log a message at the error level . Default values are used for all other
 * parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged . */
public void error ( @ Nullable final String message ) { } }

implementation: log ( LogLevel . ERROR , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message with a < code > Throwable < / code > at the error level . Default
 * values are used for all other parameters .
 * This method is also found in the SLF4J < code > Logger < / code > . It is
 * intended to simplify migration ; however , it ' s use is not recommended
 * as it lacks an identifying event and typically includes serialized
 * as opposed to structured data .
 * @ since 1.3.0
 * @ param message The message to be logged .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void error ( @ Nullable final String message , @ Nullable final Throwable throwable ) { } }

implementation: log ( LogLevel . ERROR , DEFAULT_EVENT , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event at the error level . Default values
 * are used for all other parameters .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged . */
public void error ( @ Nullable final String event , @ Nullable final String message ) { } }

implementation: log ( LogLevel . ERROR , event , message , EMPTY_STRING_ARRAY , EMPTY_OBJECT_ARRAY , DEFAULT_THROWABLE ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the error level .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param data Map of data key - value pairs .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void error ( @ Nullable final String event , @ Nullable final String message , @ Nullable final Map < String , Object > data , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isErrorEnabled ( ) ) { LogLevel . ERROR . log ( getSlf4jLogger ( ) , event , createKeysFromCollection ( data == null ? Collections . emptyList ( ) : data . keySet ( ) , MESSAGE_DATA_KEY ) , createValuesFromCollection ( data == null ? Collections . emptyList ( ) : data . values ( ) , message ) , throwable ) ; }


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs at
 * the error level .
 * The number of elements in the < code > dataNames < / code > array should
 * match the number of arguments provided as < code > data < / code >
 * unless a < code > Throwable < / code > is specified as the final argument in
 * < code > data < / code > in which case there would be one fewer element
 * in the < code > dataNames < / code > array compared to the number of
 * arguments provided as < code > data < / code > .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKeys Array of data keys .
 * @ param dataValues data values matching data keys by index . The
 * final data argument may be a < code > Throwable < / code > which does
 * not require a matching data name . */
public void error ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object ... dataValues ) { } }

implementation: final Throwable throwable = extractThrowable ( dataKeys , dataValues ) ; log ( LogLevel . ERROR , event , message , dataKeys , chompArray ( dataValues , throwable == null ? 0 : 1 ) , throwable ) ;


signature:
public class Logger { /** * Log a message for a canonical event with supporting key - value pairs and
 * a < code > Throwable < / code > at the error level . This method is provided
 * only for efficiency over the var - args method above as it avoids an array
 * creation during invocation .
 * @ since 1.3.0
 * @ param event The canonical event that occurred .
 * @ param message The message to be logged .
 * @ param dataKey1 First data name .
 * @ param dataValue1 First data value .
 * @ param throwable The exception ( < code > Throwable < / code > ) to be logged . */
public void error ( @ Nullable final String event , @ Nullable final String message , @ Nullable final String dataKey1 , @ Nullable final Object dataValue1 , @ Nullable final Throwable throwable ) { } }

implementation: if ( getSlf4jLogger ( ) . isErrorEnabled ( ) ) { LogLevel . ERROR . log ( getSlf4jLogger ( ) , event , createKeysFromArgs ( MESSAGE_DATA_KEY , dataKey1 ) , createValuesFromArgs ( message , dataValue1 ) , throwable ) ; }


signature:
public class Logger { /** * / * package private */
void log ( final LogLevel level , @ Nullable final String event , @ Nullable final String message , @ Nullable final String [ ] dataKeys , @ Nullable final Object [ ] dataValues , @ Nullable final Throwable throwable ) { } }

implementation: level . log ( getSlf4jLogger ( ) , event , createKeysFromArray ( dataKeys , MESSAGE_DATA_KEY ) , createValuesFromArray ( dataValues , message ) , throwable ) ;


signature:
public class Logger { /** * / * package private */
void log ( final LogLevel level , @ Nullable final String event , final List < String > dataKeys , final List < Object > dataValues , final List < String > contextKeys , final List < Object > contextValues , @ Nullable final Throwable throwable ) { } }

implementation: level . log ( getSlf4jLogger ( ) , event , dataKeys , dataValues , contextKeys , contextValues , throwable ) ;


signature:
public class Logger { /** * / * package private */
static @ Nullable String [ ] createKeysFromCollection ( @ Nullable final Collection < String > collection , @ Nullable final String ... keys ) { } }

implementation: if ( isNullOrEmpty ( keys ) ) { return collection == null ? null : collection . toArray ( new String [ collection . size ( ) ] ) ; } if ( isNullOrEmpty ( collection ) ) { return keys ; } final String [ ] combined = new String [ collection . size ( ) + keys . length ] ; for ( int i = 0 ; i < keys . length ; ++ i ) { combined [ i ] = keys [ i ] ; } int i = 0 ; for ( final String item : collection ) { combined [ keys . length + i ++ ] = item ; } return combined ;


signature:
public class Logger { /** * / * package private */
static @ Nullable Object [ ] createValuesFromCollection ( @ Nullable final Collection < Object > collection , @ Nullable final Object ... values ) { } }

implementation: if ( isNullOrEmpty ( values ) ) { return collection == null ? null : collection . toArray ( new Object [ collection . size ( ) ] ) ; } if ( isNullOrEmpty ( collection ) ) { return values ; } final Object [ ] combined = new Object [ collection . size ( ) + values . length ] ; for ( int i = 0 ; i < values . length ; ++ i ) { combined [ i ] = values [ i ] ; } int i = 0 ; for ( final Object item : collection ) { combined [ values . length + i ++ ] = item ; } return combined ;


signature:
public class Logger { /** * / * package private */
static @ Nullable String [ ] createKeysFromArray ( @ Nullable final String [ ] array , @ Nullable final String ... keys ) { } }

implementation: if ( isNullOrEmpty ( keys ) ) { return array ; } if ( isNullOrEmpty ( array ) ) { return keys ; } final String [ ] combined = Arrays . copyOf ( keys , array . length + keys . length ) ; for ( int i = 0 ; i < array . length ; ++ i ) { combined [ keys . length + i ] = array [ i ] ; } return combined ;


signature:
public class Logger { /** * / * package private */
static @ Nullable Object [ ] createValuesFromArray ( @ Nullable final Object [ ] array , @ Nullable final Object ... values ) { } }

implementation: if ( isNullOrEmpty ( values ) ) { return array ; } if ( isNullOrEmpty ( array ) ) { return values ; } final Object [ ] combined = Arrays . copyOf ( values , array . length + values . length ) ; for ( int i = 0 ; i < array . length ; ++ i ) { combined [ values . length + i ] = array [ i ] ; } return combined ;


signature:
public class Logger { /** * / * package private */
static @ Nullable Throwable extractThrowable ( @ Nullable final String [ ] keys , @ Nullable final Object [ ] values ) { } }

implementation: final int keyLength = keys == null ? 0 : keys . length ; if ( values != null && values . length == keyLength + 1 ) { final int throwableIndex = values . length - 1 ; if ( values [ throwableIndex ] instanceof Throwable ) { return ( Throwable ) values [ throwableIndex ] ; } } return null ;


signature:
public class Logger { /** * / * package private */
static @ Nullable Object [ ] chompArray ( @ Nullable final Object [ ] in , final int count ) { } }

implementation: if ( count == 0 || in == null ) { return in ; } return Arrays . copyOf ( in , in . length - count ) ;


signature:
public class MapSerialziationStrategy { /** * Serialize an event .
 * @ param event The event .
 * @ param eventName The event name .
 * @ param map The message key to value pairs .
 * @ return Serialization of message as a < code > String < / code > .
 * @ throws Exception Serialization may throw any < code > Exception < / code > . */
public String serialize ( final ILoggingEvent event , final String eventName , @ Nullable final Map < String , ? extends Object > map ) throws Exception { } }

implementation:
final StringWriter jsonWriter = new StringWriter ( ) ; final JsonGenerator jsonGenerator = _jsonFactory . createGenerator ( jsonWriter ) ; // Start wrapper
StenoSerializationHelper . startStenoWrapper ( event , eventName , jsonGenerator , _objectMapper ) ; // Write event data
jsonGenerator . writeObjectFieldStart ( "data" ) ; if ( map != null ) { for ( final Map . Entry < String , ? extends Object > entry : map . entrySet ( ) ) { if ( StenoSerializationHelper . isSimpleType ( entry . getValue ( ) ) ) { jsonGenerator . writeObjectField ( entry . getKey ( ) , entry . getValue ( ) ) ; } else { jsonGenerator . writeFieldName ( entry . getKey ( ) ) ; _objectMapper . writeValue ( jsonGenerator , entry . getValue ( ) ) ; } } } jsonGenerator . writeEndObject ( ) ; // End ' data ' field
// Output throwable
StenoSerializationHelper . writeThrowable ( event . getThrowableProxy ( ) , jsonGenerator , _objectMapper ) ; // End wrapper
StenoSerializationHelper . endStenoWrapper ( event , eventName , jsonGenerator , _objectMapper , _encoder ) ; return jsonWriter . toString ( ) ;


signature:
public class StandardSerializationStrategy { /** * Serialize an event .
 * @ param event The event .
 * @ param eventName The event name .
 * @ return Serialization of message as a < code > String < / code > .
 * @ throws Exception Serialization may throw any < code > Exception < / code > . */
public String serialize ( final ILoggingEvent event , final String eventName ) throws Exception { } }

implementation:
final StringWriter jsonWriter = new StringWriter ( ) ; final JsonGenerator jsonGenerator = _jsonFactory . createGenerator ( jsonWriter ) ; // Start wrapper
StenoSerializationHelper . startStenoWrapper ( event , eventName , jsonGenerator , _objectMapper ) ; // Write event data
jsonGenerator . writeObjectFieldStart ( "data" ) ; jsonGenerator . writeObjectField ( "message" , event . getFormattedMessage ( ) ) ; jsonGenerator . writeEndObject ( ) ; // End ' data ' field
// Output throwable
StenoSerializationHelper . writeThrowable ( event . getThrowableProxy ( ) , jsonGenerator , _objectMapper ) ; // End wrapper
StenoSerializationHelper . endStenoWrapper ( event , eventName , jsonGenerator , _objectMapper , _encoder ) ; return jsonWriter . toString ( ) ;


signature:
public class LogBuilderAspect { /** * Before outputting the message inject additional context .
 * @ param joinPoint The < code > JoinPoint < / code > . */
@ Before ( "call(* com.arpnetworking.steno.LogBuilder.log())" ) public void addToContextLineAndMethod ( final JoinPoint joinPoint ) { } }

implementation: final SourceLocation sourceLocation = joinPoint . getSourceLocation ( ) ; final LogBuilder targetLogBuilder = ( LogBuilder ) joinPoint . getTarget ( ) ; targetLogBuilder . addContext ( "line" , String . valueOf ( sourceLocation . getLine ( ) ) ) ; targetLogBuilder . addContext ( "file" , sourceLocation . getFileName ( ) ) ; targetLogBuilder . addContext ( "class" , sourceLocation . getWithinType ( ) ) ;


signature:
public class StenoSerializationHelper { /** * Start writing the Steno JSON wrapper .
 * @ since 1.8.0
 * @ param event Instance of < code > ILoggingEvent < / code > .
 * @ param eventName The name of the event .
 * @ param jsonGenerator < code > JsonGenerator < / code > instance .
 * @ param objectMapper < code > ObjectMapper < / code > instance .
 * @ throws java . io . IOException If writing JSON fails . */
public static void startStenoWrapper ( final ILoggingEvent event , final String eventName , final JsonGenerator jsonGenerator , final ObjectMapper objectMapper ) throws IOException { } }

implementation: final StenoSerializationHelper . StenoLevel level = StenoSerializationHelper . StenoLevel . findByLogbackLevel ( event . getLevel ( ) ) ; jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeObjectField ( "time" , ISO_DATE_TIME_FORMATTER . format ( Instant . ofEpochMilli ( event . getTimeStamp ( ) ) ) ) ; jsonGenerator . writeObjectField ( "name" , eventName ) ; jsonGenerator . writeObjectField ( "level" , level . name ( ) ) ;