idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
133,900 | 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 . |
133,901 | 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 . |
133,902 | 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 . |
133,903 | 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 . |
133,904 | 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 . |
133,905 | 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 . |
133,906 | 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 . |
133,907 | 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 |
133,908 | 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 |
133,909 | 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 |
133,910 | 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 |
133,911 | 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 . |
133,912 | 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 . |
133,913 | 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 . |
133,914 | 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 . |
133,915 | 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 . |
133,916 | 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 . |
133,917 | 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 . |
133,918 | 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 . |
133,919 | 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 . |
133,920 | 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 . |
133,921 | 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 . |
133,922 | 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 . |
133,923 | 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 |
133,924 | public MockResponse enqueue ( SocketPolicy socketPolicy ) { MockResponse mockResponse = new MockResponse ( ) . setSocketPolicy ( socketPolicy ) ; mockWebServer . enqueue ( mockResponse ) ; return mockResponse ; } | Given policy will be enqueued as MockResponse |
133,925 | 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 . |
133,926 | 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 |
133,927 | 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 . |
133,928 | 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 . |
133,929 | 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 |
133,930 | 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 . |
133,931 | 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 . |
133,932 | 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 . |
133,933 | 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 . |
133,934 | 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 . |
133,935 | 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! |
133,936 | 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 . |
133,937 | 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 . |
133,938 | 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 . |
133,939 | 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 . |
133,940 | 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 . |
133,941 | 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 . |
133,942 | 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 . |
133,943 | 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 . |
133,944 | 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 . |
133,945 | 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 . |
133,946 | 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 . |
133,947 | 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 . |
133,948 | 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 . |
133,949 | 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 |
133,950 | 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 |
133,951 | 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 |
133,952 | 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 |
133,953 | 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 |
133,954 | 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 . |
133,955 | 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 . |
133,956 | 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 |
133,957 | 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 |
133,958 | 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 |
133,959 | 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 |
133,960 | 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 . |
133,961 | public ObservableMap < String , Property < ? > > getBindings ( ) { if ( bindings == null ) { bindings = FXCollections . observableHashMap ( ) ; } return bindings ; } | session scope bindings |
133,962 | 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> ; > ; |
133,963 | 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> ; > ; |
133,964 | 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 |
133,965 | 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 . |
133,966 | 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 . |
133,967 | 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 . |
133,968 | 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 . |
133,969 | 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 . |
133,970 | 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 . |
133,971 | 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 . |
133,972 | @ 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 . |
133,973 | public void connect ( Context context , BeanListener listener ) { lastKnownContext = context ; beanListener = listener ; gattClient . connect ( context , device ) ; } | Attempt to connect to this Bean . |
133,974 | 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 . |
133,975 | public void readLed ( Callback < LedColor > callback ) { addCallback ( BeanMessageID . CC_LED_READ_ALL , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_LED_READ_ALL ) ; } | Read the LED color . |
133,976 | public void setAdvertising ( boolean enable ) { Buffer buffer = new Buffer ( ) ; buffer . writeByte ( enable ? 1 : 0 ) ; sendMessage ( BeanMessageID . BT_ADV_ONOFF , buffer ) ; } | Set the advertising flag . |
133,977 | public void readTemperature ( Callback < Integer > callback ) { addCallback ( BeanMessageID . CC_TEMP_READ , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_TEMP_READ ) ; } | Request a temperature reading . |
133,978 | public void readAcceleration ( Callback < Acceleration > callback ) { addCallback ( BeanMessageID . CC_ACCEL_READ , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_ACCEL_READ ) ; } | Request an acceleration sensor reading . |
133,979 | public void readSketchMetadata ( Callback < SketchMetadata > callback ) { addCallback ( BeanMessageID . BL_GET_META , callback ) ; sendMessageWithoutPayload ( BeanMessageID . BL_GET_META ) ; } | Request the sketch metadata . |
133,980 | 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 . |
133,981 | public void setAccelerometerRange ( AccelerometerRange range ) { Buffer buffer = new Buffer ( ) ; buffer . writeByte ( range . getRawValue ( ) ) ; sendMessage ( BeanMessageID . CC_ACCEL_SET_RANGE , buffer ) ; } | Set the accelerometer range . |
133,982 | public void readAccelerometerRange ( Callback < AccelerometerRange > callback ) { addCallback ( BeanMessageID . CC_ACCEL_GET_RANGE , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_ACCEL_GET_RANGE ) ; } | Read the accelerometer range . |
133,983 | 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 . |
133,984 | public void setRadioConfig ( RadioConfig config , boolean save ) { sendMessage ( save ? BeanMessageID . BT_SET_CONFIG : BeanMessageID . BT_SET_CONFIG_NOSAVE , config ) ; } | Set the radio config . |
133,985 | 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 . |
133,986 | 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 . |
133,987 | 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 . |
133,988 | 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 |
133,989 | 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 |
133,990 | public void setArduinoEnabled ( boolean enable ) { Buffer buffer = new Buffer ( ) ; buffer . writeByte ( enable ? 1 : 0 ) ; sendMessage ( BeanMessageID . CC_POWER_ARDUINO , buffer ) ; } | Enable or disable the Arduino . |
133,991 | public void readArduinoPowerState ( final Callback < Boolean > callback ) { addCallback ( BeanMessageID . CC_GET_AR_POWER , callback ) ; sendMessageWithoutPayload ( BeanMessageID . CC_GET_AR_POWER ) ; } | Read the Arduino power state . |
133,992 | public void readBatteryLevel ( final Callback < BatteryLevel > callback ) { gattClient . getBatteryProfile ( ) . getBatteryLevel ( new BatteryLevelCallback ( ) { public void onBatteryLevel ( int percentage ) { callback . onResult ( new BatteryLevel ( percentage ) ) ; } } ) ; } | Read the battery level . |
133,993 | public OADProfile . OADApproval programWithFirmware ( FirmwareBundle bundle , OADProfile . OADListener listener ) { return gattClient . getOADProfile ( ) . programWithFirmware ( bundle , listener ) ; } | Programs the Bean with new firmware images . |
133,994 | public boolean isTargetClassAndCurrentJvmTargetClassMatch ( ) { Class < ? > targetClassOnThisJVM ; try { targetClassOnThisJVM = Class . forName ( targetClassName ) ; } catch ( ClassNotFoundException e ) { log . error ( "target class " + targetClassName + " does not exist on this JVM." ) ; return false ; } ObjectStreamC... | Compare targetClassSerialVersionUID and current JVM s targetClass serialVersionUID . If they are same return true else return false . |
133,995 | public static boolean checkIfClassVersionApplicable ( Object cacheEntry , boolean useStructuredCache ) { if ( ! useStructuredCache && cacheEntry instanceof CacheEntry ) { return true ; } if ( useStructuredCache && cacheEntry instanceof Map ) { return true ; } return false ; } | Check if class version comparable . |
133,996 | private void refreshDeviceCache ( BluetoothGatt gatt ) { try { BluetoothGatt localBluetoothGatt = gatt ; Method localMethod = localBluetoothGatt . getClass ( ) . getMethod ( "refresh" , new Class [ 0 ] ) ; if ( localMethod != null ) { localMethod . invoke ( localBluetoothGatt , new Object [ 0 ] ) ; } else { Log . e ( T... | Attempt to invalidate Androids internal GATT table cache |
133,997 | protected ConnectionFactoryBuilder createConnectionFactoryBuilder ( OverridableReadOnlyProperties properties ) { ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder ( ) ; builder . setProtocol ( ConnectionFactoryBuilder . Protocol . BINARY ) ; builder . setLocatorType ( ConnectionFactoryBuilder . Locator . ... | creating ConnectionFactoryBuilder object . Override thid method if you need . |
133,998 | String getNamespacedKey ( CacheNamespace cacheNamespace , String key ) { String namespaceIndicator = getNamespaceIndicator ( cacheNamespace ) ; if ( cacheNamespace . isNamespaceExpirationRequired ( ) == false ) { return namespaceIndicator + ":" + key ; } String namespaceIndicatorKey = namespaceIndicator + NAMESPACE_NAM... | Return cache namespace decorated key . |
133,999 | private int uint16FromData ( int offset ) { return twoBytesToInt ( Arrays . copyOfRange ( data ( ) , offset , offset + 2 ) , Constants . CC2540_BYTE_ORDER ) ; } | Parse a little - endian UInt16 from the data at the given offset . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.