idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
15,400 | public int getLength ( ) { int length = 4 + 4 ; if ( this . identifierPatterns != null ) { for ( String identifier : this . identifierPatterns ) { try { length += ( 4 + identifier . getBytes ( "UTF-16BE" ) . length ) ; } catch ( UnsupportedEncodingException e ) { log . error ( "Unable to encode to UTF-16BE." ) ; } } } return length ; } | Length of this object when encoded according to the Solver - World Model protocol . |
15,401 | public < T > T asObject ( String string , Class < T > valueType ) throws BugError { if ( "null" . equals ( string ) ) { return null ; } Number number = string . isEmpty ( ) ? 0 : parseNumber ( string ) ; if ( Types . equalsAny ( valueType , int . class , Integer . class ) ) { return ( T ) ( Integer ) number . intValue ( ) ; } if ( Types . equalsAny ( valueType , double . class , Double . class ) ) { return ( T ) ( Double ) number . doubleValue ( ) ; } if ( Types . equalsAny ( valueType , byte . class , Byte . class ) ) { return ( T ) ( Byte ) number . byteValue ( ) ; } if ( Types . equalsAny ( valueType , short . class , Short . class ) ) { return ( T ) ( Short ) number . shortValue ( ) ; } if ( Types . equalsAny ( valueType , long . class , Long . class ) ) { if ( string . length ( ) > 0 && string . indexOf ( '.' ) == - 1 ) { if ( string . length ( ) > 1 && string . charAt ( 0 ) == '0' && string . charAt ( 1 ) == 'x' ) { return ( T ) ( Long ) Long . parseLong ( string . substring ( 2 ) , 16 ) ; } return ( T ) ( Long ) Long . parseLong ( string ) ; } return ( T ) ( Long ) number . longValue ( ) ; } if ( Types . equalsAny ( valueType , float . class , Float . class ) ) { return ( T ) ( Float ) number . floatValue ( ) ; } if ( Types . equalsAny ( valueType , BigDecimal . class ) ) { return ( T ) new BigDecimal ( number . doubleValue ( ) ) ; } throw new BugError ( "Unsupported numeric value |%s|." , valueType ) ; } | Convert a string to a number of given type . If given string can t be stored into required type silent rounding is applied . If given string is empty return 0 since it is considered as an optional numeric input . |
15,402 | private Number parseNumber ( String string ) { if ( string . length ( ) > 2 && string . charAt ( 0 ) == '0' && string . charAt ( 1 ) == 'x' ) { return Long . parseLong ( string . substring ( 2 ) , 16 ) ; } return Double . parseDouble ( string ) ; } | Parse numeric string value to a number . |
15,403 | public static < T > ListDataKey < T > create ( String name , Class < T > dataClass ) { return create ( name , dataClass , true ) ; } | creates a list data key with the given name and type . Null types are allowed . |
15,404 | public XMLGregorianCalendar getTimeStamp ( ) { GregorianCalendar cal = new GregorianCalendar ( ) ; DatatypeFactory dt ; try { dt = DatatypeFactory . newInstance ( ) ; return dt . newXMLGregorianCalendar ( cal ) ; } catch ( DatatypeConfigurationException e ) { e . printStackTrace ( ) ; } return null ; } | Get the current timestamp . |
15,405 | public void setPayloadProperties ( BaseMessage message , Object msg ) { MessageDataDesc messageDataDesc = message . getMessageDataDesc ( null ) ; if ( messageDataDesc != null ) { Map < String , Class < ? > > mapPropertyNames = messageDataDesc . getPayloadPropertyNames ( null ) ; if ( mapPropertyNames != null ) { for ( String strKey : mapPropertyNames . keySet ( ) ) { Class < ? > classKey = mapPropertyNames . get ( strKey ) ; this . setPayloadProperty ( message , msg , strKey , classKey ) ; } } } if ( message . get ( "Version" ) == null ) this . setPayloadProperty ( DEFAULT_VERSION , msg , "Version" , Float . class ) ; this . setPayloadProperty ( this . getTimeStamp ( ) , msg , "TimeStamp" , org . joda . time . DateTime . class ) ; } | Move the standard payload properties from the message to the xml . |
15,406 | public void setPayloadProperty ( BaseMessage message , Object msg , String strKey , Class < ? > classKey ) { Object data = message . get ( strKey ) ; if ( data == null ) return ; this . setPayloadProperty ( data , msg , strKey , classKey ) ; } | Move this standard payload properties from the message to the xml . |
15,407 | public void setPayloadProperty ( Object data , Object msg , String strKey , Class < ? > classKey ) { String name = "set" + strKey ; try { Class < ? > [ ] params = { classKey } ; Method method = msg . getClass ( ) . getMethod ( name , params ) ; if ( method != null ) { Object [ ] datas = new Object [ 1 ] ; if ( data != null ) if ( ! classKey . isAssignableFrom ( data . getClass ( ) ) ) { data = this . convertObjectToDatatype ( data , classKey ) ; } datas [ 0 ] = data ; method . invoke ( msg , datas ) ; } } catch ( SecurityException e ) { e . printStackTrace ( ) ; } catch ( NoSuchMethodException e ) { } catch ( InvocationTargetException e ) { e . printStackTrace ( ) ; } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; } } | Move this standard payload data to the xml . |
15,408 | private static void populateCache ( ) { if ( cache == null ) { cache = new LinkedHashMap < > ( ) ; logger . info ( "IDataDecoders found:" ) ; ServiceLoader < IDataDecoder > loader = ServiceLoader . load ( IDataDecoder . class ) ; for ( IDataDecoder discoveredDecoder : loader ) { String name = discoveredDecoder . getClass ( ) . getCanonicalName ( ) ; String decoderMimeType = discoveredDecoder . getMimeType ( ) ; logger . info ( String . format ( " %s -> %s" , decoderMimeType , name ) ) ; cache . put ( decoderMimeType , discoveredDecoder . getClass ( ) ) ; } } } | Populates the cache . |
15,409 | public static IDataDecoder getDecoder ( final String mimeType ) throws ClassNotFoundException , IllegalAccessException , InstantiationException { populateCache ( ) ; if ( ! cache . containsKey ( mimeType ) ) { throw new ClassNotFoundException ( String . format ( "IDataDecoder for" + " mimeType [%s] not found." , mimeType ) ) ; } Class < ? extends IDataDecoder > decoderClass = cache . get ( mimeType ) ; return decoderClass . newInstance ( ) ; } | Retrieve a decoder for a specified mime type . |
15,410 | public final void setCancelable ( final Cancelable cancelable ) { if ( SwingUtilities . isEventDispatchThread ( ) ) { setCancelableIntern ( cancelable ) ; } else { try { SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { setCancelableIntern ( cancelable ) ; } } ) ; } catch ( final Exception ex ) { ignore ( ) ; } } } | Sets the listener to inform about the user cancelling the current transfer . |
15,411 | public static void main ( final String [ ] args ) { SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { Utils4Swing . initSystemLookAndFeel ( ) ; Utils4Swing . createShowAndPosition ( "Test Progress Dialog" , new FileCopyProgressPanel ( ) , true , new ScreenCenterPositioner ( ) ) ; } } ) ; } | Main method to test the panel . Only for testing purposes . |
15,412 | public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { if ( this . getOwner ( ) != null ) { IntegerField thisField = ( ( IntegerField ) this . getOwner ( ) . getRecord ( ) . getField ( m_iMainFilesFieldSeq ) ) ; if ( this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) != null ) if ( this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) != null ) if ( this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) != null ) { int iUserID = - 1 ; if ( this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) != null ) if ( ( ( BaseApplication ) this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) != null ) if ( ( ( BaseApplication ) this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) != null ) if ( ( ( BaseApplication ) this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) . length ( ) > 0 ) iUserID = Integer . parseInt ( ( ( BaseApplication ) this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) ) ; int iErrorCode = thisField . setValue ( iUserID , bDisplayOption , DBConstants . SCREEN_MOVE ) ; if ( iMoveMode == DBConstants . INIT_MOVE ) thisField . setModified ( false ) ; return iErrorCode ; } } return DBConstants . ERROR_RETURN ; } | The Field has Changed . Change the changed by user field . |
15,413 | protected void eliminate ( ) { int count = end - begin ; int mod = Math . floorMod ( begin , size ) ; while ( count > 0 && isRemovable ( mod ) ) { remove ( mod ) ; begin ++ ; count -- ; mod = Math . floorMod ( begin , size ) ; } } | Eliminate values that are no longer used in calculation |
15,414 | protected Object newArray ( Object old , int oldLen , Object arr ) { int sb = Math . floorMod ( begin , oldLen ) ; int se = Math . floorMod ( end , oldLen ) ; if ( sb < se ) { System . arraycopy ( old , sb , arr , sb , se - sb ) ; } else { System . arraycopy ( old , sb , arr , sb , oldLen - sb ) ; System . arraycopy ( old , 0 , arr , 0 , se ) ; } return arr ; } | Returns new oldLen ring buffer |
15,415 | public List < String > readFile ( Reader reader ) throws Exception { try { if ( characteristics . doIgnoreCase ( ) ) { if ( characteristics . aloneOnLine ( ) ) { return readFileIgnoreCaseAloneOnLine ( reader ) ; } else { throw new Exception ( "Batch separator detection scheme not implemented" ) ; } } else { if ( characteristics . aloneOnLine ( ) ) { return readFileConsiderCaseAloneOnLine ( reader ) ; } else { return readFileConsiderCase ( reader ) ; } } } catch ( Exception e ) { throw new Exception ( "Failed to read file: " + e . getMessage ( ) ) ; } finally { if ( options . debug ) System . out . println ( "Done reading" ) ; } } | Reads an SQL - script and identifies individual statements . The batch separator handling is dependent on the database manager |
15,416 | public void syncRecords ( Record recAlt , Record recMain ) { boolean bFieldsInSync = true ; m_buffer = new VectorBuffer ( null ) ; for ( int iIndex = 0 ; iIndex < recMain . getFieldCount ( ) ; iIndex ++ ) { BaseField fieldAlt = recAlt . getField ( iIndex ) ; BaseField fieldMain = null ; if ( bFieldsInSync ) fieldMain = recMain . getField ( iIndex ) ; if ( ( fieldMain == null ) || ( ! fieldMain . getFieldName ( ) . equals ( fieldAlt . getFieldName ( ) ) ) ) { fieldMain = recMain . getField ( fieldAlt . getFieldName ( ) ) ; bFieldsInSync = false ; } if ( fieldMain != null ) if ( fieldAlt != null ) if ( this . isLanguageOverride ( fieldMain ) ) { m_buffer . addNextField ( fieldMain ) ; if ( ! fieldAlt . isNull ( ) ) { fieldMain . moveFieldToThis ( ( BaseField ) fieldAlt , DBConstants . DISPLAY , DBConstants . READ_MOVE ) ; fieldMain . setModified ( false ) ; } } } } | Save the record state and copy the localized fields from the language record to the main record . |
15,417 | public void restoreMainRecord ( Record record , boolean altMatchesToNull ) { Iterator < BaseTable > iterator = this . getTables ( ) ; while ( iterator . hasNext ( ) ) { BaseTable table = iterator . next ( ) ; if ( ( table != null ) && ( table != this . getNextTable ( ) ) ) { Record record2 = table . getRecord ( ) ; this . restoreMainRecord ( record2 , record , altMatchesToNull ) ; } } } | Restore the unchangeable info from the buffer to this main record . |
15,418 | public void restoreMainRecord ( Record recAlt , Record recMain , boolean altMatchesToNull ) { if ( m_buffer != null ) m_buffer . resetPosition ( ) ; boolean bFieldsInSync = true ; for ( int iIndex = 0 ; iIndex < recAlt . getFieldCount ( ) ; iIndex ++ ) { BaseField fieldAlt = recAlt . getField ( iIndex ) ; BaseField fieldMain = null ; if ( bFieldsInSync ) fieldMain = recMain . getField ( iIndex ) ; if ( ( fieldMain == null ) || ( ! fieldMain . getFieldName ( ) . equals ( fieldAlt . getFieldName ( ) ) ) ) { fieldMain = recMain . getField ( fieldAlt . getFieldName ( ) ) ; bFieldsInSync = false ; } fieldAlt . moveFieldToThis ( ( BaseField ) fieldMain ) ; if ( fieldMain != null ) if ( fieldAlt != null ) if ( this . isLanguageOverride ( fieldMain ) ) { if ( m_buffer != null ) m_buffer . getNextField ( fieldMain , DBConstants . DONT_DISPLAY , DBConstants . READ_MOVE ) ; fieldMain . setModified ( false ) ; } if ( altMatchesToNull ) if ( fieldMain . equals ( fieldAlt ) ) if ( ( fieldAlt . isNullable ( ) ) && ( fieldAlt != recAlt . getCounterField ( ) ) ) fieldAlt . setData ( null ) ; } } | Restore the main record s string fields to their original state from the buffer . |
15,419 | public int moveFieldToThis ( BaseField field , boolean bDisplayOption , int iMoveMode ) { if ( field == null ) return DBConstants . NORMAL_RETURN ; if ( field instanceof CounterField ) { if ( this . getReferenceRecord ( null , false ) == null ) if ( field . getRecord ( ) . getListener ( ClearFieldReferenceOnCloseHandler . class ) == null ) this . setReferenceRecord ( field . getRecord ( ) ) ; } else if ( field instanceof ReferenceField ) { } else this . setReferenceRecord ( null ) ; return super . moveFieldToThis ( field , bDisplayOption , iMoveMode ) ; } | Move data to this field from another field . If these isn t a reference record yet figures out the reference record . |
15,420 | public Record getReference ( ) { Record record = this . getReferenceRecord ( ) ; if ( record != null ) { try { if ( this . getData ( ) == null ) { record . addNew ( ) ; return record ; } Object bookmark = this . getData ( ) ; if ( ( record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) || ( record . getEditMode ( ) == Constants . EDIT_CURRENT ) ) { Object oldBookmark = record . getHandle ( DBConstants . BOOKMARK_HANDLE ) ; if ( ( bookmark != null ) && ( bookmark . equals ( oldBookmark ) ) ) return record ; } record . setHandle ( bookmark , DBConstants . BOOKMARK_HANDLE ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; record = null ; } } return record ; } | Get the record that this field references and make it current . |
15,421 | public String getReferenceRecordName ( ) { if ( m_recordReference != null ) return this . getReferenceRecord ( ) . getTableNames ( false ) ; else { if ( this . getClass ( ) . getName ( ) . indexOf ( "Field" ) != - 1 ) return this . getClass ( ) . getName ( ) . substring ( Math . max ( 0 , this . getClass ( ) . getName ( ) . lastIndexOf ( '.' ) + 1 ) , this . getClass ( ) . getName ( ) . indexOf ( "Field" ) ) ; else if ( this . getFieldName ( false , false ) . indexOf ( "ID" ) != - 1 ) return this . getFieldName ( false , false ) . substring ( 0 , this . getFieldName ( false , false ) . indexOf ( "ID" ) ) ; else this . getFieldName ( false , false ) ; } return Constants . BLANK ; } | Get the record name that this field references . |
15,422 | public int setReference ( Record record , boolean bDisplayOption , int iMoveMode ) { return this . moveFieldToThis ( ( BaseField ) record . getCounterField ( ) , bDisplayOption , iMoveMode ) ; } | Make this field a reference to the current object in this record info class . |
15,423 | public void syncReference ( Record record ) { this . setReferenceRecord ( record ) ; BaseField recordKeyField = ( BaseField ) record . getCounterField ( ) ; if ( ( recordKeyField . isNull ( ) ) && ( ! this . isNull ( ) ) && ( ! record . isModified ( ) ) && ( record . getEditMode ( ) != DBConstants . EDIT_CURRENT ) && ( record . getEditMode ( ) != DBConstants . EDIT_IN_PROGRESS ) && ( ( record . getOpenMode ( ) & DBConstants . OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY ) == 0 ) ) { recordKeyField . moveFieldToThis ( this , DBConstants . DISPLAY , DBConstants . SCREEN_MOVE ) ; recordKeyField . setModified ( false ) ; } else this . setReference ( record , DBConstants . DISPLAY , DBConstants . SCREEN_MOVE ) ; MoveOnChangeHandler listener = ( MoveOnChangeHandler ) this . getListener ( MoveOnChangeHandler . class . getName ( ) ) ; if ( ( listener == null ) || ( listener . getDestField ( ) != recordKeyField ) ) this . addListener ( new MoveOnChangeHandler ( recordKeyField , null ) ) ; MoveOnValidHandler listener2 = ( MoveOnValidHandler ) record . getListener ( MoveOnValidHandler . class . getName ( ) ) ; if ( ( listener2 == null ) || ( listener2 . getSourceField ( ) != recordKeyField ) ) record . addListener ( new MoveOnValidHandler ( this , recordKeyField ) ) ; MainReadOnlyHandler listener3 = ( MainReadOnlyHandler ) recordKeyField . getListener ( MainReadOnlyHandler . class . getName ( ) ) ; if ( listener3 == null ) recordKeyField . addListener ( new MainReadOnlyHandler ( null ) ) ; } | Synchronize this refernce field with this record . Adds the behaviors to sync this field and the record . Used for popup screenfields where the referencerecord has a detail to display on change . |
15,424 | public ScreenComponent setupIconView ( ScreenLoc itsLocation , ComponentParent targetScreen , Convert converter , int iDisplayFieldDesc , boolean bIncludeBlankOption ) { ScreenComponent screenField = null ; Record record = this . makeReferenceRecord ( ) ; ImageField fldDisplayFieldDesc = this . getIconField ( record ) ; if ( fldDisplayFieldDesc . getListener ( BlankButtonHandler . class ) == null ) fldDisplayFieldDesc . addListener ( new BlankButtonHandler ( null ) ) ; if ( fldDisplayFieldDesc != null ) { FieldConverter fldDescConverter = new FieldDescConverter ( fldDisplayFieldDesc , ( Converter ) converter ) ; Map < String , Object > properties = new HashMap < String , Object > ( ) ; properties . put ( ScreenModel . IMAGE , ScreenModel . NONE ) ; properties . put ( ScreenModel . NEVER_DISABLE , Constants . TRUE ) ; screenField = createScreenComponent ( ScreenModel . BUTTON_BOX , itsLocation , targetScreen , fldDescConverter , iDisplayFieldDesc , properties ) ; String strDisplay = converter . getFieldDesc ( ) ; if ( ! ( targetScreen instanceof GridScreenParent ) ) if ( ( strDisplay != null ) && ( strDisplay . length ( ) > 0 ) ) { ScreenLoc descLocation = targetScreen . getNextLocation ( ScreenConstants . FIELD_DESC , ScreenConstants . DONT_SET_ANCHOR ) ; properties = new HashMap < String , Object > ( ) ; properties . put ( ScreenModel . DISPLAY_STRING , strDisplay ) ; createScreenComponent ( ScreenModel . STATIC_STRING , descLocation , targetScreen , converter , iDisplayFieldDesc , properties ) ; } } if ( ( ( targetScreen instanceof GridScreenParent ) ) || ( iDisplayFieldDesc == ScreenConstants . DONT_DISPLAY_FIELD_DESC ) ) { this . addListener ( new ReadSecondaryHandler ( fldDisplayFieldDesc . getRecord ( ) ) ) ; } return screenField ; } | Display a button that shows the icon from the current record in the secondary file . |
15,425 | public ImageField getIconField ( Record record ) { if ( record == null ) record = this . getReferenceRecord ( ) ; for ( int i = 0 ; i < record . getFieldCount ( ) ; i ++ ) { BaseField field = record . getField ( i ) ; if ( field instanceof ImageField ) return ( ImageField ) field ; } return null ; } | Get the IconField from this record . |
15,426 | public ScreenComponent setupPopupView ( ScreenLoc itsLocation , ComponentParent targetScreen , Convert converter , int iDisplayFieldDesc , boolean bIncludeBlankOption ) { ScreenComponent screenField = null ; Record record = this . makeReferenceRecord ( ) ; screenField = this . setupIconView ( itsLocation , targetScreen , converter , iDisplayFieldDesc , bIncludeBlankOption ) ; if ( ( ! ( targetScreen instanceof GridScreenParent ) ) && ( iDisplayFieldDesc != ScreenConstants . DONT_DISPLAY_FIELD_DESC ) ) { if ( screenField != null ) { itsLocation = targetScreen . getNextLocation ( ScreenConstants . RIGHT_OF_LAST , ScreenConstants . DONT_SET_ANCHOR ) ; iDisplayFieldDesc = ScreenConstants . DONT_DISPLAY_FIELD_DESC ; } screenField = this . setupTablePopup ( itsLocation , targetScreen , converter , iDisplayFieldDesc , record , - 1 , - 1 , bIncludeBlankOption , false ) ; } return screenField ; } | Add icon to popup . |
15,427 | public static boolean copyDirectory ( final File source , final File destination ) throws FileIsSecurityRestrictedException , IOException , FileIsADirectoryException , FileIsNotADirectoryException , DirectoryAlreadyExistsException { return copyDirectory ( source , destination , true ) ; } | Copies the given source directory to the given destination directory . |
15,428 | public static boolean copyDirectory ( final File source , final File destination , final boolean lastModified ) throws FileIsSecurityRestrictedException , IOException , FileIsADirectoryException , FileIsNotADirectoryException , DirectoryAlreadyExistsException { return copyDirectoryWithFileFilter ( source , destination , null , lastModified ) ; } | Copies the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory . |
15,429 | public static boolean copyDirectoryWithFileFilter ( final File source , final File destination , final FileFilter fileFilter , final boolean lastModified ) throws IOException , FileIsNotADirectoryException , FileIsADirectoryException , FileIsSecurityRestrictedException , DirectoryAlreadyExistsException { return copyDirectoryWithFileFilter ( source , destination , fileFilter , null , lastModified ) ; } | Copies all files that match to the FileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory . |
15,430 | public static boolean copyDirectoryWithFileFilter ( final File source , final File destination , final FileFilter includeFileFilter , final FileFilter excludeFileFilter , final Collection < File > excludeFiles , final boolean lastModified ) throws IOException , FileIsNotADirectoryException , FileIsADirectoryException , FileIsSecurityRestrictedException , DirectoryAlreadyExistsException { if ( ! source . isDirectory ( ) ) { throw new FileIsNotADirectoryException ( "Source file '" + source . getAbsolutePath ( ) + "' is not a directory." ) ; } if ( ! destination . exists ( ) ) { CreateFileExtensions . newDirectory ( destination ) ; } boolean copied = false ; File [ ] includeFilesArray ; if ( null != includeFileFilter ) { includeFilesArray = source . listFiles ( includeFileFilter ) ; } else { includeFilesArray = source . listFiles ( ) ; } if ( null != includeFilesArray ) { File [ ] excludeFilesArray ; List < File > allExcludeFilesList = null ; List < File > excludeFileFilterList ; if ( null != excludeFileFilter ) { excludeFilesArray = source . listFiles ( excludeFileFilter ) ; excludeFileFilterList = Arrays . asList ( excludeFilesArray ) ; allExcludeFilesList = new ArrayList < > ( excludeFileFilterList ) ; } if ( excludeFiles != null && ! excludeFiles . isEmpty ( ) ) { if ( allExcludeFilesList != null ) { allExcludeFilesList . addAll ( excludeFiles ) ; } else { allExcludeFilesList = new ArrayList < > ( excludeFiles ) ; } } if ( null != allExcludeFilesList && ! allExcludeFilesList . isEmpty ( ) ) { for ( final File element : includeFilesArray ) { final File currentFile = element ; if ( ! allExcludeFilesList . contains ( currentFile ) ) { final File copy = new File ( destination , currentFile . getName ( ) ) ; if ( currentFile . isDirectory ( ) ) { copied = copyDirectoryWithFileFilter ( currentFile , copy , includeFileFilter , excludeFileFilter , lastModified ) ; } else { copied = copyFile ( currentFile , copy , lastModified ) ; } } } } else { for ( final File currentFile : includeFilesArray ) { final File copy = new File ( destination , currentFile . getName ( ) ) ; if ( currentFile . isDirectory ( ) ) { copied = copyDirectoryWithFileFilter ( currentFile , copy , includeFileFilter , excludeFileFilter , lastModified ) ; } else { copied = copyFile ( currentFile , copy , lastModified ) ; } } } } else { throw new FileIsSecurityRestrictedException ( "File '" + source . getAbsolutePath ( ) + "' is security restricted." ) ; } return copied ; } | Copies all files that match to the given includeFileFilter and does not copy all the files that match the excludeFileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory . |
15,431 | public static boolean copyDirectoryWithFilenameFilter ( final File source , final File destination , final FilenameFilter filenameFilter , final boolean lastModified ) throws IOException , FileIsNotADirectoryException , FileIsADirectoryException , FileIsSecurityRestrictedException , DirectoryAlreadyExistsException { return copyDirectoryWithFilenameFilter ( source , destination , filenameFilter , null , lastModified ) ; } | Copies all files that match to the FilenameFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory . |
15,432 | public static boolean copyDirectoryWithFilenameFilter ( final File source , final File destination , final FilenameFilter includeFilenameFilter , final FilenameFilter excludeFilenameFilter , final boolean lastModified ) throws IOException , FileIsNotADirectoryException , FileIsADirectoryException , FileIsSecurityRestrictedException { if ( ! source . isDirectory ( ) ) { throw new FileIsNotADirectoryException ( "Source file '" + source . getAbsolutePath ( ) + "' is not a directory." ) ; } if ( ! destination . exists ( ) ) { CreateFileExtensions . newDirectory ( destination ) ; } boolean copied = false ; File [ ] includeFilesArray ; if ( null != includeFilenameFilter ) { includeFilesArray = source . listFiles ( includeFilenameFilter ) ; } else { includeFilesArray = source . listFiles ( ) ; } if ( null != includeFilesArray ) { File [ ] excludeFilesArray ; List < File > excludeFilesList = null ; if ( null != excludeFilenameFilter ) { excludeFilesArray = source . listFiles ( excludeFilenameFilter ) ; excludeFilesList = Arrays . asList ( excludeFilesArray ) ; } if ( null != excludeFilesList && ! excludeFilesList . isEmpty ( ) ) { for ( final File element : includeFilesArray ) { final File currentFile = element ; if ( ! excludeFilesList . contains ( currentFile ) ) { final File copy = new File ( destination , currentFile . getName ( ) ) ; if ( currentFile . isDirectory ( ) ) { copied = copyDirectoryWithFilenameFilter ( currentFile , copy , includeFilenameFilter , excludeFilenameFilter , lastModified ) ; } else { copied = copyFile ( currentFile , copy , lastModified ) ; } } } } else { for ( final File currentFile : includeFilesArray ) { final File copy = new File ( destination , currentFile . getName ( ) ) ; if ( currentFile . isDirectory ( ) ) { copied = copyDirectoryWithFilenameFilter ( currentFile , copy , includeFilenameFilter , excludeFilenameFilter , lastModified ) ; } else { copied = copyFile ( currentFile , copy , lastModified ) ; } } } } else { throw new FileIsSecurityRestrictedException ( "File '" + source . getAbsolutePath ( ) + "' is security restricted." ) ; } return copied ; } | Copies all files that match to the given includeFilenameFilter and does not copy all the files that match the excludeFilenameFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory . |
15,433 | public static boolean copyFile ( final File source , final File destination ) throws IOException , FileIsADirectoryException { return copyFile ( source , destination , true ) ; } | Copies the given source file to the given destination file . |
15,434 | public static boolean copyFile ( final File source , final File destination , final boolean lastModified ) throws IOException { return copyFile ( source , destination , null , null , lastModified ) ; } | Copies the given source file to the given destination file with the option to set the lastModified time from the given destination file . |
15,435 | public static boolean copyFile ( final File source , final File destination , final Charset sourceEncoding , final Charset destinationEncoding , final boolean lastModified ) throws IOException { if ( source . isDirectory ( ) ) { throw new IllegalArgumentException ( "The source File " + destination . getName ( ) + " should be a File but is a Directory." ) ; } if ( destination . isDirectory ( ) ) { throw new IllegalArgumentException ( "The destination File " + destination . getName ( ) + " should be a File but is a Directory." ) ; } boolean copied = false ; try ( InputStream inputStream = StreamExtensions . getInputStream ( source ) ; InputStreamReader reader = sourceEncoding != null ? new InputStreamReader ( inputStream , sourceEncoding ) : new InputStreamReader ( inputStream ) ; OutputStream outputStream = StreamExtensions . getOutputStream ( destination , ! destination . exists ( ) ) ; BufferedOutputStream bos = new BufferedOutputStream ( outputStream ) ; OutputStreamWriter writer = destinationEncoding != null ? new OutputStreamWriter ( bos , destinationEncoding ) : new OutputStreamWriter ( bos ) ) { int tmp ; final char [ ] charArray = new char [ FileConst . BLOCKSIZE ] ; while ( ( tmp = reader . read ( charArray ) ) > 0 ) { writer . write ( charArray , 0 , tmp ) ; } copied = true ; } catch ( final IOException e ) { throw e ; } if ( lastModified ) { destination . setLastModified ( source . lastModified ( ) ) ; } return copied ; } | Copies the given source file to the given destination file with the given source encodings and destination encodings . |
15,436 | public static boolean copyFileToDirectory ( final File source , final File destinationDir ) throws FileIsNotADirectoryException , IOException , FileIsADirectoryException { return copyFileToDirectory ( source , destinationDir , true ) ; } | Copies the given source file to the given destination directory . |
15,437 | public static boolean copyFileToDirectory ( final File source , final File destinationDir , final boolean lastModified ) throws FileIsNotADirectoryException , IOException , FileIsADirectoryException { if ( null == destinationDir ) { throw new IllegalArgumentException ( "Destination must not be null" ) ; } if ( ! destinationDir . isDirectory ( ) ) { throw new FileIsNotADirectoryException ( "Destination File-object '" + destinationDir . getAbsolutePath ( ) + "' is not a directory." ) ; } final File destinationFile = new File ( destinationDir , source . getName ( ) ) ; return copyFile ( source , destinationFile , lastModified ) ; } | Copies the given source file to the given destination directory with the option to set the lastModified time from the given destination directory . |
15,438 | protected int doUpdate ( JdbcTemplate jdbcTemplate , TaskRequest req , TaskResponse res ) { final List < Phrase > parametersInUse = update_parameters != null ? update_parameters : parameters ; final PreparedStatementSetter preparedStatementSetter = new PhraseParameterPreparedStatementSetter ( parametersInUse , req , res ) ; final String fUpdateSql = ( String ) update_sql . evaluate ( req , res ) ; return jdbcTemplate . update ( fUpdateSql , preparedStatementSetter ) ; } | Executes the update and returns the affected row count |
15,439 | protected int doInsert ( JdbcTemplate jdbcTemplate , TaskRequest req , TaskResponse res ) { final List < Phrase > parametersInUse = insert_parameters != null ? insert_parameters : parameters ; final PreparedStatementSetter preparedStatementSetter = new PhraseParameterPreparedStatementSetter ( parametersInUse , req , res ) ; final String fInsertSql = ( String ) insert_sql . evaluate ( req , res ) ; return jdbcTemplate . update ( fInsertSql , preparedStatementSetter ) ; } | Executes the insert and returns the affected row count |
15,440 | public static int decodeSingle ( final byte [ ] input , final int inoff ) { if ( input == null ) { throw new NullPointerException ( "input" ) ; } if ( input . length < 2 ) { throw new IllegalArgumentException ( "input.length(" + input . length + ") < 2" ) ; } if ( inoff < 0 ) { throw new IllegalArgumentException ( "inoff(" + inoff + ") < 0" ) ; } if ( inoff >= input . length - 1 ) { throw new IllegalArgumentException ( "inoff(" + inoff + ") >= input.length(" + input . length + ") - 1" ) ; } return ( decodeHalf ( input [ inoff ] & 0xFF ) << 4 ) | decodeHalf ( input [ inoff + 1 ] & 0xFF ) ; } | Decodes two nibbles in given input array and returns the decoded octet . |
15,441 | public static void decodeSingle ( final byte [ ] input , final int inoff , final byte [ ] output , final int outoff ) { if ( output == null ) { throw new NullPointerException ( "output" ) ; } if ( outoff < 0 ) { throw new IllegalArgumentException ( "outoff(" + outoff + ") < 0" ) ; } if ( outoff >= output . length ) { throw new IllegalArgumentException ( "outoff(" + outoff + ") >= output.length(" + output . length + ")" ) ; } output [ outoff ] = ( byte ) decodeSingle ( input , inoff ) ; } | Decodes two nibbles in given input array and writes the resulting single octet into specified output array . |
15,442 | public static void decodeMultiple ( final byte [ ] input , int inoff , final byte [ ] output , int outoff , final int count ) { if ( count < 0 ) { throw new IllegalArgumentException ( "count(" + count + ") < 0" ) ; } for ( int i = 0 ; i < count ; i ++ ) { decodeSingle ( input , inoff , output , outoff ) ; inoff += 2 ; outoff += 1 ; } } | Decodes multiple units in given input array and writes the resulting octets into specifed output array . |
15,443 | public static byte [ ] decodeMultiple ( final byte [ ] input ) { if ( input == null ) { throw new NullPointerException ( "input" ) ; } final byte [ ] output = new byte [ input . length >> 1 ] ; decodeMultiple ( input , 0 , output , 0 , output . length ) ; return output ; } | Encodes given sequence of nibbles into a sequence of octets . |
15,444 | public String decodeToString ( final byte [ ] input , final String outputCharset ) throws UnsupportedEncodingException { return new String ( decode ( input ) , outputCharset ) ; } | Decodes given sequence of nibbles into a string . |
15,445 | public int setString ( String strField , boolean bDisplayOption , int iMoveMode ) { int iFieldLength = 0 ; Object objTempBinary = null ; if ( strField != null ) { iFieldLength = strField . length ( ) ; int iMaxLength = this . getMaxLength ( ) ; if ( ( iFieldLength > iMaxLength ) || ( iFieldLength > 40 ) ) iFieldLength = iMaxLength ; try { objTempBinary = this . stringToBinary ( strField ) ; } catch ( Exception ex ) { String strError = ex . getMessage ( ) ; if ( strError == null ) strError = ex . getClass ( ) . getName ( ) ; Task task = null ; if ( this . getRecord ( ) != null ) if ( this . getRecord ( ) . getRecordOwner ( ) != null ) task = this . getRecord ( ) . getRecordOwner ( ) . getTask ( ) ; if ( task == null ) return DBConstants . ERROR_RETURN ; return task . setLastError ( strError ) ; } } return this . setData ( objTempBinary , bDisplayOption , iMoveMode ) ; } | Convert and move string to this field . This Data is in a binary format so convert it and move it . |
15,446 | public Distance getRadius ( Velocity velocity ) { Distance circle = velocity . getDistance ( getTimeForFullCircle ( ) ) ; circle . mul ( 1 / Math . PI ) ; return circle ; } | Returns the radius of the circle |
15,447 | public Motion getMotionAfter ( Motion motion , TimeSpan span ) { return new Motion ( motion . getSpeed ( ) , getBearingAfter ( motion . getAngle ( ) , span ) ) ; } | Return s motion after timespan |
15,448 | public Map < String , Object > apply ( final Map < String , Object > row ) { Map < String , Object > cleanRow , filteredRow ; if ( row == null ) { cleanRow = new LinkedHashMap < > ( ) ; } else { cleanRow = new LinkedHashMap < > ( row ) ; } filteredRow = new LinkedHashMap < > ( ) ; for ( String column : columns ) { if ( cleanRow . containsKey ( column ) ) { filteredRow . put ( column , cleanRow . get ( column ) ) ; } else { filteredRow . put ( column , null ) ; } } return filteredRow ; } | Apply the filter . |
15,449 | public File collect ( Path projectRoot ) throws IOException , ZipException { DataArchiver dataArchiver = new DataArchiver ( projectRoot ) ; try { ProjectFileVisitor fileVisitor = new ProjectFileVisitor ( dataArchiver , projectRoot ) ; Files . walkFileTree ( projectRoot , fileVisitor ) ; dataArchiver . add ( "DWFileList.txt" , fileVisitor . getFileList ( ) ) ; return dataArchiver . createArchive ( ) ; } finally { dataArchiver . dispose ( ) ; } } | Gathers needed information about project |
15,450 | public static URL locateContextConfig ( String webappRootContext , String userSpecifiedContextLocation , URL defaultLocation ) { if ( webappRootContext == null ) { String msg = "Argument 'webappRootContext' cannot be null." ; throw new IllegalArgumentException ( msg ) ; } URL rslt = null ; if ( userSpecifiedContextLocation != null ) { if ( userSpecifiedContextLocation . startsWith ( "/" ) ) { userSpecifiedContextLocation = userSpecifiedContextLocation . substring ( 1 ) ; } rslt = ResourceHelper . evaluate ( webappRootContext , userSpecifiedContextLocation ) ; } else { rslt = defaultLocation ; } return rslt ; } | Locate the configuration file if present for a Portlet or Servlet . |
15,451 | public static Class compileClass ( String name , String code , List < Class > classPath ) throws Exception { JavaCompiler compiler = ToolProvider . getSystemJavaCompiler ( ) ; DiagnosticCollector < JavaFileObject > diagnostics = new DiagnosticCollector < JavaFileObject > ( ) ; MemoryJavaFileManager fileManager = new MemoryJavaFileManager ( compiler . getStandardFileManager ( null , null , null ) ) ; List < JavaFileObject > javaFileObjects = new ArrayList < JavaFileObject > ( ) ; javaFileObjects . add ( new MemoryJavaFileObject ( name , code ) ) ; File tempDir = new File ( System . getProperty ( "java.io.tmpdir" ) , name ) ; List < String > options = new ArrayList < String > ( ) ; if ( classPath . size ( ) > 0 ) { options . add ( "-classpath" ) ; options . add ( tempDir . getAbsolutePath ( ) ) ; for ( Class c : classPath ) { String classRelativePath = c . getName ( ) . replace ( '.' , '/' ) + ".class" ; URL classInputLocation = c . getResource ( '/' + classRelativePath ) ; File outputFile = new File ( tempDir , classRelativePath ) ; outputFile . getParentFile ( ) . mkdirs ( ) ; InputStream input = classInputLocation . openStream ( ) ; FileOutputStream output = new FileOutputStream ( outputFile ) ; IOUtils . copy ( input , output ) ; input . close ( ) ; output . close ( ) ; } } Boolean success = compiler . getTask ( null , fileManager , diagnostics , options , null , javaFileObjects ) . call ( ) ; if ( success ) { return fileManager . getClassLoader ( null ) . loadClass ( name ) ; } else { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( Diagnostic diagnostic : diagnostics . getDiagnostics ( ) ) { stringBuilder . append ( diagnostic . getMessage ( null ) ) . append ( "\n" ) ; } throw new Exception ( stringBuilder . toString ( ) ) ; } } | Compiles Java code and returns compiled class back . |
15,452 | public void init ( BaseMessage message , Object objRawMessage ) { m_message = message ; if ( message != null ) message . setExternalMessage ( this ) ; if ( objRawMessage != null ) this . setRawData ( objRawMessage ) ; } | Initialize new ExternalTrxMessage . |
15,453 | public void moveHeaderParams ( Map < String , Object > mapMessage , Map < String , Object > mapHeader ) { for ( int i = 0 ; i < m_rgstrHeaderParams . length ; i ++ ) { if ( mapMessage . get ( m_rgstrHeaderParams [ i ] ) != null ) if ( mapHeader . get ( m_rgstrHeaderParams [ i ] ) == null ) { Object objValue = mapMessage . get ( m_rgstrHeaderParams [ i ] ) ; mapMessage . remove ( m_rgstrHeaderParams [ i ] ) ; mapHeader . put ( m_rgstrHeaderParams [ i ] , objValue ) ; } } } | Move the header params from the message map to the header map . |
15,454 | public Document getScratchDocument ( DocumentBuilder db ) { if ( m_doc == null ) { m_doc = db . newDocument ( ) ; } return m_doc ; } | Get the scratch document for this message . Creates a new document the first time . |
15,455 | public String getXSLTDocument ( ) { TrxMessageHeader messageHeader = ( TrxMessageHeader ) this . getMessage ( ) . getMessageHeader ( ) ; String strDocument = null ; if ( messageHeader != null ) strDocument = ( String ) messageHeader . get ( TrxMessageHeader . XSLT_DOCUMENT ) ; return strDocument ; } | Get the XSLT Document to do the conversion . Override this if you have a standard document to suppyl . |
15,456 | public StreamSource getTransformerStream ( String strDocument ) { StreamSource source = null ; if ( strDocument == null ) strDocument = this . getXSLTDocument ( ) ; if ( strDocument == null ) { Reader reader = new StringReader ( XSL_CONVERT ) ; source = new StreamSource ( reader ) ; return source ; } if ( strDocument . indexOf ( ':' ) == - 1 ) { try { FileReader reader = new FileReader ( strDocument ) ; if ( reader != null ) source = new StreamSource ( reader ) ; } catch ( IOException ex ) { source = null ; } if ( source == null ) { Task task = null ; BaseAppletReference applet = null ; if ( task instanceof BaseAppletReference ) applet = ( BaseAppletReference ) task ; App app = null ; if ( task != null ) app = task . getApplication ( ) ; URL url = null ; if ( app != null ) url = app . getResourceURL ( strDocument , applet ) ; else url = this . getClass ( ) . getClassLoader ( ) . getResource ( strDocument ) ; if ( url != null ) { try { InputStream is = url . openStream ( ) ; source = new StreamSource ( is ) ; } catch ( IOException ex ) { source = null ; } } } } if ( source == null ) { try { URL url = new URL ( strDocument ) ; InputStream is = url . openStream ( ) ; source = new StreamSource ( is ) ; } catch ( IOException ex ) { source = null ; } } return source ; } | Get the XSLT transformer stream from this file or URL String . |
15,457 | public Collection < PatientListItem > getListItems ( ) { if ( ! noCaching && patients != null ) { return patients ; } patients = new ArrayList < > ( ) ; AbstractPatientListFilter filter = isFiltered ( ) ? getActiveFilter ( ) : null ; PatientListFilterEntity entity = filter == null ? null : ( PatientListFilterEntity ) filter . getEntity ( ) ; List < String > tempList = VistAUtil . getBrokerSession ( ) . callRPCList ( "RGCWPTPL LISTPTS" , null , listId , entity == null ? 0 : entity . getId ( ) , formatDateRange ( ) ) ; addPatients ( patients , tempList , 0 ) ; return patients ; } | Returns the patient list . |
15,458 | public static final < K , V > MapList < K , V > unmodifiableMapList ( MapList < K , V > map ) { return new UnmodifiableMapList ( Collections . unmodifiableMap ( map ) , map . getComparator ( ) ) ; } | Returns unmodifiable MapList . |
15,459 | public static final < K , V > MapSet < K , V > unmodifiableMapSet ( MapSet < K , V > set ) { return new UnmodifiableMapSet ( set ) ; } | Returns unmodifiable MapSet . |
15,460 | public void free ( ) { m_keyArea . removeKeyField ( this ) ; m_keyArea = null ; m_field = null ; if ( m_fieldTempParam != null ) m_fieldTempParam . free ( ) ; m_fieldTempParam = null ; if ( m_fieldStartParam != null ) m_fieldStartParam . free ( ) ; m_fieldStartParam = null ; if ( m_fieldEndParam != null ) m_fieldEndParam . free ( ) ; m_fieldEndParam = null ; } | Free this key field . |
15,461 | public BaseField getField ( int iAreaDesc ) { switch ( iAreaDesc ) { default : case DBConstants . FILE_KEY_AREA : return m_field ; case DBConstants . TEMP_KEY_AREA : if ( m_fieldTempParam == null ) { try { m_fieldTempParam = ( BaseField ) m_field . clone ( ) ; m_fieldTempParam . setFieldName ( new String ( m_field . getFieldName ( false , false ) + "Temp" ) ) ; m_fieldTempParam . setNullable ( true ) ; } catch ( CloneNotSupportedException ex ) { m_fieldTempParam = null ; } } return m_fieldTempParam ; case DBConstants . START_SELECT_KEY : if ( m_fieldStartParam == null ) { try { m_fieldStartParam = ( BaseField ) m_field . clone ( ) ; m_fieldStartParam . setFieldName ( new String ( m_field . getFieldName ( false , false ) + "Start" ) ) ; m_fieldStartParam . setNullable ( true ) ; } catch ( CloneNotSupportedException ex ) { m_fieldStartParam = null ; } } return m_fieldStartParam ; case DBConstants . END_SELECT_KEY : if ( m_fieldEndParam == null ) { try { m_fieldEndParam = ( BaseField ) m_field . clone ( ) ; m_fieldEndParam . setFieldName ( new String ( m_field . getFieldName ( false , false ) + "End" ) ) ; m_fieldEndParam . setNullable ( true ) ; } catch ( CloneNotSupportedException ex ) { m_fieldEndParam = null ; } } return m_fieldEndParam ; } } | Get the field that this KeyField points to . |
15,462 | private String getInjectionSetting ( final String input , final char startDelim ) { return input == null || input . equals ( "" ) ? null : StringUtilities . split ( input , startDelim ) [ 0 ] . trim ( ) ; } | Gets the Injection Setting for these options when using the String Constructor . |
15,463 | public int removeCallback ( IConnectionStateCallback criteria ) { List < IConnectionStateCallback > listCallbacks = getConnectionDetail ( ) . getConnCallbacks ( ) ; if ( listCallbacks . size ( ) <= 1 ) { getConnectionDetail ( ) . unHappyDisconnect ( ) ; listCallbacks . remove ( criteria ) ; DefaultConnectionList connList = ( DefaultConnectionList ) DefaultConnectionList . getSingleton ( ) ; connList . remove ( this ) ; } else { listCallbacks . remove ( criteria ) ; } return listCallbacks . size ( ) ; } | Returns the count of callbacks still listening to this . This method will perform a hard disconnect if 0 is returned . |
15,464 | public Site overrideWith ( final Site other ) { return new Site ( other . id > 0L ? other . id : this . id , other . baseURL != null ? other . baseURL : this . baseURL , other . title != null ? other . title : this . title , other . description != null ? other . description : this . description , other . permalinkStructure != null ? other . permalinkStructure : this . permalinkStructure , other . defaultCategory != null ? other . defaultCategory : this . defaultCategory ) ; } | Overrides values in this site with those in another if set . |
15,465 | public String buildPermalink ( final Post post ) { final String authorSlug = post . author != null ? Strings . nullToEmpty ( post . author . slug ) : "" ; final List < TaxonomyTerm > categories = post . categories ( ) ; final Term categoryTerm = categories . size ( ) > 0 ? categories . get ( 0 ) . term : defaultCategory ; final String category = Strings . nullToEmpty ( categoryTerm . slug ) ; final String post_id = Long . toString ( post . id ) ; final DateTime publishTime = new DateTime ( post . publishTimestamp ) ; final String year = Integer . toString ( publishTime . getYear ( ) ) ; final String monthnum = String . format ( "%02d" , publishTime . getMonthOfYear ( ) ) ; final String day = String . format ( "%02d" , publishTime . getDayOfMonth ( ) ) ; final String hour = String . format ( "%02d" , publishTime . getHourOfDay ( ) ) ; final String minute = String . format ( "%02d" , publishTime . getMinuteOfHour ( ) ) ; final String second = String . format ( "%02d" , publishTime . getSecondOfMinute ( ) ) ; final String path = permalinkStructure . replace ( "%year%" , year ) . replace ( "%monthnum%" , monthnum ) . replace ( "%day%" , day ) . replace ( "%hour%" , hour ) . replace ( "%minute%" , minute ) . replace ( "%second%" , second ) . replace ( "%post_id%" , post_id ) . replace ( "%postname%" , Strings . nullToEmpty ( post . slug ) ) . replace ( "%category%" , category ) . replace ( "%author%" , authorSlug ) ; return baseURL + path ; } | Builds the permalink for a post from this site . |
15,466 | public void init ( Object obj ) { for ( int i = 0 ; i < MAX_ICONS ; i ++ ) { ImageIcon icon = this . getImageIcon ( i ) ; if ( icon == null ) break ; this . addIcon ( icon , i ) ; } } | Creates new JBlinkLabel . |
15,467 | public java . awt . Component getTableCellRendererComponent ( JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) { if ( m_table == null ) { m_table = table ; TableColumnModel columnModel = table . getColumnModel ( ) ; for ( int iColumn = 0 ; iColumn < columnModel . getColumnCount ( ) ; iColumn ++ ) { TableColumn tableColumn = columnModel . getColumn ( iColumn ) ; TableCellRenderer renderer = tableColumn . getCellRenderer ( ) ; if ( renderer == this ) m_iThisColumn = column ; } } m_iThisRow = row ; ImageIcon icon = this . getImageIcon ( value ) ; this . setIcon ( icon ) ; return this ; } | If this control is in a JTable this is how to render it . |
15,468 | public ImageIcon getImageIcon ( Object value ) { if ( value == null ) return m_rgIcons [ 0 ] ; String strType = value . toString ( ) ; int iType = 0 ; try { iType = Integer . parseInt ( strType ) ; } catch ( NumberFormatException ex ) { } if ( m_rgIcons == null ) return null ; int iIconCount = 0 ; for ( int i = 1 ; i < MAX_ICONS ; i ++ ) { if ( m_rgIcons [ i ] != null ) if ( ( ( 1 << i ) & iType ) != 0 ) iIconCount ++ ; } if ( iIconCount == 0 ) iIconCount = 1 ; int iRelIndex ; if ( ( iType & 1 ) == 0 ) { iRelIndex = m_iCurrentIcon % iIconCount ; } else { if ( ( m_iCurrentIcon & 1 ) == 0 ) iRelIndex = MAX_ICONS ; else { int iIconIndex = m_iCurrentIcon / 2 + 1 ; iRelIndex = iIconIndex % iIconCount ; } } int i ; for ( i = 1 ; i < MAX_ICONS ; i ++ ) { if ( m_rgIcons [ i ] != null ) if ( ( ( 1 << i ) & iType ) != 0 ) iRelIndex -- ; if ( iRelIndex < 0 ) break ; } if ( i >= MAX_ICONS ) i = 0 ; return m_rgIcons [ i ] ; } | Here is the value of this object display the correct image . |
15,469 | public void addIcon ( Object icon , int iIndex ) { if ( m_rgIcons == null ) { m_rgIcons = new ImageIcon [ MAX_ICONS ] ; m_timer = new javax . swing . Timer ( 500 , this ) ; m_timer . start ( ) ; } if ( iIndex < MAX_ICONS ) if ( icon instanceof ImageIcon ) m_rgIcons [ iIndex ] = ( ImageIcon ) icon ; } | Add this icon to the list of icons alternating for this label . |
15,470 | public void set ( Object value ) { try { Object v = ConvertUtility . convert ( type , value ) ; if ( field != null ) { field . set ( getBase ( ) , v ) ; } else { setter . invoke ( getBase ( ) , v ) ; } } catch ( IllegalAccessException | IllegalArgumentException | InvocationTargetException ex ) { throw new IllegalArgumentException ( ex ) ; } } | Set value using type conversions |
15,471 | public void renderItem ( final Comboitem item , final Document doc ) { item . setLabel ( doc . getTitle ( ) ) ; } | Render the combo item for the specified document . |
15,472 | public String readFile ( String filename ) { String path = m_fileSource . getParent ( ) ; String string = Utility . transferURLStream ( "file:" + path + '/' + filename , null , null , null ) ; if ( string != null ) { int start = string . indexOf ( "<repository" ) ; if ( start != - 1 ) start = string . indexOf ( ">" , start ) ; int end = string . lastIndexOf ( "</repository>" ) ; if ( ( start != - 1 ) && ( end != - 1 ) ) string = string . substring ( start + 1 , end ) ; } return string ; } | ReadFile Method . |
15,473 | public static boolean compareFilesByAbsolutePath ( final File sourceFile , final File fileToCompare ) { return CompareFileExtensions . compareFiles ( sourceFile , fileToCompare , false , true , true , true , true , true ) . getAbsolutePathEquality ( ) ; } | Compare files by absolute path . |
15,474 | public static boolean compareFilesByChecksumCRC32 ( final File sourceFile , final File fileToCompare ) throws IOException { final long checksumSourceFile = ChecksumExtensions . getCheckSumCRC32 ( sourceFile ) ; final long checksumFileToCompare = ChecksumExtensions . getCheckSumCRC32 ( fileToCompare ) ; return checksumSourceFile == checksumFileToCompare ; } | Compare files by checksum with the algorithm CRC32 . |
15,475 | public static boolean compareFilesByContent ( final File sourceFile , final File fileToCompare ) { return CompareFileExtensions . compareFiles ( sourceFile , fileToCompare , true , true , true , true , true , false ) . getContentEquality ( ) ; } | Compare files by content . |
15,476 | public static boolean compareFilesByExtension ( final File sourceFile , final File fileToCompare ) { return CompareFileExtensions . compareFiles ( sourceFile , fileToCompare , true , false , true , true , true , true ) . getFileExtensionEquality ( ) ; } | Compare files by extension . |
15,477 | public static boolean compareFilesByLastModified ( final File sourceFile , final File fileToCompare ) { return CompareFileExtensions . compareFiles ( sourceFile , fileToCompare , true , true , true , false , true , true ) . getLastModifiedEquality ( ) ; } | Compare files by last modified . |
15,478 | public static boolean compareFilesByLength ( final File sourceFile , final File fileToCompare ) { return CompareFileExtensions . compareFiles ( sourceFile , fileToCompare , true , true , false , true , true , true ) . getLengthEquality ( ) ; } | Compare files by length . |
15,479 | public static boolean compareFilesByName ( final File sourceFile , final File fileToCompare ) { return CompareFileExtensions . compareFiles ( sourceFile , fileToCompare , true , true , true , true , false , true ) . getNameEquality ( ) ; } | Compare files by name . |
15,480 | public < T extends Exception > T rethrow ( Class < T > exceptionType ) { return exceptionType . cast ( getCause ( ) ) ; } | Get the wrapped exception for re - throwing . |
15,481 | private MediaTracker getTracker ( ) { synchronized ( this ) { if ( tracker == null ) { @ SuppressWarnings ( "serial" ) Component comp = new Component ( ) { } ; tracker = new MediaTracker ( comp ) ; } } return ( MediaTracker ) tracker ; } | Returns the MediaTracker for the current AppContext creating a new MediaTracker if necessary . |
15,482 | public void run ( Reader in , Writer out ) throws RuleException { try { AddDoc addDoc = AddDoc . read ( in ) ; addDoc . getFields ( ) . add ( field ) ; addDoc . write ( out ) ; } catch ( JAXBException jaxbe ) { throw new RuleException ( jaxbe . getLinkedException ( ) ) ; } } | Adds a single field to a Solr document |
15,483 | public static FilesIterator < String > getRelativeNamesIterator ( File baseDir ) { return new FilesIterator < String > ( baseDir , Strategy . RELATIVE_NAMES ) ; } | Create relative file names iterator . |
15,484 | public static FilesIterator < File > getAbsoluteIterator ( String baseDir ) { return new FilesIterator < File > ( new File ( baseDir ) , Strategy . FILES ) ; } | Create absolute path files iterator . |
15,485 | public static FilesIterator < File > getRelativeIterator ( String baseDir ) { return new FilesIterator < File > ( new File ( baseDir ) , Strategy . RELATIVE_FILES ) ; } | Create relative path files iterator . |
15,486 | public static FilesIterator < String > getAbsoluteNamesIterator ( String baseDir ) { return new FilesIterator < String > ( new File ( baseDir ) , Strategy . NAMES ) ; } | Create absolute file names iterator . |
15,487 | private boolean isLoopExitCondition ( ) { while ( workingDirectory . index == workingDirectory . files . length ) { if ( stack . isEmpty ( ) ) { return true ; } pop ( ) ; } return false ; } | Test for iteration loop exit condition . Iteration loop is ended if current working directory index reaches its files count and there is no more directories on stack . |
15,488 | public void init ( Record record , RecordOwner recordOwner , Record recordToSync , boolean bUpdateOnSelect , int iEventToTrigger ) { super . init ( record ) ; m_recordOwner = recordOwner ; m_recordToSync = recordToSync ; m_bUpdateOnSelect = bUpdateOnSelect ; m_iEventToTrigger = iEventToTrigger ; } | OnSelectHandler - Constructor . |
15,489 | public void setOwner ( ListenerOwner owner ) { super . setOwner ( owner ) ; if ( owner != null ) if ( m_recordToSync != null ) { if ( ! m_recordToSync . getBaseRecord ( ) . getTableNames ( false ) . equals ( this . getOwner ( ) . getBaseRecord ( ) . getTableNames ( false ) ) ) { m_recordToSync = null ; return ; } m_recordToSync . addListener ( new FileRemoveBOnCloseHandler ( this ) ) ; } } | Set the field or file that owns this listener . I Check to make sure that the base tables are the same first . |
15,490 | public RecordMessage createMessage ( Object bookmark ) { int iRecordMessageType = DBConstants . SELECT_TYPE ; RecordMessageHeader messageHeader = new RecordMessageHeader ( this . getOwner ( ) , bookmark , null , iRecordMessageType , null ) ; RecordMessage message = new RecordMessage ( messageHeader ) ; message . put ( RecordMessageHeader . UPDATE_ON_SELECT , new Boolean ( m_bUpdateOnSelect ) ) ; if ( this . getRecordToSync ( ) != null ) message . put ( RecordMessageHeader . RECORD_TO_UPDATE , this . getRecordToSync ( ) ) ; return message ; } | Create the record message . Override this to add information to the message . |
15,491 | public boolean shutdownService ( Object service , BundleContext context ) { if ( service instanceof BaseServiceMessageTransport ) ( ( BaseServiceMessageTransport ) service ) . free ( ) ; return super . shutdownService ( service , context ) ; } | Stop this service . Override this to do all the startup . |
15,492 | public void fork ( K to , M msg ) { if ( maxParallelism == 0 ) { throw new IllegalArgumentException ( "maxParallelism == 0, fork() not allowed! Use switchTo." ) ; } try { stopSemaphore . acquire ( ) ; parallelSet . add ( getCurrentKey ( ) ) ; doFork ( to , msg ) ; } catch ( InterruptedException ex ) { throw new IllegalArgumentException ( ex ) ; } } | Fork executing thread . |
15,493 | public M join ( ) { if ( threadMap . isEmpty ( ) ) { throw new IllegalStateException ( "threads are already interrupted" ) ; } Thread currentThread = Thread . currentThread ( ) ; Semaphore currentSemaphore = semaphoreMap . get ( currentThread ) ; if ( currentSemaphore == null ) { throw new IllegalStateException ( "Current thread is not workflow thread" ) ; } stopSemaphore . release ( ) ; parallelSet . remove ( getCurrentKey ( ) ) ; return doJoin ( ) ; } | Thread waits until another thread calls fork switchTo or endTo method using threads key . Returns message from another thread . |
15,494 | public M switchTo ( K to , M msg ) { doFork ( to , msg ) ; return doJoin ( ) ; } | Switch executing thread . |
15,495 | public void endTo ( K to , M msg ) { K key = getCurrentKey ( ) ; if ( key . equals ( to ) ) { throw new IllegalArgumentException ( "current and to are equals" ) ; } if ( key != null ) { kill ( key ) ; doFork ( to , msg ) ; throw new ThreadStoppedException ( "suicide" ) ; } else { throw new IllegalArgumentException ( "called from wrong thread" ) ; } } | Ends the current thread and switches to |
15,496 | public K getCurrentKey ( ) { lock . lock ( ) ; try { Thread currentThread = Thread . currentThread ( ) ; for ( Entry < K , Thread > entry : threadMap . entrySet ( ) ) { if ( currentThread . equals ( entry . getValue ( ) ) ) { return entry . getKey ( ) ; } } return null ; } finally { lock . unlock ( ) ; } } | Returns key for current thread . Returns null if current thread is not part of the workflow . |
15,497 | public void waitAndStopThreads ( ) { try { if ( threadMap . isEmpty ( ) ) { throw new IllegalStateException ( "threads are already interrupted" ) ; } stopSemaphore . acquire ( maxParallelism ) ; stopThreads ( ) ; } catch ( InterruptedException ex ) { throw new IllegalArgumentException ( ex ) ; } } | Wait until parallel excecuting threads have joined . After that interrupt all other than the calling thread . |
15,498 | public void stopThreads ( ) { if ( threadMap . isEmpty ( ) ) { throw new IllegalStateException ( "threads are already interrupted" ) ; } lock . lock ( ) ; try { Thread currentThread = Thread . currentThread ( ) ; for ( Thread thread : threadMap . values ( ) ) { if ( ! currentThread . equals ( thread ) ) { thread . interrupt ( ) ; } } threadMap . clear ( ) ; semaphoreMap . clear ( ) ; } finally { lock . unlock ( ) ; } } | Interrupt all other than the calling thread . |
15,499 | public < R > R accessContext ( ContextAccess < C , R > access ) { contextLock . lock ( ) ; try { return access . access ( context ) ; } finally { contextLock . unlock ( ) ; } } | Provides thread save access to the context object . ContextAccess . access method is called inside a lock to prevent concurrent modification to the object . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.