idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
8,600 | public static long getNextMidnight ( Time recycle , long theTime , String tz ) { if ( recycle == null ) { recycle = new Time ( ) ; } recycle . timezone = tz ; recycle . set ( theTime ) ; recycle . monthDay ++ ; recycle . hour = 0 ; recycle . minute = 0 ; recycle . second = 0 ; return recycle . normalize ( true ) ; } | Finds and returns the next midnight after theTime in milliseconds UTC |
8,601 | public static void checkForDuplicateNames ( Map < String , Boolean > isDuplicateName , Cursor cursor , int nameIndex ) { isDuplicateName . clear ( ) ; cursor . moveToPosition ( - 1 ) ; while ( cursor . moveToNext ( ) ) { String displayName = cursor . getString ( nameIndex ) ; if ( displayName != null ) { isDuplicateName . put ( displayName , isDuplicateName . containsKey ( displayName ) ) ; } } } | Scan through a cursor of calendars and check if names are duplicated . This travels a cursor containing calendar display names and fills in the provided map with whether or not each name is repeated . |
8,602 | public static int getDisplayColorFromColor ( int color ) { if ( ! isJellybeanOrLater ( ) ) { return color ; } float [ ] hsv = new float [ 3 ] ; Color . colorToHSV ( color , hsv ) ; hsv [ 1 ] = Math . min ( hsv [ 1 ] * SATURATION_ADJUST , 1.0f ) ; hsv [ 2 ] = hsv [ 2 ] * INTENSITY_ADJUST ; return Color . HSVToColor ( hsv ) ; } | For devices with Jellybean or later darkens the given color to ensure that white text is clearly visible on top of it . For devices prior to Jellybean does nothing as the sync adapter handles the color change . |
8,603 | public static int getDeclinedColorFromColor ( int color ) { int bg = 0xffffffff ; int a = DECLINED_EVENT_ALPHA ; int r = ( ( ( color & 0x00ff0000 ) * a ) + ( ( bg & 0x00ff0000 ) * ( 0xff - a ) ) ) & 0xff000000 ; int g = ( ( ( color & 0x0000ff00 ) * a ) + ( ( bg & 0x0000ff00 ) * ( 0xff - a ) ) ) & 0x00ff0000 ; int b = ( ( ( color & 0x000000ff ) * a ) + ( ( bg & 0x000000ff ) * ( 0xff - a ) ) ) & 0x0000ff00 ; return ( 0xff000000 ) | ( ( r | g | b ) >> 8 ) ; } | white . The result is the color that should be used for declined events . |
8,604 | private static void weaveDNAStrands ( LinkedList < DNASegment > segments , int firstJulianDay , HashMap < Integer , DNAStrand > strands , int top , int bottom , int [ ] dayXs ) { Iterator < DNAStrand > strandIterator = strands . values ( ) . iterator ( ) ; while ( strandIterator . hasNext ( ) ) { DNAStrand strand = strandIterator . next ( ) ; if ( strand . count < 1 && strand . allDays == null ) { strandIterator . remove ( ) ; continue ; } strand . points = new float [ strand . count * 4 ] ; strand . position = 0 ; } for ( DNASegment segment : segments ) { DNAStrand strand = strands . get ( segment . color ) ; int dayIndex = segment . day - firstJulianDay ; int dayStartMinute = segment . startMinute % DAY_IN_MINUTES ; int dayEndMinute = segment . endMinute % DAY_IN_MINUTES ; int height = bottom - top ; int workDayHeight = height * 3 / 4 ; int remainderHeight = ( height - workDayHeight ) / 2 ; int x = dayXs [ dayIndex ] ; int y0 = 0 ; int y1 = 0 ; y0 = top + getPixelOffsetFromMinutes ( dayStartMinute , workDayHeight , remainderHeight ) ; y1 = top + getPixelOffsetFromMinutes ( dayEndMinute , workDayHeight , remainderHeight ) ; if ( DEBUG ) { Log . d ( TAG , "Adding " + Integer . toHexString ( segment . color ) + " at x,y0,y1: " + x + " " + y0 + " " + y1 + " for " + dayStartMinute + " " + dayEndMinute ) ; } strand . points [ strand . position ++ ] = x ; strand . points [ strand . position ++ ] = y0 ; strand . points [ strand . position ++ ] = x ; strand . points [ strand . position ++ ] = y1 ; } } | list of points to draw |
8,605 | private static int getPixelOffsetFromMinutes ( int minute , int workDayHeight , int remainderHeight ) { int y ; if ( minute < WORK_DAY_START_MINUTES ) { y = minute * remainderHeight / WORK_DAY_START_MINUTES ; } else if ( minute < WORK_DAY_END_MINUTES ) { y = remainderHeight + ( minute - WORK_DAY_START_MINUTES ) * workDayHeight / WORK_DAY_MINUTES ; } else { y = remainderHeight + workDayHeight + ( minute - WORK_DAY_END_MINUTES ) * remainderHeight / WORK_DAY_END_LENGTH ; } return y ; } | Compute a pixel offset from the top for a given minute from the work day height and the height of the top area . |
8,606 | private static DNAStrand getOrCreateStrand ( HashMap < Integer , DNAStrand > strands , int color ) { DNAStrand strand = strands . get ( color ) ; if ( strand == null ) { strand = new DNAStrand ( ) ; strand . color = color ; strand . count = 0 ; strands . put ( strand . color , strand ) ; } return strand ; } | Try to get a strand of the given color . Create it if it doesn t exist . |
8,607 | public static void setUpSearchView ( SearchView view , Activity act ) { SearchManager searchManager = ( SearchManager ) act . getSystemService ( Context . SEARCH_SERVICE ) ; view . setSearchableInfo ( searchManager . getSearchableInfo ( act . getComponentName ( ) ) ) ; view . setQueryRefinementEnabled ( true ) ; } | This sets up a search view to use Calendar s search suggestions provider and to allow refining the search . |
8,608 | public static void setMidnightUpdater ( Handler h , Runnable r , String timezone ) { if ( h == null || r == null || timezone == null ) { return ; } long now = System . currentTimeMillis ( ) ; Time time = new Time ( timezone ) ; time . set ( now ) ; long runInMillis = ( 24 * 3600 - time . hour * 3600 - time . minute * 60 - time . second + 1 ) * 1000 ; h . removeCallbacks ( r ) ; h . postDelayed ( r , runInMillis ) ; } | do run the runnable |
8,609 | public static void resetMidnightUpdater ( Handler h , Runnable r ) { if ( h == null || r == null ) { return ; } h . removeCallbacks ( r ) ; } | Stop the midnight update thread |
8,610 | public static String getDisplayedTimezone ( long startMillis , String localTimezone , String eventTimezone ) { String tzDisplay = null ; if ( ! TextUtils . equals ( localTimezone , eventTimezone ) ) { TimeZone tz = TimeZone . getTimeZone ( localTimezone ) ; if ( tz == null || tz . getID ( ) . equals ( "GMT" ) ) { tzDisplay = localTimezone ; } else { Time startTime = new Time ( localTimezone ) ; startTime . set ( startMillis ) ; tzDisplay = tz . getDisplayName ( startTime . isDst != 0 , TimeZone . SHORT ) ; } } return tzDisplay ; } | Returns the timezone to display in the event info if the local timezone is different from the event timezone . Otherwise returns null . |
8,611 | private static boolean singleDayEvent ( long startMillis , long endMillis , long localGmtOffset ) { if ( startMillis == endMillis ) { return true ; } int startDay = Time . getJulianDay ( startMillis , localGmtOffset ) ; int endDay = Time . getJulianDay ( endMillis - 1 , localGmtOffset ) ; return startDay == endDay ; } | Returns whether the specified time interval is in a single day . |
8,612 | private static int isTodayOrTomorrow ( Resources r , long dayMillis , long currentMillis , long localGmtOffset ) { int startDay = Time . getJulianDay ( dayMillis , localGmtOffset ) ; int currentDay = Time . getJulianDay ( currentMillis , localGmtOffset ) ; int days = startDay - currentDay ; if ( days == 1 ) { return TOMORROW ; } else if ( days == 0 ) { return TODAY ; } else { return NONE ; } } | Returns TODAY or TOMORROW if applicable . Otherwise returns NONE . |
8,613 | public static Intent createEmailAttendeesIntent ( Resources resources , String eventTitle , String body , List < String > toEmails , List < String > ccEmails , String ownerAccount ) { List < String > toList = toEmails ; List < String > ccList = ccEmails ; if ( toEmails . size ( ) <= 0 ) { if ( ccEmails . size ( ) <= 0 ) { throw new IllegalArgumentException ( "Both toEmails and ccEmails are empty." ) ; } toList = ccEmails ; ccList = null ; } String subject = null ; if ( eventTitle != null ) { subject = resources . getString ( R . string . email_subject_prefix ) + eventTitle ; } Uri . Builder uriBuilder = new Uri . Builder ( ) ; uriBuilder . scheme ( "mailto" ) ; if ( toList . size ( ) > 1 ) { for ( int i = 1 ; i < toList . size ( ) ; i ++ ) { uriBuilder . appendQueryParameter ( "to" , toList . get ( i ) ) ; } } if ( subject != null ) { uriBuilder . appendQueryParameter ( "subject" , subject ) ; } if ( body != null ) { uriBuilder . appendQueryParameter ( "body" , body ) ; } if ( ccList != null && ccList . size ( ) > 0 ) { for ( String email : ccList ) { uriBuilder . appendQueryParameter ( "cc" , email ) ; } } String uri = uriBuilder . toString ( ) ; if ( uri . startsWith ( "mailto:" ) ) { StringBuilder builder = new StringBuilder ( uri ) ; builder . insert ( 7 , Uri . encode ( toList . get ( 0 ) ) ) ; uri = builder . toString ( ) ; } Intent emailIntent = new Intent ( Intent . ACTION_SENDTO , Uri . parse ( uri ) ) ; emailIntent . putExtra ( "fromAccountString" , ownerAccount ) ; if ( body != null ) { emailIntent . putExtra ( Intent . EXTRA_TEXT , body ) ; } return Intent . createChooser ( emailIntent , resources . getString ( R . string . email_picker_label ) ) ; } | Create an intent for emailing attendees of an event . |
8,614 | public static String getVersionCode ( Context context ) { if ( sVersion == null ) { try { sVersion = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) . versionName ; } catch ( PackageManager . NameNotFoundException e ) { Log . e ( TAG , "Error finding package " + context . getApplicationInfo ( ) . packageName ) ; } } return sVersion ; } | Return the app version code . |
8,615 | private static int findNanpMatchEnd ( CharSequence text , int startPos ) { if ( text . length ( ) > startPos + 4 && text . subSequence ( startPos , startPos + 4 ) . toString ( ) . equalsIgnoreCase ( "tel:" ) ) { startPos += 4 ; } int endPos = text . length ( ) ; int curPos = startPos ; int foundDigits = 0 ; char firstDigit = 'x' ; boolean foundWhiteSpaceAfterAreaCode = false ; while ( curPos <= endPos ) { char ch ; if ( curPos < endPos ) { ch = text . charAt ( curPos ) ; } else { ch = 27 ; } if ( Character . isDigit ( ch ) ) { if ( foundDigits == 0 ) { firstDigit = ch ; } foundDigits ++ ; if ( foundDigits > NANP_MAX_DIGITS ) { return - 1 ; } } else if ( Character . isWhitespace ( ch ) ) { if ( ( firstDigit == '1' && foundDigits == 4 ) || ( foundDigits == 3 ) ) { foundWhiteSpaceAfterAreaCode = true ; } else if ( firstDigit == '1' && foundDigits == 1 ) { } else if ( foundWhiteSpaceAfterAreaCode && ( ( firstDigit == '1' && ( foundDigits == 7 ) ) || ( foundDigits == 6 ) ) ) { } else { break ; } } else if ( NANP_ALLOWED_SYMBOLS . indexOf ( ch ) == - 1 ) { break ; } curPos ++ ; } if ( ( firstDigit != '1' && ( foundDigits == 7 || foundDigits == 10 ) ) || ( firstDigit == '1' && foundDigits == 11 ) ) { return curPos ; } return - 1 ; } | Checks to see if there is a valid phone number in the input starting at the specified offset . If so the index of the last character + 1 is returned . The input is assumed to begin with a non - whitespace character . |
8,616 | private static boolean spanWillOverlap ( Spannable spanText , URLSpan [ ] spanList , int start , int end ) { if ( start == end ) { return false ; } for ( URLSpan span : spanList ) { int existingStart = spanText . getSpanStart ( span ) ; int existingEnd = spanText . getSpanEnd ( span ) ; if ( ( start >= existingStart && start < existingEnd ) || end > existingStart && end <= existingEnd ) { if ( Log . isLoggable ( TAG , Log . VERBOSE ) ) { CharSequence seq = spanText . subSequence ( start , end ) ; Log . v ( TAG , "Not linkifying " + seq + " as phone number due to overlap" ) ; } return true ; } } return false ; } | Determines whether a new span at [ start end ) will overlap with any existing span . |
8,617 | private static int dayToUtilDay ( int day ) { switch ( day ) { case EventRecurrence . SU : return Calendar . SUNDAY ; case EventRecurrence . MO : return Calendar . MONDAY ; case EventRecurrence . TU : return Calendar . TUESDAY ; case EventRecurrence . WE : return Calendar . WEDNESDAY ; case EventRecurrence . TH : return Calendar . THURSDAY ; case EventRecurrence . FR : return Calendar . FRIDAY ; case EventRecurrence . SA : return Calendar . SATURDAY ; default : throw new IllegalArgumentException ( "bad day argument: " + day ) ; } } | Converts EventRecurrence s day of week to DateUtil s day of week . |
8,618 | protected static String reportURL ( String type ) throws EasyPostException { try { String urlType = URLEncoder . encode ( type , "UTF-8" ) . toLowerCase ( ) ; return String . format ( "%s/reports/%s/" , EasyPost . API_BASE , urlType ) ; } catch ( java . io . UnsupportedEncodingException e ) { throw new EasyPostException ( "Undetermined Report Type" ) ; } } | generate report URL pattern |
8,619 | public Item retrieveReference ( String name , String value ) throws EasyPostException { return retrieveReference ( name , value , null ) ; } | retrieve by custom reference |
8,620 | private URI getOriginalUri ( HttpServletRequest request ) { String requestUrl = request . getRequestURL ( ) . toString ( ) ; String incomingScheme = URI . create ( requestUrl ) . getScheme ( ) ; String originalScheme = request . getHeader ( "X-Forwarded-Proto" ) ; if ( originalScheme != null && ! incomingScheme . equals ( originalScheme ) ) { return URI . create ( requestUrl . replaceFirst ( "^" + incomingScheme , originalScheme ) ) ; } else { return URI . create ( requestUrl ) ; } } | Return the URL as it was originally received from a possible frontend proxy . |
8,621 | private static byte [ ] hmacSha ( String crypto , byte [ ] keyBytes , byte [ ] text ) { try { Mac hmac ; hmac = Mac . getInstance ( crypto ) ; SecretKeySpec macKey = new SecretKeySpec ( keyBytes , "RAW" ) ; hmac . init ( macKey ) ; return hmac . doFinal ( text ) ; } catch ( GeneralSecurityException gse ) { throw new UndeclaredThrowableException ( gse ) ; } } | This method uses the JCE to provide the crypto algorithm . HMAC computes a Hashed Message Authentication Code with the crypto hash algorithm as a parameter . |
8,622 | public static int generateTOTP ( byte [ ] key , long time , int digits , String crypto ) { byte [ ] msg = ByteBuffer . allocate ( 8 ) . putLong ( time ) . array ( ) ; byte [ ] hash = hmacSha ( crypto , key , msg ) ; int offset = hash [ hash . length - 1 ] & 0xf ; int binary = ( ( hash [ offset ] & 0x7f ) << 24 ) | ( ( hash [ offset + 1 ] & 0xff ) << 16 ) | ( ( hash [ offset + 2 ] & 0xff ) << 8 ) | ( hash [ offset + 3 ] & 0xff ) ; int otp = binary % DIGITS_POWER [ digits ] ; return otp ; } | This method generates a TOTP value for the given set of parameters . |
8,623 | @ SuppressWarnings ( "unchecked" ) public final List < RegisteredService > loadServices ( ) { logger . info ( "Loading Registered Services from: [ {} ]..." , this . servicesConfigFile ) ; final List < RegisteredService > resolvedServices = new ArrayList < RegisteredService > ( ) ; try { final Map < String , List > m = unmarshalServicesRegistryResourceIntoMap ( ) ; if ( m != null ) { final Iterator < Map > i = m . get ( SERVICES_KEY ) . iterator ( ) ; while ( i . hasNext ( ) ) { final Map < ? , ? > record = i . next ( ) ; final String svcId = ( ( String ) record . get ( SERVICES_ID_KEY ) ) ; final RegisteredService svc = getRegisteredServiceInstance ( svcId ) ; if ( svc != null ) { resolvedServices . add ( this . objectMapper . convertValue ( record , svc . getClass ( ) ) ) ; logger . debug ( "Unmarshaled {}: {}" , svc . getClass ( ) . getSimpleName ( ) , record ) ; } } synchronized ( this . mutexMonitor ) { this . delegateServiceRegistryDao . setRegisteredServices ( resolvedServices ) ; } } } catch ( final Throwable e ) { throw new RuntimeException ( e ) ; } return resolvedServices ; } | This method is used as a Spring bean loadServices - method as well as the reloading method when the change in the services definition resource is detected at runtime |
8,624 | public void init ( ) throws Exception { try { unmarshalAndSetBackingMap ( ) ; } catch ( final ClassCastException ex ) { throw new BeanCreationException ( String . format ( "The semantic structure of the person attributes JSON config is not correct. Please fix it in this resource: [%s]" , this . personAttributesConfigFile . getURI ( ) ) ) ; } } | Init method un - marshals JSON representation of the person attributes . |
8,625 | public void onApplicationEvent ( final ResourceChangeDetectingEventNotifier . ResourceChangedEvent resourceChangedEvent ) { try { if ( ! resourceChangedEvent . getResourceUri ( ) . equals ( this . personAttributesConfigFile . getURI ( ) ) ) { return ; } } catch ( final Throwable e ) { logger . error ( "An exception is caught while trying to access JSON resource: " , e ) ; return ; } final Map < String , Map < String , List < Object > > > savedBackingMap ; synchronized ( this . synchronizationMonitor ) { savedBackingMap = super . getBackingMap ( ) ; } try { unmarshalAndSetBackingMap ( ) ; } catch ( final Throwable ex ) { logger . error ( "An exception is caught during reloading of the JSON configuration:" , ex ) ; synchronized ( this . synchronizationMonitor ) { super . setBackingMap ( savedBackingMap ) ; } } } | Reload person attributes when JSON config is changed . In case of un - marshaling errors or any other errors do not disturb running CAS server by propagating the exceptions but instead log the error and leave the previously cached person attributes state alone . |
8,626 | void init ( ) throws Throwable { if ( this . digestAlgorithmName != null ) { this . hashService . setHashAlgorithmName ( this . digestAlgorithmName ) ; } if ( this . hashIterations > 0 ) { this . hashService . setHashIterations ( this . hashIterations ) ; } } | This method is only intended to be called by the infrastructure code managing instances of this class once during initialization of this instance |
8,627 | public OutlookMessage parseMsg ( final InputStream msgFileStream ) throws IOException { final OutlookMessage msg = new OutlookMessage ( rtf2htmlConverter ) ; try { checkDirectoryEntry ( new POIFSFileSystem ( msgFileStream ) . getRoot ( ) , msg ) ; } finally { msgFileStream . close ( ) ; } convertHeaders ( msg ) ; return msg ; } | Parses a . msg file provided by an input stream . |
8,628 | private byte [ ] getBytesFromStream ( final InputStream dstream ) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; final byte [ ] buffer = new byte [ 1024 ] ; int read ; while ( ( read = dstream . read ( buffer ) ) > 0 ) { baos . write ( buffer , 0 , read ) ; } return baos . toByteArray ( ) ; } | Reads the bytes from the stream to a byte array . |
8,629 | public void setProperty ( final OutlookMessageProperty msgProp ) { final String name = msgProp . getClazz ( ) ; final Object value = msgProp . getData ( ) ; if ( name != null && value != null ) { switch ( name ) { case "3701" : setSize ( msgProp . getSize ( ) ) ; setData ( ( byte [ ] ) value ) ; break ; case "3704" : setFilename ( ( String ) value ) ; break ; case "3707" : setLongFilename ( ( String ) value ) ; break ; case "370e" : setMimeTag ( ( String ) value ) ; break ; case "3703" : setExtension ( ( String ) value ) ; break ; default : } } } | Sets the property specified by the name parameter . Unknown names are ignored . |
8,630 | private String getStringResource ( String path ) { InputStream in = getClass ( ) . getResourceAsStream ( path ) ; StringBuilder index = new StringBuilder ( ) ; char [ ] buffer = new char [ 1024 ] ; int read = 0 ; try ( InputStreamReader reader = new InputStreamReader ( in ) ) { while ( ( read = reader . read ( buffer ) ) != - 1 ) { index . append ( buffer , 0 , read ) ; } } catch ( IOException e ) { return index . toString ( ) ; } return index . toString ( ) ; } | read the description contained in the index . html file |
8,631 | public Service getServiceObjectFromId ( String id ) { log . fine ( "Return service object for " + id ) ; Service service = null ; for ( Service s : services . getServices ( ) ) { if ( id . equals ( s . getId ( ) ) ) { return s ; } } return service ; } | Returns the service object associated with the given id |
8,632 | public File createGitRepository ( String repositoryName ) throws IOException { RepositoryService service = new RepositoryService ( ) ; service . getClient ( ) . setOAuth2Token ( oAuthToken ) ; Repository repository = new Repository ( ) ; repository . setName ( repositoryName ) ; repository = service . createRepository ( repository ) ; repositoryLocation = repository . getHtmlUrl ( ) ; CloneCommand cloneCommand = Git . cloneRepository ( ) . setURI ( repository . getCloneUrl ( ) ) . setDirectory ( localGitDirectory ) ; addAuth ( cloneCommand ) ; try { localRepository = cloneCommand . call ( ) ; } catch ( GitAPIException e ) { throw new IOException ( "Error cloning to local file system" , e ) ; } return localGitDirectory ; } | Creates a repository on GitHub and in a local temporary directory . This is a one time operation as once it is created on GitHub and locally it cannot be recreated . |
8,633 | public static boolean hasChildNode ( Node parentNode , String nodeName ) { return getChildNode ( parentNode , nodeName , null ) != null ? true : false ; } | Determine if the parent node contains a child node with matching name |
8,634 | public static Node getChildNode ( Node parentNode , String name , String value ) { List < Node > matchingChildren = getChildren ( parentNode , name , value ) ; return ( matchingChildren . size ( ) > 0 ) ? matchingChildren . get ( 0 ) : null ; } | Get the matching child node |
8,635 | public static Node getGrandchildNode ( Node parentNode , String childNodeName , String grandChildNodeName , String grandChildNodeValue ) { List < Node > matchingChildren = getChildren ( parentNode , childNodeName , null ) ; for ( Node child : matchingChildren ) { Node matchingGrandChild = getChildNode ( child , grandChildNodeName , grandChildNodeValue ) ; if ( matchingGrandChild != null ) { return matchingGrandChild ; } } return null ; } | Get the matching grand child node |
8,636 | private static List < Node > getChildren ( Node parentNode , String name , String value ) { List < Node > childNodes = new ArrayList < Node > ( ) ; if ( parentNode == null || name == null ) { return childNodes ; } if ( parentNode . getNodeType ( ) == Node . ELEMENT_NODE && parentNode . hasChildNodes ( ) ) { NodeList children = parentNode . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node child = children . item ( i ) ; if ( child != null && name . equals ( child . getNodeName ( ) ) && ( value == null || value . equals ( child . getTextContent ( ) ) ) ) { childNodes . add ( child ) ; } } } return childNodes ; } | Get all matching child nodes |
8,637 | public static Node addChildNode ( Document doc , Node parentNode , String childName , String childValue ) { if ( doc == null || parentNode == null || childName == null ) { return null ; } Node childNode = doc . createElement ( childName ) ; if ( childValue != null ) { childNode . setTextContent ( childValue ) ; } parentNode . appendChild ( childNode ) ; return childNode ; } | Add a child node |
8,638 | public static Node findOrAddChildNode ( Document doc , Node parentNode , String childName , String childValue ) { Node matchingChild = getChildNode ( parentNode , childName , childValue ) ; return matchingChild != null ? matchingChild : addChildNode ( doc , parentNode , childName , childValue ) ; } | Get the matching child node . Create a node if it doens t already exist |
8,639 | public WebElement waitForElement ( By by ) { int attempts = 0 ; int size = driver . findElements ( by ) . size ( ) ; while ( size == 0 ) { size = driver . findElements ( by ) . size ( ) ; if ( attempts == MAX_ATTEMPTS ) fail ( String . format ( "Could not find %s after %d seconds" , by . toString ( ) , MAX_ATTEMPTS ) ) ; attempts ++ ; try { Thread . sleep ( 1000 ) ; } catch ( Exception x ) { fail ( "Failed due to an exception during Thread.sleep!" ) ; x . printStackTrace ( ) ; } } if ( size > 1 ) System . err . println ( "WARN: There are more than 1 " + by . toString ( ) + " 's!" ) ; return driver . findElement ( by ) ; } | Method that acts as an arbiter of implicit timeouts of sorts .. sort of like a Wait For Ajax method . |
8,640 | public String url ( ) { String url = "" ; if ( ! StringUtils . isEmpty ( baseUrl ( ) ) ) { url = baseUrl ( ) + path ( ) ; } else { if ( ! StringUtils . isEmpty ( properties . getProperty ( Constants . DEFAULT_PROPERTY_URL ) ) ) { url = properties . getProperty ( Constants . DEFAULT_PROPERTY_URL ) ; } if ( testConfig != null && ( ! StringUtils . isEmpty ( testConfig . url ( ) ) ) ) { url = testConfig . url ( ) ; } if ( ! StringUtils . isEmpty ( JvmUtil . getJvmProperty ( Constants . JVM_CONDUCTOR_URL ) ) ) { url = JvmUtil . getJvmProperty ( Constants . JVM_CONDUCTOR_URL ) ; } } return url ; } | Url that automated tests will be testing . |
8,641 | public static IDataSource create ( JsonObject config ) throws DataSourceCreationException { String title = config . getAsJsonPrimitive ( "title" ) . getAsString ( ) ; String description = config . getAsJsonPrimitive ( "description" ) . getAsString ( ) ; String typeName = config . getAsJsonPrimitive ( "type" ) . getAsString ( ) ; JsonObject settings = config . getAsJsonObject ( "settings" ) ; final IDataSourceType type = DataSourceTypesRegistry . getType ( typeName ) ; if ( type == null ) throw new UnknownDataSourceTypeException ( typeName ) ; return type . createDataSource ( title , description , settings ) ; } | Create a datasource using a JSON config |
8,642 | private IDataSource getDataSource ( HttpServletRequest request ) throws DataSourceNotFoundException { String contextPath = request . getContextPath ( ) ; String requestURI = request . getRequestURI ( ) ; String path = contextPath == null ? requestURI : requestURI . substring ( contextPath . length ( ) ) ; if ( path . equals ( "/" ) || path . isEmpty ( ) ) { final String baseURL = FragmentRequestParserBase . extractBaseURL ( request , config ) ; return new IndexDataSource ( baseURL , dataSources ) ; } String dataSourceName = path . substring ( 1 ) ; IDataSource dataSource = dataSources . get ( dataSourceName ) ; if ( dataSource == null ) { throw new DataSourceNotFoundException ( dataSourceName ) ; } return dataSource ; } | Get the datasource |
8,643 | public void addMetadata ( final Model model ) { final Resource datasetId = model . createResource ( getDatasetURI ( ) ) ; final Resource fragmentId = model . createResource ( fragmentURL ) ; datasetId . addProperty ( CommonResources . RDF_TYPE , CommonResources . VOID_DATASET ) ; datasetId . addProperty ( CommonResources . RDF_TYPE , CommonResources . HYDRA_COLLECTION ) ; datasetId . addProperty ( CommonResources . VOID_SUBSET , fragmentId ) ; Literal itemsPerPage = model . createTypedLiteral ( this . getMaxPageSize ( ) ) ; datasetId . addProperty ( CommonResources . HYDRA_ITEMSPERPAGE , itemsPerPage ) ; fragmentId . addProperty ( CommonResources . RDF_TYPE , CommonResources . HYDRA_COLLECTION ) ; fragmentId . addProperty ( CommonResources . RDF_TYPE , CommonResources . HYDRA_PAGEDCOLLECTION ) ; } | Adds some basic metadata to the given RDF model . This method may be overridden in subclasses . |
8,644 | public void addControls ( final Model model ) { final URIBuilder pagedURL ; try { pagedURL = new URIBuilder ( fragmentURL ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( e ) ; } final Resource fragmentId = model . createResource ( fragmentURL ) ; final Resource firstPageId = model . createResource ( pagedURL . setParameter ( ILinkedDataFragmentRequest . PARAMETERNAME_PAGE , "1" ) . toString ( ) ) ; fragmentId . addProperty ( CommonResources . HYDRA_FIRSTPAGE , firstPageId ) ; if ( pageNumber > 1 ) { final String prevPageNumber = Long . toString ( pageNumber - 1 ) ; final Resource prevPageId = model . createResource ( pagedURL . setParameter ( ILinkedDataFragmentRequest . PARAMETERNAME_PAGE , prevPageNumber ) . toString ( ) ) ; fragmentId . addProperty ( CommonResources . HYDRA_PREVIOUSPAGE , prevPageId ) ; } if ( ! isLastPage ) { final String nextPageNumber = Long . toString ( pageNumber + 1 ) ; final Resource nextPageId = model . createResource ( pagedURL . setParameter ( ILinkedDataFragmentRequest . PARAMETERNAME_PAGE , nextPageNumber ) . toString ( ) ) ; fragmentId . addProperty ( CommonResources . HYDRA_NEXTPAGE , nextPageId ) ; } } | Adds an RDF description of page links to the given RDF model . This method may be overridden in subclasses . |
8,645 | private Triple toTriple ( TripleID tripleId ) { return new Triple ( dictionary . getNode ( tripleId . getSubject ( ) , TripleComponentRole . SUBJECT ) , dictionary . getNode ( tripleId . getPredicate ( ) , TripleComponentRole . PREDICATE ) , dictionary . getNode ( tripleId . getObject ( ) , TripleComponentRole . OBJECT ) ) ; } | Converts the HDT triple to a Jena Triple . |
8,646 | public ElasticsearchContainer withSecureSetting ( String key , String value ) { securedKeys . put ( key , value ) ; return this ; } | Define the elasticsearch docker registry base url |
8,647 | public ElasticsearchContainer withPluginDir ( Path pluginDir ) { if ( pluginDir == null ) { return this ; } this . pluginDir = createVolumeDirectory ( true ) ; addFileSystemBind ( this . pluginDir . toString ( ) , "/plugins" , BindMode . READ_ONLY ) ; logger ( ) . debug ( "Installing plugins from [{}]" , pluginDir ) ; try { Files . list ( pluginDir ) . forEach ( path -> { logger ( ) . trace ( "File found in [{}]: [{}]" , pluginDir , path ) ; if ( path . toString ( ) . endsWith ( ".zip" ) ) { logger ( ) . debug ( "Copying [{}] to [{}]" , path . getFileName ( ) , this . pluginDir . toAbsolutePath ( ) . toString ( ) ) ; try { Files . copy ( path , this . pluginDir . resolve ( path . getFileName ( ) ) ) ; withPlugin ( "file:///tmp/plugins/" + path . getFileName ( ) ) ; } catch ( IOException e ) { logger ( ) . error ( "Error while copying" , e ) ; } } } ) ; } catch ( IOException e ) { logger ( ) . error ( "Error listing plugins" , e ) ; } return this ; } | Path to plugin dir which contains plugins that needs to be installed |
8,648 | public void start ( ) { Thread thread = new Thread ( new LogCatCommandExecutor ( ) ) ; thread . setName ( getClass ( ) . getSimpleName ( ) + " logcat for " + device . getSerialNumber ( ) ) ; thread . start ( ) ; try { sleep ( 500 ) ; } catch ( InterruptedException e ) { } logListenerCommandShell . activate ( ) ; } | Start receiving and acting on paparazzo requests from the device . |
8,649 | public static RGBColor rgb ( int r , int g , int b ) { return new RGBColor ( makeRgb ( r , g , b ) ) ; } | RGB color as r g b triple . |
8,650 | public double cur ( Element elem , String prop , boolean force ) { if ( JsUtils . isWindow ( elem ) ) { if ( "width" . equals ( prop ) ) { return getContentDocument ( elem ) . getClientWidth ( ) ; } if ( "height" . equals ( prop ) ) { return getContentDocument ( elem ) . getClientHeight ( ) ; } elem = GQuery . body ; } if ( force && sizeRegex . test ( prop ) ) { } else if ( elem . getPropertyString ( prop ) != null && ( elem . getStyle ( ) == null || elem . getStyle ( ) . getProperty ( prop ) == null ) ) { return elem . getPropertyDouble ( prop ) ; } String val = curCSS ( elem , prop , force ) ; if ( "thick" . equalsIgnoreCase ( val ) ) { return 5 ; } else if ( "medium" . equalsIgnoreCase ( val ) ) { return 3 ; } else if ( "thin" . equalsIgnoreCase ( val ) ) { return 1 ; } if ( ! val . matches ( "^[\\d\\.]+.*$" ) ) { val = curCSS ( elem , prop , false ) ; } val = val . trim ( ) . replaceAll ( "[^\\d\\.\\-]+.*$" , "" ) ; return val . isEmpty ( ) ? 0 : Double . parseDouble ( val ) ; } | Returns the numeric value of a css property . |
8,651 | public String curCSS ( Element elem , String name , boolean force ) { if ( elem == null ) { return "" ; } name = fixPropertyName ( name ) ; String ret = elem . getStyle ( ) . getProperty ( name ) ; if ( force ) { Element toDetach = null ; if ( JsUtils . isDetached ( elem ) ) { toDetach = attachTemporary ( elem ) ; } if ( sizeRegex . test ( name ) ) { ret = getVisibleSize ( elem , name ) + "px" ; } else if ( "opacity" . equalsIgnoreCase ( name ) ) { ret = String . valueOf ( getOpacity ( elem ) ) ; } else { ret = getComputedStyle ( elem , JsUtils . hyphenize ( name ) , name , null ) ; } if ( toDetach != null ) { toDetach . removeFromParent ( ) ; } } return ret == null ? "" : ret ; } | Return the string value of a css property of an element . |
8,652 | private void fixInlineElement ( Element e ) { if ( e . getClientHeight ( ) == 0 && e . getClientWidth ( ) == 0 && "inline" . equals ( curCSS ( e , "display" , true ) ) ) { setStyleProperty ( e , "display" , "inline-block" ) ; setStyleProperty ( e , "width" , "auto" ) ; setStyleProperty ( e , "height" , "auto" ) ; } } | inline elements do not have width nor height unless we set it to inline - block |
8,653 | public void setStyleProperty ( Element e , String prop , String val ) { if ( e == null || prop == null ) { return ; } prop = fixPropertyName ( prop ) ; if ( prop . matches ( "^[A-Z]+$" ) ) { prop = prop . toLowerCase ( ) ; } prop = JsUtils . camelize ( prop ) ; if ( val == null || val . trim ( ) . length ( ) == 0 ) { removeStyleProperty ( e , prop ) ; } else { if ( val . matches ( "-?[\\d\\.]+" ) && ! cssNumberRegex . test ( prop ) ) { val += "px" ; } e . getStyle ( ) . setProperty ( prop , val ) ; } } | Set the value of a style property of an element . |
8,654 | public String defaultDisplay ( String tagName ) { String ret = elemdisplay . get ( tagName ) ; if ( ret == null ) { Element e = DOM . createElement ( tagName ) ; Document . get ( ) . getBody ( ) . appendChild ( e ) ; ret = curCSS ( e , "display" , false ) ; e . removeFromParent ( ) ; if ( ret == null || ret . matches ( "(|none)" ) ) { ret = "block" ; } elemdisplay . put ( tagName , ret ) ; } return ret ; } | Returns the default display value for each html tag . |
8,655 | public void setItems ( java . util . Collection < java . util . Map < String , AttributeValue > > items ) { if ( items == null ) { this . items = null ; return ; } java . util . List < java . util . Map < String , AttributeValue > > itemsCopy = new java . util . ArrayList < java . util . Map < String , AttributeValue > > ( items . size ( ) ) ; itemsCopy . addAll ( items ) ; this . items = itemsCopy ; } | Sets the value of the Items property for this object . |
8,656 | public void queueAnimation ( final GQAnimation anim , final int duration ) { if ( isOff ( ) ) { anim . onStart ( ) ; anim . onComplete ( ) ; } else { queue ( anim . e , DEFAULT_NAME , new Function ( ) { public void cancel ( Element e ) { Animation anim = ( Animation ) data ( e , GQAnimation . ACTUAL_ANIMATION , null ) ; if ( anim != null ) { anim . cancel ( ) ; } } public void f ( Element e ) { anim . run ( duration ) ; } } ) ; } } | Queue an animation for an element . |
8,657 | public static String vendorProperty ( String prop ) { return vendorPropNames . get ( prop ) != null ? vendorPropNames . get ( prop ) : prop ; } | Get the cached vendor property name . |
8,658 | public Effects slideToggle ( Function ... f ) { return as ( Effects ) . slideToggle ( Speed . DEFAULT , f ) ; } | Toggle the visibility of all matched elements by adjusting their height and firing an optional callback after completion . Only the height is adjusted for this animation causing all matched elements to be hidden or shown in a sliding manner |
8,659 | private void initResultsTable ( DeferredSelector [ ] dg , Benchmark ... benchs ) { int numRows = dg . length ; grid = new FlexTable ( ) ; grid . addStyleName ( "resultstable" ) ; RootPanel . get ( "results" ) . clear ( ) ; RootPanel . get ( "results" ) . add ( grid ) ; grid . setText ( 0 , 0 , "Selector" ) ; for ( int i = 0 ; i < benchs . length ; i ++ ) { grid . setText ( 0 , i + 1 , benchs [ i ] . getId ( ) ) ; } for ( int i = 0 ; i < numRows ; i ++ ) { grid . setText ( i + 1 , 0 , dg [ i ] . getSelector ( ) ) ; for ( int j = 0 ; j < benchs . length ; j ++ ) { grid . setText ( i + 1 , j + 1 , "-" ) ; } } } | Reset the result table |
8,660 | public Callbacks add ( com . google . gwt . core . client . Callback < ? , ? > ... c ) { addAll ( ( Object [ ] ) c ) ; return this ; } | Add a Callback or a collection of callbacks to a callback list . |
8,661 | public Callbacks fire ( Object ... o ) { if ( ! done ) { done = isOnce ; if ( isMemory ) { memory = new ArrayList < > ( Arrays . asList ( o ) ) ; } if ( stack != null ) for ( Object c : stack ) { if ( ! run ( c , o ) && stopOnFalse ) { break ; } } } return this ; } | Call all of the callbacks with the given arguments . |
8,662 | public synchronized void save ( String persistence ) { try { createObjectMapper ( ) . writeValue ( new File ( persistence ) , tableList ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } | Maybe save automatically on destroy? |
8,663 | public ObjectMapper createObjectMapper ( ) { ObjectMapper mapper = new ObjectMapper ( ) ; mapper . setVisibility ( PropertyAccessor . FIELD , JsonAutoDetect . Visibility . ANY ) . setVisibility ( PropertyAccessor . CREATOR , JsonAutoDetect . Visibility . ANY ) . setVisibility ( PropertyAccessor . SETTER , JsonAutoDetect . Visibility . NONE ) . setVisibility ( PropertyAccessor . GETTER , JsonAutoDetect . Visibility . NONE ) . setVisibility ( PropertyAccessor . IS_GETTER , JsonAutoDetect . Visibility . NONE ) ; mapper . configure ( SerializationFeature . FAIL_ON_EMPTY_BEANS , false ) ; return mapper ; } | Not sure about this . If correct and only need one only create one instance |
8,664 | public void setSS ( java . util . Collection < String > sS ) { if ( sS == null ) { this . sS = null ; return ; } java . util . List < String > sSCopy = new java . util . ArrayList < String > ( sS . size ( ) ) ; sSCopy . addAll ( sS ) ; this . sS = sSCopy ; } | A set of strings . |
8,665 | public void setNS ( java . util . Collection < String > nS ) { if ( nS == null ) { this . nS = null ; return ; } java . util . List < String > nSCopy = new java . util . ArrayList < String > ( nS . size ( ) ) ; nSCopy . addAll ( nS ) ; this . nS = nSCopy ; } | A set of numbers . |
8,666 | public void setBS ( java . util . Collection < java . nio . ByteBuffer > bS ) { if ( bS == null ) { this . bS = null ; return ; } java . util . List < java . nio . ByteBuffer > bSCopy = new java . util . ArrayList < java . nio . ByteBuffer > ( bS . size ( ) ) ; bSCopy . addAll ( bS ) ; this . bS = bSCopy ; } | A set of binary attributes . |
8,667 | public static Promise when ( Object ... d ) { int l = d . length ; Promise [ ] p = new Promise [ l ] ; for ( int i = 0 ; i < l ; i ++ ) { p [ i ] = makePromise ( d [ i ] ) ; } return when ( p ) ; } | Provides a way to execute callback functions based on one or more objects usually Deferred objects that represent asynchronous events . |
8,668 | protected void trigger ( GwtEvent < ? > e , Function callback , Element element ) { trigger ( e , callback , element , eventBus ) ; } | fire event and call callback function . |
8,669 | public Iterator < T > iterator ( ) { final List < T > allResultsCopy = new ArrayList < T > ( ) ; allResultsCopy . addAll ( allResults ) ; final Iterator < T > iter = allResultsCopy . iterator ( ) ; return new Iterator < T > ( ) { Iterator < T > iterator = iter ; int pos = 0 ; public boolean hasNext ( ) { return iterator . hasNext ( ) || nextResultsAvailable ( ) ; } public T next ( ) { if ( ! iterator . hasNext ( ) ) { if ( allResults . size ( ) == allResultsCopy . size ( ) ) { if ( ! nextResultsAvailable ( ) ) { throw new NoSuchElementException ( ) ; } moveNextResults ( ) ; } if ( allResults . size ( ) > allResultsCopy . size ( ) ) allResultsCopy . addAll ( allResults . subList ( allResultsCopy . size ( ) , allResults . size ( ) ) ) ; iterator = allResultsCopy . listIterator ( pos ) ; } pos ++ ; return iterator . next ( ) ; } public void remove ( ) { throw new UnsupportedOperationException ( UNMODIFIABLE_MESSAGE ) ; } } ; } | Returns an iterator over this list that lazily initializes results as necessary . |
8,670 | public List < T > subList ( int arg0 , int arg1 ) { while ( allResults . size ( ) < arg1 && nextResultsAvailable ( ) ) { moveNextResults ( ) ; } return Collections . unmodifiableList ( allResults . subList ( arg0 , arg1 ) ) ; } | Returns a sub - list in the range specified loading more results as necessary . |
8,671 | public int indexOf ( Object arg0 ) { int indexOf = allResults . indexOf ( arg0 ) ; if ( indexOf >= 0 ) return indexOf ; while ( nextResultsAvailable ( ) ) { indexOf = nextResults . indexOf ( arg0 ) ; int size = allResults . size ( ) ; moveNextResults ( ) ; if ( indexOf >= 0 ) return indexOf + size ; } return - 1 ; } | Returns the first index of the object given in the list . Additional results are loaded incrementally as necessary . |
8,672 | private static boolean supportsTransform3d ( ) { if ( transform == null ) { return false ; } String rotate = "rotateY(1deg)" ; divStyle . setProperty ( transform , rotate ) ; rotate = divStyle . getProperty ( transform ) ; return rotate != null && ! rotate . isEmpty ( ) ; } | Some browsers like HTMLUnit only support 2d transformations |
8,673 | public static String getVendorPropertyName ( String prop ) { String vendorProp = JsUtils . camelize ( "-" + prefix + "-" + prop ) ; if ( JsUtils . hasProperty ( divStyle , vendorProp ) ) { return vendorProp ; } if ( JsUtils . hasProperty ( divStyle , prop ) ) { return prop ; } String camelProp = JsUtils . camelize ( prop ) ; if ( JsUtils . hasProperty ( divStyle , camelProp ) ) { return camelProp ; } return null ; } | Compute the correct CSS property name for a specific browser vendor . |
8,674 | public static Transform getInstance ( Element e , String initial ) { Transform t = GQuery . data ( e , TRANSFORM ) ; if ( t == null || initial != null ) { if ( initial == null ) { initial = GQuery . getSelectorEngine ( ) . getDocumentStyleImpl ( ) . curCSS ( e , transform , false ) ; } t = new Transform ( initial ) ; GQuery . data ( e , TRANSFORM , t ) ; } return t ; } | Return the Transform dictionary object of an element but reseting historical values and setting them to the initial value passed . |
8,675 | private void parse ( String s ) { if ( s != null ) { for ( MatchResult r = transformParseRegex . exec ( s ) ; r != null ; r = transformParseRegex . exec ( s ) ) { setFromString ( vendorProperty ( r . getGroup ( 1 ) ) , r . getGroup ( 2 ) ) ; } } } | Parse a transform value as string and fills the dictionary map . |
8,676 | public void setFromString ( String prop , String ... val ) { if ( val . length == 1 ) { String [ ] vals = val [ 0 ] . split ( "[\\s,]+" ) ; set ( prop , vals ) ; } else { set ( prop , val ) ; } } | Set a transform multi - value giving either a set of strings or just an string of values separated by comma . |
8,677 | @ SuppressWarnings ( "unchecked" ) public T clearQueue ( String name ) { for ( Element e : elements ( ) ) { queue ( e , name , null ) . clear ( ) ; } return ( T ) this ; } | remove all queued function from the named queue . |
8,678 | @ SuppressWarnings ( "unchecked" ) public T delay ( int milliseconds , String name , Function ... funcs ) { for ( Element e : elements ( ) ) { queue ( e , name , new DelayFunction ( e , name , milliseconds , funcs ) ) ; } return ( T ) this ; } | Add a delay in the named queue . |
8,679 | @ SuppressWarnings ( "unchecked" ) public T dequeue ( String name ) { for ( Element e : elements ( ) ) { dequeueCurrentAndRunNext ( e , name ) ; } return ( T ) this ; } | Removes a queued function from the front of the named queue and executes it . |
8,680 | public Promise promise ( final String name ) { final Promise . Deferred dfd = Deferred ( ) ; final Function resolve = new Function ( ) { int count = 1 ; { for ( Element elem : elements ( ) ) { if ( queue ( elem , name , null ) != null ) { emptyHooks ( elem , name ) . add ( this ) ; count ++ ; } } } public void f ( ) { if ( -- count == 0 ) { dfd . resolve ( QueuePlugin . this ) ; } } } ; resolve . f ( this , name ) ; return dfd . promise ( ) ; } | Returns a dynamically generated Promise that is resolved once all actions in the named queue have ended . |
8,681 | public int queue ( String name ) { Queue < ? > q = isEmpty ( ) ? null : queue ( get ( 0 ) , name , null ) ; return q == null ? 0 : q . size ( ) ; } | Show the number of functions to be executed on the first matched element in the named queue . |
8,682 | @ SuppressWarnings ( "unchecked" ) public T queue ( Function ... funcs ) { for ( Element e : elements ( ) ) { for ( Function f : funcs ) { queue ( e , DEFAULT_NAME , f ) ; } } return ( T ) this ; } | Adds new functions to be executed onto the end of the effects queue of all matched elements . |
8,683 | @ SuppressWarnings ( "unchecked" ) public T queue ( final String name , Function ... funcs ) { for ( final Function f : funcs ) { for ( Element e : elements ( ) ) { queue ( e , name , f ) ; } } return ( T ) this ; } | Adds new functions to be executed onto the end of the named queue of all matched elements . |
8,684 | @ SuppressWarnings ( "unchecked" ) public T queue ( String name , Queue < ? > queue ) { for ( Element e : elements ( ) ) { replacequeue ( e , name , queue ) ; } return ( T ) this ; } | Replaces the current named queue with the given queue on all matched elements . |
8,685 | public void dequeueIfNotDoneYet ( Element elem , String name , Object object ) { @ SuppressWarnings ( "rawtypes" ) Queue queue = queue ( elem , name , null ) ; if ( queue != null && object . equals ( queue . peek ( ) ) ) { dequeueCurrentAndRunNext ( elem , name ) ; } } | Dequeue the object and run the next if it is the first in the queue . |
8,686 | public final Object f ( Object ... args ) { return dfd != null && ( cache == CacheType . ALL || cache == CacheType . RESOLVED && dfd . promise ( ) . isResolved ( ) || cache == CacheType . REJECTED && dfd . promise ( ) . isRejected ( ) ) ? dfd . promise ( ) : new PromiseFunction ( ) { public void f ( Deferred dfd ) { FunctionDeferred . this . resolve = resolve ; FunctionDeferred . this . reject = reject ; FunctionDeferred . this . dfd = dfd ; FunctionDeferred . this . f ( dfd ) ; } } ; } | This function is called when the previous promise in the pipe is resolved . |
8,687 | @ SuppressWarnings ( "unchecked" ) public < T extends JavaScriptObject > T getArgumentJSO ( int argIdx , int pos ) { return ( T ) getArgument ( argIdx , pos , JavaScriptObject . class ) ; } | Utility method for safety getting a JavaScriptObject present at a certain position in the list of arguments composed by arrays . |
8,688 | public Object [ ] getArgumentArray ( int idx ) { Object o = idx < 0 ? arguments : getArgument ( idx ) ; if ( o != null ) { return o . getClass ( ) . isArray ( ) ? ( Object [ ] ) o : new Object [ ] { o } ; } else if ( idx == 0 ) { return arguments ; } return new Object [ 0 ] ; } | Utility method for safety getting an array present at a certain position in the list of arguments . |
8,689 | public < T > T getArgument ( int idx , Class < ? extends T > type ) { return getArgument ( - 1 , idx , type ) ; } | Safety return the argument in the position idx . |
8,690 | @ SuppressWarnings ( "unchecked" ) public < T > T getArgument ( int argIdx , int pos , Class < ? extends T > type ) { Object [ ] objs = getArgumentArray ( argIdx ) ; Object o = objs . length > pos ? objs [ pos ] : null ; if ( o != null && ( type == null || o . getClass ( ) == type || type == JavaScriptObject . class && o instanceof JavaScriptObject ) ) { return ( T ) o ; } return null ; } | Utility method for safety getting an object present at a certain position in the list of arguments composed by arrays . |
8,691 | public Object f ( Widget w , int i ) { setElement ( w . getElement ( ) ) ; setIndex ( i ) ; f ( w ) ; return null ; } | Override this for GQuery methods which loop over matched widgets and invoke a callback on each widget . |
8,692 | public void f ( int i , Object ... args ) { setIndex ( i ) ; setArguments ( args ) ; if ( args . length == 1 && args [ 0 ] instanceof JavaScriptObject ) { if ( JsUtils . isElement ( ( JavaScriptObject ) args [ 0 ] ) ) { setElement ( ( com . google . gwt . dom . client . Element ) args [ 0 ] ) ; f ( getElement ( ) , i ) ; } else if ( JsUtils . isEvent ( ( JavaScriptObject ) args [ 0 ] ) ) { setEvent ( ( Event ) args [ 0 ] ) ; f ( getEvent ( ) ) ; } else { f ( ) ; } } } | Override this method for bound callbacks . |
8,693 | public boolean f ( Event e , Object ... arg ) { setArguments ( arg ) ; setEvent ( e ) ; return f ( e ) ; } | Override this method for bound event handlers if you wish to deal with per - handler user data . |
8,694 | public void f ( Widget w ) { setElement ( w . getElement ( ) ) ; if ( loop ) { loop = false ; f ( ) ; } else { f ( w . getElement ( ) . < com . google . gwt . dom . client . Element > cast ( ) ) ; } } | Override this for GQuery methods which take a callback but do not expect a return value apply to a single widget . |
8,695 | public static Promise ajax ( Settings settings ) { resolveSettings ( settings ) ; final Function onSuccess = settings . getSuccess ( ) ; if ( onSuccess != null ) { onSuccess . setElement ( settings . getContext ( ) ) ; } final Function onError = settings . getError ( ) ; if ( onError != null ) { onError . setElement ( settings . getContext ( ) ) ; } final String dataType = settings . getDataType ( ) ; Promise ret = null ; if ( "jsonp" . equalsIgnoreCase ( dataType ) ) { ret = GQ . getAjaxTransport ( ) . getJsonP ( settings ) ; } else if ( "loadscript" . equalsIgnoreCase ( dataType ) ) { ret = GQ . getAjaxTransport ( ) . getLoadScript ( settings ) ; } else { ret = GQ . getAjaxTransport ( ) . getXhr ( settings ) . then ( new Function ( ) { public Object f ( Object ... args ) { Response response = arguments ( 0 ) ; Request request = arguments ( 1 ) ; Object retData = response . getText ( ) ; if ( retData != null && ! "" . equals ( retData ) ) { try { if ( "xml" . equalsIgnoreCase ( dataType ) ) { retData = JsUtils . parseXML ( response . getText ( ) ) ; } else if ( "json" . equalsIgnoreCase ( dataType ) ) { retData = GQ . create ( response . getText ( ) ) ; } else { retData = response . getText ( ) ; if ( "script" . equalsIgnoreCase ( dataType ) ) { ScriptInjector . fromString ( ( String ) retData ) . setWindow ( window ) . inject ( ) ; } } } catch ( Exception e ) { if ( GWT . isClient ( ) && GWT . getUncaughtExceptionHandler ( ) != null ) { GWT . getUncaughtExceptionHandler ( ) . onUncaughtException ( e ) ; } else { e . printStackTrace ( ) ; } } } return new Object [ ] { retData , "success" , request , response } ; } } , new Function ( ) { public Object f ( Object ... args ) { Throwable exception = arguments ( 0 ) ; Request request = getArgument ( 1 , Request . class ) ; String msg = String . valueOf ( exception ) ; return new Object [ ] { null , msg , request , null , exception } ; } } ) ; } if ( onSuccess != null ) { ret . done ( onSuccess ) ; } if ( onError != null ) { ret . fail ( onError ) ; } return ret ; } | Perform an ajax request to the server . |
8,696 | public static final < T extends JavaScriptObject > T checkNull ( T js ) { if ( ! GWT . isProdMode ( ) && js == null ) { throw new NullPointerException ( ) ; } return js ; } | Throw a NPE when a js is null . |
8,697 | public static < T > T prop ( JavaScriptObject o , Object id , Class < ? extends T > type ) { return o == null ? null : o . < JsCache > cast ( ) . get ( id , type ) ; } | Returns a property present in a javascript object . |
8,698 | public static void prop ( JavaScriptObject o , Object id , Object val ) { if ( o != null ) { o . < JsCache > cast ( ) . put ( id , val ) ; } } | Set a property to a javascript object . |
8,699 | public static < T > T exec ( JavaScriptObject jsFunction , Object ... args ) { assert isFunction ( jsFunction ) ; return jsni ( jsFunction , "call" , jsFunction , args ) ; } | Execute a native javascript function . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.