idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
14,100
public static final long move ( ByteBuffer b1 , ByteBuffer b2 ) { int remaining1 = b1 . remaining ( ) ; int remaining2 = b2 . remaining ( ) ; if ( remaining1 <= remaining2 ) { b2 . put ( b1 ) ; return remaining1 ; } else { int safeLimit = b1 . limit ( ) ; b1 . limit ( b1 . position ( ) + remaining2 ) ; b2 . put ( b1 ) ; b1 . limit ( safeLimit ) ; return remaining2 ; } }
Moves bytes from b1 to b2 as much as is possible . Positions are moved according to move .
14,101
public static final long move ( ByteBuffer bb , ByteBuffer [ ] bbArray , int offset , int length ) { return move ( new ByteBuffer [ ] { bb } , 0 , 1 , bbArray , offset , length ) ; }
Moves bytes from bb to bbArray as much as is possible . Positions are moved according to move . Returns number of bytes moved .
14,102
public static final long move ( ByteBuffer [ ] bbArray1 , ByteBuffer [ ] bbArray2 ) { return move ( bbArray1 , 0 , bbArray2 . length , bbArray2 , 0 , bbArray2 . length ) ; }
Moves bytes from bbArray1 to bbArray2 as much as is possible . Positions are moved according to move . Returns number of bytes moved .
14,103
public static final long move ( ByteBuffer [ ] bbArray1 , int offset1 , int length1 , ByteBuffer [ ] bbArray2 , int offset2 , int length2 ) { if ( length1 == 0 || length2 == 0 ) { return 0 ; } long res = 0 ; ArrayIterator < ByteBuffer > i1 = new ArrayIterator < > ( bbArray1 , offset1 , length1 ) ; ArrayIterator < ByteBuffer > i2 = new ArrayIterator < > ( bbArray2 , offset2 , length2 ) ; ByteBuffer b1 = i1 . next ( ) ; ByteBuffer b2 = i2 . next ( ) ; while ( true ) { res += move ( b1 , b2 ) ; if ( ! b1 . hasRemaining ( ) ) { if ( i1 . hasNext ( ) ) { b1 = i1 . next ( ) ; } else { return res ; } } if ( ! b2 . hasRemaining ( ) ) { if ( i2 . hasNext ( ) ) { b2 = i2 . next ( ) ; } else { return res ; } } } }
Moves bytes from ba1 to ba2 as much as is possible . Positions are moved according to move . Returns number of bytes moved .
14,104
public int [ ] calculateInYearsMonthsDaysHoursMinutesAndSeconds ( final long compute ) { long uebrig = - 1 ; final int [ ] result = new int [ 6 ] ; final int years = ( int ) this . calculateInYears ( compute ) ; if ( 0 < years ) { result [ 0 ] = years ; uebrig = compute - years * ONE_YEAR ; } else { result [ 0 ] = 0 ; } final int months = ( int ) this . calculateInDefaultMonth ( uebrig ) ; if ( 0 < months ) { result [ 1 ] = months ; uebrig -= months * ONE_DEFAULT_MONTH ; } else { result [ 1 ] = 0 ; } final int days = ( int ) this . calculateInDays ( uebrig ) ; if ( 0 < days ) { result [ 2 ] = days ; uebrig -= days * ONE_DAY ; } else { result [ 2 ] = 0 ; } final int hours = ( int ) this . calculateInHours ( uebrig ) ; if ( 0 < hours ) { result [ 3 ] = hours ; uebrig -= hours * ONE_HOUR ; } else { result [ 3 ] = 0 ; } final int minutes = ( int ) this . calculateInMinutes ( uebrig ) ; if ( 0 < minutes ) { result [ 4 ] = minutes ; uebrig -= minutes * ONE_MINUTE ; } else { result [ 4 ] = 0 ; } final int seconds = ( int ) this . calculateInSeconds ( uebrig ) ; if ( 0 < seconds ) { result [ 5 ] = seconds ; } else { result [ 5 ] = 0 ; } return result ; }
Calculate in years months days hours minutes and seconds .
14,105
public String getHumanReadableAge ( final int [ ] readableAge ) { if ( null == readableAge || readableAge . length != 6 ) { throw new IllegalArgumentException ( "Int array should not be null and the length should be equal 6." ) ; } final StringBuilder result = new StringBuilder ( ) ; result . append ( "Your are " ) ; result . append ( readableAge [ 0 ] ) . append ( " years" ) ; result . append ( " " ) ; result . append ( readableAge [ 1 ] ) . append ( " months" ) ; result . append ( " " ) ; result . append ( readableAge [ 2 ] ) . append ( " days" ) ; result . append ( " " ) ; result . append ( readableAge [ 3 ] ) . append ( " hours" ) ; result . append ( " " ) ; result . append ( readableAge [ 4 ] ) . append ( " minutes" ) ; result . append ( " " ) ; result . append ( readableAge [ 5 ] ) . append ( " seconds" ) ; result . append ( " young!" ) ; return result . toString ( ) ; }
Gets a human readable string from the age .
14,106
public List < Tag > getAllTags ( ) { List < Tag > ret = new Vector < Tag > ( taggers . size ( ) ) ; for ( Tagger tagger : taggers ) ret . add ( tagger . getTag ( ) ) ; return ret ; }
Obtains the list of all tags used by the taggers
14,107
public void floodFill ( int xx , int yy , int replacement ) { floodFill ( xx , yy , ( c ) -> c != replacement , replacement ) ; }
Fills area starting at xx yy . Area must be surrounded with replacement color .
14,108
public void floodFill ( int xx , int yy , IntPredicate target , int replacement ) { floodFill ( xx , yy , 0 , 0 , width , height , target , replacement ) ; }
Fills area starting at xx yy . Pixels fullfilling target are replaced with replacement color .
14,109
public void init ( RecordOwnerParent parent , Rec record , Map < String , Object > properties ) { ScreenLocation itsLocation = null ; Converter fieldConverter = null ; int iDisplayFieldDesc = ScreenConstants . DEFAULT_DISPLAY ; if ( properties != null ) { if ( properties . get ( ScreenModel . LOCATION ) instanceof ScreenLocation ) itsLocation = ( ScreenLocation ) properties . get ( ScreenModel . LOCATION ) ; else { try { if ( properties . get ( ScreenModel . LOCATION ) instanceof Short ) itsLocation = new ScreenLocation ( ( ( Short ) properties . get ( ScreenModel . DISPLAY ) ) . shortValue ( ) , ScreenConstants . ANCHOR_DEFAULT ) ; else if ( properties . get ( ScreenModel . LOCATION ) instanceof Integer ) itsLocation = new ScreenLocation ( ( ( Integer ) properties . get ( ScreenModel . DISPLAY ) ) . shortValue ( ) , ScreenConstants . ANCHOR_DEFAULT ) ; else if ( properties . get ( ScreenModel . LOCATION ) != null ) itsLocation = new ScreenLocation ( Short . parseShort ( properties . get ( ScreenModel . LOCATION ) . toString ( ) ) , ScreenConstants . ANCHOR_DEFAULT ) ; } catch ( Exception ex ) { } } if ( properties . get ( ScreenModel . DISPLAY ) instanceof Short ) iDisplayFieldDesc = ( ( Short ) properties . get ( ScreenModel . DISPLAY ) ) . intValue ( ) ; if ( properties . get ( ScreenModel . DISPLAY ) instanceof Integer ) iDisplayFieldDesc = ( ( Integer ) properties . get ( ScreenModel . DISPLAY ) ) . intValue ( ) ; else { try { if ( properties . get ( ScreenModel . DISPLAY ) != null ) iDisplayFieldDesc = Integer . parseInt ( properties . get ( ScreenModel . DISPLAY ) . toString ( ) ) ; } catch ( Exception ex ) { } } } properties . remove ( ScreenModel . DISPLAY ) ; properties . remove ( ScreenModel . LOCATION ) ; this . init ( ( Record ) record , itsLocation , ( BasePanel ) parent , fieldConverter , iDisplayFieldDesc , properties ) ; }
This is the new constructor list . This initializer is required by the RecordOwner interface .
14,110
public void addListeners ( ) { super . addListeners ( ) ; if ( this . getMainRecord ( ) != null ) this . getMainRecord ( ) . addScreenListeners ( this ) ; if ( this . getMainRecord ( ) != null ) if ( DBConstants . TRUE . equalsIgnoreCase ( this . getMainRecord ( ) . getTable ( ) . getDatabase ( ) . getProperty ( DBConstants . READ_ONLY_DB ) ) ) this . setEditing ( false ) ; }
Override this to add behaviors .
14,111
public boolean onLogon ( ) { Record record = Record . makeRecordFromClassName ( UserInfoModel . THICK_CLASS , this ) ; this . removeRecord ( record ) ; BasePanel parentScreen = this . getParentScreen ( ) ; ScreenLocation itsLocation = this . getScreenLocation ( ) ; parentScreen . popHistory ( 1 , false ) ; parentScreen . pushHistory ( this . getScreenURL ( ) , false ) ; this . finalizeThisScreen ( ) ; Map < String , Object > properties = null ; this . free ( ) ; int docMode = record . commandToDocType ( UserInfoModel . LOGIN_SCREEN ) ; record . makeScreen ( itsLocation , parentScreen , docMode , properties ) ; return true ; }
Display the Logon screen .
14,112
public static ScreenParent makeScreenFromParams ( Task task , ScreenLoc itsLocation , ComponentParent screenParent , int iDocType , Map < String , Object > properties ) { iDocType = iDocType & ~ ( ScreenConstants . DISPLAY_MASK | ScreenConstants . SCREEN_TYPE_MASK ) ; ScreenParent screen = null ; String strScreen = task . getProperty ( DBParams . SCREEN ) ; if ( ( strScreen != null ) && ( strScreen . length ( ) > 0 ) ) screen = Record . makeNewScreen ( strScreen , itsLocation , screenParent , iDocType | ScreenConstants . DEFAULT_DISPLAY , properties , null , true ) ; if ( screen == null ) { String strRecord = task . getProperty ( DBParams . RECORD ) ; if ( strRecord != null ) { String strScreenType = task . getProperty ( DBParams . COMMAND ) ; iDocType = iDocType | ScreenConstants . DISPLAY_MODE | ScreenConstants . DEFAULT_DISPLAY ; if ( ( strScreenType != null ) && ( strScreenType . length ( ) > 0 ) ) screen = BaseScreen . makeScreenFromRecord ( itsLocation , screenParent , strRecord , strScreenType , properties ) ; else screen = BaseScreen . makeScreenFromRecord ( itsLocation , screenParent , strRecord , iDocType , properties ) ; } } if ( screen == null ) { String strRecord = task . getProperty ( ThinMenuConstants . FORM . toLowerCase ( ) ) ; if ( strRecord != null ) screen = BaseScreen . makeScreenFromRecord ( itsLocation , screenParent , strRecord , iDocType | ScreenConstants . MAINT_MODE | ScreenConstants . DEFAULT_DISPLAY , properties ) ; } if ( screen == null ) { String strMenu = task . getProperty ( DBParams . MENU ) ; if ( strMenu != null ) { screen = new MenuScreen ( null , null , ( BasePanel ) screenParent , null , iDocType | ScreenConstants . MAINT_MODE , properties ) ; } } if ( screen == null ) { screen = new MenuScreen ( null , null , ( BasePanel ) screenParent , null , iDocType | ScreenConstants . MAINT_MODE , properties ) ; } return screen ; }
Make a screen window from the current params .
14,113
public String title ( ) { if ( getPlaceId ( ) != null ) { return getFormattedAddress ( ) ; } else { final TitleBuffer buf = new TitleBuffer ( ) ; buf . append ( getAddressLine1 ( ) ) . append ( "," , getAddressLine2 ( ) ) . append ( "," , getAddressLine3 ( ) ) . append ( "," , getAddressLine4 ( ) ) . append ( "," , getPostalCode ( ) ) . append ( "," , getCountry ( ) ) ; return StringUtils . abbreviateMiddle ( buf . toString ( ) , "..." , 30 ) ; } }
region > title
14,114
public Location getLocation ( ) { final String latLng = getLatLng ( ) ; return latLng != null ? Location . fromString ( latLng . replace ( "," , ";" ) ) : null ; }
region > Locatable API
14,115
void lifecycleAvailable ( Lifecycle lifecycle ) { LOG . debug ( "Lifecycle now available, draining queue" ) ; lifecycle . addListener ( LifecycleStage . CONFIGURE_STAGE , new LifecycleListener ( ) { public void onStage ( LifecycleStage lifecycleStage ) { LOG . debug ( "Lifecycle started, further injections disallowed" ) ; LifecycleAnnotationFinder . this . lifecycle = null ; } } ) ; this . lifecycle = lifecycle ; for ( LifecycleInvocation invocation : foundInvocations ) { addListener ( invocation ) ; } foundInvocations = null ; }
Called once Guice has created our Lifecycle so we can start registering callbacks
14,116
public int compareVersions ( VersionedOntology o ) throws OntopException { if ( ! base . equals ( o . base ) || ! ontologyPath . equals ( o . ontologyPath ) ) { throw new OntopException ( "Version comparison must be done with same ontology series." ) ; } if ( major > o . major ) { return 1 ; } else if ( major == o . major ) { if ( minor > o . minor ) { return 1 ; } else if ( minor == o . minor ) { return 0 ; } } return - 1 ; }
returns - 1 if this is lower than o returns 0 if this is equal to o returns 1 if this is greater than o
14,117
public boolean readCurrentUser ( ) { String strUserName = this . getProperty ( DBParams . USER_NAME ) ; String strUserID = this . getProperty ( DBParams . USER_ID ) ; boolean bUserFound = false ; if ( ( this . getMainRecord ( ) . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( this . getMainRecord ( ) . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) { bUserFound = true ; } else { if ( ( strUserID != null ) && ( strUserID . length ( ) > 0 ) ) { bUserFound = ( ( UserInfo ) this . getMainRecord ( ) ) . getUserInfo ( strUserID , false ) ; if ( bUserFound ) if ( this . getMainRecord ( ) . getField ( UserInfo . READ_ONLY_RECORD ) . getState ( ) == true ) bUserFound = false ; } if ( ! bUserFound ) if ( ( strUserName != null ) && ( strUserName . length ( ) > 0 ) ) { bUserFound = ( ( UserInfo ) this . getMainRecord ( ) ) . getUserInfo ( strUserName , false ) ; if ( bUserFound ) if ( this . getMainRecord ( ) . getField ( UserInfo . READ_ONLY_RECORD ) . getState ( ) == true ) bUserFound = false ; } } if ( ! bUserFound ) { try { this . getMainRecord ( ) . addNew ( ) ; } catch ( DBException e ) { e . printStackTrace ( ) ; } this . getMainRecord ( ) . getField ( UserInfo . USER_NAME ) . setString ( strUserName ) ; this . getMainRecord ( ) . getField ( UserInfo . USER_NAME ) . setModified ( false ) ; } else { } return bUserFound ; }
ReadCurrentUser Method .
14,118
public void addAutoLoginHandler ( ) { this . getMainRecord ( ) . addListener ( new FileListener ( null ) { public int doRecordChange ( FieldInfo field , int iChangeType , boolean bDisplayOption ) { int iErrorCode = super . doRecordChange ( field , iChangeType , bDisplayOption ) ; if ( ( iChangeType == DBConstants . AFTER_ADD_TYPE ) || ( iChangeType == DBConstants . AFTER_UPDATE_TYPE ) ) if ( iErrorCode == DBConstants . NORMAL_RETURN ) { Record recUserInfo = this . getOwner ( ) ; Task task = recUserInfo . getTask ( ) ; String strUserName = recUserInfo . getField ( UserInfo . ID ) . toString ( ) ; if ( ( strUserName == null ) || ( strUserName . length ( ) == 0 ) ) strUserName = recUserInfo . getLastModified ( DBConstants . BOOKMARK_HANDLE ) . toString ( ) ; String strPassword = recUserInfo . getField ( UserInfo . PASSWORD ) . toString ( ) ; iErrorCode = task . getApplication ( ) . login ( task , strUserName , strPassword , task . getProperty ( DBParams . DOMAIN ) ) ; } return iErrorCode ; } } ) ; }
AddAutoLoginHandler Method .
14,119
public static boolean addStaticExtension ( String extension ) { if ( AssertUtils . isEmpty ( extension ) ) { return false ; } if ( ! extension . startsWith ( "." ) ) { extension = "." + extension ; } extension = extension . toLowerCase ( ) ; return STATIC_RESOURCE_EXTENSIONS . add ( extension ) ; }
Add the given extension to the list of static resources .
14,120
private boolean isStaticResource ( String uri ) { int index = uri . lastIndexOf ( '.' ) ; if ( index == - 1 ) { return false ; } String currentExtension = uri . substring ( index ) ; return STATIC_RESOURCE_EXTENSIONS . contains ( currentExtension ) ; }
Method that given a URL checks if the resources is static or not - depending on the request extension like . css . js . png etc .
14,121
public static TimecodeDuration valueOf ( String timecode ) throws IllegalArgumentException { TimecodeDuration td = new TimecodeDuration ( ) ; return ( TimecodeDuration ) td . parse ( timecode ) ; }
Returns a TimecodeDuration instance for given TimecodeDuration storage string . Will return null in case the storage string represents a null TimecodeDuration
14,122
public SceneManager setWindowForTerminating ( Window window ) { this . window = window ; window . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent e ) { terminate ( ) ; } public void windowClosed ( WindowEvent e ) { terminate ( ) ; } } ) ; return this ; }
Sets the specified window . The window will be disposed when terminating this manager . This manager will also be terminated when closing the window .
14,123
public void init ( String text ) { this . setOpaque ( true ) ; this . setHorizontalTextPosition ( JToggleButton . LEFT ) ; this . setAlignmentX ( JComponent . CENTER_ALIGNMENT ) ; }
Creates new JCellButton
14,124
public Component getTableCellRendererComponent ( JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) { this . setControlValue ( value ) ; if ( isSelected && ! hasFocus ) { this . setForeground ( table . getSelectionForeground ( ) ) ; this . setBackground ( table . getSelectionBackground ( ) ) ; } else { this . setForeground ( table . getForeground ( ) ) ; this . setBackground ( table . getBackground ( ) ) ; } return this ; }
Get the renderer for this location in the table . From the TableCellRenderer interface . Sets the value of this control and returns this .
14,125
public Component getTableCellEditorComponent ( JTable table , Object value , boolean isSelected , int row , int column ) { this . setControlValue ( value ) ; return this ; }
Get the editor for this location in the table . From the TableCellEditor interface . Sets the value of this control and returns this .
14,126
public Object getCellEditorValue ( ) { boolean bValue = this . isSelected ( ) ; if ( bValue ) return Boolean . TRUE . toString ( ) ; else return Boolean . FALSE . toString ( ) ; }
Get the value . From the TableCellEditor interface .
14,127
public void setControlValue ( Object value ) { Boolean boolValue = null ; if ( value instanceof String ) if ( ( ( String ) value ) . length ( ) > 0 ) boolValue = new Boolean ( ( String ) value ) ; if ( boolValue == null ) boolValue = Boolean . FALSE ; this . setSelected ( boolValue . booleanValue ( ) ) ; }
Set the value of this checkbox .
14,128
public Record openMainRecord ( ) { Record record = Record . makeRecordFromClassName ( MenusModel . THICK_CLASS , this ) ; record . setOpenMode ( DBConstants . OPEN_READ_ONLY ) ; return record ; }
OpenMainFile Method .
14,129
private String fixDatabaseName ( String databaseName , Record record , Map < String , String > oldProperties ) { if ( databaseName . endsWith ( BaseDatabase . SHARED_SUFFIX ) ) databaseName = databaseName . substring ( 0 , databaseName . length ( ) - BaseDatabase . SHARED_SUFFIX . length ( ) ) ; else if ( databaseName . endsWith ( BaseDatabase . USER_SUFFIX ) ) databaseName = databaseName . substring ( 0 , databaseName . length ( ) - BaseDatabase . USER_SUFFIX . length ( ) ) ; String recordDBName = record . getDatabaseName ( ) ; if ( record instanceof DatabaseInfo ) recordDBName = DatabaseInfo . DATABASE_INFO_FILE ; if ( ! databaseName . startsWith ( recordDBName ) ) { this . getTask ( ) . setProperty ( DBConstants . DB_USER_PREFIX , databaseName . substring ( 0 , databaseName . indexOf ( '_' ) ) ) ; databaseName = databaseName . substring ( databaseName . indexOf ( '_' ) + 1 ) ; } if ( ! databaseName . endsWith ( recordDBName ) ) { String suffix = databaseName . substring ( databaseName . lastIndexOf ( '_' ) + 1 ) ; if ( suffix . length ( ) == 2 ) { this . getTask ( ) . setProperty ( DBParams . LANGUAGE , suffix ) ; databaseName = databaseName . substring ( 0 , databaseName . lastIndexOf ( '_' ) ) ; suffix = databaseName . substring ( databaseName . lastIndexOf ( '_' ) + 1 ) ; } if ( ! databaseName . endsWith ( recordDBName ) ) { databaseName = databaseName . substring ( 0 , databaseName . lastIndexOf ( '_' ) ) ; if ( ( record . getDatabaseType ( ) & DBConstants . USER_DATA ) != 0 ) this . getTask ( ) . setProperty ( record . getDatabaseName ( ) + BaseDatabase . DBUSER_PARAM_SUFFIX , suffix ) ; else this . getTask ( ) . setProperty ( record . getDatabaseName ( ) + BaseDatabase . DBSHARED_PARAM_SUFFIX , suffix ) ; suffix = databaseName . substring ( databaseName . lastIndexOf ( '_' ) + 1 ) ; } if ( ! databaseName . endsWith ( recordDBName ) ) { this . getTask ( ) . setProperty ( DBConstants . SYSTEM_NAME , suffix ) ; databaseName = databaseName . substring ( 0 , databaseName . lastIndexOf ( '_' ) ) ; } } return databaseName ; }
Clean up the database name ;
14,130
private String getDatabaseInfoDatabaseName ( String className ) { String databaseName = className . substring ( 0 , className . length ( ) - 1 - DatabaseInfo . DATABASE_INFO_FILE . length ( ) ) ; databaseName = databaseName . substring ( databaseName . lastIndexOf ( '.' ) + 1 ) ; if ( databaseName . endsWith ( BaseDatabase . SHARED_SUFFIX ) ) databaseName = databaseName . substring ( 0 , databaseName . length ( ) - BaseDatabase . SHARED_SUFFIX . length ( ) ) ; if ( databaseName . endsWith ( BaseDatabase . USER_SUFFIX ) ) databaseName = databaseName . substring ( 0 , databaseName . length ( ) - BaseDatabase . USER_SUFFIX . length ( ) ) ; return databaseName ; }
GetDatabaseInfoDatabaseName Method .
14,131
public void saveOldProperties ( Map < String , String > oldProperties , Record record ) { this . saveOldProperty ( oldProperties , record . getDatabaseName ( ) + BaseDatabase . DBSHARED_PARAM_SUFFIX ) ; this . saveOldProperty ( oldProperties , record . getDatabaseName ( ) + BaseDatabase . DBUSER_PARAM_SUFFIX ) ; this . saveOldProperty ( oldProperties , DBConstants . DB_USER_PREFIX ) ; this . saveOldProperty ( oldProperties , DBConstants . SYSTEM_NAME ) ; this . saveOldProperty ( oldProperties , DBParams . LANGUAGE ) ; }
SaveOldProperties Method .
14,132
public void saveOldProperty ( Map < String , String > oldProperties , String param ) { oldProperties . put ( param , this . getTask ( ) . getProperty ( param ) ) ; }
SaveOldProperty Method .
14,133
public void restoreOldProperties ( Map < String , String > oldProperties , Record record ) { this . restoreOldProperty ( oldProperties , record . getDatabaseName ( ) + BaseDatabase . DBSHARED_PARAM_SUFFIX ) ; this . restoreOldProperty ( oldProperties , record . getDatabaseName ( ) + BaseDatabase . DBUSER_PARAM_SUFFIX ) ; this . restoreOldProperty ( oldProperties , DBConstants . DB_USER_PREFIX ) ; this . restoreOldProperty ( oldProperties , DBConstants . SYSTEM_NAME ) ; this . restoreOldProperty ( oldProperties , DBParams . LANGUAGE ) ; }
RestoreOldProperties Method .
14,134
private void restoreOldProperty ( Map < String , String > oldProperties , String param ) { this . getTask ( ) . setProperty ( param , oldProperties . get ( param ) ) ; }
RestoreOldProperty Method .
14,135
public int getUserID ( ) { int iUserID = - 1 ; String strUserID = DBConstants . BLANK ; if ( this . getRecord ( ) . getRecordOwner ( ) != null ) if ( this . getRecord ( ) . getRecordOwner ( ) . getTask ( ) != null ) if ( this . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) != null ) strUserID = ( ( BaseApplication ) this . getRecord ( ) . getRecordOwner ( ) . getTask ( ) . getApplication ( ) ) . getUserID ( ) ; try { iUserID = Integer . parseInt ( strUserID ) ; if ( iUserID == 0 ) iUserID = - 1 ; } catch ( NumberFormatException e ) { iUserID = - 1 ; } return iUserID ; }
Get the current User s ID .
14,136
public final Object [ ] [ ] cloneMatrix ( Object [ ] [ ] tempString ) { Object [ ] [ ] mxString = null ; if ( tempString != null ) { mxString = new Object [ tempString . length ] [ 2 ] ; for ( int i = 0 ; i < tempString . length ; i ++ ) { mxString [ i ] [ MessageConstants . NAME ] = tempString [ i ] [ MessageConstants . NAME ] ; mxString [ i ] [ MessageConstants . VALUE ] = tempString [ i ] [ MessageConstants . VALUE ] ; } } return mxString ; }
Create a copy of this matrix .
14,137
public void propertyChange ( final java . beans . PropertyChangeEvent p1 ) { this . firePropertyChange ( p1 . getPropertyName ( ) , p1 . getOldValue ( ) , p1 . getNewValue ( ) ) ; }
Pass the property changes on to my listeners .
14,138
public void scanTreeForExcludes ( StringBuffer sb , String strParentFolderID ) { m_recPackagesExclude . setKeyArea ( Packages . PARENT_FOLDER_ID_KEY ) ; StringSubFileFilter listener = null ; m_recPackagesExclude . addListener ( listener = new StringSubFileFilter ( strParentFolderID , Packages . PARENT_FOLDER_ID , null , null , null , null ) ) ; try { java . util . List < String > list = new ArrayList < String > ( ) ; m_recPackagesExclude . close ( ) ; while ( m_recPackagesExclude . hasNext ( ) ) { m_recPackagesExclude . next ( ) ; if ( m_recPackagesExclude . getField ( Packages . EXCLUDE ) . getState ( ) == true ) sb . append ( "<exclude>" + this . getTree ( m_recPackagesExclude ) + "</exclude>\n" ) ; list . add ( m_recPackagesExclude . getField ( Packages . ID ) . toString ( ) ) ; } m_recPackagesExclude . removeListener ( listener , true ) ; listener = null ; for ( String strFolderID : list ) { this . scanTreeForExcludes ( sb , strFolderID ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; if ( listener != null ) m_recPackagesExclude . removeListener ( listener , true ) ; } }
ScanTreeForExcludes Method .
14,139
public String getTree ( Record recPackages ) { try { if ( m_recPackagesTree == null ) { RecordOwner recordOwner = this . getOwner ( ) . findRecordOwner ( ) ; m_recPackagesTree = new Packages ( recordOwner ) ; if ( recordOwner != null ) recordOwner . removeRecord ( m_recPackagesTree ) ; } String strPackagesTree = recPackages . getField ( Packages . NAME ) . toString ( ) ; m_recPackagesTree . addNew ( ) ; m_recPackagesTree . getField ( Packages . ID ) . moveFieldToThis ( recPackages . getField ( Packages . PARENT_FOLDER_ID ) ) ; while ( ( m_recPackagesTree . getField ( Packages . ID ) . getValue ( ) > 0 ) && ( m_recPackagesTree . seek ( null ) ) ) { strPackagesTree = m_recPackagesTree . getField ( Packages . NAME ) . toString ( ) + '.' + strPackagesTree ; m_recPackagesTree . getField ( Packages . ID ) . moveFieldToThis ( m_recPackagesTree . getField ( Packages . PARENT_FOLDER_ID ) ) ; } return strPackagesTree ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; return null ; } }
GetTree Method .
14,140
public void addElement ( int iTargetPosition , Object bookmark , GridList gridList ) { int iArrayIndex = this . bufferToArrayIndex ( iTargetPosition ) ; if ( ! this . inBufferArray ( iTargetPosition ) ) iArrayIndex = this . newBufferStartsAt ( iTargetPosition , gridList ) ; m_aCurrentRecord [ iArrayIndex ] = bookmark ; if ( ! this . inBufferList ( iTargetPosition ) ) m_iCurrentRecordEnd = iTargetPosition + 1 ; }
Add this record s unique info to current buffer .
14,141
public int findElement ( Object bookmark , int iHandleType ) { int iTargetPosition ; Object thisBookmark = null ; if ( bookmark == null ) return - 1 ; boolean bDataRecordFormat = false ; for ( iTargetPosition = m_iCurrentRecordStart ; iTargetPosition < m_iCurrentRecordEnd ; iTargetPosition ++ ) { thisBookmark = this . elementAt ( iTargetPosition ) ; if ( iTargetPosition == m_iCurrentRecordStart ) if ( thisBookmark instanceof DataRecord ) bDataRecordFormat = true ; if ( bookmark . equals ( thisBookmark ) ) return iTargetPosition ; else if ( bDataRecordFormat ) if ( bookmark . equals ( ( ( DataRecord ) thisBookmark ) . getHandle ( iHandleType ) ) ) return iTargetPosition ; } return - 1 ; }
This method does a sequential seqrch through the buffer looking for the bookmark .
14,142
public boolean inBufferList ( int iTargetPosition ) { boolean bInBufferList = ( ( iTargetPosition >= m_iCurrentRecordStart ) && ( iTargetPosition < m_iCurrentRecordEnd ) ) ; if ( bInBufferList ) if ( m_aCurrentRecord [ this . bufferToArrayIndex ( iTargetPosition ) ] == gEmptyCell ) bInBufferList = false ; return bInBufferList ; }
Is this actual file position in the current cache?
14,143
public void moveBufferToAccessList ( GridList gridList ) { for ( int index = m_iCurrentRecordStart ; index < m_iCurrentRecordEnd ; index ++ ) { int iArrayIndex = this . bufferToArrayIndex ( index ) ; Object bookmark = m_aCurrentRecord [ iArrayIndex ] ; if ( bookmark != gEmptyCell ) gridList . addElement ( index , bookmark ) ; } }
Move these to the access list before getting rid of them .
14,144
public int newBufferStartsAt ( int iTargetPosition , GridList gridList ) { if ( gridList != null ) this . moveBufferToAccessList ( gridList ) ; for ( int index = m_iCurrentRecordStart ; index < m_iCurrentRecordEnd ; index ++ ) { int iArrayIndex = this . bufferToArrayIndex ( index ) ; Object bookmark = m_aCurrentRecord [ iArrayIndex ] ; m_aCurrentRecord [ iArrayIndex ] = gEmptyCell ; if ( ! gridList . inRecordList ( index ) ) if ( ( bookmark != null ) && ( bookmark != gEmptyCell ) ) this . freeElement ( bookmark ) ; } m_iCurrentRecordStart = iTargetPosition ; m_iCurrentRecordEnd = iTargetPosition ; return this . bufferToArrayIndex ( iTargetPosition ) ; }
Shift the current cache to the current records and setup a new buffer .
14,145
private ResourceHandler createZipResourceHandler ( final URL zipFile ) throws IOException { final FileSystem fileSystem = newFileSystem ( URI . create ( "jar:" + zipFile ) , Collections . < String , Object > emptyMap ( ) ) ; final ResourceManager resMgr = new FileSystemResourceManager ( fileSystem ) ; return new ResourceHandler ( resMgr ) ; }
Creates the resource handle for a zip file specified by the URL .
14,146
public void setReturnSessionOrObject ( PrintWriter out , Object objReturn ) { String strID = null ; String strSessionClass = null ; if ( objReturn instanceof RemoteTable ) { strSessionClass = REMOTE_TABLE ; strID = this . add ( new TableHolder ( this , ( RemoteTable ) objReturn ) ) ; } else if ( objReturn instanceof RemoteSession ) { strSessionClass = REMOTE_SESSION ; strID = this . add ( new SessionHolder ( this , ( RemoteSession ) objReturn ) ) ; } else if ( objReturn instanceof RemoteBaseSession ) { strSessionClass = REMOTE_BASE_SESSION ; strID = this . add ( new BaseSessionHolder ( this , ( RemoteBaseSession ) objReturn ) ) ; } if ( strID != null ) this . setReturnString ( out , strSessionClass + CLASS_SEPARATOR + strID ) ; else this . setReturnObject ( out , objReturn ) ; }
If this is a session convert to a proxy session and return if object convert and return .
14,147
public void free ( ) { m_dependentStateListener = null ; this . removeListener ( false ) ; if ( m_nextListener != null ) { m_nextListener . free ( ) ; m_nextListener = null ; } }
Free this listener .
14,148
public void doAddListener ( BaseListener listener ) { if ( m_nextListener != null ) m_nextListener . doAddListener ( listener ) ; else m_nextListener = listener ; }
Add a listener to the end of the chain .
14,149
public void removeListener ( BaseListener listener , boolean bFreeFlag ) { if ( m_nextListener != null ) { if ( m_nextListener == listener ) { m_nextListener = listener . getNextListener ( ) ; listener . unlink ( bFreeFlag ) ; } else m_nextListener . removeListener ( listener , bFreeFlag ) ; } }
Remove a specific listener from the chain .
14,150
public BaseListener getNextEnabledListener ( ) { if ( m_nextListener == null ) return null ; if ( m_nextListener . isEnabled ( ) ) return m_nextListener ; else return m_nextListener . getNextEnabledListener ( ) ; }
Get then next enabled listener in the chain .
14,151
public String getFullPath ( String strSite , String strPath ) { if ( strSite != null ) { if ( strPath != null ) if ( strPath . startsWith ( "/" ) ) strPath = strSite + strPath ; } return strPath ; }
GetFullPath Method .
14,152
public Record moveToCurrentRecord ( Record recBase ) { if ( recBase == null ) recBase = this . getBaseRecord ( ) ; BaseField fldRecordType = recBase . getSharedRecordTypeKey ( ) ; Object objKey = fldRecordType . getData ( ) ; BaseTable tableCurrent = this . getTableAt ( objKey ) ; Record recCurrent = null ; if ( tableCurrent != null ) recCurrent = tableCurrent . getRecord ( ) ; if ( recCurrent == null ) { RecordOwner recordOwner = recBase . getRecordOwner ( ) ; RecordOwner recordOwnerFake = this . getFakeRecordOwner ( recordOwner ) ; recCurrent = recBase . createSharedRecord ( objKey , recordOwnerFake ) ; if ( recCurrent != null ) if ( recCurrent . getRecordOwner ( ) == recordOwnerFake ) { recCurrent . setRecordOwner ( recordOwner ) ; this . addTable ( objKey , recCurrent . getTable ( ) ) ; recCurrent . setOpenMode ( recBase . getOpenMode ( ) ) ; recBase . matchListeners ( recCurrent , true , true , true , true , true ) ; } } if ( recCurrent != null ) if ( recCurrent != recBase ) { this . copyRecordInfo ( recCurrent , recBase , true , false ) ; } if ( recCurrent != null ) this . setCurrentRecord ( recCurrent ) ; return recCurrent ; }
Figure what kind of record this record is and move it to the correct record .
14,153
public void copyRecordInfo ( Record recDest , Record recSource , boolean bCopyEditMode , boolean bOnlyModifiedFields ) { if ( recDest == null ) recDest = this . getCurrentRecord ( ) ; if ( recDest != recSource ) { boolean bAllowFieldChange = false ; boolean bMoveModifiedState = true ; Object [ ] rgobjEnabledFieldsOld = recSource . setEnableFieldListeners ( false ) ; recDest . moveFields ( recSource , null , DBConstants . DONT_DISPLAY , DBConstants . READ_MOVE , bAllowFieldChange , bOnlyModifiedFields , bMoveModifiedState , false ) ; recSource . setEnableFieldListeners ( rgobjEnabledFieldsOld ) ; if ( bCopyEditMode ) recDest . setEditMode ( recSource . getEditMode ( ) ) ; } }
Set the current table target .
14,154
public static < T > Optional < T > of ( final T optionalValue ) { checkNotNull ( optionalValue , "Optional value may not be null in method of" ) ; return new Optional < T > ( optionalValue ) ; }
Returns an Optional with the specified present non - null value .
14,155
public Optional < T > filter ( final Predicate < ? super T > predicate ) { if ( isPresent ( ) && predicate . test ( get ( ) ) ) { return this ; } return empty ( ) ; }
Apply a predicate to the optional if the optional is present and the predicate is true return the optional otherwise return empty .
14,156
public Optional < T > ifPresent ( final Consumer < ? super T > consumer ) { if ( isPresent ( ) ) { consumer . accept ( get ( ) ) ; } return this ; }
If a value is present invoke the specified consumer with the value otherwise do nothing .
14,157
public T orElseSupplier ( final Supplier < T > other ) { checkNotNull ( other , "orElse requires a non null supplier" ) ; if ( isPresent ( ) ) { return get ( ) ; } return other . get ( ) ; }
Return the value if present otherwise get the value from the Supplier .
14,158
public T orElseThrow ( final String msg ) { checkNonEmptyString ( msg , "Valid message required" ) ; if ( isPresent ( ) ) { return get ( ) ; } throw new NoSuchElementException ( msg ) ; }
If optional is not empty return it s value if empty throw a NoSuchElementException with message .
14,159
public < V > Optional < V > map ( final Function < T , V > function ) { checkNotNull ( function , "Must provide non null function to map" ) ; if ( isPresent ( ) ) { final V applied = function . apply ( get ( ) ) ; return applied == null ? Optional . < V > empty ( ) : Optional . of ( function . apply ( get ( ) ) ) ; } else { return Optional . empty ( ) ; } }
If a value is present map is with function and if the result is non - null return an Optional describing the result . Otherwise return an empty Optional .
14,160
public static String hash ( String plaintext ) throws WrappedException { try { MessageDigest md = MessageDigest . getInstance ( "SHA-1" ) ; md . update ( plaintext . getBytes ( "UTF-8" ) ) ; return hexEncode ( md . digest ( ) ) ; } catch ( NoSuchAlgorithmException | UnsupportedEncodingException e ) { throw new WrappedException ( e ) ; } }
Performs a one - way hash of the plaintext value using SHA - 1 .
14,161
public static String generateKey ( ) { byte [ ] bytes = new byte [ 32 ] ; getRandom ( ) . nextBytes ( bytes ) ; char [ ] chars = new char [ 64 ] ; for ( int c = 0 ; c < 32 ; c ++ ) { byte b = bytes [ c ] ; chars [ c * 2 ] = hexChars [ ( b & 255 ) >>> 4 ] ; chars [ c * 2 + 1 ] = hexChars [ b & 15 ] ; } return new String ( chars ) ; }
Generates a random key .
14,162
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static byte [ ] encode ( final String attributeName , final Object obj ) { TypeConverter converter = DataConverter . attributeConverters . get ( attributeName ) ; if ( converter == null ) { log . warn ( "Unable to find a suitable data converter for attribute {}." , attributeName ) ; throw new IllegalArgumentException ( "Unable to find a suitable data converter for attribute \"" + attributeName + "\"." ) ; } if ( obj instanceof String ) { return converter . encode ( ( String ) obj ) ; } return converter . encode ( obj ) ; }
Encodes attribute data into the standard binary representation for the type .
14,163
public static TypeConverter < ? > putConverter ( final String attributeName , final String type ) { TypeConverter < ? > conv = DataConverter . converterClasses . get ( type ) ; if ( conv == null ) { log . warn ( "Could not find a converter for data type {}." , type ) ; throw new IllegalArgumentException ( "Could not find a converter for data type \"" + type + "\"." ) ; } return DataConverter . attributeConverters . put ( attributeName , conv ) ; }
Maps a converter for an Attribute name .
14,164
public void addRelationshipToTarget ( final Level level , final RelationshipType type ) { final TargetRelationship relationship = new TargetRelationship ( this , level , type ) ; levelRelationships . add ( relationship ) ; relationships . add ( relationship ) ; }
Add a relationship to the target level .
14,165
public List < Relationship > getPreviousRelationships ( ) { final List < Relationship > prevRelationships = new LinkedList < Relationship > ( ) ; for ( final Relationship r : relationships ) { if ( r . getType ( ) == RelationshipType . PREVIOUS ) { prevRelationships . add ( r ) ; } } return prevRelationships ; }
Gets a list of previous relationships for the Topic .
14,166
public List < Relationship > getNextRelationships ( ) { final List < Relationship > nextRelationships = new LinkedList < Relationship > ( ) ; for ( final Relationship r : relationships ) { if ( r . getType ( ) == RelationshipType . NEXT ) { nextRelationships . add ( r ) ; } } return nextRelationships ; }
Gets a list of next relationships for the Topic .
14,167
public List < Relationship > getPrerequisiteRelationships ( ) { final List < Relationship > prerequisiteRelationships = new LinkedList < Relationship > ( ) ; for ( final Relationship r : relationships ) { if ( r . getType ( ) == RelationshipType . PREREQUISITE ) { prerequisiteRelationships . add ( r ) ; } } return prerequisiteRelationships ; }
Gets a list of prerequisite relationships for the topic .
14,168
public List < Relationship > getRelatedRelationships ( ) { final List < Relationship > relatedRelationships = new LinkedList < Relationship > ( ) ; for ( final Relationship r : relationships ) { if ( r . getType ( ) == RelationshipType . REFER_TO ) { relatedRelationships . add ( r ) ; } } return relatedRelationships ; }
Gets a list of related relationships for the topic .
14,169
public List < Relationship > getLinkListRelationships ( ) { final List < Relationship > linkListRelationships = new LinkedList < Relationship > ( ) ; for ( final Relationship r : relationships ) { if ( r . getType ( ) == RelationshipType . LINKLIST ) { linkListRelationships . add ( r ) ; } } return linkListRelationships ; }
Gets a list of link - list relationships for the topic .
14,170
private boolean printRelationshipsWithLongSyntax ( final List < Relationship > relationships ) { for ( final Relationship relationship : relationships ) { if ( relationship . getRelationshipTitle ( ) != null && ! relationship . getRelationshipTitle ( ) . trim ( ) . isEmpty ( ) ) { return true ; } } return false ; }
Checks to see if a list of relationships should be printed using the long syntax .
14,171
protected String generateRelationshipText ( final RelationshipType relationshipType , boolean shortSyntax , final String spacer ) { final StringBuilder retValue ; final List < Relationship > relationships ; if ( relationshipType == RelationshipType . REFER_TO ) { if ( shortSyntax ) { retValue = new StringBuilder ( " [R: " ) ; } else { retValue = new StringBuilder ( "\n" + spacer + "[Refer-to:" ) ; } relationships = getRelatedRelationships ( ) ; } else if ( relationshipType == RelationshipType . PREREQUISITE ) { if ( shortSyntax ) { retValue = new StringBuilder ( " [P: " ) ; } else { retValue = new StringBuilder ( "\n" + spacer + "[Prerequisite:" ) ; } relationships = getPrerequisiteRelationships ( ) ; } else if ( relationshipType == RelationshipType . LINKLIST ) { if ( shortSyntax ) { retValue = new StringBuilder ( " [L: " ) ; } else { retValue = new StringBuilder ( "\n" + spacer + "[Link-List:" ) ; } relationships = getLinkListRelationships ( ) ; } else { throw new IllegalArgumentException ( "Unable to create a text based formation for the " + relationshipType . toString ( ) + " " + "relationship type." ) ; } if ( shortSyntax ) { final List < String > relatedIds = new ArrayList < String > ( ) ; for ( final Relationship related : relationships ) { relatedIds . add ( related . getSecondaryRelationshipId ( ) ) ; } retValue . append ( StringUtilities . buildString ( relatedIds . toArray ( new String [ relatedIds . size ( ) ] ) , ", " ) ) ; } else { boolean first = true ; for ( final Relationship related : relationships ) { if ( first ) { retValue . append ( "\n" ) ; first = false ; } else { retValue . append ( ",\n" ) ; } retValue . append ( spacer ) ; retValue . append ( SPACER ) ; if ( related . getRelationshipTitle ( ) != null && ! related . getRelationshipTitle ( ) . trim ( ) . isEmpty ( ) ) { retValue . append ( ContentSpecUtilities . escapeRelationshipTitle ( related . getRelationshipTitle ( ) ) ) . append ( " " ) ; } retValue . append ( "[" ) ; retValue . append ( related . getSecondaryRelationshipId ( ) ) ; retValue . append ( "]" ) ; } } retValue . append ( "]" ) ; return retValue . toString ( ) ; }
Creates the relationship text to be added to a topic s text .
14,172
public static final FileFormat getFileFormat ( Path path , Map < String , ? > env ) { FileFormat fmt = ( FileFormat ) env . get ( FORMAT ) ; String filename = path . getFileName ( ) . toString ( ) ; if ( fmt == null ) { if ( filename . endsWith ( ".tar.gz" ) || filename . endsWith ( ".tar" ) || filename . endsWith ( ".deb" ) ) { fmt = TAR_GNU ; } else { fmt = CPIO_CRC ; } } return fmt ; }
Returns FileFormat either from env or using default value which is TAR_GNU for tar and CPIO_CRC for others .
14,173
public static final FileAttribute < ? > [ ] getFileAttributes ( Map < String , ? > env ) { FileAttribute < ? > [ ] attrs = ( FileAttribute < ? > [ ] ) env . get ( FILE_ATTRIBUTES ) ; if ( attrs == null ) { attrs = new FileAttribute < ? > [ 0 ] ; } return attrs ; }
Return file attributes from env or empty array . These attributes are used in creating archive file . Because of zip - file - system crashes if trying to open file system for not existing file .
14,174
public static final FileAttribute < ? > [ ] getDefaultRegularFileAttributes ( Map < String , ? > env ) { FileAttribute < ? > [ ] attrs = ( FileAttribute < ? > [ ] ) env . get ( DEFAULT_REGULAR_FILE_ATTRIBUTES ) ; if ( attrs == null ) { attrs = new FileAttribute < ? > [ ] { PosixFilePermissions . asFileAttribute ( PosixFilePermissions . fromString ( "rw-r--r--" ) ) , new FileAttributeImpl ( OWNER , new UnixUser ( "root" , 0 ) ) , new FileAttributeImpl ( GROUP , new UnixGroup ( "root" , 0 ) ) , } ; } return attrs ; }
Return default attributes for new regular file . Either from env or default values .
14,175
public static final FileAttribute < ? > [ ] getDefaultDirectoryFileAttributes ( Map < String , ? > env ) { FileAttribute < ? > [ ] attrs = ( FileAttribute < ? > [ ] ) env . get ( DEFAULT_DIRECTORY_FILE_ATTRIBUTES ) ; if ( attrs == null ) { attrs = new FileAttribute < ? > [ ] { PosixFilePermissions . asFileAttribute ( PosixFilePermissions . fromString ( "rwxr-xr-x" ) ) , new FileAttributeImpl ( OWNER , new UnixUser ( "root" , 0 ) ) , new FileAttributeImpl ( GROUP , new UnixGroup ( "root" , 0 ) ) , } ; } return attrs ; }
Return default attributes for new directory . Either from env or default values .
14,176
public static final FileAttribute < ? > [ ] getDefaultSymbolicLinkFileAttributes ( Map < String , ? > env ) { FileAttribute < ? > [ ] attrs = ( FileAttribute < ? > [ ] ) env . get ( DEFAULT_SYMBOLIC_LINK_FILE_ATTRIBUTES ) ; if ( attrs == null ) { attrs = new FileAttribute < ? > [ ] { PosixFilePermissions . asFileAttribute ( PosixFilePermissions . fromString ( "rwxrwxrwx" ) ) , new FileAttributeImpl ( OWNER , new UnixUser ( "root" , 0 ) ) , new FileAttributeImpl ( GROUP , new UnixGroup ( "root" , 0 ) ) , } ; } return attrs ; }
Return default attributes for new symbolic link . Either from env or default values .
14,177
public static final Set < ? extends OpenOption > getOpenOptions ( Path path , Map < String , ? > env ) throws IOException { Set < ? extends OpenOption > opts = ( Set < ? extends OpenOption > ) env . get ( OPEN_OPTIONS ) ; if ( opts == null ) { if ( Files . exists ( path ) && Files . size ( path ) > 0 ) { opts = EnumSet . of ( READ ) ; } else { opts = EnumSet . of ( WRITE , CREATE ) ; } } return opts ; }
Returns open - options . Returns from env if exists . Otherwise if file exists and size greater than 0 returns READ or READ WRITE .
14,178
private synchronized WatchKey getWatchKeyForPath ( final String path ) throws IOException { WatchKey key = watchKeysByPath . get ( path ) ; if ( key == null ) { logger . debug ( "Lazy-instantiating watch key for path: {}" , path ) ; key = Paths . get ( path ) . register ( watchService , interested_types ) ; watchKeysByPath . put ( path , key ) ; pathsByWatchKey . put ( key , path ) ; listenersByWatchKey . put ( key , Collections . newSetFromMap ( new ConcurrentHashMap < SFMF4JWatchListener , Boolean > ( ) ) ) ; } return key ; }
Gets the watch key for a path with lazy initialization .
14,179
private synchronized WatchEvent < Path > resolveEventWithCorrectPath ( final WatchKey key , final WatchEvent < Path > event ) { Path correctPath = Paths . get ( pathsByWatchKey . get ( key ) ) ; return new ResolvedPathWatchEvent ( event , correctPath ) ; }
Resolves a watch event with its absolute path .
14,180
public SampleMessage getNextSample ( ) { if ( this . connected ) { try { return this . sampleQueue . take ( ) ; } catch ( InterruptedException e ) { log . error ( "Interrupted while waiting for next sample to arrive." , e ) ; } return null ; } throw new IllegalStateException ( "Connection to the aggregator has terminated." ) ; }
Returns the next sample from the Aggregator blocking until it is available if none are currently buffered . If the connection to the aggregator has been completely shut down then this method will throw an IllegalStateException .
14,181
public int addRule ( final SubscriptionRequestRule rule ) { Integer theRuleNum = Integer . valueOf ( this . nextRuleNum . getAndIncrement ( ) ) ; synchronized ( this . ruleMap ) { if ( ! this . ruleMap . values ( ) . contains ( rule ) ) { this . ruleMap . put ( theRuleNum , rule ) ; SubscriptionRequestRule [ ] newRules = this . ruleMap . values ( ) . toArray ( new SubscriptionRequestRule [ ] { } ) ; this . agg . setRules ( newRules ) ; if ( this . agg . isConnected ( ) ) { SubscriptionMessage msg = new SubscriptionMessage ( ) ; msg . setRules ( new SubscriptionRequestRule [ ] { rule } ) ; msg . setMessageType ( SubscriptionMessage . SUBSCRIPTION_MESSAGE_ID ) ; this . agg . getSession ( ) . write ( msg ) ; } return theRuleNum . intValue ( ) ; } log . warn ( "Rule {} is already configured for use." , rule ) ; return - 1 ; } }
Adds a Subscription Request Rule to the aggregator interface . If the aggregator is already connected the rule will be sent immediately otherwise it will be sent with all rules when the aggregator is connected .
14,182
void sampleReceived ( SolverAggregatorInterface aggregator , SampleMessage sample ) { if ( ! this . sampleQueue . offer ( sample ) && this . warnBufferFull ) { log . warn ( "Unable to insert a sample due to a full buffer." ) ; } }
Called when the aggregator sends a sample . Enqueues the sample into the internal buffer .
14,183
public String getDefaultVersion ( ) { Record recMessageVersion = ( ( ReferenceField ) this . getRecord ( MessageControl . MESSAGE_CONTROL_FILE ) . getField ( MessageControl . DEFAULT_VERSION_ID ) ) . getReference ( ) ; if ( recMessageVersion != null ) if ( ( recMessageVersion . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( recMessageVersion . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) return recMessageVersion . getField ( MessageVersion . CODE ) . toString ( ) ; return "2007B" ; }
GetDefaultVersion Method .
14,184
public void scanProcesses ( Object typeObject , OperationType type ) { String strTargetVersion = this . getProperty ( "version" ) ; if ( strTargetVersion == null ) strTargetVersion = this . getDefaultVersion ( ) ; Record recMessageTransport = ( ( ReferenceField ) this . getRecord ( MessageControl . MESSAGE_CONTROL_FILE ) . getField ( MessageControl . WEB_MESSAGE_TRANSPORT_ID ) ) . getReference ( ) ; MessageVersion recMessageVersion = ( ( MessageControl ) this . getRecord ( MessageControl . MESSAGE_CONTROL_FILE ) ) . getMessageVersion ( strTargetVersion ) ; MessageProcessInfo recMessageProcessInfo = new MessageProcessInfo ( this ) ; recMessageProcessInfo . setKeyArea ( MessageProcessInfo . MESSAGE_INFO_ID_KEY ) ; try { recMessageProcessInfo . close ( ) ; while ( recMessageProcessInfo . hasNext ( ) ) { recMessageProcessInfo . next ( ) ; String strQueueName = recMessageProcessInfo . getQueueName ( true ) ; String strQueueType = recMessageProcessInfo . getQueueType ( true ) ; String strProcessClass = recMessageProcessInfo . getField ( MessageProcessInfo . PROCESSOR_CLASS ) . toString ( ) ; Map < String , Object > properties = ( ( PropertiesField ) recMessageProcessInfo . getField ( MessageProcessInfo . PROPERTIES ) ) . getProperties ( ) ; Record recMessageType = ( ( ReferenceField ) recMessageProcessInfo . getField ( MessageProcessInfo . MESSAGE_TYPE_ID ) ) . getReference ( ) ; if ( recMessageType != null ) { String strMessageType = recMessageType . getField ( MessageType . CODE ) . toString ( ) ; Record recMessageInfo = ( ( ReferenceField ) recMessageProcessInfo . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) ; if ( recMessageInfo != null ) { Record recMessageInfoType = ( ( ReferenceField ) recMessageInfo . getField ( MessageInfo . MESSAGE_INFO_TYPE_ID ) ) . getReference ( ) ; if ( recMessageInfoType != null ) { String strMessageInfoType = recMessageInfoType . getField ( MessageInfoType . CODE ) . toString ( ) ; if ( MessageInfoType . REQUEST . equals ( strMessageInfoType ) ) if ( MessageType . MESSAGE_IN . equals ( strMessageType ) ) if ( ( strQueueName != null ) && ( strQueueName . length ( ) > 0 ) ) { Record recMessageTransportInfo = this . getRecord ( MessageTransportInfo . MESSAGE_TRANSPORT_INFO_FILE ) ; recMessageTransportInfo . setKeyArea ( MessageTransportInfo . MESSAGE_PROCESS_INFO_ID_KEY ) ; recMessageTransportInfo . getField ( MessageTransportInfo . MESSAGE_PROCESS_INFO_ID ) . moveFieldToThis ( recMessageProcessInfo . getField ( MessageProcessInfo . ID ) ) ; recMessageTransportInfo . getField ( MessageTransportInfo . MESSAGE_TRANSPORT_ID ) . moveFieldToThis ( recMessageTransport . getField ( MessageTransport . ID ) ) ; recMessageTransportInfo . getField ( MessageTransportInfo . MESSAGE_VERSION_ID ) . moveFieldToThis ( recMessageVersion . getField ( MessageVersion . ID ) ) ; if ( recMessageTransportInfo . seek ( DBConstants . EQUALS ) ) { this . addProcessForWSDL ( strTargetVersion , typeObject , recMessageProcessInfo , type ) ; } } } } } } recMessageProcessInfo . close ( ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { recMessageProcessInfo . free ( ) ; } }
ScanProcesses Method .
14,185
public String getControlProperty ( String strKey , String strDefaultValue ) { String strValue = ( ( PropertiesField ) this . getRecord ( MessageControl . MESSAGE_CONTROL_FILE ) . getField ( MessageControl . PROPERTIES ) ) . getProperty ( strKey ) ; if ( strValue == null ) { if ( strDefaultValue == null ) strDefaultValue = this . getDefaultValue ( strKey ) ; strValue = strDefaultValue ; } return strValue ; }
GetControlProperty Method .
14,186
public String getDefaultValue ( String strKey ) { if ( DESCRIPTIONS == null ) DESCRIPTIONS = Utility . arrayToMap ( DEFAULTS ) ; return ( String ) DESCRIPTIONS . get ( strKey ) ; }
GetDefaultValue Method .
14,187
public String getURIProperty ( String strKey , String strDefaultValue ) { String strValue = this . getControlProperty ( strKey , strDefaultValue ) ; return this . getURIValue ( strValue ) ; }
GetURIProperty Method .
14,188
public String getURIValue ( String strValue ) { String strBaseURI = ( ( PropertiesField ) this . getRecord ( MessageControl . MESSAGE_CONTROL_FILE ) . getField ( MessageControl . PROPERTIES ) ) . getProperty ( MessageControl . BASE_NAMESPACE_URI ) ; if ( strBaseURI == null ) { strBaseURI = this . getProperty ( DBParams . BASE_URL ) ; if ( strBaseURI != null ) if ( strBaseURI . endsWith ( "/" ) ) strBaseURI = strBaseURI . substring ( 0 , strBaseURI . length ( ) - 1 ) ; } if ( strBaseURI != null ) if ( strBaseURI . indexOf ( "http://" ) != 0 ) strBaseURI = "http://" + strBaseURI ; if ( strBaseURI != null ) { if ( strValue == null ) strValue = strBaseURI ; else if ( ( strValue . indexOf ( "http://" ) != 0 ) || ( strValue . startsWith ( "/" ) ) ) strValue = strBaseURI + strValue ; } return strValue ; }
GetURIValue Method .
14,189
public MessageInfo getMessageIn ( MessageProcessInfo recMessageProcessInfo ) { return ( MessageInfo ) ( ( ReferenceField ) recMessageProcessInfo . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) ; }
GetMessageIn Method .
14,190
public MessageInfo getMessageOut ( MessageProcessInfo recMessageProcessInfo ) { MessageProcessInfo recMessageProcessInfo2 = ( MessageProcessInfo ) ( ( ReferenceField ) recMessageProcessInfo . getField ( MessageProcessInfo . REPLY_MESSAGE_PROCESS_INFO_ID ) ) . getReference ( ) ; if ( recMessageProcessInfo2 != null ) return ( MessageInfo ) ( ( ReferenceField ) recMessageProcessInfo2 . getField ( MessageProcessInfo . MESSAGE_INFO_ID ) ) . getReference ( ) ; return null ; }
GetMessageOut Method .
14,191
public String fixName ( String name ) { for ( int i = 0 ; i < name . length ( ) ; i ++ ) { if ( Character . isWhitespace ( name . charAt ( i ) ) ) name = name . substring ( 0 , i ) + name . substring ( i + 1 ) ; } return name ; }
FixName Method .
14,192
public String getNamespace ( ) { String strTargetVersion = this . getProperty ( "version" ) ; if ( strTargetVersion == null ) strTargetVersion = this . getDefaultVersion ( ) ; return this . getMessageControl ( ) . getNamespaceFromVersion ( strTargetVersion ) ; }
GetNamespace Method .
14,193
public boolean linkLastPredecessor ( Record recNewProjectTask , boolean bDisplayOption ) { if ( ( recNewProjectTask == null ) || ( recNewProjectTask . getEditMode ( ) != DBConstants . EDIT_ADD ) ) return false ; Object bookmark = recNewProjectTask . getLastModified ( DBConstants . BOOKMARK_HANDLE ) ; if ( bookmark == null ) return false ; if ( m_recDetail == null ) { RecordOwner recordOwner = this . getRecordOwner ( ) ; m_recDetail = new ProjectTask ( recordOwner ) ; if ( recordOwner != null ) recordOwner . removeRecord ( m_recDetail ) ; m_recDetail . addListener ( new SubFileFilter ( this ) ) ; } int iMoveMode = DBConstants . SCREEN_MOVE ; m_recDetail . getKeyArea ( ) . setKeyOrder ( DBConstants . DESCENDING ) ; try { m_recDetail . close ( ) ; while ( m_recDetail . hasNext ( ) ) { m_recDetail . next ( ) ; if ( m_recDetail . getHandle ( DBConstants . BOOKMARK_HANDLE ) . equals ( bookmark ) ) continue ; if ( ( ! m_recDetail . getField ( ProjectTask . END_DATE_TIME ) . equals ( this . getField ( ProjectTask . END_DATE_TIME ) ) ) || ( ! m_recDetail . getField ( ProjectTask . END_DATE_TIME ) . equals ( recNewProjectTask . getField ( ProjectTask . START_DATE_TIME ) ) ) ) return false ; ProjectTaskPredecessor recProjectTaskPredecessor = this . getProjectTaskPredecessor ( ) ; recProjectTaskPredecessor . addNew ( ) ; recProjectTaskPredecessor . getField ( ProjectTaskPredecessor . PROJECT_TASK_PREDECESSOR_ID ) . moveFieldToThis ( m_recDetail . getField ( ProjectTask . ID ) ) ; recProjectTaskPredecessor . getField ( ProjectTaskPredecessor . PROJECT_TASK_ID ) . setData ( bookmark ) ; recProjectTaskPredecessor . getField ( ProjectTaskPredecessor . PREDECESSOR_TYPE ) . setString ( PredecessorTypeField . FINISH_START ) ; recProjectTaskPredecessor . add ( ) ; this . getListener ( UpdateChildrenHandler . class ) . setEnabledListener ( false ) ; this . edit ( ) ; ( ( DateTimeField ) this . getField ( ProjectTask . END_DATE_TIME ) ) . moveFieldToThis ( recNewProjectTask . getField ( ProjectTask . END_DATE_TIME ) , bDisplayOption , iMoveMode ) ; bookmark = this . getHandle ( DBConstants . BOOKMARK_HANDLE ) ; this . set ( ) ; this . setHandle ( bookmark , DBConstants . BOOKMARK_HANDLE ) ; return true ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { this . getListener ( UpdateChildrenHandler . class ) . setEnabledListener ( true ) ; m_recDetail . getKeyArea ( ) . setKeyOrder ( DBConstants . ASCENDING ) ; } return false ; }
LinkLastPredecessor Method .
14,194
public boolean updateChildren ( boolean bDisplayOption ) { int iMoveMode = DBConstants . SCREEN_MOVE ; ProjectTask recDetailChildren = this . getDetailChildren ( ) ; Date startDate = ( ( DateTimeField ) this . getField ( ProjectTask . START_DATE_TIME ) ) . getDateTime ( ) ; Date endDate = ( ( DateTimeField ) this . getField ( ProjectTask . END_DATE_TIME ) ) . getDateTime ( ) ; try { boolean bFirstRecord = true ; double dOffset = 0 ; recDetailChildren . getListener ( SurveyDatesHandler . class ) . setEnabledListener ( false ) ; ( ( UpdateDependenciesHandler ) recDetailChildren . getListener ( UpdateDependenciesHandler . class ) ) . setMoveSiblingDependents ( false ) ; recDetailChildren . close ( ) ; while ( recDetailChildren . hasNext ( ) ) { recDetailChildren . next ( ) ; Date thisStartDate = ( ( DateTimeField ) recDetailChildren . getField ( ProjectTask . START_DATE_TIME ) ) . getDateTime ( ) ; Date thisEndDate = ( ( DateTimeField ) recDetailChildren . getField ( ProjectTask . END_DATE_TIME ) ) . getDateTime ( ) ; if ( bFirstRecord ) { bFirstRecord = false ; if ( ( thisStartDate == null ) || ( thisEndDate == null ) || ( startDate == null ) || ( endDate == null ) ) break ; if ( thisStartDate . equals ( startDate ) ) break ; dOffset = startDate . getTime ( ) - thisStartDate . getTime ( ) ; if ( ( dOffset >= - 1000 ) && ( dOffset <= 1000 ) ) break ; } recDetailChildren . edit ( ) ; Converter . gCalendar = ( ( DateTimeField ) recDetailChildren . getField ( ProjectTask . START_DATE_TIME ) ) . getCalendar ( ) ; Converter . gCalendar . add ( Calendar . MILLISECOND , ( int ) dOffset ) ; ( ( DateTimeField ) recDetailChildren . getField ( ProjectTask . START_DATE_TIME ) ) . setCalendar ( Converter . gCalendar , bDisplayOption , iMoveMode ) ; recDetailChildren . set ( ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { recDetailChildren . getListener ( SurveyDatesHandler . class ) . setEnabledListener ( true ) ; ( ( UpdateDependenciesHandler ) recDetailChildren . getListener ( UpdateDependenciesHandler . class ) ) . setMoveSiblingDependents ( true ) ; } return false ; }
UpdateChildren Method .
14,195
public boolean surveyDates ( boolean bDisplayOption ) { if ( m_recDetail == null ) { RecordOwner recordOwner = this . getRecordOwner ( ) ; m_recDetail = new ProjectTask ( recordOwner ) ; if ( recordOwner != null ) recordOwner . removeRecord ( m_recDetail ) ; m_recDetail . addListener ( new SubFileFilter ( this , true ) ) ; } Date startDate = null ; Date endDate = null ; try { m_recDetail . close ( ) ; while ( m_recDetail . hasNext ( ) ) { m_recDetail . next ( ) ; Date thisStartDate = null ; if ( ! m_recDetail . getField ( ProjectTask . START_DATE_TIME ) . isNull ( ) ) thisStartDate = ( ( DateTimeField ) m_recDetail . getField ( ProjectTask . START_DATE_TIME ) ) . getDateTime ( ) ; if ( thisStartDate != null ) if ( ( startDate == null ) || ( thisStartDate . before ( startDate ) ) ) startDate = thisStartDate ; Date thisEndDate = null ; if ( ! m_recDetail . getField ( ProjectTask . END_DATE_TIME ) . isNull ( ) ) thisEndDate = ( ( DateTimeField ) m_recDetail . getField ( ProjectTask . END_DATE_TIME ) ) . getDateTime ( ) ; if ( thisEndDate != null ) if ( ( endDate == null ) || ( thisEndDate . after ( endDate ) ) ) endDate = thisEndDate ; } this . getListener ( UpdateChildrenHandler . class ) . setEnabledListener ( false ) ; this . edit ( ) ; int iMoveMode = DBConstants . SCREEN_MOVE ; if ( startDate != null ) ( ( DateTimeField ) this . getField ( ProjectTask . START_DATE_TIME ) ) . setDateTime ( startDate , bDisplayOption , iMoveMode ) ; if ( endDate != null ) ( ( DateTimeField ) this . getField ( ProjectTask . END_DATE_TIME ) ) . setDateTime ( endDate , bDisplayOption , iMoveMode ) ; boolean bHasChildren = true ; if ( ( startDate == null ) && ( endDate == null ) ) bHasChildren = false ; this . getField ( ProjectTask . HAS_CHILDREN ) . setState ( bHasChildren ) ; if ( this . isModified ( ) ) { Object bookmark = this . getHandle ( DBConstants . BOOKMARK_HANDLE ) ; this . set ( ) ; this . setHandle ( bookmark , DBConstants . BOOKMARK_HANDLE ) ; return true ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { this . getListener ( UpdateChildrenHandler . class ) . setEnabledListener ( true ) ; } return false ; }
SurveyDates Method .
14,196
public ProjectTaskPredecessor getProjectTaskPredecessor ( ) { if ( m_recProjectTaskPredecessor == null ) { m_recProjectTaskPredecessor = new ProjectTaskPredecessor ( this . getRecordOwner ( ) ) ; ( ( ReferenceField ) m_recProjectTaskPredecessor . getField ( ProjectTaskPredecessor . PROJECT_TASK_ID ) ) . getReferenceRecord ( ) ; ( ( ReferenceField ) m_recProjectTaskPredecessor . getField ( ProjectTaskPredecessor . PROJECT_TASK_PREDECESSOR_ID ) ) . getReferenceRecord ( ) ; } return m_recProjectTaskPredecessor ; }
GetProjectTaskPredecessor Method .
14,197
public ProjectTask getDetailChildren ( ) { if ( m_recDetailChildren == null ) { RecordOwner recordOwner = this . getRecordOwner ( ) ; m_recDetailChildren = new ProjectTask ( recordOwner ) ; if ( recordOwner != null ) recordOwner . removeRecord ( m_recDetailChildren ) ; m_recDetailChildren . addListener ( new SubFileFilter ( this , true ) ) ; } return m_recDetailChildren ; }
GetDetailChildren Method .
14,198
public int doSetData ( Object fieldPtr , boolean bDisplayOption , int iMoveMode ) { int iErrorCode = DBConstants . NORMAL_RETURN ; boolean bSubExists = ( this . getOwner ( ) . getRecord ( ) . getListener ( SubFileFilter . class . getName ( ) ) != null ) ; if ( bSubExists ) iErrorCode = super . doSetData ( fieldPtr , bDisplayOption , iMoveMode ) ; return iErrorCode ; }
Move the physical binary data to this field . If there is not SubFileFilter then don t allow the field to be inited .
14,199
public boolean isSingleDataImage ( ) { if ( this . getScreenField ( ) . getConverter ( ) != null ) if ( this . getScreenField ( ) . getConverter ( ) . getField ( ) != null ) if ( this . getScreenField ( ) . getConverter ( ) . getField ( ) . getComponent ( 1 ) == null ) return true ; return false ; }
Special case - if this button is linked to data and this is the only sfield then display it .