idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
137,900 | public static void addModal ( JFrame frame , Component component , ModalListener listener , Integer modalDepth ) { addModal_ ( frame , component , listener , modalDepth ) ; } | Add a modal component in the frame . | 42 | 9 |
137,901 | private static void addModal_ ( RootPaneContainer rootPane , Component component , ModalListener listener , Integer modalDepth ) { synchronized ( modals ) { if ( isModal ( component ) == false ) { getModal ( rootPane ) . addModal ( component , listener , modalDepth ) ; } } } | Add a modal component in the RootPaneContainer . | 73 | 12 |
137,902 | private static int getModalCount_ ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal != null ) { return modal . getSize ( ) ; } return 0 ; } } | Get the modal count of a specific RootPaneContainer . | 62 | 13 |
137,903 | private void closeCurrent ( ) { if ( components . size ( ) > 0 ) { Component component = components . remove ( components . size ( ) - 1 ) ; getModalPanel ( ) . removeAll ( ) ; fireCloseActionListener ( listeners . get ( component ) ) ; listeners . remove ( component ) ; if ( components . size ( ) > 0 ) { showNextComponent ( ) ; } else { restoreRootPane ( ) ; } } } | Close the current modal . | 96 | 6 |
137,904 | private void close ( Component component ) { if ( components . size ( ) > 0 ) { if ( components . contains ( component ) == false ) { return ; } components . remove ( component ) ; depths . remove ( component ) ; getModalPanel ( ) . removeAll ( ) ; fireCloseActionListener ( listeners . get ( component ) ) ; listeners . remove ( component ) ; if ( components . size ( ) > 0 ) { showNextComponent ( ) ; } else { restoreRootPane ( ) ; } } } | Close a modal | 110 | 4 |
137,905 | private void closeAll ( ) { getModalPanel ( ) . removeAll ( ) ; components . clear ( ) ; depths . clear ( ) ; listeners . clear ( ) ; restoreRootPane ( ) ; } | Close all modals . | 45 | 5 |
137,906 | private void addModal ( Component component , ModalListener listener , Integer modalDepth ) { if ( modalDepth == null ) { modalDepth = defaultModalDepth ; } if ( components . contains ( component ) == false ) { rootPane . getLayeredPane ( ) . remove ( getModalPanel ( ) ) ; rootPane . getLayeredPane ( ) . add ( getModalPanel ( ) , modalDepth ) ; KeyboardFocusManager focusManager = KeyboardFocusManager . getCurrentKeyboardFocusManager ( ) ; focusManager . clearGlobalFocusOwner ( ) ; getModalPanel ( ) . removeAll ( ) ; getModalPanel ( ) . add ( "" , component ) ; resizeModalPanel ( ) ; getModalPanel ( ) . repaint ( ) ; components . add ( component ) ; depths . put ( component , modalDepth ) ; addListener ( component , listener ) ; } } | Add a modal component | 201 | 5 |
137,907 | private ModalPanel getModalPanel ( ) { if ( modalPanel == null ) { modalPanel = new ModalPanel ( ) ; modalPanel . setLayout ( new ModalLayout ( ) ) ; } return modalPanel ; } | Get the transparent modal panel | 53 | 6 |
137,908 | public static RootPaneContainer getRootPaneContainer ( Component component ) { if ( component instanceof RootPaneContainer ) { return ( RootPaneContainer ) component ; } for ( Container p = component . getParent ( ) ; p != null ; p = p . getParent ( ) ) { if ( p instanceof RootPaneContainer ) { return ( RootPaneContainer ) p ; } } return null ; } | Get the RootPaneContainer of the specific component . | 89 | 11 |
137,909 | public static ResultDescriptor analyzeReturnType ( final DescriptorContext context , final Class < ? extends Collection > returnCollectionType ) { final Method method = context . method ; final MethodGenericsContext generics = context . generics . method ( method ) ; final Class < ? > returnClass = generics . resolveReturnClass ( ) ; final ResultDescriptor descriptor = new ResultDescriptor ( ) ; descriptor . expectType = resolveExpectedType ( returnClass , returnCollectionType ) ; final ResultType type ; final Class < ? > entityClass ; if ( isCollection ( returnClass ) ) { type = COLLECTION ; entityClass = resolveGenericType ( method , generics ) ; } else if ( returnClass . isArray ( ) ) { type = ARRAY ; entityClass = returnClass . getComponentType ( ) ; } else if ( VOID_TYPES . contains ( returnClass ) ) { type = VOID ; entityClass = Void . class ; } else { type = PLAIN ; // support for guava and jdk8 optionals entityClass = Optionals . isOptional ( returnClass ) ? resolveGenericType ( method , generics ) : returnClass ; } descriptor . returnType = type ; descriptor . entityType = entityClass ; return descriptor ; } | Analyze return type . | 272 | 5 |
137,910 | protected void recycleByRenderState ( RecyclerView . Recycler recycler , RenderState renderState ) { if ( renderState . mLayoutDirection == RenderState . LAYOUT_START ) { recycleViewsFromEnd ( recycler , renderState . mScrollingOffset ) ; } else { recycleViewsFromStart ( recycler , renderState . mScrollingOffset ) ; } } | Helper method to call appropriate recycle method depending on current render layout direction | 86 | 13 |
137,911 | public static void check ( final Object result , final Class < ? > targetType ) { if ( result != null && ! targetType . isAssignableFrom ( result . getClass ( ) ) ) { // note: conversion logic may go wrong (e.g. because converter expect collection input mostly and may // not work correctly for single element), but anyway overall conversion would be considered failed. throw new ResultConversionException ( String . format ( "Failed to convert %s to %s" , toStringType ( result ) , targetType . getSimpleName ( ) ) ) ; } } | Check converted result compatibility with required type . | 124 | 8 |
137,912 | @ SuppressWarnings ( "unchecked" ) public static Object convertToCollection ( final Object result , final Class collectionType , final Class targetEntity , final boolean projection ) { final Object converted ; if ( collectionType . equals ( Iterator . class ) ) { converted = toIterator ( result , targetEntity , projection ) ; } else if ( collectionType . isAssignableFrom ( List . class ) ) { converted = Lists . newArrayList ( toIterator ( result , targetEntity , projection ) ) ; } else if ( collectionType . isAssignableFrom ( Set . class ) ) { converted = Sets . newHashSet ( toIterator ( result , targetEntity , projection ) ) ; } else if ( ! collectionType . isInterface ( ) ) { converted = convertToCollectionImpl ( result , collectionType , targetEntity , projection ) ; } else { throw new ResultConversionException ( String . format ( "Incompatible result type requested %s for conversion from actual result %s" , collectionType , result . getClass ( ) ) ) ; } return converted ; } | Convert result object to collection . In some cases this could be do nothing case because orient already returns collection . If projection is required or when collection type is different from requested type result will be re - packaged into the new collection . | 227 | 46 |
137,913 | @ SuppressWarnings ( "PMD.LooseCoupling" ) public static Object convertToArray ( final Object result , final Class entityType , final boolean projection ) { final Collection res = result instanceof Collection // no projection because its applied later ? ( Collection ) result : convertToCollectionImpl ( result , ArrayList . class , entityType , false ) ; final Object array = Array . newInstance ( entityType , res . size ( ) ) ; int i = 0 ; for ( Object obj : res ) { Array . set ( array , i ++ , projection ? applyProjection ( obj , entityType ) : obj ) ; } return array ; } | Convert result object to array . | 139 | 7 |
137,914 | public static void check ( final boolean condition , final String message , final Object ... args ) { if ( ! condition ) { throw new SchemeInitializationException ( String . format ( message , args ) ) ; } } | Shortcut to check and throw scheme exception . | 44 | 9 |
137,915 | public < T > T doInTransaction ( final TxConfig config , final TxAction < T > action ) { return txTemplate . doInTransaction ( config , action ) ; } | Execute action within transaction . | 39 | 6 |
137,916 | public boolean collapsePanel ( ) { if ( mFirstLayout ) { mSlideState = SlideState . COLLAPSED ; return true ; } else { if ( mSlideState == SlideState . HIDDEN || mSlideState == SlideState . COLLAPSED ) return false ; return collapsePanel ( mSlideableView , 0 ) ; } } | Collapse the sliding pane if it is currently slideable . If first layout has already completed this will animate . | 78 | 22 |
137,917 | public boolean expandPanel ( float mSlideOffset ) { if ( mSlideableView == null || mSlideState == SlideState . EXPANDED ) return false ; mSlideableView . setVisibility ( View . VISIBLE ) ; return expandPanel ( mSlideableView , 0 , mSlideOffset ) ; } | Partially expand the sliding panel up to a specific offset | 72 | 11 |
137,918 | public void showPanel ( ) { if ( mFirstLayout ) { mSlideState = SlideState . COLLAPSED ; } else { if ( mSlideableView == null || mSlideState != SlideState . HIDDEN ) return ; mSlideableView . setVisibility ( View . VISIBLE ) ; requestLayout ( ) ; smoothSlideTo ( 0 , 0 ) ; } } | Shows the panel from the hidden state | 87 | 8 |
137,919 | public void hidePanel ( ) { if ( mFirstLayout ) { mSlideState = SlideState . HIDDEN ; } else { if ( mSlideState == SlideState . DRAGGING || mSlideState == SlideState . HIDDEN ) return ; int newTop = computePanelTopPosition ( 0.0f ) ; smoothSlideTo ( computeSlideOffset ( newTop ) , 0 ) ; } } | Hides the sliding panel entirely . | 92 | 7 |
137,920 | boolean smoothSlideTo ( float slideOffset , int velocity ) { if ( ! isSlidingEnabled ( ) ) { // Nothing to do. return false ; } int panelTop = computePanelTopPosition ( slideOffset ) ; if ( mDragHelper . smoothSlideViewTo ( mSlideableView , mSlideableView . getLeft ( ) , panelTop ) ) { setAllChildrenVisible ( ) ; ViewCompat . postInvalidateOnAnimation ( this ) ; return true ; } return false ; } | Smoothly animate mDraggingPane to the target X position within its range . | 110 | 18 |
137,921 | public static UnsubscribeMessage createCleanupMessage ( WebSocketSession session ) { UnsubscribeMessage msg = new UnsubscribeMessage ( "**" ) ; msg . setWebSocketSessionId ( session . getId ( ) ) ; msg . setPrincipal ( session . getPrincipal ( ) ) ; msg . setWampSession ( new WampSession ( session ) ) ; msg . cleanup = true ; return msg ; } | Creates an internal unsubscribe message . The system creates this message when the WebSocket session ends and sends it to the subscribed message handlers for cleaning up | 91 | 30 |
137,922 | public static long [ ] parseCoins ( long value ) { long [ ] result = new long [ 3 ] ; if ( value < 0 ) return result ; long temp = value ; result [ 2 ] = temp % 100 ; temp = temp / 100 ; result [ 1 ] = temp % 100 ; result [ 0 ] = temp / 100 ; return result ; } | parse given coin value into number of gold sliver and copper | 75 | 12 |
137,923 | @ Override public void handleMessageFromClient ( WebSocketSession session , WebSocketMessage < ? > webSocketMessage , MessageChannel outputChannel ) { Assert . isInstanceOf ( TextMessage . class , webSocketMessage ) ; WampMessage wampMessage = null ; try { wampMessage = WampMessage . fromJson ( session , this . jsonFactory , ( ( TextMessage ) webSocketMessage ) . getPayload ( ) ) ; } catch ( Throwable ex ) { if ( logger . isErrorEnabled ( ) ) { logger . error ( "Failed to parse " + webSocketMessage + " in session " + session . getId ( ) + "." , ex ) ; } return ; } try { WampSessionContextHolder . setAttributesFromMessage ( wampMessage ) ; outputChannel . send ( wampMessage ) ; } catch ( Throwable ex ) { logger . error ( "Failed to send client message to application via MessageChannel" + " in session " + session . getId ( ) + "." , ex ) ; if ( wampMessage != null && wampMessage instanceof CallMessage ) { CallErrorMessage callErrorMessage = new CallErrorMessage ( ( CallMessage ) wampMessage , "" , ex . toString ( ) ) ; try { String json = callErrorMessage . toJson ( this . jsonFactory ) ; session . sendMessage ( new TextMessage ( json ) ) ; } catch ( Throwable t ) { // Could be part of normal workflow (e.g. browser tab closed) logger . debug ( "Failed to send error to client." , t ) ; } } } finally { WampSessionContextHolder . resetAttributes ( ) ; } } | Handle incoming WebSocket messages from clients . | 363 | 8 |
137,924 | @ Override public void handleMessageToClient ( WebSocketSession session , Message < ? > message ) { if ( ! ( message instanceof WampMessage ) ) { logger . error ( "Expected WampMessage. Ignoring " + message + "." ) ; return ; } boolean closeWebSocketSession = false ; try { String json = ( ( WampMessage ) message ) . toJson ( this . jsonFactory ) ; session . sendMessage ( new TextMessage ( json ) ) ; } catch ( SessionLimitExceededException ex ) { // Bad session, just get out throw ex ; } catch ( Throwable ex ) { // Could be part of normal workflow (e.g. browser tab closed) logger . debug ( "Failed to send WebSocket message to client in session " + session . getId ( ) + "." , ex ) ; closeWebSocketSession = true ; } finally { if ( closeWebSocketSession ) { try { session . close ( CloseStatus . PROTOCOL_ERROR ) ; } catch ( IOException ex ) { // Ignore } } } } | Handle WAMP messages going back out to WebSocket clients . | 229 | 12 |
137,925 | private Set < Field > getItemFields ( ) { Class next = Item . class ; Set < Field > fields = new HashSet <> ( getFields ( next ) ) ; while ( next . getSuperclass ( ) != Object . class ) { next = next . getSuperclass ( ) ; fields . addAll ( getFields ( next ) ) ; } return fields ; } | get all fields for item class and all of it s super classes | 82 | 13 |
137,926 | private List < Field > getFields ( Class given ) { Field [ ] fs = given . getDeclaredFields ( ) ; return new ArrayList <> ( Arrays . asList ( fs ) ) ; } | get field of given class | 46 | 5 |
137,927 | public static void setInstance ( Cache cache ) throws GuildWars2Exception { if ( instance != null ) throw new GuildWars2Exception ( ErrorCode . Other , "Instance already initialized" ) ; instance = new GuildWars2 ( cache ) ; } | Use this to initialize instance with custom cache | 51 | 8 |
137,928 | public static List < File > listFiles ( File dir , FileFilter filter , boolean recursive ) { List < File > list = new ArrayList < File > ( ) ; listFilesInternal ( list , dir , filter , recursive ) ; return list ; } | List files ONLY not include directories . | 52 | 7 |
137,929 | @ SuppressWarnings ( "unchecked" ) public < T > T getAttribute ( String name ) { return ( T ) this . webSocketSession . getAttributes ( ) . get ( name ) ; } | Return the value for the attribute of the given name if any . | 45 | 13 |
137,930 | public void registerDestructionCallback ( String name , Runnable callback ) { synchronized ( getSessionMutex ( ) ) { if ( isSessionCompleted ( ) ) { throw new IllegalStateException ( "Session id=" + getWebSocketSessionId ( ) + " already completed" ) ; } setAttribute ( DESTRUCTION_CALLBACK_NAME_PREFIX + name , callback ) ; } } | Register a callback to execute on destruction of the specified attribute . The callback is executed when the session is closed . | 86 | 22 |
137,931 | public Object getSessionMutex ( ) { Object mutex = getAttribute ( SESSION_MUTEX_NAME ) ; if ( mutex == null ) { mutex = this . webSocketSession . getAttributes ( ) ; } return mutex ; } | Expose the object to synchronize on for the underlying session . | 54 | 13 |
137,932 | public int peek ( long timeout , TimeUnit unit ) throws InterruptedException , TimeoutException { // non volatile read ( which is quicker ) final int readLocation = this . consumerReadLocation ; blockForReadSpace ( timeout , unit , readLocation ) ; // purposely not volatile as the read memory barrier occurred above when we read ' this.readLocation' return data [ readLocation ] ; } | Retrieves but does not remove the head of this queue . | 81 | 13 |
137,933 | public Object invoke ( WampMessage message , Object ... providedArgs ) throws Exception { Object [ ] args = getMethodArgumentValues ( message , providedArgs ) ; if ( this . logger . isTraceEnabled ( ) ) { this . logger . trace ( "Resolved arguments: " + Arrays . asList ( args ) ) ; } Object returnValue = doInvoke ( args ) ; if ( this . logger . isTraceEnabled ( ) ) { this . logger . trace ( "Returned value: " + returnValue ) ; } return returnValue ; } | Invoke the method with the given message . | 120 | 9 |
137,934 | private Object [ ] getMethodArgumentValues ( WampMessage message , Object ... providedArgs ) throws Exception { MethodParameter [ ] parameters = getMethodParameters ( ) ; Object [ ] args = new Object [ parameters . length ] ; int argIndex = 0 ; for ( int i = 0 ; i < parameters . length ; i ++ ) { MethodParameter parameter = parameters [ i ] ; parameter . initParameterNameDiscovery ( this . parameterNameDiscoverer ) ; GenericTypeResolver . resolveParameterType ( parameter , getBean ( ) . getClass ( ) ) ; if ( this . argumentResolvers . supportsParameter ( parameter ) ) { try { args [ i ] = this . argumentResolvers . resolveArgument ( parameter , message ) ; continue ; } catch ( Exception ex ) { if ( this . logger . isTraceEnabled ( ) ) { this . logger . trace ( getArgumentResolutionErrorMessage ( "Error resolving argument" , i ) , ex ) ; } throw ex ; } } if ( providedArgs != null ) { args [ i ] = this . methodParameterConverter . convert ( parameter , providedArgs [ argIndex ] ) ; if ( args [ i ] != null ) { argIndex ++ ; continue ; } } if ( args [ i ] == null ) { String error = getArgumentResolutionErrorMessage ( "No suitable resolver for argument" , i ) ; throw new IllegalStateException ( error ) ; } } return args ; } | Get the method argument values for the current request . | 313 | 10 |
137,935 | protected String getDetailedErrorMessage ( String message ) { StringBuilder sb = new StringBuilder ( message ) . append ( "\n" ) ; sb . append ( "HandlerMethod details: \n" ) ; sb . append ( "Bean [" ) . append ( getBeanType ( ) . getName ( ) ) . append ( "]\n" ) ; sb . append ( "Method [" ) . append ( getBridgedMethod ( ) . toGenericString ( ) ) . append ( "]\n" ) ; return sb . toString ( ) ; } | Adds HandlerMethod details such as the controller type and method signature to the given error message . | 126 | 18 |
137,936 | protected Object doInvoke ( Object ... args ) throws Exception { ReflectionUtils . makeAccessible ( getBridgedMethod ( ) ) ; try { return getBridgedMethod ( ) . invoke ( getBean ( ) , args ) ; } catch ( IllegalArgumentException ex ) { assertTargetBean ( getBridgedMethod ( ) , getBean ( ) , args ) ; throw new IllegalStateException ( getInvocationErrorMessage ( ex . getMessage ( ) , args ) , ex ) ; } catch ( InvocationTargetException ex ) { // Unwrap for HandlerExceptionResolvers ... Throwable targetException = ex . getTargetException ( ) ; if ( targetException instanceof RuntimeException ) { throw ( RuntimeException ) targetException ; } else if ( targetException instanceof Error ) { throw ( Error ) targetException ; } else if ( targetException instanceof Exception ) { throw ( Exception ) targetException ; } else { String msg = getInvocationErrorMessage ( "Failed to invoke controller method" , args ) ; throw new IllegalStateException ( msg , targetException ) ; } } } | Invoke the handler method with the given argument values . | 236 | 11 |
137,937 | private File [ ] resolveConfigFiles ( File base , Map < String , Object > override ) { //system properties //-Dconfig=config.json -> override //Override if ( override != null ) { String configFilesString = ( String ) override . remove ( "config" ) ; if ( StringUtils . isNotBlank ( configFilesString ) ) { log . info ( "Using config files: {}" , configFilesString ) ; String [ ] strings = StringUtils . split ( configFilesString , ' ' ) ; File [ ] files = new File [ strings . length ] ; for ( int i = 0 ; i < strings . length ; i ++ ) { files [ i ] = new File ( base , strings [ i ] ) ; } return files ; } } //default useDefaultConfigFiles = true ; return base . listFiles ( DEFAULT_CONFIG_FILES_FILTER ) ; } | Find all config files . | 193 | 5 |
137,938 | public WebSocketTransportRegistration setDecoratorFactories ( WebSocketHandlerDecoratorFactory ... factories ) { if ( factories != null ) { this . decoratorFactories . addAll ( Arrays . asList ( factories ) ) ; } return this ; } | Configure one or more factories to decorate the handler used to process WebSocket messages . This may be useful in some advanced use cases for example to allow Spring Security to forcibly close the WebSocket session when the corresponding HTTP session expires . | 56 | 47 |
137,939 | public boolean offer ( float value , long timeout , TimeUnit unit ) throws InterruptedException { // non volatile read ( which is quicker ) final int writeLocation = this . producerWriteLocation ; // sets the nextWriteLocation my moving it on by 1, this may cause it it wrap back to the start. final int nextWriteLocation = ( writeLocation + 1 == capacity ) ? 0 : writeLocation + 1 ; if ( nextWriteLocation == capacity - 1 ) { final long timeoutAt = System . nanoTime ( ) + unit . toNanos ( timeout ) ; while ( readLocation == 0 ) // this condition handles the case where writer has caught up with the read, // we will wait for a read, ( which will cause a change on the read location ) { if ( ! blockAtAdd ( timeoutAt ) ) return false ; } } else { final long timeoutAt = System . nanoTime ( ) + unit . toNanos ( timeout ) ; while ( nextWriteLocation == readLocation ) // this condition handles the case general case where the read is at the start of the backing array and we are at the end, // blocks as our backing array is full, we will wait for a read, ( which will cause a change on the read location ) { if ( ! blockAtAdd ( timeoutAt ) ) return false ; } } // purposely not volatile see the comment below data [ writeLocation ] = value ; // the line below, is where the write memory barrier occurs, // we have just written back the data in the line above ( which is not require to have a memory barrier as we will be doing that in the line below setWriteLocation ( nextWriteLocation ) ; return true ; } | Inserts the specified element into this queue waiting up to the specified wait time if necessary for space to become available . | 351 | 23 |
137,940 | public int size ( ) { int read = readLocation ; int write = writeLocation ; if ( write < read ) write += capacity ; return write - read ; } | This method is not thread safe it therefore only provides and approximation of the size the size will be corrected if nothing was added or removed from the queue at the time it was called | 34 | 35 |
137,941 | public static String [ ] removeEmpties ( final String ... values ) { if ( values == null || values . length == 0 ) { return new String [ 0 ] ; } List < String > validValues = new ArrayList < String > ( ) ; for ( String value : values ) { if ( value != null && value . length ( ) > 0 ) { validValues . add ( value ) ; } } return validValues . toArray ( new String [ validValues . size ( ) ] ) ; } | Create an array with only the non - null and non - empty values | 106 | 14 |
137,942 | public static String [ ] getMatchingPaths ( final String [ ] includes , final String [ ] excludes , final String baseDir ) { DirectoryScanner scanner = new DirectoryScanner ( ) ; scanner . setBasedir ( baseDir ) ; if ( includes != null && includes . length > 0 ) { scanner . setIncludes ( includes ) ; } if ( excludes != null && excludes . length > 0 ) { scanner . setExcludes ( excludes ) ; } scanner . scan ( ) ; return scanner . getIncludedFiles ( ) ; } | Get matching paths found in given base directory | 113 | 8 |
137,943 | private FileFilter createConfigFilesFilter ( ) { SiteConfig config = site . getConfig ( ) ; boolean useDefaultConfigFiles = config . useDefaultConfigFiles ( ) ; if ( useDefaultConfigFiles ) { log . debug ( "Using default config files." ) ; return SiteConfigImpl . DEFAULT_CONFIG_FILES_FILTER ; } else { //custom config files final File [ ] configFiles = config . getConfigFiles ( ) ; return new FileFilter ( ) { @ Override public boolean accept ( File file ) { for ( File configFile : configFiles ) { if ( configFile . equals ( file ) ) { return true ; } } return false ; } } ; } } | Create config files FileFilter . | 147 | 6 |
137,944 | public static Vector inverseTransform ( double x , double y , double sx , double sy , double rotation , Vector result ) { 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 vector as specified storing the result in the vector provided . | 112 | 15 |
137,945 | public void start ( ) { setDefaultLogLevel ( ) ; /* * JLine doesn't run in Eclipse. To get around this, we allow * a property "jlineDisable" to be specified via VM arguments. * This causes it to use standard scanning of System.in and disables * auto complete functionality. */ if ( Boolean . getBoolean ( "jlineDisable" ) ) { Scanner scan = new Scanner ( System . in ) ; boolean run = true ; while ( run ) { System . out . print ( _prompt + " (no jline) >" ) ; String nextLine = scan . nextLine ( ) ; run = processInputLine ( nextLine ) ; } scan . close ( ) ; } else { try { ConsoleReader reader = new ConsoleReader ( ) ; reader . setBellEnabled ( _appContext . getBoolean ( "cliapi.bellenabled" , false ) ) ; reader . addCompleter ( new StringsCompleter ( this . getCommandNames ( ) . toArray ( new String [ 0 ] ) ) ) ; boolean run = true ; while ( run ) { String nextLine = reader . readLine ( _prompt + " >" ) ; run = processInputLine ( nextLine ) ; } } catch ( IOException e ) { System . err . println ( "Error reading from input." ) ; e . printStackTrace ( ) ; } } } | Start the application . This will continuously loop until the user exits the application . | 301 | 15 |
137,946 | protected FindCommandResult findAndCreateCommand ( String [ ] args ) throws CommandInitException { String commandName = args [ 0 ] ; String [ ] remainingArguments = StringUtils . stripArgs ( args , 1 ) ; // Check top level commands for app Class < ? extends Command < ? extends CLIContext > > commandClass = _commands . get ( commandName ) ; if ( commandClass == null ) { return null ; } try { // Create the instance of the root class and let that class hunt for any subcommands Command < ? extends CLIContext > rootCmd = ( Command < ? extends CLIContext > ) commandClass . newInstance ( ) ; return rootCmd . findAndCreateCommand ( remainingArguments ) ; } catch ( Exception e ) { throw new CommandInitException ( commandName ) ; } } | Find and create the command instance . | 177 | 7 |
137,947 | private Map < String , Class < ? extends Command < ? extends CLIContext > > > loadCommands ( ) throws CLIInitException { Map < String , Class < ? extends Command < ? extends CLIContext > > > commands = new HashMap < String , Class < ? extends Command < ? extends CLIContext > > > ( ) ; Discoverer discoverer = new ClasspathDiscoverer ( ) ; CLIAnnotationDiscovereryListener discoveryListener = new CLIAnnotationDiscovereryListener ( new String [ ] { CLICommand . class . getName ( ) } ) ; discoverer . addAnnotationListener ( discoveryListener ) ; discoverer . discover ( true , true , true , true , true ) ; loadCommands ( commands , discoveryListener . getDiscoveredClasses ( ) ) ; if ( commands . isEmpty ( ) ) { throw new CLIInitException ( "No commands could be loaded." ) ; } return commands ; } | Load the necessary commands for this application . | 207 | 8 |
137,948 | public void setBounds ( IRectangle r ) { setBounds ( r . x ( ) , r . y ( ) , r . width ( ) , r . height ( ) ) ; } | Sets the bounds of this rectangle to those of the supplied rectangle . | 42 | 14 |
137,949 | public void add ( int px , int py ) { int x1 = Math . min ( x , px ) ; int x2 = Math . max ( x + width , px ) ; int y1 = Math . min ( y , py ) ; int y2 = Math . max ( y + height , py ) ; setBounds ( x1 , y1 , x2 - x1 , y2 - y1 ) ; } | Expands the bounds of this rectangle to contain the specified point . | 94 | 13 |
137,950 | public void add ( IRectangle r ) { int x1 = Math . min ( x , r . x ( ) ) ; int x2 = Math . max ( x + width , r . x ( ) + r . width ( ) ) ; int y1 = Math . min ( y , r . y ( ) ) ; int y2 = Math . max ( y + height , r . y ( ) + r . height ( ) ) ; setBounds ( x1 , y1 , x2 - x1 , y2 - y1 ) ; } | Expands the bounds of this rectangle to contain the supplied rectangle . | 118 | 13 |
137,951 | public Vector setAngle ( double angle ) { double l = length ( ) ; return set ( l * Math . cos ( angle ) , l * Math . sin ( angle ) ) ; } | Sets this vector s angle preserving its magnitude . | 40 | 10 |
137,952 | public boolean setListenerURL ( String listenerURL ) { String newURL = _substitutor . replace ( listenerURL ) ; boolean changed = false ; if ( ! _urlValidator . isValid ( newURL ) ) { error ( "The Response Listener URL specified is invalid. Continuing with previous value." ) ; } else { if ( ! newURL . equalsIgnoreCase ( _listenerURL ) ) { _listenerURL = newURL ; _listenerTarget = createListenerTarget ( newURL ) ; changed = true ; } } return changed ; } | Sets the Listener URL . Checks to see if the URL is valid or it does nothing . | 119 | 20 |
137,953 | public void setResponseURL ( String responseURL ) { String newURL = _substitutor . replace ( responseURL ) ; if ( ! _urlValidator . isValid ( newURL ) ) { error ( "The RespondTo URL specified is invalid. Continuing with previous value." ) ; } else { this . _responseURL = newURL ; } } | Sets the respondTo URL for the client probes to use . If the URL is invalid it does nothing . | 75 | 22 |
137,954 | public Box set ( IVector3 minExtent , IVector3 maxExtent ) { _minExtent . set ( minExtent ) ; _maxExtent . set ( maxExtent ) ; return this ; } | Sets the box parameters to the values contained in the supplied vectors . | 47 | 14 |
137,955 | public Box fromPoints ( IVector3 ... points ) { setToEmpty ( ) ; for ( IVector3 point : points ) { addLocal ( point ) ; } return this ; } | Initializes this box with the extents of an array of points . | 39 | 14 |
137,956 | public static int solveQuad ( double [ ] eqn , double [ ] res ) { double a = eqn [ 2 ] ; double b = eqn [ 1 ] ; double c = eqn [ 0 ] ; int rc = 0 ; if ( a == 0f ) { if ( b == 0f ) { return - 1 ; } res [ rc ++ ] = - c / b ; } else { double d = b * b - 4f * a * c ; // d < 0f if ( d < 0f ) { return 0 ; } d = Math . sqrt ( d ) ; res [ rc ++ ] = ( - b + d ) / ( a * 2f ) ; // d != 0f if ( d != 0f ) { res [ rc ++ ] = ( - b - d ) / ( a * 2f ) ; } } return fixRoots ( res , rc ) ; } | Solves quadratic equation | 193 | 6 |
137,957 | public static int solveCubic ( double [ ] eqn , double [ ] res ) { double d = eqn [ 3 ] ; if ( d == 0 ) { return solveQuad ( eqn , res ) ; } double a = eqn [ 2 ] / d ; double b = eqn [ 1 ] / d ; double c = eqn [ 0 ] / d ; int rc = 0 ; double Q = ( a * a - 3f * b ) / 9f ; double R = ( 2f * a * a * a - 9f * a * b + 27f * c ) / 54f ; double Q3 = Q * Q * Q ; double R2 = R * R ; double n = - a / 3f ; if ( R2 < Q3 ) { double t = Math . acos ( R / Math . sqrt ( Q3 ) ) / 3f ; double p = 2f * Math . PI / 3f ; double m = - 2f * Math . sqrt ( Q ) ; res [ rc ++ ] = m * Math . cos ( t ) + n ; res [ rc ++ ] = m * Math . cos ( t + p ) + n ; res [ rc ++ ] = m * Math . cos ( t - p ) + n ; } else { // Debug.println("R2 >= Q3 (" + R2 + "/" + Q3 + ")"); double A = Math . pow ( Math . abs ( R ) + Math . sqrt ( R2 - Q3 ) , 1f / 3f ) ; if ( R > 0f ) { A = - A ; } // if (A == 0f) { if ( - ROOT_DELTA < A && A < ROOT_DELTA ) { res [ rc ++ ] = n ; } else { double B = Q / A ; res [ rc ++ ] = A + B + n ; // if (R2 == Q3) { double delta = R2 - Q3 ; if ( - ROOT_DELTA < delta && delta < ROOT_DELTA ) { res [ rc ++ ] = - ( A + B ) / 2f + n ; } } } return fixRoots ( res , rc ) ; } | Solves cubic equation | 481 | 4 |
137,958 | public static int intersectLine ( double x1 , double y1 , double x2 , double y2 , double rx1 , double ry1 , double rx2 , double ry2 ) { // LEFT/RIGHT/UP if ( ( rx2 < x1 && rx2 < x2 ) || ( rx1 > x1 && rx1 > x2 ) || ( ry1 > y1 && ry1 > y2 ) ) { return 0 ; } // DOWN if ( ry2 < y1 && ry2 < y2 ) { } else { // INSIDE if ( x1 == x2 ) { return CROSSING ; } // Build bound double bx1 , bx2 ; if ( x1 < x2 ) { bx1 = x1 < rx1 ? rx1 : x1 ; bx2 = x2 < rx2 ? x2 : rx2 ; } else { bx1 = x2 < rx1 ? rx1 : x2 ; bx2 = x1 < rx2 ? x1 : rx2 ; } double k = ( y2 - y1 ) / ( x2 - x1 ) ; double by1 = k * ( bx1 - x1 ) + y1 ; double by2 = k * ( bx2 - x1 ) + y1 ; // BOUND-UP if ( by1 < ry1 && by2 < ry1 ) { return 0 ; } // BOUND-DOWN if ( by1 > ry2 && by2 > ry2 ) { } else { return CROSSING ; } } // EMPTY if ( x1 == x2 ) { return 0 ; } // CURVE-START if ( rx1 == x1 ) { return x1 < x2 ? 0 : - 1 ; } // CURVE-END if ( rx1 == x2 ) { return x1 < x2 ? 1 : 0 ; } if ( x1 < x2 ) { return x1 < rx1 && rx1 < x2 ? 1 : 0 ; } return x2 < rx1 && rx1 < x1 ? - 1 : 0 ; } | Returns how many times rectangle stripe cross line or the are intersect | 480 | 12 |
137,959 | protected static void sortBound ( double [ ] bound , int bc ) { for ( int i = 0 ; i < bc - 4 ; i += 4 ) { int k = i ; for ( int j = i + 4 ; j < bc ; j += 4 ) { if ( bound [ k ] > bound [ j ] ) { k = j ; } } if ( k != i ) { double tmp = bound [ i ] ; bound [ i ] = bound [ k ] ; bound [ k ] = tmp ; tmp = bound [ i + 1 ] ; bound [ i + 1 ] = bound [ k + 1 ] ; bound [ k + 1 ] = tmp ; tmp = bound [ i + 2 ] ; bound [ i + 2 ] = bound [ k + 2 ] ; bound [ k + 2 ] = tmp ; tmp = bound [ i + 3 ] ; bound [ i + 3 ] = bound [ k + 3 ] ; bound [ k + 3 ] = tmp ; } } } | Sorts a bound array . | 206 | 6 |
137,960 | protected static int crossBound ( double [ ] bound , int bc , double py1 , double py2 ) { // LEFT/RIGHT if ( bc == 0 ) { return 0 ; } // Check Y coordinate int up = 0 ; int down = 0 ; for ( int i = 2 ; i < bc ; i += 4 ) { if ( bound [ i ] < py1 ) { up ++ ; continue ; } if ( bound [ i ] > py2 ) { down ++ ; continue ; } return CROSSING ; } // UP if ( down == 0 ) { return 0 ; } if ( up != 0 ) { // bc >= 2 sortBound ( bound , bc ) ; boolean sign = bound [ 2 ] > py2 ; for ( int i = 6 ; i < bc ; i += 4 ) { boolean sign2 = bound [ i ] > py2 ; if ( sign != sign2 && bound [ i + 1 ] != bound [ i - 3 ] ) { return CROSSING ; } sign = sign2 ; } } return UNKNOWN ; } | Returns whether bounds intersect a rectangle or not . | 221 | 9 |
137,961 | public void setElement ( int row , int col , float value ) { switch ( col ) { case 0 : switch ( row ) { case 0 : m00 = value ; return ; case 1 : m01 = value ; return ; case 2 : m02 = value ; return ; } break ; case 1 : switch ( row ) { case 0 : m10 = value ; return ; case 1 : m11 = value ; return ; case 2 : m12 = value ; return ; } break ; case 2 : switch ( row ) { case 0 : m20 = value ; return ; case 1 : m21 = value ; return ; case 2 : m22 = value ; return ; } break ; } throw new ArrayIndexOutOfBoundsException ( ) ; } | Sets the matrix element at the specified row and column . | 157 | 12 |
137,962 | public Plane fromPoints ( IVector3 p1 , IVector3 p2 , IVector3 p3 ) { // compute the normal by taking the cross product of the two vectors formed p2 . subtract ( p1 , _v1 ) ; p3 . subtract ( p1 , _v2 ) ; _v1 . cross ( _v2 , _normal ) . normalizeLocal ( ) ; // use the first point to determine the constant constant = - _normal . dot ( p1 ) ; return this ; } | Sets this plane based on the three points provided . | 109 | 11 |
137,963 | public Plane fromPointNormal ( IVector3 pt , IVector3 normal ) { return set ( normal , - normal . dot ( pt ) ) ; } | Sets this plane based on a point on the plane and the plane normal . | 32 | 16 |
137,964 | public static String [ ] stripArgs ( String [ ] originalArgs , int stripCount ) { if ( originalArgs . length <= stripCount ) { return new String [ 0 ] ; } String [ ] stripped = new String [ originalArgs . length - stripCount ] ; for ( int i = 0 ; i < stripped . length ; i ++ ) { stripped [ i ] = originalArgs [ i + stripCount ] ; } return stripped ; } | Strip the first N items from the array . | 91 | 10 |
137,965 | public < U extends T > OngoingMatchingC0 < T , U > when ( MatchesExact < U > o ) { List < Matcher < Object >> matchers = Lists . of ( ArgumentMatchers . eq ( o . t ) ) ; return new OngoingMatchingC0 <> ( this , new DecomposableMatchBuilder0 <> ( matchers , new IdentityFieldExtractor < U > ( ) ) . build ( ) ) ; } | Specifies an exact match and then returns a fluent interface for specifying the action to take if the value matches this case . | 100 | 24 |
137,966 | public < U extends T > OngoingMatchingC1 < T , U , U > when ( MatchesAny < U > o ) { List < Matcher < Object >> matchers = Lists . of ( ArgumentMatchers . any ( ) ) ; return new OngoingMatchingC1 <> ( this , new DecomposableMatchBuilder1 < U , U > ( matchers , 0 , new IdentityFieldExtractor <> ( ) ) . build ( ) ) ; } | Specifies a wildcard match and then returns a fluent interface for specifying the action to take if the value matches this case . | 102 | 25 |
137,967 | public void doMatch ( ) { boolean matchFound = false ; for ( ConsumablePattern < T > pattern : patterns ) { if ( pattern . matches ( value ) ) { pattern . consume ( value ) ; matchFound = true ; break ; } } if ( ! matchFound ) { throw new MatchException ( "No match found for " + value ) ; } } | Runs through the possible matches and executes the specified consumer of the first match . | 77 | 16 |
137,968 | public FluentMatchingC < T > orElse ( ) { patterns . add ( ConsumablePattern . of ( t -> true , t -> doNothing ( ) ) ) ; return this ; } | Sets a no - op to be run if no match is found . | 42 | 15 |
137,969 | public void subscribe ( ) throws URISyntaxException , TransportConfigException { /* * if this instance of the transport (as there could be several - each with * a different topic) is in shutdown mode then don't subscribe. This is a * side effect of when you shutdown a sns transport and the listener gets an * UnsubscribeConfirmation. In normal operation, when the topic does * occasional house keeping and clears out the subscriptions, running * transports will just re-subscribe. */ if ( _inShutdown ) return ; URI url = getBaseSubscriptionURI ( ) ; String subscriptionURL = url . toString ( ) + "listener/sns" ; LOGGER . info ( "Subscription URI - " + subscriptionURL ) ; SubscribeRequest subRequest = new SubscribeRequest ( _argoTopicName , "http" , subscriptionURL ) ; try { getSNSClient ( ) . subscribe ( subRequest ) ; } catch ( AmazonServiceException e ) { throw new TransportConfigException ( "Error subscribing to SNS topic." , e ) ; } // get request id for SubscribeRequest from SNS metadata this . _subscriptionArn = getSNSClient ( ) . getCachedResponseMetadata ( subRequest ) . toString ( ) ; LOGGER . info ( "SubscribeRequest - " + _subscriptionArn ) ; } | Attempt to subscript to the Argo SNS topic . | 283 | 11 |
137,970 | @ SuppressWarnings ( "unchecked" ) public static < T > Matcher < T > eq ( T value ) { return ( Matcher < T > ) new Equals ( value ) ; } | Returns an equals matcher for the given value . | 44 | 10 |
137,971 | public static URI getLocalBaseURI ( ) { InetAddress localAddr ; String addr ; try { localAddr = InetAddress . getLocalHost ( ) ; addr = localAddr . getHostAddress ( ) ; } catch ( UnknownHostException e ) { LOGGER . warn ( "Issues finding ip address of locahost. Using string 'localhost' for listener address binding" ) ; addr = "localhost" ; } return UriBuilder . fromUri ( "http://" + addr + "/" ) . port ( DEFAULT_PORT ) . build ( ) ; } | Return the local base URI based on the localhost address . | 124 | 12 |
137,972 | private String calculateSHA256Hash ( byte [ ] msg , int offset , int len ) { // Calculate the SHA256 digest of the Hello message Digest digest = platform . getCrypto ( ) . createDigestSHA256 ( ) ; digest . update ( msg , offset , len ) ; int digestLen = digest . getDigestLength ( ) ; // prepare space for hexadecimal representation, store the diggest in // the second half and then convert byte [ ] hash = new byte [ 2 * digestLen ] ; digest . getDigest ( hash , digestLen , true ) ; for ( int i = 0 ; i != digestLen ; ++ i ) { byte b = hash [ digestLen + i ] ; int d1 = ( b >> 4 ) & 0x0f ; int d2 = b & 0x0f ; hash [ i * 2 ] = ( byte ) ( ( d1 >= 10 ) ? d1 + ' ' - 10 : d1 + ' ' ) ; hash [ i * 2 + 1 ] = ( byte ) ( ( d2 >= 10 ) ? d2 + ' ' - 10 : d2 + ' ' ) ; } String hashStr = new String ( hash ) ; if ( platform . getLogger ( ) . isEnabled ( ) ) { logBuffer ( "calculateSHA256Hash" , msg , offset , len ) ; logString ( "SHA256 Hash = '" + hashStr + "'" ) ; } return hashStr ; } | Calculate the hash digest of part of a message using the SHA256 algorithm | 313 | 16 |
137,973 | public void handleIncomingMessage ( byte [ ] data , int offset , int len ) { synchronized ( messageQueue ) { messageQueue . add ( new IncomingMessage ( data , offset , len ) ) ; } synchronized ( lock ) { lock . notifyAll ( ) ; } } | Handle an incoming ZRTP message . Assumes RTP headers and trailing CRC have been stripped by caller | 58 | 21 |
137,974 | public boolean isTrusted ( ) { if ( delayedCacheUpdate || farEndZID == null ) { return false ; } cache . selectEntry ( farEndZID ) ; return cache . getTrust ( ) ; } | Retrieves the current trust status of the connection . | 46 | 11 |
137,975 | private void runSession ( ) { if ( ! started ) { logString ( "Thread Starting" ) ; completed = false ; seqNum = getStartSeqNum ( ) ; rtpStack . setNextZrtpSequenceNumber ( getStartSeqNum ( ) ) ; state = ZRTP_STATE_INACTIVE ; initiator = false ; hashMode = HashType . UNDEFINED ; dhMode = KeyAgreementType . DH3K ; sasMode = SasType . UNDEFINED ; farEndZID = null ; farEndH0 = null ; farEndClientID = "" ; isLegacyClient = false ; // farEndH1 = null; // farEndH2 = null; // farEndH3 = null; farEndZID = null ; dhPart1Msg = null ; dhPart2Msg = null ; rxHelloMsg = txHelloMsg = commitMsg = null ; msgConfirm1TX = msgConfirm2TX = null ; msgConfirm1RX = msgConfirm2RX = null ; msgErrorTX = null ; try { // TODO: create after algorithm negotiation dhSuite . setAlgorithm ( KeyAgreementType . DH3K ) ; // Initialize the retransmission timer interval timerInterval = T1_INITIAL_INTERVAL ; sendHello ( ) ; started = true ; } catch ( Throwable e ) { logError ( "Exception sending initial Hello message: " + e . toString ( ) ) ; e . printStackTrace ( ) ; completed = true ; } while ( ! completed ) { synchronized ( lock ) { try { lock . wait ( ) ; } catch ( Throwable e ) { logString ( "Thread Interrupted E:" + e ) ; } } processQueuedMessages ( ) ; } endSession ( ) ; logString ( "Thread Ending" ) ; } } | Thread run method | 403 | 3 |
137,976 | public void setSdpHelloHash ( String version , String helloHash ) { if ( ! version . startsWith ( VERSION_PREFIX ) ) { logWarning ( "Different version number: '" + version + "' Ours: '" + VERSION_PREFIX + "' (" + VERSION + ")" ) ; } sdpHelloHashReceived = helloHash ; } | Hash of the Hello message to be received . This hash is sent by the other end as part of the SDP for further verification . | 82 | 27 |
137,977 | public void untrust ( ) { cache . updateEntry ( cacheExpiryTime ( ) , false , newRS , keepRS2 , null ) ; delayedCacheUpdate = true ; } | Notifies the ZRTP protocol that the user has revoked their trust in the connection . SAS verified flags is set to false and shared secrets with the remote end are removed from the cache . | 39 | 38 |
137,978 | private boolean verifyHelloMessage ( byte [ ] helloMsg ) { if ( sdpHelloHashReceived != null ) { String hash = calculateSHA256Hash ( helloMsg , 0 , helloMsg . length ) ; boolean hashesMatched = hash . toUpperCase ( ) . equals ( sdpHelloHashReceived . toUpperCase ( ) ) ; if ( platform . getLogger ( ) . isEnabled ( ) ) { if ( hashesMatched ) { logString ( "verifyHelloMessage() Hello hash verified OK." ) ; } else { logString ( "verifyHelloMessage() Hello hash does NOT match hash= '" + hash + "' expected (SDP) = '" + sdpHelloHashReceived + "'" ) ; } } return hashesMatched ; } else { return true ; } } | Verify whether the contents of the Hello message received has not been altered by matching with the SHA256 hash received in SDP exchange . | 173 | 27 |
137,979 | public IntersectionType intersectionType ( Box box ) { // exit quickly in cases where the bounding boxes don't overlap (equivalent to a separating // axis test using the axes of the box) if ( ! _bounds . intersects ( box ) ) { return IntersectionType . NONE ; } // consider each side of the frustum as a potential separating axis int ccount = 0 ; for ( int ii = 0 ; ii < 6 ; ii ++ ) { // determine how many vertices fall inside/outside the plane int inside = 0 ; Plane plane = _planes [ ii ] ; for ( int jj = 0 ; jj < 8 ; jj ++ ) { if ( plane . distance ( box . vertex ( jj , _vertex ) ) <= 0f ) { inside ++ ; } } if ( inside == 0 ) { return IntersectionType . NONE ; } else if ( inside == 8 ) { ccount ++ ; } } return ( ccount == 6 ) ? IntersectionType . CONTAINS : IntersectionType . INTERSECTS ; } | Checks whether the frustum intersects the specified box . | 225 | 12 |
137,980 | public Box boundsUnderRotation ( Matrix3 matrix , Box result ) { result . setToEmpty ( ) ; for ( Vector3 vertex : _vertices ) { result . addLocal ( matrix . transform ( vertex , _vertex ) ) ; } return result ; } | Computes the bounds of the frustum under the supplied rotation and places the results in the box provided . | 56 | 21 |
137,981 | protected void updateDerivedState ( ) { _planes [ 0 ] . fromPoints ( _vertices [ 0 ] , _vertices [ 1 ] , _vertices [ 2 ] ) ; // near _planes [ 1 ] . fromPoints ( _vertices [ 5 ] , _vertices [ 4 ] , _vertices [ 7 ] ) ; // far _planes [ 2 ] . fromPoints ( _vertices [ 1 ] , _vertices [ 5 ] , _vertices [ 6 ] ) ; // left _planes [ 3 ] . fromPoints ( _vertices [ 4 ] , _vertices [ 0 ] , _vertices [ 3 ] ) ; // right _planes [ 4 ] . fromPoints ( _vertices [ 3 ] , _vertices [ 2 ] , _vertices [ 6 ] ) ; // top _planes [ 5 ] . fromPoints ( _vertices [ 4 ] , _vertices [ 5 ] , _vertices [ 1 ] ) ; // bottom _bounds . fromPoints ( _vertices ) ; } | Sets the planes and bounding box of the frustum based on its vertices . | 220 | 18 |
137,982 | public void setArcType ( int type ) { if ( type != OPEN && type != CHORD && type != PIE ) { throw new IllegalArgumentException ( "Invalid Arc type: " + type ) ; } this . type = type ; } | Sets the type of this arc to the specified value . | 52 | 12 |
137,983 | public void setArc ( IArc arc ) { setArc ( arc . x ( ) , arc . y ( ) , arc . width ( ) , arc . height ( ) , arc . angleStart ( ) , arc . angleExtent ( ) , arc . arcType ( ) ) ; } | Sets the location size angular extents and closure type of this arc to the same values as the supplied arc . | 61 | 23 |
137,984 | public void setAngleStart ( XY point ) { double angle = Math . atan2 ( point . y ( ) - centerY ( ) , point . x ( ) - centerX ( ) ) ; setAngleStart ( normAngle ( - Math . toDegrees ( angle ) ) ) ; } | Sets the starting angle of this arc to the angle defined by the supplied point relative to the center of this arc . | 66 | 24 |
137,985 | public static float distance ( float x1 , float y1 , float x2 , float y2 ) { return FloatMath . sqrt ( distanceSq ( x1 , y1 , x2 , y2 ) ) ; } | Returns the Euclidean distance between the specified two points . | 48 | 12 |
137,986 | public void setRoundRect ( float x , float y , float width , float height , float arcwidth , float archeight ) { this . x = x ; this . y = y ; this . width = width ; this . height = height ; this . arcwidth = arcwidth ; this . archeight = archeight ; } | Sets the frame and corner dimensions of this rectangle to the specified values . | 68 | 15 |
137,987 | public void setRoundRect ( IRoundRectangle rr ) { setRoundRect ( rr . x ( ) , rr . y ( ) , rr . width ( ) , rr . height ( ) , rr . arcWidth ( ) , rr . arcHeight ( ) ) ; } | Sets the frame and corner dimensions of this rectangle to be equal to those of the supplied rectangle . | 64 | 20 |
137,988 | public static float pointLineDistSq ( float px , float py , float x1 , float y1 , float x2 , float y2 ) { x2 -= x1 ; y2 -= y1 ; px -= x1 ; py -= y1 ; float s = px * y2 - py * x2 ; return ( s * s ) / ( x2 * x2 + y2 * y2 ) ; } | Returns the square of the distance from the specified point to the specified line . | 92 | 15 |
137,989 | public static float pointLineDist ( float px , float py , float x1 , float y1 , float x2 , float y2 ) { return FloatMath . sqrt ( pointLineDistSq ( px , py , x1 , y1 , x2 , y2 ) ) ; } | Returns the distance from the specified point to the specified line . | 64 | 12 |
137,990 | public static float pointSegDistSq ( float px , float py , float x1 , float y1 , float x2 , float y2 ) { // A = (x2 - x1, y2 - y1) // P = (px - x1, py - y1) x2 -= x1 ; // A = (x2, y2) y2 -= y1 ; px -= x1 ; // P = (px, py) py -= y1 ; float dist ; if ( px * x2 + py * y2 <= 0.0 ) { // P*A dist = px * px + py * py ; } else { px = x2 - px ; // P = A - P = (x2 - px, y2 - py) py = y2 - py ; if ( px * x2 + py * y2 <= 0.0 ) { // P*A dist = px * px + py * py ; } else { dist = px * y2 - py * x2 ; dist = dist * dist / ( x2 * x2 + y2 * y2 ) ; // pxA/|A| } } if ( dist < 0 ) { dist = 0 ; } return dist ; } | Returns the square of the distance between the specified point and the specified line segment . | 275 | 16 |
137,991 | public static float pointSegDist ( float px , float py , float x1 , float y1 , float x2 , float y2 ) { return FloatMath . sqrt ( pointSegDistSq ( px , py , x1 , y1 , x2 , y2 ) ) ; } | Returns the distance between the specified point and the specified line segment . | 64 | 13 |
137,992 | public static ZrtpCacheEntry fromString ( String key , String value ) { String data = null ; String number = null ; int sep = value . indexOf ( ' ' ) ; if ( sep > 0 ) { data = value . substring ( 0 , sep ) ; number = value . substring ( sep + 1 ) ; } else { data = value ; number = "" ; } byte [ ] buffer = new byte [ data . length ( ) / 2 ] ; for ( int i = 0 ; i < buffer . length ; i ++ ) { buffer [ i ] = ( byte ) Short . parseShort ( data . substring ( i * 2 , i * 2 + 2 ) , 16 ) ; } AndroidCacheEntry entry = new AndroidCacheEntry ( key , buffer , number ) ; return entry ; } | Create a Cache Entry from the Zid string and the CSV representation of HEX RAW data and phone number | 170 | 21 |
137,993 | public void setLine ( XY p1 , XY p2 ) { setLine ( p1 . x ( ) , p1 . y ( ) , p2 . x ( ) , p2 . y ( ) ) ; } | Sets the start and end of this line to the specified points . | 47 | 14 |
137,994 | public void setLine ( float x1 , float y1 , float x2 , float y2 ) { this . x1 = x1 ; this . y1 = y1 ; this . x2 = x2 ; this . y2 = y2 ; } | Sets the start and end point of this line to the specified values . | 55 | 15 |
137,995 | public void addAccessPoint ( String label , String ip , String port , String url , String dataType , String data ) { AccessPoint ap = new AccessPoint ( ) ; ap . label = label ; ap . ipAddress = ip ; ap . port = port ; ap . url = url ; ap . dataType = dataType ; ap . data = data ; accessPoints . add ( ap ) ; } | Add a new access point for the service record . This structure exists to help deal with network access issues and not multiple contracts . For example a service could have an access point that is different because of multiple NICs that host is accessible on . It s not to have a service accessible by HTTP and HTTPS - those are actually two different service contract IDs . So if you have multiple access points that are actually providing connection Information for different contracts then you ve done something wrong . | 84 | 93 |
137,996 | public Matrix3 set ( double [ ] values ) { return set ( values [ 0 ] , values [ 1 ] , values [ 2 ] , values [ 3 ] , values [ 4 ] , values [ 5 ] , values [ 6 ] , values [ 7 ] , values [ 8 ] ) ; } | Copies the elements of an array . | 61 | 8 |
137,997 | public Matrix3 set ( double m00 , double m10 , double m20 , double m01 , double m11 , double m21 , double m02 , double m12 , double m22 ) { this . m00 = m00 ; this . m01 = m01 ; this . m02 = m02 ; this . m10 = m10 ; this . m11 = m11 ; this . m12 = m12 ; this . m20 = m20 ; this . m21 = m21 ; this . m22 = m22 ; return this ; } | Sets all of the matrix s components at once . | 118 | 11 |
137,998 | private String ipAddressFromURL ( String url , String name ) { String ipAddr = null ; if ( _urlValidator . isValid ( url ) ) { WebTarget resolver = ClientBuilder . newClient ( ) . target ( url ) ; try { ipAddr = resolver . request ( ) . get ( String . class ) ; } catch ( Exception e ) { warn ( "URL Cannot Resolve for resolveIP named [" + name + "]. The requested URL is invalid [" + url + "]." ) ; } } else { warn ( "The requested URL for resolveIP named [" + name + "] is invalid [" + url + "]." ) ; } return ipAddr ; } | Resolve the IP address from a URL . | 147 | 9 |
137,999 | public RtpPacket protect ( RtpPacket packet ) { if ( txSessEncKey == null ) { log ( "protect() called out of session" ) ; return null ; } if ( packet == null ) { log ( "protect() called with null RTP packet" ) ; return null ; } int seqNum = packet . getSequenceNumber ( ) ; if ( seqNum == 0 ) { // wrapped round rollOverCounter += 0x10000 L ; } RtpPacket retPacket = null ; if ( ! transformPayload ( packet , rollOverCounter , seqNum , txSessSaltKey , true ) ) { log ( "protect() transformPayload error, encryption failed" ) ; return null ; } // Add authentication which is over whole rtp packet concatenated with // 48 bit ROC byte [ ] auth = null ; try { auth = getAuthentication ( packet , rollOverCounter , true ) ; // iTxSessAuthKey); if ( VERBOSE ) { log ( "protect() Adding HMAC:" ) ; logBuffer ( "auth:" , auth ) ; } } catch ( Throwable e ) { logError ( "protect() Authentication error EX: " + e ) ; e . printStackTrace ( ) ; return null ; } // aPacket should have getHmacAuthSizeBytes() bytes pre-allocated for the // auth-code // assert(aPacket.getPacket().length >= aPacket.getLength() + // getHmacAuthSizeBytes()); System . arraycopy ( auth , 0 , packet . getPacket ( ) , packet . getLength ( ) , getHmacAuthSizeBytes ( ) ) ; packet . setPayloadLength ( packet . getPayloadLength ( ) + getHmacAuthSizeBytes ( ) ) ; retPacket = packet ; if ( SUPER_VERBOSE ) { logBuffer ( "protect() After adding HMAC: " , retPacket . getPacket ( ) ) ; } return retPacket ; } | Protects an RTP Packet by encrypting payload and adds any additional SRTP trailer information | 430 | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.