idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
134,000
private boolean scan ( ) { if ( btAdapter . startLeScan ( mCallback ) ) { mScanning = true ; Log . i ( TAG , "BLE scan started successfully" ) ; if ( mHandler . postDelayed ( scanTimeoutCallback , scanTimeout * 1000 ) ) { Log . i ( TAG , String . format ( "Cancelling discovery in %d seconds" , scanTimeout ) ) ; } else ...
Helper function for starting scan and scheduling the scan timeout
134,001
public void setScanTimeout ( int timeout ) { scanTimeout = timeout ; Log . i ( TAG , String . format ( "New scan timeout set: %d seconds" , scanTimeout ) ) ; }
Set the desired scan timeout in seconds
134,002
public boolean startDiscovery ( ) { if ( mScanning ) { Log . e ( TAG , "Already discovering" ) ; return true ; } if ( mListener == null ) { throw new NullPointerException ( "Listener cannot be null" ) ; } return scan ( ) ; }
Start discovering nearby Beans using an existing BeanListener .
134,003
public void cancelDiscovery ( ) { mHandler . removeCallbacks ( scanTimeoutCallback ) ; if ( mScanning ) { Log . i ( TAG , "Cancelling discovery process" ) ; BluetoothAdapter . getDefaultAdapter ( ) . stopLeScan ( mCallback ) ; mScanning = false ; boolean success = mHandler . post ( new Runnable ( ) { public void run ( ...
Cancel a scan currently in progress . If no scan is in progress this method does nothing .
134,004
public static byte [ ] decompressSafe ( final byte [ ] src , int maxDecompressedSize ) { if ( src == null ) { throw new IllegalArgumentException ( "src must not be null." ) ; } if ( maxDecompressedSize <= 0 ) { throw new IllegalArgumentException ( "maxDecompressedSize must be larger than 0 but " + maxDecompressedSize )...
When the exact decompressed size is unknown . Decompress data size cannot be larger then maxDecompressedSize
134,005
public static byte [ ] decompressFast ( byte [ ] src , int srcOffset , int exactDecompressedSize ) { if ( src == null ) { throw new IllegalArgumentException ( "src must not be null." ) ; } if ( srcOffset < 0 ) { throw new IllegalArgumentException ( "srcOffset must equal to or larger than 0 but " + srcOffset ) ; } if ( ...
When the exact decompressed size is known use this method to decompress . It s faster .
134,006
public static SketchHex create ( String sketchName , String hexString ) throws HexParsingException { if ( sketchName . length ( ) > Constants . MAX_SKETCH_NAME_LENGTH ) { sketchName = sketchName . substring ( 0 , Constants . MAX_SKETCH_NAME_LENGTH ) ; } List < Line > lines = parseHexStringToLines ( hexString ) ; byte [...
Initialize a SketchHex object with a string of Intel Hex data .
134,007
public static < T extends Chunkable > byte [ ] bytesFrom ( T chunkable , int offset , int length ) { byte [ ] data = chunkable . getChunkableData ( ) ; if ( offset + length > data . length ) { return Arrays . copyOfRange ( data , offset , data . length ) ; } else { return Arrays . copyOfRange ( data , offset , offset +...
Retrieve a number of raw bytes at an offset .
134,008
public static < T extends Chunkable > byte [ ] chunkFrom ( T chunkable , int chunkLength , int chunkNum ) { int start = chunkNum * chunkLength ; return bytesFrom ( chunkable , start , chunkLength ) ; }
Retrieve a chunk of raw bytes . Chunks are created by slicing the array at even intervals . The final chunk may be shorter than the other chunks if it s been truncated .
134,009
public static < T extends Chunkable > int chunkCountFrom ( T chunkable , int chunkLength ) { byte [ ] data = chunkable . getChunkableData ( ) ; return ( int ) Math . ceil ( data . length * 1.0 / chunkLength ) ; }
Retrieve the count of chunks for a given chunk length .
134,010
public static < T extends Chunkable > List < byte [ ] > chunksFrom ( T chunkable , int chunkLength ) { List < byte [ ] > chunks = new ArrayList < > ( ) ; int chunkCount = chunkCountFrom ( chunkable , chunkLength ) ; for ( int i = 0 ; i < chunkCount ; i ++ ) { byte [ ] chunk = chunkFrom ( chunkable , chunkLength , i ) ;...
Retrieve all chunks for a given chunk length . The final chunk may be shorter than the other chunks if it s been truncated .
134,011
public static int twoBytesToInt ( byte [ ] bytes , ByteOrder order ) { if ( order == ByteOrder . BIG_ENDIAN ) { return bytesToInt ( bytes [ 0 ] , bytes [ 1 ] ) ; } else if ( order == ByteOrder . LITTLE_ENDIAN ) { return bytesToInt ( bytes [ 1 ] , bytes [ 0 ] ) ; } else { throw new IllegalArgumentException ( "ByteOrder ...
Convert an array of two unsigned bytes with the given byte order to one signed int .
134,012
public static byte [ ] intArrayToByteArray ( int [ ] intArray ) { byte [ ] byteArray = new byte [ intArray . length ] ; for ( int i = 0 ; i < intArray . length ; i ++ ) { byteArray [ i ] = intToByte ( intArray [ i ] ) ; } return byteArray ; }
Convert an array of ints to an array of unsigned bytes . This is useful when you want to construct a literal array of unsigned bytes with values greater than 127 . Only the lowest 8 bits of the int values are used .
134,013
public static byte [ ] intToUInt32 ( int i , ByteOrder endian ) { int truncated = ( int ) ( ( long ) i ) ; return ByteBuffer . allocate ( 4 ) . order ( endian ) . putInt ( truncated ) . array ( ) ; }
Convert an int to a four - byte array of its representation as an unsigned byte .
134,014
public static GattSerialMessage fromPayload ( byte [ ] payload ) { Buffer buffer = new Buffer ( ) ; byte [ ] header = new byte [ 2 ] ; header [ 0 ] = ( byte ) ( payload . length & 0xff ) ; header [ 1 ] = 0 ; int crc = computeCRC16 ( header , 0 , header . length ) ; crc = computeCRC16 ( crc , payload , 0 , payload . len...
Create a GattSerialMessage from a byte array payload
134,015
public static int bytesToInt ( byte [ ] bytes ) { int value = ( ( int ) bytes [ 0 ] & 0xFF ) << 24 ; value += ( ( int ) bytes [ 1 ] & 0xFF ) << 16 ; value += ( ( int ) bytes [ 2 ] & 0xFF ) << 8 ; value += ( int ) bytes [ 3 ] & 0xFF ; return value ; }
4 bytes array to int
134,016
public void send ( byte [ ] data , int id ) { boolean isFirstPacket = ( packets . size ( ) == 0 ) ; packets . add ( data ) ; ids . add ( id ) ; if ( isFirstPacket ) { scheduleSendTask ( true ) ; } Log . d ( TAG , "Added packet " + id + " to buffer; " + packets . size ( ) + " packets in buffer" ) ; }
Add a packet to the buffer to be sent . If no other packets are in the buffer it will be sent immediately .
134,017
private void scheduleSendTask ( boolean runNow ) { TimerTask task = new TimerTask ( ) { public void run ( ) { byte [ ] packet ; try { packet = packets . get ( 0 ) ; } catch ( IndexOutOfBoundsException e ) { return ; } charc . setValue ( packet ) ; boolean result = gattClient . writeCharacteristic ( charc ) ; if ( resul...
Schedules the send task to run either immediately or at SEND_INTERVAL .
134,018
public void setSbbContext ( SbbContext context ) { sbbContext = ( SbbContextExt ) context ; sipActivityContextInterfaceFactory = ( SipActivityContextInterfaceFactory ) sbbContext . getActivityContextInterfaceFactory ( sipRATypeID ) ; sleeSipProvider = ( SleeSipProvider ) sbbContext . getResourceAdaptorInterface ( sipRA...
SbbObject lifecycle methods
134,019
private ContactHeader getContactHeader ( ) throws ParseException { if ( contactHeader == null ) { final ListeningPoint listeningPoint = sleeSipProvider . getListeningPoint ( "udp" ) ; final javax . sip . address . SipURI sipURI = addressFactory . createSipURI ( null , listeningPoint . getIPAddress ( ) ) ; sipURI . setP...
some helper methods to deal with lazy init of static fields
134,020
public void onInviteEvent ( javax . sip . RequestEvent requestEvent , ActivityContextInterface aci ) { final ServerTransaction serverTransaction = requestEvent . getServerTransaction ( ) ; try { Response response = messageFactory . createResponse ( Response . TRYING , requestEvent . getRequest ( ) ) ; serverTransaction...
Event handler method for the invite SIP message .
134,021
public void onTimerEvent ( TimerEvent event , ActivityContextInterface aci ) { if ( getFinalReplySent ( ) ) { aci . detach ( sbbContext . getSbbLocalObject ( ) ) ; final DialogActivity dialog = ( DialogActivity ) aci . getActivity ( ) ; try { dialog . sendRequest ( dialog . createRequest ( Request . BYE ) ) ; } catch (...
Event handler method for the timer event .
134,022
public void getBindingsResult ( int resultCode , List < RegistrationBinding > bindings ) { ServerTransaction serverTransaction = getRegisterTransactionToReply ( ) ; if ( serverTransaction == null ) { tracer . warning ( "failed to find SIP server tx to send response" ) ; return ; } try { if ( resultCode < 300 ) { sendRe...
call backs from data source child sbb
134,023
private void cancelTimers ( List < org . mobicents . slee . example . sjr . data . RegistrationBinding > removedContacts ) { for ( RegistrationBinding binding : removedContacts ) { ActivityContextInterfaceExt aci = ( ActivityContextInterfaceExt ) this . activityContextNamingFacility . lookup ( getACIName ( binding . ge...
Simple method to cancel pending timers for contacts that have been removed
134,024
private void updateTimers ( List < org . mobicents . slee . example . sjr . data . RegistrationBinding > contacts ) { String bindingAciName = null ; ActivityContextInterface aci = null ; for ( RegistrationBinding binding : contacts ) { bindingAciName = getACIName ( binding . getContactAddress ( ) , binding . getSipAddr...
Simple method to update timers for passed contacts . If timer exists it will be reset to new timeout . If it does not exist it will be create along with NullActivity .
134,025
public DialogWrapper getDialogWrapper ( Dialog d ) { if ( d == null ) { return null ; } DialogWrapper dw = null ; DialogWrapperAppData dwad = ( DialogWrapperAppData ) d . getApplicationData ( ) ; if ( dwad != null ) { dw = dwad . getDialogWrapper ( d , this ) ; } return dw ; }
Retrieves the wrapper associated with a dialog recreating if needed in a cluster env .
134,026
public TransactionWrapper getTransactionWrapper ( Transaction t ) { if ( t == null ) { return null ; } final TransactionWrapperAppData twad = ( TransactionWrapperAppData ) t . getApplicationData ( ) ; return twad != null ? twad . getTransactionWrapper ( t , this ) : null ; }
Retrieves the wrapper associated with a tx recreating if needed in a cluster env .
134,027
public static List < RouteHeader > getRouteList ( Response response , HeaderFactory headerFactory ) throws ParseException { final ArrayList < RouteHeader > routeList = new ArrayList < RouteHeader > ( ) ; final ListIterator < ? > rrLit = response . getHeaders ( RecordRouteHeader . NAME ) ; while ( rrLit . hasNext ( ) ) ...
Generates route list the same way dialog does .
134,028
public static URI getRequestUri ( Response response , AddressFactory addressFactory ) throws ParseException { final ContactHeader contact = ( ( ContactHeader ) response . getHeader ( ContactHeader . NAME ) ) ; return ( contact != null ) ? ( URI ) contact . getAddress ( ) . getURI ( ) . clone ( ) : null ; }
Forges Request - URI using contact and To name par to address URI this is required on dialog fork this is how target is determined
134,029
public void onMessageEvent ( javax . sip . RequestEvent event , ActivityContextInterface aci ) { final Request request = event . getRequest ( ) ; try { final String body = new String ( request . getRawContent ( ) ) ; final int firstTokenStart = body . indexOf ( FIRST_TOKEN ) ; final int timerDurationStart = firstTokenS...
Event handler for the SIP MESSAGE from the UA
134,030
public void onTimerEvent ( TimerEvent event , ActivityContextInterface aci ) { aci . detach ( sbbContext . getSbbLocalObject ( ) ) ; try { DataSourceChildSbbLocalInterface child = ( DataSourceChildSbbLocalInterface ) getLocationChildRelation ( ) . create ( ) ; child . getBindings ( getSender ( ) . getURI ( ) . toString...
Event handler from the timer event which signals that a message must be sent back to the UA
134,031
public void serviceActive ( ReceivableService receivableService ) { for ( ReceivableEvent receivableEvent : receivableService . getReceivableEvents ( ) ) { Set < ServiceID > servicesReceivingEvent = eventID2serviceIDs . get ( receivableEvent . getEventType ( ) ) ; if ( servicesReceivingEvent == null ) { servicesReceivi...
Informs the filter that a receivable service is now active . For the events related with the service and if there are no other services bound then events of such event type should now not be filtered .
134,032
public void serviceInactive ( ReceivableService receivableService ) { for ( ReceivableEvent receivableEvent : receivableService . getReceivableEvents ( ) ) { Set < ServiceID > servicesReceivingEvent = eventID2serviceIDs . get ( receivableEvent . getEventType ( ) ) ; if ( servicesReceivingEvent != null ) { synchronized ...
Informs the filter that a receivable service is now inactive . For the events related with the service if there are no other services bound then events of such event type should be filtered
134,033
public FireableEventType getEventId ( EventLookupFacility eventLookupFacility , Request request , boolean inDialogActivity ) { final String requestMethod = request . getMethod ( ) ; if ( requestMethod . equals ( Request . CANCEL ) ) inDialogActivity = false ; FireableEventType eventID = null ; if ( inDialogActivity ) {...
Retrieves the event id for a SIP Request event .
134,034
public FireableEventType getEventId ( EventLookupFacility eventLookupFacility , Response response ) { String statusCodeName = null ; final int responseStatus = response . getStatusCode ( ) ; if ( responseStatus == 100 ) { statusCodeName = "TRYING" ; } else if ( 100 < responseStatus && responseStatus < 200 ) { statusCod...
Retrieves the event id for a SIP Response event .
134,035
private void executeTask ( DataSourceJdbcTask jdbcTask ) { JdbcActivity jdbcActivity = jdbcRA . createActivity ( ) ; ActivityContextInterface jdbcACI = jdbcACIF . getActivityContextInterface ( jdbcActivity ) ; jdbcACI . attach ( sbbContextExt . getSbbLocalObject ( ) ) ; jdbcActivity . execute ( jdbcTask ) ; }
Simple method to create JDBC activity and execute given task .
134,036
protected final void args ( Object ... args ) { if ( args == null ) args = NO_ARGS ; this . args = args ; retry ( ) ; }
Sets the arguments for internal use only .
134,037
private synchronized void ensureIsRun ( ) { if ( ! isRun ) { isRun = true ; try { result = executeProc ( args ) ; exception = null ; } catch ( ProcError e ) { throw e . asRuntimeException ( ) ; } catch ( Throwable t ) { exception = t ; result = null ; } } }
Execute the proc if not done so already .
134,038
protected int describeArgsTo ( Description description ) { for ( int i = 0 ; i < args . length ; i ++ ) { if ( i > 0 ) description . appendText ( ", " ) ; description . appendValue ( args [ i ] ) ; } return args . length ; }
Describes the arguments that are used for execution this asProc .
134,039
public static long fromAlpha1 ( String s ) { s = s . trim ( ) ; if ( s . isEmpty ( ) ) return 0 ; return fromAlpha ( s ) + 1 ; }
Parses a one - based alpha - index . An empty string will be parsed as zero .
134,040
protected Object run ( A a , B b , C c , D d ) throws Throwable { throw notImplemented ( "run(A, B, C, D)" ) ; }
Executes the proc .
134,041
public static < T > T boxAllAs ( Object src , Class < T > type ) { return ( T ) boxAll ( type , src , 0 , - 1 ) ; }
Transforms any array into an array of boxed values .
134,042
public < E extends Enum < ? > > String getMessage ( E key , Object ... args ) throws MessageConveyorException { String declararingClassName = key . getDeclaringClass ( ) . getName ( ) ; CAL10NResourceBundle rb = cache . get ( declararingClassName ) ; if ( rb == null || rb . hasChanged ( ) ) { rb = lookup ( key ) ; cach...
Given an enum as key find the corresponding resource bundle and return the corresponding internationalized .
134,043
public int findHighestKey ( int max ) { int highest = Integer . MIN_VALUE ; int index = index ( hash ( max ) ) ; final int maxTry = capacity ; for ( int i = 0 ; i < maxTry ; i ++ ) { if ( ! slotIsFree ( index ) ) { int k = keys [ index ] ; if ( k == max ) return max ; if ( max > k && k > highest ) highest = k ; } index...
Finds the highest key LE max for which there is a value .
134,044
public int findLowestKey ( int min ) { int lowest = Integer . MAX_VALUE ; int index = index ( hash ( min ) ) ; final int maxTry = capacity ; for ( int i = 0 ; i < maxTry ; i ++ ) { if ( ! slotIsFree ( index ) ) { int k = keys [ index ] ; if ( k == min ) return min ; if ( min < k && k < lowest ) lowest = k ; } index = n...
Finds the highest key GE min for which there is a value .
134,045
private int find ( int key , int hash ) { int index = index ( hash ) ; final int maxTry = capacity ; for ( int i = 0 ; i < maxTry ; i ++ ) { Object slot = values [ index ] ; if ( slot == null ) return - 1 ; if ( slot != GUARD ) return keys [ index ] == key ? index : - 1 ; index = nextIndex ( index ) ; } return - 1 ; }
Finds the slot of an existing value for key ;
134,046
private int findInsertIndex ( int key , int hash ) { int index = index ( hash ) ; final int maxTry = capacity ; for ( int i = 0 ; i < maxTry ; i ++ ) { if ( slotIsFree ( index ) ) return index ; index = nextIndex ( index ) ; } throw new IllegalStateException ( "Free slots expected" ) ; }
Find slot to inser key - value
134,047
public UriMappingResolver addResource ( String uri , String resource ) { uriMap . put ( uri , resource ) ; return this ; }
Adds a single resource that can be looked - up by its uri .
134,048
protected String getMappingString ( ) { StringBuilder sb = new StringBuilder ( ) ; final int schemaSize = uriMap . size ( ) ; final int domainSize = patternMap . size ( ) ; int s = 0 , d = 0 ; for ( String schema : uriMap . keySet ( ) ) { if ( s > 0 ) sb . append ( ", " ) ; sb . append ( schema ) ; s ++ ; if ( s > 2 &&...
string representation for debugging purposes
134,049
protected String expandSystemId ( String baseId , String systemId ) { return getRequest ( ) . expandSystemId ( baseId , systemId ) ; }
Calculates the resource location .
134,050
private static int quoteSingle ( final StringBuilder sb , final String string , final int start ) { int i = start + 1 ; if ( needsBlockQuoting ( string . charAt ( start ) ) ) return - i ; int unquoteLen = 0 ; int quotedMap = 1 ; for ( int j = 1 ; i < string . length ( ) ; i ++ , j ++ ) { char c = string . charAt ( i ) ...
Tries to quote each character with a backslash .
134,051
public static boolean useParentheses ( int pSelf , int pNested ) { if ( pSelf == PrecedencedSelfDescribing . P_NONE || pSelf == PrecedencedSelfDescribing . P_UNARY_NO_PAREN ) { return false ; } if ( pNested < PrecedencedSelfDescribing . P_UNARY ) { return pNested <= pSelf ; } else { return pNested < pSelf ; } }
Compares own precedence against nested and return
134,052
private int compareParameter ( Class < ? > a , Class < ? > b ) { final int a_preferred = - 1 ; if ( a . equals ( b ) ) { return 0 ; } else if ( b . isAssignableFrom ( a ) ) { return a_preferred ; } else if ( a . isAssignableFrom ( b ) ) { return - a_preferred ; } else { return 0 ; } }
Compares two parameter types .
134,053
public int applicability ( final Class < ? > [ ] paramTypes , boolean varArgs ) { if ( argTypes == null ) { return MATCH_WILDCARD ; } int level = MATCH ; final int fixArgs = paramTypes . length - ( varArgs ? 1 : 0 ) ; if ( fixArgs > argTypes . length || ( ! varArgs && fixArgs != argTypes . length ) ) { return NO_MATCH ...
Returns the applicabilty of a signature . A signature with higher applicability is always preferred even if the other is more specific .
134,054
public static int maxLetterValue ( final int numberOfLetters ) { int v = 1 ; for ( int i = 1 ; i < numberOfLetters ; i ++ ) { v *= i % 2 == 0 ? 2 : 5 ; } return v ; }
Given an array of letters returns the value of the highest letter .
134,055
public static String toRoman ( final int number , final int [ ] [ ] digits , final String zero , final String [ ] letters ) { int maxVal = maxLetterValue ( letters ) ; return toRoman ( new StringBuilder ( ) , number , digits , zero , letters , maxVal ) . toString ( ) ; }
Converts an integer into a roman number .
134,056
public List < Object > match ( ) { final IntMatchResults result = new IntMatchResults ( ) ; if ( matches ( result ) ) { return result . getIntResultList ( ) ; } else { return null ; } }
Matches the entire input and returns a list of extracted values .
134,057
public boolean find ( int start , MatchResults result ) { if ( ! matcher . find ( start ) ) return false ; applyMatch ( result ) ; return true ; }
Finds the next match and fills the result
134,058
public static < T > Constructor < T > bestConstructor ( Class < T > clazz , Object [ ] args ) throws AmbiguousConstructorMatchException { return bestConstructor ( collectConstructors ( clazz ) , args ) ; }
Finds the best constructor for the given arguments .
134,059
public static < T > Constructor < T > bestConstructor ( Class < T > clazz , Class < ? > [ ] argTypes ) throws AmbiguousConstructorMatchException { return bestConstructor ( collectConstructors ( clazz ) , argTypes ) ; }
Finds the best constructor for the given arguments types .
134,060
public static < T > Constructor < T > bestConstructor ( Constructor < T > [ ] constructors , Object [ ] args ) throws AmbiguousConstructorMatchException { return bestConstructor ( constructors , collectArgTypes ( args ) ) ; }
Selects the best constructor for the given arguments .
134,061
public static < T > Constructor < T > bestConstructor ( Constructor < T > [ ] constructors , Class < ? > [ ] argTypes ) throws AmbiguousConstructorMatchException { try { return best ( constructors , collectSignatures ( constructors ) , collectVarArgs ( constructors ) , argTypes ) ; } catch ( AmbiguousSignatureMatchExce...
Selects the best constructor for the given argument types .
134,062
public static < T > Constructor < T > [ ] candidateConstructors ( Class < T > clazz , Object [ ] args ) { return candidateConstructors ( collectConstructors ( clazz ) , args ) ; }
Finds the best equally - matching constructors for the given arguments .
134,063
public static < T > Constructor < T > [ ] candidateConstructors ( Class < T > clazz , Class < ? > [ ] argTypes ) { return candidateConstructors ( collectConstructors ( clazz ) , argTypes ) ; }
Finds the best equally - matching constructors for the given argument types .
134,064
public static < T > Constructor < T > [ ] candidateConstructors ( Constructor < T > [ ] constructors , Object [ ] args ) { return candidateConstructors ( constructors , collectArgTypes ( args ) ) ; }
Selects the best equally - matching constructors for the given arguments .
134,065
public static < T > Constructor < T > [ ] candidateConstructors ( Constructor < T > [ ] constructors , Class < ? > [ ] argTypes ) { return candidates ( constructors , collectSignatures ( constructors ) , collectVarArgs ( constructors ) , argTypes ) ; }
Selects the best equally - matching constructors for the given argument types .
134,066
public static Method bestMethod ( Class < ? > clazz , String name , Object [ ] args ) throws AmbiguousMethodMatchException { return bestMethod ( collectMethods ( clazz , name ) , args ) ; }
Finds the best method for the given arguments .
134,067
public static Method bestMethod ( Class < ? > clazz , String name , Class < ? > [ ] argTypes ) throws AmbiguousMethodMatchException { return bestMethod ( collectMethods ( clazz , name ) , argTypes ) ; }
Finds the best method for the given argument types .
134,068
public static Method bestMethod ( Method [ ] methods , Object [ ] args ) throws AmbiguousMethodMatchException { return bestMethod ( methods , collectArgTypes ( args ) ) ; }
Selects the best method for the given arguments .
134,069
public static Method bestMethod ( Method [ ] methods , Class < ? > [ ] argTypes ) throws AmbiguousMethodMatchException { try { return best ( methods , collectSignatures ( methods ) , collectVarArgs ( methods ) , argTypes ) ; } catch ( AmbiguousSignatureMatchException e ) { throw new AmbiguousMethodMatchException ( e , ...
Selects the best method for the given argument types .
134,070
public static Method [ ] candidateMethods ( Class < ? > clazz , String name , Object [ ] args ) { return candidateMethods ( collectMethods ( clazz , name ) , args ) ; }
Finds the best equally - matching methods for the given arguments .
134,071
public static Method [ ] candidateMethods ( Class < ? > clazz , String name , Class < ? > [ ] argTypes ) { return candidateMethods ( collectMethods ( clazz , name ) , argTypes ) ; }
Finds the best equally - matching methods for the given argument types .
134,072
public static Method [ ] candidateMethods ( Method [ ] methods , Object [ ] args ) { return candidateMethods ( methods , collectArgTypes ( args ) ) ; }
Selects the best equally - matching methods for the given arguments .
134,073
public static Method [ ] candidateMethods ( Method [ ] methods , Class < ? > [ ] argTypes ) { return candidates ( methods , collectSignatures ( methods ) , collectVarArgs ( methods ) , argTypes ) ; }
Selects the best equally - matching methods for the given argument types .
134,074
public static < T > T best ( T [ ] items , Class < ? > [ ] [ ] signatures , boolean [ ] varArgs , Class < ? > [ ] argTypes ) throws AmbiguousSignatureMatchException { int i = bestMatch ( signatures , varArgs , argTypes ) ; if ( i < 0 ) return null ; return items [ i ] ; }
Selects the best item for the given argument types .
134,075
public static < T > T [ ] candidates ( T [ ] items , Class < ? > [ ] [ ] signatures , boolean [ ] varArgs , Class < ? > [ ] argTypes ) { final int [ ] indices = candidateMatches ( signatures , varArgs , argTypes ) ; T [ ] result = newArray ( items . getClass ( ) . getComponentType ( ) , indices . length ) ; for ( int i...
Selects the best equally - matching item for the given argument types .
134,076
public static int bestMatch ( Class < ? > [ ] [ ] signatures , boolean [ ] varArgs , Class < ? > [ ] argTypes ) throws AmbiguousSignatureMatchException { return bestMatch ( signatures , varArgs , new JavaSignatureComparator ( argTypes ) ) ; }
Selects the best match in signatures for the given argument types .
134,077
public static int [ ] candidateMatches ( Class < ? > [ ] [ ] signatures , boolean [ ] varArgs , Class < ? > [ ] argTypes ) { return candidateMatches ( signatures , varArgs , new JavaSignatureComparator ( argTypes ) ) ; }
Returns indices of all signatures that are a best match for the given argument types .
134,078
public static Object [ ] fixVarArgs ( Class < ? > [ ] paramsWithVarArgs , Object [ ] arguments ) { int n = paramsWithVarArgs . length ; return fixVarArgs ( n , paramsWithVarArgs [ n - 1 ] , arguments ) ; }
Fixes an arguments array to fit parameter types where the last parameter is an varargs array .
134,079
@ SuppressWarnings ( "SuspiciousSystemArraycopy" ) public static Object [ ] fixVarArgs ( int length , Class < ? > varArgType , Object [ ] arguments ) { final Object [ ] result ; if ( arguments . length == length && varArgType . isInstance ( arguments [ length - 1 ] ) ) { return arguments ; } else { result = Arrays . co...
Fixes an arguments array to fit a given length the last value is an array filled with varargs .
134,080
protected void uncountable ( String word ) { Rule r = new UncountableRule ( lower ( word ) ) ; plural ( r ) ; singular ( r ) ; }
Declares a word as uncountable which means that singular and plural are identical .
134,081
public synchronized Pluralizer register ( Locale l , Pluralizer p ) { return pluralizers . put ( l , p ) ; }
Registers a pluralizer
134,082
public synchronized Pluralizer find ( Locale l ) { while ( l != null ) { List < Locale > candidates = control . getCandidateLocales ( PLURALIZER_CLASS , l ) ; for ( Locale c : candidates ) { Pluralizer p = pluralizers . get ( c ) ; if ( p != null ) return p ; } l = control . getFallbackLocale ( PLURALIZER_CLASS , l ) ;...
Finds the best pluralizer for a locale .
134,083
public synchronized PluralizerRegistry copy ( ) { PluralizerRegistry r = new PluralizerRegistry ( control ) ; r . pluralizers . putAll ( pluralizers ) ; return r ; }
Creates a shallow copy of this registry .
134,084
protected Match < ? > match ( ) { Match < ? > m = result ( ) . getMatch ( ) ; if ( m == null ) { throw new IllegalStateException ( "Match failed" ) ; } return m ; }
For internal use . Fails if this is a mismatch .
134,085
protected Mismatch < ? > mismatch ( ) { Mismatch < ? > m = result ( ) . getMismatch ( ) ; if ( m == null ) { throw new IllegalStateException ( "Match succeded" ) ; } return m ; }
For internal use . Fails if this is a match .
134,086
public static ResolvingException wrap ( RRequest request , Exception e ) { if ( e instanceof ResolvingException ) return ( ResolvingException ) e ; return new ResolvingException ( request , e ) ; }
Wraps e in an resolving exception if it isn t one already .
134,087
public Throwable getResolvingCause ( ) { Throwable t = this , c = this ; while ( c instanceof ResolvingException ) { t = c ; c = t . getCause ( ) ; } return c == null ? t : c ; }
Returns the underlying cause of this resolving exceptions . Unpacks nested resolving exceptions if necessary .
134,088
protected String expandSystemId ( String baseId , String systemId ) { if ( baseId == null || baseId . isEmpty ( ) ) return systemId ; if ( systemId == null || systemId . isEmpty ( ) ) return baseId ; try { return new URI ( baseId ) . resolve ( new URI ( systemId ) ) . toASCIIString ( ) ; } catch ( URISyntaxException ex...
Calculates the schema file location .
134,089
public void push ( T token ) { if ( token == lastPushed ) return ; lastPushed = token ; if ( token . getChannel ( ) == TokenChannel . Default ) { main . add ( token ) ; } all . add ( token ) ; }
make Liskov spin
134,090
protected static char [ ] flags ( final CharSequence ... flagStrings ) { final StringBuilder sb = new StringBuilder ( ) ; for ( CharSequence flags : flagStrings ) sb . append ( flags ) ; return flags ( sb . toString ( ) ) ; }
Converts strings of flags into a sorted flag array that can be passed as a parameter to other utility methods .
134,091
protected static char [ ] flags ( final String flagString ) { if ( flagString == null || flagString . isEmpty ( ) ) { return NO_FLAGS ; } noDupsExcept ( flagString , NO_FLAGS ) ; final char [ ] flags = flagString . toCharArray ( ) ; Arrays . sort ( flags ) ; return flags ; }
Converts a string of flags into a sorted flag array that can be passed as a parameter to other utility methods .
134,092
protected void ensureNoFlags ( final String flags ) { if ( flags == null || flags . isEmpty ( ) ) return ; throw FormatException . formatFlagsMismatch ( flags , getFormatName ( ) ) ; }
Ensures no flags are given .
134,093
protected char selectFlag ( final String flags , final char [ ] choice ) { if ( flags == null ) return 0 ; StringBuilder conflict = null ; char found = 0 ; for ( int i = 0 ; i < flags . length ( ) ; i ++ ) { char f = flags . charAt ( i ) ; if ( oneOf ( f , choice ) ) { if ( found != 0 ) { if ( conflict == null ) confli...
Selects exactly one of the expected flags .
134,094
private void proxy ( final SipResponse msg ) { final ViaHeader via = msg . getViaHeader ( ) ; final Connection connection = this . stack . connect ( via . getHost ( ) , via . getPort ( ) ) ; connection . send ( msg ) ; }
Proxy the response to
134,095
private SipResponse processRegisterRequest ( final SipRequest request ) { final SipURI requestURI = ( SipURI ) request . getRequestUri ( ) ; final Buffer domain = requestURI . getHost ( ) ; final SipURI aor = getAOR ( request ) ; if ( ! validateDomain ( domain , aor ) ) { return request . createResponse ( 404 ) ; } fin...
Section 10 . 3 in RFC3261 outlines how to process a register request . For the purpose of this little exercise we are skipping many steps just to keep things simple .
134,096
private SipRequest generateAck ( final SipResponse response ) { final ContactHeader contact = response . getContactHeader ( ) ; final SipURI requestURI = ( SipURI ) contact . getAddress ( ) . getURI ( ) ; final ToHeader to = response . getToHeader ( ) ; final FromHeader from = response . getFromHeader ( ) ; final CSeqH...
Generating an ACK to a 2xx response is the same as any other subsequent request . However a subsequent request is generated in the context of what is known as a Dialog and since we currently are completely stateless this is not necessarily an easy thing to achieve but for now we will ignore many of the details .
134,097
public static ASN1OctetString getInstance ( Object obj ) { if ( obj == null || obj instanceof ASN1OctetString ) { return ( ASN1OctetString ) obj ; } if ( obj instanceof ASN1TaggedObject ) { return getInstance ( ( ( ASN1TaggedObject ) obj ) . getObject ( ) ) ; } if ( obj instanceof ASN1Sequence ) { Vector v = new Vector...
return an Octet String from the given object .
134,098
public static Logger get ( Class < ? > cls , String resourceBundleName ) { return Logger . getLogger ( cls . getPackage ( ) . getName ( ) , resourceBundleName ) ; }
Get a logger for the class s package that uses the resource bundle for localisation .
134,099
@ SuppressWarnings ( "unchecked" ) public static < T > T lookup ( String name ) { try { return ( T ) new InitialContext ( ) . lookup ( name ) ; } catch ( NamingException e ) { throw new IllegalStateException ( e ) ; } }
Get the named object in the starting context .