idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
10,200 | public Cursor getItem ( int position ) { if ( mDataValid && mCursor != null ) { mCursor . moveToPosition ( position ) ; return mCursor ; } else { return null ; } } | Returns a cursor pointed to the given position . |
10,201 | public void execute ( ) throws MojoExecutionException { if ( skipProject ( ) ) { getLog ( ) . info ( "POM project detected; skipping" ) ; } else { URLClassLoader classLoader = new URLClassLoader ( generateClassPathUrls ( ) ) ; List < Class < ? > > interfaceClasses = loadServiceClasses ( classLoader ) ; Map < String , L... | The main entry point for this Mojo . |
10,202 | private void writeServiceFiles ( Map < String , List < String > > serviceImplementations ) throws MojoExecutionException { File parentFolder = new File ( getClassFolder ( ) , "META-INF" + File . separator + "services" ) ; if ( ! parentFolder . exists ( ) ) { parentFolder . mkdirs ( ) ; } for ( Entry < String , List < S... | Writes the output for the service files to disk |
10,203 | private List < Class < ? > > loadServiceClasses ( ClassLoader loader ) throws MojoExecutionException { List < Class < ? > > serviceClasses = new ArrayList < Class < ? > > ( ) ; for ( String serviceClassName : getServices ( ) ) { try { Class < ? > serviceClass = loader . loadClass ( serviceClassName ) ; serviceClasses .... | Loads all interfaces using the provided ClassLoader |
10,204 | private Map < String , List < String > > findImplementations ( ClassLoader loader , List < Class < ? > > interfaceClasses ) throws MojoExecutionException { Map < String , List < String > > serviceImplementations = new HashMap < String , List < String > > ( ) ; for ( String interfaceClassName : getServices ( ) ) { servi... | Finds all implementations of interfaces in a folder |
10,205 | List < String > listCompiledClasses ( final File classFolder ) { List < String > classNames = new ArrayList < String > ( ) ; if ( ! classFolder . exists ( ) ) { getLog ( ) . info ( "Class folder does not exist; skipping scan" ) ; return classNames ; } final String extension = ".class" ; final DirectoryScanner directory... | Walks the classFolder and finds all classes |
10,206 | private List < String > listCompiledClassesRegex ( File classFolder ) { List < String > classNames = new ArrayList < String > ( ) ; Stack < File > todo = new Stack < File > ( ) ; todo . push ( classFolder ) ; String classFolderPath = classFolder . getAbsolutePath ( ) ; getLog ( ) . info ( "ClassFolderPath=" + classFold... | Walks the classFolder and finds all . class files |
10,207 | public void auth ( ) throws DockerException { try { client . resource ( restEndpointUrl + "/auth" ) . header ( "Content-Type" , MediaType . APPLICATION_JSON ) . accept ( MediaType . APPLICATION_JSON ) . post ( authConfig ( ) ) ; } catch ( UniformInterfaceException e ) { throw new DockerException ( e ) ; } } | Authenticate with the server useful for checking authentication . |
10,208 | public ClientResponse push ( final String name ) throws DockerException { if ( name == null ) { throw new IllegalArgumentException ( "name is null" ) ; } try { final String registryAuth = registryAuth ( ) ; return client . resource ( restEndpointUrl + "/images/" + name ( name ) + "/push" ) . header ( "X-Registry-Auth" ... | Push the latest image to the repository . |
10,209 | public int tag ( String image , String repository , String tag , boolean force ) throws DockerException { Preconditions . checkNotNull ( image , "image was not specified" ) ; Preconditions . checkNotNull ( repository , "repository was not specified" ) ; Preconditions . checkNotNull ( tag , " tag was not provided" ) ; M... | Tag an image into a repository |
10,210 | public ImageCreateResponse importImage ( String repository , String tag , InputStream imageStream ) throws DockerException { Preconditions . checkNotNull ( repository , "Repository was not specified" ) ; Preconditions . checkNotNull ( imageStream , "imageStream was not provided" ) ; MultivaluedMap < String , String > p... | Create an image by importing the given stream of a tar file . |
10,211 | public void removeImage ( String imageId ) throws DockerException { Preconditions . checkState ( ! StringUtils . isEmpty ( imageId ) , "Image ID can't be empty" ) ; try { WebResource webResource = client . resource ( restEndpointUrl + "/images/" + imageId ) . queryParam ( "force" , "true" ) ; LOGGER . trace ( "DELETE: ... | Remove an image deleting any tags it might have . |
10,212 | protected boolean fillBuffer ( ) { if ( ! _inProgress . isEmpty ( ) || ! _queue . isEmpty ( ) ) { throw new IllegalStateException ( "cannot fill buffer when buffer or pending messages are non-empty" ) ; } if ( _iterator == null ) { final Map < String , List < KafkaStream < byte [ ] , byte [ ] > > > streams = _consumer ... | Refills the buffer with messages from the configured kafka topic if available . |
10,213 | public static void checkConfigSanity ( final Properties config ) { final Object autoCommit = config . getProperty ( "auto.commit.enable" ) ; if ( autoCommit == null || Boolean . parseBoolean ( String . valueOf ( autoCommit ) ) ) { throw new IllegalArgumentException ( "kafka configuration 'auto.commit.enable' should be ... | Checks the sanity of a kafka consumer configuration for use in storm . |
10,214 | protected URL resolveURL ( ) { if ( this . clazz != null ) { return this . clazz . getResource ( this . path ) ; } else if ( this . classLoader != null ) { return this . classLoader . getResource ( this . path ) ; } else { return ClassLoader . getSystemResource ( this . path ) ; } } | Resolves a URL for the underlying class path resource . |
10,215 | public URL getURL ( ) throws IOException { URL url = resolveURL ( ) ; if ( url == null ) { throw new FileNotFoundException ( getDescription ( ) + " cannot be resolved to URL because it does not exist" ) ; } return url ; } | This implementation returns a URL for the underlying class path resource if available . |
10,216 | static Object adaptValue ( Object value , boolean classValuesAsString , boolean nestedAnnotationsAsMap ) { if ( classValuesAsString ) { if ( value instanceof Class ) { value = ( ( Class < ? > ) value ) . getName ( ) ; } else if ( value instanceof Class [ ] ) { Class < ? > [ ] clazzArray = ( Class [ ] ) value ; String [... | Adapt the given value according to the given class and nested annotation settings . |
10,217 | private void extendCG ( Configuration config , List < Context > contexts ) { PluginConfiguration pluginConfiguration = new PluginConfiguration ( ) ; pluginConfiguration . setConfigurationType ( CommentsWavePlugin . class . getTypeName ( ) ) ; addToContext ( contexts , pluginConfiguration ) ; if ( verbose ) getLog ( ) .... | extend origin mbg the ability for generating comments |
10,218 | public static < T extends Node > AbstractMerger < T > getMerger ( Class < T > clazz ) { AbstractMerger < T > merger = null ; Class < ? > type = clazz ; while ( merger == null && type != null ) { merger = map . get ( type ) ; type = type . getSuperclass ( ) ; } return merger ; } | first check if mapper of the type T exist if existed return it else check if mapper of the supper type exist then return it |
10,219 | public boolean doIsEquals ( NormalAnnotationExpr first , NormalAnnotationExpr second ) { boolean equals = true ; if ( ! first . getName ( ) . equals ( second . getName ( ) ) ) equals = false ; if ( equals == true ) { if ( first . getPairs ( ) == null ) return second . getPairs ( ) == null ; if ( ! isSmallerHasEqualsInB... | 1 . check the name 2 . check the member including key and value if their size is not the same and the less one is all matched in the more one return true |
10,220 | public static String merge ( String first , String second ) throws ParseException { JavaParser . setDoNotAssignCommentsPreceedingEmptyLines ( false ) ; CompilationUnit cu1 = JavaParser . parse ( new StringReader ( first ) , true ) ; CompilationUnit cu2 = JavaParser . parse ( new StringReader ( second ) , true ) ; Abstr... | Util method to make source merge more convenient |
10,221 | public static Fixture parseFrom ( String fileName , Parser parser ) { if ( fileName == null ) { throw new NullPointerException ( "File name should not be null" ) ; } String path = "fixtures/" + fileName + ".yaml" ; InputStream inputStream = openPathAsStream ( path ) ; Fixture result = parser . parse ( inputStream ) ; i... | Parse the given filename and returns the Fixture object . |
10,222 | public Comparator < Object > withSourceProvider ( final OrderSourceProvider sourceProvider ) { return new Comparator < Object > ( ) { public int compare ( Object o1 , Object o2 ) { return doCompare ( o1 , o2 , sourceProvider ) ; } } ; } | Build an adapted order comparator with the given soruce provider . |
10,223 | public static String collapse ( String name ) { if ( name == null ) { return null ; } int breakPoint = name . lastIndexOf ( '.' ) ; if ( breakPoint < 0 ) { return name ; } return collapseQualifier ( name . substring ( 0 , breakPoint ) , true ) + name . substring ( breakPoint ) ; } | Collapses a name . Mainly intended for use with classnames where an example might serve best to explain . Imagine you have a class named org . hibernate . internal . util . StringHelper ; calling collapse on that classname will result in o . h . u . StringHelper . |
10,224 | public static String collapseQualifier ( String qualifier , boolean includeDots ) { StringTokenizer tokenizer = new StringTokenizer ( qualifier , "." ) ; String collapsed = Character . toString ( tokenizer . nextToken ( ) . charAt ( 0 ) ) ; while ( tokenizer . hasMoreTokens ( ) ) { if ( includeDots ) { collapsed += '.'... | Given a qualifier collapse it . |
10,225 | public static String partiallyUnqualify ( String name , String qualifierBase ) { if ( name == null || ! name . startsWith ( qualifierBase ) ) { return name ; } return name . substring ( qualifierBase . length ( ) + 1 ) ; } | Partially unqualifies a qualified name . For example with a base of org . hibernate the name org . hibernate . internal . util . StringHelper would become util . StringHelper . |
10,226 | private static String cleanAlias ( String alias ) { char [ ] chars = alias . toCharArray ( ) ; if ( ! Character . isLetter ( chars [ 0 ] ) ) { for ( int i = 1 ; i < chars . length ; i ++ ) { if ( Character . isLetter ( chars [ i ] ) ) { return alias . substring ( i ) ; } } } return alias ; } | Clean the generated alias by removing any non - alpha characters from the beginning . |
10,227 | public String path ( M method , T target , Object ... params ) { MethodlessRouter < T > router = ( method == null ) ? anyMethodRouter : routers . get ( method ) ; if ( router == null ) router = anyMethodRouter ; String ret = router . path ( target , params ) ; if ( ret != null ) return ret ; return ( router == anyMetho... | Reverse routing . |
10,228 | public static < T , P extends Convertable < T > > T convert ( P value ) throws ParseException { return value == null ? null : value . convert ( ) ; } | Converting single item if it is not null . |
10,229 | public static < IN , OUT > OUT create ( IN obj , Creator < IN , OUT > creator ) { return obj == null ? null : creator . create ( obj ) ; } | Creates output object using provided creator . Returns null if obj null . |
10,230 | public static Object instanceFromTarget ( Object target ) throws InstantiationException , IllegalAccessException { if ( target == null ) return null ; if ( target instanceof Class ) { Class < ? > klass = ( Class < ? > ) target ; return klass . newInstance ( ) ; } else { return target ; } } | When target is a class this method calls newInstance on the class . Otherwise it returns the target as is . |
10,231 | private void getDescriptor ( final StringBuilder sb ) { if ( this . buf == null ) { sb . append ( ( char ) ( ( off & 0xFF000000 ) >>> 24 ) ) ; } else if ( sort == OBJECT ) { sb . append ( 'L' ) ; sb . append ( this . buf , off , len ) ; sb . append ( ';' ) ; } else { sb . append ( this . buf , off , len ) ; } } | Appends the descriptor corresponding to this Java type to the given string builder . |
10,232 | public static void showSoftKeyboard ( Context context , View view ) { if ( view == null ) { return ; } final InputMethodManager manager = ( InputMethodManager ) context . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; view . requestFocus ( ) ; manager . showSoftInput ( view , 0 ) ; } | Shows soft keyboard and requests focus for given view . |
10,233 | public List < MockResponse > enqueue ( String ... paths ) { if ( paths == null ) { return null ; } List < MockResponse > mockResponseList = new ArrayList < > ( ) ; for ( String path : paths ) { Fixture fixture = Fixture . parseFrom ( path , parser ) ; MockResponse mockResponse = fixture . toMockResponse ( ) ; mockWebSe... | Given paths will be parsed to fixtures and added to the queue . Can be multiple |
10,234 | public MockResponse enqueue ( SocketPolicy socketPolicy ) { MockResponse mockResponse = new MockResponse ( ) . setSocketPolicy ( socketPolicy ) ; mockWebServer . enqueue ( mockResponse ) ; return mockResponse ; } | Given policy will be enqueued as MockResponse |
10,235 | public static Class < ? > getMapValueReturnType ( Method method , int nestingLevel ) { return ResolvableType . forMethodReturnType ( method ) . getNested ( nestingLevel ) . asMap ( ) . resolveGeneric ( 1 ) ; } | Determine the generic value type of the given Map return type . |
10,236 | protected void addSingleUpsertToSqlMap ( Document document , IntrospectedTable introspectedTable ) { XmlElement update = new XmlElement ( "update" ) ; update . addAttribute ( new Attribute ( "id" , UPSERT ) ) ; update . addAttribute ( new Attribute ( "parameterType" , "map" ) ) ; generateSqlMapContent ( introspectedTab... | add update xml element to mapper . xml for upsert |
10,237 | public void start ( Intent intent ) { intent = setupIntent ( intent ) ; if ( application != null ) { intent . addFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; application . startActivity ( intent ) ; return ; } if ( activity != null ) { if ( requestCode == NO_RESULT_CODE ) { activity . startActivity ( intent ) ; } else {... | Starts activity by intent . |
10,238 | public void finish ( int resultCode , Intent data ) { Activity activity = getActivity ( ) ; activity . setResult ( resultCode , data ) ; activity . finish ( ) ; setTransition ( true ) ; } | Finishes current activity with provided result code and data . |
10,239 | public void navigateUp ( Intent intent ) { intent . setFlags ( Intent . FLAG_ACTIVITY_CLEAR_TOP | Intent . FLAG_ACTIVITY_SINGLE_TOP ) ; start ( intent ) ; finish ( ) ; } | Navigates up to specified activity in the back stack skipping intermediate activities |
10,240 | public static Config load ( final String ... resources ) { final ScriptEngine engine = new ScriptEngineManager ( ) . getEngineByName ( "nashorn" ) ; try ( final InputStream resourceAsStream = findResource ( "jjs-config-utils.js" ) ) { engine . eval ( new InputStreamReader ( resourceAsStream ) ) ; loadResources ( engine... | Loads a config file . |
10,241 | private Duration parseDurationUsingTypeSafeSpec ( final String path , final String durationString ) { final Optional < Map . Entry < TimeUnit , List < String > > > entry = timeUnitMap . entrySet ( ) . stream ( ) . filter ( timeUnitListEntry -> timeUnitListEntry . getValue ( ) . stream ( ) . anyMatch ( durationString ::... | Parses a string into duration type safe spec format if possible . |
10,242 | public static Set < String > lowercaseLines ( final Class < ? > origin , final String resource ) throws IOException { return ImmutableSet . copyOf ( new HashSet < String > ( ) { { readResource ( origin , resource , new NullReturnLineProcessor ( ) { public boolean processLine ( final String line ) { final String l = sim... | Return a Set containing trimmed lowercaseLines read from a file skipping comments . |
10,243 | public static ImmutableSet < String > lowercaseWordSet ( final Class < ? > origin , final String resource , final boolean eliminatePrepAndConj ) throws IOException { return ImmutableSet . copyOf ( new HashSet < String > ( ) { { readResource ( origin , resource , new NullReturnLineProcessor ( ) { public boolean processL... | Returns a Set containing only single words . |
10,244 | public static ImmutableSet < String > wordSet ( final Class < ? > origin , final String resource ) throws IOException { return ImmutableSet . copyOf ( new HashSet < String > ( ) { { readResource ( origin , resource , new NullReturnLineProcessor ( ) { public boolean processLine ( final String line ) { final String l = s... | Return a set containing all non - comment non - empty words . |
10,245 | public void process ( final NerResultSet resultSet ) { final FeatureMap featureMap = conf . getFeatureMap ( ) ; if ( conf . tracing ) trace = new ArrayList < > ( ) ; final Map < Phrase , Set < Phrase > > phraseInMemory = new HashMap < > ( ) ; for ( final List < Phrase > phrasesInSentence : resultSet . phrases ) { for (... | This method process the whole input result set and gives all _phrases in the set a name type - modifies the data of the passed in NerResultSet! |
10,246 | public List < List < Token > > process ( final String text ) { final List < List < Token > > paragraph = new ArrayList < > ( ) ; currentSentence = new ArrayList < > ( ) ; final Tokens tokens = splitText ( text ) ; while ( tokens . hasNext ( ) ) { final Token t = tokens . next ( ) ; final String trimmedWord = t . text .... | Tokenize some text - not thread safe . |
10,247 | private static boolean detectNameWordInSentenceByPosition ( final List < Token > _text , final int _pos ) { boolean isFirstWord = false ; boolean nextWordIsName = false ; if ( _pos == 0 || ! isLetterOrDigit ( ( _text . get ( _pos - 1 ) . text . charAt ( 0 ) ) ) ) { isFirstWord = true ; if ( _text . size ( ) > _pos + 1 ... | Detects if a particular word in a sentence is a name . |
10,248 | private static boolean isName ( final String _text , final boolean isFirstWord , final boolean nextWordIsName ) { if ( hasManyCaps ( _text ) ) return true ; else if ( startsWithCap ( _text ) ) { if ( isFirstWord ) { if ( _text . endsWith ( "ly" ) ) return false ; final String type_original = Dictionary . checkup ( _tex... | This method detects a word if it is a potential name word . |
10,249 | private static void getAttachedPrep ( final List < Token > sentenceToken , final List < Phrase > sentencePhrase , final int index ) { final String prep ; boolean nameSequenceMeetEnd = true ; final Collection < Phrase > phraseSequence = new HashSet < > ( ) ; int phrasePtr = index ; Phrase currentNamePhrase = sentencePhr... | This method will find all the attached preps of a phrase . |
10,250 | private static boolean startsWithCap ( final String word ) { return ! "i" . equalsIgnoreCase ( word ) && isAllowedChar ( word . charAt ( 0 ) ) && isUpperCase ( word . charAt ( 0 ) ) ; } | This method detects if the word s first character is in capital size . |
10,251 | private static boolean hasManyCaps ( final String word ) { if ( "i" . equalsIgnoreCase ( word ) ) return false ; int capCharCount = 0 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( isUpperCase ( word . charAt ( i ) ) ) capCharCount ++ ; if ( capCharCount == 2 ) return true ; } return false ; } | This method detects if the word has more than one character which is capital sized . |
10,252 | public static boolean isPlural ( final String _word ) { final String word = toEngLowerCase ( _word ) ; if ( word . endsWith ( "s" ) ) { final String wordStub = word . substring ( 0 , word . length ( ) - 1 ) ; if ( checkup ( wordStub ) != null ) return true ; } if ( word . endsWith ( "ed" ) ) { final String wordStub = w... | This method checks if the word is a plural form . |
10,253 | private void addHeadersToContext ( final HttpHeaders headers ) { for ( HttpHeader header : headers . all ( ) ) { final String rawKey = header . key ( ) ; final String transformedKey = rawKey . replaceAll ( "-" , "" ) ; context . put ( "requestHeader" . concat ( transformedKey ) , header . values ( ) . toString ( ) ) ; ... | Adds the request header information to the Velocity context . |
10,254 | private void addBodyToContext ( final String body ) { if ( ! body . isEmpty ( ) ) { final JSONParser parser = new JSONParser ( ) ; try { final JSONObject json = ( JSONObject ) parser . parse ( body ) ; context . put ( "requestBody" , json ) ; } catch ( final ParseException e ) { e . printStackTrace ( ) ; } } } | Adds the request body to the context if one exists . |
10,255 | private String getRenderedBody ( final ResponseDefinition response ) { final String templatePath = fileSource . getPath ( ) . concat ( "/" + response . getBodyFileName ( ) ) ; final Template template = Velocity . getTemplate ( templatePath ) ; StringWriter writer = new StringWriter ( ) ; template . merge ( context , wr... | Renders the velocity template . |
10,256 | public static Map < Integer , NerClassification > positionClassificationMap ( final NerResultSet nerResultSet ) { final Map < Integer , NerClassification > m = new HashMap < > ( ) ; for ( final List < Phrase > sentence : nerResultSet . phrases ) { for ( final Phrase p : sentence ) { final int phraseStartIndex = p . phr... | Return a Map of Token startIndex to classification of the Phrase that Token is a part of . |
10,257 | public static Feature generateFeatureByName ( final String featureType , final int weight , final List < String > resourceNames ) throws IllegalArgumentException , IOException { switch ( featureType ) { case "RuledWordFeature" : return new RuledWordFeature ( resourceNames , weight ) ; case "PrepositionContextFeature" :... | Factory method create features by name . |
10,258 | public float getVoltage ( ) { float inMin = 0 ; float inMax = 100 ; float outMin = ( float ) 2.0 ; float outMax = ( float ) 3.7 ; float x = this . percentage ; return ( x - inMin ) * ( outMax - outMin ) / ( inMax - inMin ) + outMin ; } | Get the battery level in volts . |
10,259 | private void reset ( ) { setState ( OADState . INACTIVE ) ; currentImage = null ; firmwareBundle = null ; nextBlock = 0 ; oadListener = null ; watchdog . stop ( ) ; oadApproval . reset ( ) ; } | Set the state to INACTIVE and clear state variables |
10,260 | private void reconnect ( ) { if ( uploadInProgress ( ) ) { setState ( OADState . RECONNECTING ) ; BeanManager . getInstance ( ) . startDiscovery ( ) ; Log . i ( TAG , "Waiting for device to reconnect..." ) ; } } | Attempt to reconnect to a Bean that is in the middle of OAD process |
10,261 | private void offerNextImage ( ) { if ( oadState == OADState . OFFERING_IMAGES ) { try { currentImage = firmwareBundle . getNextImage ( ) ; if ( currentImage != null ) { Log . i ( TAG , "Offering image: " + currentImage . name ( ) ) ; writeToCharacteristic ( oadIdentify , currentImage . metadata ( ) ) ; } } catch ( OADE... | Offer the next image available in the Firmware Bundle |
10,262 | private void onNotificationBlock ( BluetoothGattCharacteristic characteristic ) { int requestedBlock = Convert . twoBytesToInt ( characteristic . getValue ( ) , Constants . CC2540_BYTE_ORDER ) ; if ( requestedBlock == 0 ) { Log . i ( TAG , String . format ( "Image accepted (Name: %s) (Size: %s bytes)" , currentImage . ... | Received a notification on Block characteristic |
10,263 | private void setupOAD ( ) { BluetoothGattService oadService = mGattClient . getService ( Constants . UUID_OAD_SERVICE ) ; if ( oadService == null ) { fail ( BeanError . MISSING_OAD_SERVICE ) ; return ; } oadIdentify = oadService . getCharacteristic ( Constants . UUID_OAD_CHAR_IDENTIFY ) ; if ( oadIdentify == null ) { f... | Setup BLOCK and IDENTIFY characteristics |
10,264 | private void setupNotifications ( ) { Log . i ( TAG , "Enabling OAD notifications" ) ; boolean oadIdentifyNotifying = enableNotifyForChar ( oadIdentify ) ; boolean oadBlockNotifying = enableNotifyForChar ( oadBlock ) ; if ( oadIdentifyNotifying && oadBlockNotifying ) { Log . i ( TAG , "Enable notifications successful" ... | Enables notifications for all OAD characteristics . |
10,265 | private boolean enableNotifyForChar ( BluetoothGattCharacteristic characteristic ) { boolean success = true ; boolean successEnable = mGattClient . setCharacteristicNotification ( characteristic , true ) ; if ( successEnable ) { Log . i ( TAG , "Enabled notify for characteristic: " + characteristic . getUuid ( ) ) ; } ... | Enable notifications for a given characteristic . |
10,266 | private boolean writeToCharacteristic ( BluetoothGattCharacteristic charc , byte [ ] data ) { charc . setValue ( data ) ; boolean result = mGattClient . writeCharacteristic ( charc ) ; if ( result ) { Log . d ( TAG , "Wrote to characteristic: " + charc . getUuid ( ) + ", data: " + Arrays . toString ( data ) ) ; } else ... | Write to a OAD characteristic |
10,267 | private boolean needsUpdate ( Long bundleVersion , String beanVersion ) { if ( beanVersion . contains ( "OAD" ) ) { Log . i ( TAG , "Bundle version: " + bundleVersion ) ; Log . i ( TAG , "Bean version: " + beanVersion ) ; return true ; } else { try { long parsedVersion = Long . parseLong ( beanVersion . split ( " " ) [... | Helper function to determine whether a Bean needs a FW update given a specific Bundle version |
10,268 | private void checkFirmwareVersion ( ) { Log . i ( TAG , "Checking Firmware version..." ) ; setState ( OADState . CHECKING_FW_VERSION ) ; mGattClient . getDeviceProfile ( ) . getFirmwareVersion ( new DeviceProfile . VersionCallback ( ) { public void onComplete ( String version ) { boolean updateNeeded = needsUpdate ( fi... | Check the Beans FW version to determine if an update is required |
10,269 | private void fail ( BeanError error ) { Log . e ( TAG , "OAD Error: " + error . toString ( ) ) ; if ( uploadInProgress ( ) ) { oadListener . error ( error ) ; reset ( ) ; } } | Stop the firmware upload and alert the OADListener |
10,270 | public OADApproval programWithFirmware ( final FirmwareBundle bundle , OADListener listener ) { if ( ! mGattClient . isConnected ( ) ) { listener . error ( BeanError . NOT_CONNECTED ) ; } Log . i ( TAG , "Starting firmware update procedure" ) ; this . oadListener = listener ; this . firmwareBundle = bundle ; watchdog .... | Program the Bean s CC2540 with new firmware . |
10,271 | public ObservableMap < String , Property < ? > > getBindings ( ) { if ( bindings == null ) { bindings = FXCollections . observableHashMap ( ) ; } return bindings ; } | session scope bindings |
10,272 | public static < T > Observable . Transformer < T , ImmutableList < T > > toImmutableList ( ) { return new Observable . Transformer < T , ImmutableList < T > > ( ) { public Observable < ImmutableList < T > > call ( Observable < T > source ) { return source . collect ( new Func0 < ImmutableList . Builder < T > > ( ) { pu... | Returns a Transformer< ; T ImmutableList< ; T> ; > that maps an Observable< ; T> ; to an Observable< ; ImmutableList< ; T> ; > ; |
10,273 | public static < T > Observable . Transformer < T , ImmutableSet < T > > toImmutableSet ( ) { return new Observable . Transformer < T , ImmutableSet < T > > ( ) { public Observable < ImmutableSet < T > > call ( Observable < T > source ) { return source . collect ( new Func0 < ImmutableSet . Builder < T > > ( ) { public ... | Returns a Transformer< ; T ImmutableSet< ; T> ; > that maps an Observable< ; T> ; to an Observable< ; ImmutableSet< ; T> ; > ; |
10,274 | public boolean update ( Object key , Object value , Object currentVersion , Object previousVersion ) throws CacheException { log . debug ( "region access strategy nonstrict-read-write entity update() {} {}" , getInternalRegion ( ) . getCacheNamespace ( ) , key ) ; return false ; } | not necessary in nostrict - read - write |
10,275 | public boolean afterUpdate ( Object key , Object value , Object currentVersion , Object previousVersion , SoftLock lock ) throws CacheException { log . debug ( "region access strategy nonstrict-read-write entity afterUpdate() {} {}" , getInternalRegion ( ) . getCacheNamespace ( ) , key ) ; getInternalRegion ( ) . evict... | need evict the key after update . |
10,276 | private void handleMessage ( byte [ ] data ) { Buffer buffer = new Buffer ( ) ; buffer . write ( data ) ; int type = ( buffer . readShort ( ) & 0xffff ) & ~ ( APP_MSG_RESPONSE_BIT ) ; if ( type == BeanMessageID . SERIAL_DATA . getRawValue ( ) ) { beanListener . onSerialMessageReceived ( buffer . readByteArray ( ) ) ; }... | Handles incoming messages from the Bean and dispatches them to the proper handlers . |
10,277 | private void handleStatus ( Status status ) { Log . d ( TAG , "Handling Bean status: " + status ) ; BeanState beanState = status . beanState ( ) ; if ( beanState == BeanState . READY ) { resetSketchStateTimeout ( ) ; if ( sketchUploadState == SketchUploadState . SENDING_START_COMMAND ) { sketchUploadState = SketchUploa... | Fired when the Bean sends a Status message . Updates the client s internal state machine used for uploading sketches and firmware to the Bean . |
10,278 | private void resetSketchStateTimeout ( ) { TimerTask onTimeout = new TimerTask ( ) { public void run ( ) { returnUploadError ( BeanError . STATE_TIMEOUT ) ; } } ; stopSketchStateTimeout ( ) ; sketchStateTimeout = new Timer ( ) ; sketchStateTimeout . schedule ( onTimeout , SKETCH_UPLOAD_STATE_TIMEOUT ) ; } | Reset the state timeout timer . If this timer fires the client has waited too long for a state update from the Bean and an error will be fired . |
10,279 | private void resetSketchBlockSendTimeout ( ) { TimerTask onTimeout = new TimerTask ( ) { public void run ( ) { sendNextSketchBlock ( ) ; } } ; stopSketchBlockSendTimeout ( ) ; sketchBlockSendTimeout = new Timer ( ) ; sketchBlockSendTimeout . schedule ( onTimeout , SKETCH_BLOCK_SEND_INTERVAL ) ; } | Reset the block send timer . When this timer fires another sketch block is sent . |
10,280 | private void sendNextSketchBlock ( ) { byte [ ] rawBlock = sketchBlocksToSend . get ( currSketchBlockNum ) ; Buffer block = new Buffer ( ) ; block . write ( rawBlock ) ; sendMessage ( BeanMessageID . BL_FW_BLOCK , block ) ; resetSketchBlockSendTimeout ( ) ; int blocksSent = currSketchBlockNum + 1 ; int totalBlocks = sk... | Send one block of sketch data to the Bean and increment the block counter . |
10,281 | private void addCallback ( BeanMessageID type , Callback < ? > callback ) { List < Callback < ? > > callbacks = beanCallbacks . get ( type ) ; if ( callbacks == null ) { callbacks = new ArrayList < > ( 16 ) ; beanCallbacks . put ( type , callbacks ) ; } callbacks . add ( callback ) ; } | Add a callback for a Bean message type . |
10,282 | @ SuppressWarnings ( "unchecked" ) private < T > Callback < T > getFirstCallback ( BeanMessageID type ) { List < Callback < ? > > callbacks = beanCallbacks . get ( type ) ; if ( callbacks == null || callbacks . isEmpty ( ) ) { Log . w ( TAG , "Got response without callback!" ) ; return null ; } return ( Callback < T > ... | Get the first callback for a Bean message type . |
10,283 | public void connect ( Context context , BeanListener listener ) { lastKnownContext = context ; beanListener = listener ; gattClient . connect ( context , device ) ; } | Attempt to connect to this Bean . |
10,284 | public void setLed ( LedColor color ) { Buffer buffer = new Buffer ( ) ; buffer . writeByte ( color . red ( ) ) ; buffer . writeByte ( color . green ( ) ) ; buffer . writeByte ( color . blue ( ) ) ; sendMessage ( BeanMessageID . CC_LED_WRITE_ALL , buffer ) ; } | Set the LED color . |
10,285 | public void readLed ( Callback < LedColor > callback ) { addCallback ( BeanMessageID . CC_LED_READ_ALL , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_LED_READ_ALL ) ; } | Read the LED color . |
10,286 | public void setAdvertising ( boolean enable ) { Buffer buffer = new Buffer ( ) ; buffer . writeByte ( enable ? 1 : 0 ) ; sendMessage ( BeanMessageID . BT_ADV_ONOFF , buffer ) ; } | Set the advertising flag . |
10,287 | public void readTemperature ( Callback < Integer > callback ) { addCallback ( BeanMessageID . CC_TEMP_READ , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_TEMP_READ ) ; } | Request a temperature reading . |
10,288 | public void readAcceleration ( Callback < Acceleration > callback ) { addCallback ( BeanMessageID . CC_ACCEL_READ , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_ACCEL_READ ) ; } | Request an acceleration sensor reading . |
10,289 | public void readSketchMetadata ( Callback < SketchMetadata > callback ) { addCallback ( BeanMessageID . BL_GET_META , callback ) ; sendMessageWithoutPayload ( BeanMessageID . BL_GET_META ) ; } | Request the sketch metadata . |
10,290 | public void readScratchData ( ScratchBank bank , Callback < ScratchData > callback ) { addCallback ( BeanMessageID . BT_GET_SCRATCH , callback ) ; Buffer buffer = new Buffer ( ) ; buffer . writeByte ( intToByte ( bank . getRawValue ( ) ) ) ; sendMessage ( BeanMessageID . BT_GET_SCRATCH , buffer ) ; } | Request a scratch bank data value . |
10,291 | public void setAccelerometerRange ( AccelerometerRange range ) { Buffer buffer = new Buffer ( ) ; buffer . writeByte ( range . getRawValue ( ) ) ; sendMessage ( BeanMessageID . CC_ACCEL_SET_RANGE , buffer ) ; } | Set the accelerometer range . |
10,292 | public void readAccelerometerRange ( Callback < AccelerometerRange > callback ) { addCallback ( BeanMessageID . CC_ACCEL_GET_RANGE , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_ACCEL_GET_RANGE ) ; } | Read the accelerometer range . |
10,293 | public void setScratchData ( ScratchBank bank , byte [ ] data ) { ScratchData sd = ScratchData . create ( bank , data ) ; sendMessage ( BeanMessageID . BT_SET_SCRATCH , sd ) ; } | Set a scratch bank data value with raw bytes . |
10,294 | public void setRadioConfig ( RadioConfig config , boolean save ) { sendMessage ( save ? BeanMessageID . BT_SET_CONFIG : BeanMessageID . BT_SET_CONFIG_NOSAVE , config ) ; } | Set the radio config . |
10,295 | public void sendSerialMessage ( byte [ ] value ) { Buffer buffer = new Buffer ( ) ; buffer . write ( value ) ; sendMessage ( BeanMessageID . SERIAL_DATA , buffer ) ; } | Send raw bytes to the Bean as a serial message . |
10,296 | public void setPin ( int pin , boolean active ) { Buffer buffer = new Buffer ( ) ; buffer . writeIntLe ( pin ) ; buffer . writeByte ( active ? 1 : 0 ) ; sendMessage ( BeanMessageID . BT_SET_PIN , buffer ) ; } | Set the Bean s security code . |
10,297 | public void sendSerialMessage ( String value ) { Buffer buffer = new Buffer ( ) ; try { buffer . write ( value . getBytes ( "UTF-8" ) ) ; sendMessage ( BeanMessageID . SERIAL_DATA , buffer ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } } | Send a UTF - 8 string to the Bean as a serial message . |
10,298 | public void readFirmwareVersion ( final Callback < String > callback ) { gattClient . getDeviceProfile ( ) . getFirmwareVersion ( new DeviceProfile . VersionCallback ( ) { public void onComplete ( String version ) { callback . onResult ( version ) ; } } ) ; } | Read the Bean hardware version |
10,299 | public void readHardwareVersion ( final Callback < String > callback ) { gattClient . getDeviceProfile ( ) . getHardwareVersion ( new DeviceProfile . VersionCallback ( ) { public void onComplete ( String version ) { callback . onResult ( version ) ; } } ) ; } | Read Bean firmware version |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.