idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
15,800
public float getNextFrequency ( float delta ) throws IOException { float last = frequencyCounter . getFrequency ( ) ; float min = last - delta ; float max = last + delta ; while ( true ) { int sample = getSample ( ) ; if ( frequencyCounter . update ( sample ) ) { float next = frequencyCounter . getFrequency ( ) ; if ( next > max || next < min ) { return next ; } } } }
Returns next frequency that deviates more than delta from previous .
15,801
public float getHalfWave ( ) throws IOException { while ( true ) { int sample = getSample ( ) ; if ( frequencyCounter . update ( sample ) ) { return frequencyCounter . getFrequency ( ) ; } } }
Reads one half - wave and returns frequency
15,802
public List < Dependency > asList ( boolean withChildren ) { if ( withChildren ) { return new ArrayList < > ( asSet ( ) ) ; } else { if ( list != null ) { return new ArrayList < > ( list ) ; } else { return new ArrayList < > ( ) ; } } }
Returns the dependencies as a list
15,803
public Set < Dependency > asSet ( boolean withChildren ) { if ( withChildren ) { Set < Dependency > dependencySet = new HashSet < > ( ) ; List < Dependency > dependencyList = asList ( false ) ; dependencySet . addAll ( dependencyList ) ; for ( Dependency dependency : dependencyList ) { if ( dependency . isInternal ( ) ) { dependencySet . addAll ( dependency . getDependencies ( ) . asSet ( ) ) ; } } return dependencySet ; } else { return new HashSet < > ( list ) ; } }
Returns the dependencies as a set
15,804
public final void insert ( ClusterName targetCluster , TableMetadata targetTable , Row row , boolean isNotExists ) throws UnsupportedException , ExecutionException { try { connectionHandler . startJob ( targetCluster . getName ( ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Inserting one row in table [" + targetTable . getName ( ) . getName ( ) + "] in cluster [" + targetCluster . getName ( ) + "]" ) ; } insert ( targetTable , row , isNotExists , connectionHandler . getConnection ( targetCluster . getName ( ) ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "One row has been inserted successfully in table [" + targetTable . getName ( ) . getName ( ) + "] in cluster [" + targetCluster . getName ( ) + "]" ) ; } } finally { connectionHandler . endJob ( targetCluster . getName ( ) ) ; } }
Insert a single row in a table .
15,805
public final void update ( ClusterName targetCluster , TableName tableName , Collection < Relation > assignments , Collection < Filter > whereClauses ) throws UnsupportedException , ExecutionException { try { connectionHandler . startJob ( targetCluster . getName ( ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Updating table [" + tableName . getName ( ) + "] in cluster [" + targetCluster . getName ( ) + "]" ) ; } update ( tableName , assignments , whereClauses , connectionHandler . getConnection ( targetCluster . getName ( ) ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "The table [" + tableName . getName ( ) + "] has been updated successfully in cluster [" + targetCluster . getName ( ) + "]" ) ; } } finally { connectionHandler . endJob ( targetCluster . getName ( ) ) ; } }
This method updates data of a table according to some conditions .
15,806
public final void truncate ( ClusterName targetCluster , TableName tableName ) throws UnsupportedException , ExecutionException { try { connectionHandler . startJob ( targetCluster . getName ( ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Tuncating table [" + tableName . getName ( ) + "] in cluster [" + targetCluster . getName ( ) + "]" ) ; } truncate ( tableName , connectionHandler . getConnection ( targetCluster . getName ( ) ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "The table [" + tableName . getName ( ) + "] has been successfully truncated in cluster [" + targetCluster . getName ( ) + "]" ) ; } } finally { connectionHandler . endJob ( targetCluster . getName ( ) ) ; } }
This method deletes all the rows of a table .
15,807
public File getDestPath ( String sourcePath ) { String destPathname = DBConstants . BLANK ; String dirPrefix = this . getProperty ( DIR_PREFIX ) ; String sourceDir = this . getProperty ( SOURCE_DIR ) ; String destDir = this . getProperty ( DEST_DIR ) ; int startPath = sourcePath . indexOf ( sourceDir ) ; if ( ( dirPrefix != null ) && ( sourceDir != null ) && ( sourceDir . length ( ) > 0 ) && ( sourcePath . indexOf ( dirPrefix ) == 0 ) ) destPathname += dirPrefix ; else { if ( ( ! destDir . startsWith ( "/" ) ) && ( ! destDir . startsWith ( File . separator ) ) ) { if ( startPath == 0 ) { int iEndStartPath = sourceDir . lastIndexOf ( File . separator ) ; if ( iEndStartPath == - 1 ) iEndStartPath = sourceDir . lastIndexOf ( '/' ) ; if ( iEndStartPath > 0 ) destPathname += sourceDir . substring ( 0 , iEndStartPath + 1 ) ; } } } destPathname = Utility . addToPath ( destPathname , destDir ) ; if ( startPath != - 1 ) destPathname = Utility . addToPath ( destPathname , sourcePath . substring ( startPath + sourceDir . length ( ) ) ) ; return new File ( destPathname ) ; }
Get the destination pathname .
15,808
public ScanListener getScanListener ( ) { if ( m_listener == null ) { String strClassName = this . getProperty ( LISTENER_CLASS ) ; if ( strClassName == null ) strClassName = ReplaceScanListener . class . getName ( ) ; m_listener = ( ScanListener ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( strClassName ) ; if ( m_listener != null ) ( ( BaseScanListener ) m_listener ) . init ( this , null ) ; else System . exit ( 0 ) ; } return m_listener ; }
Get the scan listener .
15,809
public String getFullPath ( String pathToFix ) { String dirPrefix = this . getProperty ( DIR_PREFIX ) ; if ( dirPrefix == null ) dirPrefix = Utility . addToPath ( System . getProperty ( "user.home" ) , "workspace/tourgeek/src/com/tourgeek" ) ; if ( pathToFix == null ) pathToFix = dirPrefix ; else if ( ( ! pathToFix . startsWith ( "/" ) ) && ( ! pathToFix . startsWith ( "." ) ) && ( ! pathToFix . startsWith ( File . separator ) ) ) pathToFix = Utility . addToPath ( dirPrefix , pathToFix ) ; return pathToFix ; }
Get the full path name .
15,810
private static void addFile ( final File file , final File dirToZip , final ZipOutputStream zos ) throws IOException { final String absolutePath = file . getAbsolutePath ( ) ; final int index = absolutePath . indexOf ( dirToZip . getName ( ) ) ; final String zipEntryName = absolutePath . substring ( index , absolutePath . length ( ) ) ; final byte [ ] b = new byte [ ( int ) file . length ( ) ] ; final ZipEntry cpZipEntry = new ZipEntry ( zipEntryName ) ; zos . putNextEntry ( cpZipEntry ) ; zos . write ( b , 0 , ( int ) file . length ( ) ) ; zos . closeEntry ( ) ; }
Adds the file .
15,811
public static boolean isZip ( final String filename ) { for ( final String element : FileConst . ZIP_EXTENSIONS ) { if ( filename . endsWith ( element ) ) { return true ; } } return false ; }
Checks if the given filename is a zip - file .
15,812
public void setTimecodeBase ( int timecodeBase ) { if ( timecodeBase < 0 ) { timecodeBase = 0 ; } if ( this . timecodeBase > 0 && timecodeBase != this . timecodeBase ) { this . frames = ( int ) Math . round ( ( double ) this . frames * timecodeBase / this . timecodeBase ) ; } this . timecodeBase = timecodeBase ; innerSetDropFrame ( this . dropFrame ) ; }
Changes timecode base of the timecode
15,813
public void setHMSF ( int hours , int minutes , int seconds , int frames ) { innerSetHMSF ( hours , minutes , seconds , frames ) ; }
Sets the timecode to the provided hours minutes seconds and frames
15,814
public void open ( String strKeyArea , int iOpenMode , boolean bDirection , String strFields , Object objInitialKey , Object objEndKey , byte [ ] byBehaviorData ) throws DBException , RemoteException { BaseTransport transport = this . createProxyTransport ( OPEN ) ; transport . addParam ( KEY , strKeyArea ) ; transport . addParam ( OPEN_MODE , iOpenMode ) ; transport . addParam ( DIRECTION , bDirection ) ; transport . addParam ( FIELDS , strFields ) ; transport . addParam ( INITIAL_KEY , objInitialKey ) ; transport . addParam ( END_KEY , objEndKey ) ; transport . addParam ( BEHAVIOR_DATA , byBehaviorData ) ; Object strReturn = transport . sendMessageAndGetReply ( ) ; Object objReturn = transport . convertReturnObject ( strReturn ) ; this . checkDBException ( objReturn ) ; }
Open - Receive to this server and send the response .
15,815
public org . jbundle . thin . base . db . FieldList makeFieldList ( String strFieldsToInclude ) throws RemoteException { BaseTransport transport = this . createProxyTransport ( MAKE_FIELD_LIST ) ; transport . addParam ( FIELDS , strFieldsToInclude ) ; Object strReturn = transport . sendMessageAndGetReply ( ) ; Object objReturn = transport . convertReturnObject ( strReturn ) ; return ( org . jbundle . thin . base . db . FieldList ) objReturn ; }
Make a thin FieldList for this table . Usually used for special queries that don t have a field list available .
15,816
public void dispose ( ) { try { if ( generator != null ) { generator . writeEndArray ( ) ; generator . close ( ) ; } this . getWriter ( ) . close ( ) ; } catch ( IOException ioe ) { logger . error ( "Unable to close writer" , ioe ) ; logger . trace ( ioe . getMessage ( ) , ioe ) ; } finally { generator = null ; this . setWriter ( null ) ; } }
Closes the output writer .
15,817
private boolean consideringHierarchy ( Publish p ) { boolean sent = false ; for ( Entry < Class < ? > , List < SubscriberParent > > e : p . mapping . entrySet ( ) ) { if ( e . getKey ( ) . isAssignableFrom ( p . message . getClass ( ) ) ) { for ( SubscriberParent parent : e . getValue ( ) ) { if ( ! predicateApplies ( parent . getSubscriber ( ) , p . message ) ) { continue ; } parent . getSubscriber ( ) . receiveO ( p . message ) ; sent = true ; } } } return sent ; }
Iterates through the subscribers considering the type hierarchy and invokes the receiveO method .
15,818
private boolean normal ( Publish p ) { boolean sent = false ; List < SubscriberParent > list = p . mapping . get ( p . message . getClass ( ) ) ; if ( list == null ) { return false ; } for ( SubscriberParent sp : list ) { Subscriber < ? > s = sp . getSubscriber ( ) ; if ( ! predicateApplies ( s , p . message ) ) { continue ; } s . receiveO ( p . message ) ; sent = true ; } return sent ; }
Iterates through the subscribers invoking the receiveO method .
15,819
private boolean predicateApplies ( Subscriber < ? > s , Object message ) { if ( s instanceof PredicatedSubscriber && ! ( ( PredicatedSubscriber < ? > ) s ) . appliesO ( message ) ) { return false ; } return true ; }
Checks to see if the subscriber is a predicated subscriber and if it applies .
15,820
public boolean isEmpty ( ) { if ( m_filter != null ) return false ; if ( m_mapNameValue != null ) if ( m_mapNameValue . size ( ) != 0 ) return false ; return true ; }
Is this node empty .
15,821
public Map < String , NameValue > getValueMap ( boolean bAddIfNotFound ) { if ( m_mapNameValue == null ) if ( bAddIfNotFound ) m_mapNameValue = new Hashtable < String , NameValue > ( ) ; return m_mapNameValue ; }
Get the next Lower nodes .
15,822
public boolean removeNameValueNode ( NameValue node ) { Map < String , NameValue > map = this . getValueMap ( false ) ; if ( map == null ) return false ; return ( map . remove ( node . getKey ( ) ) == node ) ; }
Add this node to my value map .
15,823
public void addThisMessageFilter ( BaseMessageFilter filter ) { if ( m_filter == null ) m_filter = filter ; else { if ( m_filter instanceof BaseMessageFilter ) { BaseMessageFilter filterFirst = ( BaseMessageFilter ) m_filter ; m_filter = new Hashtable < String , Object > ( ) ; ( ( Map ) m_filter ) . put ( filterFirst . getFilterID ( ) , filterFirst ) ; } ( ( Map ) m_filter ) . put ( filter . getFilterID ( ) , filter ) ; } }
Set the owner of this value .
15,824
public boolean removeThisMessageFilter ( BaseMessageFilter filter ) { if ( m_filter instanceof BaseMessageFilter ) { if ( m_filter != filter ) return false ; m_filter = null ; return true ; } else return ( ( ( Map ) m_filter ) . remove ( filter . getFilterID ( ) ) != null ) ; }
Remove this filter from the filter list .
15,825
public Iterator getFilterIterator ( ) { if ( m_filter instanceof Map ) return ( ( Map ) m_filter ) . values ( ) . iterator ( ) ; else if ( m_filter != null ) return new OneFilterIterator ( ) ; else return null ; }
Get the list of filters for this leaf node .
15,826
protected boolean isAvailable ( URL url ) { try ( InputStream inputStream = url . openStream ( ) ) { return true ; } catch ( IOException e ) { LOG . debug ( "URL {} not available" , url , e ) ; return false ; } }
Checks the availability of a URL by openening a reading stream on it .
15,827
public void add ( double value ) { max = Math . max ( max , value ) ; min = Math . min ( min , value ) ; if ( count == 0 ) { average = value ; } else { average = count * average / ( count + 1 ) + value / ( count + 1 ) ; deviationSquare = count * deviationSquare / ( count + 1 ) + Math . pow ( value - average , 2 ) / ( count + 1 ) ; } count ++ ; }
Add a new value .
15,828
public void clear ( ) { count = 0 ; average = 0 ; max = Double . MIN_VALUE ; min = Double . MAX_VALUE ; deviationSquare = 0 ; }
Clears the added values .
15,829
public int select ( long timeout ) throws IOException { fine ( "select(" + timeout + ")" ) ; lock . lock ( ) ; try { ensureAllRunning ( ) ; try { SelKey sk = queue . poll ( timeout , TimeUnit . MILLISECONDS ) ; if ( sk != null ) { selectedKeys . add ( sk ) ; queue . drainTo ( selectedKeys ) ; selectedKeys . remove ( WAKEUP_KEY ) ; return selectedKeys . size ( ) ; } else { fine ( "select() timeout" ) ; return 0 ; } } catch ( InterruptedException ex ) { fine ( "select() interrupted" ) ; return 0 ; } } finally { lock . unlock ( ) ; } }
Selects and waits .
15,830
public MDecimal getMPH ( ) { MDecimal result = new MDecimal ( currentUnit . getConverterTo ( MILES_PER_HOUR ) . convert ( doubleValue ( ) ) ) ; logger . trace ( MMarker . GETTER , "Converting from {} to MPS : {}" , currentUnit , result ) ; return result ; }
Miles per hour
15,831
public static void restoreFieldParam ( PropertyOwner propertyOwner , Field field ) { String strFieldName = field . getFieldName ( ) ; if ( propertyOwner . getProperty ( strFieldName ) != null ) field . setString ( ( String ) propertyOwner . getProperty ( strFieldName ) ) ; }
RestoreProductParam Method .
15,832
public static String propertiesToURL ( String strURL , Map < String , Object > properties ) { if ( properties != null ) { for ( String strKey : properties . keySet ( ) ) { Object strValue = properties . get ( strKey ) ; strURL = Utility . addURLParam ( strURL , strKey . toString ( ) , strValue . toString ( ) ) ; } } return strURL ; }
Add to this URL using all the properties in this property list .
15,833
public static String [ ] propertiesToArgs ( Map < String , Object > properties ) { if ( properties == null ) return null ; String [ ] rgArgs = new String [ properties . size ( ) ] ; int i = 0 ; for ( String strKey : properties . keySet ( ) ) { Object strValue = properties . get ( strKey ) ; rgArgs [ i ++ ] = strKey . toString ( ) + '=' + strValue . toString ( ) ; } return rgArgs ; }
Create an argument list using all the properties in this property list .
15,834
public static InputStream getStringInputStream ( String string ) { InputStream is = null ; try { ByteArrayOutputStream ba = new ByteArrayOutputStream ( ) ; DataOutputStream os = new DataOutputStream ( ba ) ; os . writeUTF ( string ) ; os . flush ( ) ; is = new ByteArrayInputStream ( ba . toByteArray ( ) ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return is ; }
A utility method to get an UTF - 8 Input stream from a string .
15,835
public static String endTag ( String string ) { if ( string . indexOf ( ' ' ) != - 1 ) string = string . substring ( 0 , string . indexOf ( ' ' ) ) ; return "</" + string + '>' ; }
Change this string to a XML end Text string .
15,836
public static String getAsFormattedString ( Map < String , Object > map , String strKey , Class < ? > classData , Object objDefault ) { Object objData = map . get ( strKey ) ; try { return Converter . formatObjectToString ( objData , classData , objDefault ) ; } catch ( Exception ex ) { return null ; } }
Get this item from the map and convert it to the target class . Convert this object to an formatted string .
15,837
public static Properties mapToProperties ( Map < String , Object > map ) { Properties properties = new Properties ( ) ; Iterator < ? extends Map . Entry < ? , ? > > i = map . entrySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { Map . Entry < ? , ? > e = i . next ( ) ; properties . setProperty ( ( String ) e . getKey ( ) , ( e . getValue ( ) != null ) ? e . getValue ( ) . toString ( ) : DBConstants . BLANK ) ; } return properties ; }
Convert map to properties .
15,838
public static Map < String , Object > copyAppProperties ( Map < String , Object > properties , Map < String , Object > appProperties ) { if ( appProperties != null ) { appProperties = Utility . putAllIfNew ( new HashMap < String , Object > ( ) , appProperties ) ; if ( appProperties . get ( Params . APP_NAME ) != null ) appProperties . remove ( Params . APP_NAME ) ; if ( appProperties . get ( DBParams . FREEIFDONE ) != null ) appProperties . remove ( DBParams . FREEIFDONE ) ; if ( appProperties . get ( MessageConstants . MESSAGE_FILTER ) != null ) appProperties . remove ( MessageConstants . MESSAGE_FILTER ) ; } return Utility . putAllIfNew ( properties , appProperties ) ; }
Copy the application properties to this map .
15,839
public static RecordOwner getRecordOwner ( RecordOwnerParent recordOwnerParent ) { if ( recordOwnerParent instanceof RecordOwner ) return ( RecordOwner ) recordOwnerParent ; RecordOwner recordOwner = null ; if ( recordOwnerParent != null ) if ( recordOwnerParent . getTask ( ) != null ) if ( recordOwnerParent . getTask ( ) . getApplication ( ) != null ) recordOwner = ( RecordOwner ) recordOwnerParent . getTask ( ) . getApplication ( ) . getSystemRecordOwner ( ) ; return recordOwner ; }
Get a recordowner from this recordOwnerParent . This method does a deep search using the listeners and the database connections to find a recordowner .
15,840
public static String getServletPath ( Task task , String strServletParam ) { String strServletName = null ; if ( strServletParam == null ) strServletParam = Params . SERVLET ; if ( task != null ) strServletName = task . getProperty ( strServletParam ) ; if ( ( strServletName == null ) || ( strServletName . length ( ) == 0 ) ) { strServletName = Constants . DEFAULT_SERVLET ; if ( Params . XHTMLSERVLET . equalsIgnoreCase ( strServletParam ) ) strServletName = Constants . DEFAULT_XHTML_SERVLET ; } return strServletName ; }
Get the path to the target servlet .
15,841
public static String getSystemSuffix ( String suffix , String defaultSuffix ) { if ( defaultSuffix == null ) defaultSuffix = DEFAULT_SYSTEM_SUFFIX ; if ( suffix == null ) suffix = defaultSuffix ; for ( int i = suffix . length ( ) - 2 ; i > 0 ; i -- ) { if ( ! Character . isLetterOrDigit ( suffix . charAt ( i ) ) ) { suffix = suffix . substring ( i + 1 ) ; break ; } } return suffix ; }
Get the system suffix fix it and return it .
15,842
public static boolean onPrint ( Component component , boolean bPrintHeader ) { PrinterJob job = PrinterJob . getPrinterJob ( ) ; ScreenPrinter fapp = new ScreenPrinter ( component , bPrintHeader ) ; job . setPrintable ( fapp ) ; if ( job . printDialog ( ) ) fapp . printJob ( job ) ; return true ; }
Print the current screen .
15,843
public void printJob ( PrinterJob job ) { Frame frame = this . getFrame ( ) ; dialog = new PrintDialog ( frame , false ) ; dialog . pack ( ) ; if ( frame != null ) this . centerDialogInFrame ( dialog , frame ) ; Map < String , Object > map = new Hashtable < String , Object > ( ) ; map . put ( "job" , job ) ; SyncPageWorker thread = new SyncPageWorker ( dialog , map ) { public void runPageLoader ( ) { Thread swingPageLoader = new Thread ( "SwingPageLoader" ) { public void run ( ) { ( ( PrintDialog ) m_syncPage ) . setVisible ( true ) ; } } ; SwingUtilities . invokeLater ( swingPageLoader ) ; } public void afterPageDisplay ( ) { Thread swingPageLoader = new Thread ( "SwingPageLoader" ) { public void run ( ) { try { PrinterJob job = ( PrinterJob ) get ( "job" ) ; job . print ( ) ; } catch ( PrinterException ex ) { ex . printStackTrace ( ) ; } ( ( PrintDialog ) m_syncPage ) . setVisible ( false ) ; } } ; SwingUtilities . invokeLater ( swingPageLoader ) ; } } ; thread . start ( ) ; }
Print this job .
15,844
public int print ( Graphics g , PageFormat pageFormat , int pageIndex ) { Graphics2D g2d = ( Graphics2D ) g ; if ( firstTime ) { m_componentPrint = new ComponentPrint ( null ) ; m_componentPrint . surveyComponents ( m_component ) ; m_paperPrint = new PaperPrint ( null ) ; m_paperPrint . surveyPage ( pageFormat , g2d , m_bPrintHeader ) ; firstTime = false ; } int pageHeight = m_paperPrint . getPrintableHeight ( ) ; double scale = Math . min ( 1.0 , ( ( double ) m_paperPrint . getPrintableWidth ( ) / ( double ) m_componentPrint . getMaxComponentWidth ( ) ) ) ; m_paperPrint . setCurrentYLocation ( 0 ) ; m_componentPrint . setPageHeight ( ( int ) ( pageHeight / scale ) ) ; boolean pageDone = m_componentPrint . setCurrentYLocation ( pageIndex , 0 ) ; while ( ! pageDone ) { Component component = m_componentPrint . getCurrentComponent ( ) ; int componentCurrentYLocation = m_componentPrint . getCurrentYLocation ( ) ; int componentHeightOnPage = m_componentPrint . getComponentPageHeight ( ) ; if ( this . isCancelled ( ) ) return NO_SUCH_PAGE ; if ( component == null ) { if ( m_paperPrint . getCurrentYLocation ( ) == 0 ) return NO_SUCH_PAGE ; else break ; } if ( m_paperPrint . getCurrentYLocation ( ) == 0 ) { if ( m_bPrintHeader ) { m_paperPrint . printHeader ( g2d , m_componentPrint . getTitle ( ) ) ; m_paperPrint . printFooter ( g2d , "Page " + ( pageIndex + 1 ) ) ; } this . setDialogMessage ( "Printing page " + ( pageIndex + 1 ) ) ; } int xShift = m_paperPrint . getXOffset ( ) ; int yShift = m_paperPrint . getYOffset ( ) - ( int ) ( componentCurrentYLocation * scale ) ; g2d . setClip ( m_paperPrint . getXOffset ( ) , m_paperPrint . getYOffset ( ) , m_paperPrint . getPrintableWidth ( ) , ( int ) ( componentHeightOnPage * scale ) ) ; g2d . translate ( xShift , yShift ) ; g2d . scale ( scale , scale ) ; disableDoubleBuffering ( component ) ; component . paint ( g2d ) ; enableDoubleBuffering ( component ) ; g2d . scale ( 1 / scale , 1 / scale ) ; g2d . translate ( - xShift , - yShift ) ; m_paperPrint . addCurrentYLocation ( ( int ) ( componentHeightOnPage * scale ) ) ; pageDone = m_componentPrint . addCurrentYLocation ( componentHeightOnPage ) ; } return PAGE_EXISTS ; }
Print this page .
15,845
public static void disableDoubleBuffering ( Component c ) { RepaintManager currentManager = RepaintManager . currentManager ( c ) ; currentManager . setDoubleBufferingEnabled ( false ) ; }
Turn the cache off so printing will work .
15,846
public static void enableDoubleBuffering ( Component c ) { RepaintManager currentManager = RepaintManager . currentManager ( c ) ; currentManager . setDoubleBufferingEnabled ( true ) ; }
Turn the cache back on .
15,847
public void centerDialogInFrame ( Dialog dialog , Frame frame ) { dialog . setLocation ( frame . getX ( ) + ( frame . getWidth ( ) - dialog . getWidth ( ) ) / 2 , frame . getY ( ) + ( frame . getHeight ( ) - dialog . getHeight ( ) ) / 2 ) ; }
Center this dialog in the frame .
15,848
public void free ( ) { super . free ( ) ; m_baOut = null ; m_daOut = null ; m_baIn = null ; m_daIn = null ; }
Release the objects connected to this buffer .
15,849
public void resetPosition ( ) { try { if ( m_daIn != null ) m_daIn . reset ( ) ; else if ( m_baOut != null ) { byte [ ] byInput = m_baOut . toByteArray ( ) ; this . setPhysicalData ( byInput ) ; } super . resetPosition ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } }
Set the position to the start for GetXXXX methods .
15,850
public Object getPhysicalData ( ) { if ( m_baOut == null ) { if ( m_baIn == null ) return null ; m_baIn . reset ( ) ; int iLen = m_baIn . available ( ) ; byte [ ] rgby = new byte [ iLen ] ; m_baIn . read ( rgby , 0 , iLen ) ; return rgby ; } return m_baOut . toByteArray ( ) ; }
Get the physical data that this Buffer uses . You must override this method .
15,851
private void addEntries ( final FileSystem zipFs ) throws IOException { for ( Map . Entry < String , URL > entry : contentMap . entrySet ( ) ) { final Path pathToFile = zipFs . getPath ( entry . getKey ( ) ) ; final URL resource = entry . getValue ( ) ; addResource ( pathToFile , resource ) ; } }
Adds the entries to the zip file that have been defined by the builder .
15,852
private FileSystem newZipFileSystem ( final File file ) throws IOException { final Map < String , String > env = new HashMap < > ( ) ; env . put ( "create" , "true" ) ; return newFileSystem ( URI . create ( "jar:" + file . toURI ( ) ) , env ) ; }
Creates a new zip file and exposes the zip file as a filesystem to which paths and files can be added .
15,853
private void addResource ( final Path pathToFile , final URL resource ) throws IOException { if ( resource == null ) { addFolder ( pathToFile ) ; } else { addEntry ( pathToFile , resource ) ; } }
Adds a resource respectively it s content to the filesystem at the position specified by the pathToFile
15,854
private void addEntry ( final Path pathToFile , final URL resource ) throws IOException { final Path parent = pathToFile . getParent ( ) ; if ( parent != null ) { addFolder ( parent ) ; } try ( InputStream inputStream = resource . openStream ( ) ) { Files . copy ( inputStream , pathToFile ) ; } }
Creates an entry under the specifeid path with the content from the provided resource .
15,855
public void handleGet ( HttpRequest request , HttpResponse response ) throws HttpException , IOException { String uri = request . getRequestLine ( ) . getUri ( ) ; LOG . debug ( "uri {}" , uri ) ; try { ResponseUpdater ru = this . findResponseUpdater ( request ) ; LOG . debug ( "request updater {}" , ru ) ; ru . update ( response ) ; } catch ( IllegalStateException t ) { LOG . error ( "Cannot handle request" , t ) ; throw new HttpException ( "Cannot handle request" , t ) ; } }
Handles GET requests by calling response updater based on uri pattern .
15,856
private ResponseUpdater findResponseUpdater ( final HttpRequest request ) throws HttpException { ResponseUpdater updater = this . responseUpdaterSet . stream ( ) . filter ( ru -> ru . matches ( request ) ) . findFirst ( ) . get ( ) ; if ( updater == null ) { throw new HttpException ( "cannot find correpsonding response updater" ) ; } else { return updater ; } }
Finds the first ResponseUpdater by url pattern match .
15,857
public static String getParameter ( HttpRequest request , String name ) throws URISyntaxException { NameValuePair nv = URLEncodedUtils . parse ( new URI ( request . getRequestLine ( ) . getUri ( ) ) , "UTF-8" ) . stream ( ) . filter ( param -> param . getName ( ) . equals ( name ) ) . findFirst ( ) . get ( ) ; if ( nv == null ) { return null ; } return nv . getValue ( ) ; }
Gets parameter value of request line .
15,858
public int getChildCount ( ) { if ( ! m_bHasLoaded ) { NodeData data = ( NodeData ) this . getUserObject ( ) ; if ( ( data == null ) || ( ! data . isLeaf ( ) ) ) this . loadChildren ( ) ; } return super . getChildCount ( ) ; }
If hasLoaded is false meaning the children have not yet been loaded loadChildren is messaged and super is messaged for the return value .
15,859
protected void loadChildren ( ) { DynamicTreeNode newNode ; NodeData dataParent = ( NodeData ) this . getUserObject ( ) ; FieldList fieldList = dataParent . makeRecord ( ) ; FieldTable fieldTable = fieldList . getTable ( ) ; m_fNameCount = 0 ; try { fieldTable . close ( ) ; while ( fieldTable . next ( ) != null ) { String objID = fieldList . getField ( 0 ) . toString ( ) ; String strDescription = fieldList . getField ( 3 ) . toString ( ) ; NodeData data = new NodeData ( dataParent . getBaseApplet ( ) , dataParent . getRemoteSession ( ) , strDescription , objID , dataParent . getSubRecordClassName ( ) ) ; newNode = new DynamicTreeNode ( data ) ; this . insert ( newNode , ( int ) m_fNameCount ) ; m_fNameCount ++ ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } m_bHasLoaded = true ; }
Messaged the first time getChildCount is messaged . Creates children with random names from names .
15,860
public static void zipFiles ( final ZipFile zipFile4j , final File ... toAdd ) throws ZipException { zipFiles ( zipFile4j , Zip4jConstants . COMP_DEFLATE , Zip4jConstants . DEFLATE_LEVEL_NORMAL , toAdd ) ; }
Adds a file or several files to the given zip file with the parameters Zip4jConstants . COMP_DEFLATE for the compression method and Zip4jConstants . DEFLATE_LEVEL_NORMAL as the compression level .
15,861
public static void zipFiles ( final ZipFile zipFile4j , final int compressionMethod , final int compressionLevel , final File ... toAdd ) throws ZipException { final ZipParameters parameters = new ZipParameters ( ) ; parameters . setCompressionMethod ( compressionMethod ) ; parameters . setCompressionLevel ( compressionLevel ) ; zipFiles ( zipFile4j , parameters , toAdd ) ; }
Adds a file or several files to the given zip file with the given parameters for the compression method and the compression level .
15,862
public static Record getRecordFromDescription ( BaseField field , String strDesc ) { Record recSecond = ( ( ReferenceField ) field ) . getReferenceRecord ( ) ; return BaseFixData . getRecordFromDescription ( strDesc , null , recSecond ) ; }
GetRecordFromDescription Method .
15,863
public static boolean checkAbreviations ( String string , int i ) { for ( int index = 0 ; index < ABREVIATIONS . length ; index ++ ) { if ( ABREVIATIONS [ index ] . length ( ) > 1 ) if ( string . charAt ( i ) == ABREVIATIONS [ index ] . charAt ( 0 ) ) if ( string . length ( ) > i + 1 ) if ( string . charAt ( i + 1 ) == ABREVIATIONS [ index ] . charAt ( 1 ) ) if ( string . length ( ) > i + 2 ) if ( string . charAt ( i + 2 ) == ABREVIATIONS [ index ] . charAt ( 2 ) ) return true ; } for ( int index = 0 ; index < ABREVIATIONS . length ; index ++ ) { if ( ABREVIATIONS [ index ] . length ( ) > 2 ) if ( i > 0 ) if ( string . charAt ( i - 1 ) == ABREVIATIONS [ index ] . charAt ( 0 ) ) if ( string . charAt ( i ) == ABREVIATIONS [ index ] . charAt ( 1 ) ) if ( string . length ( ) > i + 1 ) if ( string . charAt ( i + 1 ) == ABREVIATIONS [ index ] . charAt ( 2 ) ) return true ; } return false ; }
CheckAbreviations Method .
15,864
public String getProperty ( String strName ) { Record recUserRegistration = this . getUserRegistration ( ) ; return ( ( PropertiesField ) recUserRegistration . getField ( UserRegistrationModel . PROPERTIES ) ) . getProperty ( strName ) ; }
Get the value associated with this key .
15,865
public ConstructorFilterBuilder isDefault ( ) { add ( new NegationConstructorFilter ( new ModifierConstructorFilter ( Modifier . PUBLIC & Modifier . PROTECTED & Modifier . PRIVATE ) ) ) ; return this ; }
Adds a filter for default access constructors only .
15,866
public ConstructorFilter build ( ) { if ( filters . isEmpty ( ) ) { throw new IllegalStateException ( "No filter specified." ) ; } if ( filters . size ( ) == 1 ) { return filters . get ( 0 ) ; } ConstructorFilter [ ] methodFilters = new ConstructorFilter [ filters . size ( ) ] ; filters . toArray ( methodFilters ) ; return new ConstructorFilterList ( methodFilters ) ; }
Returns the ConstructorFilter built .
15,867
public static < T > DataKey < T > create ( String name , Class < T > dataClass ) { return create ( name , dataClass , true , null ) ; }
creates a data key with the given name and type . This data key allows for null values and sets no default value .
15,868
public static < T > DataKey < T > create ( String name , Class < T > dataClass , boolean allowNull , T defaultValue ) { if ( dataClass . isPrimitive ( ) ) { throw new IllegalArgumentException ( "primitives are not supported - please use their corresponding wrappers" ) ; } if ( dataClass . isArray ( ) ) { throw new IllegalArgumentException ( "arrays are not supported - please use a list with their corresponding wrapper" ) ; } return new DataKey ( name , dataClass , allowNull , defaultValue ) ; }
creates a data key with the given name data type the given permission to allow null values and a default value . You can set the default value to null to signal that there should be no default value .
15,869
public static < T > DataKey < T > create ( String name , GenericType < T > genType , boolean allowNull ) { return create ( name , genType . getRawType ( ) , allowNull , null ) ; }
creates a data key with the given name data type and the given permission to allow null values . No default value will be specified .
15,870
public void logAddRecord ( Rec record , int iSystemID ) { try { this . getTable ( ) . setProperty ( DBParams . SUPRESSREMOTEDBMESSAGES , DBConstants . TRUE ) ; this . getTable ( ) . getDatabase ( ) . setProperty ( DBParams . MESSAGES_TO_REMOTE , DBConstants . FALSE ) ; this . addNew ( ) ; this . getField ( AnalysisLog . SYSTEM_ID ) . setValue ( iSystemID ) ; this . getField ( AnalysisLog . OBJECT_ID ) . setValue ( Debug . getObjectID ( record , false ) ) ; this . getField ( AnalysisLog . CLASS_NAME ) . setString ( Debug . getClassName ( record ) ) ; this . getField ( AnalysisLog . DATABASE_NAME ) . setString ( record . getDatabaseName ( ) ) ; ( ( DateTimeField ) this . getField ( AnalysisLog . INIT_TIME ) ) . setValue ( DateTimeField . currentTime ( ) ) ; this . getField ( AnalysisLog . RECORD_OWNER ) . setString ( Debug . getClassName ( ( ( Record ) record ) . getRecordOwner ( ) ) ) ; this . getField ( AnalysisLog . STACK_TRACE ) . setString ( Debug . getStackTrace ( ) ) ; this . add ( ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } }
Log that this record has been added . Call this from the end of record . init
15,871
public void logRemoveRecord ( Rec record , int iSystemID ) { try { this . getTable ( ) . setProperty ( DBParams . SUPRESSREMOTEDBMESSAGES , DBConstants . TRUE ) ; this . getTable ( ) . getDatabase ( ) . setProperty ( DBParams . MESSAGES_TO_REMOTE , DBConstants . FALSE ) ; this . addNew ( ) ; this . getField ( AnalysisLog . SYSTEM_ID ) . setValue ( iSystemID ) ; this . getField ( AnalysisLog . OBJECT_ID ) . setValue ( Debug . getObjectID ( record , true ) ) ; this . setKeyArea ( AnalysisLog . OBJECT_ID_KEY ) ; if ( this . seek ( null ) ) { this . edit ( ) ; ( ( DateTimeField ) this . getField ( AnalysisLog . FREE_TIME ) ) . setValue ( DateTimeField . currentTime ( ) ) ; if ( this . getField ( AnalysisLog . RECORD_OWNER ) . isNull ( ) ) this . getField ( AnalysisLog . RECORD_OWNER ) . setString ( Debug . getClassName ( ( ( Record ) record ) . getRecordOwner ( ) ) ) ; this . set ( ) ; } else { } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } }
Log that this record has been freed . Call this from the end of record . free
15,872
public int doSubScriptCommands ( Script recScript , Map < String , Object > properties ) { int iErrorCode = DBConstants . NORMAL_RETURN ; Script recSubScript = recScript . getSubScript ( ) ; try { recSubScript . close ( ) ; while ( recSubScript . hasNext ( ) ) { recSubScript . next ( ) ; iErrorCode = this . doCommand ( recSubScript , properties ) ; if ( iErrorCode != DBConstants . NORMAL_RETURN ) return iErrorCode ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } return iErrorCode ; }
DoSubScriptCommands Method .
15,873
public int doRunCommand ( Script recScript , Map < String , Object > properties ) { ProcessRunnerTask processRunner = new ProcessRunnerTask ( this . getTask ( ) . getApplication ( ) , null , null ) ; processRunner . setProperties ( properties ) ; processRunner . run ( ) ; return DBConstants . NORMAL_RETURN ; }
DoRunCommand Method .
15,874
public int doSeekCommand ( Script recScript , Map < String , Object > properties ) { Record record = recScript . getTargetRecord ( properties , DBParams . RECORD ) ; if ( record == null ) return DBConstants . ERROR_RETURN ; for ( int iKeySeq = 0 ; iKeySeq < record . getKeyAreaCount ( ) ; iKeySeq ++ ) { String strKeyFieldName = record . getKeyArea ( iKeySeq ) . getKeyField ( 0 ) . getField ( DBConstants . FILE_KEY_AREA ) . getFieldName ( false , false ) ; if ( recScript . getProperty ( strKeyFieldName ) != null ) { record . setKeyArea ( iKeySeq ) ; record . getField ( strKeyFieldName ) . setString ( recScript . getProperty ( strKeyFieldName ) ) ; try { if ( record . seek ( null ) ) return DBConstants . NORMAL_RETURN ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } } } return DBConstants . ERROR_RETURN ; }
DoSeekCommand Method .
15,875
public int doCopyRecordsCommand ( Script recScript , Map < String , Object > properties ) { int iErrorCode = DBConstants . NORMAL_RETURN ; Record record = recScript . getTargetRecord ( properties , DBParams . RECORD ) ; if ( record == null ) return DBConstants . ERROR_RETURN ; if ( properties . get ( PARENT_RECORD ) != null ) { Record recParent = recScript . getTargetRecord ( properties , PARENT_RECORD ) ; if ( recParent != null ) record . addListener ( new SubFileFilter ( recParent ) ) ; } Record recDestination = recScript . getTargetRecord ( properties , Script . DESTINATION_RECORD ) ; try { record . close ( ) ; while ( record . hasNext ( ) ) { record . next ( ) ; recDestination . addNew ( ) ; recDestination . setAutoSequence ( false ) ; iErrorCode = this . doSubScriptCommands ( recScript , properties ) ; if ( iErrorCode != DBConstants . NORMAL_RETURN ) return iErrorCode ; if ( recDestination . getCounterField ( ) . isNull ( ) ) recDestination . setAutoSequence ( true ) ; try { recDestination . add ( ) ; } catch ( DBException ex ) { } } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } return DONT_READ_SUB_SCRIPT ; }
DoCopyRecordsCommand Method .
15,876
public int doCopyFieldsCommand ( Script recScript , Map < String , Object > properties ) { int iErrorCode = DBConstants . NORMAL_RETURN ; Record recSource = recScript . getTargetRecord ( properties , DBParams . RECORD ) ; if ( recSource == null ) return DBConstants . ERROR_RETURN ; Record recDestination = recScript . getTargetRecord ( properties , Script . DESTINATION_RECORD ) ; if ( recDestination == null ) return DBConstants . ERROR_RETURN ; String strSourceField = ( String ) properties . get ( Script . SOURCE_PARAM ) ; String strDestField = ( String ) properties . get ( Script . DESTINATION_PARAM ) ; if ( strDestField == null ) strDestField = strSourceField ; if ( strSourceField == null ) return DBConstants . ERROR_RETURN ; BaseField fldSource = recSource . getField ( strSourceField ) ; BaseField fldDest = recDestination . getField ( strDestField ) ; if ( ( fldSource == null ) || ( fldDest == null ) ) return DBConstants . ERROR_RETURN ; iErrorCode = fldDest . moveFieldToThis ( fldSource ) ; return iErrorCode ; }
DoCopyFieldsCommand Method .
15,877
public int doCopyDataCommand ( Script recScript , Map < String , Object > properties ) { String strURL = ( String ) properties . get ( Script . SOURCE_PARAM ) ; String strDest = ( String ) properties . get ( Script . DESTINATION_PARAM ) ; if ( ( strURL != null ) && ( strDest != null ) ) Utility . transferURLStream ( strURL , strDest ) ; return DBConstants . NORMAL_RETURN ; }
DoCopyDataCommand Method .
15,878
public void runDetail ( ) { Record recReplication = this . getMainRecord ( ) ; if ( ( recReplication . getEditMode ( ) == DBConstants . EDIT_NONE ) || ( recReplication . getEditMode ( ) == DBConstants . EDIT_ADD ) ) recReplication . getField ( Script . ID ) . setValue ( 0 ) ; String strSourcePath = "" ; String strDestPath = "" ; this . processDetail ( recReplication , strSourcePath , strDestPath ) ; }
RunDetail Method .
15,879
public boolean processDetail ( Record parent , String strSourcePath , String strDestPath ) { boolean bSubsExist = false ; String strName ; Script recReplication = new Script ( this ) ; recReplication . setKeyArea ( Script . PARENT_FOLDER_ID_KEY ) ; recReplication . addListener ( new SubFileFilter ( parent ) ) ; try { strName = parent . getField ( Script . NAME ) . toString ( ) ; while ( recReplication . hasNext ( ) ) { recReplication . next ( ) ; bSubsExist = true ; strName = recReplication . getField ( Script . NAME ) . toString ( ) ; String strSource = recReplication . getField ( Script . SOURCE_PARAM ) . toString ( ) ; String strDestination = recReplication . getField ( Script . DESTINATION_PARAM ) . toString ( ) ; strSource = strSourcePath + strSource ; strDestination = strDestPath + strDestination ; this . processDetail ( recReplication , strSource , strDestination ) ; } recReplication . close ( ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } if ( strSourcePath . length ( ) > 0 ) if ( Character . isLetterOrDigit ( strSourcePath . charAt ( strSourcePath . length ( ) - 1 ) ) ) { System . out . println ( "From: " + strSourcePath + " To: " + strDestPath ) ; File fileSource = new File ( strSourcePath ) ; File fileDest = new File ( strDestPath ) ; if ( fileSource . exists ( ) ) { if ( fileDest . exists ( ) ) fileDest . delete ( ) ; else System . out . println ( "Target doesn't exist: " + strSourcePath ) ; try { FileInputStream inStream = new FileInputStream ( fileSource ) ; FileOutputStream outStream = new FileOutputStream ( fileDest ) ; org . jbundle . jbackup . util . Util . copyStream ( inStream , outStream ) ; } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } } return bSubsExist ; }
ProcessDetail Method .
15,880
public BaseMessage convertToThinMessage ( ) { int iChangeType = ( ( RecordMessageHeader ) this . getMessageHeader ( ) ) . getRecordMessageType ( ) ; Object data = this . getData ( ) ; BaseMessage messageTableUpdate = null ; { BaseMessageHeader messageHeader = new SessionMessageHeader ( this . getMessageHeader ( ) . getQueueName ( ) , this . getMessageHeader ( ) . getQueueType ( ) , null , this ) ; messageTableUpdate = new MapMessage ( messageHeader , data ) ; messageTableUpdate . put ( MessageConstants . MESSAGE_TYPE_PARAM , Integer . toString ( iChangeType ) ) ; } return messageTableUpdate ; }
If you are sending a thick message to a thin client convert it first . Since BaseMessage is already so conversion is necessary ... return this message .
15,881
public Object getImageIcon ( Object value ) { int index = 0 ; if ( value instanceof Integer ) index = ( ( Integer ) value ) . intValue ( ) ; else if ( value != null ) { try { index = Integer . parseInt ( value . toString ( ) ) ; } catch ( NumberFormatException ex ) { } } return this . getIcon ( index ) ; }
Get the icon at this location .
15,882
public void addIcon ( Object icon , int iIndex ) { m_rgIcons [ iIndex ] = icon ; if ( this . getScreenFieldView ( ) . getControl ( ) instanceof ExtendedComponent ) ( ( ExtendedComponent ) this . getScreenFieldView ( ) . getControl ( ) ) . addIcon ( icon , iIndex ) ; }
Add an Icon to the Icon list .
15,883
private void copy ( Expression expression ) { this . operator = expression . operator ; this . elementsArray = expression . elementsArray ; this . elements = expression . elements ; }
Copies contents of given expression into this one .
15,884
private boolean addStatement ( StringBuffer statementBuffer ) { if ( statementBuffer . length ( ) > 0 ) { elements . add ( new Predicate ( statementBuffer . toString ( ) ) ) ; elementsArray = elements . toArray ( ) ; statementBuffer . delete ( 0 , statementBuffer . length ( ) ) ; return true ; } return false ; }
Adds a new statement to this Expression s elements . Clears the statementBuffer .
15,885
public void printHtmlControlDesc ( PrintWriter out , String strFieldDesc , int iHtmlAttributes ) { if ( ( iHtmlAttributes & HtmlConstants . HTML_ADD_DESC_COLUMN ) != 0 ) out . println ( "<td align=\"right\">" + strFieldDesc + "</td>" ) ; }
display this field s description in html format .
15,886
public void init ( BaseField field , Record record , String keyAreaName , boolean bCloseOnFree , boolean bUpdateRecord , boolean bAllowNull ) { super . init ( field ) ; m_record = record ; this . keyAreaName = keyAreaName ; m_keyField = null ; m_bCloseOnFree = bCloseOnFree ; m_bUpdateRecord = bUpdateRecord ; m_bAllowNull = bAllowNull ; m_bMoveBehavior = false ; m_record . addListener ( new FileRemoveBOnCloseHandler ( this ) ) ; if ( m_bUpdateRecord ) { if ( ( m_record . getOpenMode ( ) & DBConstants . LOCK_TYPE_MASK ) == 0 ) if ( m_record . getTask ( ) != null ) m_record . setOpenMode ( m_record . getOpenMode ( ) | m_record . getTask ( ) . getDefaultLockType ( m_record . getDatabaseType ( ) ) ) ; } else m_record . setOpenMode ( DBConstants . OPEN_READ_ONLY ) ; }
Initialize this listener .
15,887
public void setOwner ( ListenerOwner owner ) { super . setOwner ( owner ) ; if ( owner != null ) { MoveOnValidHandler moveBehavior = null ; m_record . setOpenMode ( m_record . getOpenMode ( ) | DBConstants . OPEN_CACHE_RECORDS ) ; m_bMoveBehavior = false ; ReadSecondaryHandler listenerDup = ( ReadSecondaryHandler ) this . getOwner ( ) . getListener ( this . getClass ( ) ) ; while ( ( listenerDup != this ) && ( listenerDup != null ) ) { if ( listenerDup . getRecord ( ) == this . getRecord ( ) ) if ( listenerDup . getActualKeyArea ( ) == this . getActualKeyArea ( ) ) { listenerDup . setRecord ( null ) ; this . getOwner ( ) . removeListener ( listenerDup , true ) ; break ; } listenerDup = ( ReadSecondaryHandler ) listenerDup . getListener ( this . getClass ( ) ) ; } this . fieldChanged ( DBConstants . DISPLAY , DBConstants . READ_MOVE ) ; if ( owner instanceof ReferenceField ) { m_keyField = m_record . getKeyArea ( keyAreaName ) . getField ( DBConstants . MAIN_KEY_FIELD ) ; moveBehavior = new MoveOnValidHandler ( ( ( BaseField ) owner ) , m_keyField , null , true , true ) ; m_keyField = null ; } else { MainReadOnlyHandler listener = new MainReadOnlyHandler ( keyAreaName ) ; m_keyField = m_record . getKeyArea ( keyAreaName ) . getField ( DBConstants . MAIN_KEY_FIELD ) ; m_keyField . addListener ( listener ) ; moveBehavior = new MoveOnValidHandler ( ( ( BaseField ) owner ) , m_keyField , null , false , true ) ; } m_record . addListener ( moveBehavior ) ; } else { if ( m_bCloseOnFree ) if ( this . getDependentListener ( ) != null ) { this . setDependentListener ( null ) ; if ( m_record != null ) m_record . free ( ) ; } m_record = null ; m_keyField = null ; } }
Set the field that owns this listener . This method adds the methods that allow a record to read itself if the main key field is changed .
15,888
public MoveOnValidHandler addFieldPair ( BaseField fldDest , BaseField fldSource , boolean bMoveToDependent , boolean bMoveBackOnChange , Converter convCheckMark , Converter convBackconvCheckMark ) { MoveOnValidHandler moveBehavior = null ; if ( convCheckMark != null ) if ( convCheckMark . getField ( ) != null ) { CheckMoveHandler listener = new CheckMoveHandler ( fldDest , fldSource ) ; ( ( BaseField ) convCheckMark . getField ( ) ) . addListener ( listener ) ; } if ( bMoveToDependent ) { m_bMoveBehavior = true ; moveBehavior = new MoveOnValidHandler ( fldDest , fldSource , convCheckMark , true , true ) ; m_record . addListener ( moveBehavior ) ; } if ( bMoveBackOnChange ) { CopyFieldHandler listener = new CopyFieldHandler ( fldSource , convBackconvCheckMark ) ; fldDest . addListener ( listener ) ; } return moveBehavior ; }
Add a field source and dest .
15,889
public MoveOnValidHandler addFieldSeqPair ( int iFieldSeq ) { m_bMoveBehavior = true ; MoveOnValidHandler moveBehavior = new MoveOnValidHandler ( this . getOwner ( ) . getRecord ( ) . getField ( iFieldSeq ) ) ; m_record . addListener ( moveBehavior ) ; return moveBehavior ; }
This method is specifically for making sure a handle is moved to this field on valid . The field must be a ReferenceField .
15,890
public MoveOnValidHandler addFieldSeqPair ( int iDestFieldSeq , int iSourceFieldSeq , boolean bMoveToDependent , boolean bMoveBackOnChange , Converter convCheckMark , Converter convBackconvCheckMark ) { return this . addFieldPair ( this . getOwner ( ) . getRecord ( ) . getField ( iDestFieldSeq ) , m_record . getField ( iSourceFieldSeq ) , bMoveToDependent , bMoveBackOnChange , convCheckMark , convBackconvCheckMark ) ; }
Add the set of fields that will move on a valid record .
15,891
public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { int iErrorCode = DBConstants . NORMAL_RETURN ; if ( m_bUpdateRecord ) if ( m_record . isModified ( ) ) { try { if ( m_record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) m_record . set ( ) ; else if ( m_record . getEditMode ( ) == Constants . EDIT_ADD ) m_record . add ( ) ; } catch ( DBException ex ) { return ex . getErrorCode ( ) ; } } if ( m_bMoveBehavior ) if ( m_keyField != null ) if ( ( iMoveMode == DBConstants . INIT_MOVE ) || ( iMoveMode == DBConstants . READ_MOVE ) ) m_keyField . setModified ( true ) ; if ( m_keyField == null ) { int iHandleType = DBConstants . BOOKMARK_HANDLE ; iErrorCode = DBConstants . NORMAL_RETURN ; try { Object handle = this . getOwner ( ) . getData ( ) ; if ( ( handle == null ) || ( ( this . getOwner ( ) instanceof ReferenceField ) && ( ( ( Integer ) handle ) . intValue ( ) == 0 ) ) ) { if ( ( m_bAllowNull ) || ( iMoveMode != DBConstants . SCREEN_MOVE ) ) m_record . handleNewRecord ( DBConstants . DISPLAY ) ; else iErrorCode = DBConstants . KEY_NOT_FOUND ; } else { if ( m_record . setHandle ( handle , iHandleType ) == null ) iErrorCode = DBConstants . KEY_NOT_FOUND ; else { for ( int i = 0 ; i < m_record . getFieldCount ( ) ; i ++ ) { m_record . getField ( i ) . handleFieldChanged ( bDisplayOption , DBConstants . READ_MOVE ) ; } } } } catch ( DBException ex ) { iErrorCode = ex . getErrorCode ( ) ; } } else iErrorCode = m_keyField . moveFieldToThis ( this . getOwner ( ) , DBConstants . DISPLAY , DBConstants . SCREEN_MOVE ) ; return iErrorCode ; }
The Field has Changed . Read the secondary file .
15,892
private void pack ( String data ) { byte [ ] bytes = data . getBytes ( Constants . UTF8 ) ; buffer . put ( getLengthDescriptor ( bytes . length ) ) ; buffer . put ( bytes ) ; }
Pack an argument and place in buffer .
15,893
public void addParameters ( RPCParameters parameters ) { for ( int i = 0 ; i < parameters . getCount ( ) ; i ++ ) { RPCParameter parameter = parameters . get ( i ) ; if ( parameter . hasData ( ) != HasData . NONE ) { addParameter ( Integer . toString ( i + 1 ) , parameter ) ; } } }
Adds RPC parameters to the request .
15,894
public void addParameters ( Map < String , Object > parameters , boolean suppressNull ) { for ( String name : parameters . keySet ( ) ) { Object value = parameters . get ( name ) ; if ( ! suppressNull || value != null ) { addParameter ( name , value ) ; } } }
Adds map - based parameters to the request .
15,895
public void addParameter ( String name , String sub , Object data ) { pack ( name ) ; pack ( sub ) ; pack ( BrokerUtil . toString ( data ) ) ; }
Adds a subscripted parameter to the request .
15,896
public void addParameter ( String name , RPCParameter parameter ) { for ( String subscript : parameter ) { addParameter ( name , subscript , parameter . get ( subscript ) ) ; } }
Adds an RPC parameter to the request .
15,897
public void addParameter ( String name , Object value ) { String subscript = "" ; if ( name . contains ( "(" ) ) { String [ ] pcs = name . split ( "\\(" , 2 ) ; name = pcs [ 0 ] ; subscript = pcs [ 1 ] ; if ( subscript . endsWith ( ")" ) ) { subscript = subscript . substring ( 0 , subscript . length ( ) - 1 ) ; } } addParameter ( name , subscript , value ) ; }
Adds a parameter to the request .
15,898
public void write ( DataOutputStream stream , byte sequenceId ) throws IOException { this . sequenceId = sequenceId ; stream . write ( PREAMBLE ) ; stream . write ( sequenceId ) ; stream . write ( action . getCode ( ) ) ; stream . write ( buffer . toArray ( ) ) ; stream . write ( Constants . EOD ) ; }
Write request components to output stream .
15,899
public static final < T extends Recyclable > T get ( Class < T > cls ) { return get ( cls , null ) ; }
Returns new or recycled uninitialized object .