idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
100 | public static int [ ] Concatenate ( int [ ] array , int [ ] array2 ) { int [ ] all = new int [ array . length + array2 . length ] ; int idx = 0 ; //First array for ( int i = 0 ; i < array . length ; i ++ ) all [ idx ++ ] = array [ i ] ; //Second array for ( int i = 0 ; i < array2 . length ; i ++ ) all [ idx ++ ] = arra... | Concatenate the arrays . | 114 | 7 |
101 | public static int [ ] ConcatenateInt ( List < int [ ] > arrays ) { int size = 0 ; for ( int i = 0 ; i < arrays . size ( ) ; i ++ ) { size += arrays . get ( i ) . length ; } int [ ] all = new int [ size ] ; int idx = 0 ; for ( int i = 0 ; i < arrays . size ( ) ; i ++ ) { int [ ] v = arrays . get ( i ) ; for ( int j = 0 ... | Concatenate all the arrays in the list into a vector . | 139 | 14 |
102 | public static < T extends Number > int [ ] asArray ( final T ... array ) { int [ ] b = new int [ array . length ] ; for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = array [ i ] . intValue ( ) ; } return b ; } | Convert any number class to array of integer . | 69 | 10 |
103 | public static void Shuffle ( double [ ] array , long seed ) { Random random = new Random ( ) ; if ( seed != 0 ) random . setSeed ( seed ) ; for ( int i = array . length - 1 ; i > 0 ; i -- ) { int index = random . nextInt ( i + 1 ) ; double temp = array [ index ] ; array [ index ] = array [ i ] ; array [ i ] = temp ; } ... | Shuffle an array . | 97 | 5 |
104 | public static float [ ] toFloat ( int [ ] array ) { float [ ] n = new float [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { n [ i ] = ( float ) array [ i ] ; } return n ; } | 1 - D Integer array to float array . | 62 | 9 |
105 | public static float [ ] [ ] toFloat ( int [ ] [ ] array ) { float [ ] [ ] n = new float [ array . length ] [ array [ 0 ] . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { for ( int j = 0 ; j < array [ 0 ] . length ; j ++ ) { n [ i ] [ j ] = ( float ) array [ i ] [ j ] ; } } return n ; } | 2 - D Integer array to float array . | 103 | 9 |
106 | public static int [ ] toInt ( double [ ] array ) { int [ ] n = new int [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { n [ i ] = ( int ) array [ i ] ; } return n ; } | 1 - D Double array to integer array . | 62 | 9 |
107 | public static int [ ] [ ] toInt ( double [ ] [ ] array ) { int [ ] [ ] n = new int [ array . length ] [ array [ 0 ] . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { for ( int j = 0 ; j < array [ 0 ] . length ; j ++ ) { n [ i ] [ j ] = ( int ) array [ i ] [ j ] ; } } return n ; } | 2 - D Double array to integer array . | 103 | 9 |
108 | public static double [ ] toDouble ( int [ ] array ) { double [ ] n = new double [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { n [ i ] = ( double ) array [ i ] ; } return n ; } | 1 - D Integer array to double array . | 62 | 9 |
109 | public static double [ ] [ ] toDouble ( int [ ] [ ] array ) { double [ ] [ ] n = new double [ array . length ] [ array [ 0 ] . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { for ( int j = 0 ; j < array [ 0 ] . length ; j ++ ) { n [ i ] [ j ] = ( double ) array [ i ] [ j ] ; } } return n ; } | 2 - D Integer array to double array . | 103 | 9 |
110 | public ApiResponse < TokenInfoSuccessResponse > tokenInfoWithHttpInfo ( ) throws ApiException { com . squareup . okhttp . Call call = tokenInfoValidateBeforeCall ( null , null ) ; Type localVarReturnType = new TypeToken < TokenInfoSuccessResponse > ( ) { } . getType ( ) ; return apiClient . execute ( call , localVarRet... | Token Info Returns the Token Information | 85 | 6 |
111 | public static double HighAccuracyFunction ( double x ) { if ( x < - 8 || x > 8 ) return 0 ; double sum = x ; double term = 0 ; double nextTerm = x ; double pwr = x * x ; double i = 1 ; // Iterate until adding next terms doesn't produce // any change within the current numerical accuracy. while ( sum != term ) { term = ... | High - accuracy Normal cumulative distribution function . | 139 | 8 |
112 | public static double HighAccuracyComplemented ( double x ) { double [ ] R = { 1.25331413731550025 , 0.421369229288054473 , 0.236652382913560671 , 0.162377660896867462 , 0.123131963257932296 , 0.0990285964717319214 , 0.0827662865013691773 , 0.0710695805388521071 , 0.0622586659950261958 } ; int j = ( int ) ( 0.5 * ( Math... | High - accuracy Complementary normal distribution function . | 326 | 10 |
113 | public String toIPTC ( SubjectReferenceSystem srs ) { StringBuffer b = new StringBuffer ( ) ; b . append ( "IPTC:" ) ; b . append ( getNumber ( ) ) ; b . append ( ":" ) ; if ( getNumber ( ) . endsWith ( "000000" ) ) { b . append ( toIPTCHelper ( srs . getName ( this ) ) ) ; b . append ( "::" ) ; } else if ( getNumber (... | Formats an IPTC string for this reference using information obtained from Subject Reference System . | 334 | 17 |
114 | public DataSetInfo create ( int dataSet ) throws InvalidDataSetException { DataSetInfo info = dataSets . get ( createKey ( dataSet ) ) ; if ( info == null ) { int recordNumber = ( dataSet >> 8 ) & 0xFF ; int dataSetNumber = dataSet & 0xFF ; throw new UnsupportedDataSetException ( recordNumber + ":" + dataSetNumber ) ; ... | Creates and caches dataset info object . Subsequent invocations will return same instance . | 103 | 17 |
115 | public double Function1D ( double x ) { double frequency = initFrequency ; double amplitude = initAmplitude ; double sum = 0 ; // octaves for ( int i = 0 ; i < octaves ; i ++ ) { sum += SmoothedNoise ( x * frequency ) * amplitude ; frequency *= 2 ; amplitude *= persistence ; } return sum ; } | 1 - D Perlin noise function . | 79 | 8 |
116 | public double Function2D ( double x , double y ) { double frequency = initFrequency ; double amplitude = initAmplitude ; double sum = 0 ; // octaves for ( int i = 0 ; i < octaves ; i ++ ) { sum += SmoothedNoise ( x * frequency , y * frequency ) * amplitude ; frequency *= 2 ; amplitude *= persistence ; } return sum ; } | 2 - D Perlin noise function . | 86 | 8 |
117 | private double Noise ( int x , int y ) { int n = x + y * 57 ; n = ( n << 13 ) ^ n ; return ( 1.0 - ( ( n * ( n * n * 15731 + 789221 ) + 1376312589 ) & 0x7fffffff ) / 1073741824.0 ) ; } | Ordinary noise function . | 75 | 5 |
118 | private double CosineInterpolate ( double x1 , double x2 , double a ) { double f = ( 1 - Math . cos ( a * Math . PI ) ) * 0.5 ; return x1 * ( 1 - f ) + x2 * f ; } | Cosine interpolation . | 58 | 5 |
119 | public List < FailedEventInvocation > getFailedInvocations ( ) { synchronized ( this . mutex ) { if ( this . failedEvents == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . failedEvents ) ; } } | Gets the list of failed invocations that has been collected by this collector . | 60 | 16 |
120 | public Set < Class < ? > > getPrevented ( ) { if ( this . prevent == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( this . prevent ) ; } | Gets the listener classes to which dispatching should be prevented while this event is being dispatched . | 47 | 19 |
121 | public static double Function1D ( double x , double mean , double amplitude , double position , double width , double phase , double frequency ) { double envelope = mean + amplitude * Math . exp ( - Math . pow ( ( x - position ) , 2 ) / Math . pow ( ( 2 * width ) , 2 ) ) ; double carry = Math . cos ( 2 * Math . PI * fr... | 1 - D Gabor function . | 98 | 7 |
122 | public static ComplexNumber Function2D ( int x , int y , double wavelength , double orientation , double phaseOffset , double gaussVariance , double aspectRatio ) { double X = x * Math . cos ( orientation ) + y * Math . sin ( orientation ) ; double Y = - x * Math . sin ( orientation ) + y * Math . cos ( orientation ) ;... | 2 - D Complex Gabor function . | 183 | 8 |
123 | public Long getOldestTaskCreatedTime ( ) { Timer . Context ctx = getOldestTaskTimeTimer . time ( ) ; try { long oldest = Long . MAX_VALUE ; /* * I am asking this question first, because if I ask it after I could * miss the oldest time if the oldest is polled and worked on */ Long oldestQueueTime = this . taskQueue . ge... | We want to get the best result possible as this value is used to determine what work needs to be recovered . | 173 | 22 |
124 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public List < HazeltaskTask < G > > shutdownNow ( ) { return ( List < HazeltaskTask < G > > ) ( List ) localExecutorPool . shutdownNow ( ) ; } | SuppressWarnings I really want to return HazeltaskTasks instead of Runnable | 62 | 20 |
125 | public void registerCollectionSizeGauge ( CollectionSizeGauge collectionSizeGauge ) { String name = createMetricName ( LocalTaskExecutorService . class , "queue-size" ) ; metrics . register ( name , collectionSizeGauge ) ; } | Calling this twice will not actually overwrite the gauge | 58 | 9 |
126 | public ExecutorLoadBalancingConfig < GROUP > useLoadBalancedEnumOrdinalPrioritizer ( Class < GROUP > groupClass ) { if ( ! groupClass . isEnum ( ) ) { throw new IllegalArgumentException ( "The group class " + groupClass + " is not an enum" ) ; } groupPrioritizer = new LoadBalancedPriorityPrioritizer < GROUP > ( new Enu... | If you have priorities based on enums this is the recommended prioritizer to use as it will prevent starvation of low priority items | 105 | 26 |
127 | public static < GROUP extends Serializable > ExecutorConfig < GROUP > basicGroupable ( ) { return new ExecutorConfig < GROUP > ( ) . withTaskIdAdapter ( ( TaskIdAdapter < Groupable < GROUP > , GROUP , ? > ) new DefaultGroupableTaskIdAdapter < GROUP > ( ) ) ; } | This configuration requires that all your tasks you submit to the system implement the Groupable interface . By default it will round robin tasks from each group | 67 | 29 |
128 | public Collection < HazeltaskTask < GROUP > > call ( ) throws Exception { try { if ( isShutdownNow ) return this . getDistributedExecutorService ( ) . shutdownNowWithHazeltask ( ) ; else this . getDistributedExecutorService ( ) . shutdown ( ) ; } catch ( IllegalStateException e ) { } return Collections . emptyList ( ) ... | I promise that this is always a collection of HazeltaskTasks | 83 | 14 |
129 | public static < T > Collection < MemberResponse < T > > executeOptimistic ( IExecutorService execSvc , Set < Member > members , Callable < T > callable ) { return executeOptimistic ( execSvc , members , callable , 60 , TimeUnit . SECONDS ) ; } | Will wait a maximum of 1 minute for each node to response with their result . If an error occurs on any member we will always attempt to continue execution and collect as many results as possible . | 67 | 38 |
130 | public static < T > Collection < MemberResponse < T > > executeOptimistic ( IExecutorService execSvc , Set < Member > members , Callable < T > callable , long maxWaitTime , TimeUnit unit ) { Collection < MemberResponse < T >> result = new ArrayList < MemberResponse < T > > ( members . size ( ) ) ; Map < Member , Future... | We will always try to gather as many results as possible and never throw an exception . | 433 | 17 |
131 | @ SuppressWarnings ( "unchecked" ) public < T > DistributedFuture < GROUP , T > createFuture ( HazeltaskTask < GROUP > task ) { DistributedFuture < GROUP , T > future = new DistributedFuture < GROUP , T > ( topologyService , task . getGroup ( ) , task . getId ( ) ) ; this . futures . put ( task . getId ( ) , ( Distribu... | It is required that T be Serializable | 107 | 8 |
132 | public void errorFuture ( UUID taskId , Exception e ) { DistributedFuture < GROUP , Serializable > future = remove ( taskId ) ; if ( future != null ) { future . setException ( e ) ; } } | handles when a member leaves and hazelcast partition data is lost . We want to find the Futures that are waiting on lost data and error them | 48 | 31 |
133 | public void schedule ( BackoffTask task , long initialDelay , long fixedDelay ) { synchronized ( queue ) { start ( ) ; queue . put ( new DelayedTimerTask ( task , initialDelay , fixedDelay ) ) ; } } | Schedules the task with a fixed delay period and an initialDelay period . This functions like the normal java Timer . | 53 | 26 |
134 | public Future < HazeltaskTask < GROUP > > addPendingTaskAsync ( HazeltaskTask < GROUP > task ) { return pendingTask . putAsync ( task . getId ( ) , task ) ; } | Asynchronously put the work into the pending map so we can work on submitting it to the worker if we wanted . Could possibly cause duplicate work if we execute the work then add to the map . | 45 | 40 |
135 | public void applyXMLDSigAsFirstChild ( @ Nonnull final PrivateKey aPrivateKey , @ Nonnull final X509Certificate aCertificate , @ Nonnull final Document aDocument ) throws Exception { ValueEnforcer . notNull ( aPrivateKey , "privateKey" ) ; ValueEnforcer . notNull ( aCertificate , "certificate" ) ; ValueEnforcer . notNu... | Apply an XMLDSig onto the passed document . | 422 | 10 |
136 | public static < K > Map < K , Integer > rankMapOnIntegerValue ( Map < K , Integer > inputMap ) { Map < K , Integer > newMap = new TreeMap < K , Integer > ( new IntegerValueComparator ( inputMap ) ) ; newMap . putAll ( inputMap ) ; Map < K , Integer > linkedMap = new LinkedHashMap < K , Integer > ( newMap ) ; return lin... | Ranks a map based on integer values | 95 | 8 |
137 | private void handleIncomingMessage ( SerialMessage incomingMessage ) { logger . debug ( "Incoming message to process" ) ; logger . debug ( incomingMessage . toString ( ) ) ; switch ( incomingMessage . getMessageType ( ) ) { case Request : handleIncomingRequestMessage ( incomingMessage ) ; break ; case Response : handle... | Handles incoming Serial Messages . Serial messages can either be messages that are a response to our own requests or the stick asking us information . | 113 | 27 |
138 | private void handleIncomingRequestMessage ( SerialMessage incomingMessage ) { logger . debug ( "Message type = REQUEST" ) ; switch ( incomingMessage . getMessageClass ( ) ) { case ApplicationCommandHandler : handleApplicationCommandRequest ( incomingMessage ) ; break ; case SendData : handleSendDataRequest ( incomingMe... | Handles an incoming request message . An incoming request message is a message initiated by a node or the controller . | 150 | 22 |
139 | private void handleApplicationCommandRequest ( SerialMessage incomingMessage ) { logger . trace ( "Handle Message Application Command Request" ) ; int nodeId = incomingMessage . getMessagePayloadByte ( 1 ) ; logger . debug ( "Application Command Request from Node " + nodeId ) ; ZWaveNode node = getNode ( nodeId ) ; if ... | Handles incoming Application Command Request . | 495 | 7 |
140 | private void handleSendDataRequest ( SerialMessage incomingMessage ) { logger . trace ( "Handle Message Send Data Request" ) ; int callbackId = incomingMessage . getMessagePayloadByte ( 0 ) ; TransmissionState status = TransmissionState . getTransmissionState ( incomingMessage . getMessagePayloadByte ( 1 ) ) ; SerialMe... | Handles incoming Send Data Request . Send Data request are used to acknowledge or cancel failed messages . | 501 | 19 |
141 | private void handleFailedSendDataRequest ( SerialMessage originalMessage ) { ZWaveNode node = this . getNode ( originalMessage . getMessageNode ( ) ) ; if ( node . getNodeStage ( ) == NodeStage . NODEBUILDINFO_DEAD ) return ; if ( ! node . isListening ( ) && originalMessage . getPriority ( ) != SerialMessage . SerialMe... | Handles a failed SendData request . This can either be because of the stick actively reporting it or because of a time - out of the transaction in the send thread . | 269 | 34 |
142 | private void handleApplicationUpdateRequest ( SerialMessage incomingMessage ) { logger . trace ( "Handle Message Application Update Request" ) ; int nodeId = incomingMessage . getMessagePayloadByte ( 1 ) ; logger . trace ( "Application Update Request from Node " + nodeId ) ; UpdateState updateState = UpdateState . getU... | Handles incoming Application Update Request . | 634 | 7 |
143 | private void handleGetVersionResponse ( SerialMessage incomingMessage ) { this . ZWaveLibraryType = incomingMessage . getMessagePayloadByte ( 12 ) ; this . zWaveVersion = new String ( ArrayUtils . subarray ( incomingMessage . getMessagePayload ( ) , 0 , 11 ) ) ; logger . debug ( String . format ( "Got MessageGetVersion... | Handles the response of the getVersion request . | 106 | 10 |
144 | private void handleSerialApiGetInitDataResponse ( SerialMessage incomingMessage ) { logger . debug ( String . format ( "Got MessageSerialApiGetInitData response." ) ) ; this . isConnected = true ; int nodeBytes = incomingMessage . getMessagePayloadByte ( 2 ) ; if ( nodeBytes != NODE_BYTES ) { logger . error ( "Invalid ... | Handles the response of the SerialApiGetInitData request . | 361 | 14 |
145 | private void handleMemoryGetId ( SerialMessage incomingMessage ) { this . homeId = ( ( incomingMessage . getMessagePayloadByte ( 0 ) ) << 24 ) | ( ( incomingMessage . getMessagePayloadByte ( 1 ) ) << 16 ) | ( ( incomingMessage . getMessagePayloadByte ( 2 ) ) << 8 ) | ( incomingMessage . getMessagePayloadByte ( 3 ) ) ; ... | Handles the response of the MemoryGetId request . The MemoryGetId function gets the home and node id from the controller memory . | 151 | 27 |
146 | private void handleSerialAPIGetCapabilitiesResponse ( SerialMessage incomingMessage ) { logger . trace ( "Handle Message Serial API Get Capabilities" ) ; this . serialAPIVersion = String . format ( "%d.%d" , incomingMessage . getMessagePayloadByte ( 0 ) , incomingMessage . getMessagePayloadByte ( 1 ) ) ; this . manufac... | Handles the response of the SerialAPIGetCapabilities request . | 369 | 14 |
147 | private void handleSendDataResponse ( SerialMessage incomingMessage ) { logger . trace ( "Handle Message Send Data Response" ) ; if ( incomingMessage . getMessageBuffer ( ) [ 2 ] != 0x00 ) logger . debug ( "Sent Data successfully placed on stack." ) ; else logger . error ( "Sent Data was not placed on stack due to erro... | Handles the response of the SendData request . | 78 | 10 |
148 | private void handleRequestNodeInfoResponse ( SerialMessage incomingMessage ) { logger . trace ( "Handle RequestNodeInfo Response" ) ; if ( incomingMessage . getMessageBuffer ( ) [ 2 ] != 0x00 ) logger . debug ( "Request node info successfully placed on stack." ) ; else logger . error ( "Request node info not placed on ... | Handles the response of the Request node request . | 80 | 10 |
149 | public void connect ( final String serialPortName ) throws SerialInterfaceException { logger . info ( "Connecting to serial port {}" , serialPortName ) ; try { CommPortIdentifier portIdentifier = CommPortIdentifier . getPortIdentifier ( serialPortName ) ; CommPort commPort = portIdentifier . open ( "org.openhab.binding... | Connects to the comm port and starts send and receive threads . | 361 | 13 |
150 | public void close ( ) { if ( watchdog != null ) { watchdog . cancel ( ) ; watchdog = null ; } disconnect ( ) ; // clear nodes collection and send queue for ( Object listener : this . zwaveEventListeners . toArray ( ) ) { if ( ! ( listener instanceof ZWaveNode ) ) continue ; this . zwaveEventListeners . remove ( listene... | Closes the connection to the Z - Wave controller . | 117 | 11 |
151 | public void disconnect ( ) { if ( sendThread != null ) { sendThread . interrupt ( ) ; try { sendThread . join ( ) ; } catch ( InterruptedException e ) { } sendThread = null ; } if ( receiveThread != null ) { receiveThread . interrupt ( ) ; try { receiveThread . join ( ) ; } catch ( InterruptedException e ) { } receiveT... | Disconnects from the serial interface and stops send and receive threads . | 187 | 14 |
152 | public void enqueue ( SerialMessage serialMessage ) { this . sendQueue . add ( serialMessage ) ; logger . debug ( "Enqueueing message. Queue length = {}" , this . sendQueue . size ( ) ) ; } | Enqueues a message for sending on the send thread . | 50 | 12 |
153 | public void notifyEventListeners ( ZWaveEvent event ) { logger . debug ( "Notifying event listeners" ) ; for ( ZWaveEventListener listener : this . zwaveEventListeners ) { logger . trace ( "Notifying {}" , listener . toString ( ) ) ; listener . ZWaveIncomingEvent ( event ) ; } } | Notify our own event listeners of a Z - Wave event . | 73 | 13 |
154 | public void initialize ( ) { this . enqueue ( new SerialMessage ( SerialMessage . SerialMessageClass . GetVersion , SerialMessage . SerialMessageType . Request , SerialMessage . SerialMessageClass . GetVersion , SerialMessage . SerialMessagePriority . High ) ) ; this . enqueue ( new SerialMessage ( SerialMessage . Seri... | Initializes communication with the Z - Wave controller stick . | 167 | 11 |
155 | public void identifyNode ( int nodeId ) throws SerialInterfaceException { SerialMessage newMessage = new SerialMessage ( nodeId , SerialMessage . SerialMessageClass . IdentifyNode , SerialMessage . SerialMessageType . Request , SerialMessage . SerialMessageClass . IdentifyNode , SerialMessage . SerialMessagePriority . ... | Send Identify Node message to the controller . | 106 | 9 |
156 | public void requestNodeInfo ( int nodeId ) { SerialMessage newMessage = new SerialMessage ( nodeId , SerialMessage . SerialMessageClass . RequestNodeInfo , SerialMessage . SerialMessageType . Request , SerialMessage . SerialMessageClass . ApplicationUpdate , SerialMessage . SerialMessagePriority . High ) ; byte [ ] new... | Send Request Node info message to the controller . | 102 | 9 |
157 | public void sendData ( SerialMessage serialMessage ) { if ( serialMessage . getMessageClass ( ) != SerialMessage . SerialMessageClass . SendData ) { logger . error ( String . format ( "Invalid message class %s (0x%02X) for sendData" , serialMessage . getMessageClass ( ) . getLabel ( ) , serialMessage . getMessageClass ... | Transmits the SerialMessage to a single Z - Wave Node . Sets the transmission options as well . | 431 | 20 |
158 | public void sendValue ( int nodeId , int endpoint , int value ) { ZWaveNode node = this . getNode ( nodeId ) ; ZWaveSetCommands zwaveCommandClass = null ; SerialMessage serialMessage = null ; for ( ZWaveCommandClass . CommandClass commandClass : new ZWaveCommandClass . CommandClass [ ] { ZWaveCommandClass . CommandClas... | Send value to node . | 306 | 5 |
159 | private void processProperties ( ) { state = true ; try { importerServiceFilter = getFilter ( importerServiceFilterProperty ) ; } catch ( InvalidFilterException invalidFilterException ) { LOG . debug ( "The value of the Property " + FILTER_IMPORTERSERVICE_PROPERTY + " is invalid," + " the recuperation of the Filter has... | Get the filters ImporterServiceFilter and ImportDeclarationFilter from the properties stop the instance if one of . them is invalid . | 188 | 26 |
160 | @ Modified ( id = "importerServices" ) void modifiedImporterService ( ServiceReference < ImporterService > serviceReference ) { try { importersManager . modified ( serviceReference ) ; } catch ( InvalidFilterException invalidFilterException ) { LOG . error ( "The ServiceProperty \"" + TARGET_FILTER_PROPERTY + "\" of th... | Update the Target Filter of the ImporterService . Apply the induce modifications on the links of the ImporterService | 188 | 22 |
161 | private void unregisterAllServlets ( ) { for ( String endpoint : registeredServlets ) { registeredServlets . remove ( endpoint ) ; web . unregister ( endpoint ) ; LOG . info ( "endpoint {} unregistered" , endpoint ) ; } } | Unregister all servlets registered by this exporter . | 54 | 11 |
162 | public double [ ] calculateDrift ( ArrayList < T > tracks ) { double [ ] result = new double [ 3 ] ; double sumX = 0 ; double sumY = 0 ; double sumZ = 0 ; int N = 0 ; for ( int i = 0 ; i < tracks . size ( ) ; i ++ ) { T t = tracks . get ( i ) ; TrajectoryValidIndexTimelagIterator it = new TrajectoryValidIndexTimelagIte... | Calculates the static drift . Static means that the drift does not change direction or intensity over time . | 250 | 21 |
163 | public void addCommandClass ( ZWaveCommandClass commandClass ) { ZWaveCommandClass . CommandClass key = commandClass . getCommandClass ( ) ; if ( ! supportedCommandClasses . containsKey ( key ) ) { supportedCommandClasses . put ( key , commandClass ) ; } } | Adds a command class to the list of supported command classes by this endpoint . Does nothing if command class is already added . | 62 | 24 |
164 | public boolean canBeLinked ( D declaration , ServiceReference < S > declarationBinderRef ) { // Evaluate the target filter of the ImporterService on the Declaration Filter filter = bindersManager . getTargetFilter ( declarationBinderRef ) ; return filter . matches ( declaration . getMetadata ( ) ) ; } | Return true if the Declaration can be linked to the ImporterService . | 67 | 14 |
165 | public boolean link ( D declaration , ServiceReference < S > declarationBinderRef ) { S declarationBinder = bindersManager . getDeclarationBinder ( declarationBinderRef ) ; LOG . debug ( declaration + " match the filter of " + declarationBinder + " : bind them together" ) ; declaration . bind ( declarationBinderRef ) ;... | Try to link the declaration with the importerService referenced by the ServiceReference . return true if they have been link together false otherwise . | 138 | 27 |
166 | public boolean unlink ( D declaration , ServiceReference < S > declarationBinderRef ) { S declarationBinder = bindersManager . getDeclarationBinder ( declarationBinderRef ) ; try { declarationBinder . removeDeclaration ( declaration ) ; } catch ( BinderException e ) { LOG . debug ( declarationBinder + " throw an except... | Try to unlink the declaration from the importerService referenced by the ServiceReference . return true if they have been cleanly unlink false otherwise . | 120 | 30 |
167 | private static String removeLastDot ( final String pkgName ) { return pkgName . charAt ( pkgName . length ( ) - 1 ) == Characters . DOT ? pkgName . substring ( 0 , pkgName . length ( ) - 1 ) : pkgName ; } | Filters a dot at the end of the passed package name if present . | 63 | 15 |
168 | @ Nonnull private static Properties findDefaultProperties ( ) { final InputStream in = SourceCodeFormatter . class . getClassLoader ( ) . getResourceAsStream ( DEFAULT_PROPERTIES_PATH ) ; final Properties p = new Properties ( ) ; try { p . load ( in ) ; } catch ( final IOException e ) { throw new RuntimeException ( Str... | Gets the default options to be passed when no custom properties are given . | 109 | 15 |
169 | public static String format ( final String code , final Properties options , final LineEnding lineEnding ) { Check . notEmpty ( code , "code" ) ; Check . notEmpty ( options , "options" ) ; Check . notNull ( lineEnding , "lineEnding" ) ; final CodeFormatter formatter = ToolFactory . createCodeFormatter ( options ) ; fin... | Pretty prints the given source code . | 272 | 7 |
170 | private void processProperties ( ) { state = true ; try { exporterServiceFilter = getFilter ( exporterServiceFilterProperty ) ; } catch ( InvalidFilterException invalidFilterException ) { LOG . debug ( "The value of the Property " + FILTER_EXPORTERSERVICE_PROPERTY + " is invalid," + " the recuperation of the Filter has... | Get the filters ExporterServiceFilter and ExportDeclarationFilter from the properties stop the instance if one of . them is invalid . | 188 | 26 |
171 | @ Modified ( id = "exporterServices" ) void modifiedExporterService ( ServiceReference < ExporterService > serviceReference ) { try { exportersManager . modified ( serviceReference ) ; } catch ( InvalidFilterException invalidFilterException ) { LOG . error ( "The ServiceProperty \"" + TARGET_FILTER_PROPERTY + "\" of th... | Update the Target Filter of the ExporterService . Apply the induce modifications on the links of the ExporterService | 188 | 22 |
172 | private void checkGAs ( List l ) { for ( final Iterator i = l . iterator ( ) ; i . hasNext ( ) ; ) if ( ! ( i . next ( ) instanceof GroupAddress ) ) throw new KNXIllegalArgumentException ( "not a group address list" ) ; } | iteration not synchronized | 66 | 4 |
173 | public static Trajectory addPositionNoise ( Trajectory t , double sd ) { CentralRandomNumberGenerator r = CentralRandomNumberGenerator . getInstance ( ) ; Trajectory newt = new Trajectory ( t . getDimension ( ) ) ; for ( int i = 0 ; i < t . size ( ) ; i ++ ) { newt . add ( t . get ( i ) ) ; for ( int j = 1 ; j <= t . g... | Adds position noise to the trajectories | 238 | 7 |
174 | public SerialMessage getNoMoreInformationMessage ( ) { logger . debug ( "Creating new message for application command WAKE_UP_NO_MORE_INFORMATION for node {}" , this . getNode ( ) . getNodeId ( ) ) ; SerialMessage result = new SerialMessage ( this . getNode ( ) . getNodeId ( ) , SerialMessage . SerialMessageClass . Sen... | Gets a SerialMessage with the WAKE_UP_NO_MORE_INFORMATION command . | 185 | 20 |
175 | public void putInWakeUpQueue ( SerialMessage serialMessage ) { if ( this . wakeUpQueue . contains ( serialMessage ) ) { logger . debug ( "Message already on the wake-up queue for node {}. Discarding." , this . getNode ( ) . getNodeId ( ) ) ; return ; } logger . debug ( "Putting message in wakeup queue for node {}." , t... | Puts a message in the wake - up queue of this node to send the message on wake - up . | 111 | 22 |
176 | protected Method resolveTargetMethod ( Message message , FieldDescriptor payloadField ) { Method targetMethod = fieldToMethod . get ( payloadField ) ; if ( targetMethod == null ) { // look up and cache target method; this block is called only once // per target method, so synchronized is ok synchronized ( this ) { targ... | Find out which method to call on the service bean . | 241 | 11 |
177 | protected FieldDescriptor resolvePayloadField ( Message message ) { for ( FieldDescriptor field : message . getDescriptorForType ( ) . getFields ( ) ) { if ( message . hasField ( field ) ) { return field ; } } throw new RuntimeException ( "No payload found in message " + message ) ; } | Find out which field in the incoming message contains the payload that is . delivered to the service method . | 73 | 20 |
178 | public static Status from ( Set < ServiceReference > serviceReferencesBound , Set < ServiceReference > serviceReferencesHandled ) { if ( serviceReferencesBound == null && serviceReferencesHandled == null ) { throw new IllegalArgumentException ( "Cannot create a status with serviceReferencesBound == null" + "and service... | Creates a status instance from the given serviceReferences . The given list is copied to a new set made immutable . | 157 | 23 |
179 | public SerialMessage getValueMessage ( ) { logger . debug ( "Creating new message for application command BASIC_GET for node {}" , this . getNode ( ) . getNodeId ( ) ) ; SerialMessage result = new SerialMessage ( this . getNode ( ) . getNodeId ( ) , SerialMessageClass . SendData , SerialMessageType . Request , SerialMe... | Gets a SerialMessage with the BASIC GET command | 158 | 11 |
180 | public SerialMessage setValueMessage ( int level ) { logger . debug ( "Creating new message for application command BASIC_SET for node {}" , this . getNode ( ) . getNodeId ( ) ) ; SerialMessage result = new SerialMessage ( this . getNode ( ) . getNodeId ( ) , SerialMessageClass . SendData , SerialMessageType . Request ... | Gets a SerialMessage with the BASIC SET command | 164 | 11 |
181 | public void subscriptionRequestReceived ( SubscriptionRequest sr ) throws SubscriptionException { LOG . info ( "Subscriber -> (Hub), new subscription request received." , sr . getCallback ( ) ) ; try { verifySubscriberRequestedSubscription ( sr ) ; if ( "subscribe" . equals ( sr . getMode ( ) ) ) { LOG . info ( "Adding... | Input method called by a Subscriber indicating its intent into receive notification about a given topic . | 214 | 19 |
182 | public Boolean verifySubscriberRequestedSubscription ( SubscriptionRequest sr ) throws SubscriptionOriginVerificationException { LOG . info ( "(Hub) -> Subscriber, sending notification to verify the origin of the subscription {}." , sr . getCallback ( ) ) ; SubscriptionConfirmationRequest sc = new SubscriptionConfirmat... | Output method that sends a subscription confirmation for the subscriber to avoid DoS attacks or false subscription . | 329 | 19 |
183 | public void notifySubscriberCallback ( ContentNotification cn ) { String content = fetchContentFromPublisher ( cn ) ; distributeContentToSubscribers ( content , cn . getUrl ( ) ) ; } | Output method responsible for sending the updated content to the Subscribers . | 46 | 14 |
184 | public Point2D . Double minDistancePointSpline ( Point2D . Double p , int nPointsPerSegment ) { double minDistance = Double . MAX_VALUE ; Point2D . Double minDistancePoint = null ; int numberOfSplines = spline . getN ( ) ; double [ ] knots = spline . getKnots ( ) ; for ( int i = 0 ; i < numberOfSplines ; i ++ ) { doubl... | Finds to a given point p the point on the spline with minimum distance . | 216 | 17 |
185 | public void showTrajectoryAndSpline ( ) { if ( t . getDimension ( ) == 2 ) { double [ ] xData = new double [ rotatedTrajectory . size ( ) ] ; double [ ] yData = new double [ rotatedTrajectory . size ( ) ] ; for ( int i = 0 ; i < rotatedTrajectory . size ( ) ; i ++ ) { xData [ i ] = rotatedTrajectory . get ( i ) . x ; y... | Plots the rotated trajectory spline and support points . | 625 | 11 |
186 | public static < T > Set < T > getSet ( Collection < T > collection ) { Set < T > set = new LinkedHashSet < T > ( ) ; set . addAll ( collection ) ; return set ; } | Convert Collection to Set | 48 | 5 |
187 | public static < T > String join ( Collection < T > col , String delim ) { StringBuilder sb = new StringBuilder ( ) ; Iterator < T > iter = col . iterator ( ) ; if ( iter . hasNext ( ) ) sb . append ( iter . next ( ) . toString ( ) ) ; while ( iter . hasNext ( ) ) { sb . append ( delim ) ; sb . append ( iter . next ( ) ... | Joins a collection in a string using a delimiter | 114 | 11 |
188 | public void checkVersion ( ZWaveCommandClass commandClass ) { ZWaveVersionCommandClass versionCommandClass = ( ZWaveVersionCommandClass ) this . getNode ( ) . getCommandClass ( CommandClass . VERSION ) ; if ( versionCommandClass == null ) { logger . error ( String . format ( "Version command class not supported on node... | Check the version of a command class by sending a VERSION_COMMAND_CLASS_GET message to the node . | 173 | 25 |
189 | public static String getContent ( String stringUrl ) throws IOException { InputStream stream = getContentStream ( stringUrl ) ; return MyStreamUtils . readContent ( stream ) ; } | Get content for URL only | 39 | 5 |
190 | public static InputStream getContentStream ( String stringUrl ) throws MalformedURLException , IOException { URL url = new URL ( stringUrl ) ; URLConnection urlConnection = url . openConnection ( ) ; InputStream is = urlConnection . getInputStream ( ) ; if ( "gzip" . equals ( urlConnection . getContentEncoding ( ) ) ) ... | Get stream for URL only | 96 | 5 |
191 | public static Map < String , List < String > > getResponseHeaders ( String stringUrl ) throws IOException { return getResponseHeaders ( stringUrl , true ) ; } | Get the response headers for URL | 37 | 6 |
192 | public static Map < String , List < String > > getResponseHeaders ( String stringUrl , boolean followRedirects ) throws IOException { URL url = new URL ( stringUrl ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setInstanceFollowRedirects ( followRedirects ) ; InputStream is = conn ... | Get the response headers for URL following redirects | 249 | 9 |
193 | public static void downloadUrl ( String stringUrl , Map < String , String > parameters , File fileToSave ) throws IOException { URL url = new URL ( stringUrl ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setFollowRedirects ( true ) ; if ( parameters != null ) { for ( Entry < Strin... | Download a specified URL to a file | 358 | 7 |
194 | public static byte [ ] getContentBytes ( String stringUrl ) throws IOException { URL url = new URL ( stringUrl ) ; byte [ ] data = MyStreamUtils . readContentBytes ( url . openStream ( ) ) ; return data ; } | Return the content from an URL in byte array | 53 | 9 |
195 | public static String httpRequest ( String stringUrl , String method , Map < String , String > parameters , String input , String charset ) throws IOException { URL url = new URL ( stringUrl ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setDoOutput ( true ) ; conn . setRequestMetho... | Execute a HTTP request | 204 | 5 |
196 | public void add ( ServiceReference < D > declarationSRef ) { D declaration = getDeclaration ( declarationSRef ) ; boolean matchFilter = declarationFilter . matches ( declaration . getMetadata ( ) ) ; declarations . put ( declarationSRef , matchFilter ) ; } | Add the declarationSRef to the DeclarationsManager . Calculate the matching of the Declaration with the DeclarationFilter of the Linker . | 57 | 27 |
197 | public void createLinks ( ServiceReference < D > declarationSRef ) { D declaration = getDeclaration ( declarationSRef ) ; for ( ServiceReference < S > serviceReference : linkerManagement . getMatchedBinderServiceRef ( ) ) { if ( linkerManagement . canBeLinked ( declaration , serviceReference ) ) { linkerManagement . li... | Create all the links possible between the Declaration and all the ImporterService matching the . ImporterServiceFilter of the Linker . | 85 | 26 |
198 | public void removeLinks ( ServiceReference < D > declarationSRef ) { D declaration = getDeclaration ( declarationSRef ) ; for ( ServiceReference serviceReference : declaration . getStatus ( ) . getServiceReferencesBounded ( ) ) { // FIXME : In case of multiples Linker, we will remove the link of all the ServiceReferenc... | Remove all the existing links of the Declaration . | 99 | 9 |
199 | public Set < D > getMatchedDeclaration ( ) { Set < D > bindedSet = new HashSet < D > ( ) ; for ( Map . Entry < ServiceReference < D > , Boolean > e : declarations . entrySet ( ) ) { if ( e . getValue ( ) ) { bindedSet . add ( getDeclaration ( e . getKey ( ) ) ) ; } } return bindedSet ; } | Return a set of all the Declaration matching the DeclarationFilter of the . Linker . | 91 | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.