idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
138,000 | public int startNewSession ( ) { if ( txSessEncKey != null ) return SESSION_ERROR_ALREADY_ACTIVE ; if ( ( txMasterSalt == null ) || ( rxMasterSalt == null ) ) return SESSION_ERROR_MASTER_SALT_UDNEFINED ; if ( ( txMasterKey == null ) || ( rxMasterKey == null ) ) return SESSION_ERROR_MASTER_SALT_UDNEFINED ; if ( ! txSessionKeyDerivation ( ) ) { log ( "startNewSession txSessionKeyDerivation failed" ) ; return SESSION_ERROR_KEY_DERIVATION_FAILED ; } // Create encryptor components for tx session try { // and the HMAC components txEncryptorSuite = platform . getCrypto ( ) . createEncryptorSuite ( txSessEncKey , initVector ) ; txHMAC = platform . getCrypto ( ) . createHMACSHA1 ( txSessAuthKey ) ; } catch ( Throwable e ) { log ( "startNewSession failed to create Tx encryptor" ) ; return SESSION_ERROR_RESOURCE_CREATION_PROBLEM ; } replayWindow = platform . getUtils ( ) . createSortedVector ( ) ; receivedFirst = false ; rollOverCounter = 0 ; rxRoc = 0 ; txIV = new byte [ 16 ] ; // Always uses a 128 bit IV rxIV = new byte [ 16 ] ; txEncOut = new byte [ 16 ] ; rxEncOut = new byte [ 16 ] ; return SESSION_OK ; } | Starts a new SRTP Session using the preset master key and salt to generate the session keys | 352 | 19 |
138,001 | public static boolean linesIntersect ( double x1 , double y1 , double x2 , double y2 , double x3 , double y3 , double x4 , double y4 ) { // A = (x2-x1, y2-y1) // B = (x3-x1, y3-y1) // C = (x4-x1, y4-y1) // D = (x4-x3, y4-y3) = C-B // E = (x1-x3, y1-y3) = -B // F = (x2-x3, y2-y3) = A-B // // Result is ((AxB) * (AxC) <= 0) and ((DxE) * (DxF) <= 0) // // DxE = (C-B)x(-B) = BxB-CxB = BxC // DxF = (C-B)x(A-B) = CxA-CxB-BxA+BxB = AxB+BxC-AxC x2 -= x1 ; // A y2 -= y1 ; x3 -= x1 ; // B y3 -= y1 ; x4 -= x1 ; // C y4 -= y1 ; double AvB = x2 * y3 - x3 * y2 ; double AvC = x2 * y4 - x4 * y2 ; // online if ( AvB == 0 && AvC == 0 ) { if ( x2 != 0 ) { return ( x4 * x3 <= 0 ) || ( ( x3 * x2 >= 0 ) && ( x2 > 0 ? x3 <= x2 || x4 <= x2 : x3 >= x2 || x4 >= x2 ) ) ; } if ( y2 != 0 ) { return ( y4 * y3 <= 0 ) || ( ( y3 * y2 >= 0 ) && ( y2 > 0 ? y3 <= y2 || y4 <= y2 : y3 >= y2 || y4 >= y2 ) ) ; } return false ; } double BvC = x3 * y4 - x4 * y3 ; return ( AvB * AvC <= 0 ) && ( BvC * ( AvB + BvC - AvC ) <= 0 ) ; } | Returns true if the specified two line segments intersect . | 515 | 10 |
138,002 | public static boolean lineIntersectsRect ( double x1 , double y1 , double x2 , double y2 , double rx , double ry , double rw , double rh ) { double rr = rx + rw , rb = ry + rh ; return ( rx <= x1 && x1 <= rr && ry <= y1 && y1 <= rb ) || ( rx <= x2 && x2 <= rr && ry <= y2 && y2 <= rb ) || linesIntersect ( rx , ry , rr , rb , x1 , y1 , x2 , y2 ) || linesIntersect ( rr , ry , rx , rb , x1 , y1 , x2 , y2 ) ; } | Returns true if the specified line segment intersects the specified rectangle . | 171 | 13 |
138,003 | public Quaternion set ( IQuaternion other ) { return set ( other . x ( ) , other . y ( ) , other . z ( ) , other . w ( ) ) ; } | Copies the elements of another quaternion . | 42 | 10 |
138,004 | public Quaternion fromVectors ( IVector3 from , IVector3 to ) { float angle = from . angle ( to ) ; if ( angle < MathUtil . EPSILON ) { return set ( IDENTITY ) ; } if ( angle <= FloatMath . PI - MathUtil . EPSILON ) { return fromAngleAxis ( angle , from . cross ( to ) . normalizeLocal ( ) ) ; } // it's a 180 degree rotation; any axis orthogonal to the from vector will do Vector3 axis = new Vector3 ( 0f , from . z ( ) , - from . y ( ) ) ; float length = axis . length ( ) ; return fromAngleAxis ( FloatMath . PI , length < MathUtil . EPSILON ? axis . set ( - from . z ( ) , 0f , from . x ( ) ) . normalizeLocal ( ) : axis . multLocal ( 1f / length ) ) ; } | Sets this quaternion to the rotation of the first normalized vector onto the second . | 209 | 18 |
138,005 | public Quaternion fromAnglesXZ ( float x , float z ) { float hx = x * 0.5f , hz = z * 0.5f ; float sx = FloatMath . sin ( hx ) , cx = FloatMath . cos ( hx ) ; float sz = FloatMath . sin ( hz ) , cz = FloatMath . cos ( hz ) ; return set ( cz * sx , sz * sx , sz * cx , cz * cx ) ; } | Sets this quaternion to one that first rotates about x by the specified number of radians then rotates about z by the specified number of radians . | 111 | 34 |
138,006 | public Quaternion fromAnglesXY ( float x , float y ) { float hx = x * 0.5f , hy = y * 0.5f ; float sx = FloatMath . sin ( hx ) , cx = FloatMath . cos ( hx ) ; float sy = FloatMath . sin ( hy ) , cy = FloatMath . cos ( hy ) ; return set ( cy * sx , sy * cx , - sy * sx , cy * cx ) ; } | Sets this quaternion to one that first rotates about x by the specified number of radians then rotates about y by the specified number of radians . | 105 | 34 |
138,007 | public static float normalizeAnglePositive ( float a ) { while ( a < 0f ) { a += TWO_PI ; } while ( a >= TWO_PI ) { a -= TWO_PI ; } return a ; } | Returns an angle in the range [ 0 2pi ) . | 49 | 12 |
138,008 | public ProbeWrapper unmarshal ( String payload ) throws ProbeParseException { Probe xmlProbe = parseProbePayload ( payload ) ; ProbeWrapper probe = new ProbeWrapper ( xmlProbe . getId ( ) ) ; probe . setClientId ( xmlProbe . getClient ( ) ) ; probe . setDESVersion ( xmlProbe . getDESVersion ( ) ) ; probe . setRespondToPayloadType ( xmlProbe . getRespondToPayloadType ( ) ) ; if ( xmlProbe . getRa ( ) != null ) { for ( RespondTo respondToUrl : xmlProbe . getRa ( ) . getRespondTo ( ) ) { probe . addRespondToURL ( respondToUrl . getLabel ( ) , respondToUrl . getValue ( ) ) ; } } if ( xmlProbe . getScids ( ) != null ) { for ( String scid : xmlProbe . getScids ( ) . getServiceContractID ( ) ) { probe . addServiceContractID ( scid ) ; } } if ( xmlProbe . getSiids ( ) != null ) { for ( String siid : xmlProbe . getSiids ( ) . getServiceInstanceID ( ) ) { probe . addServiceInstanceID ( siid ) ; } } return probe ; } | Create a new ProbeWrapper from the wireline payload . | 285 | 12 |
138,009 | @ Benchmark public void fizzbuzzConditional ( ) { IntStream . range ( 0 , 101 ) . forEach ( n -> { if ( n % ( 3 * 5 ) == 0 ) { System . out . println ( "FizzBuzz" ) ; } else if ( n % 3 == 0 ) { System . out . println ( "Fizz" ) ; } else if ( n % 5 == 0 ) { System . out . println ( "Buzz" ) ; } else { System . out . println ( n ) ; } } ) ; } | Fizzbuzz benchmark using a conditional . | 118 | 9 |
138,010 | @ Benchmark public void fizzBuzzPatternMatching ( ) { IntStream . range ( 0 , 101 ) . forEach ( n -> System . out . println ( match ( Tuple2 . of ( n % 3 , n % 5 ) ) . when ( tuple2 ( eq ( 0 ) , eq ( 0 ) ) ) . get ( ( ) -> "FizzBuzz" ) . when ( tuple2 ( eq ( 0 ) , any ( ) ) ) . get ( y -> "Fizz" ) . when ( tuple2 ( any ( ) , eq ( 0 ) ) ) . get ( x -> "Buzz" ) . orElse ( String . valueOf ( n ) ) . getMatch ( ) ) ) ; } | Fizzbuzz benchmark using motif pattern matching . | 153 | 10 |
138,011 | public Quaternion set ( double x , double y , double z , double w ) { this . x = x ; this . y = y ; this . z = z ; this . w = w ; return this ; } | Sets all of the elements of the quaternion . | 47 | 12 |
138,012 | public Quaternion fromAxes ( IVector3 nx , IVector3 ny , IVector3 nz ) { double nxx = nx . x ( ) , nyy = ny . y ( ) , nzz = nz . z ( ) ; double x2 = ( 1f + nxx - nyy - nzz ) / 4f ; double y2 = ( 1f - nxx + nyy - nzz ) / 4f ; double z2 = ( 1f - nxx - nyy + nzz ) / 4f ; double w2 = ( 1f - x2 - y2 - z2 ) ; return set ( Math . sqrt ( x2 ) * ( ny . z ( ) >= nz . y ( ) ? + 1f : - 1f ) , Math . sqrt ( y2 ) * ( nz . x ( ) >= nx . z ( ) ? + 1f : - 1f ) , Math . sqrt ( z2 ) * ( nx . y ( ) >= ny . x ( ) ? + 1f : - 1f ) , Math . sqrt ( w2 ) ) ; } | Sets this quaternion to one that rotates onto the given unit axes . | 252 | 17 |
138,013 | public static Point closestInteriorPoint ( IRectangle r , IPoint p ) { return closestInteriorPoint ( r , p , new Point ( ) ) ; } | Computes and returns the point inside the bounds of the rectangle that s closest to the given point . | 35 | 20 |
138,014 | public boolean isRectangular ( ) { return ( _isPolygonal ) && ( _rulesSize <= 5 ) && ( _coordsSize <= 8 ) && ( _coords [ 1 ] == _coords [ 3 ] ) && ( _coords [ 7 ] == _coords [ 5 ] ) && ( _coords [ 0 ] == _coords [ 6 ] ) && ( _coords [ 2 ] == _coords [ 4 ] ) ; } | Returns true if this area is rectangular . | 99 | 8 |
138,015 | public void add ( Area area ) { if ( area == null || area . isEmpty ( ) ) { return ; } else if ( isEmpty ( ) ) { copy ( area , this ) ; return ; } if ( isPolygonal ( ) && area . isPolygonal ( ) ) { addPolygon ( area ) ; } else { addCurvePolygon ( area ) ; } if ( areaBoundsSquare ( ) < GeometryUtil . EPSILON ) { reset ( ) ; } } | Adds the supplied area to this area . | 108 | 8 |
138,016 | public void intersect ( Area area ) { if ( area == null ) { return ; } else if ( isEmpty ( ) || area . isEmpty ( ) ) { reset ( ) ; return ; } if ( isPolygonal ( ) && area . isPolygonal ( ) ) { intersectPolygon ( area ) ; } else { intersectCurvePolygon ( area ) ; } if ( areaBoundsSquare ( ) < GeometryUtil . EPSILON ) { reset ( ) ; } } | Intersects the supplied area with this area . | 105 | 10 |
138,017 | public void subtract ( Area area ) { if ( area == null || isEmpty ( ) || area . isEmpty ( ) ) { return ; } if ( isPolygonal ( ) && area . isPolygonal ( ) ) { subtractPolygon ( area ) ; } else { subtractCurvePolygon ( area ) ; } if ( areaBoundsSquare ( ) < GeometryUtil . EPSILON ) { reset ( ) ; } } | Subtracts the supplied area from this area . | 94 | 11 |
138,018 | public void exclusiveOr ( Area area ) { Area a = clone ( ) ; a . intersect ( area ) ; add ( area ) ; subtract ( a ) ; } | Computes the exclusive or of this area and the supplied area and sets this area to the result . | 34 | 20 |
138,019 | private static double [ ] adjustSize ( double [ ] array , int newSize ) { if ( newSize <= array . length ) { return array ; } double [ ] newArray = new double [ 2 * newSize ] ; System . arraycopy ( array , 0 , newArray , 0 , array . length ) ; return newArray ; } | the method check up the array size and necessarily increases it . | 71 | 12 |
138,020 | @ GET @ Path ( "/ipAddrInfo" ) public String getIPAddrInfo ( ) throws UnknownHostException { Properties clientProps = getPropeSenderProps ( ) ; StringBuffer buf = new StringBuffer ( ) ; InetAddress localhost = null ; NetworkInterface ni = null ; try { localhost = InetAddress . getLocalHost ( ) ; LOGGER . debug ( "Network Interface name not specified. Using the NI for localhost " + localhost . getHostAddress ( ) ) ; ni = NetworkInterface . getByInetAddress ( localhost ) ; } catch ( UnknownHostException | SocketException e ) { LOGGER . error ( "Error occured dealing with network interface name lookup " , e ) ; } buf . append ( "<p>" ) . append ( "<span style='color: red'> IP Address: </span>" ) . append ( localhost . getHostAddress ( ) ) ; buf . append ( "<span style='color: red'> Host name: </span>" ) . append ( localhost . getCanonicalHostName ( ) ) ; if ( ni == null ) { buf . append ( "<span style='color: red'> Network Interface is NULL </span>" ) ; } else { buf . append ( "<span style='color: red'> Network Interface name: </span>" ) . append ( ni . getDisplayName ( ) ) ; } buf . append ( "</p><p>" ) ; buf . append ( "Sending probes to " + respondToAddresses . size ( ) + " addresses - " ) ; for ( ProbeRespondToAddress rta : respondToAddresses ) { buf . append ( "<span style='color: red'> Probe to: </span>" ) . append ( rta . respondToAddress + ":" + rta . respondToPort ) ; } buf . append ( "</p>" ) ; return buf . toString ( ) ; } | Return the ip info of where the web host lives that supports the browser app . | 410 | 16 |
138,021 | @ GET @ Path ( "/launchProbe" ) @ Produces ( "application/txt" ) public String launchProbe ( ) throws IOException , UnsupportedPayloadType , ProbeSenderException , TransportException { Properties clientProps = getPropeSenderProps ( ) ; String multicastGroupAddr = clientProps . getProperty ( "multicastGroupAddr" , DEFAULT_MULTICAST_GROUP_ADDR ) ; String multicastPortString = clientProps . getProperty ( "multicastPort" , DEFAULT_MULTICAST_PORT . toString ( ) ) ; // String listenerIPAddress = clientProps.getProperty("listenerIPAddress"); // String listenerPort = clientProps.getProperty("listenerPort"); String listenerURLPath = clientProps . getProperty ( "listenerProbeResponseURLPath" , DEFAULT_PROBE_RESPONSE_URL_PATH ) ; Integer multicastPort = Integer . parseInt ( multicastPortString ) ; ProbeSender gen ; try { gen = ProbeSenderFactory . createMulticastProbeSender ( multicastGroupAddr , multicastPort ) ; // loop over the "respond to addresses" specified in the properties file. // TODO: Clean out the commented out code. // for (ProbeRespondToAddress rta : respondToAddresses) { // // Probe probe = new Probe(Probe.JSON); // probe.addRespondToURL("http://"+rta.respondToAddress+":"+rta.respondToPort+listenerURLPath); // // The following is a "naked" probe - no service contract IDs, etc. // // No specified service contract IDs implies "all" // // This will evoke responses from all reachable responders except those // configured to "noBrowser" // gen.sendProbe(probe); // } Probe probe = new Probe ( Probe . JSON ) ; for ( ProbeRespondToAddress rta : respondToAddresses ) { probe . addRespondToURL ( "browser" , "http://" + rta . respondToAddress + ":" + rta . respondToPort + listenerURLPath ) ; } // The following is a "naked" probe - no service contract IDs, etc. // No specified service contract IDs implies "all" // This will evoke responses from all reachable responders except those // configured to "noBrowser" gen . sendProbe ( probe ) ; gen . close ( ) ; return "Launched " + respondToAddresses . size ( ) + " probe(s) successfully on " + multicastGroupAddr + ":" + multicastPort ; } catch ( TransportConfigException e ) { return "Launched Failed: " + e . getLocalizedMessage ( ) ; } } | Actually launch a probe . | 604 | 5 |
138,022 | @ GET @ Path ( "/responses" ) @ Produces ( "application/json" ) public String getResponses ( ) throws UnknownHostException { Properties clientProps = getPropeSenderProps ( ) ; String listenerIPAddress = clientProps . getProperty ( "listenerIPAddress" ) ; String listenerPort = clientProps . getProperty ( "listenerPort" ) ; String listenerReponsesURLPath = clientProps . getProperty ( "listenerReponsesURLPath" , DEFAULT_RESPONSES_URL_PATH ) ; String response = restGetCall ( "http://" + listenerIPAddress + ":" + listenerPort + listenerReponsesURLPath ) ; return response ; } | Returns a list of the responses collected in the listener . | 158 | 11 |
138,023 | @ GET @ Path ( "/clearCache" ) @ Produces ( "application/json" ) public String clearCache ( ) throws UnknownHostException { Properties clientProps = getPropeSenderProps ( ) ; String listenerIPAddress = clientProps . getProperty ( "listenerIPAddress" ) ; String listenerPort = clientProps . getProperty ( "listenerPort" ) ; String listenerClearCacheURLPath = clientProps . getProperty ( "listenerClearCacheURLPath" , DEFAULT_CLEAR_CACHE_URL_PATH ) ; String response = restGetCall ( "http://" + listenerIPAddress + ":" + listenerPort + listenerClearCacheURLPath ) ; return response ; } | Clears the active response cache . | 155 | 7 |
138,024 | public double distance ( Vector3 point ) { double distance = - Float . MAX_VALUE ; for ( Plane plane : _planes ) { distance = Math . max ( distance , plane . distance ( point ) ) ; } return distance ; } | Determines the maximum signed distance of the point from the planes of the frustum . If the distance is less than or equal to zero the point lies inside the frustum . | 49 | 36 |
138,025 | public static Class < ? extends Command < ? extends CLIContext > > getCommandClass ( CLIContext context , String commandName ) { return context . getHostApplication ( ) . getCommands ( ) . get ( commandName . toLowerCase ( ) ) ; } | Get a command by name . | 59 | 6 |
138,026 | public static < T > DecomposableMatchBuilder0 < List < T > > nil ( ) { List < Matcher < Object >> matchers = Lists . of ( ) ; return new DecomposableMatchBuilder0 < List < T > > ( matchers , new ListConsNilFieldExtractor <> ( ) ) ; } | Matches an empty list . | 72 | 6 |
138,027 | public static void print ( ConsoleLevel level , String message ) { if ( level . compareTo ( _level ) <= 0 ) { if ( _printLogLevel ) { level . getStream ( ) . println ( level . name ( ) + ": " + message ) ; } else { level . getStream ( ) . println ( message ) ; } level . getStream ( ) . flush ( ) ; } } | Print the given message at the given level . | 86 | 9 |
138,028 | public R getMatch ( ) { for ( Pattern < T , R > pattern : patterns ) { if ( pattern . matches ( value ) ) { return pattern . apply ( value ) ; } } throw new MatchException ( "No match found for " + value ) ; } | Runs through the possible matches and executes the specified action of the first match and returns the result . | 56 | 20 |
138,029 | public void seedUsingPcmAudio ( byte [ ] data ) { byte [ ] key = new byte [ 64 ] ; for ( int i = 0 ; i < key . length ; i ++ ) { int x = 0 ; //Pick 4 random bytes from the PCM audio data, from each of the bytes //take the two least significant bits and concatenate them to form //the i-th byte in the seed key for ( int j = 0 ; j < 4 ; j ++ ) { x = ( x << 2 ) | ( 3 & data [ RandomSource . getInt ( data . length ) ] ) ; } key [ i ] = ( byte ) x ; } seed ( key ) ; initialized = true ; } | Seed the random generator with 2 least significant bits of randomly picked bytes within the provided PCM audio data | 151 | 21 |
138,030 | public int getInt ( ) { try { byte [ ] rand = fipsGenerator . getBytes ( 4 ) ; int result = rand [ 0 ] ; for ( int i = 1 ; i < 4 ; i ++ ) { result = ( result << 8 ) | rand [ i ] ; } return result ; } catch ( Throwable ex ) { BBPlatform . getPlatform ( ) . getLogger ( ) . logException ( "RandomGenerator.getInt() Falling back to RandomSource " + ex . getMessage ( ) ) ; return RandomSource . getInt ( ) ; } } | Returns a random integer | 124 | 4 |
138,031 | public void getBytes ( byte [ ] buffer ) { try { fipsGenerator . getBytes ( buffer ) ; } catch ( Throwable ex ) { BBPlatform . getPlatform ( ) . getLogger ( ) . logException ( "RandomGenerator.getBytes() Falling back to RandomSource... " + ex . getMessage ( ) ) ; RandomSource . getBytes ( buffer ) ; } } | Generates random bytes filling the given buffer entirely | 84 | 9 |
138,032 | protected void checkBuf ( int pointCount , boolean checkMove ) { if ( checkMove && typeSize == 0 ) { throw new IllegalPathStateException ( "First segment must be a SEG_MOVETO" ) ; } if ( typeSize == types . length ) { byte [ ] tmp = new byte [ typeSize + BUFFER_CAPACITY ] ; System . arraycopy ( types , 0 , tmp , 0 , typeSize ) ; types = tmp ; } if ( pointSize + pointCount > points . length ) { float [ ] tmp = new float [ pointSize + Math . max ( BUFFER_CAPACITY * 2 , pointCount ) ] ; System . arraycopy ( points , 0 , tmp , 0 , pointSize ) ; points = tmp ; } } | Checks points and types buffer size to add pointCount points . If necessary realloc buffers to enlarge size . | 166 | 22 |
138,033 | protected boolean isInside ( int cross ) { return ( rule == WIND_NON_ZERO ) ? Crossing . isInsideNonZero ( cross ) : Crossing . isInsideEvenOdd ( cross ) ; } | Checks cross count according to path rule to define is it point inside shape or not . | 45 | 18 |
138,034 | public static void subQuad ( double [ ] coef , double t0 , boolean left ) { if ( left ) { coef [ 2 ] = ( 1 - t0 ) * coef [ 0 ] + t0 * coef [ 2 ] ; coef [ 3 ] = ( 1 - t0 ) * coef [ 1 ] + t0 * coef [ 3 ] ; } else { coef [ 2 ] = ( 1 - t0 ) * coef [ 2 ] + t0 * coef [ 4 ] ; coef [ 3 ] = ( 1 - t0 ) * coef [ 3 ] + t0 * coef [ 5 ] ; } } | t0 - ? | 143 | 4 |
138,035 | private boolean sendResponse ( String respondToURL , String payloadType , ResponseWrapper payload ) { // This method will likely need some thought and care in the error handling // and error reporting // It's a had job at the moment. String responseStr = null ; String contentType = null ; // MIME type boolean success = true ; switch ( payloadType ) { case "XML" : { responseStr = payload . toXML ( ) ; contentType = "application/xml" ; break ; } case "JSON" : { responseStr = payload . toJSON ( ) ; contentType = "application/json" ; break ; } default : responseStr = payload . toJSON ( ) ; } try { HttpPost postRequest = new HttpPost ( respondToURL ) ; StringEntity input = new StringEntity ( responseStr ) ; input . setContentType ( contentType ) ; postRequest . setEntity ( input ) ; LOGGER . debug ( "Sending response" ) ; LOGGER . debug ( "Response payload:" ) ; LOGGER . debug ( responseStr ) ; CloseableHttpResponse httpResponse = httpClient . execute ( postRequest ) ; try { int statusCode = httpResponse . getStatusLine ( ) . getStatusCode ( ) ; if ( statusCode > 300 ) { throw new RuntimeException ( "Failed : HTTP error code : " + httpResponse . getStatusLine ( ) . getStatusCode ( ) ) ; } if ( statusCode != 204 ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( ( httpResponse . getEntity ( ) . getContent ( ) ) ) ) ; LOGGER . debug ( "Successful response from response target - " + respondToURL ) ; String output ; LOGGER . debug ( "Output from Listener .... \n" ) ; while ( ( output = br . readLine ( ) ) != null ) { LOGGER . debug ( output ) ; } br . close ( ) ; } } finally { httpResponse . close ( ) ; } LOGGER . info ( "Successfully handled probeID: " + probe . getProbeId ( ) + " sending response to: " + respondToURL ) ; } catch ( MalformedURLException e ) { success = false ; LOGGER . error ( "MalformedURLException occured for probeID [" + payload . getProbeID ( ) + "]" + "\nThe respondTo URL was a no good. respondTo URL is: " + respondToURL ) ; } catch ( IOException e ) { success = false ; LOGGER . error ( "An IOException occured for probeID [" + payload . getProbeID ( ) + "]" + " - " + e . getLocalizedMessage ( ) ) ; LOGGER . debug ( "Stack trace for IOException for probeID [" + payload . getProbeID ( ) + "]" , e ) ; } catch ( Exception e ) { success = false ; LOGGER . error ( "Some other error occured for probeID [" + payload . getProbeID ( ) + "]" + ". respondTo URL is: " + respondToURL + " - " + e . getLocalizedMessage ( ) ) ; LOGGER . debug ( "Stack trace for probeID [" + payload . getProbeID ( ) + "]" , e ) ; } return success ; } | If the probe yields responses from the handler then send this method will send the responses to the given respondTo addresses . | 714 | 23 |
138,036 | public void run ( ) { ResponseWrapper response = null ; LOGGER . info ( "Received probe id: " + probe . getProbeId ( ) ) ; // Only handle probes that we haven't handled before // The Probe Generator needs to send a stream of identical UDP packets // to compensate for UDP reliability issues. Therefore, the Responder // will likely get more than 1 identical probe. We should ignore // duplicates. if ( ! isProbeHandled ( probe . getProbeId ( ) ) ) { if ( this . noBrowser && probe . isNaked ( ) ) { LOGGER . warn ( "Responder set to noBrowser mode. Discarding naked probe with id [" + probe . getProbeId ( ) + "]" ) ; } else { for ( ProbeHandlerPlugin handler : handlers ) { response = handler . handleProbeEvent ( probe ) ; if ( ! response . isEmpty ( ) ) { LOGGER . debug ( "Response to probe [" + probe . getProbeId ( ) + "] includes " + response . numberOfServices ( ) ) ; Iterator < RespondToURL > respondToURLs = probe . getRespondToURLs ( ) . iterator ( ) ; if ( probe . getRespondToURLs ( ) . isEmpty ( ) ) LOGGER . warn ( "Processed probe [" + probe . getProbeId ( ) + "] with no respondTo address. That's odd." ) ; if ( respondToURLs . hasNext ( ) ) { RespondToURL respondToURL = respondToURLs . next ( ) ; // we are ignoring the label for now boolean success = sendResponse ( respondToURL . url , probe . getRespondToPayloadType ( ) , response ) ; if ( ! success ) { LOGGER . warn ( "Issue sending probe [" + probe . getProbeId ( ) + "] response to [" + respondToURL . url + "]" ) ; } } } else { LOGGER . error ( "Response to probe [" + probe . getProbeId ( ) + "] is empty. Not sending empty response." ) ; } } } markProbeAsHandled ( probe . getProbeId ( ) ) ; responder . probeProcessed ( ) ; } else { LOGGER . info ( "Discarding duplicate/handled probe with id: " + probe . getProbeId ( ) ) ; } } | Handle the probe . | 513 | 4 |
138,037 | protected static int fixRoots ( float [ ] res , int rc ) { int tc = 0 ; for ( int i = 0 ; i < rc ; i ++ ) { out : { for ( int j = i + 1 ; j < rc ; j ++ ) { if ( isZero ( res [ i ] - res [ j ] ) ) { break out ; } } res [ tc ++ ] = res [ i ] ; } } return tc ; } | Excludes double roots . Roots are double if they lies enough close with each other . | 95 | 17 |
138,038 | public static int intersectQuad ( float x1 , float y1 , float cx , float cy , float x2 , float y2 , float rx1 , float ry1 , float rx2 , float ry2 ) { // LEFT/RIGHT/UP ------------------------------------------------------ if ( ( rx2 < x1 && rx2 < cx && rx2 < x2 ) || ( rx1 > x1 && rx1 > cx && rx1 > x2 ) || ( ry1 > y1 && ry1 > cy && ry1 > y2 ) ) { return 0 ; } // DOWN --------------------------------------------------------------- if ( ry2 < y1 && ry2 < cy && ry2 < y2 && rx1 != x1 && rx1 != x2 ) { if ( x1 < x2 ) { return x1 < rx1 && rx1 < x2 ? 1 : 0 ; } return x2 < rx1 && rx1 < x1 ? - 1 : 0 ; } // INSIDE ------------------------------------------------------------- QuadCurve c = new QuadCurve ( x1 , y1 , cx , cy , x2 , y2 ) ; float px1 = rx1 - x1 ; float py1 = ry1 - y1 ; float px2 = rx2 - x1 ; float py2 = ry2 - y1 ; float [ ] res1 = new float [ 3 ] ; float [ ] res2 = new float [ 3 ] ; int rc1 = c . solvePoint ( res1 , px1 ) ; int rc2 = c . solvePoint ( res2 , px2 ) ; // INSIDE-LEFT/RIGHT if ( rc1 == 0 && rc2 == 0 ) { return 0 ; } // Build bound -------------------------------------------------------- float minX = px1 - DELTA ; float maxX = px2 + DELTA ; float [ ] bound = new float [ 28 ] ; int bc = 0 ; // Add roots bc = c . addBound ( bound , bc , res1 , rc1 , minX , maxX , false , 0 ) ; bc = c . addBound ( bound , bc , res2 , rc2 , minX , maxX , false , 1 ) ; // Add extremal points rc2 = c . solveExtreme ( res2 ) ; bc = c . addBound ( bound , bc , res2 , rc2 , minX , maxX , true , 2 ) ; // Add start and end if ( rx1 < x1 && x1 < rx2 ) { bound [ bc ++ ] = 0f ; bound [ bc ++ ] = 0f ; bound [ bc ++ ] = 0f ; bound [ bc ++ ] = 4 ; } if ( rx1 < x2 && x2 < rx2 ) { bound [ bc ++ ] = 1f ; bound [ bc ++ ] = c . ax ; bound [ bc ++ ] = c . ay ; bound [ bc ++ ] = 5 ; } // End build bound ---------------------------------------------------- int cross = crossBound ( bound , bc , py1 , py2 ) ; if ( cross != UNKNOWN ) { return cross ; } return c . cross ( res1 , rc1 , py1 , py2 ) ; } | Returns how many times rectangle stripe cross quad curve or the are intersect | 703 | 13 |
138,039 | public static int intersectPath ( PathIterator p , float x , float y , float w , float h ) { int cross = 0 ; int count ; float mx , my , cx , cy ; mx = my = cx = cy = 0f ; float [ ] coords = new float [ 6 ] ; float rx1 = x ; float ry1 = y ; float rx2 = x + w ; float ry2 = y + h ; while ( ! p . isDone ( ) ) { count = 0 ; switch ( p . currentSegment ( coords ) ) { case PathIterator . SEG_MOVETO : if ( cx != mx || cy != my ) { count = intersectLine ( cx , cy , mx , my , rx1 , ry1 , rx2 , ry2 ) ; } mx = cx = coords [ 0 ] ; my = cy = coords [ 1 ] ; break ; case PathIterator . SEG_LINETO : count = intersectLine ( cx , cy , cx = coords [ 0 ] , cy = coords [ 1 ] , rx1 , ry1 , rx2 , ry2 ) ; break ; case PathIterator . SEG_QUADTO : count = intersectQuad ( cx , cy , coords [ 0 ] , coords [ 1 ] , cx = coords [ 2 ] , cy = coords [ 3 ] , rx1 , ry1 , rx2 , ry2 ) ; break ; case PathIterator . SEG_CUBICTO : count = intersectCubic ( cx , cy , coords [ 0 ] , coords [ 1 ] , coords [ 2 ] , coords [ 3 ] , cx = coords [ 4 ] , cy = coords [ 5 ] , rx1 , ry1 , rx2 , ry2 ) ; break ; case PathIterator . SEG_CLOSE : if ( cy != my || cx != mx ) { count = intersectLine ( cx , cy , mx , my , rx1 , ry1 , rx2 , ry2 ) ; } cx = mx ; cy = my ; break ; } if ( count == CROSSING ) { return CROSSING ; } cross += count ; p . next ( ) ; } if ( cy != my ) { count = intersectLine ( cx , cy , mx , my , rx1 , ry1 , rx2 , ry2 ) ; if ( count == CROSSING ) { return CROSSING ; } cross += count ; } return cross ; } | Returns how many times rectangle stripe cross path or the are intersect | 561 | 12 |
138,040 | public static int intersectShape ( IShape s , float x , float y , float w , float h ) { if ( ! s . bounds ( ) . intersects ( x , y , w , h ) ) { return 0 ; } return intersectPath ( s . pathIterator ( null ) , x , y , w , h ) ; } | Returns how many times rectangle stripe cross shape or the are intersect | 71 | 12 |
138,041 | public boolean isExpired ( ) { if ( _service . getTtl ( ) == 0 ) { return false ; } long t = this . cacheStartTime . getTime ( ) ; Date validTime = new Date ( t + ( _service . getTtl ( ) * ONE_MINUTE_IN_MILLIS ) ) ; Date now = new Date ( ) ; return ( now . getTime ( ) > validTime . getTime ( ) ) ; } | Determine if the service record is expired . The service record include a TTL that tells the client how many minutes the client can count on the information in the service record . If the cache times out then those service records that have expired should be expunged from the cache . | 99 | 56 |
138,042 | public Matrix4 setToTransform ( IVector3 translation , IQuaternion rotation ) { return setToRotation ( rotation ) . setTranslation ( translation ) ; } | Sets this to a matrix that first rotates then translates . | 35 | 13 |
138,043 | public Matrix4 setToTranslation ( IVector3 translation ) { return setToTranslation ( translation . x ( ) , translation . y ( ) , translation . z ( ) ) ; } | Sets this to a translation matrix . | 38 | 8 |
138,044 | public Matrix4 setToRotationScale ( IMatrix3 rotScale ) { return set ( rotScale . m00 ( ) , rotScale . m01 ( ) , rotScale . m02 ( ) , 0f , rotScale . m10 ( ) , rotScale . m11 ( ) , rotScale . m12 ( ) , 0f , rotScale . m20 ( ) , rotScale . m21 ( ) , rotScale . m22 ( ) , 0f , 0 , 0 , 0 , 1 ) ; } | Sets this to a rotation plus scale matrix . | 111 | 10 |
138,045 | public Matrix4 setToPerspective ( double fovy , double aspect , double near , double far ) { double f = 1f / Math . tan ( fovy / 2f ) , dscale = 1f / ( near - far ) ; return set ( f / aspect , 0f , 0f , 0f , 0f , f , 0f , 0f , 0f , 0f , ( far + near ) * dscale , 2f * far * near * dscale , 0f , 0f , - 1f , 0f ) ; } | Sets this to a perspective projection matrix . The formula comes from the OpenGL documentation for the gluPerspective function . | 119 | 25 |
138,046 | public Matrix4 setToFrustum ( double left , double right , double bottom , double top , double near , double far ) { return setToFrustum ( left , right , bottom , top , near , far , Vector3 . UNIT_Z ) ; } | Sets this to a perspective projection matrix . The formula comes from the OpenGL documentation for the glFrustum function . | 57 | 24 |
138,047 | public Matrix4 setToFrustum ( double left , double right , double bottom , double top , double near , double far , IVector3 nearFarNormal ) { double rrl = 1f / ( right - left ) ; double rtb = 1f / ( top - bottom ) ; double rnf = 1f / ( near - far ) ; double n2 = 2f * near ; double s = ( far + near ) / ( near * nearFarNormal . z ( ) - far * nearFarNormal . z ( ) ) ; return set ( n2 * rrl , 0f , ( right + left ) * rrl , 0f , 0f , n2 * rtb , ( top + bottom ) * rtb , 0f , s * nearFarNormal . x ( ) , s * nearFarNormal . y ( ) , ( far + near ) * rnf , n2 * far * rnf , 0f , 0f , - 1f , 0f ) ; } | Sets this to a perspective projection matrix . | 217 | 9 |
138,048 | public Matrix4 setToOrtho ( double left , double right , double bottom , double top , double near , double far , IVector3 nearFarNormal ) { double rlr = 1f / ( left - right ) ; double rbt = 1f / ( bottom - top ) ; double rnf = 1f / ( near - far ) ; double s = 2f / ( near * nearFarNormal . z ( ) - far * nearFarNormal . z ( ) ) ; return set ( - 2f * rlr , 0f , 0f , ( right + left ) * rlr , 0f , - 2f * rbt , 0f , ( top + bottom ) * rbt , s * nearFarNormal . x ( ) , s * nearFarNormal . y ( ) , 2f * rnf , ( far + near ) * rnf , 0f , 0f , 0f , 1f ) ; } | Sets this to an orthographic projection matrix . | 201 | 10 |
138,049 | public static int distanceSq ( int x1 , int y1 , int x2 , int y2 ) { x2 -= x1 ; y2 -= y1 ; return x2 * x2 + y2 * y2 ; } | Returns the squared Euclidian distance between the specified two points . | 50 | 12 |
138,050 | public static int distance ( int x1 , int y1 , int x2 , int y2 ) { return ( int ) Math . sqrt ( distanceSq ( x1 , y1 , x2 , y2 ) ) ; } | Returns the Euclidian distance between the specified two points truncated to the nearest integer . | 50 | 17 |
138,051 | public static int manhattanDistance ( int x1 , int y1 , int x2 , int y2 ) { return Math . abs ( x2 - x1 ) + Math . abs ( y2 - y1 ) ; } | Returns the Manhattan distance between the specified two points . | 48 | 10 |
138,052 | public static double roundNearest ( double v , double target ) { target = Math . abs ( target ) ; if ( v >= 0 ) { return target * Math . floor ( ( v + 0.5f * target ) / target ) ; } else { return target * Math . ceil ( ( v - 0.5f * target ) / target ) ; } } | Rounds a value to the nearest multiple of a target . | 78 | 12 |
138,053 | public List < Probe > sendProbe ( Probe probe ) throws ProbeSenderException { List < Probe > actualProbesToSend ; try { actualProbesToSend = splitProbe ( probe ) ; } catch ( MalformedURLException | JAXBException | UnsupportedPayloadType e ) { throw new ProbeSenderException ( "Issue splitting the probe." , e ) ; } for ( Probe probeSegment : actualProbesToSend ) { // String payload try { probeTransport . sendProbe ( probeSegment ) ; } catch ( TransportException e ) { // TODO Auto-generated catch block e . printStackTrace ( ) ; } } return actualProbesToSend ; } | Send the probe . It will take the provided probe and then disassemble it into a number of smaller probes based on the max payload size of the transport provided . | 151 | 33 |
138,054 | private List < Probe > splitProbe ( Probe probe ) throws ProbeSenderException , JAXBException , MalformedURLException , UnsupportedPayloadType { List < Probe > actualProbeList = new ArrayList < Probe > ( ) ; int maxPayloadSize = this . probeTransport . maxPayloadSize ( ) ; LinkedList < ProbeIdEntry > combinedList = probe . getCombinedIdentifierList ( ) ; // use a strategy to split up the probe into biggest possible chunks // all respondTo address must be included - if that's a problem then throw // an exception - the user will need to do some thinking. // start by taking one siid or scid off put it into a temp probe, check the // payload size of the probe and repeat until target probe is right size. // put the target probe in the list, make the temp probe the target probe // and start the process again. // Not sure how to do this with wireline compression involved. if ( probe . asXML ( ) . length ( ) < maxPayloadSize ) { actualProbeList . add ( probe ) ; } else { Probe frame = Probe . frameProbeFrom ( probe ) ; Probe splitProbe = new Probe ( frame ) ; int payloadLength = splitProbe . asXML ( ) . length ( ) ; ProbeIdEntry nextId = combinedList . peek ( ) ; if ( payloadLength + nextId . getId ( ) . length ( ) + 40 >= maxPayloadSize ) { throw new ProbeSenderException ( "Basic frame violates maxPayloadSize of transport. Likely due to too many respondTo address." ) ; } while ( ! combinedList . isEmpty ( ) ) { payloadLength = splitProbe . asXML ( ) . length ( ) ; nextId = combinedList . peek ( ) ; if ( payloadLength + nextId . getId ( ) . length ( ) + 40 >= maxPayloadSize ) { actualProbeList . add ( splitProbe ) ; splitProbe = new Probe ( frame ) ; } ProbeIdEntry id = combinedList . pop ( ) ; switch ( id . getType ( ) ) { case "scid" : splitProbe . addServiceContractID ( id . getId ( ) ) ; break ; case "siid" : splitProbe . addServiceInstanceID ( id . getId ( ) ) ; break ; default : break ; } } actualProbeList . add ( splitProbe ) ; } return actualProbeList ; } | This method will take the given probe to send and then chop it up into smaller probes that will fit under the maximum packet size specified by the transport . This is important because Argo wants the UDP packets to not get chopped up by the network routers of at all possible . This makes the overall reliability of the protocol a little higher . | 536 | 66 |
138,055 | public String getDescription ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "ProbeSender for " ) ; buf . append ( probeTransport . toString ( ) ) ; return buf . toString ( ) ; } | Return the description of the ProbeSender . | 53 | 9 |
138,056 | public byte [ ] getMyZid ( ) { ZrtpCacheEntry ce = cache . get ( LOCAL_ZID_KEY ) ; if ( ce != null ) { return ce . getData ( ) ; } else { byte [ ] zid = new byte [ 12 ] ; platform . getCrypto ( ) . getRandomGenerator ( ) . getBytes ( zid ) ; cache . put ( LOCAL_ZID_KEY , zid , null ) ; platform . getLogger ( ) . log ( "[ZRTP] created new ZID=" , zid ) ; return zid ; } } | Retrieves this clients cached ZID . If there s no cached ZID i . e . on first run a random ZID is created and stored . | 132 | 32 |
138,057 | public void selectEntry ( byte [ ] remoteZID ) { platform . getLogger ( ) . log ( "ZRTPCache: selectEntry(" + platform . getUtils ( ) . byteToHexString ( remoteZID ) + ")" ) ; String zidString = new String ( remoteZID ) ; if ( currentZid != null && currentZid . equals ( zidString ) ) { return ; } currentZid = null ; currentRs1 = null ; currentRs2 = null ; currentTrust = false ; currentNumber = null ; ZrtpCacheEntry ce = cache . get ( zidString ) ; if ( ce == null ) { currentZid = zidString ; return ; } byte [ ] data = ce . getData ( ) ; if ( data . length == 40 || data . length == 72 ) { // backward compatibility: insert trust flag = false byte [ ] newData = new byte [ 1 + data . length ] ; newData [ 0 ] = 0 ; System . arraycopy ( data , 0 , newData , 1 , data . length ) ; data = newData ; } if ( data . length != 41 && data . length != 73 ) { platform . getLogger ( ) . logWarning ( "Invalid shared secret cache entry" ) ; currentZid = zidString ; return ; } long expiry = 0 ; for ( int i = 8 ; i != 0 ; ) { expiry = ( expiry << 8 ) + ( data [ -- i ] & 0xff L ) ; } long now = System . currentTimeMillis ( ) ; if ( expiry > now ) { currentTrust = ( data [ 8 ] != 0 ) ; currentRs1 = new byte [ 32 ] ; System . arraycopy ( data , 9 , currentRs1 , 0 , 32 ) ; if ( data . length == 73 ) { currentRs2 = new byte [ 32 ] ; System . arraycopy ( data , 41 , currentRs2 , 0 , 32 ) ; } } currentNumber = ce . getNumber ( ) ; currentZid = zidString ; // //// TEST if ( UPDATE_FOR_CACHE_MISMATCH_SIMULATION ) { if ( currentRs1 != null ) currentRs1 = platform . getCrypto ( ) . getRandomGenerator ( ) . getBytes ( currentRs1 . length ) ; if ( currentRs2 != null ) currentRs2 = platform . getCrypto ( ) . getRandomGenerator ( ) . getBytes ( currentRs2 . length ) ; if ( currentRs1 != null || currentRs2 != null ) { updateEntry ( expiry , currentTrust , currentRs1 , currentRs2 , currentNumber ) ; } UPDATE_FOR_CACHE_MISMATCH_SIMULATION = false ; } // //// TEST currentTrust &= ( platform . getAddressBook ( ) . isInAddressBook ( currentNumber ) ) ; } | Selects a cache entry base on remote ZID | 625 | 10 |
138,058 | public void updateEntry ( long expiryTime , boolean trust , byte [ ] retainedSecret , byte [ ] rs2 , String number ) { if ( platform . isVerboseLogging ( ) ) { platform . getLogger ( ) . log ( "ZRTPCache: updateEntry(" + expiryTime + ", " + trust + ", " + platform . getUtils ( ) . byteToHexString ( retainedSecret ) + ", " + platform . getUtils ( ) . byteToHexString ( rs2 ) + "," + number + ")" ) ; } if ( expiryTime == 0 ) { cache . remove ( currentZid ) ; currentTrust = false ; currentRs1 = null ; currentRs2 = null ; currentNumber = null ; } else { byte [ ] data = new byte [ ( rs2 == null ) ? 41 : 73 ] ; for ( int i = 0 ; i != 8 ; ++ i ) { data [ i ] = ( byte ) ( expiryTime & 0xff ) ; expiryTime >>>= 8 ; } data [ 8 ] = ( byte ) ( trust ? 1 : 0 ) ; System . arraycopy ( retainedSecret , 0 , data , 9 , 32 ) ; if ( rs2 != null ) { System . arraycopy ( rs2 , 0 , data , 41 , 32 ) ; } cache . put ( currentZid , data , number ) ; currentTrust = trust ; currentRs1 = retainedSecret ; currentRs2 = rs2 ; currentNumber = number ; } } | Updates the entry for the selected remote ZID . | 325 | 11 |
138,059 | public List < String > descriptionsForResponseIDs ( List < String > _ids , boolean payload , boolean pretty ) { List < String > descriptions = new ArrayList < String > ( ) ; for ( ServiceWrapper s : _cache ) { if ( _ids . isEmpty ( ) || _responseIds . contains ( s . getResponseId ( ) ) ) { StringBuffer buf = serviceDesciption ( payload , pretty , s ) ; descriptions . add ( buf . toString ( ) ) ; } } return descriptions ; } | Return the list of description strings for a list of response ids . | 111 | 14 |
138,060 | public List < String > descriptionsForProbeIDs ( List < String > _ids , boolean payload , boolean pretty ) { List < String > descriptions = new ArrayList < String > ( ) ; for ( ServiceWrapper s : _cache ) { if ( _ids . isEmpty ( ) || _probeIds . contains ( s . getProbeId ( ) ) ) { StringBuffer buf = serviceDesciption ( payload , pretty , s ) ; descriptions . add ( buf . toString ( ) ) ; } } return descriptions ; } | Return the list of description strings for a list of probe ids . | 114 | 14 |
138,061 | public String asJSON ( boolean pretty ) { JSONSerializer ser = new JSONSerializer ( ) ; Gson gson = new Gson ( ) ; Gson prettyJson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; JsonArray cacheArray = new JsonArray ( ) ; String cacheAsString ; for ( ServiceWrapper s : _cache ) { String json = ser . marshalService ( s ) ; JsonObject jsonService = gson . fromJson ( json , JsonObject . class ) ; cacheArray . add ( jsonService ) ; } if ( pretty ) { cacheAsString = prettyJson . toJson ( cacheArray ) ; } else { cacheAsString = gson . toJson ( cacheArray ) ; } return cacheAsString ; } | Return the cache as JSON . | 175 | 6 |
138,062 | @ Override public void sendProbe ( Probe probe ) throws TransportException { LOGGER . info ( "Sending probe [" + probe . getProbeID ( ) + "] on network inteface [" + networkInterface . getName ( ) + "] at port [" + multicastAddress + ":" + multicastPort + "]" ) ; LOGGER . debug ( "Probe requesting TTL of [" + probe . getHopLimit ( ) + "]" ) ; try { String msg = probe . asXML ( ) ; LOGGER . debug ( "Probe payload (always XML): \n" + msg ) ; byte [ ] msgBytes ; msgBytes = msg . getBytes ( StandardCharsets . UTF_8 ) ; // send discovery string InetAddress group = InetAddress . getByName ( multicastAddress ) ; DatagramPacket packet = new DatagramPacket ( msgBytes , msgBytes . length , group , multicastPort ) ; outboundSocket . setTimeToLive ( probe . getHopLimit ( ) ) ; outboundSocket . send ( packet ) ; LOGGER . debug ( "Probe sent on port [" + multicastAddress + ":" + multicastPort + "]" ) ; } catch ( IOException e ) { throw new TransportException ( "Unable to send probe. Issue sending UDP packets." , e ) ; } catch ( JAXBException e ) { throw new TransportException ( "Unable to send probe because it could not be serialized to XML" , e ) ; } } | Actually send the probe out on the wire . | 326 | 9 |
138,063 | public ResponseWrapper unmarshal ( String payload ) throws ResponseParseException { Services xmlServices = parseResponsePayload ( payload ) ; ResponseWrapper response = constructResponseWrapperFromResponse ( xmlServices ) ; return response ; } | Translate the wireline string into an instance of a ResponseWrapper object . | 49 | 16 |
138,064 | public ServiceWrapper unmarshalService ( String payload ) throws ResponseParseException { Service xmlService = parseServicePayload ( payload ) ; ServiceWrapper service = constructServiceWrapperFromService ( xmlService ) ; return service ; } | Translate the wireline string to an instance of a ServiceWrapper object . | 50 | 16 |
138,065 | public < T > T get ( String key , T defaultValue ) { if ( map . containsKey ( key ) ) { Object value = map . get ( key ) ; return ( T ) ( value instanceof byte [ ] ? unmarshall ( ( byte [ ] ) value ) : value ) ; } return defaultValue ; } | Returns the value of the mapping with the specified key or the given default value . | 69 | 16 |
138,066 | public void setRespondToPayloadType ( String respondToPayloadType ) throws UnsupportedPayloadType { // Sanity check on the payload type values. Should be XML or JSON // If the probe goes out with a bad value here, then the Responder may have // problems if ( respondToPayloadType == null || respondToPayloadType . isEmpty ( ) || ( ! respondToPayloadType . equals ( ProbeWrapper . JSON ) && ! respondToPayloadType . equals ( ProbeWrapper . XML ) ) ) throw new UnsupportedPayloadType ( "Attempting to set payload type to: " + respondToPayloadType + ". Cannot be null or empty and must be " + ProbeWrapper . JSON + " or " + ProbeWrapper . XML ) ; _probe . setRespondToPayloadType ( respondToPayloadType ) ; } | set the payload type for the response from the Responder . It only support XML and JSON . | 187 | 19 |
138,067 | public LinkedList < ProbeIdEntry > getCombinedIdentifierList ( ) { LinkedList < ProbeIdEntry > combinedList = new LinkedList < ProbeIdEntry > ( ) ; for ( String id : this . getProbeWrapper ( ) . getServiceContractIDs ( ) ) { combinedList . add ( new ProbeIdEntry ( "scid" , id ) ) ; } for ( String id : this . getProbeWrapper ( ) . getServiceInstanceIDs ( ) ) { combinedList . add ( new ProbeIdEntry ( "siid" , id ) ) ; } return combinedList ; } | Create and return a LinkedList of a combination of both scids and siids . This is a method that is used primarily in the creation of split packets . | 132 | 33 |
138,068 | public static boolean checkClientId ( boolean isLegacyAttributeList , String farEndClientID ) { if ( ZRTP . CLIENT_ID_LEGACY . equals ( farEndClientID ) ) return true ; if ( ZRTP . CLIENT_ID_RFC . equals ( farEndClientID ) ) return false ; boolean isPrintable = true ; for ( int i = 0 ; i < farEndClientID . length ( ) ; i ++ ) { int singleChar = farEndClientID . charAt ( i ) ; if ( singleChar < 32 || singleChar >= 127 ) { isPrintable = false ; } } return ! isPrintable && isLegacyAttributeList ; } | Legacy Client send ZRTP . CLIENT_ID_LEGACY or a non - printable ClientId | 147 | 23 |
138,069 | public static float pointRectDistanceSq ( IRectangle r , IPoint p ) { Point p2 = closestInteriorPoint ( r , p ) ; return Points . distanceSq ( p . x ( ) , p . y ( ) , p2 . x , p2 . y ) ; } | Returns the squared Euclidean distance between the given point and the nearest point inside the bounds of the given rectangle . If the supplied point is inside the rectangle the distance will be zero . | 64 | 37 |
138,070 | public void cacheAll ( ArrayList < ExpiringService > list ) { for ( ExpiringService service : list ) { cache . put ( service . getService ( ) . getId ( ) , service ) ; } } | Put a list of services in the cache . | 46 | 9 |
138,071 | public String asJSON ( ) { Gson gson = new Gson ( ) ; clearExpired ( ) ; Cache jsonCache = new Cache ( ) ; for ( ExpiringService svc : cache . values ( ) ) { jsonCache . cache . add ( svc . getService ( ) ) ; } String json = gson . toJson ( jsonCache ) ; return json ; } | Return the JSON string of the response cache . Leverage the Gson nature of the domain wireline classes | 83 | 21 |
138,072 | public void addRespondToURL ( String label , String url ) { RespondToURL respondToURL = new RespondToURL ( ) ; respondToURL . label = label ; respondToURL . url = url ; respondToURLs . add ( respondToURL ) ; } | Add a response URL to the probe . | 58 | 8 |
138,073 | public String asString ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( " PID: [ " ) . append ( this . id ) . append ( " ]" ) ; ; buf . append ( " CID: [ " ) . append ( this . clientId ) . append ( " ]" ) ; ; buf . append ( " DES: [ " ) . append ( this . desVersion ) . append ( " ]" ) ; ; buf . append ( " SCIDS: [ " ) ; for ( String scid : serviceContractIDs ) { buf . append ( scid ) . append ( " " ) ; } buf . append ( "]" ) ; buf . append ( " SIIDS: [ " ) ; for ( String siid : serviceInstanceIDs ) { buf . append ( siid ) . append ( " " ) ; } buf . append ( "]" ) ; buf . append ( " RESPOND_TO: [ " ) ; for ( RespondToURL rt : respondToURLs ) { buf . append ( rt . label ) . append ( ", " ) . append ( rt . url ) . append ( " " ) ; } buf . append ( "]" ) ; buf . append ( " PAYLOAD_TYPE: [ " ) . append ( respondToPayloadType ) . append ( " ]" ) ; return buf . toString ( ) ; } | This will return the single - line textual representation . This was crafted for the command line client . Your mileage may vary . | 296 | 24 |
138,074 | public void setFrame ( XY loc , IDimension size ) { setFrame ( loc . x ( ) , loc . y ( ) , size . width ( ) , size . height ( ) ) ; } | Sets the location and size of the framing rectangle of this shape to the supplied values . | 43 | 18 |
138,075 | public void setFrame ( IRectangle r ) { setFrame ( r . x ( ) , r . y ( ) , r . width ( ) , r . height ( ) ) ; } | Sets the location and size of the framing rectangle of this shape to be equal to the supplied rectangle . | 40 | 21 |
138,076 | public void setFrameFromDiagonal ( XY p1 , XY p2 ) { setFrameFromDiagonal ( p1 . x ( ) , p1 . y ( ) , p2 . x ( ) , p2 . y ( ) ) ; } | Sets the location and size of the framing rectangle of this shape based on the supplied diagonal line . | 53 | 20 |
138,077 | public void setFrameFromCenter ( XY center , XY corner ) { setFrameFromCenter ( center . x ( ) , center . y ( ) , corner . x ( ) , corner . y ( ) ) ; } | Sets the location and size of the framing rectangle of this shape based on the supplied center and corner points . | 45 | 22 |
138,078 | public static Point inverseTransform ( double x , double y , double sx , double sy , double rotation , double tx , double ty , Point result ) { x -= tx ; y -= ty ; // untranslate double sinnega = Math . sin ( - rotation ) , cosnega = Math . cos ( - rotation ) ; double nx = ( x * cosnega - y * sinnega ) ; // unrotate double ny = ( x * sinnega + y * cosnega ) ; return result . set ( nx / sx , ny / sy ) ; // unscale } | Inverse transforms a point as specified storing the result in the point provided . | 130 | 15 |
138,079 | public void setServiceList ( ArrayList < ServiceWrapper > services ) { writeLock . lock ( ) ; try { LOGGER . info ( "Updating service list by " + Thread . currentThread ( ) . getName ( ) ) ; this . serviceList = services ; } finally { writeLock . unlock ( ) ; } } | As the Responder is multi - threaded make sure that the access to the services list which might change out if the user changes it is synchronized to make sure nothing weird happens . | 70 | 35 |
138,080 | public void initializeWithPropertiesFilename ( String filename ) throws ProbeHandlerConfigException { InputStream is ; // try to load the properties file off the classpath first if ( ConfigFileProbeHandlerPlugin . class . getResource ( filename ) != null ) { is = ConfigFileProbeHandlerPlugin . class . getResourceAsStream ( filename ) ; } else { try { is = new FileInputStream ( filename ) ; } catch ( FileNotFoundException e ) { throw new ProbeHandlerConfigException ( "Error loading handler config for [" + this . getClass ( ) . getName ( ) + "]" , e ) ; } } try { config . load ( is ) ; } catch ( IOException e ) { throw new ProbeHandlerConfigException ( "Error loading handler config for [" + this . getClass ( ) . getName ( ) + "]" , e ) ; } finally { try { is . close ( ) ; } catch ( IOException e ) { throw new ProbeHandlerConfigException ( "Error closing handler config for {" + this . getClass ( ) . getName ( ) + "]" , e ) ; } } // Launch the timer task that will look for changes to the config file try { configFileScan = new Timer ( ) ; configFileScan . scheduleAtFixedRate ( new ConfigFileMonitorTask ( this ) , 100 , 10000 ) ; } catch ( ConfigurationException e ) { throw new ProbeHandlerConfigException ( "Error initializing monitor task." , e ) ; } } | Initialize the handler . | 313 | 5 |
138,081 | private void initializeTransports ( ArrayList < TransportConfig > transportConfigs ) { for ( TransportConfig config : transportConfigs ) { ClientProbeSenders transport = new ClientProbeSenders ( config ) ; try { transport . initialize ( this ) ; _clientSenders . add ( transport ) ; } catch ( TransportConfigException e ) { LOGGER . warn ( "Transport [" + config . getName ( ) + "] failed to initialize." , e ) ; Console . error ( "Unable to initialize the Transport [" + config . getName ( ) + "]. Ignoring." ) ; } } } | Initializes the Transports . | 130 | 6 |
138,082 | private void initializeLocalhostNI ( ) { InetAddress localhost ; try { localhost = InetAddress . getLocalHost ( ) ; NetworkInterface ni = NetworkInterface . getByInetAddress ( localhost ) ; if ( ni != null ) getNIList ( ) . add ( ni . getName ( ) ) ; } catch ( UnknownHostException | SocketException e ) { Console . severe ( "Cannot get the Network Interface for localhost" ) ; Console . severe ( e . getMessage ( ) ) ; } } | Sets up the network interface list with at least the localhost NI . | 113 | 15 |
138,083 | public List < String > getAvailableNetworkInterfaces ( boolean requiresMulticast ) throws SocketException { Enumeration < NetworkInterface > nis = NetworkInterface . getNetworkInterfaces ( ) ; List < String > multicastNIs = new ArrayList < String > ( ) ; // Console.info("Available Multicast-enabled Network Interfaces"); while ( nis . hasMoreElements ( ) ) { NetworkInterface ni = nis . nextElement ( ) ; if ( ni . isUp ( ) && ! ni . isLoopback ( ) ) { if ( requiresMulticast ) { if ( ni . supportsMulticast ( ) ) multicastNIs . add ( ni . getName ( ) ) ; } else { multicastNIs . add ( ni . getName ( ) ) ; } } } return multicastNIs ; } | This gets a list of all the available network interface names . | 180 | 12 |
138,084 | public ClientProbeSenders getClientTransportNamed ( String transportName ) { ClientProbeSenders found = null ; for ( ClientProbeSenders t : _clientSenders ) { if ( t . getName ( ) . equalsIgnoreCase ( transportName ) ) { found = t ; break ; } } return found ; } | Returns the client transport specified by given name . | 73 | 9 |
138,085 | public static < T extends Case3 < A , B , C > , A , B , C > DecomposableMatchBuilder0 < T > case3 ( Class < T > clazz , MatchesExact < A > a , MatchesExact < B > b , MatchesExact < C > c ) { List < Matcher < Object >> matchers = Lists . of ( ArgumentMatchers . eq ( a . t ) , ArgumentMatchers . eq ( b . t ) , ArgumentMatchers . eq ( c . t ) ) ; return new DecomposableMatchBuilder0 < T > ( matchers , new Case3FieldExtractor <> ( clazz ) ) ; } | Matches a case class of three elements . | 148 | 9 |
138,086 | public CommandResult execute ( T context ) { try { return innerExecute ( context ) ; } catch ( Exception e ) { Console . error ( e . getMessage ( ) ) ; return CommandResult . ERROR ; } } | Executes the command . The command line arguments contains all of the key - value pairs and switches but does not include the command name that came from the original arguments . | 46 | 33 |
138,087 | public long factMatching ( long n ) { return match ( n ) . when ( caseLong ( 0 ) ) . get ( ( ) -> 1L ) . when ( caseLong ( any ( ) ) ) . get ( i -> i * factMatching ( i - 1 ) ) . getMatch ( ) ; } | An implementation of factorial using motif pattern matching . | 67 | 10 |
138,088 | public static IShape createTransformedShape ( Transform t , IShape src ) { if ( src == null ) { return null ; } if ( src instanceof Path ) { return ( ( Path ) src ) . createTransformedShape ( t ) ; } PathIterator path = src . pathIterator ( t ) ; Path dst = new Path ( path . windingRule ( ) ) ; dst . append ( path , false ) ; return dst ; } | Creates and returns a new shape that is the supplied shape transformed by this transform s matrix . | 92 | 19 |
138,089 | private static void sort ( double [ ] coords1 , int length1 , double [ ] coords2 , int length2 , int [ ] array ) { int temp ; int length = length1 + length2 ; double x1 , y1 , x2 , y2 ; for ( int i = 1 ; i < length ; i ++ ) { if ( array [ i - 1 ] < length1 ) { x1 = coords1 [ 2 * array [ i - 1 ] ] ; y1 = coords1 [ 2 * array [ i - 1 ] + 1 ] ; } else { x1 = coords2 [ 2 * ( array [ i - 1 ] - length1 ) ] ; y1 = coords2 [ 2 * ( array [ i - 1 ] - length1 ) + 1 ] ; } if ( array [ i ] < length1 ) { x2 = coords1 [ 2 * array [ i ] ] ; y2 = coords1 [ 2 * array [ i ] + 1 ] ; } else { x2 = coords2 [ 2 * ( array [ i ] - length1 ) ] ; y2 = coords2 [ 2 * ( array [ i ] - length1 ) + 1 ] ; } int j = i ; while ( j > 0 && compare ( x1 , y1 , x2 , y2 ) <= 0 ) { temp = array [ j ] ; array [ j ] = array [ j - 1 ] ; array [ j - 1 ] = temp ; j -- ; if ( j > 0 ) { if ( array [ j - 1 ] < length1 ) { x1 = coords1 [ 2 * array [ j - 1 ] ] ; y1 = coords1 [ 2 * array [ j - 1 ] + 1 ] ; } else { x1 = coords2 [ 2 * ( array [ j - 1 ] - length1 ) ] ; y1 = coords2 [ 2 * ( array [ j - 1 ] - length1 ) + 1 ] ; } if ( array [ j ] < length1 ) { x2 = coords1 [ 2 * array [ j ] ] ; y2 = coords1 [ 2 * array [ j ] + 1 ] ; } else { x2 = coords2 [ 2 * ( array [ j ] - length1 ) ] ; y2 = coords2 [ 2 * ( array [ j ] - length1 ) + 1 ] ; } } } } } | the array sorting | 520 | 3 |
138,090 | public void setFrameFromDiagonal ( float x1 , float y1 , float x2 , float y2 ) { float rx , ry , rw , rh ; if ( x1 < x2 ) { rx = x1 ; rw = x2 - x1 ; } else { rx = x2 ; rw = x1 - x2 ; } if ( y1 < y2 ) { ry = y1 ; rh = y2 - y1 ; } else { ry = y2 ; rh = y1 - y2 ; } setFrame ( rx , ry , rw , rh ) ; } | Sets the location and size of the framing rectangle of this shape based on the specified diagonal line . | 137 | 20 |
138,091 | public void setFrameFromCenter ( float centerX , float centerY , float cornerX , float cornerY ) { float width = Math . abs ( cornerX - centerX ) ; float height = Math . abs ( cornerY - centerY ) ; setFrame ( centerX - width , centerY - height , width * 2 , height * 2 ) ; } | Sets the location and size of the framing rectangle of this shape based on the specified center and corner points . | 75 | 22 |
138,092 | @ POST @ Path ( "/probeResponse" ) @ Consumes ( "application/json" ) public String handleJSONProbeResponse ( String probeResponseJSON ) { JSONSerializer serializer = new JSONSerializer ( ) ; ResponseWrapper response ; try { response = serializer . unmarshal ( probeResponseJSON ) ; } catch ( ResponseParseException e ) { String errorResponseString = "Incoming Response could not be parsed. Error message is: " + e . getMessage ( ) ; Console . error ( errorResponseString ) ; Console . error ( "Wireline message that could no be parsed is:" ) ; Console . error ( probeResponseJSON ) ; return errorResponseString ; } for ( ServiceWrapper service : response . getServices ( ) ) { service . setResponseID ( response . getResponseID ( ) ) ; service . setProbeID ( response . getProbeID ( ) ) ; cache . cache ( new ExpiringService ( service ) ) ; } String statusString = "Successfully cached " + response . getServices ( ) . size ( ) + " services" ; updateCacheListener ( statusString ) ; return statusString ; } | Inbound JSON responses get processed here . | 246 | 8 |
138,093 | public Circle set ( ICircle c ) { return set ( c . x ( ) , c . y ( ) , c . radius ( ) ) ; } | Sets the properties of this circle to be equal to those of the supplied circle . | 33 | 17 |
138,094 | public Circle set ( double x , double y , double radius ) { this . x = x ; this . y = y ; this . radius = radius ; return this ; } | Sets the properties of this circle to the supplied values . | 36 | 12 |
138,095 | public Matrix4 setToRotation ( float angle , float x , float y , float z ) { float c = FloatMath . cos ( angle ) , s = FloatMath . sin ( angle ) , omc = 1f - c ; float xs = x * s , ys = y * s , zs = z * s , xy = x * y , xz = x * z , yz = y * z ; return set ( x * x * omc + c , xy * omc - zs , xz * omc + ys , 0f , xy * omc + zs , y * y * omc + c , yz * omc - xs , 0f , xz * omc - ys , yz * omc + xs , z * z * omc + c , 0f , 0f , 0f , 0f , 1f ) ; } | Sets this to a rotation matrix . The formula comes from the OpenGL documentation for the glRotatef function . | 200 | 23 |
138,096 | public Matrix4 setToReflection ( float x , float y , float z , float w ) { float x2 = - 2f * x , y2 = - 2f * y , z2 = - 2f * z ; float xy2 = x2 * y , xz2 = x2 * z , yz2 = y2 * z ; float x2y2z2 = x * x + y * y + z * z ; return set ( 1f + x2 * x , xy2 , xz2 , x2 * w * x2y2z2 , xy2 , 1f + y2 * y , yz2 , y2 * w * x2y2z2 , xz2 , yz2 , 1f + z2 * z , z2 * w * x2y2z2 , 0f , 0f , 0f , 1f ) ; } | Sets this to a reflection across the specified plane . | 198 | 11 |
138,097 | public Matrix4 set ( float [ ] values ) { return set ( values [ 0 ] , values [ 1 ] , values [ 2 ] , values [ 3 ] , values [ 4 ] , values [ 5 ] , values [ 6 ] , values [ 7 ] , values [ 8 ] , values [ 9 ] , values [ 10 ] , values [ 11 ] , values [ 12 ] , values [ 13 ] , values [ 14 ] , values [ 15 ] ) ; } | Copies the elements of a row - major array . | 96 | 11 |
138,098 | public void launch ( Object arg ) { ReconnectableMap . INSTANCE . dismiss ( key ) ; out . put ( "restore" , true ) ; out . put ( "arg" , arg ) ; launches . onNext ( arg ) ; } | Launches an observable providing an argument . Dismisses the previous observable instance if it is not completed yet . | 53 | 22 |
138,099 | public static < E > List < E > of ( E e1 , E e2 , E e3 , E e4 ) { List < E > list = new ArrayList <> ( ) ; list . add ( e1 ) ; list . add ( e2 ) ; list . add ( e3 ) ; list . add ( e4 ) ; return list ; } | Returns a list of the given elements in order . | 78 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.