idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
200
public static AccessorPrefix determineAccessorPrefix ( @ Nonnull final String methodName ) { Check . notEmpty ( methodName , "methodName" ) ; final Matcher m = PATTERN . matcher ( methodName ) ; Check . stateIsTrue ( m . find ( ) , "passed method name '%s' is not applicable" , methodName ) ; return new AccessorPrefix (...
Determines the prefix of an accessor method based on an accessor method name .
96
18
201
public static String determineFieldName ( @ Nonnull final String methodName ) { Check . notEmpty ( methodName , "methodName" ) ; final Matcher m = PATTERN . matcher ( methodName ) ; Check . stateIsTrue ( m . find ( ) , "passed method name '%s' is not applicable" , methodName ) ; return m . group ( 2 ) . substring ( 0 ,...
Determines the field name based on an accessor method name .
111
14
202
public static < T extends JsonRtn > T parseJsonRtn ( String jsonRtn , Class < T > jsonRtnClazz ) { T rtn = JSONObject . parseObject ( jsonRtn , jsonRtnClazz ) ; appendErrorHumanMsg ( rtn ) ; return rtn ; }
parse json text to specified class
68
6
203
private static JsonRtn appendErrorHumanMsg ( JsonRtn jsonRtn ) { if ( bundle == null || jsonRtn == null || StringUtils . isEmpty ( jsonRtn . getErrCode ( ) ) ) { return null ; } try { jsonRtn . setErrHumanMsg ( bundle . getString ( jsonRtn . getErrCode ( ) ) ) ; return jsonRtn ; } catch ( Exception e ) { return null ; ...
append human message to JsonRtn class
103
9
204
public static boolean isSuccess ( JsonRtn jsonRtn ) { if ( jsonRtn == null ) { return false ; } String errCode = jsonRtn . getErrCode ( ) ; if ( StringUtils . isEmpty ( errCode ) || StringUtils . equals ( WECHAT_JSON_RTN_SUCCESS_CODE , errCode ) ) { return true ; } return false ; }
return request is success by JsonRtn object
91
10
205
public static Object unmarshal ( String message , Class < ? > childClass ) { try { Class < ? > [ ] reverseAndToArray = Iterables . toArray ( Lists . reverse ( getAllSuperTypes ( childClass ) ) , Class . class ) ; JAXBContext jaxbCtx = JAXBContext . newInstance ( reverseAndToArray ) ; Unmarshaller unmarshaller = jaxbCtx...
xml - > object
137
4
206
public static String marshal ( Object object ) { if ( object == null ) { return null ; } try { JAXBContext jaxbCtx = JAXBContext . newInstance ( object . getClass ( ) ) ; Marshaller marshaller = jaxbCtx . createMarshaller ( ) ; marshaller . setProperty ( Marshaller . JAXB_FRAGMENT , Boolean . TRUE ) ; StringWriter sw =...
object - > xml
135
4
207
private Properties parseFile ( File file ) throws InvalidDeclarationFileException { Properties properties = new Properties ( ) ; InputStream is = null ; try { is = new FileInputStream ( file ) ; properties . load ( is ) ; } catch ( Exception e ) { throw new InvalidDeclarationFileException ( String . format ( "Error rea...
Parse the given file to obtains a Properties object .
199
12
208
private D createAndRegisterDeclaration ( Map < String , Object > metadata ) { D declaration ; if ( klass . equals ( ImportDeclaration . class ) ) { declaration = ( D ) ImportDeclarationBuilder . fromMetadata ( metadata ) . build ( ) ; } else if ( klass . equals ( ExportDeclaration . class ) ) { declaration = ( D ) Expo...
Create and register the declaration of class D with the given metadata .
122
13
209
void start ( String monitoredDirectory , Long pollingTime ) { this . monitoredDirectory = monitoredDirectory ; String deployerKlassName ; if ( klass . equals ( ImportDeclaration . class ) ) { deployerKlassName = ImporterDeployer . class . getName ( ) ; } else if ( klass . equals ( ExportDeclaration . class ) ) { deploy...
This method must be called on the start of the component . Initialize and start the directory monitor .
204
20
210
void stop ( ) { try { dm . stop ( getBundleContext ( ) ) ; } catch ( DirectoryMonitoringException e ) { LOG . error ( "Failed to stop " + DirectoryMonitor . class . getName ( ) + " for the directory " + monitoredDirectory , e ) ; } declarationsFiles . clear ( ) ; declarationRegistrationManager . unregisterAll ( ) ; }
This method must be called on the stop of the component . Stop the directory monitor and unregister all the declarations .
82
23
211
public static double calculateBoundedness ( double D , int N , double timelag , double confRadius ) { double r = confRadius ; double cov_area = a ( N ) * D * timelag ; double res = cov_area / ( 4 * r * r ) ; return res ; }
Calculates the Boundedness value to given confinement radius diffusion coefficient timlag and number of steps .
67
21
212
public static double getRadiusToBoundedness ( double D , int N , double timelag , double B ) { double cov_area = a ( N ) * D * timelag ; double radius = Math . sqrt ( cov_area / ( 4 * B ) ) ; return radius ; }
Calculates the radius to a given boundedness value
65
11
213
@ ArgumentsChecked @ Throws ( IllegalNullArgumentException . class ) public static byte checkByte ( @ Nonnull final Number number ) { Check . notNull ( number , "number" ) ; if ( ! isInByteRange ( number ) ) { throw new IllegalNumberRangeException ( number . toString ( ) , BYTE_MIN , BYTE_MAX ) ; } return number . byte...
Checks if a given number is in the range of a byte .
90
14
214
@ ArgumentsChecked @ Throws ( IllegalNullArgumentException . class ) public static double checkDouble ( @ Nonnull final Number number ) { Check . notNull ( number , "number" ) ; if ( ! isInDoubleRange ( number ) ) { throw new IllegalNumberRangeException ( number . toString ( ) , DOUBLE_MIN , DOUBLE_MAX ) ; } return num...
Checks if a given number is in the range of a double .
92
14
215
@ ArgumentsChecked @ Throws ( IllegalNullArgumentException . class ) public static float checkFloat ( @ Nonnull final Number number ) { Check . notNull ( number , "number" ) ; if ( ! isInFloatRange ( number ) ) { throw new IllegalNumberRangeException ( number . toString ( ) , FLOAT_MIN , FLOAT_MAX ) ; } return number ....
Checks if a given number is in the range of a float .
92
14
216
@ ArgumentsChecked @ Throws ( IllegalNullArgumentException . class ) public static int checkInteger ( @ Nonnull final Number number ) { Check . notNull ( number , "number" ) ; if ( ! isInIntegerRange ( number ) ) { throw new IllegalNumberRangeException ( number . toString ( ) , INTEGER_MIN , INTEGER_MAX ) ; } return nu...
Checks if a given number is in the range of an integer .
92
14
217
@ ArgumentsChecked @ Throws ( IllegalNullArgumentException . class ) public static int checkLong ( @ Nonnull final Number number ) { Check . notNull ( number , "number" ) ; if ( ! isInLongRange ( number ) ) { throw new IllegalNumberRangeException ( number . toString ( ) , LONG_MIN , LONG_MAX ) ; } return number . intVa...
Checks if a given number is in the range of a long .
88
14
218
@ ArgumentsChecked @ Throws ( IllegalNullArgumentException . class ) public static short checkShort ( @ Nonnull final Number number ) { Check . notNull ( number , "number" ) ; if ( ! isInShortRange ( number ) ) { throw new IllegalNumberRangeException ( number . toString ( ) , SHORT_MIN , SHORT_MAX ) ; } return number ....
Checks if a given number is in the range of a short .
90
14
219
public double estimateExcludedVolumeFraction ( ) { //Calculate volume/area of the of the scene without obstacles if ( recalculateVolumeFraction ) { CentralRandomNumberGenerator r = CentralRandomNumberGenerator . getInstance ( ) ; boolean firstRandomDraw = false ; if ( randomNumbers == null ) { randomNumbers = new doubl...
Estimate excluded volume fraction by monte carlo method
229
11
220
private void handleMultiInstanceReportResponse ( SerialMessage serialMessage , int offset ) { logger . trace ( "Process Multi-instance Report" ) ; int commandClassCode = serialMessage . getMessagePayloadByte ( offset ) ; int instances = serialMessage . getMessagePayloadByte ( offset + 1 ) ; if ( instances == 0 ) { setI...
Handles Multi Instance Report message . Handles Report on the number of instances for the command class .
390
21
221
private void handleMultiInstanceEncapResponse ( SerialMessage serialMessage , int offset ) { logger . trace ( "Process Multi-instance Encapsulation" ) ; int instance = serialMessage . getMessagePayloadByte ( offset ) ; int commandClassCode = serialMessage . getMessagePayloadByte ( offset + 1 ) ; CommandClass commandCla...
Handles Multi Instance Encapsulation message . Decapsulates an Application Command message and handles it using the right instance .
313
25
222
private void handleMultiChannelEncapResponse ( SerialMessage serialMessage , int offset ) { logger . trace ( "Process Multi-channel Encapsulation" ) ; CommandClass commandClass ; ZWaveCommandClass zwaveCommandClass ; int endpointId = serialMessage . getMessagePayloadByte ( offset ) ; int commandClassCode = serialMessag...
Handles Multi Channel Encapsulation message . Decapsulates an Application Command message and handles it using the right endpoint .
482
24
223
public SerialMessage getMultiInstanceGetMessage ( CommandClass commandClass ) { logger . debug ( "Creating new message for application command MULTI_INSTANCE_GET for node {} and command class {}" , this . getNode ( ) . getNodeId ( ) , commandClass . getLabel ( ) ) ; SerialMessage result = new SerialMessage ( this . get...
Gets a SerialMessage with the MULTI INSTANCE GET command . Returns the number of instances for this command class .
195
25
224
public SerialMessage getMultiChannelCapabilityGetMessage ( ZWaveEndpoint endpoint ) { logger . debug ( "Creating new message for application command MULTI_CHANNEL_CAPABILITY_GET for node {} and endpoint {}" , this . getNode ( ) . getNodeId ( ) , endpoint . getEndpointId ( ) ) ; SerialMessage result = new SerialMessage ...
Gets a SerialMessage with the MULTI CHANNEL CAPABILITY GET command . Gets the capabilities for a specific endpoint .
209
27
225
public synchronized void createImportationDeclaration ( String deviceId , String deviceType , String deviceSubType ) { Map < String , Object > metadata = new HashMap < String , Object > ( ) ; metadata . put ( Constants . DEVICE_ID , deviceId ) ; metadata . put ( Constants . DEVICE_TYPE , deviceType ) ; metadata . put (...
Create an import declaration and delegates its registration for an upper class .
149
13
226
public static Dimension getDimension ( File videoFile ) throws IOException { try ( FileInputStream fis = new FileInputStream ( videoFile ) ) { return getDimension ( fis , new AtomicReference < ByteBuffer > ( ) ) ; } }
Returns the dimensions for the video
54
6
227
public static String determineAccessorName ( @ Nonnull final AccessorPrefix prefix , @ Nonnull final String fieldName ) { Check . notNull ( prefix , "prefix" ) ; Check . notEmpty ( fieldName , "fieldName" ) ; final Matcher m = PATTERN . matcher ( fieldName ) ; Check . stateIsTrue ( m . find ( ) , "passed field name '%s...
Determines the accessor method name based on a field name .
143
14
228
public static String determineMutatorName ( @ Nonnull final String fieldName ) { Check . notEmpty ( fieldName , "fieldName" ) ; final Matcher m = PATTERN . matcher ( fieldName ) ; Check . stateIsTrue ( m . find ( ) , "passed field name '%s' is not applicable" , fieldName ) ; final String name = m . group ( ) ; return M...
Determines the mutator method name based on a field name .
122
14
229
@ Nonnull public static XMLDSigValidationResult createReferenceErrors ( @ Nonnull @ Nonempty final List < Integer > aInvalidReferences ) { return new XMLDSigValidationResult ( aInvalidReferences ) ; }
An invalid reference or references . The verification of the digest of a reference failed . This can be caused by a change to the referenced data since the signature was generated .
47
33
230
public static Chart getTrajectoryChart ( String title , Trajectory t ) { if ( t . getDimension ( ) == 2 ) { double [ ] xData = new double [ t . size ( ) ] ; double [ ] yData = new double [ t . size ( ) ] ; for ( int i = 0 ; i < t . size ( ) ; i ++ ) { xData [ i ] = t . get ( i ) . x ; yData [ i ] = t . get ( i ) . y ; ...
Plots the trajectory
180
4
231
public static Chart getMSDLineChart ( Trajectory t , int lagMin , int lagMax , AbstractMeanSquaredDisplacmentEvaluator msdeval ) { double [ ] xData = new double [ lagMax - lagMin + 1 ] ; double [ ] yData = new double [ lagMax - lagMin + 1 ] ; msdeval . setTrajectory ( t ) ; msdeval . setTimelag ( lagMin ) ; for ( int i...
Plots the MSD curve for trajectory t
231
9
232
public static Chart getMSDLineWithConfinedModelChart ( Trajectory t , int lagMin , int lagMax , double timelag , double a , double b , double c , double d ) { double [ ] xData = new double [ lagMax - lagMin + 1 ] ; double [ ] yData = new double [ lagMax - lagMin + 1 ] ; double [ ] modelData = new double [ lagMax - lagM...
Plots the MSD curve with the trajectory t and adds the fitted model for confined diffusion above .
427
20
233
public static Chart getMSDLineWithPowerModelChart ( Trajectory t , int lagMin , int lagMax , double timelag , double a , double D ) { double [ ] xData = new double [ lagMax - lagMin + 1 ] ; double [ ] yData = new double [ lagMax - lagMin + 1 ] ; double [ ] modelData = new double [ lagMax - lagMin + 1 ] ; MeanSquaredDis...
Plots the MSD curve with the trajectory t and adds the fitted model for anomalous diffusion above .
324
21
234
public static Chart getMSDLineWithFreeModelChart ( Trajectory t , int lagMin , int lagMax , double timelag , double diffusionCoefficient , double intercept ) { double [ ] xData = new double [ lagMax - lagMin + 1 ] ; double [ ] yData = new double [ lagMax - lagMin + 1 ] ; double [ ] modelData = new double [ lagMax - lag...
Plots the MSD curve with the trajectory t and adds the fitted model for free diffusion .
345
19
235
public static Chart getMSDLineWithActiveTransportModelChart ( Trajectory t , int lagMin , int lagMax , double timelag , double diffusionCoefficient , double velocity ) { double [ ] xData = new double [ lagMax - lagMin + 1 ] ; double [ ] yData = new double [ lagMax - lagMin + 1 ] ; double [ ] modelData = new double [ la...
Plots the MSD curve with the trajectory t and adds the fitted model for directed motion above .
368
20
236
public static Chart getMSDLineChart ( Trajectory t , int lagMin , int lagMax ) { return getMSDLineChart ( t , lagMin , lagMax , new MeanSquaredDisplacmentFeature ( t , lagMin ) ) ; }
Plots the MSD curve for trajectory t .
56
10
237
public static void plotCharts ( List < Chart > charts ) { int numRows = 1 ; int numCols = 1 ; if ( charts . size ( ) > 1 ) { numRows = ( int ) Math . ceil ( charts . size ( ) / 2.0 ) ; numCols = 2 ; } final JFrame frame = new JFrame ( "" ) ; frame . setDefaultCloseOperation ( JFrame . HIDE_ON_CLOSE ) ; frame . getConte...
Plots a list of charts in matrix with 2 columns .
213
12
238
@ Nullable public Import find ( @ Nonnull final String typeName ) { Check . notEmpty ( typeName , "typeName" ) ; Import ret = null ; final Type type = new Type ( typeName ) ; for ( final Import imp : imports ) { if ( imp . getType ( ) . getName ( ) . equals ( type . getName ( ) ) ) { ret = imp ; break ; } } if ( ret ==...
Searches the set of imports to find a matching import by type name .
142
16
239
private void query ( String zipcode ) { /* Setup YQL query statement using dynamic zipcode. The statement searches geo.places for the zipcode and returns XML which includes the WOEID. For more info about YQL go to: http://developer.yahoo.com/yql/ */ String qry = URLEncoder . encode ( "SELECT woeid FROM geo.places WHERE...
Query zipcode from Yahoo to find associated WOEID
214
11
240
private void parseResponse ( InputStream inputStream ) { try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder dBuilder = dbFactory . newDocumentBuilder ( ) ; Document doc = dBuilder . parse ( inputStream ) ; doc . getDocumentElement ( ) . normalize ( ) ; NodeList nodes = d...
Extract WOEID after XML loads
179
8
241
@ Nonnull public static InterfaceAnalysis analyze ( @ Nonnull final String code ) { Check . notNull ( code , "code" ) ; final CompilationUnit unit = Check . notNull ( SourceCodeReader . parse ( code ) , "compilationUnit" ) ; final List < TypeDeclaration > types = Check . notEmpty ( unit . getTypes ( ) , "typeDeclaratio...
Analyzes the source code of an interface . The specified interface must not contain methods that changes the state of the corresponding object itself .
350
26
242
public Integer next ( ) { for ( int i = currentIndex ; i < t . size ( ) ; i ++ ) { if ( i + timelag >= t . size ( ) ) { return null ; } if ( ( t . get ( i ) != null ) && ( t . get ( i + timelag ) != null ) ) { if ( overlap ) { currentIndex = i + 1 ; } else { currentIndex = i + timelag ; } return i ; } } return null ; }
Give next index i where i and i + timelag is valid
108
14
243
private static boolean matches ( @ Nonnull final Pattern pattern , @ Nonnull final CharSequence chars ) { return pattern . matcher ( chars ) . matches ( ) ; }
Checks whether a character sequence matches against a specified pattern or not .
36
14
244
@ ArgumentsChecked @ Throws ( { IllegalNullArgumentException . class , IllegalNumberArgumentException . class } ) public static void isNumber ( final boolean condition , @ Nonnull final String value ) { if ( condition ) { Check . isNumber ( value ) ; } }
Ensures that a String argument is a number .
60
11
245
@ Override public Trajectory subList ( int fromIndex , int toIndex ) { Trajectory t = new Trajectory ( dimension ) ; for ( int i = fromIndex ; i < toIndex ; i ++ ) { t . add ( this . get ( i ) ) ; } return t ; }
Generates a sub - trajectory
66
6
246
public double [ ] [ ] getPositionsAsArray ( ) { double [ ] [ ] posAsArr = new double [ size ( ) ] [ 3 ] ; for ( int i = 0 ; i < size ( ) ; i ++ ) { if ( get ( i ) != null ) { posAsArr [ i ] [ 0 ] = get ( i ) . x ; posAsArr [ i ] [ 1 ] = get ( i ) . y ; posAsArr [ i ] [ 2 ] = get ( i ) . z ; } else { posAsArr [ i ] = nu...
Converts the positions to a 2D double array
138
10
247
public void scale ( double v ) { for ( int i = 0 ; i < this . size ( ) ; i ++ ) { this . get ( i ) . scale ( v ) ; ; } }
Multiplies all positions with a factor v
42
9
248
public static int randomIntBetween ( int min , int max ) { Random rand = new Random ( ) ; return rand . nextInt ( ( max - min ) + 1 ) + min ; }
Returns an integer between interval
40
5
249
public static long randomLongBetween ( long min , long max ) { Random rand = new Random ( ) ; return min + ( long ) ( rand . nextDouble ( ) * ( max - min ) ) ; }
Returns a long between interval
44
5
250
private static int getTrimmedXStart ( BufferedImage img ) { int height = img . getHeight ( ) ; int width = img . getWidth ( ) ; int xStart = width ; for ( int i = 0 ; i < height ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { if ( img . getRGB ( j , i ) != Color . WHITE . getRGB ( ) && j < xStart ) { xStart = j ; bre...
Get the first non - white X point
114
8
251
private static int getTrimmedWidth ( BufferedImage img ) { int height = img . getHeight ( ) ; int width = img . getWidth ( ) ; int trimmedWidth = 0 ; for ( int i = 0 ; i < height ; i ++ ) { for ( int j = width - 1 ; j >= 0 ; j -- ) { if ( img . getRGB ( j , i ) != Color . WHITE . getRGB ( ) && j > trimmedWidth ) { trim...
Get the last non - white X point
115
8
252
private static int getTrimmedYStart ( BufferedImage img ) { int width = img . getWidth ( ) ; int height = img . getHeight ( ) ; int yStart = height ; for ( int i = 0 ; i < width ; i ++ ) { for ( int j = 0 ; j < height ; j ++ ) { if ( img . getRGB ( i , j ) != Color . WHITE . getRGB ( ) && j < yStart ) { yStart = j ; br...
Get the first non - white Y point
114
8
253
private static int getTrimmedHeight ( BufferedImage img ) { int width = img . getWidth ( ) ; int height = img . getHeight ( ) ; int trimmedHeight = 0 ; for ( int i = 0 ; i < width ; i ++ ) { for ( int j = height - 1 ; j >= 0 ; j -- ) { if ( img . getRGB ( i , j ) != Color . WHITE . getRGB ( ) && j > trimmedHeight ) { t...
Get the last non - white Y point
115
8
254
public static BufferedImage resizeToHeight ( BufferedImage originalImage , int heightOut ) { int width = originalImage . getWidth ( ) ; int height = originalImage . getHeight ( ) ; int heightPercent = ( heightOut * 100 ) / height ; int newWidth = ( width * heightPercent ) / 100 ; BufferedImage resizedImage = new Buffer...
Resizes an image to the specified height changing width in the same proportion
145
14
255
public static BufferedImage resizeToWidth ( BufferedImage originalImage , int widthOut ) { int width = originalImage . getWidth ( ) ; int height = originalImage . getHeight ( ) ; int widthPercent = ( widthOut * 100 ) / width ; int newHeight = ( height * widthPercent ) / 100 ; BufferedImage resizedImage = new BufferedIm...
Resizes an image to the specified width changing width in the same proportion
145
14
256
public static String regexFindFirst ( String pattern , String str ) { return regexFindFirst ( Pattern . compile ( pattern ) , str , 1 ) ; }
Gets the first group of a regex
32
8
257
public static List < String > asListLines ( String content ) { List < String > retorno = new ArrayList < String > ( ) ; content = content . replace ( CARRIAGE_RETURN , RETURN ) ; content = content . replace ( RETURN , CARRIAGE_RETURN ) ; for ( String str : content . split ( CARRIAGE_RETURN ) ) { retorno . add ( str ) ;...
Split string content into list
100
5
258
public static List < String > asListLinesIgnore ( String content , Pattern ignorePattern ) { List < String > retorno = new ArrayList < String > ( ) ; content = content . replace ( CARRIAGE_RETURN , RETURN ) ; content = content . replace ( RETURN , CARRIAGE_RETURN ) ; for ( String str : content . split ( CARRIAGE_RETURN...
Split string content into list ignoring matches of the pattern
124
10
259
public static Map < String , String > getContentMap ( File file , String separator ) throws IOException { List < String > content = getContentLines ( file ) ; Map < String , String > map = new LinkedHashMap < String , String > ( ) ; for ( String line : content ) { String [ ] spl = line . split ( separator ) ; if ( line...
Get content of a file as a Map&lt ; String String&gt ; using separator to split values
125
22
260
public static void saveContentMap ( Map < String , String > map , File file ) throws IOException { FileWriter out = new FileWriter ( file ) ; for ( String key : map . keySet ( ) ) { if ( map . get ( key ) != null ) { out . write ( key . replace ( ":" , "#escapedtwodots#" ) + ":" + map . get ( key ) . replace ( ":" , "#...
Save map to file
120
4
261
public static String getTabularData ( String [ ] labels , String [ ] [ ] data , int padding ) { int [ ] size = new int [ labels . length ] ; for ( int i = 0 ; i < labels . length ; i ++ ) { size [ i ] = labels [ i ] . length ( ) + padding ; } for ( String [ ] row : data ) { for ( int i = 0 ; i < labels . length ; i ++ ...
Return tabular data
359
4
262
public static String replaceHtmlEntities ( String content , Map < String , Character > map ) { for ( Entry < String , Character > entry : escapeStrings . entrySet ( ) ) { if ( content . indexOf ( entry . getKey ( ) ) != - 1 ) { content = content . replace ( entry . getKey ( ) , String . valueOf ( entry . getValue ( ) )...
Replace HTML entities
93
4
263
public void add ( ServiceReference < S > declarationBinderRef ) throws InvalidFilterException { BinderDescriptor binderDescriptor = new BinderDescriptor ( declarationBinderRef ) ; declarationBinders . put ( declarationBinderRef , binderDescriptor ) ; }
Add the declarationBinderRef to the ImportersManager create the corresponding . BinderDescriptor .
62
22
264
public void modified ( ServiceReference < S > declarationBinderRef ) throws InvalidFilterException { declarationBinders . get ( declarationBinderRef ) . update ( declarationBinderRef ) ; }
Update the BinderDescriptor of the declarationBinderRef .
40
14
265
public void createLinks ( ServiceReference < S > declarationBinderRef ) { for ( D declaration : linkerManagement . getMatchedDeclaration ( ) ) { if ( linkerManagement . canBeLinked ( declaration , declarationBinderRef ) ) { linkerManagement . link ( declaration , declarationBinderRef ) ; } } }
Create all the links possible between the DeclarationBinder and all the ImportDeclaration matching the . ImportDeclarationFilter of the Linker .
71
28
266
public void updateLinks ( ServiceReference < S > serviceReference ) { for ( D declaration : linkerManagement . getMatchedDeclaration ( ) ) { boolean isAlreadyLinked = declaration . getStatus ( ) . getServiceReferencesBounded ( ) . contains ( serviceReference ) ; boolean canBeLinked = linkerManagement . canBeLinked ( de...
Update all the links of the DeclarationBinder .
138
10
267
public void removeLinks ( ServiceReference < S > declarationBinderRef ) { for ( D declaration : linkerManagement . getMatchedDeclaration ( ) ) { if ( declaration . getStatus ( ) . getServiceReferencesBounded ( ) . contains ( declarationBinderRef ) ) { linkerManagement . unlink ( declaration , declarationBinderRef ) ; }...
Remove all the existing links of the DeclarationBinder .
78
11
268
public Set < S > getMatchedDeclarationBinder ( ) { Set < S > bindedSet = new HashSet < S > ( ) ; for ( Map . Entry < ServiceReference < S > , BinderDescriptor > e : declarationBinders . entrySet ( ) ) { if ( e . getValue ( ) . match ) { bindedSet . add ( getDeclarationBinder ( e . getKey ( ) ) ) ; } } return bindedSet ...
Return a set of all DeclarationBinder matching the DeclarationBinderFilter of the Linker .
103
19
269
public static List < File > extract ( File zipFile , File outputFolder ) throws IOException { List < File > extracted = new ArrayList < File > ( ) ; byte [ ] buffer = new byte [ 2048 ] ; if ( ! outputFolder . exists ( ) ) { outputFolder . mkdir ( ) ; } ZipInputStream zipInput = new ZipInputStream ( new FileInputStream ...
Extracts the zip file to the output folder
267
10
270
public static void validateZip ( File file ) throws IOException { ZipInputStream zipInput = new ZipInputStream ( new FileInputStream ( file ) ) ; ZipEntry zipEntry = zipInput . getNextEntry ( ) ; while ( zipEntry != null ) { zipEntry = zipInput . getNextEntry ( ) ; } try { if ( zipInput != null ) { zipInput . close ( )...
Checks if a Zip is valid navigating through the entries
96
11
271
public static void compress ( File dir , File zipFile ) throws IOException { FileOutputStream fos = new FileOutputStream ( zipFile ) ; ZipOutputStream zos = new ZipOutputStream ( fos ) ; recursiveAddZip ( dir , zos , dir ) ; zos . finish ( ) ; zos . close ( ) ; }
Compress a directory into a zip file
73
8
272
public static void recursiveAddZip ( File parent , ZipOutputStream zout , File fileSource ) throws IOException { File [ ] files = fileSource . listFiles ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) { if ( files [ i ] . isDirectory ( ) ) { recursiveAddZip ( parent , zout , files [ i ] ) ; continue ; } byte [ ] bu...
Recursively add files to a ZipOutputStream
223
10
273
public static String readContent ( InputStream is ) { String ret = "" ; try { String line ; BufferedReader in = new BufferedReader ( new InputStreamReader ( is ) ) ; StringBuffer out = new StringBuffer ( ) ; while ( ( line = in . readLine ( ) ) != null ) { out . append ( line ) . append ( CARRIAGE_RETURN ) ; } ret = ou...
Gets string content from InputStream
115
7
274
public static boolean streamHasText ( InputStream in , String text ) { final byte [ ] readBuffer = new byte [ 8192 ] ; StringBuffer sb = new StringBuffer ( ) ; try { if ( in . available ( ) > 0 ) { int bytesRead = 0 ; while ( ( bytesRead = in . read ( readBuffer ) ) != - 1 ) { sb . append ( new String ( readBuffer , 0 ...
Checks if the InputStream have the text
173
9
275
private static void tryWritePreferenceOnDisk ( Preferences preference ) throws BackingStoreException { final String DUMMY_PROP = "dummywrite" ; instance . put ( DUMMY_PROP , "test" ) ; instance . flush ( ) ; instance . remove ( DUMMY_PROP ) ; instance . flush ( ) ; }
This ensures that we are able to use the default preference from JSDK to check basically if we are in Android or Not
75
25
276
private void doSend ( byte [ ] msg , boolean wait , KNXAddress dst ) throws KNXAckTimeoutException , KNXLinkClosedException { if ( closed ) throw new KNXLinkClosedException ( "link closed" ) ; try { logger . info ( "send message to " + dst + ( wait ? ", wait for ack" : "" ) ) ; logger . trace ( "EMI " + DataUnitBuilder...
dst is just for log information
186
7
277
static public String bb2hex ( byte [ ] bb ) { String result = "" ; for ( int i = 0 ; i < bb . length ; i ++ ) { result = result + String . format ( "%02X " , bb [ i ] ) ; } return result ; }
Converts a byte array to a hexadecimal string representation
63
13
278
private static byte calculateChecksum ( byte [ ] buffer ) { byte checkSum = ( byte ) 0xFF ; for ( int i = 1 ; i < buffer . length - 1 ; i ++ ) { checkSum = ( byte ) ( checkSum ^ buffer [ i ] ) ; } logger . trace ( String . format ( "Calculated checksum = 0x%02X" , checkSum ) ) ; return checkSum ; }
Calculates a checksum for the specified buffer .
92
11
279
public byte [ ] getMessageBuffer ( ) { ByteArrayOutputStream resultByteBuffer = new ByteArrayOutputStream ( ) ; byte [ ] result ; resultByteBuffer . write ( ( byte ) 0x01 ) ; int messageLength = messagePayload . length + ( this . messageClass == SerialMessageClass . SendData && this . messageType == SerialMessageType ....
Gets the SerialMessage as a byte array .
304
10
280
private static String getBundle ( String friendlyName , String className , int truncate ) { try { cl . loadClass ( className ) ; int start = className . length ( ) ; for ( int i = 0 ; i < truncate ; ++ i ) start = className . lastIndexOf ( ' ' , start - 1 ) ; final String bundle = className . substring ( 0 , start ) ; ...
to check availability then class name is truncated to bundle id
149
12
281
protected ServiceRegistration registerProxy ( Object objectProxy , Class clazz ) { Dictionary < String , Object > props = new Hashtable < String , Object > ( ) ; ServiceRegistration registration ; registration = context . registerService ( clazz , objectProxy , props ) ; return registration ; }
Utility method to register a proxy has a Service in OSGi .
58
14
282
@ Override protected void denyImportDeclaration ( ImportDeclaration importDeclaration ) { LOG . debug ( "CXFImporter destroy a proxy for " + importDeclaration ) ; ServiceRegistration serviceRegistration = map . get ( importDeclaration ) ; serviceRegistration . unregister ( ) ; // set the importDeclaration has unhandled...
Destroy the proxy & update the map containing the registration ref .
93
12
283
public static Result generate ( @ Nonnull final String code , @ Nonnull final ImmutableSettings settings ) { Check . notNull ( code , "code" ) ; final ImmutableSettings . Builder settingsBuilder = new ImmutableSettings . Builder ( Check . notNull ( settings , "settings" ) ) ; final InterfaceAnalysis analysis = Interfac...
The specified interface must not contain methods that changes the state of this object itself .
299
16
284
public static void addJarToClasspath ( ClassLoader loader , URL url ) throws IOException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException { URLClassLoader sysloader = ( URLClassLoader ) loader ; Class < ? > sysclass = URLClassLoader . class ; Me...
Add an URL to the given classloader
128
8
285
public void resetResendCount ( ) { this . resendCount = 0 ; if ( this . initializationComplete ) this . nodeStage = NodeStage . NODEBUILDINFO_DONE ; this . lastUpdated = Calendar . getInstance ( ) . getTime ( ) ; }
Resets the resend counter and possibly resets the node stage to DONE when previous initialization was complete .
59
22
286
public void addCommandClass ( ZWaveCommandClass commandClass ) { ZWaveCommandClass . CommandClass key = commandClass . getCommandClass ( ) ; if ( ! supportedCommandClasses . containsKey ( key ) ) { supportedCommandClasses . put ( key , commandClass ) ; if ( commandClass instanceof ZWaveEventListener ) this . controller...
Adds a command class to the list of supported command classes by this node . Does nothing if command class is already added .
108
24
287
public static String getPostString ( InputStream is , String encoding ) { try { StringWriter sw = new StringWriter ( ) ; IOUtils . copy ( is , sw , encoding ) ; return sw . toString ( ) ; } catch ( IOException e ) { // no op return null ; } finally { IOUtils . closeQuietly ( is ) ; } }
get string from post stream
81
5
288
public static void outputString ( final HttpServletResponse response , final Object obj ) { try { response . setContentType ( "text/javascript" ) ; response . setCharacterEncoding ( "utf-8" ) ; disableCache ( response ) ; response . getWriter ( ) . write ( obj . toString ( ) ) ; response . getWriter ( ) . flush ( ) ; r...
response simple String
103
3
289
public double convert ( double value , double temperatur , double viscosity ) { return temperatur * kB / ( Math . PI * viscosity * value ) ; }
Converters the diffusion coefficient to hydrodynamic diameter and vice versa
37
14
290
public static < T > T buildInstanceForMap ( Class < T > clazz , Map < String , Object > values ) throws InstantiationException , IllegalAccessException , IntrospectionException , IllegalArgumentException , InvocationTargetException { return buildInstanceForMap ( clazz , values , new MyDefaultReflectionDifferenceHandler...
Builds a instance of the class for a map containing the values without specifying the handler for differences
73
19
291
public static < T > T buildInstanceForMap ( Class < T > clazz , Map < String , Object > values , MyReflectionDifferenceHandler differenceHandler ) throws InstantiationException , IllegalAccessException , IntrospectionException , IllegalArgumentException , InvocationTargetException { log . debug ( "Building new instance...
Builds a instance of the class for a map containing the values
350
13
292
private static BundleCapability getExportedPackage ( BundleContext context , String packageName ) { List < BundleCapability > packages = new ArrayList < BundleCapability > ( ) ; for ( Bundle bundle : context . getBundles ( ) ) { BundleRevision bundleRevision = bundle . adapt ( BundleRevision . class ) ; for ( BundleCap...
Return the BundleCapability of a bundle exporting the package packageName .
240
14
293
private String [ ] readXMLDeclaration ( Reader r ) throws KNXMLException { final StringBuffer buf = new StringBuffer ( 100 ) ; try { for ( int c = 0 ; ( c = r . read ( ) ) != - 1 && c != ' ' ; ) buf . append ( ( char ) c ) ; } catch ( final IOException e ) { throw new KNXMLException ( "reading XML declaration, " + e . ...
returns array with length 3 and optional entries version encoding standalone
403
12
294
private Long fetchServiceId ( ServiceReference serviceReference ) { return ( Long ) serviceReference . getProperty ( org . osgi . framework . Constants . SERVICE_ID ) ; }
Returns the service id with the propertype .
38
9
295
public void setSpecificDeviceClass ( Specific specificDeviceClass ) throws IllegalArgumentException { // The specific Device class does not match the generic device class. if ( specificDeviceClass . genericDeviceClass != Generic . NOT_KNOWN && specificDeviceClass . genericDeviceClass != this . genericDeviceClass ) thro...
Set the specific device class of the node .
86
9
296
private String parseRssFeed ( String feed ) { String [ ] result = feed . split ( "<br />" ) ; String [ ] result2 = result [ 2 ] . split ( "<BR />" ) ; return result2 [ 0 ] ; }
Parser for actual conditions
53
4
297
private List < String > parseRssFeedForeCast ( String feed ) { String [ ] result = feed . split ( "<br />" ) ; List < String > returnList = new ArrayList < String > ( ) ; String [ ] result2 = result [ 2 ] . split ( "<BR />" ) ; returnList . add ( result2 [ 3 ] + "\n" ) ; returnList . add ( result [ 3 ] + "\n" ) ; retur...
Parser for forecast
147
3
298
public SerialMessage getMessage ( AlarmType alarmType ) { logger . debug ( "Creating new message for application command SENSOR_ALARM_GET for node {}" , this . getNode ( ) . getNodeId ( ) ) ; SerialMessage result = new SerialMessage ( this . getNode ( ) . getNodeId ( ) , SerialMessage . SerialMessageClass . SendData , ...
Gets a SerialMessage with the SENSOR_ALARM_GET command
193
16
299
public SerialMessage getSupportedMessage ( ) { logger . debug ( "Creating new message for application command SENSOR_ALARM_SUPPORTED_GET for node {}" , this . getNode ( ) . getNodeId ( ) ) ; if ( this . getNode ( ) . getManufacturer ( ) == 0x010F && this . getNode ( ) . getDeviceType ( ) == 0x0501 ) { logger . warn ( "...
Gets a SerialMessage with the SENSOR_ALARM_SUPPORTED_GET command
274
20