idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
15,500 | public static void setConverterFactoryClass ( Configuration conf , Class < ? extends ConverterFactory > converterFactoryClass ) { conf . setClass ( CONVERTER_FACTORY , converterFactoryClass , ConverterFactory . class ) ; LOG . debug ( "Set input ConverterFactory class on conf: {}" , converterFactoryClass ) ; } | Sets the ConverterFactory class |
15,501 | static StructTypeInfo getTypeInfo ( Configuration conf ) { StructTypeInfo inputTypeInfo = ( StructTypeInfo ) TypeInfoUtils . getTypeInfoFromTypeString ( conf . get ( INPUT_TYPE_INFO ) ) ; LOG . debug ( "Got input typeInfo from conf: {}" , inputTypeInfo ) ; return inputTypeInfo ; } | Gets the StructTypeInfo that declares the columns to be read from the configuration |
15,502 | public static void setTypeInfo ( Configuration conf , StructTypeInfo typeInfo ) { conf . set ( INPUT_TYPE_INFO , typeInfo . getTypeName ( ) ) ; LOG . debug ( "Set input typeInfo on conf: {}" , typeInfo ) ; } | Sets the StructTypeInfo that declares the columns to be read in the configuration |
15,503 | static StructTypeInfo getSchemaTypeInfo ( Configuration conf ) { String schemaTypeInfo = conf . get ( SCHEMA_TYPE_INFO ) ; if ( schemaTypeInfo != null && ! schemaTypeInfo . isEmpty ( ) ) { LOG . debug ( "Got schema typeInfo from conf: {}" , schemaTypeInfo ) ; return ( StructTypeInfo ) TypeInfoUtils . getTypeInfoFromTypeString ( conf . get ( SCHEMA_TYPE_INFO ) ) ; } return null ; } | Gets the StructTypeInfo that declares the total schema of the file from the configuration |
15,504 | public static void setSchemaTypeInfo ( Configuration conf , StructTypeInfo schemaTypeInfo ) { if ( schemaTypeInfo != null ) { conf . set ( SCHEMA_TYPE_INFO , schemaTypeInfo . getTypeName ( ) ) ; LOG . debug ( "Set schema typeInfo on conf: {}" , schemaTypeInfo ) ; } } | Sets the StructTypeInfo that declares the total schema of the file in the configuration |
15,505 | static void setReadColumns ( Configuration conf , StructTypeInfo actualStructTypeInfo ) { StructTypeInfo readStructTypeInfo = getTypeInfo ( conf ) ; LOG . info ( "Read StructTypeInfo: {}" , readStructTypeInfo ) ; List < Integer > ids = new ArrayList < > ( ) ; List < String > names = new ArrayList < > ( ) ; List < String > readNames = readStructTypeInfo . getAllStructFieldNames ( ) ; List < String > actualNames = actualStructTypeInfo . getAllStructFieldNames ( ) ; for ( int i = 0 ; i < actualNames . size ( ) ; i ++ ) { String actualName = actualNames . get ( i ) ; if ( readNames . contains ( actualName ) ) { TypeInfo actualTypeInfo = actualStructTypeInfo . getStructFieldTypeInfo ( actualName ) ; TypeInfo readTypeInfo = readStructTypeInfo . getStructFieldTypeInfo ( actualName ) ; if ( ! actualTypeInfo . equals ( readTypeInfo ) ) { throw new IllegalStateException ( "readTypeInfo [" + readTypeInfo + "] does not match actualTypeInfo [" + actualTypeInfo + "]" ) ; } ids . add ( i ) ; names . add ( actualName ) ; } } if ( ids . size ( ) == 0 ) { throw new IllegalStateException ( "None of the selected columns were found in the ORC file." ) ; } LOG . info ( "Set column projection on columns: {} ({})" , ids , names ) ; ColumnProjectionUtils . appendReadColumns ( conf , ids , names ) ; } | Sets which fields are to be read from the ORC file |
15,506 | protected void addClassEditors ( BuilderModel model , String cprefix ) { List < ComponentClass > classes = model . getComponentClasses ( ) ; int size = classes . size ( ) ; for ( int ii = 0 ; ii < size ; ii ++ ) { ComponentClass cclass = classes . get ( ii ) ; if ( ! cclass . name . startsWith ( cprefix ) ) { continue ; } List < Integer > ccomps = model . getComponents ( cclass ) ; if ( ccomps . size ( ) > 0 ) { add ( new ClassEditor ( model , cclass , ccomps ) ) ; } else { log . info ( "Not creating editor for empty class " + "[class=" + cclass + "]." ) ; } } } | Adds editor user interface elements for each component class to allow the user to select the desired component . |
15,507 | public boolean isListening ( ) throws Exception { try { JSONObject resp = new JSONObject ( Get . get ( API_BASE_URL + ":" + API_PORT , Constants . REQUEST_HEARTBEAT , "" ) ) ; return true ; } catch ( Exception e ) { return false ; } } | Returns true if there is RoboRemoteServer currently listening |
15,508 | public JSONArray map ( String query , String method_name , Object ... items ) throws Exception { QueryBuilder builder = new QueryBuilder ( API_PORT ) ; builder . map ( query , method_name , items ) ; return builder . execute ( ) ; } | Used to call a method with a list of arguments |
15,509 | public static Tracker parseTracker ( JSONObject object ) throws JSONException { final int id = JsonInput . getInt ( object , "id" ) ; final String name = JsonInput . getStringNotNull ( object , "name" ) ; return new Tracker ( id , name ) ; } | Parses a tracker . |
15,510 | public static IssueStatus parseStatus ( JSONObject object ) throws JSONException { final int id = JsonInput . getInt ( object , "id" ) ; final String name = JsonInput . getStringNotNull ( object , "name" ) ; final IssueStatus result = new IssueStatus ( id , name ) ; if ( object . has ( "is_default" ) ) result . setDefaultStatus ( JsonInput . getOptionalBool ( object , "is_default" ) ) ; if ( object . has ( "is_closed" ) ) result . setClosed ( JsonInput . getOptionalBool ( object , "is_closed" ) ) ; return result ; } | Parses a status . |
15,511 | public static Project parseMinimalProject ( JSONObject content ) throws JSONException { final Project result = new Project ( ) ; result . setId ( JsonInput . getInt ( content , "id" ) ) ; result . setIdentifier ( JsonInput . getStringOrNull ( content , "identifier" ) ) ; result . setName ( JsonInput . getStringNotNull ( content , "name" ) ) ; return result ; } | Parses a minimal version of a project . |
15,512 | public static Project parseProject ( JSONObject content ) throws JSONException { final Project result = new Project ( ) ; result . setId ( JsonInput . getInt ( content , "id" ) ) ; result . setIdentifier ( JsonInput . getStringOrNull ( content , "identifier" ) ) ; result . setName ( JsonInput . getStringNotNull ( content , "name" ) ) ; result . setDescription ( JsonInput . getStringOrEmpty ( content , "description" ) ) ; result . setHomepage ( JsonInput . getStringOrEmpty ( content , "homepage" ) ) ; result . setCreatedOn ( getDateOrNull ( content , "created_on" ) ) ; result . setUpdatedOn ( getDateOrNull ( content , "updated_on" ) ) ; final JSONObject parentProject = JsonInput . getObjectOrNull ( content , "parent" ) ; if ( parentProject != null ) result . setParentId ( JsonInput . getInt ( parentProject , "id" ) ) ; result . setTrackers ( JsonInput . getListOrNull ( content , "trackers" , TRACKER_PARSER ) ) ; return result ; } | Parses a project . |
15,513 | public int getRenderPriority ( String action , String component , int orientation ) { int ocount = ( _overrides != null ) ? _overrides . size ( ) : 0 ; for ( int ii = 0 ; ii < ocount ; ii ++ ) { PriorityOverride over = _overrides . get ( ii ) ; if ( over . matches ( action , component , orientation ) ) { return over . renderPriority ; } } return renderPriority ; } | Returns the render priority appropriate for the specified action orientation and component . |
15,514 | public void addPriorityOverride ( PriorityOverride override ) { if ( _overrides == null ) { _overrides = new ComparableArrayList < PriorityOverride > ( ) ; } _overrides . insertSorted ( override ) ; } | Adds the supplied render priority override record to this component class . |
15,515 | public int fringesOn ( int first , int second ) { FringeRecord f1 = _frecs . get ( first ) ; if ( null != f1 ) { if ( f1 . tilesets . size ( ) > 0 ) { FringeRecord f2 = _frecs . get ( second ) ; if ( ( null == f2 ) || ( f1 . priority > f2 . priority ) ) { return f1 . priority ; } } } return - 1 ; } | If the first base tileset fringes upon the second return the fringe priority of the first base tileset otherwise return - 1 . |
15,516 | public FringeTileSetRecord getFringe ( int baseset , int hashValue ) { FringeRecord f = _frecs . get ( baseset ) ; return f . tilesets . get ( hashValue % f . tilesets . size ( ) ) ; } | Get a random FringeTileSetRecord from amongst the ones listed for the specified base tileset . |
15,517 | public Window getWindow ( ) { Component parent = getParent ( ) ; while ( ! ( parent instanceof Window ) && parent != null ) { parent = parent . getParent ( ) ; } return ( Window ) parent ; } | from interface FrameManager . ManagedRoot |
15,518 | public String getAttributeString ( String attName ) { Object o = attributes . get ( attName ) ; if ( o == null ) { return null ; } else { return ( String ) o ; } } | Get the value for a given attribute . |
15,519 | private void maybeSetProperty ( final String name , final String value ) { if ( System . getProperty ( name ) == null ) { System . setProperty ( name , value ) ; } } | Helper to only set a property if not already set . |
15,520 | public void render ( Graphics2D gfx ) { Object oalias = SwingUtil . activateAntiAliasing ( gfx ) ; gfx . setColor ( getBackground ( ) ) ; gfx . fill ( _shape ) ; gfx . setColor ( _outline ) ; gfx . draw ( _shape ) ; SwingUtil . restoreAntiAliasing ( gfx , oalias ) ; if ( _icon != null ) { _icon . paintIcon ( _owner . getTarget ( ) , gfx , _ipos . x , _ipos . y ) ; } gfx . setColor ( Color . BLACK ) ; _label . render ( gfx , _lpos . x , _lpos . y ) ; } | Render the chat glyph with no thought to dirty rectangles or restoring composites . |
15,521 | public void translate ( int dx , int dy ) { setLocation ( _bounds . x + dx , _bounds . y + dy ) ; } | Attempt to translate this glyph . |
15,522 | public static MisoSceneMetrics getSceneMetrics ( ) { return new MisoSceneMetrics ( config . getValue ( TILE_WIDTH_KEY , DEF_TILE_WIDTH ) , config . getValue ( TILE_HEIGHT_KEY , DEF_TILE_HEIGHT ) , config . getValue ( FINE_GRAN_KEY , DEF_FINE_GRAN ) ) ; } | Creates scene metrics with information obtained from the deployed config file . |
15,523 | public void onCreate ( SQLiteDatabase db ) { try { if ( builder . tables == null ) { throw new SQLiteHelperException ( "The array of String tables can't be null!!" ) ; } executePragma ( db ) ; builder . onCreateCallback . onCreate ( db ) ; } catch ( SQLiteHelperException e ) { Log . e ( this . getClass ( ) . toString ( ) , Log . getStackTraceString ( e ) , e ) ; } } | Called when the database is created for the first time . This is where the creation of tables and the initial population of the tables should happen . |
15,524 | public void onUpgrade ( SQLiteDatabase db , int oldVersion , int newVersion ) { try { if ( builder . tableNames == null ) { throw new SQLiteHelperException ( "The array of String tableNames can't be null!!" ) ; } builder . onUpgradeCallback . onUpgrade ( db , oldVersion , newVersion ) ; } catch ( SQLiteHelperException e ) { Log . e ( this . getClass ( ) . toString ( ) , Log . getStackTraceString ( e ) , e ) ; } } | Called when the database needs to be upgraded . The implementation should use this method to drop tables add tables or do anything else it needs to upgrade to the new schema version . |
15,525 | static String getHex ( Color color ) { return String . format ( "#%02x%02x%02x%02x" , color . getRed ( ) , color . getGreen ( ) , color . getBlue ( ) , color . getAlpha ( ) ) ; } | create rgba hex from a java color |
15,526 | public List < ConnectionListener > getConnectionListeners ( ) { if ( changes == null ) { return ( List < ConnectionListener > ) Collections . EMPTY_LIST ; } List < EventListener > listeners = changes . getListenerList ( AMQP ) ; if ( ( listeners == null ) || listeners . isEmpty ( ) ) { return ( List < ConnectionListener > ) Collections . EMPTY_LIST ; } ArrayList < ConnectionListener > list = new ArrayList < ConnectionListener > ( ) ; for ( EventListener listener : listeners ) { list . add ( ( ConnectionListener ) listener ) ; } return list ; } | Returns the list of ConnectionListeners registered with this AmqpClient instance . |
15,527 | public void connect ( String url , String virtualHost , String username , String password ) { if ( websocket != null ) { throw new IllegalStateException ( "AmqpClient already connected" ) ; } this . readyState = ReadyState . CONNECTING ; this . url = url ; this . userName = username ; this . password = password ; this . virtualHost = virtualHost ; this . hasNegotiated = false ; asyncClient . getStateMachine ( ) . enterState ( "handshaking" , "" , this . url ) ; } | Connect to AMQP Broker via Kaazing Gateway |
15,528 | public void disconnect ( ) { if ( readyState == ReadyState . OPEN ) { this . closeConnection ( 0 , "" , 0 , 0 , null , null ) ; } else if ( readyState == ReadyState . CONNECTING ) { socketClosedHandler ( ) ; } } | Disconnects from Amqp Server . |
15,529 | public AmqpChannel openChannel ( ) { int id = ++ this . channelCount ; AmqpChannel chan = new AmqpChannel ( id , this ) ; channels . put ( id , chan ) ; return chan ; } | Opens a channel on server . |
15,530 | void closedHandler ( Object context , String input , Object frame , String stateName ) { if ( getReadyState ( ) == ReadyState . CLOSED ) { return ; } if ( this . channels . size ( ) != 0 ) { for ( int i = 1 ; i <= this . channels . size ( ) ; i ++ ) { AmqpChannel channel = this . channels . get ( i ) ; AmqpFrame f = new AmqpFrame ( ) ; f . setMethodName ( "closeChannel" ) ; f . setChannelId ( ( short ) i ) ; channel . channelClosedHandler ( this , "" , f , "closeChannel" ) ; } } try { readyState = ReadyState . CLOSED ; fireOnClosed ( new ConnectionEvent ( this , Kind . CLOSE ) ) ; if ( websocket != null ) { websocket . close ( ) ; } } catch ( Exception e1 ) { throw new IllegalStateException ( e1 ) ; } finally { websocket = null ; } } | should be the order following in all our client implementations . |
15,531 | private void socketClosedHandler ( ) { if ( getReadyState ( ) == ReadyState . CLOSED ) { return ; } if ( this . channels . size ( ) != 0 ) { for ( int i = 1 ; i <= this . channels . size ( ) ; i ++ ) { AmqpChannel channel = this . channels . get ( i ) ; AmqpFrame f = new AmqpFrame ( ) ; f . setMethodName ( "closeChannel" ) ; f . setChannelId ( ( short ) i ) ; channel . channelClosedHandler ( this , "" , f , "closeChannel" ) ; } } readyState = ReadyState . CLOSED ; fireOnClosed ( new ConnectionEvent ( this , Kind . CLOSE ) ) ; } | closing the channels raising events and such . |
15,532 | AmqpClient tuneOkConnection ( int channelMax , int frameMax , int heartbeat ) { this . tuneOkConnection ( channelMax , frameMax , heartbeat , null , null ) ; return this ; } | Sends a TuneOkConnection to server . |
15,533 | AmqpClient closeOkConnection ( Continuation callback , ErrorHandler error ) { Object [ ] args = { } ; AmqpBuffer bodyArg = null ; String methodName = "closeOkConnection" ; String methodId = "10" + "50" ; AmqpMethod amqpMethod = MethodLookup . LookupMethod ( methodId ) ; Object [ ] arguments = { this , amqpMethod , this . id , args , bodyArg } ; asyncClient . enqueueAction ( methodName , "write" , arguments , callback , error ) ; return this ; } | Sends a CloseOkConnection to server . |
15,534 | private void fireOnClosed ( ConnectionEvent e ) { List < EventListener > listeners = changes . getListenerList ( AMQP ) ; for ( EventListener listener : listeners ) { ConnectionListener amqpListener = ( ConnectionListener ) listener ; amqpListener . onConnectionClose ( e ) ; } } | Occurs when the connection to the AMQP server is closed |
15,535 | protected CompositedMirage createCompositedMirage ( int index ) { if ( _sources . length == 1 && _sources [ 0 ] . frames instanceof TileSetFrameImage ) { TileSetFrameImage frames = ( TileSetFrameImage ) _sources [ 0 ] . frames ; Rectangle tbounds = new Rectangle ( ) ; frames . getTrimmedBounds ( _orient , index , tbounds ) ; int x = frames . getXOrigin ( _orient , index ) - tbounds . x ; int y = frames . getYOrigin ( _orient , index ) - tbounds . y ; return new SubmirageForwarder ( frames . getTileMirage ( _orient , index ) , x , y ) ; } return new CompositedVolatileMirage ( index ) ; } | Creates a composited image for the specified frame . |
15,536 | protected void createComponent ( int componentId , String cclass , String cname , FrameProvider fprov ) { ComponentClass clazz = _classes . get ( cclass ) ; if ( clazz == null ) { log . warning ( "Non-existent component class" , "class" , cclass , "name" , cname , "id" , componentId ) ; return ; } CharacterComponent component = new CharacterComponent ( componentId , cname , clazz , fprov ) ; _components . put ( componentId , component ) ; ArrayList < CharacterComponent > comps = _classComps . get ( cclass ) ; if ( comps == null ) { comps = Lists . newArrayList ( ) ; _classComps . put ( cclass , comps ) ; } if ( ! comps . contains ( component ) ) { comps . add ( component ) ; } else { log . info ( "Requested to register the same component twice?" , "comp" , component ) ; } } | Creates a component and inserts it into the component table . |
15,537 | public void setFrames ( MultiFrameImage frames ) { if ( frames == null ) { return ; } if ( frames == _frames ) { return ; } _frames = frames ; _frameIdx = 0 ; layout ( ) ; } | Set the image array used to render the sprite . |
15,538 | protected void setFrameIndex ( int frameIdx , boolean forceUpdate ) { frameIdx = ( frameIdx % _frames . getFrameCount ( ) ) ; if ( frameIdx == _frameIdx && ! forceUpdate ) { return ; } else { _frameIdx = frameIdx ; } Rectangle dirty = new Rectangle ( _bounds ) ; accomodateFrame ( _frameIdx , _frames . getWidth ( _frameIdx ) , _frames . getHeight ( _frameIdx ) ) ; dirty . add ( _bounds ) ; if ( _mgr != null ) { _mgr . getRegionManager ( ) . addDirtyRegion ( dirty ) ; } } | Instructs the sprite to display the specified frame index . |
15,539 | private MetricGroup up_down_host_ ( String host , boolean up ) { final GroupName group = GroupName . valueOf ( getBasePath ( ) , Tags . valueOf ( singletonMap ( "host" , MetricValue . fromStrValue ( host ) ) ) ) ; return new SimpleMetricGroup ( group , singleton ( up ? UP_METRIC : DOWN_METRIC ) ) ; } | Return a metric group indicating if the host is up or down . |
15,540 | public static synchronized JspFactory getDefaultFactory ( ) { if ( deflt == null ) { try { Class factory = Class . forName ( "org.apache.jasper.runtime.JspFactoryImpl" ) ; if ( factory != null ) { deflt = ( JspFactory ) factory . newInstance ( ) ; } } catch ( Exception ex ) { } } return deflt ; } | Returns the default factory for this implementation . |
15,541 | public VariableInfo [ ] getVariableInfo ( TagData data ) { VariableInfo [ ] result = null ; TagExtraInfo tei = getTagExtraInfo ( ) ; if ( tei != null ) { result = tei . getVariableInfo ( data ) ; } return result ; } | Information on the scripting objects created by this tag at runtime . This is a convenience method on the associated TagExtraInfo class . |
15,542 | private String getProperty ( final String name ) { assert name != null ; ensureConfigured ( ) ; return evaluate ( System . getProperty ( name , props . getProperty ( name ) ) ) ; } | Get the value of a property checking system properties then configuration properties and evaluating the result . |
15,543 | public static Collection < Attribute > fromJson ( ObjectNode object ) throws IOException { Collection < Attribute > attributes = new HashSet < > ( ) ; convertJsonObject ( attributes , object , "" , 0 , new HashMap < > ( ) ) ; return attributes ; } | Flattens a raw nested json string representation into a collection of attributes . |
15,544 | public static String toJsonString ( Collection < Attribute > attributeCollection , ObjectMapper objectMapper ) throws JsonProcessingException { return objectMapper . writeValueAsString ( toObject ( attributeCollection ) ) ; } | Re - expands a flattened json representation from a collection of attributes back into a raw nested json string . |
15,545 | public BaseTile getFringeTile ( MisoSceneModel scene , int col , int row , Map < FringeTile , WeakReference < FringeTile > > fringes , Map < Long , BufferedImage > masks ) { int underset = adjustTileSetId ( scene . getBaseTileId ( col , row ) >> 16 ) ; _fringers . clear ( ) ; boolean passable = true ; for ( int y = row - 1 , maxy = row + 2 ; y < maxy ; y ++ ) { for ( int x = col - 1 , maxx = col + 2 ; x < maxx ; x ++ ) { if ( ( x == col ) && ( y == row ) ) { continue ; } int btid = scene . getBaseTileId ( x , y ) ; int baseset = adjustTileSetId ( ( btid <= 0 ) ? scene . getDefaultBaseTileSet ( ) : ( btid >> 16 ) ) ; int pri = _fringeconf . fringesOn ( baseset , underset ) ; if ( pri == - 1 ) { continue ; } FringerRec fringer = ( FringerRec ) _fringers . get ( baseset ) ; if ( fringer == null ) { fringer = new FringerRec ( baseset , pri ) ; _fringers . put ( baseset , fringer ) ; } fringer . bits |= FLAGMATRIX [ y - row + 1 ] [ x - col + 1 ] ; if ( passable && ( btid > 0 ) ) { try { BaseTile bt = ( BaseTile ) _tmgr . getTile ( btid ) ; passable = bt . isPassable ( ) ; } catch ( NoSuchTileSetException nstse ) { log . warning ( "Autofringer couldn't find a base set while attempting to " + "figure passability" , nstse ) ; } } } } int numfringers = _fringers . size ( ) ; if ( numfringers == 0 ) { return null ; } FringerRec [ ] frecs = new FringerRec [ numfringers ] ; for ( int ii = 0 , pp = 0 ; ii < 16 ; ii ++ ) { FringerRec rec = ( FringerRec ) _fringers . getValue ( ii ) ; if ( rec != null ) { frecs [ pp ++ ] = rec ; } } return composeFringeTile ( frecs , fringes , TileUtil . getTileHash ( col , row ) , passable , masks ) ; } | Compute and return the fringe tile to be inserted at the specified location . |
15,546 | protected FringeTile composeFringeTile ( FringerRec [ ] fringers , Map < FringeTile , WeakReference < FringeTile > > fringes , int hashValue , boolean passable , Map < Long , BufferedImage > masks ) { QuickSort . sort ( fringers ) ; List < Long > keys = Lists . newArrayList ( ) ; for ( FringerRec fringer : fringers ) { int [ ] indexes = getFringeIndexes ( fringer . bits ) ; FringeConfiguration . FringeTileSetRecord tsr = _fringeconf . getFringe ( fringer . baseset , hashValue ) ; int fringeset = tsr . fringe_tsid ; for ( int index : indexes ) { keys . add ( ( ( ( long ) fringer . baseset ) << 32 ) + ( fringeset << 16 ) + index ) ; } } long [ ] fringeId = new long [ keys . size ( ) ] ; for ( int ii = 0 ; ii < fringeId . length ; ii ++ ) { fringeId [ ii ] = keys . get ( ii ) ; } FringeTile frTile = new FringeTile ( fringeId , passable ) ; WeakReference < FringeTile > result = fringes . get ( frTile ) ; if ( result != null ) { FringeTile fringe = result . get ( ) ; if ( fringe != null ) { return fringe ; } } BufferedImage img = null ; for ( FringerRec fringer : fringers ) { int [ ] indexes = getFringeIndexes ( fringer . bits ) ; FringeConfiguration . FringeTileSetRecord tsr = _fringeconf . getFringe ( fringer . baseset , hashValue ) ; for ( int index : indexes ) { try { img = getTileImage ( img , tsr , fringer . baseset , index , hashValue , masks ) ; } catch ( NoSuchTileSetException nstse ) { log . warning ( "Autofringer couldn't find a needed tileset" , nstse ) ; } } } frTile . setImage ( new BufferedMirage ( img ) ) ; fringes . put ( frTile , new WeakReference < FringeTile > ( frTile ) ) ; return frTile ; } | Compose a FringeTile out of the various fringe images needed . |
15,547 | protected BufferedImage getTileImage ( BufferedImage img , FringeConfiguration . FringeTileSetRecord tsr , int baseset , int index , int hashValue , Map < Long , BufferedImage > masks ) throws NoSuchTileSetException { int fringeset = tsr . fringe_tsid ; TileSet fset = _tmgr . getTileSet ( fringeset ) ; if ( ! tsr . mask ) { Tile stamp = fset . getTile ( index ) ; return stampTileImage ( stamp , img , stamp . getWidth ( ) , stamp . getHeight ( ) ) ; } Long maskkey = Long . valueOf ( ( ( ( long ) baseset ) << 32 ) + ( fringeset << 16 ) + index ) ; BufferedImage mask = masks . get ( maskkey ) ; if ( mask == null ) { BufferedImage fsrc = _tmgr . getTileSet ( fringeset ) . getRawTileImage ( index ) ; BufferedImage bsrc = _tmgr . getTileSet ( baseset ) . getRawTileImage ( 0 ) ; mask = ImageUtil . composeMaskedImage ( _imgr , fsrc , bsrc ) ; masks . put ( maskkey , mask ) ; } return stampTileImage ( mask , img , mask . getWidth ( null ) , mask . getHeight ( null ) ) ; } | Retrieve or compose an image for the specified fringe . |
15,548 | protected int [ ] getFringeIndexes ( int bits ) { int index = BITS_TO_INDEX [ bits ] ; if ( index != - 1 ) { int [ ] ret = new int [ 1 ] ; ret [ 0 ] = index ; return ret ; } int start = 0 ; while ( ( ( ( 1 << start ) & bits ) != 0 ) && ( start < NUM_FRINGEBITS ) ) { start ++ ; } if ( start == NUM_FRINGEBITS ) { return new int [ 0 ] ; } ArrayList < Integer > indexes = Lists . newArrayList ( ) ; int weebits = 0 ; for ( int ii = ( start + 1 ) % NUM_FRINGEBITS ; ii != start ; ii = ( ii + 1 ) % NUM_FRINGEBITS ) { if ( ( ( 1 << ii ) & bits ) != 0 ) { weebits |= ( 1 << ii ) ; } else if ( weebits != 0 ) { index = BITS_TO_INDEX [ weebits ] ; if ( index != - 1 ) { indexes . add ( index ) ; } weebits = 0 ; } } if ( weebits != 0 ) { index = BITS_TO_INDEX [ weebits ] ; if ( index != - 1 ) { indexes . add ( index ) ; } } int [ ] ret = new int [ indexes . size ( ) ] ; for ( int ii = 0 ; ii < ret . length ; ii ++ ) { ret [ ii ] = indexes . get ( ii ) ; } return ret ; } | Get the fringe index specified by the fringebits . If no index is available try breaking down the bits into contiguous regions of bits and look for indexes for those . |
15,549 | public Sound getSound ( String path ) { ClipBuffer buffer = null ; if ( _manager . isInitialized ( ) ) { buffer = _manager . getClip ( _provider , path ) ; } return ( buffer == null ) ? new BlankSound ( ) : new Sound ( this , buffer ) ; } | Obtains an instance of the specified sound which can be positioned played looped and otherwise used to make noise . |
15,550 | public void dispose ( ) { reclaimAll ( ) ; for ( PooledSource pooled : _sources ) { pooled . source . delete ( ) ; } _sources . clear ( ) ; _manager . removeGroup ( this ) ; } | Disposes this sound group freeing up the OpenAL sources with which it is associated . All sounds obtained from this group will no longer be usable and should be discarded . |
15,551 | public void reclaimAll ( ) { for ( PooledSource pooled : _sources ) { if ( pooled . holder != null ) { pooled . holder . stop ( ) ; pooled . holder . reclaim ( ) ; pooled . holder = null ; } } } | Stops and reclaims all sounds from this sound group but does not free the sources . |
15,552 | protected void baseGainChanged ( ) { for ( int ii = 0 , nn = _sources . size ( ) ; ii < nn ; ii ++ ) { Sound holder = _sources . get ( ii ) . holder ; if ( holder != null ) { holder . updateSourceGain ( ) ; } } } | Called by the manager when the base gain has changed . |
15,553 | protected void setFrameIndex ( int fidx ) { _fidx = fidx ; _bounds . width = _frames . getWidth ( _fidx ) ; _bounds . height = _frames . getHeight ( _fidx ) ; } | Sets the frame index and updates our dimensions . |
15,554 | public synchronized T read ( T dto ) throws Exception { Cursor cursor = db . query ( transformer . getTableName ( ) , transformer . getFields ( ) , transformer . getWhereClause ( dto ) , null , null , null , null ) ; T object = null ; if ( cursor . moveToFirst ( ) ) { object = transformer . transform ( cursor ) ; } return object ; } | Convenience method for reading rows in the database . |
15,555 | public synchronized Collection < T > readAll ( ) throws Exception { Cursor cursor = db . query ( transformer . getTableName ( ) , transformer . getFields ( ) , null , null , null , null , null ) ; Collection < T > list = getAllCursor ( cursor ) ; return list ; } | Convenience method for reading all rows in the table of database . |
15,556 | public static int dot ( Point v1s , Point v1e , Point v2s , Point v2e ) { return ( ( v1e . x - v1s . x ) * ( v2e . x - v2s . x ) + ( v1e . y - v1s . y ) * ( v2e . y - v2s . y ) ) ; } | Computes and returns the dot product of the two vectors . |
15,557 | public static int dot ( Point vs , Point v1e , Point v2e ) { return ( ( v1e . x - vs . x ) * ( v2e . x - vs . x ) + ( v1e . y - vs . y ) * ( v2e . y - vs . y ) ) ; } | Computes and returns the dot product of the two vectors . The vectors are assumed to start with the same coordinate and end with different coordinates . |
15,558 | public static boolean lineIntersection ( Point2D p1 , Point2D p2 , boolean seg1 , Point2D p3 , Point2D p4 , boolean seg2 , Point2D result ) { double y43 = p4 . getY ( ) - p3 . getY ( ) ; double x21 = p2 . getX ( ) - p1 . getX ( ) ; double x43 = p4 . getX ( ) - p3 . getX ( ) ; double y21 = p2 . getY ( ) - p1 . getY ( ) ; double denom = y43 * x21 - x43 * y21 ; if ( denom == 0 ) { return false ; } double y13 = p1 . getY ( ) - p3 . getY ( ) ; double x13 = p1 . getX ( ) - p3 . getX ( ) ; double ua = ( x43 * y13 - y43 * x13 ) / denom ; if ( seg1 && ( ( ua < 0 ) || ( ua > 1 ) ) ) { return false ; } if ( seg2 ) { double ub = ( x21 * y13 - y21 * x13 ) / denom ; if ( ( ub < 0 ) || ( ub > 1 ) ) { return false ; } } double x = p1 . getX ( ) + ua * x21 ; double y = p1 . getY ( ) + ua * y21 ; result . setLocation ( x , y ) ; return true ; } | Calculate the intersection of two lines . Either line may be considered as a line segment and the intersecting point is only considered valid if it lies upon the segment . Note that Point extends Point2D . |
15,559 | public static Rectangle grow ( Rectangle source , Rectangle target ) { if ( target == null ) { log . warning ( "Can't grow with null rectangle [src=" + source + ", tgt=" + target + "]." , new Exception ( ) ) ; } else if ( source == null ) { source = new Rectangle ( target ) ; } else { source . add ( target ) ; } return source ; } | Adds the target rectangle to the bounds of the source rectangle . If the source rectangle is null a new rectangle is created that is the size of the target rectangle . |
15,560 | public static Rectangle getTile ( int width , int height , int tileWidth , int tileHeight , int tileIndex ) { Rectangle bounds = new Rectangle ( ) ; getTile ( width , height , tileWidth , tileHeight , tileIndex , bounds ) ; return bounds ; } | Returns the rectangle containing the specified tile in the supplied larger rectangle . Tiles go from left to right top to bottom . |
15,561 | public static void getTile ( int width , int height , int tileWidth , int tileHeight , int tileIndex , Rectangle bounds ) { int tilesPerRow = width / tileWidth ; if ( tilesPerRow == 0 ) { bounds . setBounds ( 0 , 0 , width , height ) ; } else { int row = tileIndex / tilesPerRow ; int col = tileIndex % tilesPerRow ; bounds . setBounds ( tileWidth * col , tileHeight * row , tileWidth , tileHeight ) ; } } | Fills in the bounds of the specified tile in the supplied larger rectangle . Tiles go from left to right top to bottom . |
15,562 | private void setNegotiatedExtensions ( String extensionsHeader ) { if ( ( extensionsHeader == null ) || ( extensionsHeader . trim ( ) . length ( ) == 0 ) ) { _negotiatedExtensions = null ; return ; } String [ ] extns = extensionsHeader . split ( "," ) ; List < String > extnNames = new ArrayList < String > ( ) ; for ( String extn : extns ) { String [ ] properties = extn . split ( ";" ) ; String extnName = properties [ 0 ] . trim ( ) ; if ( ! getEnabledExtensions ( ) . contains ( extnName ) ) { String s = String . format ( "Extension '%s' is not an enabled " + "extension so it should not have been negotiated" , extnName ) ; setException ( new WebSocketException ( s ) ) ; return ; } WebSocketExtension extension = WebSocketExtension . getWebSocketExtension ( extnName ) ; WsExtensionParameterValuesSpiImpl paramValues = _negotiatedParameters . get ( extnName ) ; Collection < Parameter < ? > > anonymousParams = extension . getParameters ( Metadata . ANONYMOUS ) ; for ( int i = 1 ; i < properties . length ; i ++ ) { String property = properties [ i ] . trim ( ) ; String [ ] pair = property . split ( "=" ) ; Parameter < ? > parameter = null ; String paramValue = null ; if ( pair . length == 1 ) { parameter = anonymousParams . iterator ( ) . next ( ) ; paramValue = pair [ 0 ] . trim ( ) ; } else { parameter = extension . getParameter ( pair [ 0 ] . trim ( ) ) ; paramValue = pair [ 1 ] . trim ( ) ; } if ( parameter . type ( ) != String . class ) { String paramName = parameter . name ( ) ; String s = String . format ( "Negotiated Extension '%s': " + "Type of parameter '%s' should be String" , extnName , paramName ) ; setException ( new WebSocketException ( s ) ) ; return ; } if ( paramValues == null ) { paramValues = new WsExtensionParameterValuesSpiImpl ( ) ; _negotiatedParameters . put ( extnName , paramValues ) ; } paramValues . setParameterValue ( parameter , paramValue ) ; } extnNames . add ( extnName ) ; } HashSet < String > extnsSet = new HashSet < String > ( extnNames ) ; _negotiatedExtensions = unmodifiableCollection ( extnsSet ) ; } | RFC 3864 format . |
15,563 | public static int scrollToIndex ( String listRef , int itemIndex ) throws Exception { int listViewIndex = getListViewIndex ( listRef ) ; if ( itemIndex >= numItemsInList ( listRef ) ) throw new Exception ( "Item index is greater than number of items in the list" ) ; QueryBuilder builder = new QueryBuilder ( ) ; int firstVisiblePosition = builder . map ( "solo" , "getCurrentViews" , "android.widget.ListView" ) . call ( "get" , listViewIndex ) . call ( "getFirstVisiblePosition" ) . execute ( ) . getInt ( 0 ) ; if ( firstVisiblePosition > itemIndex ) scrollToTop ( ) ; boolean scrollDown = true ; while ( true ) { builder = new QueryBuilder ( ) ; firstVisiblePosition = builder . map ( "solo" , "getCurrentViews" , "android.widget.ListView" ) . call ( "get" , listViewIndex ) . call ( "getFirstVisiblePosition" ) . execute ( ) . getInt ( 0 ) ; builder = new QueryBuilder ( ) ; int headersViewsCount = builder . map ( "solo" , "getCurrentViews" , "android.widget.ListView" ) . call ( "get" , listViewIndex ) . call ( "getHeaderViewsCount" ) . execute ( ) . getInt ( 0 ) ; firstVisiblePosition = firstVisiblePosition - headersViewsCount ; builder = new QueryBuilder ( ) ; int visibleChildCount = builder . map ( "solo" , "getCurrentViews" , "android.widget.ListView" ) . call ( "get" , listViewIndex ) . call ( "getChildCount" ) . execute ( ) . getInt ( 0 ) ; int wantedPosition = itemIndex - firstVisiblePosition ; if ( wantedPosition >= visibleChildCount ) { if ( ! scrollDown ) { break ; } scrollDown = Solo . scrollDownList ( listViewIndex ) ; } else { return wantedPosition ; } } throw new Exception ( "Could not find item" ) ; } | Scrolls the specified item index onto the screen and returns the offset based on the current visible list |
15,564 | public int value ( ) { int end = Math . min ( _history . length , _index ) ; int value = 0 ; for ( int ii = 0 ; ii < end ; ii ++ ) { value += _history [ ii ] ; } return ( end > 0 ) ? ( value / end ) : 0 ; } | Returns the current averaged value . |
15,565 | protected Frob loop ( String pkgPath , String key , float pan , byte cmd ) { SoundKey skey = new SoundKey ( cmd , pkgPath , key , 0 , _clipVol , pan ) ; addToPlayQueue ( skey ) ; return skey ; } | Loop the specified sound . |
15,566 | protected void addToPlayQueue ( SoundKey skey ) { boolean queued = enqueue ( skey , true ) ; if ( queued ) { if ( _verbose . getValue ( ) ) { log . info ( "Sound request [key=" + skey . key + "]." ) ; } } else { log . warning ( "SoundManager not playing sound because too many sounds in queue " + "[key=" + skey + "]." ) ; } } | Add the sound clip key to the queue to be played . |
15,567 | protected boolean enqueue ( SoundKey key , boolean okToStartNew ) { boolean add ; boolean queued ; synchronized ( _queue ) { if ( key . cmd == PLAY && _queue . size ( ) > MAX_QUEUE_SIZE ) { queued = add = false ; } else { _queue . appendLoud ( key ) ; queued = true ; add = okToStartNew && ( _freeSpoolers == 0 ) && ( _spoolerCount < MAX_SPOOLERS ) ; if ( add ) { _spoolerCount ++ ; } } } if ( add ) { Thread spooler = new Thread ( "narya SoundManager line spooler" ) { public void run ( ) { spoolerRun ( ) ; } } ; spooler . setDaemon ( true ) ; spooler . start ( ) ; } return queued ; } | Enqueue a new SoundKey . |
15,568 | protected void spoolerRun ( ) { while ( true ) { try { SoundKey key ; synchronized ( _queue ) { _freeSpoolers ++ ; key = _queue . get ( MAX_WAIT_TIME ) ; _freeSpoolers -- ; if ( key == null || key . cmd == DIE ) { _spoolerCount -- ; if ( key != null && _spoolerCount > 0 ) { _queue . appendLoud ( key ) ; } return ; } } processKey ( key ) ; } catch ( Exception e ) { log . warning ( e ) ; } } } | This is the primary run method of the sound - playing threads . |
15,569 | protected void processKey ( SoundKey key ) throws Exception { switch ( key . cmd ) { case PLAY : case LOOP : playSound ( key ) ; break ; case LOCK : if ( ! isTesting ( ) ) { synchronized ( _clipCache ) { try { getClipData ( key ) ; _lockedClips . put ( key , _clipCache . get ( key ) ) ; } catch ( Exception e ) { if ( _verbose . getValue ( ) ) { throw e ; } } } } break ; case UNLOCK : synchronized ( _clipCache ) { _lockedClips . remove ( key ) ; } break ; } } | Process the requested command in the specified SoundKey . |
15,570 | protected byte [ ] getClipData ( SoundKey key ) throws IOException , UnsupportedAudioFileException { byte [ ] [ ] data ; synchronized ( _clipCache ) { if ( isTesting ( ) ) { _clipCache . clear ( ) ; } data = _clipCache . get ( key ) ; if ( data == null ) { data = _lockedClips . get ( key ) ; } if ( data == null ) { InputStream stream = getTestClip ( key ) ; if ( stream != null ) { data = new byte [ 1 ] [ ] ; data [ 0 ] = StreamUtil . toByteArray ( stream ) ; } else { data = _loader . load ( key . pkgPath , key . key ) ; } _clipCache . put ( key , data ) ; } } return ( data . length > 0 ) ? data [ RandomUtil . getInt ( data . length ) ] : null ; } | Called by spooling threads loads clip data from the resource manager or the cache . |
15,571 | protected static void adjustVolume ( Line line , float vol ) { FloatControl control = ( FloatControl ) line . getControl ( FloatControl . Type . MASTER_GAIN ) ; float gain ; if ( vol == 0f ) { gain = control . getMinimum ( ) ; } else { gain = ( float ) ( ( Math . log ( vol ) / Math . log ( 10.0 ) ) * 20.0 ) ; } control . setValue ( gain ) ; } | Use the gain control to implement volume . |
15,572 | protected static void adjustPan ( Line line , float pan ) { try { FloatControl control = ( FloatControl ) line . getControl ( FloatControl . Type . PAN ) ; control . setValue ( pan ) ; } catch ( Exception e ) { log . debug ( "Cannot set pan on line: " + e ) ; } } | Set the pan value for the specified line . |
15,573 | public void tick ( long tickStamp ) { if ( _nextTime == - 1 ) { _nextTime = tickStamp + _initDelay ; } else if ( tickStamp >= _nextTime ) { if ( _repeatDelay != 0L ) { _nextTime += _repeatDelay ; } else { _nextTime = - 1 ; cancel ( ) ; } expired ( ) ; } } | documentation inherited from FrameParticipant |
15,574 | private AffineTransform getRotationTransform ( ) { double theta ; switch ( _orient ) { case NORTH : default : theta = 0.0 ; break ; case SOUTH : theta = Math . PI ; break ; case EAST : theta = Math . PI * 0.5 ; break ; case WEST : theta = - Math . PI * 0.5 ; break ; case NORTHEAST : theta = Math . PI * 0.25 ; break ; case NORTHWEST : theta = - Math . PI * 0.25 ; break ; case SOUTHEAST : theta = Math . PI * 0.75 ; break ; case SOUTHWEST : theta = - Math . PI * 0.75 ; break ; case NORTHNORTHEAST : theta = - Math . PI * 0.125 ; break ; case NORTHNORTHWEST : theta = Math . PI * 0.125 ; break ; case SOUTHSOUTHEAST : theta = - Math . PI * 0.875 ; break ; case SOUTHSOUTHWEST : theta = Math . PI * 0.875 ; break ; case EASTNORTHEAST : theta = - Math . PI * 0.375 ; break ; case EASTSOUTHEAST : theta = - Math . PI * 0.625 ; break ; case WESTNORTHWEST : theta = Math . PI * 0.375 ; break ; case WESTSOUTHWEST : theta = Math . PI * 0.625 ; break ; } return AffineTransform . getRotateInstance ( theta , ( _ox - _oxoff ) + _frames . getWidth ( _frameIdx ) / 2 , ( _oy - _oyoff ) + _frames . getHeight ( _frameIdx ) / 2 ) ; } | Computes and returns the rotation transform for this sprite . |
15,575 | public Stream < Entry < MatchedName , MetricValue > > filter ( Context t ) { return t . getTSData ( ) . getCurrentCollection ( ) . get ( this :: match , x -> true ) . stream ( ) . flatMap ( this :: filterMetricsInTsv ) ; } | Create a stream of TimeSeriesMetricDeltas with values . |
15,576 | public static final Color blend ( Color c1 , Color c2 ) { return new Color ( ( c1 . getRed ( ) + c2 . getRed ( ) ) >> 1 , ( c1 . getGreen ( ) + c2 . getGreen ( ) ) >> 1 , ( c1 . getBlue ( ) + c2 . getBlue ( ) ) >> 1 ) ; } | Blends the two supplied colors . |
15,577 | public static final Color blend ( Color c1 , Color c2 , float firstperc ) { float p2 = 1.0f - firstperc ; return new Color ( ( int ) ( c1 . getRed ( ) * firstperc + c2 . getRed ( ) * p2 ) , ( int ) ( c1 . getGreen ( ) * firstperc + c2 . getGreen ( ) * p2 ) , ( int ) ( c1 . getBlue ( ) * firstperc + c2 . getBlue ( ) * p2 ) ) ; } | Blends the two supplied colors using the supplied percentage as the amount of the first color to use . |
15,578 | protected void setupLogging ( final Level level ) { SLF4JBridgeHandler . removeHandlersForRootLogger ( ) ; SLF4JBridgeHandler . install ( ) ; Log . configure ( LoggerFactory . getILoggerFactory ( ) ) ; log . debug ( "Logging setup; level: {}" , level ) ; } | Setup logging environment . |
15,579 | public void addAnimations ( Animation [ ] anims ) { int acount = anims . length ; for ( int ii = 0 ; ii < acount ; ii ++ ) { addAnimation ( anims [ ii ] ) ; } } | Adds the supplied animations to the animation waiter for observation . |
15,580 | public static SoundManager createSoundManager ( RunQueue rqueue ) { if ( _soundmgr != null ) { throw new IllegalStateException ( "A sound manager has already been created." ) ; } _soundmgr = new SoundManager ( rqueue ) ; return _soundmgr ; } | Creates initializes and returns the singleton sound manager instance . |
15,581 | public void updateStreams ( float time ) { for ( int ii = _streams . size ( ) - 1 ; ii >= 0 ; ii -- ) { _streams . get ( ii ) . update ( time ) ; } deleteFinalizedObjects ( ) ; } | Updates all of the streams controlled by the manager . This should be called once per frame by the application . |
15,582 | public void loadClip ( ClipProvider provider , String path , Observer observer ) { getClip ( provider , path , observer ) ; } | Loads a clip buffer for the sound clip loaded via the specified provider with the specified path . The loaded clip is placed in the cache . |
15,583 | protected synchronized void deleteFinalizedObjects ( ) { if ( _finalizedSources != null ) { IntBuffer idbuf = BufferUtils . createIntBuffer ( _finalizedSources . length ) ; idbuf . put ( _finalizedSources ) . rewind ( ) ; AL10 . alDeleteSources ( idbuf ) ; _finalizedSources = null ; } if ( _finalizedBuffers != null ) { IntBuffer idbuf = BufferUtils . createIntBuffer ( _finalizedBuffers . length ) ; idbuf . put ( _finalizedBuffers ) . rewind ( ) ; AL10 . alDeleteBuffers ( idbuf ) ; _finalizedBuffers = null ; } } | Deletes all finalized objects . |
15,584 | protected void paintLabels ( Graphics2D gfx , int x , int y ) { _label . render ( gfx , x , y ) ; } | Derived classes may wish to extend score animation and render more than just the standard single label . |
15,585 | public void addRule ( ValidationData vd ) { this . rules . addAll ( vd . getValidationRules ( ) . stream ( ) . filter ( vr -> vr . isUse ( ) ) . collect ( Collectors . toList ( ) ) ) ; } | Add rule . |
15,586 | public void initDataGroup ( ParamType paramType , List < ValidationData > lists ) { this . paramType = paramType ; lists . forEach ( vd -> { this . addRule ( vd ) ; } ) ; } | Init data group . |
15,587 | public HandlerRegistration addMapZoomEndHandler ( final Runnable zoomHandler ) { return mapWidget . addZoomChangeHandler ( zoomChangeMapEvent -> zoomHandler . run ( ) ) ; } | Add zoom handler event is not exposed at present |
15,588 | public boolean sameProduct ( JProduct p , Map < String , String > featLinks , boolean exactContent ) { List < JCell > tempCells = new ArrayList < > ( this . cells ) ; if ( p . getCells ( ) . size ( ) != this . cells . size ( ) ) { return false ; } for ( JCell pC : p . getCells ( ) ) { for ( JCell thisC : this . cells ) { if ( tempCells . contains ( thisC ) ) { if ( thisC . sameCell ( pC , featLinks , exactContent ) ) { tempCells . remove ( thisC ) ; } } } } return tempCells . isEmpty ( ) ; } | Compares cells of both products omitting ids |
15,589 | public static Annotation getAnnotation ( Annotation [ ] annotations , Class < ? > annotationClass ) { return Arrays . stream ( annotations ) . filter ( annotation -> annotation . annotationType ( ) . equals ( annotationClass ) ) . findFirst ( ) . orElse ( null ) ; } | Gets annotation . |
15,590 | public List < ValidationData > getValidationDatas ( ParamType paramType , String key ) { if ( this . urlMap == null || this . validationDataRuleListMap == null ) { log . info ( "url map is empty :: " + key ) ; return null ; } if ( key == null || paramType == null ) { throw new ValidationLibException ( "any parameter is null" , HttpStatus . INTERNAL_SERVER_ERROR ) ; } ReqUrl reqUrl = urlMap . get ( key ) ; if ( reqUrl == null ) { log . info ( "reqUrl is null :" + key ) ; return null ; } return validationDataRuleListMap . get ( paramType . getUniqueKey ( reqUrl . getUniqueKey ( ) ) ) ; } | Gets validation datas . |
15,591 | public static AssistType all ( ) { AssistType assistType = new AssistType ( ) ; assistType . nullable = true ; assistType . string = true ; assistType . number = true ; assistType . enumType = true ; assistType . list = true ; assistType . obj = true ; return assistType ; } | All assist type . |
15,592 | public List < ReqUrl > getReqUrls ( ) { String url = this . getClassMappingUrl ( this . getParentClass ( ) ) ; RequestAnnotation requestAnnotation = new RequestAnnotation ( this . getParentMethod ( ) ) ; url += this . getRequestMappingUrl ( requestAnnotation . getValue ( ) ) ; List < ReqUrl > list = new ArrayList < > ( ) ; for ( RequestMethod requestMethod : requestAnnotation . getMethod ( ) ) { list . add ( new ReqUrl ( requestMethod . name ( ) , url ) ) ; } return list ; } | Gets req urls . |
15,593 | public boolean sameJSONFormat ( JSONFormat jf ) { Map < String , String > featLinks = new HashMap < > ( ) ; if ( ! this . name . equals ( jf . name ) || ! this . creator . equals ( jf . creator ) || ! this . license . equals ( jf . license ) || ! this . source . equals ( jf . source ) ) { return false ; } else if ( ! this . sameFeatures ( jf , featLinks ) ) { System . out . println ( "\nDifferences in features" ) ; return false ; } else if ( ! this . sameProducts ( jf , featLinks , false ) ) { System . out . println ( "\nDifferences in products" ) ; return false ; } return true ; } | Checks if the JSONFormat in parameter is the same as this omitting ids and jcell . jvalue . value content |
15,594 | private void validateFacetFields ( String [ ] facetFieldList ) { if ( facetFieldList == null || facetFieldList . length == 0 ) { return ; } for ( String facetfield : facetFieldList ) { if ( schema . getColumnIndex ( facetfield ) < 0 ) { throw new IllegalArgumentException ( "Facet field:" + facetfield + ", not found in schema" ) ; } } } | Check each facet field is present in schema . |
15,595 | private FacetList calculateFacetList ( AbstractDataTable table , String [ ] facetFields ) { if ( facetFields == null || facetFields . length == 0 ) { throw new NullPointerException ( "Facet field list empty" ) ; } FacetList facetList = new FacetList ( ) ; for ( String facetField : facetFields ) { Set < String > distinctColumnValues = dataTableExtensions . getDistinctColumnValues ( table , schema . getColumnIndex ( facetField ) ) ; facetList . addFacetField ( facetField , distinctColumnValues ) ; } return facetList ; } | facet field - > list of facet field values |
15,596 | public DataProvider getDataProvider ( ) { if ( this . dataProvider == null ) { DataSchema schema = getSchema ( ) ; String [ ] facetFieldList = getFacetFieldList ( ) ; final ApplicationContext applicationContext1 = getApplicationContext ( ) ; final DatasourceConfig config = applicationContext1 . getConfig ( DatasourceConfig . class ) ; GenericDataSource dataSource = new GenericDataSource ( config . getFilename ( ) , null , GenericDataSource . DataSourceType . ServletRelativeDataSource ) ; switch ( config . getDataSourceProvider ( ) ) { case ClientSideSearchDataProvider : dataSource . setDataSourceProvider ( DataSourceProvider . ClientSideSearchDataProvider ) ; this . dataProvider = new ClientSideSearchDataProvider ( dataSource , schema , facetFieldList ) ; break ; case ServerSideLuceneDataProvider : dataSource . setDataSourceProvider ( DataSourceProvider . ServerSideLuceneDataProvider ) ; this . dataProvider = new ServerSideSearchDataProvider ( dataSource , schema , facetFieldList ) ; break ; case GoogleAppEngineLuceneDataSource : dataSource . setDataSourceProvider ( DataSourceProvider . GoogleAppEngineLuceneDataSource ) ; this . dataProvider = new ServerSideSearchDataProvider ( dataSource , schema , facetFieldList ) ; break ; case LocalClientSideDataProvider : default : dataSource . setDataSourceProvider ( DataSourceProvider . LocalClientSideDataProvider ) ; this . dataProvider = new DefaultLocalJSONDataProvider ( dataSource , schema , facetFieldList ) ; break ; } } return this . dataProvider ; } | Lazy initialise Dataprovider |
15,597 | public void setConfigDynamically ( Config viewConfig ) { if ( viewConfig instanceof MapViewConfig ) { MapViewConfig newMapViewConfig = ( MapViewConfig ) viewConfig ; updateMapViewConfig ( newMapViewConfig ) ; } } | This method configures dynamically any config in the xml . Right now only overrides the coordinates of the map but it could be use to override any configuration |
15,598 | public void sessionCheck ( HttpServletRequest req ) { String authHeader = req . getHeader ( "Authorization" ) ; if ( authHeader != null && this . validationSessionCheck ( authHeader ) ) { return ; } if ( req . getCookies ( ) != null ) { Cookie cookie = Arrays . stream ( req . getCookies ( ) ) . filter ( ck -> ck . getName ( ) . equals ( "AuthToken" ) ) . findFirst ( ) . orElse ( null ) ; if ( cookie != null && this . validationSessionCheck ( cookie . getValue ( ) ) ) { return ; } } if ( req . getParameter ( "token" ) != null ) { String token = req . getParameter ( "token" ) ; if ( this . validationSessionCheck ( token ) ) { return ; } } throw new ValidationLibException ( "UnAuthorization" , HttpStatus . UNAUTHORIZED ) ; } | Session check . |
15,599 | public ValidationSessionInfo checkAuth ( ValidationLoginInfo info , HttpServletRequest req , HttpServletResponse res ) { if ( info . getToken ( ) == null || info . getToken ( ) . isEmpty ( ) ) { throw new ValidationLibException ( "UnAuthorization" , HttpStatus . UNAUTHORIZED ) ; } if ( this . validationConfig . getAuthToken ( ) == null ) { throw new ValidationLibException ( "Sever authkey is not helper " , HttpStatus . INTERNAL_SERVER_ERROR ) ; } if ( validaitonSessionCheckAndRemake ( info . getToken ( ) ) ) { return this . createSession ( req , res ) ; } if ( ! this . validationConfig . getAuthToken ( ) . equals ( info . getToken ( ) ) ) { throw new ValidationLibException ( "UnAuthorization" , HttpStatus . UNAUTHORIZED ) ; } req . getSession ( ) ; return this . createSession ( req , res ) ; } | Check auth validation session info . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.