idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
15,300 | public Rectangle getBoundsSurrounding ( Rectangle content ) { Rectangle bounds = new Rectangle ( content ) ; bounds . width += _leftPad + _rightPad ; bounds . height += _topPad + _bottomPad ; bounds . x -= _leftPad ; bounds . y -= _topPad ; return bounds ; } | Returns a rectangle describing the bounds of this NinePatch when drawn such that it frames the given content rectangle . |
15,301 | protected static Rectangle getRectangle ( BufferedImage img , boolean stretch ) { Rectangle rect = new Rectangle ( 0 , 0 , img . getWidth ( ) - 2 , img . getHeight ( ) - 2 ) ; for ( int xx = 1 ; xx < rect . width + 1 ; xx ++ ) { if ( ImageUtil . hitTest ( img , xx , stretch ? 0 : img . getHeight ( ) - 1 ) ) { rect . x = xx - 1 ; rect . width -= rect . x ; break ; } } for ( int xx = img . getWidth ( ) - 1 ; xx >= rect . x + 1 ; xx -- ) { if ( ImageUtil . hitTest ( img , xx , stretch ? 0 : img . getHeight ( ) - 1 ) ) { rect . width = xx - rect . x ; break ; } } for ( int yy = 1 ; yy < rect . height + 1 ; yy ++ ) { if ( ImageUtil . hitTest ( img , stretch ? 0 : img . getWidth ( ) - 1 , yy ) ) { rect . y = yy - 1 ; rect . height -= rect . y ; break ; } } for ( int yy = img . getHeight ( ) - 1 ; yy >= rect . y + 1 ; yy -- ) { if ( ImageUtil . hitTest ( img , stretch ? 0 : img . getWidth ( ) - 1 , yy ) ) { rect . height = yy - rect . y ; break ; } } return rect ; } | Parses the image to find the bounds of the rectangle defined by pixels on the outside . |
15,302 | public void appendDirtySprite ( Sprite sprite , int tx , int ty ) { DirtyItem item = getDirtyItem ( ) ; item . init ( sprite , tx , ty ) ; _items . add ( item ) ; } | Appends the dirty sprite at the given coordinates to the dirty item list . |
15,303 | public void appendDirtyObject ( SceneObject scobj ) { DirtyItem item = getDirtyItem ( ) ; item . init ( scobj , scobj . info . x , scobj . info . y ) ; _items . add ( item ) ; } | Appends the dirty object tile at the given coordinates to the dirty item list . |
15,304 | public void paintAndClear ( Graphics2D gfx ) { int icount = _items . size ( ) ; for ( int ii = 0 ; ii < icount ; ii ++ ) { DirtyItem item = _items . get ( ii ) ; item . paint ( gfx ) ; item . clear ( ) ; _freelist . add ( item ) ; } _items . clear ( ) ; } | Paints all the dirty items in this list using the supplied graphics context . The items are removed from the dirty list after being painted and the dirty list ends up empty . |
15,305 | public void clear ( ) { for ( int icount = _items . size ( ) ; icount > 0 ; icount -- ) { DirtyItem item = _items . remove ( 0 ) ; item . clear ( ) ; _freelist . add ( item ) ; } } | Clears out any items that were in this list . |
15,306 | private Intermediate mapAndReduce ( Context ctx ) { final List < Map . Entry < Tags , MetricValue > > matcher_tsvs = matchers_ . stream ( ) . flatMap ( m -> m . filter ( ctx ) ) . map ( named_entry -> SimpleMapEntry . create ( named_entry . getKey ( ) . getTags ( ) , named_entry . getValue ( ) ) ) . collect ( Collectors . toList ( ) ) ; final Map < Boolean , List < TimeSeriesMetricDeltaSet > > expr_tsvs_map = exprs_ . stream ( ) . map ( expr -> expr . apply ( ctx ) ) . collect ( Collectors . partitioningBy ( TimeSeriesMetricDeltaSet :: isVector ) ) ; final List < TimeSeriesMetricDeltaSet > expr_tsvs = expr_tsvs_map . getOrDefault ( true , Collections . emptyList ( ) ) ; final Optional < T > scalar = expr_tsvs_map . getOrDefault ( false , Collections . emptyList ( ) ) . stream ( ) . map ( tsv_set -> map_ ( tsv_set . asScalar ( ) . get ( ) ) ) . reduce ( this :: reducer_ ) ; return new Intermediate ( scalar , unmodifiableMap ( aggregation_ . apply ( matcher_tsvs . stream ( ) , expr_tsvs . stream ( ) . flatMap ( TimeSeriesMetricDeltaSet :: streamAsMap ) , Map . Entry :: getKey , Map . Entry :: getKey , Map . Entry :: getValue , Map . Entry :: getValue ) . entrySet ( ) . stream ( ) . map ( entry -> { return entry . getValue ( ) . stream ( ) . map ( this :: map_ ) . reduce ( this :: reducer_ ) . map ( v -> SimpleMapEntry . create ( entry . getKey ( ) , v ) ) ; } ) . flatMap ( opt -> opt . map ( Stream :: of ) . orElseGet ( Stream :: empty ) ) . collect ( Collectors . toMap ( entry -> entry . getKey ( ) , entry -> entry . getValue ( ) ) ) ) ) ; } | Create a reduction of the matchers and expressions for a given context . |
15,307 | public List < Issue > getIssues ( Map < String , String > pParameters ) throws RedmineException { Set < NameValuePair > params = new HashSet < NameValuePair > ( ) ; for ( final Entry < String , String > param : pParameters . entrySet ( ) ) { params . add ( new BasicNameValuePair ( param . getKey ( ) , param . getValue ( ) ) ) ; } return transport . getObjectsList ( Issue . class , params ) ; } | Generic method to search for issues . |
15,308 | public void deleteRelation ( Integer id ) throws RedmineException { transport . deleteObject ( IssueRelation . class , Integer . toString ( id ) ) ; } | Delete Issue Relation with the given ID . |
15,309 | public Attachment uploadAttachment ( String fileName , String contentType , InputStream content ) throws RedmineException , IOException { final InputStream wrapper = new MarkedInputStream ( content , "uploadStream" ) ; final String token ; try { token = transport . upload ( wrapper ) ; final Attachment result = new Attachment ( ) ; result . setToken ( token ) ; result . setContentType ( contentType ) ; result . setFileName ( fileName ) ; return result ; } catch ( RedmineException e ) { unwrapIO ( e , "uploadStream" ) ; throw e ; } } | Uploads an attachement . |
15,310 | private void unwrapIO ( RedmineException orig , String tag ) throws IOException { Throwable e = orig ; while ( e != null ) { if ( e instanceof MarkedIOException ) { final MarkedIOException marked = ( MarkedIOException ) e ; if ( tag . equals ( marked . getTag ( ) ) ) throw marked . getIOException ( ) ; } e = e . getCause ( ) ; } } | Unwraps an IO . |
15,311 | public void addMembership ( Membership membership ) throws RedmineException { final Project project = membership . getProject ( ) ; if ( project == null ) throw new IllegalArgumentException ( "Project must be set" ) ; if ( membership . getUser ( ) == null ) throw new IllegalArgumentException ( "User must be set" ) ; transport . addChildEntry ( Project . class , getProjectKey ( project ) , membership ) ; } | Add a membership . |
15,312 | public void export ( Writer output , UndirectedGraph < V , E > g ) { export ( output , g , false ) ; } | Exports an undirected graph into a PLAIN text file in GML format . |
15,313 | public void export ( Writer output , DirectedGraph < V , E > g ) { export ( output , g , true ) ; } | Exports a directed graph into a PLAIN text file in GML format . |
15,314 | public void set ( final Iterable < String > strings ) { checkNotNull ( strings ) ; candidates . clear ( ) ; addAll ( strings ) ; } | Set completion strings ; replacing any existing . |
15,315 | public void addAll ( final Iterable < String > strings ) { checkNotNull ( strings ) ; for ( String string : strings ) { add ( string ) ; } } | Add all strings to existing candidates . |
15,316 | public void add ( final String string ) { checkNotNull ( string ) ; candidates . put ( string , candidate ( string ) ) ; } | Add a string to existing candidates . |
15,317 | public void add ( final String string , final Candidate candidate ) { checkNotNull ( string ) ; checkNotNull ( candidate ) ; candidates . put ( string , candidate ) ; } | Add string with specific completer . |
15,318 | protected void initNextPath ( long initStamp , long tickStamp ) { if ( _paths . size ( ) == 0 ) { _pable . pathCompleted ( tickStamp ) ; } else { _curPath = _paths . remove ( 0 ) ; _lastInit = initStamp ; _curPath . init ( _pableRep , initStamp ) ; _curPath . tick ( _pableRep , tickStamp ) ; } } | Initialize and start the next path in the sequence . |
15,319 | public static String getStatus ( String elementName , long percentage , double speed , String speedUnit , Duration eta ) { StringBuilder sb = new StringBuilder ( getBar ( percentage ) ) ; sb . append ( ( long ) speed ) ; if ( elementName != null ) { sb . append ( " " ) . append ( elementName ) ; } sb . append ( "/" ) . append ( speedUnit ) ; sb . append ( " ETA " ) . append ( FORMATTER . print ( eta . toPeriod ( ) ) ) ; return sb . toString ( ) ; } | Generate the full status . |
15,320 | protected static String getBar ( long percentage ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( percentage ) ; sb . append ( "% [" ) ; for ( int i = 0 ; i < 100 ; i ++ ) { if ( percentage == 100 || i < percentage - 1 ) { sb . append ( "=" ) ; } else if ( i == percentage - 1 ) { sb . append ( ">" ) ; } else { sb . append ( " " ) ; } } sb . append ( "] " ) ; return sb . toString ( ) ; } | Generates the progress bar for the given percentage |
15,321 | public void processConnect ( WebSocketChannel channel , WSURI location , String [ ] protocols ) { nextHandler . processConnect ( channel , location , protocols ) ; } | Process connect request to uri and protocol specified |
15,322 | public synchronized void processAuthorize ( WebSocketChannel channel , String authorizeToken ) { nextHandler . processAuthorize ( channel , authorizeToken ) ; } | Send authorize token to the Gateway |
15,323 | public tsfile_data data ( TimeSeriesCollection ts_data ) { final dictionary_delta dict_delta = new dictionary_delta ( ) ; dict_delta . gdd = new path_dictionary_delta [ 0 ] ; dict_delta . mdd = new path_dictionary_delta [ 0 ] ; dict_delta . sdd = new strval_dictionary_delta [ 0 ] ; dict_delta . tdd = new tag_dictionary_delta [ 0 ] ; final List < tsfile_record > records = new ArrayList < > ( ) ; final Iterator < TimeSeriesValue > tsv_iter = ts_data . getTSValues ( ) . stream ( ) . iterator ( ) ; while ( tsv_iter . hasNext ( ) ) { final TimeSeriesValue tsv = tsv_iter . next ( ) ; tsfile_record record = new tsfile_record ( ) ; record . group_ref = simpleGroupPath_index ( dict_delta , tsv . getGroup ( ) . getPath ( ) ) ; record . tag_ref = tags_index ( dict_delta , tsv . getGroup ( ) . getTags ( ) ) ; record . metrics = tsv . getMetrics ( ) . entrySet ( ) . stream ( ) . map ( entry -> { tsfile_record_entry tre = new tsfile_record_entry ( ) ; tre . metric_ref = metricName_index ( dict_delta , entry . getKey ( ) ) ; tre . v = metric_value_ ( dict_delta , entry . getValue ( ) ) ; return tre ; } ) . toArray ( tsfile_record_entry [ ] :: new ) ; records . add ( record ) ; } tsfile_data result = new tsfile_data ( ) ; result . records = records . stream ( ) . toArray ( tsfile_record [ ] :: new ) ; result . ts = timestamp ( ts_data . getTimestamp ( ) ) ; if ( dict_delta . gdd . length > 0 || dict_delta . mdd . length > 0 || dict_delta . sdd . length > 0 || dict_delta . tdd . length > 0 ) result . dd = dict_delta ; return result ; } | Transform a TimeSeriesCollection into the XDR serialized form . |
15,324 | public static < T > Iterable < T > simpleIterable ( final Iterable < T > iterable ) { requireNonNull ( iterable ) ; return ( ) -> iterable . iterator ( ) ; } | Wraps any iterable into a generic iterable object . This is useful for using complex iterables such as FluentIterable with libraries that use reflection to determine bean definitions such as Jackson . |
15,325 | public static < T > Iterable < T > distinct ( final Iterable < T > iterable ) { requireNonNull ( iterable ) ; return ( ) -> Iterators2 . distinct ( iterable . iterator ( ) ) ; } | If we can assume the iterable is sorted return the distinct elements . This only works if the data provided is sorted . |
15,326 | public String encodeAuthAmqPlain ( String username , String password ) { AmqpBuffer bytes = new AmqpBuffer ( ) ; bytes . putShortString ( "LOGIN" ) ; bytes . putTypeIdentifier ( "Longstr" ) ; bytes . putLongString ( username ) ; bytes . putShortString ( "PASSWORD" ) ; bytes . putTypeIdentifier ( "Longstr" ) ; bytes . putLongString ( password ) ; bytes . flip ( ) ; int len = bytes . remaining ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < len ; i ++ ) { builder . append ( ( char ) ( bytes . getUnsigned ( ) ) ) ; } String s = builder . toString ( ) ; return s ; } | Encodes the AMQPLAIN authentication response as an AmqpArguments |
15,327 | private Arg [ ] getMethodArguments ( List < Parameter > param ) { Arg [ ] val = new Arg [ param . size ( ) ] ; for ( int i = 0 ; i < param . size ( ) ; i ++ ) { String type = param . get ( i ) . type ; Arg arg = new Arg ( ) ; arg . type = type ; arg . name = param . get ( i ) . name ; Object v = null ; String type1 = null ; try { type1 = this . getMappedType ( type ) ; v = getObjectOfType ( type1 ) ; } catch ( Exception e ) { throw new IllegalStateException ( "type codec failed for type " + type + " for domain " + e . getMessage ( ) ) ; } this . bitCount = ( byte ) ( ( type1 == "Bit" ) ? this . bitCount + 1 : 0 ) ; arg . value = v ; val [ i ] = arg ; } return val ; } | Decodes arguments given a method s parameter list |
15,328 | public AmqpFrame getFrame ( ) { int pos = this . position ( ) ; AmqpMethod method = new AmqpMethod ( ) ; int classIndex ; AmqpFrame frame = new AmqpFrame ( ) ; if ( this . remaining ( ) > 7 ) { frame . setHeader ( this . getFrameHeader ( ) ) ; frame . setChannelId ( ( short ) frame . getHeader ( ) . channel ) ; frame . setType ( ( short ) frame . getHeader ( ) . frameType ) ; if ( this . remaining ( ) >= frame . getHeader ( ) . size + 1 ) { switch ( frame . getType ( ) ) { case AmqpConstants . FRAME_BODY : WrappedByteBuffer body = new AmqpBuffer ( ) ; int end = this . position ( ) + ( int ) frame . getHeader ( ) . size ; while ( position ( ) < end ) { body . put ( get ( ) ) ; } frame . setBody ( body ) ; frame . setMethodName ( "body" ) ; break ; case AmqpConstants . FRAME_HEADER : classIndex = this . getUnsignedShort ( ) ; @ SuppressWarnings ( "unused" ) short weight = ( short ) this . getUnsignedShort ( ) ; @ SuppressWarnings ( "unused" ) long bodySize = this . getUnsignedLong ( ) ; frame . setContentProperties ( this . getContentProperties ( ) ) ; frame . setMethodName ( "header" ) ; break ; case AmqpConstants . FRAME_METHOD : classIndex = this . getUnsignedShort ( ) ; int methodIndex = this . getUnsignedShort ( ) ; String indexes = String . valueOf ( classIndex ) + String . valueOf ( methodIndex ) ; method = MethodLookup . LookupMethod ( indexes ) ; List < Parameter > params = method . allParameters ; frame . setMethodName ( method . name ) ; frame . setArgs ( this . getMethodArguments ( params ) ) ; break ; case AmqpConstants . FRAME_HEARTBEAT : case AmqpConstants . FRAME_RABBITMQ_HEARTBEAT : throw new IllegalStateException ( "Received heartbeat frame even though the client has expressed no interest in heartbeat via tune-ok method." ) ; default : throw new IllegalStateException ( "Unrecognized AMQP 0-9-1 Frame type = " + frame . getType ( ) ) ; } short frameEnd = ( short ) this . getUnsigned ( ) ; if ( frameEnd != AmqpConstants . FRAME_END ) { throw new IllegalStateException ( "Invalid end of AMQP method frame" ) ; } } else { this . position ( pos ) ; return null ; } return frame ; } return null ; } | Parses the ByteBuffer and returns an AMQP frame |
15,329 | AmqpBuffer putMethodArguments ( Object [ ] args , List < Parameter > formalParams ) { for ( int i = 0 ; i < formalParams . size ( ) ; i ++ ) { String type = formalParams . get ( i ) . type ; if ( type == null ) { throw new IllegalStateException ( "Unknown AMQP domain " + type ) ; } String typeMap = getMappedType ( type ) ; putObjectOfType ( typeMap , args [ i ] ) ; this . bitCount = ( byte ) ( ( typeMap == "Bit" ) ? this . bitCount + 1 : 0 ) ; } return this ; } | Encodes arguments given a method s parameter list and the provided arguments |
15,330 | public void update ( Graphics g ) { Shape clip = g . getClip ( ) ; Rectangle dirty ; if ( clip != null ) { dirty = clip . getBounds ( ) ; } else { dirty = getRootPane ( ) . getBounds ( ) ; Insets insets = getInsets ( ) ; dirty . x += insets . left ; dirty . y += insets . top ; } if ( _fmgr != null ) { _fmgr . restoreFromBack ( dirty ) ; } } | We catch update requests and forward them on to the repaint infrastructure . |
15,331 | public static < T extends Serializable > T deserialize ( byte [ ] bytes ) throws IOException , ClassNotFoundException { return deserialize ( bytes , false ) ; } | Utility for returning a Serializable object from a byte array . |
15,332 | public PushProcessorPipeline build ( List < PushProcessorSupplier > processor_suppliers ) throws Exception { ApiServer api = null ; PushMetricRegistryInstance registry = null ; final List < PushProcessor > processors = new ArrayList < > ( processor_suppliers . size ( ) ) ; try { final EndpointRegistration epr ; if ( epr_ == null ) epr = api = new ApiServer ( api_sockaddr_ ) ; else epr = epr_ ; registry = cfg_ . create ( PushMetricRegistryInstance :: new , epr ) ; for ( PushProcessorSupplier pps : processor_suppliers ) processors . add ( pps . build ( epr ) ) ; if ( history_ != null ) registry . setHistory ( history_ ) ; if ( api != null ) api . start ( ) ; return new PushProcessorPipeline ( registry , collect_interval_seconds_ , processors ) ; } catch ( Exception ex ) { try { if ( api != null ) api . close ( ) ; } catch ( Exception ex1 ) { ex . addSuppressed ( ex1 ) ; } try { if ( registry != null ) registry . close ( ) ; } catch ( Exception ex1 ) { ex . addSuppressed ( ex1 ) ; } for ( PushProcessor pp : processors ) { try { pp . close ( ) ; } catch ( Exception ex1 ) { ex . addSuppressed ( ex1 ) ; } } throw ex ; } } | Creates a push processor . |
15,333 | public static BufferedImage createCompatibleImage ( BufferedImage source , int width , int height ) { WritableRaster raster = source . getRaster ( ) . createCompatibleWritableRaster ( width , height ) ; return new BufferedImage ( source . getColorModel ( ) , raster , false , null ) ; } | Creates a new buffered image with the same sample model and color model as the source image but with the new width and height . |
15,334 | public static BufferedImage createErrorImage ( int width , int height ) { BufferedImage img = new BufferedImage ( width , height , BufferedImage . TYPE_BYTE_INDEXED ) ; Graphics2D g = ( Graphics2D ) img . getGraphics ( ) ; g . setColor ( Color . red ) ; Label l = new Label ( "Error" ) ; l . layout ( g ) ; Dimension d = l . getSize ( ) ; for ( int yy = 0 ; yy < height ; yy += d . height ) { for ( int xx = 0 ; xx < width ; xx += ( d . width + 5 ) ) { l . render ( g , xx , yy ) ; } } g . dispose ( ) ; return img ; } | Creates an image with the word Error written in it . |
15,335 | public static BufferedImage recolorImage ( BufferedImage image , Colorization [ ] zations ) { ColorModel cm = image . getColorModel ( ) ; if ( ! ( cm instanceof IndexColorModel ) ) { throw new RuntimeException ( Logger . format ( "Unable to recolor images with non-index color model" , "cm" , cm . getClass ( ) ) ) ; } IndexColorModel icm = ( IndexColorModel ) cm ; int size = icm . getMapSize ( ) ; int zcount = zations . length ; int [ ] rgbs = new int [ size ] ; icm . getRGBs ( rgbs ) ; float [ ] hsv = new float [ 3 ] ; int [ ] fhsv = new int [ 3 ] ; for ( int ii = 0 ; ii < size ; ii ++ ) { int value = rgbs [ ii ] ; if ( ( value & 0xFF000000 ) == 0 ) { continue ; } int red = ( value >> 16 ) & 0xFF ; int green = ( value >> 8 ) & 0xFF ; int blue = ( value >> 0 ) & 0xFF ; Color . RGBtoHSB ( red , green , blue , hsv ) ; Colorization . toFixedHSV ( hsv , fhsv ) ; for ( int z = 0 ; z < zcount ; z ++ ) { Colorization cz = zations [ z ] ; if ( cz != null && cz . matches ( hsv , fhsv ) ) { rgbs [ ii ] = cz . recolorColor ( hsv ) ; break ; } } } IndexColorModel nicm = new IndexColorModel ( icm . getPixelSize ( ) , size , rgbs , 0 , icm . hasAlpha ( ) , icm . getTransparentPixel ( ) , icm . getTransferType ( ) ) ; return new BufferedImage ( nicm , image . getRaster ( ) , false , null ) ; } | Recolors the supplied image using the supplied colorizations . |
15,336 | public static void tileImage ( Graphics2D gfx , Mirage image , int x , int y , int width , int height ) { int iwidth = image . getWidth ( ) , iheight = image . getHeight ( ) ; int xnum = width / iwidth , xplus = width % iwidth ; int ynum = height / iheight , yplus = height % iheight ; Shape oclip = gfx . getClip ( ) ; for ( int ii = 0 ; ii < ynum ; ii ++ ) { int xx = x ; for ( int jj = 0 ; jj < xnum ; jj ++ ) { image . paint ( gfx , xx , y ) ; xx += iwidth ; } if ( xplus > 0 ) { gfx . clipRect ( xx , y , xplus , iheight ) ; image . paint ( gfx , xx , y ) ; gfx . setClip ( oclip ) ; } y += iheight ; } if ( yplus > 0 ) { int xx = x ; for ( int jj = 0 ; jj < xnum ; jj ++ ) { gfx . clipRect ( xx , y , iwidth , yplus ) ; image . paint ( gfx , xx , y ) ; gfx . setClip ( oclip ) ; xx += iwidth ; } if ( xplus > 0 ) { gfx . clipRect ( xx , y , xplus , yplus ) ; image . paint ( gfx , xx , y ) ; gfx . setClip ( oclip ) ; } } } | Paints multiple copies of the supplied image using the supplied graphics context such that the requested area is filled with the image . |
15,337 | public static void tileImageAcross ( Graphics2D gfx , Mirage image , int x , int y , int width ) { tileImage ( gfx , image , x , y , width , image . getHeight ( ) ) ; } | Paints multiple copies of the supplied image using the supplied graphics context such that the requested width is filled with the image . |
15,338 | public static void tileImageDown ( Graphics2D gfx , Mirage image , int x , int y , int height ) { tileImage ( gfx , image , x , y , image . getWidth ( ) , height ) ; } | Paints multiple copies of the supplied image using the supplied graphics context such that the requested height is filled with the image . |
15,339 | public static BufferedImage createTracedImage ( ImageCreator isrc , BufferedImage src , Color tcolor , int thickness ) { return createTracedImage ( isrc , src , tcolor , thickness , 1.0f , 1.0f ) ; } | Creates and returns a new image consisting of the supplied image traced with the given color and thickness . |
15,340 | protected static boolean bordersNonTransparentPixel ( BufferedImage data , int wid , int hei , boolean [ ] traced , int x , int y ) { if ( y > 0 ) { for ( int rxx = x - 1 ; rxx <= x + 1 ; rxx ++ ) { if ( rxx < 0 || rxx >= wid || traced [ ( ( y - 1 ) * wid ) + rxx ] ) { continue ; } if ( ( data . getRGB ( rxx , y - 1 ) & TRANS_MASK ) != 0 ) { return true ; } } } if ( x > 0 && ! traced [ ( y * wid ) + ( x - 1 ) ] ) { if ( ( data . getRGB ( x - 1 , y ) & TRANS_MASK ) != 0 ) { return true ; } } if ( x < wid - 1 && ! traced [ ( y * wid ) + ( x + 1 ) ] ) { if ( ( data . getRGB ( x + 1 , y ) & TRANS_MASK ) != 0 ) { return true ; } } if ( y < hei - 1 ) { for ( int rxx = x - 1 ; rxx <= x + 1 ; rxx ++ ) { if ( rxx < 0 || rxx >= wid || traced [ ( ( y + 1 ) * wid ) + rxx ] ) { continue ; } if ( ( data . getRGB ( rxx , y + 1 ) & TRANS_MASK ) != 0 ) { return true ; } } } return false ; } | Returns whether the given pixel is bordered by any non - transparent pixel . |
15,341 | public static BufferedImage composeMaskedImage ( ImageCreator isrc , BufferedImage mask , BufferedImage base ) { int wid = base . getWidth ( ) ; int hei = base . getHeight ( ) ; Raster maskdata = mask . getData ( ) ; Raster basedata = base . getData ( ) ; if ( maskdata . getNumBands ( ) == 4 && basedata . getNumBands ( ) >= 3 ) { WritableRaster target = basedata . createCompatibleWritableRaster ( wid , hei ) ; int [ ] adata = maskdata . getSamples ( 0 , 0 , wid , hei , 3 , ( int [ ] ) null ) ; target . setSamples ( 0 , 0 , wid , hei , 3 , adata ) ; for ( int ii = 0 ; ii < 3 ; ii ++ ) { int [ ] cdata = basedata . getSamples ( 0 , 0 , wid , hei , ii , ( int [ ] ) null ) ; target . setSamples ( 0 , 0 , wid , hei , ii , cdata ) ; } return new BufferedImage ( mask . getColorModel ( ) , target , true , null ) ; } else { BufferedImage target = isrc . createImage ( wid , hei , Transparency . TRANSLUCENT ) ; Graphics2D g2 = target . createGraphics ( ) ; try { g2 . drawImage ( mask , 0 , 0 , null ) ; g2 . setComposite ( AlphaComposite . SrcIn ) ; g2 . drawImage ( base , 0 , 0 , null ) ; } finally { g2 . dispose ( ) ; } return target ; } } | Create an image using the alpha channel from the first and the RGB values from the second . |
15,342 | public static BufferedImage composeMaskedImage ( ImageCreator isrc , Shape mask , BufferedImage base ) { int wid = base . getWidth ( ) ; int hei = base . getHeight ( ) ; BufferedImage target = isrc . createImage ( wid , hei , Transparency . TRANSLUCENT ) ; Graphics2D g2 = target . createGraphics ( ) ; try { g2 . setColor ( Color . BLACK ) ; g2 . fill ( mask ) ; g2 . setComposite ( AlphaComposite . SrcIn ) ; g2 . drawImage ( base , 0 , 0 , null ) ; } finally { g2 . dispose ( ) ; } return target ; } | Create a new image using the supplied shape as a mask from which to cut out pixels from the supplied image . Pixels inside the shape will be added to the final image pixels outside the shape will be clear . |
15,343 | public static void computeTrimmedBounds ( BufferedImage image , Rectangle tbounds ) { int width = image . getWidth ( ) , height = image . getHeight ( ) ; int firstrow = - 1 , lastrow = - 1 , minx = width , maxx = 0 ; for ( int yy = 0 ; yy < height ; yy ++ ) { int firstidx = - 1 , lastidx = - 1 ; for ( int xx = 0 ; xx < width ; xx ++ ) { int argb = image . getRGB ( xx , yy ) ; if ( ( argb >> 24 ) == 0 ) { continue ; } if ( firstidx == - 1 ) { firstidx = xx ; } lastidx = xx ; } if ( firstidx == - 1 ) { continue ; } minx = Math . min ( firstidx , minx ) ; maxx = Math . max ( lastidx , maxx ) ; if ( firstrow == - 1 ) { firstrow = yy ; } lastrow = yy ; } if ( firstrow != - 1 ) { tbounds . x = minx ; tbounds . y = firstrow ; tbounds . width = maxx - minx + 1 ; tbounds . height = lastrow - firstrow + 1 ; } else { tbounds . x = 0 ; tbounds . y = 0 ; tbounds . width = 1 ; tbounds . height = 1 ; } } | Computes the bounds of the smallest rectangle that contains all non - transparent pixels of this image . This isn t extremely efficient so you shouldn t be doing this anywhere exciting . |
15,344 | public static long getEstimatedMemoryUsage ( Raster raster ) { DataBuffer db = raster . getDataBuffer ( ) ; int bpe = ( int ) Math . ceil ( DataBuffer . getDataTypeSize ( db . getDataType ( ) ) / 8f ) ; return bpe * db . getSize ( ) ; } | Returns the estimated memory usage in bytes for the specified raster . |
15,345 | public static long getEstimatedMemoryUsage ( Iterator < BufferedImage > iter ) { long size = 0 ; while ( iter . hasNext ( ) ) { BufferedImage image = iter . next ( ) ; size += getEstimatedMemoryUsage ( image ) ; } return size ; } | Returns the estimated memory usage in bytes for all buffered images in the supplied iterator . |
15,346 | protected static GraphicsConfiguration getDefGC ( ) { if ( _gc == null ) { try { GraphicsEnvironment env = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; GraphicsDevice gd = env . getDefaultScreenDevice ( ) ; _gc = gd . getDefaultConfiguration ( ) ; } catch ( HeadlessException e ) { } } return _gc ; } | Obtains the default graphics configuration for this VM . If the JVM is in headless mode this method will return null . |
15,347 | public void getIntersectingSprites ( List < Sprite > list , Shape shape ) { int size = _sprites . size ( ) ; for ( int ii = 0 ; ii < size ; ii ++ ) { Sprite sprite = _sprites . get ( ii ) ; if ( sprite . intersects ( shape ) ) { list . add ( sprite ) ; } } } | When an animated view processes its dirty rectangles it may require an expansion of the dirty region which may in turn require the invalidation of more sprites than were originally invalid . In such cases the animated view can call back to the sprite manager asking it to append the sprites that intersect a particular region to the given list . |
15,348 | public void getHitSprites ( List < Sprite > list , int x , int y ) { for ( int ii = _sprites . size ( ) - 1 ; ii >= 0 ; ii -- ) { Sprite sprite = _sprites . get ( ii ) ; if ( sprite . hitTest ( x , y ) ) { list . add ( sprite ) ; } } } | When an animated view is determining what entity in its view is under the mouse pointer it may require a list of sprites that are hit by a particular pixel . The sprites bounds are first checked and sprites with bounds that contain the supplied point are further checked for a non - transparent at the specified location . |
15,349 | public Sprite getHighestHitSprite ( int x , int y ) { for ( int ii = _sprites . size ( ) - 1 ; ii >= 0 ; ii -- ) { Sprite sprite = _sprites . get ( ii ) ; if ( sprite . hitTest ( x , y ) ) { return sprite ; } } return null ; } | Finds the sprite with the highest render order that hits the specified pixel . |
15,350 | public void removeSprites ( Predicate < Sprite > pred ) { int idxoff = 0 ; for ( int ii = 0 , ll = _sprites . size ( ) ; ii < ll ; ii ++ ) { Sprite sprite = _sprites . get ( ii - idxoff ) ; if ( pred . apply ( sprite ) ) { _sprites . remove ( sprite ) ; sprite . invalidate ( ) ; sprite . shutdown ( ) ; idxoff ++ ; if ( ii <= _tickpos ) { _tickpos -- ; } } } } | Removes all sprites that match the supplied predicate . |
15,351 | public void cancelMove ( ) { if ( _path != null ) { Path oldpath = _path ; _path = null ; oldpath . wasRemoved ( this ) ; if ( _observers != null ) { _observers . apply ( new CancelledOp ( this , oldpath ) ) ; } } } | Cancels any path that the sprite may currently be moving along . |
15,352 | public void pathCompleted ( long timestamp ) { Path oldpath = _path ; _path = null ; oldpath . wasRemoved ( this ) ; if ( _observers != null ) { _observers . apply ( new CompletedOp ( this , oldpath , timestamp ) ) ; } } | Called by the active path when it has completed . |
15,353 | protected boolean tickPath ( long tickStamp ) { if ( _path == null ) { return false ; } if ( _pathStamp == 0 ) { _path . init ( this , _pathStamp = tickStamp ) ; } return ( _path == null ) ? true : _path . tick ( this , tickStamp ) ; } | Ticks any path assigned to this sprite . |
15,354 | public void layout ( Graphics2D gfx , SceneObject tipFor , Rectangle boundary ) { layout ( gfx , ICON_PAD , EXTRA_PAD ) ; bounds = new Rectangle ( _size ) ; for ( int ii = 0 , ll = _layouts . size ( ) ; ii < ll ; ii ++ ) { LayoutReg reg = _layouts . get ( ii ) ; String act = tipFor . info . action == null ? "" : tipFor . info . action ; if ( act . startsWith ( reg . prefix ) ) { reg . layout . layout ( gfx , boundary , tipFor , this ) ; break ; } } } | Called to initialize the tip so that it can be painted . |
15,355 | public static void registerTipLayout ( String prefix , TipLayout layout ) { LayoutReg reg = new LayoutReg ( ) ; reg . prefix = prefix ; reg . layout = layout ; _layouts . insertSorted ( reg ) ; } | It may be desirable to layout object tips specially depending on what sort of actions they represent so we allow different tip layout algorithms to be registered for particular object prefixes . The registration is simply a list searched from longest string to shortest string for the first match to an object s action . |
15,356 | public static boolean isLeaf ( Node node ) { return node instanceof Leaf || node . children ( ) == null || node . children ( ) . size ( ) == 0 ; } | Returns true if a node is a leaf . Note that a leaf can also be a parent node that does not have any children . |
15,357 | public static boolean isEmpty ( Node node ) { return ( node == null || ( node . children ( ) != null && node . children ( ) . size ( ) == 0 ) ) ; } | Determines if a node is null or a single parent node without children . |
15,358 | public static boolean parentContainsOnlyLeaves ( ParentNode parentNode ) { for ( Node child : parentNode . children ( ) ) { if ( ! isLeaf ( child ) ) return false ; } return true ; } | Determines if parent node has children that are all leaves |
15,359 | public static Criteria criteriaFromNode ( Node node , Comparator rangeComparator ) { return criteriaFromNode ( node , rangeComparator , null ) ; } | Creates criteria from a node . A Comparator is injected into all nodes which need to determine order or equality . |
15,360 | public static void renameTileSet ( String mapPath , String oldName , String newName ) throws PersistenceException { MapFileTileSetIDBroker broker = new MapFileTileSetIDBroker ( new File ( mapPath ) ) ; if ( ! broker . renameTileSet ( oldName , newName ) ) { throw new PersistenceException ( "No such old tileset '" + oldName + "'." ) ; } broker . commit ( ) ; } | Loads up the tileset map file with the specified path and copies the tileset ID from the old tileset name to the new tileset name . This is necessary when a tileset is renamed so that the new name does not cause the tileset to be assigned a new tileset ID . Bear in mind that the old name should never again be used as it will conflict with a tileset provided under the new name . |
15,361 | protected TrimmedTileSet trim ( TileSet aset , OutputStream fout ) throws IOException { return TrimmedTileSet . trimTileSet ( aset , fout ) ; } | Converts the tileset to a trimmed tile set and saves it at the specified location . |
15,362 | protected void saveBroker ( File mapfile , HashMapIDBroker broker ) throws RuntimeException { if ( ! broker . isModified ( ) ) { return ; } try { BufferedWriter bout = new BufferedWriter ( new FileWriter ( mapfile ) ) ; broker . writeTo ( bout ) ; bout . close ( ) ; } catch ( IOException ioe ) { throw new RuntimeException ( "Unable to store component ID map [mapfile=" + mapfile + "]" , ioe ) ; } } | Stores a persistent representation of the supplied hashmap ID broker in the specified file . |
15,363 | private static GroupName nameFromObjectName ( ObjectName obj_name , NamedResolverMap resolvedMap ) { String name = obj_name . getKeyProperty ( "name" ) ; String type = obj_name . getKeyProperty ( "type" ) ; String domain = obj_name . getDomain ( ) ; Map < String , MetricValue > tags = obj_name . getKeyPropertyList ( ) . entrySet ( ) . stream ( ) . filter ( ( entry ) -> ! entry . getKey ( ) . equals ( "name" ) ) . filter ( ( entry ) -> ! entry . getKey ( ) . equals ( "type" ) ) . map ( Tag :: valueOf ) . collect ( Collectors . toMap ( ( Tag t ) -> t . getName ( ) , ( Tag t ) -> t . getValue ( ) ) ) ; final List < String > path = new ArrayList < > ( ) ; if ( name != null ) { path . addAll ( Arrays . asList ( name . split ( "\\." ) ) ) ; } else if ( type != null ) { path . addAll ( Arrays . asList ( domain . split ( "\\." ) ) ) ; path . add ( type ) ; } else { path . addAll ( Arrays . asList ( domain . split ( "\\." ) ) ) ; } return resolvedMap . getGroupName ( path , tags ) ; } | Extract a metric group name from a JMX ObjectName . |
15,364 | static boolean isSorted ( Iterable < ? extends TimeSeriesCollection > tscIterable ) { final Iterator < ? extends TimeSeriesCollection > iter = tscIterable . iterator ( ) ; if ( ! iter . hasNext ( ) ) return true ; DateTime timestamp = iter . next ( ) . getTimestamp ( ) ; while ( iter . hasNext ( ) ) { final DateTime nextTimestamp = iter . next ( ) . getTimestamp ( ) ; if ( ! nextTimestamp . isAfter ( timestamp ) ) return false ; timestamp = nextTimestamp ; } return true ; } | Validation function to check if an iterable is sorted with ascending timestamps . |
15,365 | public void resolve ( Observer observer ) { if ( _state == UNLOADING ) { _state = LOADED ; _manager . restoreClip ( this ) ; } if ( _state == LOADED ) { if ( observer != null ) { observer . clipLoaded ( this ) ; } return ; } if ( observer != null ) { _observers . add ( observer ) ; } if ( _state == LOADING ) { return ; } AL10 . alGetError ( ) ; _buffer = new Buffer ( _manager ) ; int errno = AL10 . alGetError ( ) ; if ( errno != AL10 . AL_NO_ERROR ) { log . warning ( "Failed to create buffer [key=" + getKey ( ) + ", errno=" + errno + "]." ) ; _buffer = null ; _manager . queueClipFailure ( this ) ; } else { _state = LOADING ; _manager . queueClipLoad ( this ) ; } } | Instructs this buffer to resolve its underlying clip and be ready to be played ASAP . |
15,366 | public void dispose ( ) { if ( _buffer != null ) { if ( _bound > 0 ) { _state = UNLOADING ; return ; } _buffer . delete ( ) ; _buffer = null ; _state = UNLOADED ; } } | Frees up the internal audio buffers associated with this clip . |
15,367 | protected boolean bind ( Clip clip ) { AL10 . alGetError ( ) ; _buffer . setData ( clip . format , clip . data , clip . frequency ) ; int errno = AL10 . alGetError ( ) ; if ( errno != AL10 . AL_NO_ERROR ) { log . warning ( "Failed to bind clip" , "key" , getKey ( ) , "errno" , errno ) ; failed ( ) ; return false ; } _state = LOADED ; _size = _buffer . getSize ( ) ; _observers . apply ( new ObserverList . ObserverOp < Observer > ( ) { public boolean apply ( Observer observer ) { observer . clipLoaded ( ClipBuffer . this ) ; return true ; } } ) ; _observers . clear ( ) ; return true ; } | This method is called back on the main thread and instructs this buffer to bind the clip data to this buffer s OpenAL buffer . |
15,368 | protected void failed ( ) { if ( _buffer != null ) { _buffer . delete ( ) ; _buffer = null ; } _state = UNLOADED ; _observers . apply ( new ObserverList . ObserverOp < Observer > ( ) { public boolean apply ( Observer observer ) { observer . clipFailed ( ClipBuffer . this ) ; return true ; } } ) ; _observers . clear ( ) ; } | Called when we fail in some part of the process in resolving our clip data . Notifies our observers and resets the clip to the UNLOADED state . |
15,369 | protected void createVolatileImage ( ) { if ( _image != null ) { _image . flush ( ) ; } _image = _imgr . createImage ( _bounds . width , _bounds . height , getTransparency ( ) ) ; refreshVolatileImage ( ) ; } | Creates our volatile image from the information in our source image . |
15,370 | public boolean askBoolean ( final String question ) { checkNotNull ( question ) ; log . trace ( "Ask boolean; question={}" , question ) ; String result = readLine ( String . format ( "%s (yes/no): " , question ) ) ; return result . equalsIgnoreCase ( "yes" ) ; } | Ask a question which results in a boolean result . |
15,371 | public void addPressCommand ( int keyCode , String command , int rate ) { addPressCommand ( keyCode , command , rate , DEFAULT_REPEAT_DELAY ) ; } | Adds a mapping from a key press to an action command string that will auto - repeat at the specified repeat rate . Overwrites any existing mapping and repeat rate that may have already been registered . |
15,372 | public void addPressCommand ( int keyCode , String command , int rate , long repeatDelay ) { KeyRecord krec = getKeyRecord ( keyCode ) ; krec . pressCommand = command ; krec . repeatRate = rate ; krec . repeatDelay = repeatDelay ; } | Adds a mapping from a key press to an action command string that will auto - repeat at the specified repeat rate after the specified auto - repeat delay has expired . Overwrites any existing mapping for the specified key code that may have already been registered . |
15,373 | public void addReleaseCommand ( int keyCode , String command ) { KeyRecord krec = getKeyRecord ( keyCode ) ; krec . releaseCommand = command ; } | Adds a mapping from a key release to an action command string . Overwrites any existing mapping that may already have been registered . |
15,374 | protected KeyRecord getKeyRecord ( int keyCode ) { KeyRecord krec = _keys . get ( keyCode ) ; if ( krec == null ) { krec = new KeyRecord ( ) ; _keys . put ( keyCode , krec ) ; } return krec ; } | Returns the key record for the specified key creating it and inserting it in the key table if necessary . |
15,375 | public void addSprite ( Sprite sprite ) { _metamgr . addSprite ( sprite ) ; if ( ( ( sprite instanceof ActionSprite ) || ( sprite instanceof HoverSprite ) ) && ( _actionSpriteCount ++ == 0 ) ) { if ( _actionHandler == null ) { _actionHandler = createActionSpriteHandler ( ) ; } addMouseListener ( _actionHandler ) ; addMouseMotionListener ( _actionHandler ) ; } } | Adds a sprite to this panel . |
15,376 | public void removeSprite ( Sprite sprite ) { _metamgr . removeSprite ( sprite ) ; if ( ( ( sprite instanceof ActionSprite ) || ( sprite instanceof HoverSprite ) ) && ( -- _actionSpriteCount == 0 ) ) { removeMouseListener ( _actionHandler ) ; removeMouseMotionListener ( _actionHandler ) ; } } | Removes a sprite from this panel . |
15,377 | public void clearSprites ( ) { _metamgr . clearSprites ( ) ; if ( _actionHandler != null ) { removeMouseListener ( _actionHandler ) ; removeMouseMotionListener ( _actionHandler ) ; _actionSpriteCount = 0 ; } } | Removes all sprites from this panel . |
15,378 | public void tick ( long tickStamp ) { if ( _metamgr . isPaused ( ) ) { return ; } willTick ( tickStamp ) ; _metamgr . tick ( tickStamp ) ; didTick ( tickStamp ) ; _tickPaintPending = true ; } | from interface FrameParticipant |
15,379 | public void addObscurer ( Obscurer obscurer ) { if ( _obscurerList == null ) { _obscurerList = Lists . newArrayList ( ) ; } _obscurerList . add ( obscurer ) ; } | Adds an element that could be obscuring the panel and thus requires extra redrawing . |
15,380 | protected void addObscurerDirtyRegions ( boolean changedOnly ) { if ( _obscurerList != null ) { for ( Obscurer obscurer : _obscurerList ) { Rectangle obscured = obscurer . getObscured ( changedOnly ) ; if ( obscured != null ) { Point pt = new Point ( obscured . x , obscured . y ) ; SwingUtilities . convertPointFromScreen ( pt , this ) ; addObscurerDirtyRegion ( new Rectangle ( pt . x , pt . y , obscured . width , obscured . height ) ) ; } } } } | Add dirty regions for all our obscurers . |
15,381 | protected void paintDirtyRect ( Graphics2D gfx , Rectangle rect ) { paintBehind ( gfx , rect ) ; paintBits ( gfx , AnimationManager . BACK , rect ) ; paintBetween ( gfx , rect ) ; paintBits ( gfx , AnimationManager . FRONT , rect ) ; paintInFront ( gfx , rect ) ; } | Paints all the layers of the specified dirty region . |
15,382 | public static String getEntityEncoding ( HttpEntity entity ) { final Header header = entity . getContentEncoding ( ) ; if ( header == null ) return null ; return header . getValue ( ) ; } | Returns entity encoding . |
15,383 | public static String getCharset ( HttpEntity entity ) { final String guess = EntityUtils . getContentCharSet ( entity ) ; return guess == null ? HTTP . DEFAULT_CONTENT_CHARSET : guess ; } | Returns entity charset to use . |
15,384 | public Tuple < String , Boolean > decodeFormat ( int type , String format ) { boolean quotes = true ; switch ( placeOf ( type ) ) { case PLACE : switch ( modeOf ( type ) ) { case EMOTE : quotes = false ; break ; } break ; } return Tuple . newTuple ( format , quotes ) ; } | Determines the format string and whether to use quotes based on the chat type . |
15,385 | public int decodeType ( String localtype ) { if ( ChatCodes . USER_CHAT_TYPE . equals ( localtype ) ) { return TELL ; } else if ( ChatCodes . PLACE_CHAT_TYPE . equals ( localtype ) ) { return PLACE ; } else { return 0 ; } } | Decodes the main chat type given the supplied localtype provided by the chat system . |
15,386 | public int adjustTypeByMode ( int mode , int type ) { switch ( mode ) { case ChatCodes . DEFAULT_MODE : return type | SPEAK ; case ChatCodes . EMOTE_MODE : return type | EMOTE ; case ChatCodes . THINK_MODE : return type | THINK ; case ChatCodes . SHOUT_MODE : return type | SHOUT ; case ChatCodes . BROADCAST_MODE : return BROADCAST ; default : return type ; } } | Adjust the chat type based on the mode of the chat message . |
15,387 | public Color getOutlineColor ( int type ) { switch ( type ) { case BROADCAST : return BROADCAST_COLOR ; case TELL : return TELL_COLOR ; case TELLFEEDBACK : return TELLFEEDBACK_COLOR ; case INFO : return INFO_COLOR ; case FEEDBACK : return FEEDBACK_COLOR ; case ATTENTION : return ATTENTION_COLOR ; default : return Color . black ; } } | Computes the chat glyph outline color from the chat message type . |
15,388 | public SparseMisoSceneModel parseScene ( String path ) throws IOException , SAXException { _model = null ; _digester . push ( this ) ; FileInputStream stream = null ; try { stream = new FileInputStream ( path ) ; _digester . parse ( stream ) ; } finally { StreamUtil . close ( stream ) ; } return _model ; } | Parses the XML file at the specified path into a scene model instance . |
15,389 | public static PathMatcher valueOf ( String str ) throws ParseException { try { return valueOf ( new StringReader ( str ) ) ; } catch ( IOException ex ) { throw new IllegalStateException ( "StringReader IO error?" , ex ) ; } } | Read path matcher from string . |
15,390 | public static PathMatcher valueOf ( Reader reader ) throws IOException , ParseException { class DescriptiveErrorListener extends BaseErrorListener { public List < String > errors = new ArrayList < > ( ) ; public void syntaxError ( Recognizer < ? , ? > recognizer , Object offendingSymbol , int line , int charPositionInLine , String msg , org . antlr . v4 . runtime . RecognitionException e ) { LOG . log ( Level . INFO , "Parse error: {0}:{1} -> {2}" , new Object [ ] { line , charPositionInLine , msg } ) ; errors . add ( String . format ( "%d:%d: %s" , line , charPositionInLine , msg ) ) ; } } final DescriptiveErrorListener error_listener = new DescriptiveErrorListener ( ) ; final PathMatcherLexer lexer = new PathMatcherLexer ( CharStreams . fromReader ( reader ) ) ; lexer . removeErrorListeners ( ) ; lexer . addErrorListener ( error_listener ) ; final PathMatcherGrammar parser = new PathMatcherGrammar ( new BufferedTokenStream ( lexer ) ) ; parser . removeErrorListeners ( ) ; parser . addErrorListener ( error_listener ) ; final PathMatcherGrammar . ExprContext expr ; try { expr = parser . expr ( ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , "parser yielded exceptional return" , ex ) ; if ( ! error_listener . errors . isEmpty ( ) ) throw new ParseException ( error_listener . errors , ex ) ; else throw ex ; } if ( ! error_listener . errors . isEmpty ( ) ) { if ( expr . exception != null ) throw new ParseException ( error_listener . errors , expr . exception ) ; throw new ParseException ( error_listener . errors ) ; } else if ( expr . exception != null ) { throw new ParseException ( expr . exception ) ; } return expr . s ; } | Read path matcher from reader . |
15,391 | public List < ChannelListener > getChannelListeners ( ) { if ( changes == null ) { return ( List < ChannelListener > ) Collections . EMPTY_LIST ; } List < EventListener > listeners = changes . getListenerList ( AMQP ) ; if ( ( listeners == null ) || listeners . isEmpty ( ) ) { return ( List < ChannelListener > ) Collections . EMPTY_LIST ; } ArrayList < ChannelListener > list = new ArrayList < ChannelListener > ( ) ; for ( EventListener listener : listeners ) { list . add ( ( ChannelListener ) listener ) ; } return list ; } | Returns the list of ChannelListeners registered with this AmqpChannel instance . |
15,392 | AmqpChannel openChannel ( ) { if ( readyState == ReadyState . OPEN ) { return this ; } Object [ ] args = { "" } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodName = "openChannel" ; String methodId = "20" + "10" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; asyncClient . getStateMachine ( ) . enterState ( "channelReady" , "" , null ) ; asyncClient . enqueueAction ( methodName , "channelWrite" , arguments , null , null ) ; readyState = ReadyState . CONNECTING ; return this ; } | Creates a Channel to the AMQP server on the given clients connection |
15,393 | public AmqpChannel flowChannel ( boolean active ) { isFlowOn = active ; Object [ ] args = { active } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodId = "20" + "20" ; String methodName = "flowChannel" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; if ( client . getReadyState ( ) == ReadyState . OPEN ) { asyncClient . enqueueAction ( methodName , "channelWrite" , arguments , null , null ) ; } return this ; } | This method asks the peer to pause or restart the flow of content data sent by a consumer . This is a simple flow - control mechanism that a peer can use to avoid overflowing its queues or otherwise finding itself receiving more messages than it can process . |
15,394 | public AmqpChannel closeChannel ( int replyCode , String replyText , int classId , int methodId1 ) { if ( readyState == ReadyState . CLOSED ) { return this ; } Object [ ] args = { replyCode , replyText , classId , methodId1 } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodName = "closeChannel" ; String methodId = "20" + "40" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; asyncClient . enqueueAction ( methodName , "channelWrite" , arguments , null , null ) ; return this ; } | This method indicates that the sender wants to close the channel . |
15,395 | private AmqpChannel closeOkChannel ( ) { if ( readyState == ReadyState . CLOSED ) { return this ; } Object [ ] args = { } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodName = "closeOkChannel" ; String methodId = "20" + "41" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; asyncClient . enqueueAction ( methodName , "channelWrite" , arguments , null , null ) ; return this ; } | Confirms to the peer that a flow command was received and processed . |
15,396 | public AmqpChannel deleteQueue ( String queue , boolean ifUnused , boolean ifEmpty , boolean noWait ) { Object [ ] args = { 0 , queue , ifUnused , ifEmpty , noWait } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodName = "deleteQueue" ; String methodId = "50" + "40" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; boolean hasnowait = false ; for ( int i = 0 ; i < amqpMethod . allParameters . size ( ) ; i ++ ) { String argname = amqpMethod . allParameters . get ( i ) . name ; if ( argname == "noWait" ) { hasnowait = true ; break ; } } asyncClient . enqueueAction ( methodName , "channelWrite" , arguments , null , null ) ; if ( hasnowait && noWait ) { asyncClient . enqueueAction ( "nowait" , null , null , null , null ) ; } return this ; } | This method deletes a queue . When a queue is deleted any pending messages are sent to a dead - letter queue if this is defined in the server configuration and all consumers on the queue are canceled . |
15,397 | public AmqpChannel unbindQueue ( String queue , String exchange , String routingKey , AmqpArguments arguments ) { Object [ ] args = { 0 , queue , exchange , routingKey , arguments } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodName = "unbindQueue" ; String methodId = "50" + "50" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; Object [ ] methodArguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; asyncClient . enqueueAction ( methodName , "channelWrite" , methodArguments , null , null ) ; return this ; } | This method unbinds a queue from an exchange . |
15,398 | public AmqpChannel qosBasic ( int prefetchSize , int prefetchCount , boolean global ) { Object [ ] args = { prefetchSize , prefetchCount , global } ; WrappedByteBuffer bodyArg = null ; HashMap < String , Object > headersArg = null ; String methodName = "qosBasic" ; String methodId = "60" + "10" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg , headersArg } ; asyncClient . enqueueAction ( methodName , "channelWrite" , arguments , null , null ) ; return this ; } | This method requests a specific quality of service . The QoS can be specified for the current channel or for all channels on the connection . The particular properties and semantics of a qos method always depend on the content class semantics . Though the qos method could in principle apply to both peers it is currently meaningful only for the server . |
15,399 | public AmqpChannel publishBasic ( ByteBuffer body , AmqpProperties properties , String exchange , String routingKey , boolean mandatory , boolean immediate ) { @ SuppressWarnings ( "unchecked" ) Map < String , Object > amqpProps = ( Map < String , Object > ) Collections . EMPTY_MAP ; if ( properties != null ) { amqpProps = properties . getProperties ( ) ; } HashMap < String , Object > props = ( HashMap < String , Object > ) amqpProps ; return publishBasic ( body , props , exchange , routingKey , mandatory , immediate ) ; } | This method publishes a message to a specific exchange . The message will be routed to queues as defined by the exchange configuration and distributed to any active consumers when the transaction if any is committed . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.