idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
119,500 | private void parseTextMessage ( String message ) { JSONObject data ; try { data = new JSONObject ( message ) ; if ( ! data . has ( "type" ) ) { return ; } String type = data . getString ( "type" ) ; if ( type . equals ( "order" ) ) { if ( orderUpdateListener != null ) { orderUpdateListener . onOrderUpdate ( getOrder ( ... | Parses incoming text message . |
119,501 | public static ImageGalleryFragment newInstance ( Bundle extras ) { ImageGalleryFragment fragment = new ImageGalleryFragment ( ) ; fragment . setArguments ( extras ) ; return fragment ; } | region Factory Methods |
119,502 | public void onImageClick ( int position ) { Intent intent = new Intent ( ImageGalleryActivity . this , FullScreenImageGalleryActivity . class ) ; Bundle bundle = new Bundle ( ) ; bundle . putStringArrayList ( FullScreenImageGalleryActivity . KEY_IMAGES , images ) ; bundle . putInt ( FullScreenImageGalleryActivity . KEY... | region ImageGalleryAdapter . OnImageClickListener Methods |
119,503 | public void loadFullScreenImage ( ImageView iv , String imageUrl , int width , LinearLayout bglinearLayout ) { fullScreenImageLoader . loadFullScreenImage ( iv , imageUrl , width , bglinearLayout ) ; } | region FullScreenImageGalleryAdapter . FullScreenImageLoader Methods |
119,504 | public RectF getZoomedRect ( ) { if ( mScaleType == ScaleType . FIT_XY ) { throw new UnsupportedOperationException ( "getZoomedRect() not supported with FIT_XY" ) ; } PointF topLeft = transformCoordTouchToBitmap ( 0 , 0 , true ) ; PointF bottomRight = transformCoordTouchToBitmap ( viewWidth , viewHeight , true ) ; floa... | Return a Rect representing the zoomed image . |
119,505 | private void savePreviousImageValues ( ) { if ( matrix != null && viewHeight != 0 && viewWidth != 0 ) { matrix . getValues ( m ) ; prevMatrix . setValues ( m ) ; prevMatchViewHeight = matchViewHeight ; prevMatchViewWidth = matchViewWidth ; prevViewHeight = viewHeight ; prevViewWidth = viewWidth ; } } | Save the current matrix and view dimensions in the prevMatrix and prevView variables . |
119,506 | public void setZoom ( TouchImageView img ) { PointF center = img . getScrollPosition ( ) ; setZoom ( img . getCurrentZoom ( ) , center . x , center . y , img . getScaleType ( ) ) ; } | Set zoom parameters equal to another TouchImageView . Including scale position and ScaleType . |
119,507 | private void fixTrans ( ) { matrix . getValues ( m ) ; float transX = m [ Matrix . MTRANS_X ] ; float transY = m [ Matrix . MTRANS_Y ] ; float fixTransX = getFixTrans ( transX , viewWidth , getImageWidth ( ) ) ; float fixTransY = getFixTrans ( transY , viewHeight , getImageHeight ( ) ) ; if ( fixTransX != 0 || fixTrans... | Performs boundary checking and fixes the image matrix if it is out of bounds . |
119,508 | private void fitImageToView ( ) { Drawable drawable = getDrawable ( ) ; if ( drawable == null || drawable . getIntrinsicWidth ( ) == 0 || drawable . getIntrinsicHeight ( ) == 0 ) { return ; } if ( matrix == null || prevMatrix == null ) { return ; } int drawableWidth = drawable . getIntrinsicWidth ( ) ; int drawableHeig... | If the normalizedScale is equal to 1 then the image is made to fit the screen . Otherwise it is made to fit the screen according to the dimensions of the previous image matrix . This allows the image to maintain its zoom after rotation . |
119,509 | private int setViewSize ( int mode , int size , int drawableWidth ) { int viewSize ; switch ( mode ) { case MeasureSpec . EXACTLY : viewSize = size ; break ; case MeasureSpec . AT_MOST : viewSize = Math . min ( drawableWidth , size ) ; break ; case MeasureSpec . UNSPECIFIED : viewSize = drawableWidth ; break ; default ... | Set view dimensions based on layout params |
119,510 | private void translateMatrixAfterRotate ( int axis , float trans , float prevImageSize , float imageSize , int prevViewSize , int viewSize , int drawableSize ) { if ( imageSize < viewSize ) { m [ axis ] = ( viewSize - ( drawableSize * m [ Matrix . MSCALE_X ] ) ) * 0.5f ; } else if ( trans > 0 ) { m [ axis ] = - ( ( ima... | After rotating the matrix needs to be translated . This function finds the area of image which was previously centered and adjusts translations so that is again the center post - rotation . |
119,511 | private PointF transformCoordTouchToBitmap ( float x , float y , boolean clipToBitmap ) { matrix . getValues ( m ) ; float origW = getDrawable ( ) . getIntrinsicWidth ( ) ; float origH = getDrawable ( ) . getIntrinsicHeight ( ) ; float transX = m [ Matrix . MTRANS_X ] ; float transY = m [ Matrix . MTRANS_Y ] ; float fi... | This function will transform the coordinates in the touch event to the coordinate system of the drawable that the imageview contain |
119,512 | private PointF transformCoordBitmapToTouch ( float bx , float by ) { matrix . getValues ( m ) ; float origW = getDrawable ( ) . getIntrinsicWidth ( ) ; float origH = getDrawable ( ) . getIntrinsicHeight ( ) ; float px = bx / origW ; float py = by / origH ; float finalX = m [ Matrix . MTRANS_X ] + getImageWidth ( ) * px... | Inverse of transformCoordTouchToBitmap . This function will transform the coordinates in the drawable s coordinate system to the view s coordinate system . |
119,513 | public void loadFullScreenImage ( final ImageView iv , String imageUrl , int width , final LinearLayout bgLinearLayout ) { if ( ! TextUtils . isEmpty ( imageUrl ) ) { Picasso . with ( iv . getContext ( ) ) . load ( imageUrl ) . resize ( width , 0 ) . into ( iv , new Callback ( ) { public void onSuccess ( ) { Bitmap bit... | region FullScreenImageGalleryAdapter . FullScreenImageLoader |
119,514 | public void sign ( Key privateKey , List < X509Certificate > x509List , String password , HashAlgorithm hashAlgorithm ) throws XMLSignatureException , MarshalException , IOException , FormatNotUnderstoodException { if ( this . tempSignFileOS != null ) { this . tempSignFileOS . close ( ) ; } SignatureConfig sc = new Sig... | Signs the Excel OOXML file and writes it to the final outputstream |
119,515 | public void close ( ) throws IOException { try { if ( this . tempSignFileOS != null ) { this . tempSignFileOS . close ( ) ; } } finally { if ( ! this . tempSignFile . delete ( ) ) { LOG . warn ( "Could not delete temporary files used for signing" ) ; } } } | Cleans up tempfolder |
119,516 | public Key getPrivateKey ( String alias , String password ) throws UnrecoverableKeyException , KeyStoreException , NoSuchAlgorithmException { return this . keystore . getKey ( alias , password . toCharArray ( ) ) ; } | Reads a private key from keystore |
119,517 | public void setPassword ( String alias , String password , String passwordPassword ) throws NoSuchAlgorithmException , InvalidKeySpecException , KeyStoreException { SecretKeyFactory skf = SecretKeyFactory . getInstance ( "PBE" ) ; SecretKey pSecret = skf . generateSecret ( new PBEKeySpec ( password . toCharArray ( ) ) ... | Sets the password in the currently openend keystore . Do not forget to store it afterwards |
119,518 | public void close ( ) throws IOException { try { prepareMetaData ( ) ; if ( this . oStream != null ) { if ( this . howc . getPassword ( ) == null ) { finalizeWriteNotEncrypted ( ) ; } else if ( this . currentWorkbook instanceof HSSFWorkbook ) { finalizeWriteEncryptedHSSF ( ) ; } else if ( this . currentWorkbook instanc... | Writes the document in - memory representation to the OutputStream . Afterwards it closes all related workbooks . |
119,519 | public static boolean isSupportedFormat ( String format ) { for ( int i = 0 ; i < MSExcelWriter . VALID_FORMAT . length ; i ++ ) { if ( VALID_FORMAT [ i ] . equals ( format ) ) { return true ; } } return false ; } | Checks if format is supported |
119,520 | public static CipherAlgorithm getAlgorithmCipher ( String encryptAlgorithm ) { if ( encryptAlgorithm == null ) { return null ; } switch ( encryptAlgorithm ) { case "aes128" : return CipherAlgorithm . aes128 ; case "aes192" : return CipherAlgorithm . aes192 ; case "aes256" : return CipherAlgorithm . aes256 ; case "des" ... | Returns the CipherAlgorithm object matching the String . |
119,521 | public static HashAlgorithm getHashAlgorithm ( String hashAlgorithm ) { if ( hashAlgorithm == null ) { return null ; } switch ( hashAlgorithm ) { case "md2" : return HashAlgorithm . md2 ; case "md4" : return HashAlgorithm . md4 ; case "md5" : return HashAlgorithm . md5 ; case "none" : return HashAlgorithm . none ; case... | Returns the HashAlgorithm object matching the String . |
119,522 | public static EncryptionMode getEncryptionModeCipher ( String encryptionMode ) { if ( encryptionMode == null ) { return null ; } switch ( encryptionMode ) { case "agile" : return EncryptionMode . agile ; case "binaryRC4" : return EncryptionMode . binaryRC4 ; case "cryptoAPI" : return EncryptionMode . cryptoAPI ; case "... | Returns the EncryptionMode object matching the String . |
119,523 | public static ChainingMode getChainMode ( String chainMode ) { if ( chainMode == null ) { return null ; } switch ( chainMode ) { case "cbc" : return ChainingMode . cbc ; case "cfb" : return ChainingMode . cfb ; case "ecb" : return ChainingMode . ecb ; default : LOG . error ( "Uknown chainmode: \"" + chainMode + "\"" ) ... | Returns the ChainMode object matching the String . |
119,524 | private String parseCellInlineStringText ( XMLEventReader xer ) throws XMLStreamException , FormatNotUnderstoodException { String result = "" ; XMLEvent xe ; while ( ( xe = xer . nextTag ( ) ) . isStartElement ( ) ) { String elementName = xe . asStartElement ( ) . getName ( ) . getLocalPart ( ) . toUpperCase ( ) ; swit... | Parses an inline string from cell in XML format |
119,525 | public void open ( FileInputSplit split ) throws IOException { super . open ( split ) ; if ( this . customSchema == null ) { ExcelFlinkFileInputFormat effif = new ExcelFlinkFileInputFormat ( this . shocr ) ; effif . open ( split ) ; SpreadSheetCellDAO [ ] currentRow = effif . nextRecord ( null ) ; int i = 0 ; while ( (... | Open an Excel file |
119,526 | public Tuple3 < Long , Long , GenericDataType [ ] > getCurrentState ( ) throws IOException { return new Tuple3 < > ( this . getOfficeReader ( ) . getCurrentParser ( ) . getCurrentSheet ( ) , this . getOfficeReader ( ) . getCurrentParser ( ) . getCurrentRow ( ) , this . converter . getSchemaRow ( ) ) ; } | Store currently processed sheet and row as well as infered schema |
119,527 | public void readFrom ( InputStream is ) throws IOException { this . currentItem = 0 ; OutputStream tempOS = null ; if ( ( this . ca != null ) || ( this . compressTempFile ) ) { tempOS = new FileOutputStream ( this . tempFile ) ; if ( this . ca != null ) { tempOS = new CipherOutputStream ( tempOS , this . ciEncrypt ) ; ... | Reads from the original Excel document the string table and puts it into a compressed and encrypted file . |
119,528 | public RichTextString getItemAt ( int idx ) { try { return new XSSFRichTextString ( this . getString ( idx ) ) ; } catch ( IOException e ) { LOG . error ( "Cannot read from temporary shared String table. Exception: " + e ) ; } return new XSSFRichTextString ( "" ) ; } | Get an item from the shared string table |
119,529 | public void close ( ) throws IOException { if ( this . in != null ) { this . in . close ( ) ; } if ( ! this . tempFile . delete ( ) ) { LOG . warn ( "Cannot delete tempFile: " + this . tempFile . getAbsolutePath ( ) ) ; throw new IOException ( "Cannot delete tempFile: " + this . tempFile . getAbsolutePath ( ) ) ; } ; } | Closes the temporary inputstream and deletes the temp file |
119,530 | private void addString ( String str , OutputStream os ) throws IOException { if ( this . cacheSize >= 0 ) { byte [ ] strbytes = str . getBytes ( EncryptedCachedDiskStringsTable . encoding ) ; byte [ ] sizeOfStr = ByteBuffer . allocate ( 4 ) . putInt ( strbytes . length ) . array ( ) ; this . stringPositionInFileList . ... | Adds a string to the table on disk |
119,531 | public void initialize ( Configuration conf , Properties prop ) throws SerDeException { this . initialize ( conf , prop , null ) ; } | Initializes the Serde |
119,532 | public static String getCellAddressA1Format ( int rowNum , int columnNum ) { CellAddress cellAddr = new CellAddress ( rowNum , columnNum ) ; return cellAddr . formatAsString ( ) ; } | Generate a cell address in A1 format from a row and column number |
119,533 | public boolean addLinkedWorkbook ( String name , InputStream inputStream , String password ) throws FormatNotUnderstoodException { if ( this . addedFormulaEvaluators . containsKey ( name ) ) { return false ; } LOG . debug ( "Start adding \"" + name + "\" to current workbook" ) ; HadoopOfficeReadConfiguration linkedWBH... | Adds a linked workbook that is referred from this workbook . If the filename is already in the list then it is not processed twice . Note that the inputStream is closed after parsing |
119,534 | public List < String > getLinkedWorkbooks ( ) { List < String > result = new ArrayList < > ( ) ; if ( this . currentWorkbook instanceof HSSFWorkbook ) { result = getLinkedWorkbooksHSSF ( ) ; } else if ( this . currentWorkbook instanceof XSSFWorkbook ) { for ( ExternalLinksTable element : ( ( XSSFWorkbook ) this . curre... | Provides a list of filenames that contain workbooks that are linked with the current one . Officially supported only for new Excel format . For the old Excel format this is experimental |
119,535 | public void close ( ) throws IOException { if ( this . in != null ) { in . close ( ) ; } if ( this . currentWorkbook != null ) { LOG . debug ( "Closing current Workbook \"" + this . hocr . getFileName ( ) + "\"" ) ; this . currentWorkbook . close ( ) ; } for ( Workbook addedWorkbook : this . addedWorkbooks ) { addedWor... | Close parser and linked workbooks |
119,536 | public GenericDataType [ ] getSchemaRow ( ) { GenericDataType [ ] result = new GenericDataType [ this . schemaRow . size ( ) ] ; this . schemaRow . toArray ( result ) ; return result ; } | Returns a list of objects corresponding to the schema . |
119,537 | public void create ( OutputStream oStream , Map < String , InputStream > linkedWorkbooks , Map < String , String > linkedWorkbooksPasswords , InputStream template ) throws OfficeWriterException { this . oStream = oStream ; if ( this . currentOfficeSpreadSheetWriter != null ) { this . currentOfficeSpreadSheetWriter . cr... | Creates a new office document |
119,538 | public void write ( Object o ) throws OfficeWriterException { if ( this . currentOfficeSpreadSheetWriter != null ) { this . currentOfficeSpreadSheetWriter . write ( o ) ; } else { throw new OfficeWriterException ( EX_NO_WRITER_INSTANTIATED ) ; } } | Writes an object to the office document . Note the type of object highly depends on the underlying writer . E . g . for SpreadSheet - based writers it is of class SpreadSheetCellDAO |
119,539 | private WebTarget withAuthToken ( final WebTarget target ) { if ( _sessionOptions . getAuthToken ( ) != null ) { return target . queryParam ( AUTH_TOKEN_PARAM_NAME , _sessionOptions . getAuthToken ( ) ) ; } else { return target ; } } | Add authorization token to the web target . |
119,540 | protected < T > T getResponse ( final WebTarget target , final ResponseProcessor < T > responseProcessor , final Request request ) { Builder requestBuilder = target . request ( ) ; Response response = requestBuilder . buildGet ( ) . invoke ( ) ; if ( response . getStatus ( ) == Response . Status . OK . getStatusCode ( ... | Generic method to handle the invocation of the requests error processing and so on leaving the specialised methods to simply invoke with the appropriate ReponseProcessor to process the resulting InputStream . |
119,541 | public static void notNull ( final Object argument , final String name ) { if ( argument == null ) { s_logger . error ( "Argument {} was null" , name ) ; throw new QuandlRuntimeException ( "Value " + name + " was null" ) ; } } | Throws an exception if the argument is not null . |
119,542 | public static < E > void notNullOrEmpty ( final E [ ] argument , final String name ) { if ( argument == null ) { s_logger . error ( "Argument {} was null" , name ) ; throw new QuandlRuntimeException ( "Value " + name + " was null" ) ; } else if ( argument . length == 0 ) { s_logger . error ( "Argument {} was empty arra... | Throws an exception if the array argument is not null or empty . |
119,543 | public static < E > void notNullOrEmpty ( final Collection < E > argument , final String name ) { if ( argument == null ) { s_logger . error ( "Argument {} was null" , name ) ; throw new QuandlRuntimeException ( "Value " + name + " was null" ) ; } else if ( argument . size ( ) == 0 ) { s_logger . error ( "Argument {} w... | Throws an exception if the collection argument is not null or empty . |
119,544 | public static QuandlCodeRequest singleColumn ( final String quandlCode , final int columnNumber ) { ArgumentChecker . notNull ( quandlCode , "quandlCode" ) ; return new QuandlCodeRequest ( quandlCode , columnNumber ) ; } | Request just a single column for a given quandlCode . |
119,545 | public static QuandlCodeRequest allColumns ( final String quandlCode ) { ArgumentChecker . notNull ( quandlCode , "quandlCode" ) ; return new QuandlCodeRequest ( quandlCode , null ) ; } | Request all columns for a given quandlCode . |
119,546 | public static TabularResult of ( final HeaderDefinition headerDefinition , final List < Row > rows ) { ArgumentChecker . notNull ( headerDefinition , "headerDefinition" ) ; ArgumentChecker . notNull ( rows , "rows" ) ; return new TabularResult ( headerDefinition , rows ) ; } | Create a tabular result set from a header definition and an ordered list of rows . |
119,547 | public HeaderDefinition getHeaderDefinition ( ) { JSONArray jsonArray = null ; try { jsonArray = _jsonObject . getJSONArray ( COLUMN_NAMES_FIELD ) ; List < String > columnNames = new ArrayList < String > ( jsonArray . length ( ) ) ; for ( int i = 0 ; i < jsonArray . length ( ) ; i ++ ) { columnNames . add ( jsonArray .... | Extract a HeaderDefinition from the meta data . Throws a QuandlRuntimeException if it cannot construct a valid HeaderDefinition |
119,548 | public String getQuandlCode ( ) { try { String dataSourceField = getString ( DATA_SOURCE_FIELD ) ; String codeField = getString ( CODE_FIELD ) ; return dataSourceField + "/" + codeField ; } catch ( RuntimeException ex ) { return null ; } } | Get the Quandl code associated with this metadata . |
119,549 | public String getString ( final String fieldName ) { try { return _jsonObject . getString ( fieldName ) ; } catch ( JSONException ex ) { throw new RuntimeException ( "Cannot find field" , ex ) ; } } | Get a String field . Throws a QuandlRuntimeException if it cannot find the field |
119,550 | public Double getDouble ( final String fieldName ) { try { if ( _jsonObject . isNull ( fieldName ) ) { return null ; } else { return _jsonObject . getDouble ( fieldName ) ; } } catch ( JSONException ex ) { throw new QuandlRuntimeException ( "Cannot find field" , ex ) ; } } | Get a Double field . This attempts to work around the stupid NaN is null behavior by explicitly testing for null . Throws a QuandlRuntimeException if it cannot find the field |
119,551 | public int getTotalDocuments ( ) { try { final int totalDocs = _jsonObject . getJSONObject ( META_OBJECT_FIELD ) . getInt ( "total_count" ) ; return totalDocs ; } catch ( JSONException ex ) { throw new QuandlRuntimeException ( "Could not find total_count field in results from Quandl" , ex ) ; } } | Get the total number of documents in this result set . Throws a QuandlRuntimeException if Quandl response doesn t contain this field although it should . |
119,552 | public int getDocumentsPerPage ( ) { try { final int perPage = _jsonObject . getJSONObject ( META_OBJECT_FIELD ) . getInt ( "per_page" ) ; return perPage ; } catch ( JSONException ex ) { throw new QuandlRuntimeException ( "Could not find total_count field in results from Quandl" , ex ) ; } } | Get the number of documents per page in this result set . Throws a QuandlRuntimeException if Quandl response doesn t contain this field although it should . |
119,553 | public int getCurrentPage ( ) { try { final int currentPage = _jsonObject . getJSONObject ( META_OBJECT_FIELD ) . getInt ( "current_page" ) ; return currentPage ; } catch ( JSONException ex ) { throw new QuandlRuntimeException ( "Could not find total_count field in results from Quandl" , ex ) ; } } | Get the current page of this result set . You can specify the page number in the request . Throws a QuandlRuntimeException if Quandl response doesn t contain this field although it should . |
119,554 | public List < MetaDataResult > getMetaDataResultList ( ) { JSONArray jsonArray = null ; try { jsonArray = _jsonObject . getJSONArray ( DATASETS_ARRAY_FIELD ) ; List < MetaDataResult > metaDataResults = new ArrayList < MetaDataResult > ( jsonArray . length ( ) ) ; for ( int i = 0 ; i < jsonArray . length ( ) ; i ++ ) { ... | Extract a list of MetaDataResult objects each one representing a match . Throws a QuandlRuntimeException if it cannot construct a valid HeaderDefinition |
119,555 | public static Row of ( final HeaderDefinition headerDefinition , final String [ ] values ) { ArgumentChecker . notNull ( headerDefinition , "headerDefinition" ) ; ArgumentChecker . notNull ( values , "values" ) ; return new Row ( headerDefinition , values ) ; } | Create a Row . Items in the values array can be null although the array cannot . If the headerDefinition has a different number of columns than the length of the values array then an IllegalArgumentException will be thrown . |
119,556 | public Row withPaddedHeader ( final HeaderDefinition headerDefinition ) { if ( _headerDefinition != headerDefinition ) { String [ ] values = new String [ headerDefinition . size ( ) ] ; System . arraycopy ( _values , 0 , values , 0 , _values . length ) ; return Row . of ( headerDefinition , values ) ; } else { return t... | Create row with new header . |
119,557 | public String processMultiMetaDataRequest ( final MultiMetaDataRequest request ) { StringBuilder result = new StringBuilder ( ) ; for ( String code : request . getQuandlCodes ( ) ) { if ( result . length ( ) > 0 ) { result . append ( "," ) ; } result . append ( code ) ; } return result . toString ( ) ; } | Process a multi - metadata request into a descriptive title string . |
119,558 | public String processDataSetRequest ( final DataSetRequest request ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( request . getQuandlCode ( ) ) ; if ( request . getColumnIndex ( ) != null ) { sb . append ( " column index " ) ; sb . append ( request . getColumnIndex ( ) ) ; } if ( request . getStartDate ( ... | Process a data set request into a descriptive title string . |
119,559 | public String processMultiDataSetRequest ( final MultiDataSetRequest request ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Quandl codes " ) ; final Iterator < QuandlCodeRequest > iter = request . getQuandlCodeRequests ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { QuandlCodeRequest req = iter . nex... | Process a multi data set request into a descriptive title string . |
119,560 | public String processSearchRequest ( final SearchRequest request ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "Search for " ) ; if ( request . getDatabaseCode ( ) != null ) { builder . append ( "code " ) ; builder . append ( request . getDatabaseCode ( ) ) ; } if ( request . getQuery ( ) != nu... | Process a search request into a descriptive title string . |
119,561 | public static String toPrettyPrintedString ( final JSONObject jsonObject ) { ArgumentChecker . notNull ( jsonObject , "jsonObject" ) ; try { return jsonObject . toString ( JSON_INDENT ) + LINE_SEPARATOR ; } catch ( JSONException ex ) { s_logger . error ( "Problem converting JSONObject to String" , ex ) ; throw new Quan... | Pretty print a JSONObject as an indented piece of JSON code . Throws a QuandlRuntimeException if it can t render the JSONObject to a String . |
119,562 | public static String toPrettyPrintedString ( final TabularResult result ) { ArgumentChecker . notNull ( result , "result" ) ; StringBuilder sb = new StringBuilder ( ) ; int [ ] maxWidths = maximumWidths ( result ) ; separator ( sb , maxWidths ) ; header ( sb , maxWidths , result . getHeaderDefinition ( ) ) ; separator ... | Pretty print a TabularResult in a text - based table format . |
119,563 | protected void readFile ( ) throws IOException { String line ; try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( stream ) ) ) { while ( ( line = reader . readLine ( ) ) != null ) { if ( line . contains ( BEGIN_MARKER ) ) { beginMarker = line . trim ( ) ; String endMarker = beginMarker . replace... | Read the PEM file and save the DER encoded octet stream and begin marker . |
119,564 | private static byte [ ] readBytes ( BufferedReader reader , String endMarker ) throws IOException { String line = null ; StringBuilder buf = new StringBuilder ( ) ; while ( ( line = reader . readLine ( ) ) != null ) { if ( line . contains ( endMarker ) ) { return Base64 . getDecoder ( ) . decode ( buf . toString ( ) ) ... | Read the lines between BEGIN and END marker and convert the Base64 encoded content into binary byte array . |
119,565 | private int getLength ( ) throws IOException { int i = in . read ( ) ; if ( i == - 1 ) throw new IOException ( "Invalid DER: length missing" ) ; if ( ( i & ~ 0x7F ) == 0 ) return i ; int num = i & 0x7F ; if ( i >= 0xFF || num > 4 ) throw new IOException ( "Invalid DER: length field too big (" + i + ")" ) ; byte [ ] byt... | Decode the length of the field . Can only support length encoding up to 4 octets . |
119,566 | protected boolean podRunning ( Json podStatus ) { if ( podStatus == null ) { return false ; } log . trace ( "Determining pod status" ) ; String phase = Optional . ofNullable ( podStatus . at ( "phase" ) ) . map ( Json :: asString ) . orElse ( "not running" ) ; log . trace ( " status.phase=%s" , phase ) ; if ( ! phase ... | Helper method to determine if a pod is considered running or not . |
119,567 | public String getString ( ) throws IOException { String encoding ; switch ( type ) { case DerParser . NUMERIC_STRING : case DerParser . PRINTABLE_STRING : case DerParser . VIDEOTEX_STRING : case DerParser . IA5_STRING : case DerParser . GRAPHIC_STRING : case DerParser . ISO646_STRING : case DerParser . GENERAL_STRING :... | Get value as string . Most strings are treated as Latin - 1 . |
119,568 | public byte [ ] forecastJsonBytes ( ForecastRequest request ) throws ForecastException { notNull ( "The ForecastRequest cannot be null." , request ) ; logger . log ( Level . FINE , "Executing Forecat request: {0}" , request ) ; try ( InputStream is = executeForecastRequest ( request ) ) { return IOUtil . readFully ( is... | Returns the forecast response as bytes . |
119,569 | public String getValue ( String keyMsgType ) throws IOException { if ( keyToValue . containsKey ( keyMsgType ) ) { return keyToValue . get ( keyMsgType ) ; } else { throw new IOException ( "Key " + keyMsgType + " doesn't exist in " + keyToValue ) ; } } | Gets the value associated with the key from the message . This version throws an exception if the key is not available and should be used for mandatory fields |
119,570 | public String getValueWithDefault ( String keyMsgType , String defaultVal ) { return keyToValue . getOrDefault ( keyMsgType , defaultVal ) ; } | Gets the value associated with the key from the message if it exists in the underlying map . This version returns the default value if it does not exist . |
119,571 | public int getValueAsIntWithDefault ( String keyIdField , int defaultVal ) throws IOException { if ( keyToValue . containsKey ( keyIdField ) ) { return Integer . parseInt ( getValue ( keyIdField ) ) ; } else return defaultVal ; } | Calls the getValue method first and the converts to an integer . |
119,572 | public void onCopyToClipboard ( ActionEvent actionEvent ) { Clipboard systemClipboard = Clipboard . getSystemClipboard ( ) ; ClipboardContent content = new ClipboardContent ( ) ; content . putString ( loggingArea . getText ( ) ) ; systemClipboard . setContent ( content ) ; } | A shortcut button to get the contents of the logger window into the clipboard . |
119,573 | public MenuState < String > newMenuState ( String value , boolean changed , boolean active ) { return new StringMenuState ( changed , active , value ) ; } | Returns a new String current value that can be used as the current value in the Menutree |
119,574 | public static int getVersionFromProperties ( ) { String ver = version . get ( ) ; if ( ver == null ) { try { InputStream resourceAsStream = ProtocolUtil . class . getResourceAsStream ( "/japi-version.properties" ) ; Properties props = new Properties ( ) ; props . load ( resourceAsStream ) ; ver = props . getProperty ( ... | gets and caches the current version from the version properties file |
119,575 | public static ApiPlatform fromKeyToApiPlatform ( int key ) { if ( keyToPlatform . get ( ) == null ) { Map < Integer , ApiPlatform > map = new HashMap < > ( ) ; for ( ApiPlatform apiPlatform : ApiPlatform . values ( ) ) { map . put ( apiPlatform . getKey ( ) , apiPlatform ) ; } keyToPlatform . set ( Collections . unmodi... | get the api platform given it s integer key value . |
119,576 | protected void processMessagesOnConnection ( ) { try { logger . log ( INFO , "Connected to " + getConnectionName ( ) ) ; state . set ( StreamState . CONNECTED ) ; notifyConnection ( ) ; inputBuffer . flip ( ) ; while ( ! Thread . currentThread ( ) . isInterrupted ( ) && isConnected ( ) ) { try { byte byStart = 0 ; whil... | This is the loop that handles a connection by reading messages until there s an IOException or the transport or thread change to an end state . |
119,577 | public void sendMenuCommand ( MenuCommand msg ) throws IOException { if ( isConnected ( ) ) { synchronized ( outputBuffer ) { cmdBuffer . clear ( ) ; protocol . toChannel ( cmdBuffer , msg ) ; cmdBuffer . flip ( ) ; outputBuffer . clear ( ) ; outputBuffer . put ( START_OF_MSG ) ; outputBuffer . put ( protocol . getKeyI... | Sends a command to the remote with the protocol and usual headers . |
119,578 | private byte nextByte ( ByteBuffer inputBuffer ) throws IOException { getAtLeastBytes ( inputBuffer , 1 , ReadMode . ONLY_WHEN_EMPTY ) ; return inputBuffer . get ( ) ; } | Reads the next available byte from the input buffer provided waiting if data is not available . |
119,579 | public void registerConnectionChangeListener ( ConnectionChangeListener listener ) { connectionListeners . add ( listener ) ; executor . execute ( ( ) -> listener . connectionChange ( this , isConnected ( ) ) ) ; } | Register for connection change events when there is a change in connectivity status on the underlying transport . |
119,580 | protected void logByteBuffer ( String msg , ByteBuffer inBuffer ) { if ( ! logger . isLoggable ( DEBUG ) ) return ; ByteBuffer bb = inBuffer . duplicate ( ) ; byte [ ] byData = new byte [ 512 ] ; int len = Math . min ( byData . length , bb . remaining ( ) ) ; byte dataByte = bb . get ( ) ; int pos = 0 ; while ( pos < l... | Helper method that logs the entire message buffer when at debug logging level . |
119,581 | public CodeVariableBuilder paramFromPropertyWithDefault ( String property , String defVal ) { params . add ( new PropertyWithDefaultParameter ( property , defVal ) ) ; return this ; } | This parameter will be based on the value of a property if the property is empty or missing then the replacement default will be used . |
119,582 | protected void loadModules ( String sourceDir , Collection < String > moduleNames ) { ModuleFinder finder = ModuleFinder . of ( Paths . get ( sourceDir ) ) ; ClassLoader scl = ClassLoader . getSystemClassLoader ( ) ; ModuleLayer parent = ModuleLayer . boot ( ) ; Configuration cf = parent . configuration ( ) . resolve (... | Load all the modules that were configured into the main class loader we don t want any additional class loaders we just want to load the classes in . |
119,583 | private CodePluginConfig parsePluginConfig ( InputStream inputStream ) { Gson gson = new Gson ( ) ; CodePluginConfig config = gson . fromJson ( new InputStreamReader ( inputStream ) , CodePluginConfig . class ) ; logger . log ( Level . INFO , "Loaded configuration " + config ) ; return config ; } | Create a plugin config object from JSON format . |
119,584 | public void start ( ) { connector . registerConnectorListener ( this :: onCommandReceived ) ; connector . registerConnectionChangeListener ( this :: onConnectionChange ) ; connector . start ( ) ; executor . scheduleAtFixedRate ( this :: checkHeartbeat , 1000 , 1000 , TimeUnit . MILLISECONDS ) ; } | starts the remote connection such that it will attempt to establish connectivity |
119,585 | public void sendCommand ( MenuCommand command ) { lastTx . set ( clock . millis ( ) ) ; try { connector . sendMenuCommand ( command ) ; } catch ( IOException e ) { logger . log ( ERROR , "Error while writing out command" , e ) ; connector . close ( ) ; } } | send a command to the Arduino normally use the CommandFactory to generate the command |
119,586 | protected String safeStringFromProperty ( StringProperty stringProperty , String field , List < FieldError > errorsBuilder , int maxLen , StringFieldType fieldType ) { String s = stringProperty . get ( ) ; if ( fieldType == StringFieldType . OPTIONAL && s . length ( ) > maxLen ) { errorsBuilder . add ( new FieldError (... | Gets the string value from a text field and validates it is correct in terms of length and content . |
119,587 | protected int safeIntFromProperty ( StringProperty strProp , String field , List < FieldError > errorsBuilder , int min , int max ) { String s = strProp . get ( ) ; if ( StringHelper . isStringEmptyOrNull ( s ) ) { return 0 ; } int val = 0 ; try { val = Integer . valueOf ( s ) ; if ( val < min || val > max ) { errorsBu... | Gets the integer value from a text field property and validates it again the conditions provided . It must be a number and within the ranges provided . |
119,588 | public MenuState < Integer > newMenuState ( Integer value , boolean changed , boolean active ) { return new IntegerMenuState ( changed , active , value ) ; } | returns a new state object that represents the current value for the menu . Current values are held separately to the items see MenuTree |
119,589 | public static boolean setAboutHandler ( Object target , Method aboutHandler ) { boolean enableAboutMenu = ( target != null && aboutHandler != null ) ; if ( enableAboutMenu ) { setHandler ( new OSXAdapter ( "handleAbout" , target , aboutHandler ) ) ; } try { Method enableAboutMethod = macOSXApplication . getClass ( ) . ... | They will be called when the About menu item is selected from the application menu |
119,590 | public static void setPreferencesHandler ( Object target , Method prefsHandler ) { boolean enablePrefsMenu = ( target != null && prefsHandler != null ) ; if ( enablePrefsMenu ) { setHandler ( new OSXAdapter ( "handlePreferences" , target , prefsHandler ) ) ; } try { Method enablePrefsMethod = macOSXApplication . getCla... | They will be called when the Preferences menu item is selected from the application menu |
119,591 | public static void setFileHandler ( Object target , Method fileHandler ) { setHandler ( new OSXAdapter ( "handleOpenFile" , target , fileHandler ) { public boolean callTarget ( Object appleEvent ) { if ( appleEvent != null ) { try { Method getFilenameMethod = appleEvent . getClass ( ) . getDeclaredMethod ( "getFilename... | application bundle s Info . plist |
119,592 | public static void setHandler ( OSXAdapter adapter ) { try { Class < ? > applicationClass = Class . forName ( "com.apple.eawt.Application" ) ; if ( macOSXApplication == null ) { macOSXApplication = applicationClass . getConstructor ( ( Class [ ] ) null ) . newInstance ( ( Object [ ] ) null ) ; } Class < ? > application... | setHandler creates a Proxy object from the passed OSXAdapter and adds it as an ApplicationListener |
119,593 | public boolean callTarget ( Object appleEvent ) throws InvocationTargetException , IllegalAccessException { Object result = targetMethod . invoke ( targetObject , ( Object [ ] ) null ) ; if ( result == null ) { return true ; } return Boolean . valueOf ( result . toString ( ) ) . booleanValue ( ) ; } | See setFileHandler above for an example |
119,594 | public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable { if ( isCorrectMethod ( method , args ) ) { boolean handled = callTarget ( args [ 0 ] ) ; setApplicationEventHandled ( args [ 0 ] , handled ) ; } return null ; } | This is the entry point for our proxy object ; it is called every time an ApplicationListener method is invoked |
119,595 | protected void setApplicationEventHandled ( Object event , boolean handled ) { if ( event != null ) { try { Method setHandledMethod = event . getClass ( ) . getDeclaredMethod ( "setHandled" , new Class [ ] { boolean . class } ) ; setHandledMethod . invoke ( event , new Object [ ] { Boolean . valueOf ( handled ) } ) ; }... | This method checks for a boolean result from the proxy method and sets the event accordingly |
119,596 | public static < T > Optional < T > visitWithResult ( MenuItem item , AbstractMenuItemVisitor < T > visitor ) { item . accept ( visitor ) ; return visitor . getResult ( ) ; } | Visits a menu item calling the appropriate function for the type and collects the result that is set by calling your visitor s setResult method . |
119,597 | public static SubMenuItem asSubMenu ( MenuItem item ) { return visitWithResult ( item , new AbstractMenuItemVisitor < SubMenuItem > ( ) { public void visit ( SubMenuItem item ) { setResult ( item ) ; } public void anyItem ( MenuItem item ) { } } ) . orElse ( null ) ; } | Returns the menu item as a sub menu or null |
119,598 | public static MenuItem createFromExistingWithId ( MenuItem selected , int newId ) { return visitWithResult ( selected , new AbstractMenuItemVisitor < MenuItem > ( ) { public void visit ( AnalogMenuItem item ) { setResult ( AnalogMenuItemBuilder . anAnalogMenuItemBuilder ( ) . withExisting ( item ) . withId ( newId ) . ... | creates a copy of the menu item chosen with the ID changed to newId |
119,599 | public static int eepromSizeForItem ( MenuItem item ) { return MenuItemHelper . visitWithResult ( item , new AbstractMenuItemVisitor < Integer > ( ) { public void visit ( AnalogMenuItem item ) { setResult ( 2 ) ; } public void visit ( BooleanMenuItem item ) { setResult ( 1 ) ; } public void visit ( EnumMenuItem item ) ... | Gets the size of the eeprom storage for a given element type |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.