idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
16,500
public static boolean isAlphaNumericOrContainsOnlyCharacters ( String in , String chars ) { char c = 0 ; for ( int i = 0 ; i < in . length ( ) ; i ++ ) { c = in . charAt ( i ) ; if ( Character . isLetterOrDigit ( c ) == ( chars . indexOf ( c ) != - 1 ) ) { return false ; } } return true ; }
tells whether all characters in a String are letters or digits or part of a given String
16,501
public static boolean containsCharacters ( String in , String chars ) { for ( int i = 0 ; i < chars . length ( ) ; i ++ ) { if ( in . indexOf ( chars . charAt ( i ) ) != - 1 ) { return true ; } } return false ; }
tells whether one or more characters in a String are part of a given String
16,502
public static String absorbInputStream ( InputStream input ) throws IOException { byte [ ] bytes = StreamSupport . absorbInputStream ( input ) ; return new String ( bytes ) ; }
keep reading until the InputStream is exhausted
16,503
public static List < String > split ( String input , String punctuationChars , boolean sort , boolean convertToLowerCase , boolean distinct ) { return split ( input , punctuationChars , "\"" , sort , convertToLowerCase , distinct ) ; }
reads all words in a text
16,504
public static String trim ( String input , int maxNrofChars , String end ) { if ( end == null ) { end = "" ; } int margin = end . length ( ) ; if ( input != null && input . length ( ) > maxNrofChars + margin ) { input = input . substring ( 0 , maxNrofChars ) + end ; } return input ; }
Trims strings that contain too many characters and adds trailing characters to indicate that the original string has been trimmed .
16,505
public static char [ ] createCharArray ( int size , char defaultVal ) { char [ ] retval = new char [ size ] ; if ( size > 0 ) { if ( size < 500 ) { for ( int i = 0 ; i < size ; i ++ ) { retval [ i ] = defaultVal ; } } else { initializelLargeCharArray ( retval , defaultVal ) ; } } return retval ; }
Creates a character array and initializes it with a default value .
16,506
public X509Certificate generateSelfSignedCertificate ( String subjectDN , KeyPair pair , int days , String algorithm ) throws CertificateException { return generateCertificate ( subjectDN , null , pair , null , days , algorithm ) ; }
Create a self - signed X . 509 Certificate
16,507
public X509Certificate generateCertificate ( String subjectDN , String issuerDN , KeyPair pair , PrivateKey privkey , int days , String signingAlgorithm ) throws CertificateException { if ( privkey == null ) { privkey = pair . getPrivate ( ) ; } X500Name issuer ; if ( issuerDN == null ) { issuer = new X500Name ( RFC4519Style . INSTANCE , subjectDN ) ; } else { issuer = new X500Name ( RFC4519Style . INSTANCE , issuerDN ) ; } long now = System . currentTimeMillis ( ) ; BigInteger serial = BigInteger . probablePrime ( 64 , new SecureRandom ( Primitives . writeLong ( now ) ) ) ; X500Name subject = new X500Name ( RFC4519Style . INSTANCE , subjectDN ) ; PublicKey publicKey = pair . getPublic ( ) ; byte [ ] encoded = publicKey . getEncoded ( ) ; SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo . getInstance ( encoded ) ; X509v3CertificateBuilder builder = new X509v3CertificateBuilder ( issuer , serial , new Date ( now - 86400000l ) , new Date ( now + days * 86400000l ) , subject , subjectPublicKeyInfo ) ; X509CertificateHolder holder = builder . build ( createSigner ( privkey , signingAlgorithm ) ) ; return new JcaX509CertificateConverter ( ) . getCertificate ( holder ) ; }
Create a signed X . 509 Certificate
16,508
public static < T extends TransactionalSetter > T getInstance ( Class < T > cls , Object intf ) { Class < ? > [ ] interfaces = cls . getInterfaces ( ) ; if ( interfaces . length != 1 ) { throw new IllegalArgumentException ( cls + " should implement exactly one interface" ) ; } boolean ok = false ; if ( ! interfaces [ 0 ] . isAssignableFrom ( intf . getClass ( ) ) ) { throw new IllegalArgumentException ( cls + " doesn't implement " + intf ) ; } try { TransactionalSetterClass annotation = cls . getAnnotation ( TransactionalSetterClass . class ) ; if ( annotation == null ) { throw new IllegalArgumentException ( "@" + TransactionalSetterClass . class . getSimpleName ( ) + " missing in cls" ) ; } Class < ? > c = Class . forName ( annotation . value ( ) ) ; T t = ( T ) c . newInstance ( ) ; t . intf = intf ; return t ; } catch ( ClassNotFoundException | InstantiationException | IllegalAccessException ex ) { throw new IllegalArgumentException ( ex ) ; } }
Creates a instance of a class TransactionalSetter subclass .
16,509
public void init ( Object env , Map < String , Object > properties , Object applet ) { if ( properties == null ) properties = new Hashtable < String , Object > ( ) ; if ( m_properties == null ) m_properties = properties ; else m_properties . putAll ( properties ) ; m_mapTasks = new HashMap < Task , RemoteTask > ( ) ; if ( applet != null ) m_sApplet = applet ; try { Class . forName ( "javax.jnlp.PersistenceService" ) ; this . setMuffinManager ( new MuffinManager ( this ) ) ; if ( this . getMuffinManager ( ) . isServiceAvailable ( ) ) if ( ( this . getProperty ( Params . REMOTE_HOST ) == null ) || ( this . getProperty ( Params . REMOTE_HOST ) . length ( ) == 0 ) ) this . setProperty ( Params . REMOTE_HOST , this . getAppServerName ( ) ) ; } catch ( Exception ex ) { } String strUser = this . getProperty ( Params . USER_ID ) ; if ( strUser == null ) if ( this . getProperty ( Params . USER_NAME ) == null ) if ( this . getMuffinManager ( ) != null ) { strUser = this . getMuffinManager ( ) . getMuffin ( Params . USER_ID ) ; this . setProperty ( Params . USER_ID , strUser ) ; } if ( strUser == null ) if ( this . getProperty ( Params . USER_NAME ) == null ) { try { strUser = System . getProperties ( ) . getProperty ( "user.name" ) ; this . setProperty ( Params . USER_NAME , strUser ) ; } catch ( java . security . AccessControlException ex ) { } } try { System . setProperty ( "javax.xml.parsers.DocumentBuilderFactory" , "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" ) ; } catch ( Exception e ) { } if ( Util . getPortableImageUtil ( ) == null ) { PortableImageUtil portableImageUtil = null ; try { Class . forName ( "javax.swing.ImageIcon" ) ; portableImageUtil = ( PortableImageUtil ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( SWING_IMAGE_UTIL ) ; } catch ( Exception ex ) { portableImageUtil = ( PortableImageUtil ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( ANDROID_IMAGE_UTIL ) ; } if ( portableImageUtil == null ) portableImageUtil = ( PortableImageUtil ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( SWING_IMAGE_UTIL ) ; Util . setPortableImageUtil ( portableImageUtil ) ; } }
Initialize the Application .
16,510
public void free ( ) { if ( m_mapTasks != null ) { while ( m_mapTasks . size ( ) > 0 ) { for ( Task task : m_mapTasks . keySet ( ) ) { if ( task != null ) { int iCount = 0 ; while ( task . isRunning ( ) ) { if ( iCount ++ == 10 ) { Util . getLogger ( ) . warning ( "Shutting down a running task" ) ; break ; } try { Thread . sleep ( 100 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } this . removeTask ( task ) ; task . setApplication ( null ) ; task . stopTask ( ) ; } else { try { RemoteTask remoteTask = m_mapTasks . remove ( task ) ; if ( remoteTask != null ) remoteTask . freeRemoteSession ( ) ; } catch ( RemoteException ex ) { ex . printStackTrace ( ) ; } } break ; } } } m_mapTasks = null ; if ( m_PhysicalDatabaseParent instanceof Freeable ) { ( ( Freeable ) m_PhysicalDatabaseParent ) . free ( ) ; m_PhysicalDatabaseParent = null ; } }
Free all the resources belonging to this application .
16,511
public int addTask ( Task task , Object remoteTask ) { if ( m_taskMain == null ) { if ( task != null ) if ( task . isMainTaskCandidate ( ) ) m_taskMain = task ; } m_mapTasks . put ( task , ( RemoteTask ) remoteTask ) ; return m_mapTasks . size ( ) ; }
Add this session screen or task that belongs to this application .
16,512
public boolean removeTask ( Task task ) { if ( task != null ) if ( ! m_mapTasks . containsKey ( task ) ) Util . getLogger ( ) . warning ( "Attempt to remove non-existent task" ) ; RemoteTask remoteTask = m_mapTasks . remove ( task ) ; if ( remoteTask != null ) { try { remoteTask . freeRemoteSession ( ) ; } catch ( RemoteException ex ) { ex . printStackTrace ( ) ; } } synchronized ( this ) { boolean bEndOfTasks = true ; if ( m_taskMain == task ) { if ( m_mapTasks . size ( ) == 0 ) m_taskMain = null ; else { m_taskMain = null ; for ( Task task2 : m_mapTasks . keySet ( ) ) { if ( task2 . isMainTaskCandidate ( ) ) { m_taskMain = task2 ; break ; } if ( task2 . isRunning ( ) ) { bEndOfTasks = false ; continue ; } } } } if ( m_taskMain != null ) return false ; return bEndOfTasks ; } }
Remove this session screen or task that belongs to this application .
16,513
public int getConnectionType ( ) { int iConnectionType = DEFAULT_CONNECTION_TYPE ; if ( this . getMuffinManager ( ) != null ) if ( this . getMuffinManager ( ) . isServiceAvailable ( ) ) iConnectionType = PROXY ; String strConnectionType = this . getProperty ( Params . CONNECTION_TYPE ) ; if ( strConnectionType != null ) { if ( "proxy" . equalsIgnoreCase ( strConnectionType ) ) iConnectionType = PROXY ; if ( Util . isNumeric ( strConnectionType ) ) iConnectionType = Integer . parseInt ( strConnectionType ) ; } if ( ClassServiceUtility . getClassService ( ) . getClassFinder ( null ) == null ) iConnectionType = PROXY ; return iConnectionType ; }
Get the connection type .
16,514
public String getAppServerName ( ) { String strServer = this . getProperty ( Params . REMOTE_HOST ) ; if ( ( strServer == null ) || ( strServer . length ( ) == 0 ) ) { URL urlCodeBase = this . getCodeBase ( ) ; if ( urlCodeBase != null ) { strServer = urlCodeBase . getHost ( ) ; int port = urlCodeBase . getPort ( ) ; if ( ( port != - 1 ) && ( port != 80 ) ) if ( ! strServer . contains ( ":" ) ) strServer = strServer + ':' + port ; } } return strServer ; }
Get the URL of the server .
16,515
public String getResourcePath ( String strResourceName ) { if ( strResourceName == null ) strResourceName = THIN_RES_PATH + "Menu" ; if ( ( ! strResourceName . endsWith ( RESOURCES ) ) && ( ! strResourceName . endsWith ( BUNDLE ) ) && ( ! strResourceName . endsWith ( PROPERTIES ) ) ) strResourceName = strResourceName + "Resources" ; if ( strResourceName . indexOf ( '.' ) == - 1 ) strResourceName = getResPackage ( ) + strResourceName ; if ( strResourceName . indexOf ( '.' ) == 0 ) strResourceName = Constants . ROOT_PACKAGE + strResourceName . substring ( 1 ) ; return strResourceName ; }
Fix this resource name to point to the resources .
16,516
public String getString ( String string ) { String strReturn = null ; try { if ( m_resources == null ) this . setLanguage ( null ) ; if ( m_resources != null ) if ( string != null ) strReturn = m_resources . getString ( string ) ; } catch ( MissingResourceException ex ) { strReturn = null ; } if ( ( strReturn != null ) && ( strReturn . length ( ) > 0 ) ) return strReturn ; else return string ; }
Look this key up in the current resource file and return the string in the local language . If no resource file is active return the string .
16,517
public String getLanguage ( boolean bCheckLocaleAlso ) { String strLanguage = this . getProperty ( Params . LANGUAGE ) ; if ( ( strLanguage == null ) || ( strLanguage . length ( ) == 0 ) ) if ( bCheckLocaleAlso ) return Locale . getDefault ( ) . getLanguage ( ) ; return strLanguage ; }
Get the current language .
16,518
public String getProperty ( String strProperty ) { String strValue = null ; if ( m_properties != null ) if ( m_properties . get ( strProperty ) != null ) strValue = m_properties . get ( strProperty ) . toString ( ) ; if ( strValue == null ) if ( m_sApplet != null ) strValue = this . getParameterByReflection ( m_sApplet , strProperty ) ; return strValue ; }
Get the value of this property key .
16,519
public int changePassword ( Task task , String strUserName , String strCurrentPassword , String strNewPassword ) { int iErrorCode = Constants . NORMAL_RETURN ; org . jbundle . thin . base . remote . RemoteTask remoteTask = ( org . jbundle . thin . base . remote . RemoteTask ) this . getRemoteTask ( null , strUserName , false ) ; Map < String , Object > properties = new HashMap < String , Object > ( ) ; properties . put ( Params . USER_NAME , strUserName ) ; properties . put ( Params . PASSWORD , strCurrentPassword ) ; properties . put ( "newPassword" , strNewPassword ) ; try { Object objReturn = remoteTask . doRemoteAction ( ThinMenuConstants . CHANGE_PASSWORD , properties ) ; if ( objReturn instanceof Integer ) iErrorCode = ( ( Integer ) objReturn ) . intValue ( ) ; } catch ( Exception ex ) { return task . setLastError ( ex . getMessage ( ) ) ; } return iErrorCode ; }
Change the password .
16,520
public String getSecurityErrorText ( int iErrorCode ) { String key = "Error " + Integer . toString ( iErrorCode ) ; if ( iErrorCode == Constants . ACCESS_DENIED ) key = "Access Denied" ; if ( iErrorCode == Constants . LOGIN_REQUIRED ) key = "Login required" ; if ( iErrorCode == Constants . AUTHENTICATION_REQUIRED ) key = "Authentication required" ; if ( iErrorCode == Constants . CREATE_USER_REQUIRED ) key = "Create user required" ; key = this . getResources ( ThinResourceConstants . ERROR_RESOURCE , true ) . getString ( key ) ; return key ; }
Get the error text for this security error .
16,521
public boolean classMatch ( String targetClass , String templateClass ) { if ( targetClass . startsWith ( BASE_CLASS ) ) return true ; if ( templateClass . endsWith ( "*" ) ) { if ( templateClass . startsWith ( "*" ) ) return targetClass . indexOf ( templateClass . substring ( 1 , templateClass . length ( ) - 1 ) ) != - 1 ; return targetClass . startsWith ( templateClass . substring ( 0 , templateClass . length ( ) - 1 ) ) ; } else { return templateClass . equalsIgnoreCase ( targetClass ) ; } }
Is this target class in the template class pattern?
16,522
public int registerUniqueApplication ( String strQueueName , String strQueueType ) { Map < String , Object > properties = new HashMap < String , Object > ( ) ; properties . put ( "removeListener" , Boolean . TRUE ) ; BaseMessage message = new MapMessage ( new BaseMessageHeader ( strQueueName , strQueueType , this , properties ) , properties ) ; this . getMessageManager ( ) . sendMessage ( message ) ; return Constants . NORMAL_RETURN ; }
Register this unique application so there will be only one running .
16,523
public String addUserParamsToURL ( String strURL ) { strURL = Util . addURLParam ( strURL , Constants . SYSTEM_NAME , this . getProperty ( Constants . SYSTEM_NAME ) , false ) ; strURL = Util . addURLParam ( strURL , Params . USER_ID , this . getProperty ( Params . USER_ID ) ) ; if ( this . getProperty ( Params . AUTH_TOKEN ) != null ) strURL = Util . addURLParam ( strURL , Params . AUTH_TOKEN , this . getProperty ( Params . AUTH_TOKEN ) ) ; return strURL ; }
Add this user s params to the URL so when I submit this to the server it can authenticate me .
16,524
void setComplete ( ) { this . complete = true ; try { if ( this . states . size ( ) == 0 ) { this . states . put ( new WorldState ( ) ) ; } else { this . states . put ( RESPONSE_COMPLETE ) ; } } catch ( InterruptedException e ) { log . error ( "Interrupted trying to indicate a completed condition." , e ) ; } }
Marks this StepResponse as completed . A StepResponse is completed when all WorldStates have been added to it and no others will be returned by the World Model .
16,525
public static void main ( String [ ] args ) { BaseApplet . main ( args ) ; BaseApplet applet = AppointmentCalendarApplet . getSharedInstance ( ) ; if ( applet == null ) applet = new AppointmentCalendarApplet ( args ) ; new JBaseFrame ( "Calendar" , applet ) ; }
For Stand - alone .
16,526
public int setSFieldValue ( String strParamValue , boolean bDisplayOption , int iMoveMode ) { String strButtonDesc = this . getButtonDesc ( ) ; String strButtonCommand = this . getButtonCommand ( ) ; if ( strButtonCommand != null ) if ( strButtonDesc != null ) if ( strButtonDesc . equals ( strParamValue ) ) { this . handleCommand ( strButtonCommand , this , ScreenConstants . USE_NEW_WINDOW ) ; return DBConstants . NORMAL_RETURN ; } return super . setSFieldValue ( strParamValue , bDisplayOption , iMoveMode ) ; }
Set this control s converter to this HTML param . ie . Check to see if this button was pressed .
16,527
public < T > void subscribe ( Subscriber < ? > subscriber , Class < T > messageType ) { subscribeStrategy . subscribe ( mapping , subscriber , messageType ) ; }
Subscribes the subscriber to the given type of message .
16,528
public < T > List < Subscriber < T > > unsubscribeAll ( Class < T > messageType ) { return subscribeStrategy . unsubscribeAll ( mapping , messageType ) ; }
Unsubscribes all subscribers listening to the given message type .
16,529
public < S extends Subscriber < T > , T > boolean unsubscribeByTypes ( S subscriberType , Class < T > messageType ) { return subscribeStrategy . unsubscribeByTypes ( mapping , subscriberType , messageType ) ; }
Forces subscribers to unsubscribe based on the given subscriber type and message type .
16,530
public < T > boolean unsubscribe ( Subscriber < T > s , Class < T > messageType ) { return subscribeStrategy . unsubscribe ( mapping , s , messageType ) ; }
Forces the given subscriber to unsubscribe from the given type of messages .
16,531
public void init ( Record record , BaseField fldDest , BaseField fldSource ) { super . init ( record , fldDest , fldSource , null , true , false , false , false , false , null , false ) ; }
This Constructor moves the source field to the dest field on valid .
16,532
public void addAction ( final LifecycleStage stage , final LifecycleAction < T > action ) { stageEvents . add ( new StageEvent ( stage , action ) ) ; }
Add a lifecycle Action to this provider . The action will called back when the lifecycle stage is hit and contain an object that was created by the provider .
16,533
static void register ( String group , long durationMillis ) { for ( ProfilingListener listener : LISTENERS ) { listener . register ( group , durationMillis ) ; } }
Register a duration in milliseconds for running a JDBC method .
16,534
protected boolean setConnector ( ) { if ( this . host == null ) { log . error ( "No host value set, cannot set up socket connector." ) ; return false ; } if ( this . port < 0 || this . port > 65535 ) { log . error ( "Port value is invalid {}." , Integer . valueOf ( this . port ) ) ; return false ; } if ( this . executors == null ) { this . executors = new ExecutorFilter ( 1 ) ; } this . connector = new NioSocketConnector ( ) ; this . connector . getSessionConfig ( ) . setIdleTime ( IdleStatus . WRITER_IDLE , ClientWorldModelInterface . TIMEOUT_PERIOD / 2 ) ; if ( ! this . connector . getFilterChain ( ) . contains ( WorldModelClientProtocolCodecFactory . CODEC_NAME ) ) { this . connector . getFilterChain ( ) . addLast ( WorldModelClientProtocolCodecFactory . CODEC_NAME , new ProtocolCodecFilter ( new WorldModelClientProtocolCodecFactory ( true ) ) ) ; } this . connector . getFilterChain ( ) . addLast ( "ExecutorPool" , this . executors ) ; this . connector . setHandler ( this . ioHandler ) ; log . debug ( "Connector set up successful." ) ; return true ; }
Sets - up the connector for this MINA session .
16,535
void finishConnection ( ) { NioSocketConnector conn = this . connector ; if ( conn != null ) { this . connector = null ; conn . dispose ( ) ; for ( ConnectionListener listener : this . connectionListeners ) { listener . connectionEnded ( this ) ; } } ExecutorFilter execs = this . executors ; if ( execs != null ) { this . executors = null ; execs . destroy ( ) ; } }
Cleans - up any resources after a connection has terminated . Should be called when the connection is disconnected and reconnect is not desired .
16,536
protected boolean _connect ( long timeout ) { log . debug ( "Attempting connection..." ) ; ConnectFuture connFuture = this . connector . connect ( new InetSocketAddress ( this . host , this . port ) ) ; if ( ! connFuture . awaitUninterruptibly ( timeout ) ) { log . warn ( "Unable to connect to world model after {}ms." , Long . valueOf ( this . connectionTimeout ) ) ; return false ; } if ( ! connFuture . isConnected ( ) ) { log . debug ( "Failed to connect." ) ; return false ; } try { log . debug ( "Attempting connection to {}:{}." , this . host , Integer . valueOf ( this . port ) ) ; this . session = connFuture . getSession ( ) ; } catch ( RuntimeIoException ioe ) { log . error ( String . format ( "Could not create session to World Model (C) %s:%d." , this . host , Integer . valueOf ( this . port ) ) , ioe ) ; return false ; } return true ; }
Attempts a connection to the world model .
16,537
protected void _disconnect ( ) { IoSession currentSession = this . session ; this . session = null ; this . sentHandshake = null ; this . receivedHandshake = null ; this . attributeAliasValues . clear ( ) ; this . originAliasValues . clear ( ) ; if ( currentSession != null && ! currentSession . isClosing ( ) ) { log . info ( "Closing connection to World Model (client) at {} (waiting {}ms)." , currentSession . getRemoteAddress ( ) , Long . valueOf ( this . connectionTimeout ) ) ; while ( ! currentSession . close ( false ) . awaitUninterruptibly ( this . connectionTimeout ) ) { log . error ( "Connection didn't close after {}ms." , Long . valueOf ( this . connectionTimeout ) ) ; } } if ( currentSession != null ) { for ( ConnectionListener listener : this . connectionListeners ) { listener . connectionInterrupted ( this ) ; } } }
Disconnects from the world model .
16,538
public synchronized long sendMessage ( AbstractRequestMessage message ) { log . debug ( "Sending {} to {}" , message , this ) ; message . setTicketNumber ( this . nextTicketNumber . getAndIncrement ( ) ) ; this . outstandingRequests . put ( Long . valueOf ( message . getTicketNumber ( ) ) , message ) ; this . session . write ( message ) ; return message . getTicketNumber ( ) ; }
Sends a request message to the world model .
16,539
public void cancelRequest ( long ticketNumber ) { if ( this . session != null && this . outstandingRequests . containsKey ( Long . valueOf ( ticketNumber ) ) ) { CancelRequestMessage message = new CancelRequestMessage ( ) ; message . setTicketNumber ( ticketNumber ) ; this . session . write ( message ) ; } else { log . warn ( "Tried to cancel unknown request for ticket number {}." , Long . valueOf ( ticketNumber ) ) ; } }
Cancels the request with the specified ticket number . Does nothing if the ticket is already complete or the ticket number doesn t match an existing request .
16,540
public boolean searchIdRegex ( final String idRegex ) { if ( idRegex == null ) { log . error ( "Unable to search for a null Identifier regex." ) ; return false ; } IdSearchMessage message = new IdSearchMessage ( ) ; message . setIdRegex ( idRegex ) ; this . session . write ( message ) ; log . debug ( "Sent {}" , message ) ; return true ; }
Search for an Identifier regular expression .
16,541
public static Class < ? > getInterface ( Class < ? > target , ClassFilter filter ) { Set < Class < ? > > interfaces = getInterfaces ( target , filter ) ; if ( ! interfaces . isEmpty ( ) ) { return interfaces . iterator ( ) . next ( ) ; } return null ; }
Returns the interface from target class that passes the supplied filter . This method also inspects any interfaces implemented by super classes .
16,542
public static Set < Class < ? > > getDeclaredInterfaces ( Class < ? > clazz , ClassFilter filter ) { Set < Class < ? > > interfacesFound = new HashSet < Class < ? > > ( ) ; Class < ? > [ ] interfaces = clazz . getInterfaces ( ) ; for ( Class < ? > interfaceClass : interfaces ) { if ( filter . passFilter ( interfaceClass ) ) { interfacesFound . add ( interfaceClass ) ; } } return interfacesFound ; }
Returns a set of interfaces that the from clazz that passes the supplied filter .
16,543
@ SuppressWarnings ( "unchecked" ) public static < T > Class < ? extends T > loadClass ( String className , Class < T > ofType ) { try { Class < ? > clazz = Class . forName ( className ) ; if ( ofType == null || ! ofType . isAssignableFrom ( clazz ) ) { throw new IllegalArgumentException ( "Class " + className + " must extend or implement " + ofType + "!" ) ; } return ( Class < ? extends T > ) clazz ; } catch ( ClassNotFoundException cnfe ) { throw new IllegalArgumentException ( "Class " + className + " could not be found!" , cnfe ) ; } }
Loads and returns the class named className of type superClass .
16,544
public static < E > int search ( E [ ] array , E value ) { return LinearSearch . search ( array , value , 1 ) ; }
Search for the value in the array and return the index of the first occurrence from the beginning of the array .
16,545
public static < E > int searchLast ( E [ ] array , E value ) { return LinearSearch . searchLast ( array , value , 1 ) ; }
Search for the value in the array and return the index of the first occurrence from the end of the array
16,546
public static < E > int search ( E [ ] array , E value , int occurrence ) { if ( occurrence <= 0 ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the array and return the index of the specified occurrence from the beginning of the array .
16,547
public static < E extends Comparable < E > > E searchMin ( List < E > list ) { if ( list . size ( ) == 0 ) { throw new IllegalArgumentException ( "The list you provided does not have any elements" ) ; } E min = list . get ( 0 ) ; for ( int i = 1 ; i < list . size ( ) ; i ++ ) { if ( list . get ( i ) . compareTo ( min ) < 0 ) { min = list . get ( i ) ; } } return min ; }
Search for the minimum element in the list .
16,548
public static < E extends Comparable < E > > E searchMax ( List < E > list ) { if ( list . size ( ) == 0 ) { throw new IllegalArgumentException ( "The list you provided does not have any elements" ) ; } E max = list . get ( 0 ) ; for ( int i = 1 ; i < list . size ( ) ; i ++ ) { if ( list . get ( i ) . compareTo ( max ) > 0 ) { max = list . get ( i ) ; } } return max ; }
Search for the maximum element in the list .
16,549
public static int search ( int [ ] intArray , int value , int occurrence ) { if ( occurrence <= 0 || occurrence > intArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < intArray . length ; i ++ ) { if ( intArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the int array and return the index of the specified occurrence from the beginning of the array .
16,550
public static int search ( char [ ] charArray , char value , int occurrence ) { if ( occurrence <= 0 || occurrence > charArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < charArray . length ; i ++ ) { if ( charArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the char array and return the index of the first occurrence from the beginning of the array .
16,551
public static int search ( byte [ ] byteArray , byte value , int occurrence ) { if ( occurrence <= 0 || occurrence > byteArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < byteArray . length ; i ++ ) { if ( byteArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the byte array and return the index of the first occurrence from the beginning of the array .
16,552
public static int search ( short [ ] shortArray , short value , int occurrence ) { if ( occurrence <= 0 || occurrence > shortArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < shortArray . length ; i ++ ) { if ( shortArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the short array and return the index of the first occurrence from the beginning of the array .
16,553
public static int search ( long [ ] longArray , long value , int occurrence ) { if ( occurrence <= 0 || occurrence > longArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < longArray . length ; i ++ ) { if ( longArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the long array and return the index of the first occurrence from the beginning of the array .
16,554
public static int search ( float [ ] floatArray , float value , int occurrence ) { if ( occurrence <= 0 || occurrence > floatArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < floatArray . length ; i ++ ) { if ( floatArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the float array and return the index of the first occurrence from the beginning of the array .
16,555
public static int search ( double [ ] doubleArray , double value , int occurrence ) { if ( occurrence <= 0 || occurrence > doubleArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = 0 ; i < doubleArray . length ; i ++ ) { if ( doubleArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the double array and return the index of the first occurrence from the beginning of the array .
16,556
public static int searchLast ( int [ ] intArray , int value , int occurrence ) { if ( occurrence <= 0 || occurrence > intArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = intArray . length - 1 ; i >= 0 ; i -- ) { if ( intArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the int array and return the index of the specified occurrence from the end of the array .
16,557
public static int searchLast ( char [ ] charArray , char value , int occurrence ) { if ( occurrence <= 0 || occurrence > charArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = charArray . length - 1 ; i >= 0 ; i -- ) { if ( charArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the char array and return the index of the first occurrence from the end of the array .
16,558
public static int searchLast ( byte [ ] byteArray , byte value , int occurrence ) { if ( occurrence <= 0 || occurrence > byteArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = byteArray . length - 1 ; i >= 0 ; i -- ) { if ( byteArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the byte array and return the index of the first occurrence from the end of the array .
16,559
public static int searchLast ( short [ ] shortArray , short value , int occurrence ) { if ( occurrence <= 0 || occurrence > shortArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = shortArray . length - 1 ; i >= 0 ; i -- ) { if ( shortArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the short array and return the index of the first occurrence from the end of the array .
16,560
public static int searchLast ( long [ ] longArray , long value , int occurrence ) { if ( occurrence <= 0 || occurrence > longArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = longArray . length - 1 ; i >= 0 ; i -- ) { if ( longArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the long array and return the index of the first occurrence from the end of the array .
16,561
public static int searchLast ( float [ ] floatArray , float value , int occurrence ) { if ( occurrence <= 0 || occurrence > floatArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = floatArray . length - 1 ; i >= 0 ; i -- ) { if ( floatArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the float array and return the index of the first occurrence from the end of the array .
16,562
public static int searchLast ( double [ ] doubleArray , double value , int occurrence ) { if ( occurrence <= 0 || occurrence > doubleArray . length ) { throw new IllegalArgumentException ( "Occurrence must be greater or equal to 1 and less than " + "the array length: " + occurrence ) ; } int valuesSeen = 0 ; for ( int i = doubleArray . length - 1 ; i >= 0 ; i -- ) { if ( doubleArray [ i ] == value ) { valuesSeen ++ ; if ( valuesSeen == occurrence ) { return i ; } } } return - 1 ; }
Search for the value in the double array and return the index of the first occurrence from the end of the array .
16,563
public < T > T asObject ( String string , Class < T > valueType ) { return ( T ) new File ( string ) ; }
Return file instance for the given path string .
16,564
public String asString ( Object object ) { return Files . path2unix ( ( ( File ) object ) . getPath ( ) ) ; }
Return file object path .
16,565
public < T > HttpClientRequest . Builder < T > head ( final URI uri , final HttpClientResponseHandler < T > httpHandler ) { return new HttpClientRequest . Builder < T > ( httpClientFactory , HttpClientMethod . HEAD , uri , httpHandler ) ; }
Start building a HEAD request .
16,566
public < T > HttpClientRequest . Builder < T > delete ( final URI uri , final HttpClientResponseHandler < T > httpHandler ) { return new HttpClientRequest . Builder < T > ( httpClientFactory , HttpClientMethod . DELETE , uri , httpHandler ) ; }
Start building a DELETE request .
16,567
public < T > HttpClientRequest . Builder < T > options ( final URI uri , final HttpClientResponseHandler < T > httpHandler ) { return new HttpClientRequest . Builder < T > ( httpClientFactory , HttpClientMethod . OPTIONS , uri , httpHandler ) ; }
Start building a OPTIONS request .
16,568
public < T > HttpClientRequest . Builder < T > put ( final URI uri , final HttpClientResponseHandler < T > httpHandler ) { return new HttpClientRequest . Builder < T > ( httpClientFactory , HttpClientMethod . PUT , uri , httpHandler ) ; }
Start building a PUT request .
16,569
public < T > HttpClientRequest . Builder < T > post ( final URI uri , final HttpClientResponseHandler < T > httpHandler ) { return new HttpClientRequest . Builder < T > ( httpClientFactory , HttpClientMethod . POST , uri , httpHandler ) ; }
Start building a POST request .
16,570
public void addListener ( FieldListener listener , BaseField field ) { super . addListener ( listener , field ) ; if ( listener . getOwner ( ) . getRecord ( ) == this . getRecord ( ) ) { Iterator < BaseTable > iterator = this . getTables ( ) ; while ( iterator . hasNext ( ) ) { BaseTable table = iterator . next ( ) ; if ( ( table != null ) && ( table != this . getNextTable ( ) ) ) { BaseField fldInTable = table . getRecord ( ) . getField ( field . getFieldName ( ) ) ; if ( fldInTable != null ) { FieldListener newBehavior = null ; try { newBehavior = ( FieldListener ) listener . clone ( fldInTable ) ; } catch ( CloneNotSupportedException ex ) { newBehavior = null ; } if ( newBehavior != null ) if ( newBehavior . getOwner ( ) == null ) fldInTable . addListener ( newBehavior ) ; } } } } }
Add a field listener to the chain . The listener must be cloned and added to all records on the list .
16,571
private String computeGetterName ( String name ) { StringBuilder _result = new StringBuilder ( ) . append ( PREFIX__GETTER ) ; _result . append ( Character . toUpperCase ( name . charAt ( 0 ) ) ) . append ( name . substring ( 1 ) ) ; return _result . toString ( ) ; }
Compute the getter name .
16,572
private String computeSetterName ( String name ) { StringBuilder _result = new StringBuilder ( ) . append ( PREFIX__SETTER ) ; _result . append ( Character . toUpperCase ( name . charAt ( 0 ) ) ) . append ( name . substring ( 1 ) ) ; return _result . toString ( ) ; }
Compute the setter name .
16,573
private SetterTarget findSetterTarget ( String path ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { String [ ] _accessStack = path . split ( REGEXP__CHAR_DOT ) ; if ( 0 == _accessStack . length ) { throw new IllegalArgumentException ( path ) ; } int _setterIndex = _accessStack . length - 1 ; Object _toChange = getObject ( ) ; for ( int _index = 0 ; _index < _setterIndex ; _index ++ ) { String _getterName = computeGetterName ( _accessStack [ _index ] ) ; Method _getter = _toChange . getClass ( ) . getMethod ( _getterName , ( Class < ? > [ ] ) null ) ; _toChange = _getter . invoke ( _toChange , ( Object [ ] ) null ) ; } String _setterName = computeSetterName ( _accessStack [ _setterIndex ] ) ; SetterTarget _target = new SetterTarget ( _toChange , _setterName ) ; return _target ; }
Find the object to change and the setter method name .
16,574
public static String getDocbookFileName ( final RESTImageV1 source ) { checkArgument ( source != null , "The source parameter can not be null" ) ; if ( source . getLanguageImages_OTM ( ) != null && source . getLanguageImages_OTM ( ) . getItems ( ) != null ) { final List < RESTLanguageImageV1 > langImages = source . getLanguageImages_OTM ( ) . returnItems ( ) ; for ( final RESTLanguageImageV1 langImage : langImages ) { final String filename = langImage . getFilename ( ) ; if ( filename != null ) { final int indexOfExtension = filename . lastIndexOf ( '.' ) ; if ( indexOfExtension != - 1 && indexOfExtension < filename . length ( ) - 1 ) { final String extension = filename . substring ( indexOfExtension , filename . length ( ) ) ; return source . getId ( ) + extension ; } } } } return "" ; }
The docbook file name for an image is the ID of the image and the extension of the first language image . This does imply that you can not mix and match image formats within a single image .
16,575
public void writeFieldOffsets ( FieldIterator fieldIterator , CodeType codeType ) { ClassInfo recClassInfo = ( ClassInfo ) this . getMainRecord ( ) ; boolean firstTime = true ; String strBaseFieldName ; String strFieldName = "MainField" ; Record recFieldData = this . getRecord ( FieldData . FIELD_DATA_FILE ) ; boolean alwaysInclude = false ; boolean alwaysExclude = false ; if ( recClassInfo . isARecord ( false ) ) { if ( codeType == CodeType . INTERFACE ) alwaysInclude = true ; else alwaysExclude = true ; } else { if ( codeType == CodeType . THICK ) alwaysInclude = true ; else alwaysExclude = true ; } for ( int pass = 1 ; pass <= 2 ; ++ pass ) { fieldIterator . close ( ) ; while ( fieldIterator . hasNext ( ) ) { fieldIterator . next ( ) ; strFieldName = recFieldData . getField ( FieldData . FIELD_NAME ) . getString ( ) ; strBaseFieldName = recFieldData . getField ( FieldData . BASE_FIELD_NAME ) . getString ( ) ; String type = "String" ; switch ( pass ) { case 1 : if ( strBaseFieldName . length ( ) > 0 ) { firstTime = false ; String value = convertNameToConstant ( strBaseFieldName ) ; String strPre = DBConstants . BLANK ; if ( recFieldData . getField ( FieldData . FIELD_NAME ) . getString ( ) . equals ( strBaseFieldName ) ) strPre = "//" ; strFieldName = convertNameToConstant ( strFieldName ) ; boolean includeThis = ( ( IncludeScopeField ) recFieldData . getField ( FieldData . INCLUDE_SCOPE ) ) . includeThis ( codeType , true ) ; if ( alwaysInclude ) includeThis = true ; if ( alwaysExclude ) includeThis = false ; if ( includeThis ) m_StreamOut . writeit ( "\n" + strPre + "public static final " + type + " " + strFieldName + " = " + value + ";" ) ; } break ; case 2 : if ( strBaseFieldName . length ( ) == 0 ) { firstTime = false ; boolean includeThis = ( ( IncludeScopeField ) recFieldData . getField ( FieldData . INCLUDE_SCOPE ) ) . includeThis ( codeType , true ) ; if ( alwaysInclude ) includeThis = true ; if ( alwaysExclude ) includeThis = false ; if ( Rec . ID . equals ( strFieldName ) ) includeThis = false ; if ( includeThis ) m_StreamOut . writeit ( "\n" + "public static final String " + this . convertNameToConstant ( strFieldName ) + " = \"" + strFieldName + "\";" ) ; break ; } } } recFieldData . close ( ) ; if ( pass == 2 ) { if ( ! firstTime ) m_StreamOut . writeit ( "\n" ) ; } } }
Write the constants for the field offsets
16,576
public boolean keyInBase ( Record recClassInfo , Record recKeyInfo ) { try { if ( recClassInfo2 == null ) recClassInfo2 = new ClassInfo ( this ) ; if ( recKeyInfo2 == null ) { recKeyInfo2 = new KeyInfo ( this ) ; recKeyInfo2 . setKeyArea ( KeyInfo . KEY_FILENAME_KEY ) ; SubFileFilter keyBehavior = new SubFileFilter ( recClassInfo2 . getField ( ClassInfo . CLASS_NAME ) , KeyInfo . KEY_FILENAME , null , null , null , null ) ; recKeyInfo2 . addListener ( keyBehavior ) ; } String baseClass = recClassInfo . getField ( ClassInfo . BASE_CLASS_NAME ) . toString ( ) ; while ( ( baseClass != null ) && ( baseClass . length ( ) > 0 ) && ( ! "FieldList" . equalsIgnoreCase ( baseClass ) ) ) { recClassInfo2 . getField ( ClassInfo . CLASS_NAME ) . setString ( baseClass ) ; recClassInfo2 . setKeyArea ( ClassInfo . CLASS_NAME_KEY ) ; if ( ! recClassInfo2 . seek ( "=" ) ) break ; recKeyInfo2 . close ( ) ; while ( recKeyInfo2 . hasNext ( ) ) { recKeyInfo2 . next ( ) ; String keyName = recKeyInfo . getField ( KeyInfo . KEY_NAME ) . toString ( ) ; if ( ( keyName == null ) || ( keyName . length ( ) == 0 ) ) keyName = recKeyInfo . getField ( KeyInfo . KEY_FIELD_1 ) . toString ( ) ; String keyName2 = recKeyInfo2 . getField ( KeyInfo . KEY_NAME ) . toString ( ) ; if ( ( keyName2 == null ) || ( keyName2 . length ( ) == 0 ) ) keyName2 = recKeyInfo2 . getField ( KeyInfo . KEY_FIELD_1 ) . toString ( ) ; if ( keyName2 . equals ( keyName ) ) return true ; } baseClass = recClassInfo2 . getField ( ClassInfo . BASE_CLASS_NAME ) . toString ( ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } return false ; }
Is this key already included in a base record?
16,577
public void writeFileMakeViews ( ) { if ( this . readThisMethod ( "makeScreen" ) ) { this . writeThisMethod ( CodeType . THICK ) ; return ; } if ( true ) { ClassInfo recClassInfo = ( ClassInfo ) this . getMainRecord ( ) ; ClassFields recClassFields = new ClassFields ( this ) ; recClassFields . addListener ( new SubFileFilter ( ClassFields . CLASS_INFO_CLASS_NAME_KEY , recClassInfo . getField ( ClassInfo . CLASS_NAME ) ) ) ; recClassFields . close ( ) ; try { boolean firstTime = true ; while ( recClassFields . hasNext ( ) ) { recClassFields . next ( ) ; String strClassFieldType = recClassFields . getField ( ClassFields . CLASS_FIELDS_TYPE ) . toString ( ) ; if ( strClassFieldType . equalsIgnoreCase ( ClassFieldsTypeField . SCREEN_CLASS_NAME ) ) { if ( firstTime ) { this . writeMethodInterface ( null , "makeScreen" , "ScreenParent" , "ScreenLoc itsLocation, ComponentParent parentScreen, int iDocMode, Map<String,Object> properties" , "" , "Make a default screen." , null ) ; m_StreamOut . writeit ( "\tScreenParent screen = null;\n" ) ; } String screenMode = recClassFields . getField ( ClassFields . CLASS_FIELD_INITIAL_VALUE ) . toString ( ) ; if ( ( screenMode == null ) || ( screenMode . length ( ) == 0 ) ) screenMode = "MAINT_MODE" ; if ( ! screenMode . contains ( "." ) ) screenMode = "ScreenConstants." + screenMode ; String fieldName = recClassFields . getField ( ClassFields . CLASS_FIELD_NAME ) . toString ( ) ; if ( firstTime ) m_StreamOut . writeit ( "\t" ) ; else m_StreamOut . writeit ( "\telse " ) ; m_StreamOut . write ( "if ((iDocMode & " + screenMode + ") == " + screenMode + ")\n" ) ; m_StreamOut . writeit ( "\t\tscreen = Record.makeNewScreen(" + fieldName + ", itsLocation, parentScreen, iDocMode | ScreenConstants.DONT_DISPLAY_FIELD_DESC, properties, this, true);\n" ) ; firstTime = false ; } } if ( ! firstTime ) { m_StreamOut . writeit ( "\telse\n" ) ; m_StreamOut . writeit ( "\t\tscreen = super.makeScreen(itsLocation, parentScreen, iDocMode, properties);\n" ) ; m_StreamOut . writeit ( "\treturn screen;\n}\n" ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } } }
Write the TableDoc code to DoMakeViews .
16,578
public void writeFree ( ) { Record recClassInfo = this . getMainRecord ( ) ; ClassFields recClassFields = new ClassFields ( this ) ; try { String strFieldName ; String strFieldClass ; recClassFields . setKeyArea ( ClassFields . CLASS_INFO_CLASS_NAME_KEY ) ; SubFileFilter fileBehavior2 = new SubFileFilter ( recClassInfo . getField ( ClassInfo . CLASS_NAME ) , ClassFields . CLASS_INFO_CLASS_NAME , null , null , null , null ) ; recClassFields . addListener ( fileBehavior2 ) ; recClassFields . close ( ) ; recClassFields . moveFirst ( ) ; this . writeMethodInterface ( null , "free" , "void" , "" , "" , "Release the objects bound to this record." , null ) ; m_StreamOut . setTabs ( + 1 ) ; m_StreamOut . writeit ( "super.free();\n" ) ; while ( recClassFields . hasNext ( ) ) { recClassFields . next ( ) ; strFieldName = recClassFields . getField ( ClassFields . CLASS_FIELD_NAME ) . getString ( ) ; String strClassFieldType = recClassFields . getField ( ClassFields . CLASS_FIELDS_TYPE ) . toString ( ) ; if ( ( strClassFieldType . equalsIgnoreCase ( ClassFieldsTypeField . CLASS_FIELD ) ) || ( strClassFieldType . equalsIgnoreCase ( ClassFieldsTypeField . NATIVE_FIELD ) ) ) if ( strFieldName . length ( ) != 0 ) if ( ! recClassFields . getField ( ClassFields . CLASS_FIELD_PROTECT ) . getString ( ) . equalsIgnoreCase ( "S" ) ) { String strReference = "" ; if ( strClassFieldType . equalsIgnoreCase ( ClassFieldsTypeField . CLASS_FIELD ) ) strReference = "null" ; else { strReference = recClassFields . getField ( ClassFields . CLASS_FIELD_INITIAL ) . getString ( ) ; if ( strReference . length ( ) == 0 ) { strReference = "0" ; strFieldClass = recClassFields . getField ( ClassFields . CLASS_FIELD_CLASS ) . getString ( ) ; if ( strFieldClass . equalsIgnoreCase ( "String" ) ) strReference = "\"\"" ; } } if ( ! strReference . equals ( "(none)" ) ) m_StreamOut . writeit ( "\t" + strFieldName + " = null;\n" ) ; } } recClassFields . close ( ) ; m_StreamOut . setTabs ( - 1 ) ; m_StreamOut . writeit ( "}\n" ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { if ( recClassFields != null ) recClassFields . free ( ) ; } }
Free the class .
16,579
public void readRecordClass ( String strRecordClass ) { String strBaseClass ; Record recClassInfo = this . getMainRecord ( ) ; if ( ! this . readThisClass ( strRecordClass ) ) strBaseClass = "Record" ; else { strBaseClass = recClassInfo . getField ( ClassInfo . BASE_CLASS_NAME ) . getString ( ) ; if ( strBaseClass . equalsIgnoreCase ( "Record" ) ) strBaseClass = "Record" ; if ( strBaseClass . length ( ) == 0 ) strBaseClass = "Record" ; } recClassInfo . getField ( ClassInfo . BASE_CLASS_NAME ) . setString ( strBaseClass ) ; }
Read the Class for this record
16,580
public void getBaseDataClass ( FieldStuff fieldStuff ) { Record recClassInfo2 = m_recClassInfo2 ; FieldData recFieldData = ( FieldData ) this . getRecord ( FieldData . FIELD_DATA_FILE ) ; String strRecordClass = recFieldData . getField ( FieldData . FIELD_CLASS ) . getString ( ) ; fieldStuff . strBaseFieldClass = null ; try { while ( true ) { recClassInfo2 . setKeyArea ( ClassInfo . CLASS_NAME_KEY ) ; recClassInfo2 . getField ( ClassInfo . CLASS_NAME ) . setString ( strRecordClass ) ; if ( ( ! recClassInfo2 . seek ( "=" ) ) || ( strRecordClass == null ) || ( strRecordClass . length ( ) == 0 ) ) { if ( fieldStuff . strBaseFieldClass == null ) fieldStuff . strBaseFieldClass = recFieldData . getField ( FieldData . FIELD_CLASS ) . getString ( ) ; return ; } if ( fieldStuff . strBaseFieldClass == null ) { String packageName = ( ( ClassInfo ) recClassInfo2 ) . getPackageName ( null ) ; if ( packageName . endsWith ( ".base.field" ) ) fieldStuff . strBaseFieldClass = recClassInfo2 . getField ( ClassInfo . CLASS_NAME ) . toString ( ) ; } if ( strRecordClass . indexOf ( "Field" ) != - 1 ) { String strType = strRecordClass . substring ( 0 , strRecordClass . indexOf ( "Field" ) ) ; if ( ( strType . equals ( "DateTime" ) ) || ( strType . equals ( "Time" ) ) ) strType = "Date" ; if ( strType . length ( ) > 0 ) if ( "Short Integer Double Float Boolean String Date" . indexOf ( strType ) != - 1 ) { if ( ( fieldStuff . strDataClass == null ) || ( fieldStuff . strDataClass . length ( ) == 0 ) ) fieldStuff . strDataClass = strType ; return ; } } strRecordClass = recClassInfo2 . getField ( ClassInfo . BASE_CLASS_NAME ) . getString ( ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } }
Read thru the classes until you get a Physical data class .
16,581
public void actionPerformed ( ActionEvent e ) { if ( e . getSource ( ) == m_cycletimer ) this . startNextFile ( ) ; else if ( e . getSource ( ) == m_timeouttimer ) this . checkTimeout ( ) ; }
Timer handling .
16,582
public synchronized void flush ( boolean bSendFakeTrx ) { try { if ( bSendFakeTrx ) this . getWriter ( ) . writeObject ( FAKE_TRX ) ; this . getWriter ( ) . flush ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Flush the buffer .
16,583
protected String getIdAndOptionsString ( ) { final String options = getOptionsString ( ) ; if ( isTopicANewTopic ( ) ) { return id + ( options . equals ( "" ) ? "" : ( ", " + options ) ) ; } else { return id + ( revision == null ? "" : ( ", rev: " + revision ) ) + ( options . equals ( "" ) ? "" : ( ", " + options ) ) ; } }
Get the ID and Options string for the topic .
16,584
public static boolean isWaiting ( int iStatusID ) { switch ( iStatusID ) { case REQUEST_SENT : case DATA_REQUIRED : return true ; case NULL_STATUS : case NO_STATUS : case PROPOSAL : case ACCEPTED : case CANCELED : case OKAY : case NOT_USED : case ERROR : case MANUAL_REQUEST_REQUIRED : case MANUAL_REQUEST_SENT : case NOT_VALID : case DATA_VALID : default : return false ; } }
Is this status waiting for an event to occur? .
16,585
public String getNewPassword ( ) { char [ ] rgchNewPassword = newPasswordField . getPassword ( ) ; char [ ] rgchConfirmPassword = confirmPasswordField . getPassword ( ) ; String strNewPassword = new String ( rgchNewPassword ) ; String strConfirmPassword = new String ( rgchConfirmPassword ) ; if ( strNewPassword != null ) if ( ! strNewPassword . equals ( strConfirmPassword ) ) return null ; return strNewPassword ; }
Compare the new and confirm password and return the new password .
16,586
public static boolean isInside ( Circle c1 , Circle c2 ) { return distanceFromCenter ( c1 , c2 . getX ( ) , c2 . getY ( ) ) + c2 . getRadius ( ) < c1 . getRadius ( ) ; }
Returns true if c2 is inside of c1
16,587
public T get ( Class < ? > clazz ) { if ( map == null || map . isEmpty ( ) ) { return null ; } Class < ? > classToInspect = clazz ; T object = map . get ( classToInspect ) ; if ( object == null && ! excludeInterfaces ) { object = getByInterfaces ( classToInspect ) ; } while ( object == null && classToInspect . getSuperclass ( ) != null ) { classToInspect = classToInspect . getSuperclass ( ) ; object = map . get ( classToInspect ) ; if ( object == null && ! excludeInterfaces ) { object = getByInterfaces ( classToInspect ) ; } } return object ; }
Returns the value of a map entry which key matches the supplied class or any of its super classes or any of its interfaces .
16,588
public T getByInterfaces ( Class < ? > clazz ) { T object = null ; Class < ? > [ ] interfaces = clazz . getInterfaces ( ) ; for ( Class < ? > interfaceClass : interfaces ) { object = map . get ( interfaceClass ) ; if ( object != null ) { break ; } } return object ; }
Returns the vale associated with the any interface implemented by the supplied class .
16,589
public MessageReceiverFilterList getMessageFilterList ( ) { if ( m_filterList == null ) { String strFilterType = null ; App app = this . getMessageQueue ( ) . getMessageManager ( ) . getApplication ( ) ; if ( app != null ) strFilterType = app . getProperty ( MessageConstants . MESSAGE_FILTER ) ; if ( MessageConstants . TREE_FILTER . equals ( strFilterType ) ) m_filterList = new TreeMessageFilterList ( this ) ; } return super . getMessageFilterList ( ) ; }
Get the message filter list . Create a new filter list the first time .
16,590
public void claimWork ( ) throws InterruptedException { synchronized ( cluster . allWorkUnits ) { for ( String workUnit : getUnclaimed ( ) ) { if ( isPeggedToMe ( workUnit ) ) { claimWorkPeggedToMe ( workUnit ) ; } } final double evenD = evenDistribution ( ) ; LinkedList < String > unclaimed = new LinkedList < String > ( getUnclaimed ( ) ) ; while ( myLoad ( ) <= evenD && ! unclaimed . isEmpty ( ) ) { final String workUnit = unclaimed . poll ( ) ; if ( config . useSoftHandoff && cluster . containsHandoffRequest ( workUnit ) && isFairGame ( workUnit ) && attemptToClaim ( workUnit , true ) ) { LOG . info ( workUnit ) ; handoffListener . finishHandoff ( workUnit ) ; } else if ( isFairGame ( workUnit ) ) { attemptToClaim ( workUnit ) ; } } } }
Begins by claiming all work units that are pegged to this node . Then continues to claim work from the available pool until we ve claimed equal to or slightly more than the total desired load .
16,591
public double myLoad ( ) { double load = 0d ; for ( String wu : cluster . myWorkUnits ) { Double d = cluster . getWorkUnitLoad ( wu ) ; if ( d != null ) { load += d ; } } return load ; }
Determines the current load on this instance when smart rebalancing is enabled . This load is determined by the sum of all of this node s meters one minute rate .
16,592
private void scheduleLoadTicks ( ) { Runnable sendLoadToZookeeper = new Runnable ( ) { public void run ( ) { final List < String > loads = new ArrayList < String > ( ) ; synchronized ( meters ) { for ( Map . Entry < String , Meter > entry : meters . entrySet ( ) ) { final String workUnit = entry . getKey ( ) ; loads . add ( String . format ( "/%s/meta/workload/%s" , cluster . name , workUnit ) ) ; loads . add ( String . valueOf ( entry . getValue ( ) . getOneMinuteRate ( ) ) ) ; } } Iterator < String > it = loads . iterator ( ) ; while ( it . hasNext ( ) ) { final String path = it . next ( ) ; final String rate = it . next ( ) ; try { ZKUtils . setOrCreate ( cluster . zk , path , rate , CreateMode . PERSISTENT ) ; } catch ( Exception e ) { LOG . error ( "Problems trying to store load rate for {} (value {}): ({}) {}" , path , rate , e . getClass ( ) . getName ( ) , e . getMessage ( ) ) ; } } String nodeLoadPath = String . format ( "/%s/nodes/%s" , cluster . name , cluster . myNodeID ) ; try { NodeInfo myInfo = new NodeInfo ( cluster . getState ( ) . toString ( ) , cluster . zk . get ( ) . getSessionId ( ) ) ; byte [ ] myInfoEncoded = JsonUtil . asJSONBytes ( myInfo ) ; ZKUtils . setOrCreate ( cluster . zk , nodeLoadPath , myInfoEncoded , CreateMode . EPHEMERAL ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "My load: {}" , myLoad ( ) ) ; } } catch ( Exception e ) { LOG . error ( "Error reporting load info to ZooKeeper." , e ) ; } } } ; loadFuture = cluster . scheduleAtFixedRate ( sendLoadToZookeeper , 0 , 1 , TimeUnit . MINUTES ) ; }
Once a minute pass off information about the amount of load generated per work unit off to Zookeeper for use in the claiming and rebalancing process .
16,593
public void createConnection ( ICredentials credentials , ConnectorClusterConfig config ) throws ConnectionException { logger . info ( "Creating new connection..." ) ; Connection connection = createNativeConnection ( credentials , config ) ; String connectionName = config . getName ( ) . getName ( ) ; synchronized ( connections ) { if ( ! connections . containsKey ( connectionName ) ) { connections . put ( connectionName , connection ) ; logger . info ( "Connected to [" + connectionName + "]" ) ; } else { String msg = "The connection [" + connectionName + "] already exists" ; logger . error ( msg ) ; throw new ConnectionException ( msg ) ; } } }
This method create a connection .
16,594
public boolean isConnected ( String clusterName ) { boolean isConnected = false ; synchronized ( connections ) { if ( connections . containsKey ( clusterName ) ) { isConnected = connections . get ( clusterName ) . isConnected ( ) ; } } return isConnected ; }
Return if a connection is connected .
16,595
public Connection getConnection ( String name ) throws ExecutionException { Connection connection = null ; synchronized ( connections ) { if ( connections . containsKey ( name ) ) { connection = connections . get ( name ) ; } else { String msg = "The connection [" + name + "] does not exist" ; logger . error ( msg ) ; throw new ExecutionException ( msg ) ; } } return connection ; }
This method return a connection .
16,596
public void startJob ( String targetCluster ) throws ExecutionException { getConnection ( targetCluster ) . setJobInProgress ( true ) ; logger . info ( "a new job has been started in cluster [" + targetCluster + "]" ) ; }
This method start a work for a connections .
16,597
public void endJob ( String targetCluster ) throws ExecutionException { getConnection ( targetCluster ) . setJobInProgress ( false ) ; logger . info ( "a new job has been finished in cluster [" + targetCluster + "]" ) ; }
This method finalize a work for a connections .
16,598
public void surveyComponents ( Component component ) { Component frame = component ; while ( frame != null ) { if ( frame instanceof Frame ) { title = ( ( Frame ) frame ) . getTitle ( ) ; break ; } frame = frame . getParent ( ) ; } if ( title == null ) title = BLANK ; Vector < Component > vector = new Vector < Component > ( ) ; this . addComponents ( ( ( Container ) component ) , vector ) ; if ( vector . size ( ) == 0 ) vector . add ( component ) ; this . componentList = new Component [ vector . size ( ) ] ; for ( int i = 0 ; i < vector . size ( ) ; i ++ ) { componentList [ i ] = ( Component ) vector . get ( i ) ; } this . resetAll ( ) ; }
Survey the components .
16,599
public void addComponents ( Container container , Vector < Component > vector ) { int components = container . getComponentCount ( ) ; int [ ] componentOrder = this . getComponentOrder ( container ) ; for ( int i = 0 ; i < components ; i ++ ) { Component component = container . getComponent ( componentOrder [ i ] ) ; if ( component instanceof JMenuBar ) continue ; if ( component instanceof JScrollPane ) { component = ( ( JScrollPane ) component ) . getViewport ( ) . getView ( ) ; if ( ! ( component instanceof JTable ) ) { vector . add ( component ) ; component = null ; } } if ( component instanceof JTable ) { JComponent header = ( ( JTable ) component ) . getTableHeader ( ) ; if ( header != null ) vector . add ( header ) ; vector . add ( component ) ; component = null ; } if ( component instanceof JToolBar ) { vector . add ( component ) ; component = null ; } if ( component instanceof Container ) this . addComponents ( ( ( Container ) component ) , vector ) ; } }
Go through all the components and order the ones that I need to print .