idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
16,000
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public void runThread ( Object objJobDef ) { if ( objJobDef instanceof Task ) { Task task = ( Task ) objJobDef ; if ( task . getApplication ( ) == null ) task . initTask ( this . getApplication ( ) , null ) ; task . run ( ) ; } else if ( ( objJobDef instanceof String ) || ( objJobDef instanceof Properties ) ) { String strJobDef = null ; Map < String , Object > properties = null ; if ( objJobDef instanceof String ) { strJobDef = ( String ) objJobDef ; properties = new Hashtable < String , Object > ( ) ; Util . parseArgs ( properties , strJobDef ) ; } if ( objJobDef instanceof Properties ) properties = ( Map ) objJobDef ; if ( properties . get ( "webStartPropertiesFile" ) != null ) properties = this . addPropertiesFile ( properties ) ; String strClass = ( String ) properties . get ( Param . TASK ) ; if ( strClass == null ) strClass = ( String ) properties . get ( Param . APPLET ) ; Object job = ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( strClass ) ; if ( job instanceof Task ) { ( ( Task ) job ) . initTask ( this . getApplication ( ) , properties ) ; ( ( Task ) job ) . run ( ) ; } else if ( job instanceof Applet ) { System . out . println ( "********** Applet task type needs to be fixed *********" ) ; } else if ( job instanceof Runnable ) { ( ( Runnable ) job ) . run ( ) ; } else Util . getLogger ( ) . warning ( "Illegal job type passed to TaskScheduler: " + job ) ; } else if ( objJobDef instanceof Runnable ) ( ( Runnable ) objJobDef ) . run ( ) ; else Util . getLogger ( ) . warning ( "Error: Illegal job type" ) ; }
Start this task running in this thread .
16,001
public static SyncWorker startPageWorker ( SyncPage syncPage , SyncNotify syncNotify , Runnable swingPageLoader , Map < String , Object > map , boolean bManageCursor ) { SyncWorker syncWorker = ( SyncWorker ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( JAVA_WORKER ) ; if ( syncWorker == null ) syncWorker = ( SyncWorker ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( ANDROID_WORKER ) ; if ( syncWorker != null ) { syncWorker . init ( syncPage , syncNotify , swingPageLoader , map , bManageCursor ) ; syncWorker . start ( ) ; } else Util . getLogger ( ) . severe ( "SyncWorker does not exist!" ) ; return syncWorker ; }
Start a task that calls the syncNotify done method when the screen is done displaying . This class is a platform - neutral implementation of SwinSyncPageWorker that guarantees a page has displayed before doing a compute - intensive task .
16,002
private FieldTextBuilder binaryOperation ( final String operator , final FieldText fieldText ) { Validate . isTrue ( fieldText != this ) ; if ( fieldText instanceof FieldTextBuilder ) { return binaryOp ( operator , ( FieldTextBuilder ) fieldText ) ; } if ( componentCount == 0 ) { fieldTextString . append ( fieldText . toString ( ) ) ; if ( fieldText . size ( ) > 1 ) { lastOperator = "" ; } } else { addOperator ( operator ) ; if ( fieldText . size ( ) == 1 ) { fieldTextString . append ( fieldText . toString ( ) ) ; } else { fieldTextString . append ( '(' ) . append ( fieldText . toString ( ) ) . append ( ')' ) ; } } componentCount += fieldText . size ( ) ; not = false ; return this ; }
Does the work for the OR AND XOR and WHEN methods .
16,003
private FieldTextBuilder binaryOp ( final String operator , final FieldTextBuilder fieldText ) { if ( componentCount == 0 ) { fieldTextString . append ( fieldText . fieldTextString ) ; lastOperator = fieldText . lastOperator ; not = fieldText . not ; componentCount = fieldText . componentCount ; } else { addOperator ( operator ) ; if ( fieldText . lastOperator == null || fieldText . lastOperator . equals ( operator ) || fieldText . not ) { fieldTextString . append ( fieldText . toString ( ) ) ; } else { fieldTextString . append ( '(' ) . append ( fieldText . toString ( ) ) . append ( ')' ) ; } componentCount += fieldText . size ( ) ; not = false ; } return this ; }
Does the work for the OR AND and XOR methods in the optimized case where fieldText is a FieldTextBuilder .
16,004
private void addOperator ( final String operator ) { Validate . notNull ( operator ) ; if ( lastOperator == null ) { lastOperator = operator ; } if ( not ) { if ( componentCount == 1 ) { fieldTextString . insert ( 0 , "NOT+" ) ; } else { fieldTextString . insert ( 0 , "NOT(" ) . append ( ')' ) ; } } else if ( ! lastOperator . equals ( operator ) ) { fieldTextString . insert ( 0 , '(' ) . append ( ')' ) ; } lastOperator = operator ; fieldTextString . append ( '+' ) . append ( operator ) . append ( '+' ) ; }
The first section of the fieldtext manipulation process where the NOTs are handled and the operator is added are common to both binaryOp methods so this method saves us repeating the code .
16,005
public void init ( App app , Rec record , Map < String , Object > properties ) { m_app = app ; }
Creates new RmiSessionServer .
16,006
public static RemoteSessionServer startupServer ( Map < String , Object > properties ) { RemoteSessionServer remoteServer = null ; Utility . getLogger ( ) . info ( "Starting RemoteSession server" ) ; try { remoteServer = new RemoteSessionServer ( null , null , null ) ; } catch ( RemoteException ex ) { ex . printStackTrace ( ) ; } return remoteServer ; }
Start up the remote server .
16,007
public void shutdown ( ) { Environment env = ( ( BaseApplication ) m_app ) . getEnvironment ( ) ; if ( m_app != null ) m_app . free ( ) ; m_app = null ; if ( ClassServiceUtility . getClassService ( ) . getClassFinder ( null ) != null ) ClassServiceUtility . getClassService ( ) . getClassFinder ( null ) . shutdownService ( null , this ) ; if ( env != null ) env . freeIfDone ( ) ; }
Shutdown the server .
16,008
public void addListener ( final LifecycleStage lifecycleStage , final LifecycleListener lifecycleListener ) { if ( ! listeners . containsKey ( lifecycleStage ) ) { throw illegalStage ( lifecycleStage ) ; } listeners . get ( lifecycleStage ) . add ( lifecycleListener ) ; }
Adds a listener to a lifecycle stage .
16,009
public void executeNext ( ) { final LifecycleStage nextStage = getNextStage ( ) ; if ( nextStage == null ) { throw new IllegalStateException ( "Lifecycle already hit the final stage!" ) ; } execute ( nextStage ) ; }
Execute the next stage in the cycle .
16,010
public void execute ( final LifecycleStage lifecycleStage ) { List < LifecycleListener > lifecycleListeners = listeners . get ( lifecycleStage ) ; if ( lifecycleListeners == null ) { throw illegalStage ( lifecycleStage ) ; } log ( "Stage '%s' starting..." , lifecycleStage . getName ( ) ) ; if ( lifecycleStage . equals ( LifecycleStage . STOP_STAGE ) ) { lifecycleListeners = Lists . reverse ( lifecycleListeners ) ; } for ( final LifecycleListener listener : lifecycleListeners ) { listener . onStage ( lifecycleStage ) ; } log ( "Stage '%s' complete." , lifecycleStage . getName ( ) ) ; }
Execute a lifecycle stage .
16,011
protected void join ( final LifecycleStage lifecycleStage , final boolean cycle ) throws InterruptedException { Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { public void run ( ) { if ( cycle ) { AbstractLifecycle . this . executeTo ( lifecycleStage ) ; } else { AbstractLifecycle . this . execute ( lifecycleStage ) ; } } } ) ; Thread . currentThread ( ) . join ( ) ; }
Register a shutdown hook to execute the given stage on JVM shutdown and join against the current thread . This will block so there needs to be a another way to shut the current thread down .
16,012
public void setArguments ( Object ... arguments ) { Params . notNullOrEmpty ( arguments , "Arguments" ) ; this . arguments = arguments ; argumentsWriter = ClientEncoders . getInstance ( ) . getArgumentsWriter ( arguments ) ; }
Set remote method invocation actual parameters . Parameters order and types should be consistent with remote method signature .
16,013
public void setExceptions ( Class < ? > [ ] exceptions ) { for ( Class < ? > exception : exceptions ) { this . exceptions . add ( exception . getSimpleName ( ) ) ; } }
Set method exceptions list . This exceptions list is used by the logic that handle remote exception . It should be consistent with remote method signature .
16,014
private Object exec ( ) throws Exception { boolean exception = false ; try { return exec ( connection ) ; } catch ( Throwable t ) { log . dump ( String . format ( "Error processing HTTP-RMI |%s|." , connection . getURL ( ) ) , t ) ; exception = true ; throw t ; } finally { if ( exception || CONNECTION_CLOSE . equals ( connection . getHeaderField ( "Connection" ) ) ) { connection . disconnect ( ) ; } } }
Executes transaction and returns remote value . Takes care to disconnect connection if server response has close header ; also disconnect on any kind of error .
16,015
private Object exec ( HttpURLConnection connection ) throws Exception { connection . setConnectTimeout ( connectionTimeout ) ; connection . setReadTimeout ( readTimeout ) ; connection . setRequestMethod ( arguments == null ? "GET" : "POST" ) ; connection . setRequestProperty ( "User-Agent" , "j(s)-lib/1.9.3" ) ; connection . setRequestProperty ( "Accept" , "application/json, text/xml, application/octet-stream" ) ; connection . setRequestProperty ( "Pragma" , "no-cache" ) ; connection . setRequestProperty ( "Cache" , "no-cache" ) ; if ( System . getProperty ( "js.net.client.android" ) != null ) { connection . setRequestProperty ( "Connection" , "close" ) ; } if ( headers != null ) { for ( Map . Entry < String , String > entry : headers . entrySet ( ) ) { connection . setRequestProperty ( entry . getKey ( ) , entry . getValue ( ) ) ; } } String sessionCookie = sessionCookies . get ( connection . getURL ( ) ) ; if ( sessionCookie != null ) { connection . setRequestProperty ( "Cookie" , sessionCookie ) ; } if ( arguments != null ) { connection . setDoOutput ( true ) ; String contentType = argumentsWriter . getContentType ( ) ; if ( contentType != null ) { connection . setRequestProperty ( "Content-Type" , contentType ) ; } argumentsWriter . write ( connection . getOutputStream ( ) , arguments ) ; } int statusCode = connection . getResponseCode ( ) ; if ( statusCode != SC_OK && statusCode != SC_NO_CONTENT ) { onError ( statusCode ) ; } String cookies = connection . getHeaderField ( "Set-Cookie" ) ; if ( cookies != null ) { Matcher matcher = JSESSIONID_PATTERN . matcher ( cookies ) ; if ( matcher . find ( ) ) { sessionCookies . put ( connection . getURL ( ) , matcher . group ( 1 ) ) ; } } if ( Types . isVoid ( returnType ) ) { return null ; } if ( ! Types . isVoid ( returnType ) && connection . getContentLength ( ) == 0 ) { throw new BugError ( "Invalid HTTP-RMI transaction with |%s|. Expect return value of type |%s| but got empty response." , connection . getURL ( ) , returnType ) ; } ValueReader valueReader = ClientEncoders . getInstance ( ) . getValueReader ( connection ) ; try { return valueReader . read ( connection . getInputStream ( ) , returnType ) ; } catch ( IOException e ) { throw new BugError ( "Invalid HTTP-RMI transaction with |%s|. Response cannot be parsed to type |%s|. Cause: %s" , connection . getURL ( ) , returnType , e ) ; } }
Execute synchronous remote method invocation using given HTTP connection .
16,016
private void onError ( int statusCode ) throws Exception { switch ( statusCode ) { case SC_FORBIDDEN : throw new RmiException ( "Server refuses to process request |%s|. Common cause may be Tomcat filtering by remote address and this IP is not allowed." , connection . getURL ( ) ) ; case SC_UNAUTHORIZED : throw new RmiException ( "Attempt to access private remote method |%s| without authorization." , connection . getURL ( ) ) ; case SC_NOT_FOUND : throw new RmiException ( "Method |%s| not found. Check URL spelling, protocol unmatched or unrecognized extension." , connection . getURL ( ) ) ; case SC_SERVICE_UNAVAILABLE : throw new RmiException ( "Front-end HTTP server is up but back-end is down. HTTP-RMI transaction |%s| aborted." , connection . getURL ( ) ) ; case SC_BAD_REQUEST : if ( isJSON ( connection . getContentType ( ) ) ) { throw ( BusinessException ) readJsonObject ( connection . getErrorStream ( ) , BusinessException . class ) ; } break ; case SC_INTERNAL_SERVER_ERROR : if ( isJSON ( connection . getContentType ( ) ) ) { RemoteException remoteException = ( RemoteException ) readJsonObject ( connection . getErrorStream ( ) , RemoteException . class ) ; log . error ( "HTTP-RMI error on |%s|: %s" , connection . getURL ( ) , remoteException ) ; if ( exceptions . contains ( getRemoteExceptionCause ( remoteException ) ) ) { Class < ? extends Throwable > cause = Classes . forOptionalName ( remoteException . getCause ( ) ) ; if ( cause != null ) { String message = remoteException . getMessage ( ) ; if ( message == null ) { throw ( Exception ) Classes . newInstance ( cause ) ; } throw ( Exception ) Classes . newInstance ( cause , remoteException . getMessage ( ) ) ; } } throw new RmiException ( connection . getURL ( ) , remoteException ) ; } } final InputStream errorStream = connection . getErrorStream ( ) ; if ( errorStream != null ) { String responseDump = Strings . load ( errorStream , 100 ) ; log . error ( "HTTP-RMI error on |%s|. Server returned |%d|. Response dump:\r\n\t%s" , connection . getURL ( ) , statusCode , responseDump ) ; } else { log . error ( "HTTP-RMI error on |%s|. Server returned |%d|." , connection . getURL ( ) , statusCode ) ; } throw new RmiException ( "HTTP-RMI error on |%s|. Server returned |%d|." , connection . getURL ( ) , statusCode ) ; }
Handle transaction error .
16,017
private static Object readJsonObject ( InputStream stream , Type type ) throws IOException { BufferedReader reader = null ; Json json = Classes . loadService ( Json . class ) ; try { reader = Files . createBufferedReader ( stream ) ; return json . parse ( reader , type ) ; } finally { if ( reader != null ) { reader . close ( ) ; } } }
Read JSON object from input stream and return initialized object instance .
16,018
public void loadProperties ( String prefix ) { List < Property > props = null ; try { props = getListByPrefix ( prefix ) ; } catch ( Exception e ) { log . error ( "Error retrieving properties with prefix: " + prefix , e ) ; return ; } for ( Property prop : props ) { if ( prop . getName ( ) != null ) { this . properties . put ( prop . getName ( ) , prop ) ; } } }
Loads all property objects beginning with the specified prefix . The property objects are stored in a map indexed by the property name for easy retrieval .
16,019
public int getValue ( String name , String [ ] choices ) { String val = getValue ( name , "" ) ; int index = Arrays . asList ( choices ) . indexOf ( val ) ; return index == - 1 ? 0 : index ; }
Returns the index of a property value as it occurs in the choice list .
16,020
public boolean getValue ( String name , boolean dflt ) { try { String val = getValue ( name , Boolean . toString ( dflt ) ) . toLowerCase ( ) ; return val . startsWith ( "y" ) ? true : Boolean . parseBoolean ( val ) ; } catch ( Exception e ) { return false ; } }
Returns a boolean property value .
16,021
public int getValue ( String name , int dflt ) { try { return Integer . parseInt ( getValue ( name , Integer . toString ( dflt ) ) ) ; } catch ( Exception e ) { return dflt ; } }
Returns an integer property value .
16,022
public String getValue ( String name , String dflt ) { Property prop = getProperty ( name ) ; return prop == null ? dflt : prop . getValue ( ) ; }
Returns a string property value .
16,023
public void printInputControl ( PrintWriter out , String strFieldDesc , String strFieldName , String strSize , String strMaxSize , String strValue , String strControlType , String strFieldType ) { out . println ( " <xfm:" + strControlType + " xform=\"form1\" ref=\"" + strFieldName + "\" cols=\"" + strSize + "\" type=\"" + strFieldType + "\">" ) ; out . println ( " <xfm:caption>" + strFieldDesc + "</xfm:caption>" ) ; out . println ( " </xfm:" + strControlType + ">" ) ; }
Display this field in XML input format .
16,024
JsonRepresentation asEventRepr ( EventMetadata metadata , final JsonRepresentation payloadRepr ) { final JsonRepresentation eventRepr = JsonRepresentation . newMap ( ) ; final JsonRepresentation metadataRepr = JsonRepresentation . newMap ( ) ; eventRepr . mapPut ( "metadata" , metadataRepr ) ; metadataRepr . mapPut ( "id" , metadata . getId ( ) ) ; metadataRepr . mapPut ( "transactionId" , metadata . getTransactionId ( ) ) ; metadataRepr . mapPut ( "sequence" , metadata . getSequence ( ) ) ; metadataRepr . mapPut ( "eventType" , metadata . getEventType ( ) ) ; metadataRepr . mapPut ( "user" , metadata . getUser ( ) ) ; metadataRepr . mapPut ( "timestamp" , metadata . getTimestamp ( ) ) ; eventRepr . mapPut ( "payload" , payloadRepr ) ; return eventRepr ; }
region > supporting methods
16,025
public void updateResourcePermissions ( ) { UserPermission recUserPermission = new UserPermission ( this . getOwner ( ) . findRecordOwner ( ) ) ; recUserPermission . addListener ( new SubFileFilter ( this . getOwner ( ) ) ) ; try { while ( recUserPermission . hasNext ( ) ) { recUserPermission . next ( ) ; recUserPermission . edit ( ) ; recUserPermission . getField ( UserPermission . USER_RESOURCE_ID ) . setModified ( true ) ; recUserPermission . set ( ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } recUserPermission . free ( ) ; }
UpdateResourcePermissions Method .
16,026
public void run ( ) { Object objJobDef = null ; while ( m_bKeepAlive ) { Date earliestDate = null ; Vector < AutoTask > vJobsToRunLater = null ; while ( ( objJobDef = this . getNextJob ( ) ) != null ) { if ( EMPTY_TIMED_JOBS == objJobDef ) { vJobsToRunLater = null ; earliestDate = null ; } else if ( END_OF_JOBS == objJobDef ) m_bKeepAlive = false ; else { if ( objJobDef instanceof AutoTask ) if ( ( ( AutoTask ) objJobDef ) . getProperties ( ) != null ) { Date date = ( Date ) ( ( AutoTask ) objJobDef ) . getProperties ( ) . get ( TIME_TO_RUN ) ; if ( date != null ) { Date now = new Date ( ) ; if ( date . after ( now ) ) { if ( ( earliestDate == null ) || ( earliestDate . after ( date ) ) ) earliestDate = date ; if ( vJobsToRunLater == null ) vJobsToRunLater = new Vector < AutoTask > ( ) ; this . addJobToRunLater ( vJobsToRunLater , ( AutoTask ) objJobDef ) ; continue ; } } } if ( objJobDef instanceof AutoTask ) if ( ( ( AutoTask ) objJobDef ) . getApplication ( ) == null ) ( ( AutoTask ) objJobDef ) . setApplication ( this . getApplication ( ) ) ; this . runThread ( objJobDef ) ; } } long lWaitTime = 0 ; if ( earliestDate != null ) { lWaitTime = earliestDate . getTime ( ) - new Date ( ) . getTime ( ) ; if ( lWaitTime <= 0 ) lWaitTime = 1 ; } if ( m_bKeepAlive ) { synchronized ( this ) { m_bThreadSuspended = true ; try { while ( m_bThreadSuspended ) { wait ( lWaitTime ) ; if ( lWaitTime != 0 ) { m_bThreadSuspended = false ; m_vPrivateJobs . addAll ( vJobsToRunLater ) ; } } } catch ( InterruptedException ex ) { ex . printStackTrace ( ) ; } } } } }
Run this thread .
16,027
public boolean sameJob ( AutoTask jobAtIndex , AutoTask jobToAdd ) { Map < String , Object > propJobAtIndex = jobAtIndex . getProperties ( ) ; Map < String , Object > propJobToAdd = jobToAdd . getProperties ( ) ; if ( propJobAtIndex . size ( ) != propJobToAdd . size ( ) ) return false ; boolean bSameJob = false ; for ( String strNewKey : propJobToAdd . keySet ( ) ) { if ( ! strNewKey . equalsIgnoreCase ( TIME_TO_RUN ) ) { if ( propJobAtIndex . get ( strNewKey ) . equals ( propJobToAdd . get ( strNewKey ) ) ) bSameJob = true ; else return false ; } } return bSameJob ; }
Do these two jobs match?
16,028
public static JMessageListener createScreenMessageListener ( FieldList record , BaseScreenModel screen ) { FieldTable table = record . getTable ( ) ; RemoteSession remoteSession = ( RemoteSession ) table . getRemoteTableType ( org . jbundle . model . Remote . class ) ; MessageManager messageManager = ( ( Application ) screen . getBaseApplet ( ) . getApplication ( ) ) . getMessageManager ( ) ; MessageReceiver handler = messageManager . getMessageQueue ( MessageConstants . RECORD_QUEUE_NAME , MessageConstants . INTRANET_QUEUE ) . getMessageReceiver ( ) ; Properties properties = new Properties ( ) ; JMessageListener listenerForSession = ( JMessageListener ) screen . addMessageHandler ( record , properties ) ; BaseMessageFilter filterForSession = new ClientSessionMessageFilter ( MessageConstants . RECORD_QUEUE_NAME , MessageConstants . INTRANET_QUEUE , screen , remoteSession , properties ) ; filterForSession . addMessageListener ( listenerForSession ) ; synchronized ( screen . getBaseApplet ( ) . getRemoteTask ( ) ) { handler . addMessageFilter ( filterForSession ) ; } return listenerForSession ; }
Create a screen message listener for this screen .
16,029
public String processPortType ( TDefinitions descriptionType , TPortType interfaceType , boolean addAddress ) { String interfaceName = interfaceType . getName ( ) ; String allAddress = DBConstants . BLANK ; for ( TOperation nextElement : interfaceType . getOperation ( ) ) { { String address = this . processInterfaceOperationType ( descriptionType , interfaceName , nextElement , addAddress ) ; if ( allAddress != null ) { if ( allAddress == DBConstants . BLANK ) allAddress = address ; else if ( ! allAddress . equalsIgnoreCase ( address ) ) allAddress = null ; } } } return allAddress ; }
ProcessPortType Method .
16,030
public String getElementNameFromMessageName ( TDefinitions descriptionType , TParam message ) { QName qName = message . getMessage ( ) ; String name = qName . getLocalPart ( ) ; for ( TDocumented nextElement : descriptionType . getAnyTopLevelOptionalElement ( ) ) { if ( nextElement instanceof TMessage ) { String msgName = ( ( TMessage ) nextElement ) . getName ( ) ; for ( TPart part : ( ( TMessage ) nextElement ) . getPart ( ) ) { if ( name . equals ( part . getName ( ) ) ) { return part . getElement ( ) . getLocalPart ( ) ; } } } } return null ; }
Search through the messages for this one and return the element name .
16,031
private void init ( IESigType eSigType ) { List < ESigItem > list = new ArrayList < > ( ) ; eSigType . loadESigItems ( list ) ; eSigList . addAll ( list ) ; }
Initialize a new esig type .
16,032
public boolean exist ( IESigType esigType , String id ) { return eSigList . indexOf ( esigType , id ) >= 0 ; }
Tests if the esig item of the specified type and unique id exists .
16,033
public void remove ( IESigType esigType , String id ) { eSigList . remove ( esigType , id ) ; }
Removes the item of the specified type and id from the list .
16,034
public void register ( IESigType eSigType ) throws Exception { if ( typeRegistry . get ( eSigType . getESigTypeId ( ) ) != null ) { throw new Exception ( "Duplicate esig type identifier: " + eSigType . getESigTypeId ( ) ) ; } typeRegistry . put ( eSigType . getESigTypeId ( ) , eSigType ) ; init ( eSigType ) ; }
Registers a new esig type . If a type with the same mnemonic id is already registered an exception is thrown .
16,035
public static void compare ( final IFileCompareResultBean fileCompareResultBean , final boolean ignoreAbsolutePathEquality , final boolean ignoreExtensionEquality , final boolean ignoreLengthEquality , final boolean ignoreLastModified , final boolean ignoreNameEquality ) { final File source = fileCompareResultBean . getSourceFile ( ) ; final File compare = fileCompareResultBean . getFileToCompare ( ) ; if ( ! ignoreAbsolutePathEquality ) { final String sourceAbsolutePath = source . getAbsolutePath ( ) ; final String compareAbsolutePath = compare . getAbsolutePath ( ) ; final boolean absolutePathEquality = sourceAbsolutePath . equals ( compareAbsolutePath ) ; fileCompareResultBean . setAbsolutePathEquality ( absolutePathEquality ) ; } else { fileCompareResultBean . setAbsolutePathEquality ( true ) ; } if ( ! ignoreExtensionEquality ) { final String sourceFileExtension = FileExtensions . getFilenameSuffix ( source ) ; final String compareFileExtension = FileExtensions . getFilenameSuffix ( compare ) ; final boolean extensionEquality = compareFileExtension . equalsIgnoreCase ( sourceFileExtension ) ; fileCompareResultBean . setFileExtensionEquality ( extensionEquality ) ; } else { fileCompareResultBean . setFileExtensionEquality ( true ) ; } if ( ! ignoreLengthEquality ) { final boolean length = source . length ( ) == compare . length ( ) ; fileCompareResultBean . setLengthEquality ( length ) ; } else { fileCompareResultBean . setLengthEquality ( true ) ; } if ( ! ignoreLastModified ) { final boolean lastModified = source . lastModified ( ) == compare . lastModified ( ) ; fileCompareResultBean . setLastModifiedEquality ( lastModified ) ; } else { fileCompareResultBean . setLastModifiedEquality ( true ) ; } if ( ! ignoreNameEquality ) { final String sourceFilename = FileExtensions . getFilenameWithoutExtension ( source ) ; final String compareFilename = FileExtensions . getFilenameWithoutExtension ( compare ) ; final boolean nameEquality = compareFilename . equalsIgnoreCase ( sourceFilename ) ; fileCompareResultBean . setNameEquality ( nameEquality ) ; } else { fileCompareResultBean . setNameEquality ( true ) ; } }
Sets the flags in the FileCompareResultBean object according to the given boolean flag what to ignore .
16,036
public static void compare ( final IFileContentResultBean fileContentResultBean , final boolean ignoreAbsolutePathEquality , final boolean ignoreExtensionEquality , final boolean ignoreLengthEquality , final boolean ignoreLastModified , final boolean ignoreNameEquality , final boolean ignoreContentEquality ) { compare ( fileContentResultBean , ignoreAbsolutePathEquality , ignoreExtensionEquality , ignoreLengthEquality , ignoreLastModified , ignoreNameEquality ) ; final File source = fileContentResultBean . getSourceFile ( ) ; final File compare = fileContentResultBean . getFileToCompare ( ) ; if ( ! ignoreContentEquality ) { boolean contentEquality ; try { final String sourceChecksum = ChecksumExtensions . getChecksum ( source , HashAlgorithm . SHA_512 . getAlgorithm ( ) ) ; final String compareChecksum = ChecksumExtensions . getChecksum ( compare , HashAlgorithm . SHA_512 . getAlgorithm ( ) ) ; contentEquality = sourceChecksum . equals ( compareChecksum ) ; fileContentResultBean . setContentEquality ( contentEquality ) ; } catch ( final NoSuchAlgorithmException e ) { try { contentEquality = ChecksumExtensions . getCheckSumCRC32 ( source ) == ChecksumExtensions . getCheckSumCRC32 ( compare ) ; fileContentResultBean . setContentEquality ( contentEquality ) ; } catch ( IOException e1 ) { fileContentResultBean . setContentEquality ( false ) ; } } catch ( IOException e ) { fileContentResultBean . setContentEquality ( false ) ; } } else { fileContentResultBean . setContentEquality ( true ) ; } }
Sets the flags in the FileContentResultBean object according to the given boolean flag what to ignore .
16,037
public static IFileContentResultBean compareFileContentByBytes ( final File sourceFile , final File fileToCompare ) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean ( sourceFile , fileToCompare ) ; completeCompare ( fileContentResultBean ) ; final boolean simpleEquality = validateEquality ( fileContentResultBean ) ; boolean contentEquality = true ; if ( simpleEquality ) { try ( InputStream sourceReader = StreamExtensions . getInputStream ( sourceFile ) ; InputStream compareReader = StreamExtensions . getInputStream ( fileToCompare ) ; ) { final byte [ ] source = StreamExtensions . getByteArray ( sourceReader ) ; final byte [ ] compare = StreamExtensions . getByteArray ( compareReader ) ; for ( int i = 0 ; 0 < source . length ; i ++ ) { if ( source [ i ] != compare [ i ] ) { contentEquality = false ; break ; } } } catch ( final FileNotFoundException e ) { contentEquality = false ; } catch ( final IOException e ) { contentEquality = false ; } } fileContentResultBean . setContentEquality ( contentEquality ) ; return fileContentResultBean ; }
Compare file content for every single byte .
16,038
public static IFileContentResultBean compareFileContentByLines ( final File sourceFile , final File fileToCompare ) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean ( sourceFile , fileToCompare ) ; completeCompare ( fileContentResultBean ) ; final boolean simpleEquality = validateEquality ( fileContentResultBean ) ; boolean contentEquality = true ; if ( simpleEquality ) { try ( BufferedReader sourceReader = ( BufferedReader ) StreamExtensions . getReader ( sourceFile ) ; BufferedReader compareReader = ( BufferedReader ) StreamExtensions . getReader ( fileToCompare ) ; ) { String sourceLine ; String compareLine ; while ( ( sourceLine = sourceReader . readLine ( ) ) != null ) { compareLine = compareReader . readLine ( ) ; if ( compareLine == null || ! sourceLine . equals ( compareLine ) ) { contentEquality = false ; break ; } } } catch ( final FileNotFoundException e ) { contentEquality = false ; } catch ( final IOException e ) { contentEquality = false ; } } fileContentResultBean . setContentEquality ( contentEquality ) ; return fileContentResultBean ; }
Compare file content by lines .
16,039
public static void completeCompare ( final IFileCompareResultBean fileCompareResultBean ) { compare ( fileCompareResultBean , false , false , false , false , false ) ; }
Completes the compare from the files encapsulated in the FileCompareResultBean .
16,040
public static List < IFileCompareResultBean > findEqualFiles ( final File dirToSearch ) { final List < File > allFiles = FileSearchExtensions . findFilesRecursive ( dirToSearch , "*" ) ; final List < IFileCompareResultBean > equalFiles = new ArrayList < > ( ) ; for ( int i = 0 ; i < allFiles . size ( ) ; i ++ ) { final File toCompare = allFiles . get ( i ) ; for ( final File file : allFiles ) { if ( toCompare . equals ( file ) ) { continue ; } final IFileCompareResultBean compareResultBean = CompareFileExtensions . simpleCompareFiles ( toCompare , file ) ; final boolean equal = CompareFileExtensions . validateEquality ( compareResultBean ) ; if ( equal && ! equalFiles . contains ( compareResultBean ) ) { equalFiles . add ( compareResultBean ) ; } } } return equalFiles ; }
Find equal files .
16,041
public static List < IFileCompareResultBean > findEqualFiles ( final File source , final File compare ) { final List < File > allSourceFiles = FileSearchExtensions . findFilesRecursive ( source , "*" ) ; final List < File > allCompareFiles = FileSearchExtensions . findFilesRecursive ( compare , "*" ) ; final List < IFileCompareResultBean > equalFiles = new ArrayList < IFileCompareResultBean > ( ) ; for ( int i = 0 ; i < allSourceFiles . size ( ) ; i ++ ) { final File toCompare = allSourceFiles . get ( i ) ; for ( int j = 0 ; j < allCompareFiles . size ( ) ; j ++ ) { final File file = allCompareFiles . get ( j ) ; if ( toCompare . equals ( file ) ) { continue ; } final IFileCompareResultBean compareResultBean = CompareFileExtensions . simpleCompareFiles ( toCompare , file ) ; final boolean equal = CompareFileExtensions . validateEquality ( compareResultBean ) ; if ( equal && ! equalFiles . contains ( compareResultBean ) ) { equalFiles . add ( compareResultBean ) ; } } } return equalFiles ; }
Find equal files from the given directories .
16,042
public static List < IFileContentResultBean > findEqualFilesWithSameContent ( final File dirToSearch ) { final List < IFileContentResultBean > equalFiles = new ArrayList < IFileContentResultBean > ( ) ; final List < File > allFiles = FileSearchExtensions . findFilesRecursive ( dirToSearch , "*" ) ; for ( int i = 0 ; i < allFiles . size ( ) ; i ++ ) { final File toCompare = allFiles . get ( i ) ; for ( int j = 0 ; j < allFiles . size ( ) ; j ++ ) { final File file = allFiles . get ( j ) ; if ( toCompare . equals ( file ) ) { continue ; } final IFileContentResultBean contentResultBean = CompareFileExtensions . compareFiles ( toCompare , file ) ; final boolean equal = CompareFileExtensions . validateEquality ( contentResultBean ) ; if ( equal && ! equalFiles . contains ( contentResultBean ) ) { equalFiles . add ( contentResultBean ) ; } } } return equalFiles ; }
Compare files with the same content .
16,043
public static IFileCompareResultBean simpleCompareFiles ( final File sourceFile , final File fileToCompare ) { return compareFiles ( sourceFile , fileToCompare , true , false , false , true , false ) ; }
Simple comparing the given files .
16,044
public static boolean validateEquality ( final IFileCompareResultBean fileCompareResultBean ) { return fileCompareResultBean . getFileExtensionEquality ( ) && fileCompareResultBean . getLengthEquality ( ) && fileCompareResultBean . getLastModifiedEquality ( ) && fileCompareResultBean . getNameEquality ( ) ; }
Validates the files encapsulated in the IFileCompareResultBean for simple equality . This means like if they have equal file extension length last modified and filenames .
16,045
public static boolean validateEquality ( final IFileContentResultBean fileContentResultBean ) { return fileContentResultBean . getFileExtensionEquality ( ) && fileContentResultBean . getLengthEquality ( ) && fileContentResultBean . getLastModifiedEquality ( ) && fileContentResultBean . getNameEquality ( ) && fileContentResultBean . getContentEquality ( ) ; }
Validates the files encapsulated in the IFileCompareResultBean for total equality . This means like if they have equal file extension length last modified filenames and content .
16,046
public boolean canSign ( boolean selectedOnly ) { for ( ESigItem item : items ) { if ( ( ! selectedOnly || item . isSelected ( ) ) && ( item . getSignState ( ) != SignState . FORCED_NO ) ) { return true ; } } return false ; }
Returns true if items exist that the user may sign .
16,047
public int getCount ( IESigType eSigType ) { int result = 0 ; for ( ESigItem item : items ) { if ( item . getESigType ( ) . equals ( eSigType ) ) { result ++ ; } } return result ; }
Returns the count of items of the specified type .
16,048
public int indexOf ( IESigType eSigType , String id ) { return items . indexOf ( new ESigItem ( eSigType , id ) ) ; }
Returns the index of a sig item identified by type and id .
16,049
public ESigItem get ( IESigType eSigType , String id ) { int i = indexOf ( eSigType , id ) ; return i == - 1 ? null : items . get ( i ) ; }
Returns a sig item identified by type and id or null if not found .
16,050
public List < ESigItem > findItems ( ESigFilter filter ) { List < ESigItem > list = new ArrayList < ESigItem > ( ) ; if ( filter == null ) { list . addAll ( items ) ; } else { for ( ESigItem item : items ) { if ( filter . matches ( item ) ) { list . add ( item ) ; } } } return list ; }
Returns a list of sig items that match the specified filter . If the filter is null all sig items are returned .
16,051
public ESigItem add ( IESigType eSigType , String id , String text , String subGroupName , SignState signState , String data , String session ) { ESigItem item = new ESigItem ( eSigType , id ) ; item . setText ( text ) ; item . setSubGroupName ( subGroupName ) ; item . setSignState ( signState ) ; item . setData ( data ) ; item . setSession ( session ) ; return add ( item ) ; }
Ads a new sig item to the list given the required elements .
16,052
public ESigItem add ( ESigItem item ) { if ( ! items . contains ( item ) ) { items . add ( item ) ; fireEvent ( "ADD" , item ) ; } return item ; }
Adds a sig item to the list . Requests to add items already in the list are ignored . If an item is successfully added an ESIG . ADD event is fired .
16,053
public boolean remove ( ESigItem item ) { boolean result = items . remove ( item ) ; if ( result ) { removed ( item ) ; } return result ; }
Removes a sig item from the list . Fires an ESIG . DELETE event if successful .
16,054
public static boolean isConcrete ( Type t ) { if ( t instanceof Class ) { final Class < ? > c = ( Class < ? > ) t ; return ! c . isInterface ( ) && ! Modifier . isAbstract ( c . getModifiers ( ) ) ; } if ( t instanceof ParameterizedType ) { final ParameterizedType p = ( ParameterizedType ) t ; return isConcrete ( p . getRawType ( ) ) ; } return false ; }
Test if type is concrete that is is not interface or abstract . If type to test is parameterized uses its raw type . If type to test is null returns false .
16,055
public static boolean isNumber ( Type t ) { for ( int i = 0 ; i < NUMERICAL_TYPES . length ; i ++ ) { if ( NUMERICAL_TYPES [ i ] == t ) { return true ; } } return false ; }
Test if type is numeric . A type is considered numeric if is a Java standard class representing a number .
16,056
public static boolean isPrimitiveLike ( Type t ) { if ( isNumber ( t ) ) { return true ; } if ( isBoolean ( t ) ) { return true ; } if ( isEnum ( t ) ) { return true ; } if ( isCharacter ( t ) ) { return true ; } if ( isDate ( t ) ) { return true ; } if ( t == String . class ) { return true ; } return false ; }
Test if type is like a primitive? Return true only if given type is a number boolean enumeration character or string .
16,057
public static boolean isClass ( String name ) { if ( name == null ) { return false ; } Matcher matcher = CLASS_NAME_PATTERN . matcher ( name ) ; return matcher . find ( ) ; }
Test if given name is a valid Java class name . This predicate returns false if name to test is null .
16,058
public static < T > DiGraphIterator < T > getInstance ( T root , Function < ? super T , ? extends Collection < T > > edges ) { return new DiGraphIterator < > ( root , ( y ) -> edges . apply ( y ) . stream ( ) ) ; }
Creates a DiGraphIterator . It will iterate once for every node .
16,059
public static < T > Spliterator < T > spliterator ( T root , Function < ? super T , ? extends Stream < T > > edges ) { DiGraphIterator dgi = new DiGraphIterator ( root , edges ) ; return Spliterators . spliteratorUnknownSize ( dgi , 0 ) ; }
Creates a Spliterator
16,060
public static void containsAll ( final Path expected , final Path actual ) throws IOException { final Assertion < Path > exists = existsIn ( expected , actual ) ; if ( Files . exists ( expected ) ) { walkFileTree ( expected , new SimpleFileVisitor < Path > ( ) { public FileVisitResult visitFile ( final Path file , final BasicFileAttributes attrs ) throws IOException { assertThat ( file , exists ) ; return super . visitFile ( file , attrs ) ; } } ) ; } }
Asserts that every file that exists relative to expected also exists relative to actual .
16,061
public static void assertEquals ( final Path expected , final Path actual ) throws IOException { containsAll ( actual , expected ) ; if ( Files . exists ( expected ) ) { containsAll ( expected , actual ) ; walkFileTree ( expected , new SimpleFileVisitor < Path > ( ) { public FileVisitResult visitFile ( final Path file , final BasicFileAttributes attrs ) throws IOException { final Path sub = relativize ( expected , file ) ; final Path therePath = resolve ( actual , sub ) ; final long hereSize = Files . size ( file ) ; final long thereSize = Files . size ( therePath ) ; assertThat ( thereSize , asserts ( ( ) -> sub + " is " + hereSize + " bytes" , t -> t == hereSize ) ) ; assertByteEquals ( sub , file , therePath ) ; return super . visitFile ( file , attrs ) ; } } ) ; } }
Asserts that two paths are deeply byte - equivalent .
16,062
public static void assertByteEquals ( final Path sub , final Path expected , final Path actual ) throws IOException { final int length = 4096 ; final byte [ ] hereBuffer = new byte [ length ] ; final byte [ ] thereBuffer = new byte [ length ] ; long hereLimit = 0 ; long thereLimit = 0 ; try ( InputStream hereStream = newInputStream ( expected ) ; InputStream thereStream = newInputStream ( actual ) ) { int line = 1 ; int ch = 0 ; for ( long i = 0 ; i < Files . size ( expected ) ; i ++ ) { if ( i >= hereLimit ) { hereLimit += read ( hereStream , hereBuffer , hereLimit ) ; } if ( i >= thereLimit ) { thereLimit += read ( thereStream , thereBuffer , thereLimit ) ; } final int c = hereBuffer [ ( int ) ( i % length ) ] ; assertThat ( thereBuffer [ ( int ) ( i % length ) ] , asserts ( message ( sub , i , line , ch ) , t -> t == c ) ) ; if ( c == '\n' ) { ch = 0 ; line ++ ; } else { ch ++ ; } } } }
Asserts that two paths are byte - equivalent .
16,063
public static String getChecksum ( final Algorithm algorithm , final byte [ ] ... byteArrays ) throws NoSuchAlgorithmException { StringBuilder sb = new StringBuilder ( ) ; for ( byte [ ] byteArray : byteArrays ) { sb . append ( getChecksum ( byteArray , algorithm . getAlgorithm ( ) ) ) ; } return sb . toString ( ) ; }
Gets the checksum from the given byte arrays with the given algorithm
16,064
public GeoLocation search ( double deltaNM , GeoSearch ... searches ) { List < GeoLocation > list = search ( false , searches ) ; if ( ! list . isEmpty ( ) && GeoDB . isUnique ( list , deltaNM ) ) { return list . get ( 0 ) ; } else { list . removeIf ( ( gl ) -> ! gl . match ( true , searches ) ) ; if ( ! list . isEmpty ( ) && GeoDB . isUnique ( list , deltaNM ) ) { return list . get ( 0 ) ; } else { return null ; } } }
Returns any GeoLocation which matches all tests and is unique in deltaNM range .
16,065
public List < GeoLocation > search ( boolean strict , GeoSearch ... searches ) { List < GeoLocation > list = new ArrayList < > ( ) ; for ( GeoFile gf : files ) { gf . search ( strict , list , searches ) ; } return list ; }
Returns a list of GeoLocations which match all the searches
16,066
public static boolean isUnique ( List < GeoLocation > list , double delta ) { Location [ ] array = new Location [ list . size ( ) ] ; int index = 0 ; for ( GeoLocation gl : list ) { array [ index ++ ] = gl . getLocation ( ) ; } return ( Location . radius ( array ) <= delta ) ; }
Returns true if greatest distance of any location from their center is less than given delta in nm .
16,067
public static Repository load ( Resolver resolver ) throws IOException { Repository repository ; repository = new Repository ( ) ; repository . loadClasspath ( resolver ) ; repository . link ( ) ; return repository ; }
simplified load method for testing
16,068
public void loadClasspath ( Resolver resolver ) throws IOException { Enumeration < URL > e ; e = getClass ( ) . getClassLoader ( ) . getResources ( MODULE_DESCRIPTOR ) ; while ( e . hasMoreElements ( ) ) { loadModule ( resolver , e . nextElement ( ) ) ; } }
Loads modules from classpath
16,069
public void loadLibrary ( Resolver resolver , Node base , Node descriptor , Node properties ) throws IOException { Source source ; Module module ; Library library ; File file ; addReload ( descriptor ) ; source = Source . load ( properties , base ) ; library = ( Library ) Library . TYPE . loadXml ( descriptor ) . get ( ) ; autoFiles ( resolver , library , source ) ; for ( net . oneandone . jasmin . descriptor . Module descriptorModule : library . modules ( ) ) { module = new Module ( descriptorModule . getName ( ) , source ) ; notLinked . put ( module , descriptorModule . dependencies ( ) ) ; for ( Resource resource : descriptorModule . resources ( ) ) { file = resolver . resolve ( source . classpathBase , resource ) ; addReload ( file ) ; resolver . resolve ( source . classpathBase , resource ) ; module . files ( ) . add ( file ) ; } add ( module ) ; } }
Core method for loading . A library is a module or an application
16,070
public List < Node > link ( ) { List < Module > dependencies ; Module module ; Module resolved ; StringBuilder problems ; List < Node > result ; problems = new StringBuilder ( ) ; for ( Map . Entry < Module , List < String > > entry : notLinked . entrySet ( ) ) { module = entry . getKey ( ) ; dependencies = module . dependencies ( ) ; for ( String name : entry . getValue ( ) ) { resolved = lookup ( name ) ; if ( resolved == null ) { problems . append ( "module '" + module . getName ( ) + "': cannot resolve dependency '" + name + "'\n" ) ; } else { dependencies . add ( resolved ) ; } } } if ( problems . length ( ) > 0 ) { throw new IllegalArgumentException ( problems . toString ( ) ) ; } result = reloadFiles ; notLinked = null ; reloadFiles = null ; return result ; }
Call this after you ve loaded all libraries
16,071
public int doSetData ( Object objData , boolean bDisplayOption , int iMoveMode ) { int iErrorCode = DBConstants . NORMAL_RETURN ; if ( ( m_bFirstTime ) || ( iMoveMode == DBConstants . READ_MOVE ) || ( iMoveMode == DBConstants . SCREEN_MOVE ) ) iErrorCode = super . doSetData ( objData , bDisplayOption , iMoveMode ) ; m_bFirstTime = false ; return iErrorCode ; }
Move the physical binary data to this field . If this is an init set only does it until the first change .
16,072
public void init ( BaseApplet applet , URL url ) { m_applet = applet ; this . setContentType ( HTML_CONTENT ) ; this . setEditable ( false ) ; this . addHyperlinkListener ( this . createHyperLinkListener ( ) ) ; this . setOpaque ( false ) ; this . setSize ( new Dimension ( 500 , 800 ) ) ; if ( url != null ) this . linkActivated ( url , applet , 0 ) ; }
HTMLView Constructor .
16,073
public HyperlinkListener createHyperLinkListener ( ) { return new HyperlinkListener ( ) { public void hyperlinkUpdate ( HyperlinkEvent e ) { if ( e . getEventType ( ) == HyperlinkEvent . EventType . ACTIVATED ) { if ( e instanceof HTMLFrameHyperlinkEvent ) { ( ( HTMLDocument ) getDocument ( ) ) . processHTMLFrameHyperlinkEvent ( ( HTMLFrameHyperlinkEvent ) e ) ; } else { URL url = e . getURL ( ) ; if ( getCallingApplet ( ) != null ) if ( getHelpPane ( ) != null ) { String strQuery = url . getQuery ( ) ; if ( ( strQuery != null ) && ( strQuery . length ( ) > 0 ) && ( strQuery . indexOf ( Params . HELP + "=" ) == - 1 ) ) { if ( BaseApplet . handleAction ( "?" + strQuery , getCallingApplet ( ) , null , 0 ) ) url = null ; } } if ( url != null ) linkActivated ( url , m_applet , 0 ) ; } } } } ; }
Create the hyperlink listener .
16,074
public void setHTMLText ( String strHtmlText ) { if ( m_helpPane != null ) m_helpPane . setVisible ( strHtmlText != null ) ; this . getTaskScheduler ( ) . addTask ( PrivateTaskScheduler . CLEAR_JOBS ) ; Thread thread = new SwingSyncPageWorker ( this , new SyncPageLoader ( null , strHtmlText , this , m_applet , false ) ) ; this . getTaskScheduler ( ) . addTask ( thread ) ; }
Set this control to this html text .
16,075
public TaskScheduler getTaskScheduler ( ) { if ( m_taskScheduler == null ) m_taskScheduler = new PrivateTaskScheduler ( this . getBaseApplet ( ) . getApplication ( ) , 0 , true ) ; return m_taskScheduler ; }
Get my private task scheduler .
16,076
public static byte [ ] addressStringToBytes ( String hex ) { final byte [ ] addr ; try { addr = Hex . decode ( hex ) ; } catch ( DecoderException addressIsNotValid ) { return null ; } if ( isValidAddress ( addr ) ) return addr ; return null ; }
Decodes a hex string to address bytes and checks validity
16,077
public static < R > Stream < R > of ( R ... elements ) { return new Stream < R > ( new ArrayIterable . ArrayIterator < R > ( elements ) ) ; }
Create a stream of the elements provided .
16,078
public static < R > Stream < R > of ( Iterator < R > iterator ) { return new Stream < R > ( iterator ) ; }
Create a stream based on an iterator .
16,079
public Optional < T > reduce ( final BiFunction < T , ? super T , T > accumulator ) { boolean found = false ; T result = null ; while ( iterator . hasNext ( ) ) { if ( ! found ) { result = iterator . next ( ) ; found = true ; } else { result = accumulator . apply ( result , iterator . next ( ) ) ; } } return found ? Optional . of ( result ) : Optional . < T > empty ( ) ; }
Performs a reduction on the elements of the stream using an accumulation function and returns an Optional describing the reduced value if any .
16,080
public < R > R reduce ( final R initial , final BiFunction < R , ? super T , R > accumulator ) { R returnValue = initial ; while ( iterator . hasNext ( ) ) { returnValue = accumulator . apply ( returnValue , iterator . next ( ) ) ; } return returnValue ; }
Performs a reduction on the elements of this stream using the provided initial value and accumulation functions .
16,081
public < R > Stream < R > map ( Function < ? super T , ? extends R > mapper ) { List < R > list = new ArrayList < R > ( ) ; while ( iterator . hasNext ( ) ) { list . add ( mapper . apply ( iterator . next ( ) ) ) ; } return Stream . of ( list ) ; }
Returns a stream consisting of the results of applying the given function to the elements of this stream .
16,082
public boolean anyMatch ( Predicate < ? super T > predicate ) { while ( iterator . hasNext ( ) ) { if ( predicate . test ( iterator . next ( ) ) ) { return true ; } } return false ; }
Returns whether any elements of this stream match the provided predicate . If the stream is empty then false is returned and the predicate is not evaluated .
16,083
@ SuppressWarnings ( "unchecked" ) public static < T > Stream < T > concat ( Stream < ? extends T > a , Stream < ? extends T > b ) { return new Stream ( Iterators . concat ( a . iterator , b . iterator ) ) ; }
Creates a concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream .
16,084
public void init ( ProxyTask proxyTask , RemoteTask remoteTask ) { super . init ( null , remoteTask ) ; m_proxyTask = proxyTask ; }
Creates a new instance of TaskHolder
16,085
public String getProperty ( String strKey , Map < String , Object > properties ) { String strProperty = super . getProperty ( strKey , properties ) ; if ( strProperty == null ) if ( ! m_proxyTask . isShared ( ) ) strProperty = m_proxyTask . getProperty ( strKey ) ; return strProperty ; }
Get the servlet s property . For Ajax proxies the top level proxy is shared among sessions . since it is not unique don t return property .
16,086
@ SuppressWarnings ( "unchecked" ) public static < E > Page < E > cast ( final Page < ? > page ) { return ( Page < E > ) page ; }
Casts a page .
16,087
@ SuppressWarnings ( "unchecked" ) public static < E , T > PageResult < T > createPage ( final Iterable < ? extends E > entries , final PageRequest pageRequest , final long totalSize , final PageEntryTransformer < T , E > transformer ) { final PageResult < T > page = new PageResult < > ( ) ; page . setPageRequest ( pageRequest == null ? new PageRequestDto ( ) : pageRequest ) ; page . setTotalSize ( totalSize ) ; if ( entries != null ) { for ( E entry : entries ) { if ( transformer == null ) { page . getEntries ( ) . add ( ( T ) entry ) ; } else { T targetEntry = transformer . transform ( entry ) ; page . getEntries ( ) . add ( targetEntry ) ; } } } return page ; }
Creates a page .
16,088
public static < E , T > Page < T > createPage ( final Page < ? extends E > sourcePage , final PageEntryTransformer < T , E > transformer ) { if ( sourcePage == null ) { return null ; } if ( transformer == null ) { return cast ( sourcePage ) ; } return createPage ( sourcePage . getEntries ( ) , sourcePage . getPageRequest ( ) , sourcePage . getTotalSize ( ) , transformer ) ; }
Transforms a page into another page .
16,089
public static < E , T > PageDto createPageDto ( final Page < ? extends E > page , final PageEntryTransformer < T , E > transformer ) { if ( page == null ) { return null ; } if ( page instanceof PageDto && transformer == null ) { return ( PageDto ) page ; } final PageRequestDto pageRequestDto = createPageRequestDto ( page . getPageRequest ( ) ) ; if ( transformer == null ) { return new PageDto ( page . getEntries ( ) , pageRequestDto , page . getTotalSize ( ) ) ; } final List < T > entries = new ArrayList < > ( ) ; for ( E e : page . getEntries ( ) ) { entries . add ( transformer . transform ( e ) ) ; } final PageDto pageDto = new PageDto ( ) ; pageDto . setEntries ( CastUtils . cast ( entries ) ) ; pageDto . setPageRequest ( pageRequestDto ) ; pageDto . setTotalSize ( page . getTotalSize ( ) ) ; return pageDto ; }
Transforms a page into a page DTO .
16,090
public static PageRequestDto createPageRequestDto ( final PageRequest pageRequest ) { final PageRequestDto pageRequestDto ; if ( pageRequest == null ) { pageRequestDto = null ; } else if ( pageRequest instanceof PageRequestDto ) { pageRequestDto = ( PageRequestDto ) pageRequest ; } else { pageRequestDto = new PageRequestDto ( pageRequest ) ; } return pageRequestDto ; }
Transforms a page request into a page request DTO .
16,091
@ SuppressWarnings ( "unchecked" ) public static < T , S extends T > T transform ( final Object xmlNodeOrJsonMap , final Class < T > valueType , final S defaultObject , final JAXBContext jaxbContext , final ObjectMapper objectMapper ) throws Exception { if ( xmlNodeOrJsonMap == null ) { return defaultObject ; } Validate . notNull ( valueType , "valueType must not be null" ) ; if ( valueType . isAssignableFrom ( xmlNodeOrJsonMap . getClass ( ) ) ) { return valueType . cast ( xmlNodeOrJsonMap ) ; } if ( xmlNodeOrJsonMap instanceof Node ) { return xmlNodeToObject ( ( Node ) xmlNodeOrJsonMap , valueType , jaxbContext ) ; } if ( xmlNodeOrJsonMap instanceof Map ) { return jsonMapToObject ( ( Map < String , Object > ) xmlNodeOrJsonMap , valueType , objectMapper ) ; } throw new IllegalArgumentException ( "xmlNodeOrJsonMap must be of type " + valueType + ", " + Node . class . getName ( ) + " or of type " + Map . class . getName ( ) ) ; }
Transforms a XML node or a JSON map into an object .
16,092
public BaseField getLeftField ( int iFieldSeq ) { if ( m_rgiFldLeft . length <= iFieldSeq ) return null ; if ( ( m_rgiFldLeft [ iFieldSeq ] instanceof String ) ) if ( ! Utility . isNumeric ( ( String ) m_rgiFldLeft [ iFieldSeq ] ) ) return this . getLeftRecord ( ) . getTable ( ) . getCurrentTable ( ) . getRecord ( ) . getField ( ( String ) m_rgiFldLeft [ iFieldSeq ] ) ; if ( ! ( m_rgiFldLeft [ iFieldSeq ] instanceof Integer ) ) return null ; int fs = ( ( Integer ) m_rgiFldLeft [ iFieldSeq ] ) . intValue ( ) ; return this . getLeftRecord ( ) . getTable ( ) . getCurrentTable ( ) . getRecord ( ) . getField ( fs ) ; }
Get the equal field from the left table for this link .
16,093
public BaseField getRightField ( int iFieldSeq ) { if ( m_rgiFldRight . length <= iFieldSeq ) return null ; if ( m_rgiFldRight [ iFieldSeq ] == null ) return null ; return this . getRightRecord ( ) . getField ( m_rgiFldRight [ iFieldSeq ] ) ; }
Get the equal field from the right table for this link .
16,094
public String getTableNames ( boolean bAddQuotes , Map < String , Object > properties ) { String strString = "" ; strString += this . getLeftRecord ( ) . getTableNames ( bAddQuotes ) ; String strOn = "ON" ; switch ( m_JoinType ) { case DBConstants . LEFT_INNER : if ( properties . get ( "INNER_JOIN" ) != null ) strString += ' ' + ( String ) properties . get ( "INNER_JOIN" ) + ' ' ; else strString += ' ' + "INNER_JOIN " ; if ( properties . get ( "INNER_JOIN_ON" ) != null ) strOn = ( String ) properties . get ( "INNER_JOIN_ON" ) ; break ; case DBConstants . LEFT_OUTER : strString += " LEFT JOIN " ; break ; } strString += this . getRightRecord ( ) . getTableNames ( bAddQuotes ) ; strString += ' ' + strOn + ' ' ; for ( int i = 1 ; i < m_rgiFldLeft . length ; i ++ ) { if ( this . getLeftField ( i ) == null ) break ; if ( i > 1 ) strString += " AND " ; strString += this . getLeftFieldNameOrValue ( i , bAddQuotes , true ) ; strString += " = " ; strString += this . getRightField ( i ) . getFieldName ( bAddQuotes , true ) ; } return strString ; }
Get the SQL table names for this link .
16,095
public void moveDataRight ( ) { for ( int i = 1 ; i < m_rgiFldLeft . length ; i ++ ) { if ( this . getRightField ( i ) == null ) break ; if ( this . getLeftField ( i ) == null ) this . getRightField ( i ) . setString ( this . getLeftFieldNameOrValue ( i , true , true ) , DBConstants . DONT_DISPLAY , DBConstants . SCREEN_MOVE ) ; else this . getRightField ( i ) . moveFieldToThis ( this . getLeftField ( i ) , DBConstants . DONT_DISPLAY , DBConstants . SCREEN_MOVE ) ; } }
Fill the right fields with the values from the left fields .
16,096
public void open ( ) throws DBException { m_objLastModBookmark = null ; try { String strKeyArea = this . getRecord ( ) . getKeyName ( ) ; KeyAreaInfo keyArea = this . getRecord ( ) . getKeyArea ( - 1 ) ; boolean bKeyOrder = Constants . ASCENDING ; if ( keyArea != null ) bKeyOrder = keyArea . getKeyOrder ( ) ; int iOpenMode = this . getRecord ( ) . getOpenMode ( ) ; String strFields = null ; Object objInitialKey = null ; Object objEndKey = null ; byte [ ] byFilter = null ; m_tableRemote . open ( strKeyArea , iOpenMode , bKeyOrder , strFields , objInitialKey , objEndKey , byFilter ) ; m_iCurrentRecord = - 1 ; m_iRecordsAccessed = 0 ; super . open ( ) ; } catch ( RemoteException ex ) { throw new DBException ( ex . getMessage ( ) ) ; } }
Reset the current position and open the file .
16,097
public boolean hasPrevious ( ) throws DBException { if ( m_iCurrentRecord >= m_iRecordsAccessed ) return true ; Object record = this . previous ( ) ; if ( record == null ) return false ; else { m_iRecordsAccessed -- ; return true ; } }
Does this list have a previous record?
16,098
public Object doGet ( int iRowIndex ) throws DBException { try { m_objLastModBookmark = null ; return m_tableRemote . get ( iRowIndex , 1 ) ; } catch ( RemoteException ex ) { ex . printStackTrace ( ) ; throw new DBException ( ex . getMessage ( ) ) ; } }
Returns an attribute value for the cell at columnIndex and rowIndex .
16,099
public void setRemoteTable ( RemoteTable tableRemote , Object syncObject ) { if ( syncObject != null ) tableRemote = new SyncRemoteTable ( tableRemote , syncObject ) ; m_tableRemote = tableRemote ; m_syncObject = syncObject ; }
Set the remote table reference .