idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
121,500 | public void transformTo ( Result r ) { if ( source == null ) { throw new IllegalStateException ( "source must not be null" ) ; } if ( r == null ) { throw new IllegalArgumentException ( "result must not be null" ) ; } try { TransformerFactory fac = factory ; if ( fac == null ) { fac = TransformerFactoryConfigurer . Defa... | Perform the transformation . |
121,501 | public String transformToString ( ) { StringWriter sw = new StringWriter ( ) ; transformTo ( new StreamResult ( sw ) ) ; return sw . toString ( ) ; } | Convenience method that returns the result of the transformation as a String . |
121,502 | public Document transformToDocument ( ) { DOMResult r = new DOMResult ( ) ; transformTo ( r ) ; return ( Document ) r . getNode ( ) ; } | Convenience method that returns the result of the transformation as a Document . |
121,503 | ComparisonState compareNodes ( final Node control , final XPathContext controlContext , final Node test , final XPathContext testContext ) { final Iterable < Node > controlChildren = Linqy . filter ( new IterableNodeList ( control . getChildNodes ( ) ) , getNodeFilter ( ) ) ; final Iterable < Node > testChildren = Linq... | Recursively compares two XML nodes . |
121,504 | private ComparisonState nodeTypeSpecificComparison ( Node control , XPathContext controlContext , Node test , XPathContext testContext ) { switch ( control . getNodeType ( ) ) { case Node . CDATA_SECTION_NODE : case Node . COMMENT_NODE : case Node . TEXT_NODE : if ( test instanceof CharacterData ) { return compareChara... | Dispatches to the node type specific comparison if one is defined for the given combination of nodes . |
121,505 | private ComparisonState compareCharacterData ( CharacterData control , XPathContext controlContext , CharacterData test , XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . TEXT_VALUE , control , getXPath ( controlContext ) , control . getData ( ) , getParentXPath ( controlContext ) , test ... | Compares textual content . |
121,506 | private ComparisonState compareDocuments ( final Document control , final XPathContext controlContext , final Document test , final XPathContext testContext ) { final DocumentType controlDt = filterNode ( control . getDoctype ( ) ) ; final DocumentType testDt = filterNode ( test . getDoctype ( ) ) ; return compare ( ne... | Compares document node doctype and XML declaration properties |
121,507 | private ComparisonState compareDocTypes ( DocumentType control , XPathContext controlContext , DocumentType test , XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . DOCTYPE_NAME , control , getXPath ( controlContext ) , control . getName ( ) , getParentXPath ( controlContext ) , test , get... | Compares properties of the doctype declaration . |
121,508 | private DeferredComparison compareDeclarations ( final Document control , final XPathContext controlContext , final Document test , final XPathContext testContext ) { return new DeferredComparison ( ) { public ComparisonState apply ( ) { return compare ( new Comparison ( ComparisonType . XML_VERSION , control , getXPat... | Compares properties of XML declaration . |
121,509 | private ComparisonState compareElements ( final Element control , final XPathContext controlContext , final Element test , final XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . ELEMENT_TAG_NAME , control , getXPath ( controlContext ) , Nodes . getQName ( control ) . getLocalPart ( ) , ge... | Compares elements node properties in particular the element s name and its attributes . |
121,510 | private ComparisonState compareElementAttributes ( final Element control , final XPathContext controlContext , final Element test , final XPathContext testContext ) { final Attributes controlAttributes = splitAttributes ( control . getAttributes ( ) ) ; controlContext . addAttributes ( Linqy . map ( controlAttributes .... | Compares element s attributes . |
121,511 | private ComparisonState compareProcessingInstructions ( ProcessingInstruction control , XPathContext controlContext , ProcessingInstruction test , XPathContext testContext ) { return compare ( new Comparison ( ComparisonType . PROCESSING_INSTRUCTION_TARGET , control , getXPath ( controlContext ) , control . getTarget (... | Compares properties of a processing instruction . |
121,512 | private ComparisonState compareNodeLists ( Iterable < Node > controlSeq , final XPathContext controlContext , Iterable < Node > testSeq , final XPathContext testContext ) { ComparisonState chain = new OngoingComparisonState ( ) ; Iterable < Map . Entry < Node , Node > > matches = getNodeMatcher ( ) . match ( controlSeq... | Matches nodes of two node lists and invokes compareNode on each pair . |
121,513 | private ComparisonState compareAttributes ( Attr control , XPathContext controlContext , Attr test , XPathContext testContext ) { return compareAttributeExplicitness ( control , controlContext , test , testContext ) . apply ( ) . andThen ( new Comparison ( ComparisonType . ATTR_VALUE , control , getXPath ( controlConte... | Compares properties of an attribute . |
121,514 | private DeferredComparison compareAttributeExplicitness ( final Attr control , final XPathContext controlContext , final Attr test , final XPathContext testContext ) { return new DeferredComparison ( ) { public ComparisonState apply ( ) { return compare ( new Comparison ( ComparisonType . ATTR_VALUE_EXPLICITLY_SPECIFIE... | Compares whether two attributes are specified explicitly . |
121,515 | private Attributes splitAttributes ( final NamedNodeMap map ) { Attr sLoc = ( Attr ) map . getNamedItemNS ( XMLConstants . W3C_XML_SCHEMA_INSTANCE_NS_URI , "schemaLocation" ) ; Attr nNsLoc = ( Attr ) map . getNamedItemNS ( XMLConstants . W3C_XML_SCHEMA_INSTANCE_NS_URI , "noNamespaceSchemaLocation" ) ; Attr type = ( Att... | Separates XML namespace related attributes from normal attributes . xb |
121,516 | private static Attr findMatchingAttr ( final List < Attr > attrs , final Attr attrToMatch ) { final boolean hasNs = attrToMatch . getNamespaceURI ( ) != null ; final String nsToMatch = attrToMatch . getNamespaceURI ( ) ; final String nameToMatch = hasNs ? attrToMatch . getLocalName ( ) : attrToMatch . getName ( ) ; for... | Find the attribute with the same namespace and local name as a given attribute in a list of attributes . |
121,517 | public DiffBuilder withComparisonListeners ( final ComparisonListener ... comparisonListeners ) { this . comparisonListeners . addAll ( Arrays . asList ( comparisonListeners ) ) ; return this ; } | Registers listeners that are notified of each comparison . |
121,518 | public int differenceFound ( Difference difference ) { final int returnValue = super . differenceFound ( difference ) ; switch ( returnValue ) { case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL : return returnValue ; case RETURN_ACCEPT_DIFFERENCE : break ; case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR : difference . setReco... | DifferenceListener implementation . Add the difference to the list of all differences |
121,519 | protected final boolean areAttributesComparable ( Element control , Element test ) { String controlValue , testValue ; Attr [ ] qualifyingAttributes ; NamedNodeMap namedNodeMap = control . getAttributes ( ) ; if ( matchesAllAttributes ( qualifyingAttrNames ) ) { qualifyingAttributes = new Attr [ namedNodeMap . getLengt... | Determine whether the qualifying attributes are present in both elements and if so whether their values are the same |
121,520 | public static InputSource toInputSource ( Source s , TransformerFactory fac ) { try { InputSource is = SAXSource . sourceToInputSource ( s ) ; if ( is == null ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; StreamResult r = new StreamResult ( bos ) ; if ( fac == null ) { fac = TransformerFactoryConfigur... | Creates a SAX InputSource from a TraX Source . |
121,521 | public static NamespaceContext toNamespaceContext ( Map < String , String > prefix2URI ) { final Map < String , String > copy = new LinkedHashMap < String , String > ( prefix2URI ) ; return new NamespaceContext ( ) { public String getNamespaceURI ( String prefix ) { if ( prefix == null ) { throw new IllegalArgumentExce... | Creates a JAXP NamespaceContext from a Map prefix = > ; Namespace URI . |
121,522 | protected void compareDocument ( Document control , Document test , DifferenceListener listener , ElementQualifier elementQualifier ) throws DifferenceFoundException { DocumentType controlDoctype = control . getDoctype ( ) ; DocumentType testDoctype = test . getDoctype ( ) ; compare ( getNullOrNotNull ( controlDoctype ... | Compare two Documents for doctype and then element differences |
121,523 | private Boolean hasChildNodes ( Node n ) { boolean flag = n . hasChildNodes ( ) ; if ( flag && XMLUnit . getIgnoreComments ( ) ) { List nl = nodeList2List ( n . getChildNodes ( ) ) ; flag = ! nl . isEmpty ( ) ; } return flag ? Boolean . TRUE : Boolean . FALSE ; } | Tests whether a Node has children taking ignoreComments setting into account . |
121,524 | static List < Node > nodeList2List ( NodeList nl ) { int len = nl . getLength ( ) ; List < Node > l = new ArrayList < Node > ( len ) ; for ( int i = 0 ; i < len ; i ++ ) { Node n = nl . item ( i ) ; if ( ! XMLUnit . getIgnoreComments ( ) || ! ( n instanceof Comment ) ) { l . add ( n ) ; } } return l ; } | Returns the NodeList s Nodes as List taking ignoreComments into account . |
121,525 | protected void compareElement ( Element control , Element test , DifferenceListener listener ) throws DifferenceFoundException { compare ( getUnNamespacedNodeName ( control ) , getUnNamespacedNodeName ( test ) , control , test , listener , ELEMENT_TAG_NAME ) ; NamedNodeMap controlAttr = control . getAttributes ( ) ; In... | Compare 2 elements and their attributes |
121,526 | protected void compareCDataSection ( CDATASection control , CDATASection test , DifferenceListener listener ) throws DifferenceFoundException { compareText ( control , test , listener ) ; } | Compare two CDATA sections - unused kept for backwards compatibility |
121,527 | protected void compareComment ( Comment control , Comment test , DifferenceListener listener ) throws DifferenceFoundException { if ( ! XMLUnit . getIgnoreComments ( ) ) { compareCharacterData ( control , test , listener , COMMENT_VALUE ) ; } } | Compare two comments |
121,528 | protected void compareDocumentType ( DocumentType control , DocumentType test , DifferenceListener listener ) throws DifferenceFoundException { compare ( control . getName ( ) , test . getName ( ) , control , test , listener , DOCTYPE_NAME ) ; compare ( control . getPublicId ( ) , test . getPublicId ( ) , control , tes... | Compare two DocumentType nodes |
121,529 | protected void compareProcessingInstruction ( ProcessingInstruction control , ProcessingInstruction test , DifferenceListener listener ) throws DifferenceFoundException { compare ( control . getTarget ( ) , test . getTarget ( ) , control , test , listener , PROCESSING_INSTRUCTION_TARGET ) ; compare ( control . getData ... | Compare two processing instructions |
121,530 | protected void compareText ( Text control , Text test , DifferenceListener listener ) throws DifferenceFoundException { compareText ( ( CharacterData ) control , ( CharacterData ) test , listener ) ; } | Compare text - unused kept for backwards compatibility |
121,531 | private void compareCharacterData ( CharacterData control , CharacterData test , DifferenceListener listener , Difference difference ) throws DifferenceFoundException { compare ( control . getData ( ) , test . getData ( ) , control , test , listener , difference ) ; } | Character comparison method used by comments text and CDATA sections |
121,532 | private boolean unequal ( Object expected , Object actual ) { return expected == null ? actual != null : unequalNotNull ( expected , actual ) ; } | Test two possibly null values for inequality |
121,533 | private boolean unequalNotNull ( Object expected , Object actual ) { if ( ( XMLUnit . getIgnoreWhitespace ( ) || XMLUnit . getNormalizeWhitespace ( ) ) && expected instanceof String && actual instanceof String ) { String expectedString = ( ( String ) expected ) . trim ( ) ; String actualString = ( ( String ) actual ) .... | Test two non - null values for inequality |
121,534 | final static String normalizeWhitespace ( String orig ) { StringBuilder sb = new StringBuilder ( ) ; boolean lastCharWasWhitespace = false ; boolean changed = false ; char [ ] characters = orig . toCharArray ( ) ; for ( int i = 0 ; i < characters . length ; i ++ ) { if ( Character . isWhitespace ( characters [ i ] ) ) ... | Replace all whitespace characters with SPACE and collapse consecutive whitespace chars to a single SPACE . |
121,535 | public static ElementSelector not ( final ElementSelector es ) { if ( es == null ) { throw new IllegalArgumentException ( "es must not be null" ) ; } return new ElementSelector ( ) { public boolean canBeCompared ( Element controlElement , Element testElement ) { return ! es . canBeCompared ( controlElement , testElemen... | Negates another ElementSelector . |
121,536 | public static ElementSelector or ( final ElementSelector ... selectors ) { if ( selectors == null ) { throw new IllegalArgumentException ( SELECTORS_MUST_NOT_BE_NULL ) ; } final Collection < ElementSelector > s = Arrays . asList ( selectors ) ; if ( any ( s , new IsNullPredicate ( ) ) ) { throw new IllegalArgumentExcep... | Accepts two elements if at least one of the given ElementSelectors does . |
121,537 | public static ElementSelector xor ( final ElementSelector es1 , final ElementSelector es2 ) { if ( es1 == null || es2 == null ) { throw new IllegalArgumentException ( SELECTORS_MUST_NOT_BE_NULL ) ; } return new ElementSelector ( ) { public boolean canBeCompared ( Element controlElement , Element testElement ) { return ... | Accepts two elements if exactly on of the given ElementSelectors does . |
121,538 | public static ElementSelector conditionalSelector ( final Predicate < ? super Element > predicate , final ElementSelector es ) { if ( predicate == null ) { throw new IllegalArgumentException ( "predicate must not be null" ) ; } if ( es == null ) { throw new IllegalArgumentException ( "es must not be null" ) ; } return ... | Applies the wrapped ElementSelector s logic if and only if the control element matches the given predicate . |
121,539 | public void setSchemaSources ( Source ... s ) { if ( s != null ) { sourceLocations = Arrays . copyOf ( s , s . length ) ; } else { sourceLocations = null ; } } | Where to find the schema . |
121,540 | public static Validator forLanguage ( String language ) { if ( ! Languages . XML_DTD_NS_URI . equals ( language ) ) { return new JAXPValidator ( language ) ; } return new ParsingValidator ( Languages . XML_DTD_NS_URI ) ; } | Factory that obtains a Validator instance based on the schema language . |
121,541 | public void saveTo ( File propertyFile ) throws IOException { Properties props = new Properties ( ) ; props . put ( "username" , username ) ; props . put ( "key" , accessKey ) ; FileOutputStream out = new FileOutputStream ( propertyFile ) ; try { props . store ( out , "Sauce OnDemand access credential" ) ; } finally { ... | Persists this credential to the disk . |
121,542 | public static GsonBuilder registerAll ( GsonBuilder builder ) { if ( builder == null ) { throw new NullPointerException ( "builder cannot be null" ) ; } registerDateMidnight ( builder ) ; registerDateTime ( builder ) ; registerDuration ( builder ) ; registerLocalDate ( builder ) ; registerLocalDateTime ( builder ) ; re... | Registers all the Joda Time converters . |
121,543 | public void stop ( Future < Void > stopFuture ) throws Exception { if ( realVerticle != null ) { realVerticle . stop ( stopFuture ) ; realVerticle = null ; } } | Vert . x calls the stop method when the verticle is undeployed . Put any cleanup code for your verticle in here |
121,544 | public void start ( ) throws Exception { if ( dependency == null ) { throw new IllegalStateException ( "Dependency was not injected!" ) ; } vertx . eventBus ( ) . consumer ( EB_ADDRESS , this ) ; super . start ( ) ; } | If your verticle does a simple synchronous start - up then override this method and put your start - up code in there . |
121,545 | public void handle ( Message < Void > msg ) { msg . reply ( dependency . getClass ( ) . getName ( ) ) ; } | Something has happened so handle it . |
121,546 | public InputStream getAsStream ( final Archive < ? > archive ) { final Archive < ? > testable = findTestableArchive ( archive ) ; final Collection < Node > values = collectPersistenceXml ( testable ) ; if ( values . size ( ) == 1 ) { return values . iterator ( ) . next ( ) . getAsset ( ) . openStream ( ) ; } return nul... | Returns open stream of persistence . xml found in the archive but only if single file have been found . |
121,547 | public Class < ? > box ( Class < ? > primitive ) { if ( ! primitive . isPrimitive ( ) ) { return primitive ; } if ( int . class . equals ( primitive ) ) { return Integer . class ; } else if ( long . class . equals ( primitive ) ) { return Long . class ; } else if ( float . class . equals ( primitive ) ) { return Float ... | A helper boxing method . Returns boxed class for a primitive class |
121,548 | private String [ ] requiredLibraries ( ) { List < String > libraries = new ArrayList < String > ( Arrays . asList ( "org.dbunit" , "org.apache.commons" , "org.apache.log4j" , "org.slf4j" , "org.yaml" , "org.codehaus.jackson" ) ) ; if ( ! dbunitConfigurationInstance . get ( ) . isExcludePoi ( ) ) { libraries . add ( "or... | Private helper methods |
121,549 | public Collection < T > getDescriptors ( TestClass testClass ) { final List < T > descriptors = new ArrayList < T > ( ) ; for ( Method testMethod : testClass . getMethods ( resourceAnnotation ) ) { descriptors . addAll ( getDescriptorsDefinedFor ( testMethod ) ) ; } descriptors . addAll ( obtainClassLevelDescriptor ( t... | Returns all resources defined for this test class including those defined on the test method level . |
121,550 | protected String determineLocation ( String location ) { if ( existsInDefaultLocation ( location ) ) { return defaultFolder ( ) + location ; } if ( ! existsInGivenLocation ( location ) ) { throw new InvalidResourceLocation ( "Unable to locate " + location + ". " + "File does not exist also in default location " + defau... | Checks if file exists in the default location . If that s not the case file is looked up starting from the root . |
121,551 | public static List < String > extractNonExistingColumns ( final Collection < String > expectedColumns , final Collection < String > actualColumns ) { final List < String > columnsNotSpecifiedInExpectedDataSet = new ArrayList < String > ( ) ; for ( String column : expectedColumns ) { if ( ! actualColumns . contains ( co... | Provides list of columns defined in expectedColumns but not listed in actualColumns . |
121,552 | public T fetchUsingFirst ( Method testMethod ) { T usedAnnotation = getAnnotationOnClassLevel ( ) ; if ( isDefinedOn ( testMethod ) ) { usedAnnotation = fetchFrom ( testMethod ) ; } return usedAnnotation ; } | Fetches annotation for a given test class . If annotation is defined on method level it s returned as a result . Otherwise class level annotation is returned if present . |
121,553 | public Factory < ? > getValueFactory ( Parameter parameter ) { if ( type . equals ( parameter . getRawType ( ) ) && parameter . isAnnotationPresent ( Auth . class ) ) { return this ; } return null ; } | org . glassfish . jersey . server . spi . internal . ValueFactoryProvider |
121,554 | public void bind ( DynamicConfiguration config ) { Injections . addBinding ( Injections . newFactoryBinder ( this ) . to ( type ) . in ( Singleton . class ) , config ) ; Injections . addBinding ( Injections . newBinder ( this ) . to ( ValueFactoryProvider . class ) , config ) ; } | org . glassfish . hk2 . utilities . Binder |
121,555 | public void setVehicleManager ( VehicleManager vehicle ) { mVehicle = vehicle ; mPreferenceListener = watchPreferences ( getPreferences ( ) ) ; mPreferenceListener . readStoredPreferences ( ) ; } | Give the instance a reference to an active VehicleManager . |
121,556 | public static Class < ? extends VehicleInterface > findClass ( String interfaceName ) throws VehicleInterfaceException { Class < ? extends VehicleInterface > interfaceType ; try { interfaceType = Class . forName ( interfaceName ) . asSubclass ( VehicleInterface . class ) ; } catch ( ClassNotFoundException e ) { throw n... | Obtain the Class object for a given VehicleInterface class name . |
121,557 | public static boolean validatePath ( String path ) { if ( path == null ) { Log . w ( TAG , "Uploading path not set" ) ; return false ; } try { uriFromString ( path ) ; return true ; } catch ( DataSinkException e ) { return false ; } } | Returns true if the path is not null and if it is a valid URI . |
121,558 | public void waitUntilBound ( ) throws VehicleServiceException { mRemoteBoundLock . lock ( ) ; Log . i ( TAG , "Waiting for the VehicleService to bind to " + this ) ; while ( mRemoteService == null ) { try { if ( ! mRemoteBoundCondition . await ( 3 , TimeUnit . SECONDS ) ) { throw new VehicleServiceException ( "Not boun... | Block until the VehicleManager is alive and can return measurements . |
121,559 | public Measurement get ( Class < ? extends Measurement > measurementType ) throws UnrecognizedMeasurementTypeException , NoValueException { return BaseMeasurement . getMeasurementFromMessage ( measurementType , get ( BaseMeasurement . getKeyForMeasurement ( measurementType ) ) . asSimpleMessage ( ) ) ; } | Retrieve the most current value of a measurement . |
121,560 | public VehicleMessage get ( MessageKey key ) throws NoValueException { if ( mRemoteService == null ) { Log . w ( TAG , "Not connected to the VehicleService -- " + "throwing a NoValueException" ) ; throw new NoValueException ( ) ; } try { VehicleMessage message = mRemoteService . get ( key ) ; if ( message == null ) { t... | Retrieve the most current value of a keyed message . |
121,561 | public void request ( KeyedMessage message , VehicleMessage . Listener listener ) { mNotifier . register ( ExactKeyMatcher . buildExactMatcher ( message . getKey ( ) ) , listener , false ) ; send ( message ) ; } | Send a message to the VehicleInterface and register the given listener to receive the first response matching the message s key . |
121,562 | public VehicleMessage request ( KeyedMessage message ) { BlockingMessageListener callback = new BlockingMessageListener ( ) ; request ( message , callback ) ; return callback . waitForResponse ( ) ; } | Send a message to the VehicleInterface and wait up to 2 seconds to receive a response . |
121,563 | public void addListener ( Class < ? extends Measurement > measurementType , Measurement . Listener listener ) { Log . i ( TAG , "Adding listener " + listener + " for " + measurementType ) ; mNotifier . register ( measurementType , listener ) ; } | Register to receive asynchronous updates for a specific Measurement type . |
121,564 | public void addListener ( Class < ? extends VehicleMessage > messageType , VehicleMessage . Listener listener ) { Log . i ( TAG , "Adding listener " + listener + " for " + messageType ) ; mNotifier . register ( messageType , listener ) ; } | Register to receive asynchronous updates for a specific VehicleMessage type . |
121,565 | public void addListener ( KeyedMessage keyedMessage , VehicleMessage . Listener listener ) { addListener ( keyedMessage . getKey ( ) , listener ) ; } | Register to receive a callback when a message with same key as the given KeyedMessage is received . |
121,566 | public void addListener ( MessageKey key , VehicleMessage . Listener listener ) { addListener ( ExactKeyMatcher . buildExactMatcher ( key ) , listener ) ; } | Register to receive a callback when a message with the given key is received . |
121,567 | public void addListener ( KeyMatcher matcher , VehicleMessage . Listener listener ) { Log . i ( TAG , "Adding listener " + listener + " to " + matcher ) ; mNotifier . register ( matcher , listener ) ; } | Register to receive a callback when a message with key matching the given KeyMatcher is received . |
121,568 | public void removeListener ( Class < ? extends Measurement > measurementType , Measurement . Listener listener ) { Log . i ( TAG , "Removing listener " + listener + " for " + measurementType ) ; mNotifier . unregister ( measurementType , listener ) ; } | Unregister a previously registered Measurement . Listener instance . |
121,569 | public void removeListener ( Class < ? extends VehicleMessage > messageType , VehicleMessage . Listener listener ) { mNotifier . unregister ( messageType , listener ) ; } | Unregister a previously registered message type listener . |
121,570 | public void removeListener ( KeyedMessage message , VehicleMessage . Listener listener ) { removeListener ( message . getKey ( ) , listener ) ; } | Unregister a previously registered keyed message listener . |
121,571 | public void removeListener ( KeyMatcher matcher , VehicleMessage . Listener listener ) { mNotifier . unregister ( matcher , listener ) ; } | Unregister a previously registered key matcher listener . |
121,572 | public void removeListener ( MessageKey key , VehicleMessage . Listener listener ) { removeListener ( ExactKeyMatcher . buildExactMatcher ( key ) , listener ) ; } | Unregister a previously registered key listener . |
121,573 | public void addSource ( VehicleDataSource source ) { Log . i ( TAG , "Adding data source " + source ) ; mUserOriginPipeline . addSource ( source ) ; } | Add a new data source to the vehicle service . |
121,574 | public void removeSource ( VehicleDataSource source ) { if ( source != null ) { Log . i ( TAG , "Removing data source " + source ) ; mUserOriginPipeline . removeSource ( source ) ; } } | Remove a previously registered source from the data pipeline . |
121,575 | public void addSink ( VehicleDataSink sink ) { Log . i ( TAG , "Adding data sink " + sink ) ; mRemoteOriginPipeline . addSink ( sink ) ; } | Add a new data sink to the vehicle service . |
121,576 | public void removeSink ( VehicleDataSink sink ) { if ( sink != null ) { mRemoteOriginPipeline . removeSink ( sink ) ; sink . stop ( ) ; } } | Remove a previously registered sink from the data pipeline . |
121,577 | public String requestCommandMessage ( CommandType type ) { VehicleMessage message = request ( new Command ( type ) ) ; String value = null ; if ( message != null ) { try { CommandResponse response = message . asCommandResponse ( ) ; if ( response . getStatus ( ) ) { value = response . getMessage ( ) ; } } catch ( Class... | Send a command request to the vehicle that does not require any metadata . |
121,578 | public void addOnVehicleInterfaceConnectedListener ( ViConnectionListener listener ) throws VehicleServiceException { if ( mRemoteService != null ) { try { mRemoteService . addViConnectionListener ( listener ) ; } catch ( RemoteException e ) { throw new VehicleServiceException ( "Unable to add connection status listene... | Register a listener to receive a callback when the selected VI is connected . |
121,579 | public void setVehicleInterface ( Class < ? extends VehicleInterface > vehicleInterfaceType , String resource ) throws VehicleServiceException { Log . i ( TAG , "Setting VI to: " + vehicleInterfaceType ) ; String interfaceName = null ; if ( vehicleInterfaceType != null ) { interfaceName = vehicleInterfaceType . getName... | Change the active vehicle interface to a new type using the given resource . |
121,580 | public void setNativeGpsStatus ( boolean enabled ) { Log . i ( TAG , ( enabled ? "Enabling" : "Disabling" ) + " native GPS" ) ; if ( mRemoteService != null ) { try { mRemoteService . setNativeGpsStatus ( enabled ) ; } catch ( RemoteException e ) { Log . w ( TAG , "Unable to change native GPS status" , e ) ; } } else { ... | Control whether the device s built - in GPS is used to provide location . |
121,581 | public VehicleInterfaceDescriptor getActiveVehicleInterface ( ) { VehicleInterfaceDescriptor descriptor = null ; if ( mRemoteService != null ) { try { descriptor = mRemoteService . getVehicleInterfaceDescriptor ( ) ; } catch ( RemoteException e ) { Log . w ( TAG , "Unable to retrieve VI descriptor" , e ) ; } } return d... | Returns a descriptor of the active vehicle interface . |
121,582 | public int getMessageCount ( ) throws VehicleServiceException { if ( mRemoteService != null ) { try { return mRemoteService . getMessageCount ( ) ; } catch ( RemoteException e ) { throw new VehicleServiceException ( "Unable to retrieve message count" , e ) ; } } else { throw new VehicleServiceException ( "Unable to ret... | Read the number of messages received by the vehicle service . |
121,583 | public boolean isViConnected ( ) { if ( mRemoteService != null ) { try { return mUserOriginPipeline . isActive ( ) || mRemoteService . isViConnected ( ) ; } catch ( RemoteException e ) { Log . d ( TAG , "Unable to send message to remote service" , e ) ; } } return false ; } | Return the connection status of the selected VI . |
121,584 | public int compareTo ( VehicleMessage other ) { CanMessage otherMessage = ( CanMessage ) other ; if ( getBusId ( ) < otherMessage . getBusId ( ) ) { return - 1 ; } else if ( getBusId ( ) > otherMessage . getBusId ( ) ) { return 1 ; } else { if ( getId ( ) < otherMessage . getId ( ) ) { return - 1 ; } else if ( getId ( ... | Sort by bus then by message ID . |
121,585 | public IBinder onBind ( Intent intent ) { Log . i ( TAG , "Service binding in response to " + intent ) ; initializeDefaultSources ( ) ; initializeDefaultSinks ( mPipeline ) ; return mBinder ; } | Initialize the service and data source when a client binds to us . |
121,586 | @ TargetApi ( Build . VERSION_CODES . HONEYCOMB ) public static Set < String > getStringSet ( SharedPreferences preferences , String key , Set < String > defaultValue ) { Set < String > result = defaultValue ; if ( supportsStringSet ( ) ) { result = preferences . getStringSet ( key , defaultValue ) ; } else { String se... | Retrieve a set of strings from SharedPreferences using the built - in getStringSet method if available and falling back to a comma separated String if not . |
121,587 | public static int vendorFromUri ( URI uri ) throws DataSourceResourceException { try { return Integer . parseInt ( uri . getAuthority ( ) , 16 ) ; } catch ( NumberFormatException e ) { throw new DataSourceResourceException ( "USB device must be of the format " + DEFAULT_USB_DEVICE_URI + " -- the given " + uri + " has a... | Return an integer vendor ID from a URI specifying a USB device . |
121,588 | public static int productFromUri ( URI uri ) throws DataSourceResourceException { try { return Integer . parseInt ( uri . getPath ( ) . substring ( 1 ) , 16 ) ; } catch ( NumberFormatException e ) { throw new DataSourceResourceException ( "USB device must be of the format " + DEFAULT_USB_DEVICE_URI + " -- the given " +... | Return an integer product ID from a URI specifying a USB device . |
121,589 | public void setCallback ( SourceCallback callback ) { try { mCallbackLock . lock ( ) ; mCallback = callback ; mCallbackChanged . signal ( ) ; } finally { mCallbackLock . unlock ( ) ; } } | Set the current source callback to the given value . |
121,590 | protected void handleMessage ( VehicleMessage message ) { if ( message != null ) { message . timestamp ( ) ; if ( mCallback != null ) { mCallback . receive ( message ) ; } } } | Pass a new message to the callback if set . |
121,591 | public static boolean validateResource ( String uriString ) { try { URI uri = UriBasedVehicleInterfaceMixin . createUri ( massageUri ( uriString ) ) ; return UriBasedVehicleInterfaceMixin . validateResource ( uri ) && uri . getPort ( ) < 65536 ; } catch ( DataSourceException e ) { return false ; } } | Return true if the address and port are valid . |
121,592 | protected synchronized boolean write ( byte [ ] bytes ) { mConnectionLock . readLock ( ) . lock ( ) ; boolean success = true ; try { if ( isConnected ( ) ) { Log . v ( TAG , "Writing " + bytes . length + " to socket" ) ; mOutStream . write ( bytes ) ; } else { Log . w ( TAG , "No connection established, could not send ... | Writes given data to the socket . |
121,593 | private static String massageUri ( String uriString ) { if ( ! uriString . startsWith ( SCHEMA_SPECIFIC_PREFIX ) ) { uriString = SCHEMA_SPECIFIC_PREFIX + uriString ; } return uriString ; } | Add the prefix required to parse with URI if it s not already there . |
121,594 | public static void logTransferStats ( final String tag , final long startTime , final double bytesReceived ) { double kilobytesTransferred = bytesReceived / 1024.0 ; long elapsedTime = TimeUnit . SECONDS . convert ( System . nanoTime ( ) - startTime , TimeUnit . NANOSECONDS ) ; Log . i ( tag , "Transferred " + kilobyte... | Log data transfer statistics to the Android log . |
121,595 | public static VehicleMessage deserialize ( String data ) throws UnrecognizedMessageTypeException { JsonObject root ; try { JsonParser parser = new JsonParser ( ) ; root = parser . parse ( data ) . getAsJsonObject ( ) ; } catch ( JsonSyntaxException | IllegalStateException e ) { throw new UnrecognizedMessageTypeExceptio... | Deserialize a single vehicle messages from the string . |
121,596 | private String readToDelimiter ( ) { String line = null ; while ( line == null || line . isEmpty ( ) ) { int delimiterIndex = mBuffer . indexOf ( DELIMITER ) ; if ( delimiterIndex != - 1 ) { line = mBuffer . substring ( 0 , delimiterIndex ) ; mBuffer . delete ( 0 , delimiterIndex + 1 ) ; } else { line = null ; break ; ... | Parse the current byte buffer to find the next potential message . |
121,597 | public void run ( ) { while ( mRunning ) { waitForCallback ( ) ; Log . d ( TAG , "Starting trace playback from beginning of " + mFilename ) ; BufferedReader reader = null ; if ( checkPermission ( ) ) { try { reader = openFile ( mFilename ) ; } catch ( DataSourceException e ) { Log . w ( TAG , "Couldn't open the trace f... | While running continuously read from the trace file and send messages to the callback . |
121,598 | private void waitForNextRecord ( long startingTime , long timestamp ) { if ( mFirstTimestamp == 0 ) { mFirstTimestamp = timestamp ; Log . d ( TAG , "Storing " + timestamp + " as the first " + "timestamp of the trace file" ) ; } long targetTime = startingTime + ( timestamp - mFirstTimestamp ) ; long sleepDuration = Math... | Using the startingTime as the relative starting point sleep this thread until the next timestamp would occur . |
121,599 | public void stop ( ) { super . stop ( ) ; try { getContext ( ) . unregisterReceiver ( mBroadcastReceiver ) ; } catch ( IllegalArgumentException e ) { Log . d ( TAG , "Unable to unregister receiver when stopping, probably not registered" ) ; } } | Unregister USB device intent broadcast receivers and stop waiting for a connection . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.