idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
16,300
public static Method getMethod ( Class < ? > target , MethodFilter methodFilter ) { Set < Method > methods = getMethods ( target , methodFilter ) ; if ( ! methods . isEmpty ( ) ) { return methods . iterator ( ) . next ( ) ; } return null ; }
Returns the method declared by the target class and any of its super classes which matches the supplied methodFilter if method is found null is returned . If more than one method is found the first in the resulting set iterator is returned .
16,301
public static void verifyMethodSignature ( Method method , Class < ? > returnType , Class < ? > ... parameters ) { if ( method == null ) { throw new IllegalArgumentException ( "Method is null" ) ; } if ( ! method . getReturnType ( ) . equals ( returnType ) ) { throw new IllegalArgumentException ( "Method " + method + " return type " + method . getReturnType ( ) + " does not match: " + returnType ) ; } Class < ? > [ ] actualParameters = method . getParameterTypes ( ) ; if ( actualParameters . length != parameters . length ) { throw new IllegalArgumentException ( "Method " + method + " number of parameters " + actualParameters . length + " does not match: " + parameters . length ) ; } if ( ! Arrays . equals ( actualParameters , parameters ) ) { throw new IllegalArgumentException ( "Method " + method + " types of parameters " + Arrays . toString ( actualParameters ) + " does not match: " + Arrays . toString ( parameters ) ) ; } }
Verify that the supplied method s signature matches return type and parameters types
16,302
public void addButtons ( ) { this . addButton ( Constants . BACK ) ; this . addButton ( Constants . GRID ) ; this . addButton ( Constants . SUBMIT ) ; this . addButton ( Constants . RESET ) ; this . addButton ( Constants . DELETE ) ; this . addButton ( Constants . HELP ) ; }
Add the buttons to this window .
16,303
public void setOwner ( ListenerOwner owner ) { if ( owner != null ) if ( m_buffer == null ) { KeyArea keyArea = ( ( Record ) owner ) . getKeyArea ( - 1 ) ; m_buffer = new VectorBuffer ( null ) ; keyArea . setupKeyBuffer ( m_buffer , DBConstants . FILE_KEY_AREA ) ; } super . setOwner ( owner ) ; }
Set the record that owns this listener . This method caches the current key values .
16,304
public void fill ( IntBiPredicate isInside , int replacement ) { fill ( 0 , 0 , width , height , isInside , ( x , y ) -> replacement ) ; }
Fills area . Pixels fullfilling target are replaced with replacement color .
16,305
protected Properties getLockProperties ( String name ) { return lockProperties != null ? lockProperties . get ( name ) : null ; }
Get a lock s properties
16,306
public User getUser ( ) { ClientResource resource = new ClientResource ( Route . ME . url ( ) ) ; resource . setChallengeResponse ( this . auth . toChallenge ( ) ) ; try { Representation repr = resource . get ( ) ; return mapper . readValue ( repr . getText ( ) , User . class ) ; } catch ( IOException ex ) { LEX4JLogger . log ( Level . WARNING , "Could not retrieve user (me) correctly!" ) ; return null ; } }
Returns the current user
16,307
public List < User > getUserList ( boolean concise , int start , int amount ) { ClientResource resource = new ClientResource ( Route . ALL_USER . url ( ) ) ; Reference ref = resource . getReference ( ) ; Map < String , Object > param = new HashMap < > ( ) ; param . put ( "concise" , concise ) ; param . put ( "start" , start ) ; param . put ( "amount" , amount ) ; Route . addParameters ( ref , param ) ; resource . setChallengeResponse ( this . auth . toChallenge ( ) ) ; try { Representation repr = resource . get ( ) ; return mapper . readValue ( repr . getText ( ) , new TypeReference < List < User > > ( ) { } ) ; } catch ( IOException ex ) { LEX4JLogger . log ( Level . WARNING , "Could not retrieve user list correctly!" ) ; return null ; } }
Returns all users
16,308
public List < DownloadListItem > getDownloadList ( ) { ClientResource resource = new ClientResource ( Route . DOWNLOAD_LIST . url ( ) ) ; resource . setChallengeResponse ( this . auth . toChallenge ( ) ) ; try { Representation repr = resource . get ( ) ; return mapper . readValue ( repr . getText ( ) , new TypeReference < List < DownloadListItem > > ( ) { } ) ; } catch ( IOException ex ) { LEX4JLogger . log ( Level . WARNING , "Could not retrieve download list correctly!" ) ; return null ; } }
Returns the download list of the current user
16,309
public List < DownloadHistoryItem > getDownloadHistory ( ) { ClientResource resource = new ClientResource ( Route . DOWNLOAD_HISTORY . url ( ) ) ; resource . setChallengeResponse ( this . auth . toChallenge ( ) ) ; try { String result = resource . get ( ) . getText ( ) ; return mapper . readValue ( result , new TypeReference < List < DownloadHistoryItem > > ( ) { } ) ; } catch ( IOException e ) { LEX4JLogger . log ( Level . WARNING , "Could not retrieve download history correctly!" ) ; return null ; } }
Returns the download history of the current user
16,310
public void postRegistration ( String username , String password , String email , String fullname ) { ClientResource resource = new ClientResource ( Route . REGISTER . url ( ) ) ; Form form = new Form ( ) ; form . add ( "username" , username ) ; form . add ( "password_1" , password ) ; form . add ( "password_2" , password ) ; form . add ( "email" , email ) ; form . add ( "fullname" , fullname ) ; resource . post ( form ) ; }
Registers a new user for the SC4D LEX
16,311
public void getActivation ( String key ) { ClientResource resource = new ClientResource ( Route . ACTIVATE . url ( ) ) ; Reference ref = resource . getReference ( ) ; Map < String , Object > param = new HashMap < > ( ) ; param . put ( "activation_key" , key ) ; Route . addParameters ( ref , param ) ; resource . get ( ) ; }
Activates a user on the SC4D LEX
16,312
protected void createWebAppContext ( ) { webapp = new WebAppContext ( ) ; webapp . setThrowUnavailableOnStartupException ( true ) ; webapp . setServerClasses ( getServerClasses ( ) ) ; webapp . setContextPath ( getContextPath ( ) ) ; webapp . setTempDirectory ( createTempDir ( "jetty-app-" ) ) ; setSecureCookies ( ) ; }
Create the WebAppContext with basic configurations set like context path etc .
16,313
public void startServer ( ) { server = new Server ( httpPort ) ; server . setHandler ( wrapHandlers ( ) ) ; if ( isWebSocketInClassPath ( ) ) { setupForWebSocket ( ) ; } try { server . start ( ) ; log ( ) . info ( "server started" ) ; Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( new ShutdownRunnable ( ) ) ) ; if ( useStdInShutdown ) { BufferedReader systemIn = new BufferedReader ( new InputStreamReader ( System . in , "UTF-8" ) ) ; while ( ( systemIn . readLine ( ) ) != null ) { } System . out . println ( "Shutdown via CTRL-D" ) ; System . exit ( 0 ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 100 ) ; } }
Start the Jetty server .
16,314
protected void setSecureCookies ( ) { SessionManager sessionManager = webapp . getSessionHandler ( ) . getSessionManager ( ) ; if ( ! ( sessionManager instanceof AbstractSessionManager ) ) { throw new RuntimeException ( "Cannot set secure cookies on session manager." ) ; } AbstractSessionManager abstractSessionManager = ( AbstractSessionManager ) sessionManager ; abstractSessionManager . getSessionCookieConfig ( ) . setSecure ( isSecureCookies ( ) ) ; abstractSessionManager . setHttpOnly ( true ) ; }
Set the secure cookies setting on the jetty session manager .
16,315
public static File copy ( InputStream stream ) throws IOException { File file = createTempFile ( ) ; copy ( stream , new FileOutputStream ( file ) ) ; return file ; }
Binary copy to temporary file . Be aware that temporary file is removed at JVM exit .
16,316
public static File copy ( URL url , String encoding ) throws IOException , IllegalArgumentException { Params . notNull ( url , "Source URL" ) ; URLConnection connection = url . openConnection ( ) ; connection . setDoInput ( true ) ; return copy ( connection . getInputStream ( ) , encoding ) ; }
Copy text from URL using specified encoding to local temporary file then close both URL input stream and temporary file .
16,317
public static File copy ( InputStream stream , String encoding ) throws IOException { File file = createTempFile ( ) ; copy ( new InputStreamReader ( stream , encoding ) , new OutputStreamWriter ( new FileOutputStream ( file ) , encoding ) ) ; return file ; }
Copy text from byte stream using specified encoding to temporary file then close both input stream and temporary file . Be aware that temporary file is removed at JVM exit .
16,318
public static File copy ( Reader reader ) throws IOException { File file = createTempFile ( ) ; copy ( reader , new FileWriter ( file ) ) ; return file ; }
Copy text from character stream to temporary file then close both the source reader and temporary file . Be aware that temporary file is removed at JVM exit .
16,319
public static long copy ( File source , File target ) throws FileNotFoundException , IOException { return copy ( new FileInputStream ( source ) , new FileOutputStream ( target ) ) ; }
Copy source file to target . Copy destination should be a file and this method throws access denied if attempt to write to a directory . Source file should exist but target is created by this method but if not already exist .
16,320
public static int copy ( Reader reader , Writer writer ) throws IOException { Params . notNull ( reader , "Reader" ) ; Params . notNull ( writer , "Writer" ) ; if ( ! ( reader instanceof BufferedReader ) ) { reader = new BufferedReader ( reader ) ; } if ( ! ( writer instanceof BufferedWriter ) ) { writer = new BufferedWriter ( writer ) ; } int charsCount = 0 ; try { char [ ] buffer = new char [ BUFFER_SIZE ] ; for ( ; ; ) { int readChars = reader . read ( buffer ) ; if ( readChars == - 1 ) { break ; } charsCount += readChars ; writer . write ( buffer , 0 , readChars ) ; } } finally { close ( reader ) ; close ( writer ) ; } return charsCount ; }
Copy characters from a reader to a given writer then close both character streams .
16,321
public static long copy ( InputStream inputStream , File file ) throws FileNotFoundException , IOException { return copy ( inputStream , new FileOutputStream ( file ) ) ; }
Copy bytes from requested input stream to given target file . This method creates the target file if does not already exist .
16,322
public static long copy ( URL url , File file ) throws FileNotFoundException , IOException { return copy ( url , new FileOutputStream ( file ) ) ; }
Copy bytes from remote file denoted by given URL to specified local file . This method creates local file if not already exists .
16,323
public static long copy ( File file , OutputStream outputStream ) throws IOException { Params . notNull ( file , "Input file" ) ; return copy ( new FileInputStream ( file ) , outputStream ) ; }
Copy source file bytes to requested output stream . Note that output stream is closed after transfer completes including on error .
16,324
public static void dump ( InputStream inputStream ) throws IOException { if ( ! ( inputStream instanceof BufferedInputStream ) ) { inputStream = new BufferedInputStream ( inputStream ) ; } try { byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int length ; while ( ( length = inputStream . read ( buffer ) ) != - 1 ) { System . out . write ( buffer , 0 , length ) ; } } finally { inputStream . close ( ) ; } }
Dump byte input stream content to standard output till end of input stream . Input stream is closed .
16,325
public static boolean move ( String sourcePath , String targetPath ) throws IllegalArgumentException { Params . notNull ( sourcePath , "Source path" ) ; Params . notNull ( targetPath , "Target path" ) ; File sourceFile = new File ( sourcePath ) ; if ( ! sourceFile . exists ( ) ) { log . error ( "Missing file to move |%s|." , sourcePath ) ; return false ; } File targetFile = new File ( targetPath ) ; if ( targetFile . exists ( ) ) { log . debug ( "Target file exists |%s|. File moving aborted." , targetPath ) ; return false ; } return sourceFile . renameTo ( targetFile ) ; }
Move source file to requested destination but do not overwrite . This method takes care to not overwrite destination file and returns false if it already exists . Note that this method does not throw exceptions if move fails and caller should always test returned boolean to determine if operation completes .
16,326
public static List < String > getPathComponents ( File file ) { if ( file == null ) { return Collections . emptyList ( ) ; } List < String > pathComponents = new ArrayList < String > ( ) ; do { pathComponents . add ( 0 , file . getName ( ) ) ; file = file . getParentFile ( ) ; } while ( file != null ) ; return pathComponents ; }
Get file path components . Return a list of path components in their natural order . List first item is path root stored as an empty string ; if file argument is empty returned list contains only root . If file argument is null returns empty list .
16,327
public static String removeExtension ( String path ) throws IllegalArgumentException { Params . notNull ( path , "Path" ) ; int extensionIndex = path . lastIndexOf ( '.' ) ; return extensionIndex != - 1 ? path . substring ( 0 , extensionIndex ) : path ; }
Remove extension from given file path and return resulting path .
16,328
public static File removeExtension ( File file ) throws IllegalArgumentException { Params . notNull ( file , "File" ) ; return new File ( removeExtension ( file . getPath ( ) ) ) ; }
Remove extension from given file and create a new one with resulting path .
16,329
public static String replaceExtension ( String path , String newExtension ) throws IllegalArgumentException { Params . notNull ( path , "Path" ) ; Params . notNull ( newExtension , "New extension" ) ; if ( newExtension . charAt ( 0 ) == '.' ) { newExtension = newExtension . substring ( 1 ) ; } int extensionDotIndex = path . lastIndexOf ( '.' ) + 1 ; if ( extensionDotIndex == 0 ) { extensionDotIndex = path . length ( ) ; } StringBuilder sb = new StringBuilder ( path . length ( ) ) ; sb . append ( path . substring ( 0 , extensionDotIndex ) ) ; sb . append ( newExtension ) ; return sb . toString ( ) ; }
Replace extension on given file path and return resulting path . Is legal for new extension parameter to start with dot extension separator but is not mandatory .
16,330
public static File replaceExtension ( File file , String newExtension ) throws IllegalArgumentException { Params . notNull ( file , "File" ) ; return new File ( replaceExtension ( file . getPath ( ) , newExtension ) ) ; }
Replace extension on given file and return resulting file .
16,331
public static String dot2path ( String qualifiedName ) { return qualifiedName != null ? DOT_PATTERN . matcher ( qualifiedName ) . replaceAll ( Matcher . quoteReplacement ( File . separator ) ) : null ; }
Replace all dots from given qualified name with platform specific path separator .
16,332
public static String basename ( String path ) { return path != null ? basename ( new File ( path ) ) : null ; }
Return base name for given file path . Returns null if given path parameter is null .
16,333
private static File createTempFile ( ) throws IOException { File file = File . createTempFile ( TMP_FILE_PREFIX , TMP_FILE_EXTENSION ) ; file . deleteOnExit ( ) ; return file ; }
Create temporary file using library specific prefix and extension . Created file is removed at JVM exit .
16,334
public static boolean isImage ( File file ) { return file != null ? IMAGE_FILE_EXTENSIONS . contains ( Files . getExtension ( file ) ) : false ; }
Guess if file is an image file based on file extension . This is a very trivial test relying on file extension and obviously cannot guarantee correct results .
16,335
public static byte [ ] getFileDigest ( InputStream inputStream ) throws IOException { if ( ! ( inputStream instanceof BufferedInputStream ) ) { inputStream = new BufferedInputStream ( inputStream ) ; } MessageDigest messageDigest = null ; try { byte [ ] buffer = new byte [ 1024 ] ; messageDigest = MessageDigest . getInstance ( "MD5" ) ; for ( ; ; ) { int bytesRead = inputStream . read ( buffer ) ; if ( bytesRead <= 0 ) { break ; } messageDigest . update ( buffer , 0 , bytesRead ) ; } } catch ( NoSuchAlgorithmException e ) { throw new BugError ( "JVM with missing MD5 algorithm for message digest." ) ; } finally { inputStream . close ( ) ; } return messageDigest . digest ( ) ; }
Create MD5 message digest for bytes produced by given input stream till its end . This method returns a 16 - bytes array with computed MD5 message digest value . Note that input stream is read till its end and is closed before this method returning including on stream read error .
16,336
public static void delete ( File file ) throws IOException { Params . notNull ( file , "File" ) ; if ( file . exists ( ) && ! file . delete ( ) ) { throw new IOException ( Strings . format ( "Fail to delete file |%s|." , file ) ) ; } }
Delete file if exists throwing exception if delete fails . Note that this method does nothing if file does not exist ; anyway null parameter sanity check is still performed .
16,337
public static String normalizePath ( String path ) { if ( File . separatorChar == '/' ) { return path . replace ( '\\' , '/' ) ; } return path . replace ( '/' , '\\' ) ; }
Ensure that path separators are compatible with current operating system .
16,338
public String getProperties ( String strCommand , Map < String , Object > properties ) { int iIndex = strCommand . indexOf ( '=' ) ; if ( iIndex != - 1 ) { if ( this . getParentScreen ( ) . getTask ( ) != null ) Util . parseArgs ( properties , strCommand ) ; if ( properties . get ( DBParams . COMMAND ) != null ) strCommand = ( String ) properties . get ( DBParams . COMMAND ) ; } return strCommand ; }
Parse the command string into properties .
16,339
public static Predicate < String > notEmptyString ( ) { return new Predicate < String > ( ) { public boolean test ( String testValue ) { if ( notNull ( ) . test ( testValue ) ) { for ( Character c : testValue . toCharArray ( ) ) { if ( ! Character . isWhitespace ( c ) ) { return true ; } } } return false ; } } ; }
Predicate to check that a String is not empty i . e . not null and contains other than whitespace characters .
16,340
public static < T > Predicate < T > notNull ( ) { return new Predicate < T > ( ) { public boolean test ( T testValue ) { return testValue != null ; } } ; }
Predicate to check that a value is not null .
16,341
public static < T > Predicate < T > contains ( final Iterable < T > iterable ) { return new Predicate < T > ( ) { public boolean test ( final T testValue ) { return Iterables . contains ( iterable , testValue ) ; } } ; }
Returns a predicate that that tests if an iterable contains an argument .
16,342
public static < T > Predicate < T > negate ( final Predicate < ? super T > predicate ) { return new Predicate < T > ( ) { public boolean test ( final T testValue ) { return ! predicate . test ( testValue ) ; } } ; }
Negate an existing predicate s test result .
16,343
public static < T > Predicate < T > and ( final Predicate < ? super T > first , final Predicate < ? super T > second ) { return new Predicate < T > ( ) { public boolean test ( final T testValue ) { return first . test ( testValue ) && second . test ( testValue ) ; } } ; }
Create a predicate which is a logical and of two existing predicate .
16,344
public static < T > Predicate < T > or ( final Predicate < ? super T > first , final Predicate < ? super T > second ) { return new Predicate < T > ( ) { public boolean test ( final T testValue ) { return first . test ( testValue ) || second . test ( testValue ) ; } } ; }
Create a predicate which is a logical or of two existing predicate .
16,345
public void addConstant ( ConstantField field ) { constantList . add ( field ) ; constants . put ( field . name , field ) ; }
Manually add a field to the list of constants .
16,346
public void register ( Class < ? > aClass ) { List < ConstantField > tmp = inspector . getConstants ( aClass ) ; constantList . addAll ( tmp ) ; for ( ConstantField constant : tmp ) constants . put ( constant . name , constant ) ; }
Extracts the constant fields from the specified class using the ClassInspector .
16,347
public void loadSettings ( String file ) throws IOException { Path path = Paths . get ( file ) ; try ( BufferedReader reader = Files . newBufferedReader ( path , StandardCharsets . UTF_8 ) ) { Properties props = new Properties ( ) ; props . load ( reader ) ; loadSettings ( props ) ; } }
Loads constant settings from a file in Properties format .
16,348
public void saveSettings ( String file ) throws IOException { Path path = Paths . get ( file ) ; try ( BufferedWriter reader = Files . newBufferedWriter ( path , StandardCharsets . UTF_8 ) ) { Properties props = new Properties ( ) ; saveSettings ( props ) ; props . store ( reader , "Saved by LiveConstantTweaker" ) ; } }
Saves constant settings to a file in Properties format .
16,349
public void set ( String name , int i ) { ConstantField constant = constants . get ( name ) ; ( ( IntConstantField ) constant ) . set ( i ) ; }
Set an integer field with name given .
16,350
public static void sleep ( long timeout , TimeUnit unit ) throws SystemException { suppress ( ( Long sleepTimeout ) -> Thread . sleep ( sleepTimeout ) ) . accept ( TimeUnit . MILLISECONDS . convert ( timeout , unit ) ) ; }
Causes the current thread to wait until the specified waiting time elapses .
16,351
public static < T extends Collection > T untilEmpty ( Callable < T > callable , long timeout , TimeUnit unit ) { return SleepBuilder . < T > sleep ( ) . withComparer ( argument -> argument . isEmpty ( ) ) . withTimeout ( timeout , unit ) . withStatement ( callable ) . build ( ) ; }
Causes the current thread to wait until the callable is returning empty collection or the specified waiting time elapses .
16,352
public void init ( ) { if ( wurflDirPath == null ) throw new IllegalStateException ( "wurflDirPath not properly set" ) ; File wurflDir = new File ( wurflDirPath ) ; if ( ! wurflDir . exists ( ) && servletContext != null ) wurflDir = new File ( servletContext . getRealPath ( wurflDirPath ) ) ; if ( ! wurflDir . exists ( ) ) throw new IllegalArgumentException ( "wurflDirPath " + wurflDir . getAbsolutePath ( ) + " does not exists" ) ; if ( ! wurflDir . isDirectory ( ) ) throw new IllegalArgumentException ( "wurflDirPath " + wurflDir . getAbsolutePath ( ) + " is not a directory" ) ; ArrayList < File > patchFiles = new ArrayList < File > ( ) ; logger . info ( "search for wurfl file and patches on: " + wurflDir . getAbsolutePath ( ) ) ; for ( String filePath : wurflDir . list ( ) ) { File file = new File ( wurflDir . getAbsoluteFile ( ) + "/" + filePath ) ; if ( WURFL_FILENAME . equals ( file . getName ( ) ) ) { wurflFile = file ; logger . debug ( "wurfl file: " + wurflFile . getAbsolutePath ( ) ) ; } else if ( file . getName ( ) . endsWith ( ".xml" ) ) { patchFiles . add ( file ) ; logger . debug ( "wurfl patch file: " + file . getAbsolutePath ( ) ) ; } } this . wurflPatchFiles = patchFiles . toArray ( new File [ ] { } ) ; this . wurflHolder = new CustomWURFLHolder ( this . wurflFile , this . wurflPatchFiles ) ; startWatchingFiles ( ) ; this . statusInfo = getNewStatusInfo ( "" ) ; }
init will properly initialize this service . this would look for wurfl files and instantiate a wurfl holder
16,353
protected synchronized void startWatchingFiles ( ) { famList . clear ( ) ; FilesystemAlterationMonitor fam = new FilesystemAlterationMonitor ( ) ; FileChangeListener wurflListener = new WurflFileListener ( ) ; fam . addListener ( wurflFile , wurflListener ) ; fam . start ( ) ; famList . add ( fam ) ; logger . debug ( "watching " + wurflFile . getAbsolutePath ( ) ) ; for ( File patchFile : wurflPatchFiles ) { fam = new FilesystemAlterationMonitor ( ) ; FileChangeListener wurflPatchListener = new WurflFileListener ( ) ; fam . addListener ( patchFile , wurflPatchListener ) ; fam . start ( ) ; famList . add ( fam ) ; logger . debug ( "watching " + patchFile . getAbsolutePath ( ) ) ; } }
create listeners and monitors for wurfl and its patches
16,354
public static Exception checkFile ( final File file ) { Exception ex = null ; String error = null ; if ( ! file . exists ( ) ) { error = "The " + file + " does not exists." ; ex = new FileDoesNotExistException ( error ) ; return ex ; } if ( ! file . isDirectory ( ) ) { error = "The " + file + " is not a directory." ; ex = new FileIsNotADirectoryException ( error ) ; return ex ; } final File [ ] ff = file . listFiles ( ) ; if ( ff == null ) { error = "The " + file + " could not list the content." ; ex = new DirectoryHasNoContentException ( error ) ; } return ex ; }
Checks the File if it is a directory or if its exists or if it is empty .
16,355
public static void delete ( final File file ) throws IOException { if ( file . isDirectory ( ) ) { DeleteFileExtensions . deleteAllFiles ( file ) ; } else { String error = null ; if ( ! file . delete ( ) ) { error = "Cannot delete the File " + file . getAbsolutePath ( ) + "." ; throw new IOException ( error ) ; } } }
Tries to delete a file and if its a directory than its deletes all the sub - directories .
16,356
public static void deleteAllFiles ( final File file ) throws IOException { String error = null ; if ( ! file . exists ( ) ) { return ; } final Exception ex = checkFile ( file ) ; if ( ex != null ) { try { throw ex ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } } DeleteFileExtensions . deleteFiles ( file ) ; if ( ! file . delete ( ) ) { error = "Cannot delete the File " + file . getAbsolutePath ( ) + "." ; throw new IOException ( error ) ; } }
Deletes the File and if it is an directory it deletes his sub - directories recursively .
16,357
public static void deleteAllFilesWithSuffix ( final File file , final String theSuffix ) throws IOException { final String filePath = file . getAbsolutePath ( ) ; final String suffix [ ] = { theSuffix } ; final List < File > files = FileSearchExtensions . findFiles ( filePath , suffix ) ; final int fileCount = files . size ( ) ; for ( int i = 0 ; i < fileCount ; i ++ ) { DeleteFileExtensions . deleteFile ( files . get ( i ) ) ; } }
Deletes all files with the given suffix recursively .
16,358
public static void deleteFiles ( final File file ) throws IOException { final File [ ] ff = file . listFiles ( ) ; if ( ff != null ) { for ( final File f : ff ) { DeleteFileExtensions . delete ( f ) ; } } }
Tries to delete all files in the Directory .
16,359
public static void deleteFilesWithFileFilter ( final File source , final FileFilter includeFileFilter ) throws FileIsNotADirectoryException , IOException , FileIsSecurityRestrictedException { DeleteFileExtensions . deleteFilesWithFileFilter ( source , includeFileFilter , null ) ; }
Tries to delete all files that match to the given includeFileFilter from the given source directory .
16,360
public static void deleteFilesWithFileFilter ( final File source , final FileFilter includeFileFilter , final FileFilter excludeFileFilter ) throws FileIsNotADirectoryException , IOException , FileIsSecurityRestrictedException { if ( ! source . isDirectory ( ) ) { throw new FileIsNotADirectoryException ( "Source file '" + source . getAbsolutePath ( ) + "' is not a directory." ) ; } File [ ] includeFilesArray ; if ( null != includeFileFilter ) { includeFilesArray = source . listFiles ( includeFileFilter ) ; } else { includeFilesArray = source . listFiles ( ) ; } if ( null != includeFilesArray ) { File [ ] excludeFilesArray = null ; List < File > excludeFilesList = null ; if ( null != excludeFileFilter ) { excludeFilesArray = source . listFiles ( excludeFileFilter ) ; excludeFilesList = Arrays . asList ( excludeFilesArray ) ; } if ( null != excludeFilesList && ! excludeFilesList . isEmpty ( ) ) { for ( final File element : includeFilesArray ) { final File currentFile = element ; if ( ! excludeFilesList . contains ( currentFile ) ) { if ( currentFile . isDirectory ( ) ) { deleteFilesWithFileFilter ( currentFile , includeFileFilter , excludeFileFilter ) ; } else { deleteFile ( currentFile ) ; } } } } else { for ( final File currentFile : includeFilesArray ) { if ( currentFile . isDirectory ( ) ) { deleteFilesWithFileFilter ( currentFile , includeFileFilter , excludeFileFilter ) ; } else { deleteFile ( currentFile ) ; } } } } else { throw new FileIsSecurityRestrictedException ( "File '" + source . getAbsolutePath ( ) + "' is security restricted." ) ; } }
Tries to delete all files that match to the given includeFileFilter and does not delete the files that match the excludeFileFilter from the given source directory .
16,361
public static void deleteFilesWithFilenameFilter ( final File source , final FilenameFilter includeFilenameFilter ) throws FileIsNotADirectoryException , IOException , FileIsSecurityRestrictedException { DeleteFileExtensions . deleteFilesWithFilenameFilter ( source , includeFilenameFilter , null ) ; }
Tries to delete all files that match to the given includeFilenameFilter from the given source directory .
16,362
public static void deleteFilesWithFilenameFilter ( final File source , final FilenameFilter includeFilenameFilter , final FilenameFilter excludeFilenameFilter ) throws FileIsNotADirectoryException , IOException , FileIsSecurityRestrictedException { if ( ! source . isDirectory ( ) ) { throw new FileIsNotADirectoryException ( "Source file '" + source . getAbsolutePath ( ) + "' is not a directory." ) ; } File [ ] includeFilesArray ; if ( null != includeFilenameFilter ) { includeFilesArray = source . listFiles ( includeFilenameFilter ) ; } else { includeFilesArray = source . listFiles ( ) ; } if ( null != includeFilesArray ) { File [ ] excludeFilesArray = null ; List < File > excludeFilesList = null ; if ( null != excludeFilenameFilter ) { excludeFilesArray = source . listFiles ( excludeFilenameFilter ) ; excludeFilesList = Arrays . asList ( excludeFilesArray ) ; } if ( null != excludeFilesList && ! excludeFilesList . isEmpty ( ) ) { for ( final File element : includeFilesArray ) { final File currentFile = element ; if ( ! excludeFilesList . contains ( currentFile ) ) { if ( currentFile . isDirectory ( ) ) { deleteFilesWithFilenameFilter ( currentFile , includeFilenameFilter , excludeFilenameFilter ) ; } else { deleteFile ( currentFile ) ; } } } } else { for ( final File currentFile : includeFilesArray ) { if ( currentFile . isDirectory ( ) ) { deleteFilesWithFilenameFilter ( currentFile , includeFilenameFilter , excludeFilenameFilter ) ; } else { deleteFile ( currentFile ) ; } } } } else { throw new FileIsSecurityRestrictedException ( "File '" + source . getAbsolutePath ( ) + "' is security restricted." ) ; } }
Tries to delete all files that match to the given includeFilenameFilter and does not delete the files that match the excludeFilenameFilter from the given source directory .
16,363
public boolean contains ( final LocalDate date ) { if ( date == null ) { return false ; } if ( endDate ( ) == null ) { if ( startDate ( ) == null ) { return true ; } if ( date . isEqual ( startDate ( ) ) || date . isAfter ( startDate ( ) ) ) { return true ; } return false ; } return asInterval ( ) . contains ( date . toInterval ( ) ) ; }
Does this date contain the specified time interval .
16,364
public int days ( ) { if ( isInfinite ( ) ) { return 0 ; } Period p = new Period ( asInterval ( ) , PeriodType . days ( ) ) ; return p . getDays ( ) ; }
The duration in days
16,365
protected String dateToString ( LocalDate localDate , String format ) { return localDate == null ? "----------" : localDate . toString ( format ) ; }
For benefit of subclass toString implementations .
16,366
@ SuppressWarnings ( "unchecked" ) public T overlap ( final T otherInterval ) { if ( otherInterval == null ) { return null ; } if ( otherInterval . isInfinite ( ) ) { return ( T ) this ; } if ( this . isInfinite ( ) ) { return otherInterval ; } final Interval thisAsInterval = asInterval ( ) ; final Interval otherAsInterval = otherInterval . asInterval ( ) ; Interval overlap = thisAsInterval . overlap ( otherAsInterval ) ; if ( overlap == null ) { return null ; } return newInterval ( overlap ) ; }
Gets the overlap between this interval and another interval .
16,367
public double horizontalForce ( Double T , double d ) { return AE * Math . sqrt ( Math . pow ( T / AE + 1 , 2 ) - 2 * w * d / AE ) - AE ; }
Horizontal force for a given fairlead tension T
16,368
public String getKey ( String strValue ) { for ( String key : m_resourceBundle . keySet ( ) ) { String strKeyValue = m_resourceBundle . getString ( key ) ; if ( strValue . startsWith ( strKeyValue ) ) return key ; } return strValue ; }
From the value find the key . Does a reverse - lookup for the key from this value . This is useful for foreign - language buttons that do a command using their english name .
16,369
public static RequestInfo getRequestInfo ( HttpServletRequest request ) { RequestInfo requestInfo = ( RequestInfo ) request . getAttribute ( REQUEST_INFO ) ; if ( requestInfo == null ) { requestInfo = new RequestInfo ( request ) ; request . setAttribute ( REQUEST_INFO , requestInfo ) ; } return requestInfo ; }
this either creates a new RequestInfo or gets the cached instance from the reqeust
16,370
public int handleMessage ( BaseMessage message ) { Map < String , Object > properties = new HashMap < String , Object > ( ) ; String strMessageType = ( String ) message . get ( MessageConstants . MESSAGE_TYPE_PARAM ) ; String strStartIndex = ( String ) message . get ( START_INDEX_PARAM ) ; String strEndIndex = ( String ) message . get ( END_INDEX_PARAM ) ; if ( strMessageType != null ) properties . put ( MessageConstants . MESSAGE_TYPE_PARAM , strMessageType ) ; if ( strStartIndex != null ) properties . put ( START_INDEX_PARAM , strStartIndex ) ; if ( strEndIndex != null ) properties . put ( END_INDEX_PARAM , strEndIndex ) ; Map < String , Object > propertiesHdr = null ; if ( message . getMessageHeader ( ) != null ) propertiesHdr = message . getMessageHeader ( ) . getProperties ( ) ; if ( propertiesHdr != null ) properties . putAll ( propertiesHdr ) ; if ( properties != null ) { strMessageType = ( String ) properties . get ( MessageConstants . MESSAGE_TYPE_PARAM ) ; try { int iMessageType = Integer . parseInt ( strMessageType ) ; if ( ( Constants . AFTER_ADD_TYPE == iMessageType ) || ( Constants . AFTER_DELETE_TYPE == iMessageType ) || ( Constants . AFTER_UPDATE_TYPE == iMessageType ) ) { SwingUtilities . invokeLater ( new UpdateGridTable ( properties ) ) ; } } catch ( NumberFormatException ex ) { } } return super . handleMessage ( message ) ; }
Handle this message . Update the model depending of the message .
16,371
public String getLink ( ) { String strType = this . getField ( ClassInfo . CLASS_TYPE ) . getString ( ) ; String strLink = this . getField ( ClassInfo . CLASS_NAME ) . getString ( ) ; if ( this . getField ( ClassInfo . CLASS_PACKAGE ) . getLength ( ) > 0 ) strLink = DBConstants . ROOT_PACKAGE + this . getField ( ClassInfo . CLASS_PACKAGE ) . toString ( ) + "." + strLink ; if ( strType . equalsIgnoreCase ( "screen" ) ) strLink = HtmlConstants . SERVLET_LINK + "?screen=" + strLink ; else if ( strType . equalsIgnoreCase ( "record" ) ) strLink = HtmlConstants . SERVLET_LINK + "?record=" + strLink ; return strLink ; }
Get the link that will run this class .
16,372
public ClassInfoModel readClassInfo ( PropertyOwner recordOwner , String className ) { String strParamRecord = null ; String strParamScreenType = null ; String strParamMenu = null ; String strParamHelp = null ; if ( className == null ) { strParamRecord = recordOwner . getProperty ( DBParams . RECORD ) ; className = recordOwner . getProperty ( DBParams . SCREEN ) ; strParamScreenType = recordOwner . getProperty ( DBParams . COMMAND ) ; strParamMenu = recordOwner . getProperty ( DBParams . MENU ) ; strParamHelp = recordOwner . getProperty ( DBParams . HELP ) ; } if ( className == null ) className = DBConstants . BLANK ; if ( ( className . length ( ) == 0 ) || ( className . equals ( "Screen" ) ) || ( className . equals ( "GridScreen" ) ) ) { if ( strParamRecord != null ) if ( strParamRecord . length ( ) > 0 ) className = strParamRecord ; } try { this . setKeyArea ( DBConstants . PRIMARY_KEY ) ; if ( className . lastIndexOf ( '.' ) != - 1 ) className = className . substring ( className . lastIndexOf ( '.' ) + 1 ) ; this . getField ( ClassInfo . CLASS_NAME ) . setString ( className ) ; boolean bSuccess = false ; this . setKeyArea ( ClassInfo . CLASS_NAME_KEY ) ; if ( className . length ( ) > 0 ) bSuccess = this . seek ( "=" ) ; if ( ! bSuccess ) { if ( ( strParamMenu != null ) && ( strParamMenu . length ( ) > 0 ) ) this . getField ( ClassInfo . CLASS_NAME ) . setString ( "MenuScreen" ) ; else if ( ( strParamRecord != null ) && ( strParamRecord . length ( ) > 0 ) ) { if ( ( strParamScreenType != null ) && ( strParamScreenType . length ( ) > 0 ) && ( strParamScreenType . equalsIgnoreCase ( ThinMenuConstants . FORM ) ) ) this . getField ( ClassInfo . CLASS_NAME ) . setString ( "Screen" ) ; else this . getField ( ClassInfo . CLASS_NAME ) . setString ( "GridScreen" ) ; } else this . getField ( ClassInfo . CLASS_NAME ) . setString ( strParamHelp ) ; if ( ! bSuccess ) bSuccess = this . seek ( "=" ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; return null ; } return this ; }
Read the ClassInfoService record
16,373
public String getPackageName ( ClassProject . CodeType codeType ) { if ( codeType == null ) codeType = ClassProject . CodeType . THICK ; String packageName = this . getField ( ClassInfo . CLASS_PACKAGE ) . toString ( ) ; ClassProject classProject = ( ClassProject ) ( ( ReferenceField ) this . getField ( ClassInfo . CLASS_PROJECT_ID ) ) . getReference ( ) ; if ( classProject != null ) if ( ( classProject . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) || ( classProject . getEditMode ( ) == DBConstants . EDIT_CURRENT ) ) packageName = classProject . getFullPackage ( codeType , packageName ) ; return packageName ; }
Get the full class name .
16,374
public String getFullClassName ( ) { String className = this . getField ( ClassInfo . CLASS_NAME ) . toString ( ) ; ClassProject classProject = ( ClassProject ) ( ( ReferenceField ) this . getField ( ClassInfo . CLASS_PROJECT_ID ) ) . getReference ( ) ; String packageName = classProject . getFullPackage ( ClassProject . CodeType . THICK , this . getField ( ClassInfo . CLASS_PACKAGE ) . toString ( ) ) ; if ( ! packageName . endsWith ( "." ) ) if ( ! className . endsWith ( "." ) ) className = "." + className ; return packageName + className ; }
GetFullClassName Method .
16,375
public void printHtmlTechInfo ( PrintWriter out , String strTag , String strParams , String strData ) { FieldData fieldInfo = new FieldData ( this . findRecordOwner ( ) ) ; String strClass = this . getClassName ( ) ; fieldInfo . setKeyArea ( FieldData . FIELD_FILE_NAME_KEY ) ; fieldInfo . addListener ( new StringSubFileFilter ( strClass , fieldInfo . getField ( FieldData . FIELD_FILE_NAME ) , null , null , null , null ) ) ; try { out . println ( "<table border=1>" ) ; out . println ( "<tr>" ) ; out . println ( "<th>" + fieldInfo . getField ( FieldData . FIELD_NAME ) . getFieldDesc ( ) + "</th>" ) ; out . println ( "<th>" + fieldInfo . getField ( FieldData . FIELD_CLASS ) . getFieldDesc ( ) + "</th>" ) ; out . println ( "<th>" + fieldInfo . getField ( FieldData . BASE_FIELD_NAME ) . getFieldDesc ( ) + "</th>" ) ; out . println ( "<th>" + fieldInfo . getField ( FieldData . MAXIMUM_LENGTH ) . getFieldDesc ( ) + "</th>" ) ; out . println ( "<th>" + fieldInfo . getField ( FieldData . FIELD_DESCRIPTION ) . getFieldDesc ( ) + "</th>" ) ; out . println ( "</tr>" ) ; while ( fieldInfo . hasNext ( ) ) { fieldInfo . next ( ) ; out . println ( "<tr>" ) ; out . println ( "<td>&#160;" + fieldInfo . getField ( FieldData . FIELD_NAME ) . toString ( ) + "</td>" ) ; out . println ( "<td>&#160;" + fieldInfo . getField ( FieldData . FIELD_CLASS ) . toString ( ) + "</td>" ) ; out . println ( "<td>&#160;" + fieldInfo . getField ( FieldData . BASE_FIELD_NAME ) . toString ( ) + "</td>" ) ; out . println ( "<td>&#160;" + fieldInfo . getField ( FieldData . MAXIMUM_LENGTH ) . toString ( ) + "</td>" ) ; out . println ( "<td>&#160;" + fieldInfo . getField ( FieldData . FIELD_DESCRIPTION ) . toString ( ) + "</td>" ) ; out . println ( "</tr>" ) ; } out . println ( "</table>" ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } fieldInfo . free ( ) ; fieldInfo = null ; }
PrintHtmlTechInfo Method .
16,376
public boolean isARecord ( boolean isAFile ) { Record recFileHdr = ( Record ) this . getRecordOwner ( ) . getRecord ( FileHdr . FILE_HDR_FILE ) ; if ( recFileHdr == null ) { recFileHdr = new FileHdr ( this . getRecordOwner ( ) ) ; this . addListener ( new FreeOnFreeHandler ( recFileHdr ) ) ; } if ( ! recFileHdr . getField ( FileHdr . FILE_NAME ) . equals ( this . getField ( ClassInfo . CLASS_NAME ) ) ) { try { recFileHdr . addNew ( ) ; recFileHdr . getField ( FileHdr . FILE_NAME ) . moveFieldToThis ( this . getField ( ClassInfo . CLASS_NAME ) ) ; int oldKeyArea = recFileHdr . getDefaultOrder ( ) ; recFileHdr . setKeyArea ( FileHdr . FILE_NAME_KEY ) ; recFileHdr . seek ( null ) ; recFileHdr . setKeyArea ( oldKeyArea ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } if ( ( recFileHdr . getEditMode ( ) == DBConstants . EDIT_CURRENT ) && ( this . getField ( ClassInfo . CLASS_NAME ) . toString ( ) . equals ( recFileHdr . getField ( FileHdr . FILE_NAME ) . getString ( ) ) ) ) return true ; if ( isAFile ) return false ; if ( ! "Record" . equalsIgnoreCase ( this . getField ( ClassInfo . CLASS_TYPE ) . toString ( ) ) ) return false ; if ( this . getField ( ClassInfo . BASE_CLASS_NAME ) . toString ( ) . contains ( "ScreenRecord" ) ) return false ; if ( "Interface" . equalsIgnoreCase ( this . getField ( ClassInfo . CLASS_TYPE ) . toString ( ) ) ) return false ; if ( RESOURCE_CLASS . equals ( this . getField ( ClassInfo . BASE_CLASS_NAME ) . toString ( ) ) ) return false ; return true ; }
IsARecord Method .
16,377
public void startDocument ( String namespaceURI , String localName , String qName , Attributes attr ) throws SAXException { startTable = false ; col = 0 ; row = 0 ; }
StartDocument Method .
16,378
public void startElement ( String namespaceURI , String localName , String qName , Attributes attr ) { if ( localName . equalsIgnoreCase ( TABLE ) ) { String strClass = attr . getValue ( "" , "class" ) ; if ( strClass != null ) if ( strClass . equalsIgnoreCase ( "table-in" ) ) { startTable = true ; row = - 1 ; } } else if ( startTable ) { if ( localName . equalsIgnoreCase ( TR ) ) { row ++ ; col = - 1 ; } else if ( localName . equalsIgnoreCase ( TD ) ) { col ++ ; } } }
StartElement Method .
16,379
public void endElement ( String namespaceURI , String localName , String qName ) throws SAXException { if ( localName . equalsIgnoreCase ( TABLE ) ) { if ( startTable ) if ( m_record . getEditMode ( ) == DBConstants . EDIT_ADD ) { try { m_record . add ( ) ; } catch ( DBException e ) { e . printStackTrace ( ) ; } } startTable = false ; } }
EndElement Method .
16,380
public void characters ( char [ ] ch , int start , int length ) throws SAXException { if ( startTable ) { try { String string = new String ( ch , start , length ) ; for ( int i = string . length ( ) - 1 ; i >= 0 ; i -- ) { int x = Character . getNumericValue ( string . charAt ( i ) ) ; if ( ( Character . isWhitespace ( string . charAt ( i ) ) ) || ( x == - 1 ) ) string = string . substring ( 0 , string . length ( ) - 1 ) ; else break ; } if ( row == 0 ) { new StringField ( m_record , string , - 1 , string , null ) ; } else { if ( col == 0 ) { if ( m_record . getEditMode ( ) == DBConstants . EDIT_ADD ) m_record . add ( ) ; m_record . addNew ( ) ; } m_record . getField ( col + 1 ) . setString ( string ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } } }
Characters Method .
16,381
public void simulate ( LocationSource locationSource , long period , boolean isDaemon ) throws IOException { this . locationSource = locationSource ; dis = new DataInputStream ( new BufferedInputStream ( url . openStream ( ) ) ) ; if ( timer == null ) { timer = new Timer ( "AnchorageSimulator" , isDaemon ) ; } timer . scheduleAtFixedRate ( this , 0 , period ) ; }
Starts simulating anchorige .
16,382
public static < T > Iterator < T > iterator ( Queue < T > queue ) { return new XIteratorImpl < > ( ( ) -> ! queue . isEmpty ( ) , queue :: remove ) ; }
Returns Queue as iterator . Calls isEmpty and remove methods
16,383
public static < T > Iterator < T > iterator ( BlockingQueue < T > queue ) { return iterator ( queue , Long . MAX_VALUE , TimeUnit . MILLISECONDS ) ; }
Returns Queue as iterator . Calls poll method
16,384
public static < T > Iterator < T > iterator ( BlockingQueue < T > queue , long time , TimeUnit unit ) { return new XIteratorImpl < > ( ( ) -> true , ( ) -> { try { T item = queue . poll ( time , unit ) ; if ( item == null ) { throw new NoSuchElementException ( "timeout" ) ; } return item ; } catch ( InterruptedException ex ) { throw new NoSuchElementException ( "interrupted" ) ; } } ) ; }
Returns Queue as iterator . Calls poll method . When timeout throws NoSuchElementException which will remove it from merger .
16,385
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public C merge ( final C other ) { return ( C ) ConfigurationUtils . defaultMerge ( ( ConfigurationComponent ) this , ( ConfigurationComponent ) other ) ; }
Performs a default merge operation between current bean instance and defaults instance
16,386
@ SuppressWarnings ( "rawtypes" ) public void basicValidate ( final String section ) throws ConfigException { ConfigurationUtils . defaultValidate ( ( ConfigurationComponent ) this , section ) ; }
Skeleton validation triggering validate on any subComponents
16,387
public static final IntStream reducingStream ( IntStream stream , ReducingFunction func ) { return StreamSupport . intStream ( new ReducingSpliterator ( stream , func ) , false ) ; }
Converts Stream to Stream where one or more int items are mapped to one int item . Mapping is done by func method . Func must return true after calling consumer method . Otherwise behavior is unpredictable .
16,388
public static Closeable getInstance ( InputStream inputStream , Type type ) throws IOException { Params . notNull ( inputStream , "Input stream" ) ; if ( type == InputStream . class ) { return inputStream ; } if ( type == ZipInputStream . class ) { return new ZipInputStream ( inputStream ) ; } if ( type == JarInputStream . class ) { return new JarInputStream ( inputStream ) ; } if ( type == FilesInputStream . class ) { return new FilesInputStream ( inputStream ) ; } if ( type == Reader . class || type == InputStreamReader . class ) { return new InputStreamReader ( inputStream , "UTF-8" ) ; } if ( type == BufferedReader . class ) { return new BufferedReader ( new InputStreamReader ( inputStream , "UTF-8" ) ) ; } if ( type == LineNumberReader . class ) { return new LineNumberReader ( new InputStreamReader ( inputStream , "UTF-8" ) ) ; } if ( type == PushbackReader . class ) { return new PushbackReader ( new InputStreamReader ( inputStream , "UTF-8" ) ) ; } throw new IllegalArgumentException ( String . format ( "Unsupported stream type |%s|." , type ) ) ; }
Create stream of requested type wrapping given input stream . Both returned bytes and character streams are closeable .
16,389
public String getSQLType ( boolean bIncludeLength , Map < String , Object > properties ) { String strType = ( String ) properties . get ( DBSQLTypes . STRING ) ; if ( strType == null ) strType = "VARCHAR" ; if ( this . getMaxLength ( ) < 127 ) { String strStart = ( String ) properties . get ( "LONGSTRINGSTART" ) ; if ( strStart != null ) { int iStart = Integer . parseInt ( strStart ) ; if ( iStart < this . getMaxLength ( ) ) strType = ( String ) properties . get ( "LONGSTRING" ) ; } } if ( bIncludeLength ) strType += "(" + Integer . toString ( this . getMaxLength ( ) ) + ")" ; return strType ; }
Get the SQL type of this field . Typically STRING VARCHAR or LONGSTRING if over 127 chars .
16,390
public int setString ( String strString , boolean bDisplayOption , int iMoveMode ) { int iMaxLength = this . getMaxLength ( ) ; if ( strString != null ) if ( strString . length ( ) > iMaxLength ) strString = strString . substring ( 0 , iMaxLength ) ; if ( strString == null ) strString = Constants . BLANK ; return this . setData ( strString , bDisplayOption , iMoveMode ) ; }
Convert and move string to this field . Data is already in string format so just move it!
16,391
public void writeit ( String strTemp ) { String strTabs = "" ; int i = 0 ; for ( i = 0 ; i < m_iTabs ; i ++ ) { strTabs += "\t" ; } if ( m_bTabOnNextLine ) if ( ( strTemp . length ( ) > 0 ) && ( strTemp . charAt ( 0 ) != '\n' ) ) strTemp = strTabs + strTemp ; m_bTabOnNextLine = false ; int iIndex = 0 ; int iIndex2 ; while ( iIndex != - 1 ) { iIndex = strTemp . indexOf ( '\n' , iIndex ) ; if ( ( iIndex != - 1 ) && ( iIndex < strTemp . length ( ) - 1 ) ) { iIndex2 = iIndex + 1 ; if ( iIndex > 1 ) if ( strTemp . charAt ( iIndex ) == '\r' ) iIndex -- ; strTemp = strTemp . substring ( 0 , iIndex + 1 ) + strTabs + strTemp . substring ( iIndex2 , strTemp . length ( ) ) ; iIndex = iIndex + 2 ; } else iIndex = - 1 ; } iIndex = 0 ; while ( iIndex != - 1 ) { iIndex = strTemp . indexOf ( '\r' , iIndex ) ; if ( iIndex != - 1 ) strTemp = strTemp . substring ( 0 , iIndex ) + strTemp . substring ( iIndex + 1 , strTemp . length ( ) ) ; } strTemp = this . tabsToSpaces ( strTemp ) ; this . print ( strTemp ) ; if ( strTemp . length ( ) > 0 ) if ( strTemp . charAt ( strTemp . length ( ) - 1 ) == '\n' ) ; m_bTabOnNextLine = true ; }
Writeit Method .
16,392
public Set < Class < ? > > getDeclaredInterfaces ( ClassFilter filter ) { return ClassUtils . getDeclaredInterfaces ( target , filter ) ; }
Returns a set of interfaces that that passes the supplied filter .
16,393
public Set < Field > getDeclaredFields ( FieldFilter filter ) { return FieldUtils . getDeclaredFields ( target , filter ) ; }
Returns a set of all fields matching the supplied filter declared in the target class .
16,394
public int setParam ( String param , Object value ) { int i = findParam ( param ) ; if ( value == null && i < 0 ) { return i ; } if ( i < 0 ) { i = extraInfo . length ; extraInfo = Arrays . copyOf ( extraInfo , i + 1 ) ; } if ( value == null ) { extraInfo = ( String [ ] ) ArrayUtils . remove ( extraInfo , i ) ; } else { extraInfo [ i ] = param + "=" + value ; } return i ; }
Sets the value for a parameter in extra info .
16,395
public String getDisplayText ( ) { StringBuilder sb = new StringBuilder ( ) ; appendText ( sb , getPatientName ( ) , "patient" ) ; appendText ( sb , getSubject ( ) , "subject" ) ; appendText ( sb , getSenderName ( ) , "sender" ) ; appendText ( sb , DateUtil . formatDate ( getDeliveryDate ( ) ) , "delivered" ) ; appendText ( sb , getPriority ( ) . toString ( ) , "priority" ) ; appendText ( sb , "dummy" , isActionable ( ) ? "actionable" : "infoonly" ) ; appendText ( sb , "dummy" , canDelete ( ) ? "delete.yes" : "delete.no" ) ; if ( message != null && ! message . isEmpty ( ) ) { sb . append ( "\n" ) ; for ( String text : message ) { sb . append ( text ) . append ( "\n" ) ; } } return sb . toString ( ) ; }
Returns the display text for this notification .
16,396
private void appendText ( StringBuilder sb , String text , String format ) { if ( text != null && ! text . isEmpty ( ) ) { format = "@vistanotification.detail." + format + ".label" ; sb . append ( StrUtil . formatMessage ( format , text ) ) . append ( "\n" ) ; } }
Appends a text element if it is not null or empty .
16,397
public int getLengthPrefix ( ) { int length = 1 ; length += 4 ; if ( this . rules != null ) { for ( SubscriptionRequestRule rule : this . rules ) { ++ length ; length += 4 + rule . getNumTransmitters ( ) * Transmitter . TRANSMITTER_ID_SIZE * 2 ; length += 8 ; } } return length ; }
Returns the length prefix value for this message as encoded according to the Solver - Aggregator protocol .
16,398
public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { double srcValue = ( ( NumberField ) this . getOwner ( ) ) . getValue ( ) ; BaseField fldTarget = this . getFieldTarget ( ) ; if ( this . getOwner ( ) . isNull ( ) ) return fldTarget . moveFieldToThis ( this . getOwner ( ) , bDisplayOption , iMoveMode ) ; boolean [ ] rgbListeners = null ; if ( m_bDisableTarget ) rgbListeners = fldTarget . setEnableListeners ( false ) ; int iErrorCode = fldTarget . setValue ( this . computeValue ( srcValue ) , bDisplayOption , iMoveMode ) ; if ( m_bDisableTarget ) fldTarget . setEnableListeners ( rgbListeners ) ; return iErrorCode ; }
The Field has Changed . Get the value of this listener s owner pass it to the computeValue method and set the returned value to the target field .
16,399
public BaseField getFieldTarget ( ) { BaseField fldTarget = m_fldTarget ; if ( fldTarget == null ) if ( targetFieldName != null ) fldTarget = ( NumberField ) ( this . getOwner ( ) . getRecord ( ) . getField ( targetFieldName ) ) ; if ( fldTarget == null ) fldTarget = this . getOwner ( ) ; return fldTarget ; }
Get the field target .