idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
27,300 | public static boolean isHaveAttribute ( AttributeSet attrs , String attribute ) { return attrs . getAttributeValue ( Ui . androidStyleNameSpace , attribute ) != null ; } | Check the AttributeSet values have a attribute String on user set the attribute resource . Form android styles namespace |
27,301 | protected int setPaintAlpha ( Paint paint , int alpha ) { final int prevAlpha = paint . getAlpha ( ) ; paint . setAlpha ( Ui . modulateAlpha ( prevAlpha , alpha ) ) ; return prevAlpha ; } | Set the draw paint alpha by modulateAlpha |
27,302 | public static Reflector with ( String name , ClassLoader classLoader ) throws ReflectException { return with ( getClassForName ( name , classLoader ) ) ; } | Create a Reflector by class name form ClassLoader |
27,303 | public Reflector set ( String name , Object value ) throws ReflectException { try { Field field = field0 ( name ) ; field . setAccessible ( true ) ; field . set ( obj , unwrap ( value ) ) ; return this ; } catch ( Exception e ) { throw new ReflectException ( e ) ; } } | Set the target field value |
27,304 | @ SuppressWarnings ( "RedundantTypeArguments" ) public < T > T get ( String name ) throws ReflectException { return field ( name ) . < T > get ( ) ; } | Get the target field value |
27,305 | public Reflector create ( Object ... args ) throws ReflectException { Class < ? > [ ] types = getTypes ( args ) ; try { Constructor < ? > constructor = type ( ) . getDeclaredConstructor ( types ) ; return with ( constructor , args ) ; } catch ( NoSuchMethodException e ) { for ( Constructor < ? > constructor : type ( ) ... | We can create class by args structural parameters |
27,306 | @ SuppressLint ( "DefaultLocale" ) private static String toLowerCaseFirstOne ( String string ) { int length = string . length ( ) ; if ( length == 0 || Character . isLowerCase ( string . charAt ( 0 ) ) ) { return string ; } else if ( length == 1 ) { return string . toLowerCase ( ) ; } else { return ( new StringBuilder ... | Change string first char to lower case |
27,307 | public static < T > Class < ? > [ ] getClasses ( Type [ ] types ) { if ( types == null ) return null ; if ( types . length == 0 ) return new Class < ? > [ 0 ] ; Class < ? > [ ] classes = new Class [ types . length ] ; for ( int i = 0 ; i < types . length ; i ++ ) { classes [ i ] = getClass ( types [ i ] ) ; } return cl... | Get the underlying class array for a type array or null if the type is a variable type . |
27,308 | public void handleMessage ( Message msg ) { if ( msg . what == ASYNC ) { mAsyncDispatcher . dispatch ( ) ; } else if ( msg . what == SYNC ) { mSyncDispatcher . dispatch ( ) ; } else super . handleMessage ( msg ) ; } | Run in main thread |
27,309 | public void setBackgroundColorRes ( int colorRes ) { ColorStateList colorStateList = UiCompat . getColorStateList ( getResources ( ) , colorRes ) ; if ( colorStateList == null ) setBackgroundColor ( 0 ) ; else setBackgroundColor ( colorStateList . getDefaultColor ( ) ) ; } | Set the background color by resource id |
27,310 | protected void setLoadingDrawable ( LoadingDrawable drawable ) { if ( drawable == null ) { throw new NullPointerException ( "LoadingDrawable is null, You can only set the STYLE_CIRCLE and STYLE_LINE parameters." ) ; } else { drawable . setCallback ( this ) ; mLoadingDrawable = drawable ; invalidate ( ) ; requestLayout ... | In this we set LoadingDrawable really |
27,311 | public void setBorder ( int flag , int size , int color ) { if ( mBorder != flag || mBorderSize != size || mBorderColor != color ) { mBorder = flag ; mBorderSize = size ; mBorderColor = color ; if ( flag <= 0 ) { mBorderDrawable = null ; } else { RectF borderRect ; if ( ( flag & BORDER_ALL ) == BORDER_ALL ) borderRect ... | Set the border You can init border size color and decision that direction contains border |
27,312 | private static void destroyService ( ) { Thread thread = DESTROY_THREAD ; if ( thread == null ) { thread = new Thread ( ) { public void run ( ) { try { Thread . sleep ( 5000 ) ; dispose ( ) ; } catch ( InterruptedException e ) { } DESTROY_THREAD = null ; } } ; thread . setDaemon ( true ) ; DESTROY_THREAD = thread ; thr... | Destroy Service After 5 seconds run |
27,313 | private static void cancelDestroyService ( ) { Thread thread = DESTROY_THREAD ; if ( thread != null ) { DESTROY_THREAD = null ; thread . interrupt ( ) ; } } | Cancel Destroy Service |
27,314 | private static void bindService ( ) { synchronized ( Command . class ) { if ( ! IS_BIND ) { Context context = Cmd . getContext ( ) ; if ( context == null ) { throw new NullPointerException ( "Context not should null. Please call Cmd.init(Context)" ) ; } else { context . bindService ( new Intent ( context , CommandServi... | Start bind Service |
27,315 | private static String commandRun ( Command command ) { if ( I_COMMAND == null ) { synchronized ( I_LOCK ) { if ( I_COMMAND == null ) { try { I_LOCK . wait ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } } } cancelDestroyService ( ) ; int count = 5 ; Exception error = null ; while ( count > 0 ) ... | Run do Command |
27,316 | public static void dispose ( ) { synchronized ( Command . class ) { if ( IS_BIND ) { Context context = Cmd . getContext ( ) ; if ( context != null ) { try { context . unbindService ( I_CONN ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } I_COMMAND = null ; IS_BIND = false ; } } } | Dispose unbindService stopService |
27,317 | private int computeFlags ( int curFlags ) { curFlags &= ~ ( WindowManager . LayoutParams . FLAG_IGNORE_CHEEK_PRESSES | WindowManager . LayoutParams . FLAG_NOT_FOCUSABLE | WindowManager . LayoutParams . FLAG_NOT_TOUCHABLE | WindowManager . LayoutParams . FLAG_WATCH_OUTSIDE_TOUCH | WindowManager . LayoutParams . FLAG_LAY... | I m NOT completely sure how all this bitwise things work ... |
27,318 | public void setProgress ( float progress ) { if ( progress < 0 ) mProgress = 0 ; else if ( mProgress > 1 ) mProgress = 1 ; else mProgress = progress ; stop ( ) ; onProgressChange ( mProgress ) ; invalidateSelf ( ) ; } | Set the draw progress The progress include 0~1 float On changed stop animation draw |
27,319 | public void setTrackColor ( ColorStateList stateList ) { mTrackStateList = stateList ; mTrackColor = mTrackStateList . getDefaultColor ( ) ; if ( mAlpha < 255 ) { mCurTrackColor = Ui . modulateColorAlpha ( mTrackColor , mAlpha ) ; } else { mCurTrackColor = mTrackColor ; } } | Set the Track ColorStateList |
27,320 | public void setScrubberColor ( ColorStateList stateList ) { mScrubberStateList = stateList ; mScrubberColor = mScrubberStateList . getDefaultColor ( ) ; if ( mAlpha < 255 ) { mCurScrubberColor = Ui . modulateColorAlpha ( mScrubberColor , mAlpha ) ; } else { mCurScrubberColor = mScrubberColor ; } } | Set the Scrubber ColorStateList |
27,321 | public void setThumbColor ( ColorStateList stateList ) { mThumbStateList = stateList ; mThumbColor = mThumbStateList . getDefaultColor ( ) ; if ( mAlpha < 255 ) { mCurThumbColor = Ui . modulateColorAlpha ( mThumbColor , mAlpha ) ; } else { mCurThumbColor = mThumbColor ; } } | Set the Thumb ColorStateList |
27,322 | protected boolean changeColor ( int color ) { boolean bFlag = mColor != color ; if ( bFlag ) { mColor = color ; onColorChange ( color ) ; invalidateSelf ( ) ; } return bFlag ; } | Set CurrentColor value |
27,323 | public static Result onBackground ( Action action ) { final HandlerPoster poster = getBackgroundPoster ( ) ; if ( Looper . myLooper ( ) == poster . getLooper ( ) ) { action . call ( ) ; return new ActionAsyncTask ( action , true ) ; } ActionAsyncTask task = new ActionAsyncTask ( action ) ; poster . async ( task ) ; ret... | Asynchronously The current thread asynchronous run relative to the sub thread not blocking the current thread |
27,324 | public static Result onUiAsync ( Action action ) { if ( Looper . myLooper ( ) == Looper . getMainLooper ( ) ) { action . call ( ) ; return new ActionAsyncTask ( action , true ) ; } ActionAsyncTask task = new ActionAsyncTask ( action ) ; getUiPoster ( ) . async ( task ) ; return task ; } | Asynchronously The current thread asynchronous run relative to the main thread not blocking the current thread |
27,325 | public static void onUiSync ( Action action ) { if ( Looper . myLooper ( ) == Looper . getMainLooper ( ) ) { action . call ( ) ; return ; } ActionSyncTask poster = new ActionSyncTask ( action ) ; getUiPoster ( ) . sync ( poster ) ; poster . waitRun ( ) ; } | Synchronously The current thread relative thread synchronization operation blocking the current thread thread for the main thread to complete |
27,326 | void onComplete ( TraceRouteThread trace , boolean isError , boolean isArrived , TraceRouteContainer routeContainer ) { if ( threads != null ) { synchronized ( mLock ) { try { threads . remove ( trace ) ; } catch ( NullPointerException e ) { e . printStackTrace ( ) ; } } } if ( ! isDone ) { if ( isError ) this . errorC... | Will the run thread is complete should call this method |
27,327 | private static List < String > parseFontFamily ( String val ) { List < String > fonts = null ; TextScanner scan = new TextScanner ( val ) ; while ( true ) { String item = scan . nextQuotedString ( ) ; if ( item == null ) item = scan . nextTokenWithWhitespace ( ',' ) ; if ( item == null ) break ; if ( fonts == null ) fo... | Parse a font family list |
27,328 | private static Length parseFontSize ( String val ) { try { Length size = FontSizeKeywords . get ( val ) ; if ( size == null ) size = parseLength ( val ) ; return size ; } catch ( SVGParseException e ) { return null ; } } | Parse a font size keyword or numerical value |
27,329 | private static Style . FontStyle parseFontStyle ( String val ) { switch ( val ) { case "italic" : return Style . FontStyle . Italic ; case "normal" : return Style . FontStyle . Normal ; case "oblique" : return Style . FontStyle . Oblique ; default : return null ; } } | Parse a font style keyword |
27,330 | private static Style . FillRule parseFillRule ( String val ) { if ( "nonzero" . equals ( val ) ) return Style . FillRule . NonZero ; if ( "evenodd" . equals ( val ) ) return Style . FillRule . EvenOdd ; return null ; } | Parse fill rule |
27,331 | private static Style . LineCap parseStrokeLineCap ( String val ) { if ( "butt" . equals ( val ) ) return Style . LineCap . Butt ; if ( "round" . equals ( val ) ) return Style . LineCap . Round ; if ( "square" . equals ( val ) ) return Style . LineCap . Square ; return null ; } | Parse stroke - linecap |
27,332 | private static Style . LineJoin parseStrokeLineJoin ( String val ) { if ( "miter" . equals ( val ) ) return Style . LineJoin . Miter ; if ( "round" . equals ( val ) ) return Style . LineJoin . Round ; if ( "bevel" . equals ( val ) ) return Style . LineJoin . Bevel ; return null ; } | Parse stroke - linejoin |
27,333 | private static Length [ ] parseStrokeDashArray ( String val ) { TextScanner scan = new TextScanner ( val ) ; scan . skipWhitespace ( ) ; if ( scan . empty ( ) ) return null ; Length dash = scan . nextLength ( ) ; if ( dash == null ) return null ; if ( dash . isNegative ( ) ) return null ; float sum = dash . floatValue ... | Parse stroke - dasharray |
27,334 | private static VectorEffect parseVectorEffect ( String val ) { switch ( val ) { case NONE : return Style . VectorEffect . None ; case "non-scaling-stroke" : return Style . VectorEffect . NonScalingStroke ; default : return null ; } } | Parse a vector effect keyword |
27,335 | private static RenderQuality parseRenderQuality ( String val ) { switch ( val ) { case "auto" : return RenderQuality . auto ; case "optimizeQuality" : return RenderQuality . optimizeQuality ; case "optimizeSpeed" : return RenderQuality . optimizeSpeed ; default : return null ; } } | Parse a rendering quality property |
27,336 | private static Set < String > parseSystemLanguage ( String val ) { TextScanner scan = new TextScanner ( val ) ; HashSet < String > result = new HashSet < > ( ) ; while ( ! scan . empty ( ) ) { String language = scan . nextToken ( ) ; int hyphenPos = language . indexOf ( '-' ) ; if ( hyphenPos != - 1 ) { language = lang... | must be supported if we are to render this element |
27,337 | public void setSVG ( SVG svg , String css ) { if ( svg == null ) throw new IllegalArgumentException ( "Null value passed to setSVG()" ) ; this . svg = svg ; this . renderOptions . css ( css ) ; doRender ( ) ; } | Directly set the SVG and the CSS . |
27,338 | @ SuppressWarnings ( { "WeakerAccess" , "unused" } ) public static SVG getFromAsset ( AssetManager assetManager , String filename ) throws SVGParseException , IOException { SVGParser parser = new SVGParser ( ) ; InputStream is = assetManager . open ( filename ) ; try { return parser . parse ( is , enableInternalEntitie... | Read and parse an SVG from the assets folder . |
27,339 | @ SuppressWarnings ( { "WeakerAccess" , "unused" } ) public RectF getDocumentViewBox ( ) { if ( this . rootElement == null ) throw new IllegalArgumentException ( "SVG document is empty" ) ; if ( this . rootElement . viewBox == null ) return null ; return this . rootElement . viewBox . toRectF ( ) ; } | Returns the viewBox attribute of the current SVG document . |
27,340 | public Typeface resolveFont ( String fontFamily , int fontWeight , String fontStyle ) { Log . i ( TAG , "resolveFont(" + fontFamily + "," + fontWeight + "," + fontStyle + ")" ) ; try { return Typeface . createFromAsset ( assetManager , fontFamily + ".ttf" ) ; } catch ( RuntimeException ignored ) { } try { return Typefa... | Attempt to find the specified font in the assets folder and return a Typeface object . For the font name Foo first the file Foo . ttf will be tried and if that fails Foo . otf . |
27,341 | public String resolveCSSStyleSheet ( String url ) { Log . i ( TAG , "resolveCSSStyleSheet(" + url + ")" ) ; return getAssetAsString ( url ) ; } | Attempt to find the specified stylesheet file in the assets folder and return its string contents . |
27,342 | private void render ( SVG . Svg obj ) { Box viewPort = makeViewPort ( obj . x , obj . y , obj . width , obj . height ) ; render ( obj , viewPort , obj . viewBox , obj . preserveAspectRatio ) ; } | Renderers for each element type |
27,343 | private Box makeViewPort ( Length x , Length y , Length width , Length height ) { float _x = ( x != null ) ? x . floatValueX ( this ) : 0f ; float _y = ( y != null ) ? y . floatValueY ( this ) : 0f ; Box viewPortUser = getCurrentViewPortInUserUnits ( ) ; float _w = ( width != null ) ? width . floatValueX ( this ) : vie... | Derive the viewport from the x y width and height attributes of an object |
27,344 | private void checkForClipPath_OldStyle ( SvgElement obj , Box boundingBox ) { SvgObject ref = obj . document . resolveIRI ( state . style . clipPath ) ; if ( ref == null ) { error ( "ClipPath reference '%s' not found" , state . style . clipPath ) ; return ; } ClipPath clipPath = ( ClipPath ) ref ; if ( clipPath . child... | Pre - KitKat . Kept for backwards compatibility . |
27,345 | private void clipStatePush ( ) { CanvasLegacy . save ( canvas , CanvasLegacy . MATRIX_SAVE_FLAG ) ; stateStack . push ( state ) ; state = new RendererState ( state ) ; } | destroy the clip region we are trying to build . |
27,346 | public RenderOptions css ( String css ) { CSSParser parser = new CSSParser ( CSSParser . Source . RenderOptions ) ; this . css = parser . parse ( css ) ; return this ; } | Specifies some additional CSS rules that will be applied during render in addition to any specified in the file itself . |
27,347 | public void setChromeColor ( int color ) { if ( chromeColor != color ) { viewBorderPaint . setColor ( color ) ; chromeColor = color ; invalidate ( ) ; } } | Set the view border chrome color . |
27,348 | public void setChromeShadowColor ( int color ) { if ( chromeShadowColor != color ) { viewBorderPaint . setShadowLayer ( 1 , - 1 , 1 , color ) ; chromeShadowColor = color ; invalidate ( ) ; } } | Set the view border chrome shadow color . |
27,349 | public void writeToStream ( final String format , final OutputStream outputStream ) { try { LOGGER . debug ( "Writing WordCloud image data to output stream" ) ; ImageIO . write ( bufferedImage , format , outputStream ) ; LOGGER . debug ( "Done writing WordCloud image data to output stream" ) ; } catch ( final IOExcepti... | Write wordcloud image data to stream in the given format |
27,350 | protected void drawForegroundToBackground ( ) { if ( backgroundColor == null ) { return ; } final BufferedImage backgroundBufferedImage = new BufferedImage ( dimension . width , dimension . height , this . bufferedImage . getType ( ) ) ; final Graphics graphics = backgroundBufferedImage . getGraphics ( ) ; graphics . s... | create background then draw current word cloud on top of it . Doing it this way preserves the transparency of the this . bufferedImage s pixels for a more flexible pixel perfect collision |
27,351 | static int computeRadius ( final Dimension dimension , final Point start ) { final int maxDistanceX = Math . max ( start . x , dimension . width - start . x ) + 1 ; final int maxDistanceY = Math . max ( start . y , dimension . height - start . y ) + 1 ; return ( int ) Math . ceil ( Math . sqrt ( maxDistanceX * maxDista... | compute the maximum radius for the placing spiral |
27,352 | protected boolean place ( final Word word , final Point start ) { final Graphics graphics = this . bufferedImage . getGraphics ( ) ; final int maxRadius = computeRadius ( dimension , start ) ; final Point position = word . getPosition ( ) ; for ( int r = 0 ; r < maxRadius ; r += 2 ) { for ( int x = Math . max ( - start... | try to place in center build out in a spiral trying to place words for N steps |
27,353 | private static List < Color > createLinearGradient ( final Color color1 , final Color color2 , final int gradientSteps ) { final List < Color > colors = new ArrayList < > ( gradientSteps + 1 ) ; colors . add ( color1 ) ; for ( int i = 1 ; i < gradientSteps ; i ++ ) { float ratio = ( float ) i / ( float ) gradientSteps ... | Creates a linear Gradient between two colors |
27,354 | public void writeToFile ( final String outputFileName , final boolean blockThread , final boolean shutdownExecutor ) { if ( blockThread ) { waitForFuturesToBlockCurrentThread ( ) ; } super . writeToFile ( outputFileName ) ; if ( shutdownExecutor ) { this . shutdown ( ) ; } } | Writes the wordcloud to an imagefile . |
27,355 | private void initSyntaxRule ( ) throws SQLException { String identifierQuoteString = meta . getIdentifierQuoteString ( ) ; if ( identifierQuoteString . length ( ) > 1 ) { sqlLine . error ( "Identifier quote string is '" + identifierQuoteString + "'; quote strings longer than 1 char are not supported" ) ; identifierQuot... | Initializes a syntax rule for a given database connection . |
27,356 | boolean connect ( ) throws SQLException { try { if ( driver != null && driver . length ( ) != 0 ) { Class . forName ( driver ) ; } } catch ( ClassNotFoundException cnfe ) { return sqlLine . error ( cnfe ) ; } boolean foundDriver = false ; Driver theDriver = null ; try { theDriver = DriverManager . getDriver ( url ) ; f... | Connection to the specified data source . |
27,357 | public Map < String , OutputFormat > getOutputFormats ( SqlLine sqlLine ) { final Map < String , OutputFormat > outputFormats = new HashMap < > ( ) ; outputFormats . put ( "vertical" , new VerticalOutputFormat ( sqlLine ) ) ; outputFormats . put ( "table" , new TableOutputFormat ( sqlLine ) ) ; outputFormats . put ( "c... | Override this method to modify known output formats implementations . |
27,358 | private List < Object > buildMetadataArgs ( String line , String paramName , String [ ] defaultValues ) { final List < Object > list = new ArrayList < > ( ) ; final String [ ] [ ] ret = sqlLine . splitCompound ( line ) ; String [ ] compound ; if ( ret == null || ret . length != 2 ) { if ( defaultValues [ defaultValues ... | Constructs a list of string parameters for a metadata call . |
27,359 | public void closeall ( String line , DispatchCallback callback ) { close ( null , callback ) ; if ( callback . isSuccess ( ) ) { while ( callback . isSuccess ( ) ) { close ( null , callback ) ; } callback . setToSuccess ( ) ; } callback . setToFailure ( ) ; } | Closes all connections . |
27,360 | public void close ( String line , DispatchCallback callback ) { if ( sqlLine . getRecordOutputFile ( ) != null ) { stopRecording ( line , callback ) ; } DatabaseConnection databaseConnection = sqlLine . getDatabaseConnection ( ) ; if ( databaseConnection == null ) { callback . setToFailure ( ) ; return ; } try { Connec... | Closes the current connection . Closes the current file writer . |
27,361 | public void properties ( String line , DispatchCallback callback ) throws Exception { String example = "" ; example += "Usage: properties <properties file>" + SqlLine . getSeparator ( ) ; String [ ] parts = sqlLine . split ( line ) ; if ( parts . length < 2 ) { callback . setToFailure ( ) ; sqlLine . error ( example ) ... | Connects to the database defined in the specified properties file . |
27,362 | public void list ( String line , DispatchCallback callback ) { int index = 0 ; DatabaseConnections databaseConnections = sqlLine . getDatabaseConnections ( ) ; sqlLine . info ( sqlLine . loc ( "active-connections" , databaseConnections . size ( ) ) ) ; for ( DatabaseConnection databaseConnection : databaseConnections )... | Lists the current connections . |
27,363 | public void script ( String line , DispatchCallback callback ) { if ( sqlLine . getScriptOutputFile ( ) == null ) { startScript ( line , callback ) ; } else { stopScript ( line , callback ) ; } } | Starts or stops saving a script to a file . |
27,364 | private void stopScript ( String line , DispatchCallback callback ) { try { sqlLine . getScriptOutputFile ( ) . close ( ) ; } catch ( Exception e ) { sqlLine . handleException ( e ) ; } sqlLine . output ( sqlLine . loc ( "script-closed" , sqlLine . getScriptOutputFile ( ) ) ) ; sqlLine . setScriptOutputFile ( null ) ; ... | Stop writing to the script file and close the script . |
27,365 | private void startScript ( String line , DispatchCallback callback ) { OutputFile outFile = sqlLine . getScriptOutputFile ( ) ; if ( outFile != null ) { callback . setToFailure ( ) ; sqlLine . error ( sqlLine . loc ( "script-already-running" , outFile ) ) ; return ; } String filename ; if ( line . length ( ) == "script... | Start writing to the specified script file . |
27,366 | public void run ( String line , DispatchCallback callback ) { String filename ; if ( line . length ( ) == "run" . length ( ) || ( filename = sqlLine . dequote ( line . substring ( "run" . length ( ) + 1 ) ) ) == null ) { sqlLine . error ( "Usage: run <file name>" ) ; callback . setToFailure ( ) ; return ; } List < Stri... | Runs a script from the specified file . |
27,367 | public static String expand ( String filename ) { if ( filename . startsWith ( "~" + File . separator ) ) { try { String home = System . getProperty ( "user.home" ) ; if ( home != null ) { return home + filename . substring ( 1 ) ; } } catch ( SecurityException e ) { } } return filename ; } | Expands ~ to the home directory . |
27,368 | public void record ( String line , DispatchCallback callback ) { if ( sqlLine . getRecordOutputFile ( ) == null ) { startRecording ( line , callback ) ; } else { stopRecording ( line , callback ) ; } } | Starts or stops saving all output to a file . |
27,369 | private void stopRecording ( String line , DispatchCallback callback ) { try { sqlLine . getRecordOutputFile ( ) . close ( ) ; } catch ( Exception e ) { sqlLine . handleException ( e ) ; } sqlLine . output ( sqlLine . loc ( "record-closed" , sqlLine . getRecordOutputFile ( ) ) ) ; sqlLine . setRecordOutputFile ( null )... | Stop writing output to the record file . |
27,370 | private void startRecording ( String line , DispatchCallback callback ) { OutputFile outputFile = sqlLine . getRecordOutputFile ( ) ; if ( outputFile != null ) { callback . setToFailure ( ) ; sqlLine . error ( sqlLine . loc ( "record-already-running" , outputFile ) ) ; return ; } String filename ; if ( line . length ( ... | Start writing to the specified record file . |
27,371 | public static Status mainWithInputRedirection ( String [ ] args , InputStream inputStream ) throws IOException { return start ( args , inputStream , false ) ; } | Starts the program with redirected input . |
27,372 | void registerKnownDrivers ( ) { if ( appConfig . allowedDrivers == null ) { return ; } for ( String driverName : appConfig . allowedDrivers ) { try { Class . forName ( driverName ) ; } catch ( Throwable t ) { } } } | Walk through all the known drivers and try to register them . |
27,373 | boolean isComment ( String line , boolean trim ) { final String trimmedLine = trim ? line . trim ( ) : line ; for ( String comment : getDialect ( ) . getSqlLineOneLineComments ( ) ) { if ( trimmedLine . startsWith ( comment ) ) { return true ; } } return false ; } | Test whether a line is a comment . |
27,374 | public boolean error ( String msg ) { output ( getColorBuffer ( ) . red ( msg ) , true , errorStream ) ; return false ; } | Issue the specified error message |
27,375 | boolean assertAutoCommit ( ) { if ( ! assertConnection ( ) ) { return false ; } try { if ( getDatabaseConnection ( ) . connection . getAutoCommit ( ) ) { return error ( loc ( "autocommit-needs-off" ) ) ; } } catch ( Exception e ) { return error ( e ) ; } return true ; } | Ensure that autocommit is on for the current connection |
27,376 | boolean assertConnection ( ) { try { if ( getDatabaseConnection ( ) == null || getDatabaseConnection ( ) . connection == null ) { return error ( loc ( "no-current-connection" ) ) ; } if ( getDatabaseConnection ( ) . connection . isClosed ( ) ) { return error ( loc ( "connection-is-closed" ) ) ; } } catch ( SQLException... | Assert that we have an active living connection . Print an error message if we do not . |
27,377 | void showWarnings ( ) { if ( getDatabaseConnection ( ) . connection == null ) { return ; } if ( ! getOpts ( ) . getShowWarnings ( ) ) { return ; } try { showWarnings ( getDatabaseConnection ( ) . connection . getWarnings ( ) ) ; } catch ( Exception e ) { handleException ( e ) ; } } | Print out any warnings that exist for the current connection . |
27,378 | String [ ] split ( String line , int assertLen , String usage ) { String [ ] ret = split ( line ) ; if ( ret . length != assertLen ) { error ( usage ) ; return null ; } return ret ; } | Split the line based on spaces asserting that the number of words is correct . |
27,379 | String wrap ( String toWrap , int len , int start ) { StringBuilder buff = new StringBuilder ( ) ; StringBuilder line = new StringBuilder ( ) ; char [ ] head = new char [ start ] ; Arrays . fill ( head , ' ' ) ; for ( StringTokenizer tok = new StringTokenizer ( toWrap , " " ) ; tok . hasMoreTokens ( ) ; ) { String next... | Wrap the specified string by breaking on space characters . |
27,380 | void progress ( int cur , int max ) { StringBuilder out = new StringBuilder ( ) ; if ( lastProgress != null ) { char [ ] back = new char [ lastProgress . length ( ) ] ; Arrays . fill ( back , '\b' ) ; out . append ( back ) ; } String progress = cur + "/" + ( max == - 1 ? "?" : "" + max ) + " " + ( max == - 1 ? "(??%)" ... | Output a progress indicator to the console . |
27,381 | String scanForDriver ( String url ) { try { Driver driver ; if ( ( driver = findRegisteredDriver ( url ) ) != null ) { return driver . getClass ( ) . getCanonicalName ( ) ; } scanDrivers ( ) ; if ( ( driver = findRegisteredDriver ( url ) ) != null ) { return driver . getClass ( ) . getCanonicalName ( ) ; } return null ... | Looks for a driver with a particular URL . Returns the name of the class if found null if not found . |
27,382 | < R > R withPrompting ( Supplier < R > action ) { if ( prompting ) { throw new IllegalArgumentException ( ) ; } prompting = true ; try { return action . get ( ) ; } finally { prompting = false ; } } | Enables prompting applies an action and disables prompting . |
27,383 | public boolean isDefault ( SqlLineProperty property ) { final String defaultValue = String . valueOf ( property . defaultValue ( ) ) ; final String currentValue = get ( property ) ; return String . valueOf ( ( Object ) null ) . equals ( currentValue ) || Objects . equals ( currentValue , defaultValue ) ; } | Returns whether the property is its default value . |
27,384 | ColorBuffer pad ( ColorBuffer str , int len ) { int n = str . getVisibleLength ( ) ; while ( n < len ) { str . append ( " " ) ; n ++ ; } return append ( str ) ; } | Pad the specified String with spaces to the indicated length |
27,385 | public ColorBuffer truncate ( int len ) { ColorBuffer cbuff = new ColorBuffer ( useColor ) ; ColorAttr lastAttr = null ; for ( Iterator < Object > i = parts . iterator ( ) ; cbuff . getVisibleLength ( ) < len && i . hasNext ( ) ; ) { Object next = i . next ( ) ; if ( next instanceof ColorAttr ) { lastAttr = ( ColorAttr... | Truncate the ColorBuffer to the specified length and return the new ColorBuffer . Any open color tags will be closed . |
27,386 | private int getStartingPoint ( String buffer ) { for ( int i = 0 ; i < buffer . length ( ) ; i ++ ) { if ( ! Character . isWhitespace ( buffer . charAt ( i ) ) ) { return i ; } } return buffer . length ( ) ; } | Returns the index of the first non - whitespace character . |
27,387 | int handleNumbers ( String line , BitSet numberBitSet , int startingPoint ) { int end = startingPoint + 1 ; while ( end < line . length ( ) && Character . isDigit ( line . charAt ( end ) ) ) { end ++ ; } if ( end == line . length ( ) ) { if ( Character . isDigit ( line . charAt ( line . length ( ) - 1 ) ) ) { numberBit... | Marks numbers position based on input . |
27,388 | int handleComments ( String line , BitSet commentBitSet , int startingPoint , boolean isSql ) { Set < String > oneLineComments = isSql ? sqlLine . getDialect ( ) . getOneLineComments ( ) : sqlLine . getDialect ( ) . getSqlLineOneLineComments ( ) ; final char ch = line . charAt ( startingPoint ) ; if ( startingPoint + 1... | Marks commented string position based on input . |
27,389 | int handleSqlSingleQuotes ( String line , BitSet quoteBitSet , int startingPoint ) { int end ; int quoteCounter = 1 ; boolean quotationEnded = false ; do { end = line . indexOf ( '\'' , startingPoint + 1 ) ; if ( end > - 1 ) { quoteCounter ++ ; } if ( end == - 1 || end == line . length ( ) - 1 ) { quoteBitSet . set ( s... | Marks single - quoted string position based on input . |
27,390 | public void post ( Object event ) { if ( event == null ) { throw new NullPointerException ( "Event to post must not be null." ) ; } enforcer . enforce ( this ) ; Set < Class < ? > > dispatchTypes = flattenHierarchy ( event . getClass ( ) ) ; boolean dispatched = false ; for ( Class < ? > eventType : dispatchTypes ) { S... | Posts an event to all registered handlers . This method will return successfully after the event has been posted to all handlers and regardless of any exceptions thrown by handlers . |
27,391 | protected void dispatchQueuedEvents ( ) { if ( isDispatching . get ( ) ) { return ; } isDispatching . set ( true ) ; try { while ( true ) { EventWithHandler eventWithHandler = eventsToDispatch . get ( ) . poll ( ) ; if ( eventWithHandler == null ) { break ; } if ( eventWithHandler . handler . isValid ( ) ) { dispatch (... | Drain the queue of events to be dispatched . As the queue is being drained new events may be posted to the end of the queue . |
27,392 | public boolean goBack ( ) { if ( _entries . size ( ) > 0 && ( _entries . get ( 0 ) . getName ( ) . equals ( ".." ) ) ) { _list . performItemClick ( _list , 0 , 0 ) ; return true ; } return false ; } | attempts to move to the parent directory |
27,393 | public static int getListYScroll ( final ListView list ) { View child = list . getChildAt ( 0 ) ; return child == null ? - 1 : list . getFirstVisiblePosition ( ) * child . getHeight ( ) - child . getTop ( ) + list . getPaddingTop ( ) ; } | This only works assuming that all list items have the same height! |
27,394 | public static Event retrieve ( String id , RequestOptions options ) throws StripeException { return retrieve ( id , null , options ) ; } | Retrieves the details of an event . Supply the unique identifier of the event which you might have received in a webhook . |
27,395 | public static Customer retrieve ( String customer ) throws StripeException { return retrieve ( customer , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of an existing customer . You need only supply the unique customer identifier that was returned upon customer creation . |
27,396 | public Discount deleteDiscount ( ) throws StripeException { return deleteDiscount ( ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Removes the currently applied discount on a customer . |
27,397 | public JsonElement serialize ( ExpandableField < ? > src , Type typeOfSrc , JsonSerializationContext context ) { if ( src . isExpanded ( ) ) { return context . serialize ( src . getExpanded ( ) ) ; } else if ( src . getId ( ) != null ) { return new JsonPrimitive ( src . getId ( ) ) ; } else { return null ; } } | Serializes an expandable attribute into a JSON string . |
27,398 | public static TaxRate retrieve ( String taxRate ) throws StripeException { return retrieve ( taxRate , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves a tax rate with the given ID . |
27,399 | public static TaxRate create ( TaxRateCreateParams params , RequestOptions options ) throws StripeException { String url = String . format ( "%s%s" , Stripe . getApiBase ( ) , "/v1/tax_rates" ) ; return request ( ApiResource . RequestMethod . POST , url , params , TaxRate . class , options ) ; } | Creates a new tax rate . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.