idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
14,800
public void addBrowserProperties ( HttpServletRequest req , PropertyOwner servletTask ) { String strBrowser = this . getBrowser ( req ) ; String strOS = this . getOS ( req ) ; servletTask . setProperty ( DBParams . BROWSER , strBrowser ) ; servletTask . setProperty ( DBParams . OS , strOS ) ; }
Add the browser properties to this servlet task .
14,801
public UserSettingJdo newLocalDate ( final String user , final String key , final String description , final LocalDate value ) { return newSetting ( user , key , description , SettingType . LOCAL_DATE , value . toString ( SettingAbstract . DATE_FORMATTER ) ) ; }
region > newLocalDate
14,802
protected void enqueueNotification ( final Notification not ) { not . lastRun = System . currentTimeMillis ( ) ; final SubscriptionSummary summary = postNotification ( not . subscriber , not . mimeType , not . payload ) ; not . callback . onSummaryInfo ( summary ) ; }
A blocking call that performs a notification . If there are pending retries that are older than two minutes old they will be retried before the method returns .
14,803
public void printHtmlHeaderArea ( PrintWriter out ) { ClassInfoModel classInfo = ( ( HelpScreen ) this . getScreenField ( ) ) . getClassInfo ( ) ; if ( classInfo != null ) if ( classInfo . isValidRecord ( ) ) { String strHeader = " <title>Technical Help Screen - " + Utility . encodeXML ( classInfo . getClassDesc ( ) ) + " </title>" + " <meta-description>" + Utility . encodeXML ( classInfo . getClassExplain ( ) ) + "</meta-description>" ; out . println ( strHeader ) ; } }
Get the top menu .
14,804
public BaseMessage processMessage ( BaseMessage message ) { RunRemoteProcessMessageData runRemoteProcessMessageData = ( RunRemoteProcessMessageData ) message . getMessageDataDesc ( null ) ; if ( runRemoteProcessMessageData == null ) message . addMessageDataDesc ( runRemoteProcessMessageData = new RunRemoteProcessMessageData ( null , null ) ) ; CreateSiteMessageData siteMessageData = ( CreateSiteMessageData ) runRemoteProcessMessageData . getMessageDataDesc ( CreateSiteMessageData . CREATE_SITE ) ; if ( siteMessageData == null ) runRemoteProcessMessageData . addMessageDataDesc ( siteMessageData = new CreateSiteMessageData ( runRemoteProcessMessageData , null ) ) ; StandardMessageResponseData reply = this . setupUserInfo ( siteMessageData ) ; if ( reply == null ) return null ; return reply . getMessage ( ) ; }
Process this message and return a reply .
14,805
public void createCustomArchive ( String destArchivePath , String homePath , String templateArchivePath , String templateFilename ) { Record recUser = this . getMainRecord ( ) ; Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( "${email}" , recUser . getField ( UserInfo . USER_NAME ) . toString ( ) ) ; Date date = new Date ( ) ; DateField dateField = new DateField ( null , null , - 1 , null , null ) ; dateField . setDate ( date , DBConstants . DISPLAY , DBConstants . INIT_MOVE ) ; map . put ( "${today}" , dateField . toString ( ) ) ; dateField . free ( ) ; URL url = this . getTask ( ) . getApplication ( ) . getResourceURL ( templateFilename , null ) ; StringBuilder sb = new StringBuilder ( Utility . transferURLStream ( url . toString ( ) , null ) ) ; sb = Utility . replace ( sb , map ) ; String templateFile = Utility . addToPath ( destArchivePath , "fixdemo.xsl" ) ; PrintWriter out = null ; try { File file = new File ( templateFile ) ; file . getParentFile ( ) . getParentFile ( ) . mkdirs ( ) ; file . getParentFile ( ) . mkdirs ( ) ; file . createNewFile ( ) ; out = new PrintWriter ( file ) ; } catch ( FileNotFoundException e ) { } catch ( IOException e ) { e . printStackTrace ( ) ; } if ( out != null ) { out . print ( sb ) ; out . close ( ) ; String workDir = templateArchivePath ; if ( workDir . lastIndexOf ( File . separator ) != - 1 ) workDir = workDir . substring ( workDir . lastIndexOf ( File . separator ) + 1 ) ; String workDirPath = Utility . addToPath ( homePath , workDir ) ; this . populateSourceDir ( templateArchivePath , workDirPath ) ; Map < String , Object > properties = new HashMap < String , Object > ( ) ; properties . put ( "sourceDir" , workDirPath ) ; properties . put ( "destDir" , destArchivePath ) ; properties . put ( "extension" , "xml" ) ; properties . put ( "filter" , ".*" ) ; properties . put ( "listenerClass" , XMLScanListener . class . getName ( ) ) ; properties . put ( "converterPath" , templateFile ) ; BaseProcess process = new ConvertCode ( this . getTask ( ) , null , properties ) ; process . run ( ) ; process . free ( ) ; } }
CreateCustomArchive Method .
14,806
public boolean setMainKey ( boolean bDisplayOption , Boolean boolSetModified , boolean bSetIfModified ) { super . setMainKey ( bDisplayOption , boolSetModified , bSetIfModified ) ; boolean bNonNulls = false ; if ( m_fldThisFile != null ) { m_fldThisFile . setString ( m_strFirst , bDisplayOption , DBConstants . READ_MOVE ) ; if ( ! m_fldThisFile . isNull ( ) ) bNonNulls = true ; } if ( m_fldThisFile2 != null ) { m_fldThisFile2 . setString ( m_strSecond , bDisplayOption , DBConstants . READ_MOVE ) ; if ( ! m_fldThisFile2 . isNull ( ) ) bNonNulls = true ; } if ( m_fldThisFile3 != null ) { m_fldThisFile3 . setString ( m_strThird , bDisplayOption , DBConstants . READ_MOVE ) ; if ( ! m_fldThisFile3 . isNull ( ) ) bNonNulls = true ; } return bNonNulls ; }
Setup the target key field to the initial string values .
14,807
public void update ( long time , double latitude , double longitude , double rateOfTurn ) { if ( strat == Strategy . LONG ) { throw new IllegalStateException ( "mixing short/long update" ) ; } strat = Strategy . SHORT ; lock . lock ( ) ; try { if ( prevTime > 0 ) { this . time = time ; this . latitude = latitude ; this . longitude = longitude ; this . speed = speed ( prevTime , prevLatitude , prevLongitude , time , latitude , longitude ) ; this . bearing = bearing ( prevLatitude , prevLongitude , latitude , longitude ) ; this . rateOfTurn = rateOfTurn ; calculated = false ; } prevTime = time ; prevLatitude = latitude ; prevLongitude = longitude ; } finally { lock . unlock ( ) ; } }
Updates values and calculates speed and bearing .
14,808
public void update ( long time , double latitude , double longitude , double speed , double bearing , double rateOfTurn ) { if ( strat == Strategy . SHORT ) { throw new IllegalStateException ( "mixing short/long update" ) ; } strat = Strategy . LONG ; lock . lock ( ) ; try { this . time = time ; this . latitude = latitude ; this . longitude = longitude ; this . speed = speed ; this . bearing = bearing ; this . rateOfTurn = rateOfTurn ; calculated = false ; } finally { lock . unlock ( ) ; } }
Updates values .
14,809
public final double estimatedLatitude ( long et ) { et = correctedTime ( et ) ; lock . lock ( ) ; try { calc ( ) ; if ( rateOfTurn == 0 ) { double dist = calcDist ( et ) ; return latitude + deltaLatitude ( dist , bearing ) ; } else { double deg = calcDeg ( et ) ; return centerLatitude + deltaLatitude ( radius , deg ) ; } } finally { lock . unlock ( ) ; } }
Returns estimated latitude at et
14,810
public final double estimatedLongitude ( long et ) { et = correctedTime ( et ) ; lock . lock ( ) ; try { calc ( ) ; if ( rateOfTurn == 0 ) { double dist = calcDist ( et ) ; return addLongitude ( longitude , deltaLongitude ( latitude , dist , bearing ) ) ; } else { double deg = calcDeg ( et ) ; return addLongitude ( centerLongitude , deltaLongitude ( latitude , radius , deg ) ) ; } } finally { lock . unlock ( ) ; } }
Return estimated longitude at et
14,811
public final Location estimatedLocation ( long et ) { lock . lock ( ) ; try { return new Location ( estimatedLatitude ( et ) , estimatedLongitude ( et ) ) ; } finally { lock . unlock ( ) ; } }
Using this method protects from parallel updates
14,812
private static DatagramPacket optionallyCopyData ( DatagramPacket packet ) { if ( packet != null ) { packet . setData ( packet . getData ( ) . clone ( ) , packet . getOffset ( ) , packet . getLength ( ) ) ; } return packet ; }
Makes a copy of the data in the packet to make the packet safe to store for longer periods of time .
14,813
public void sendMessage ( Message message ) throws RemoteException { BaseTransport transport = this . createProxyTransport ( SEND_MESSAGE ) ; transport . addParam ( MESSAGE , message ) ; transport . sendMessageAndGetReply ( ) ; }
Send a remote message .
14,814
public static < I > JMSubscriber < I > getSOPLSubscriber ( Function < I , ? > transformFunction ) { return build ( o -> System . out . println ( transformFunction . apply ( o ) ) ) ; }
Gets sopl subscriber .
14,815
public static < I > JMSubscriber < I > getJsonStringSOPLSubscriber ( Function < I , ? > transformFunction ) { return getSOPLSubscriber ( o -> JMJson . toJsonString ( transformFunction . apply ( o ) ) ) ; }
Gets json string sopl subscriber .
14,816
public static < I > JMFileSubscriber < I > buildJsonStringFileSubscriber ( String filePath , Function < Object , String > toStringFunction ) { return new JMFileSubscriber < > ( filePath , toStringFunction ) ; }
Build json string file subscriber jm file subscriber .
14,817
private File findFile ( String fileName , List path ) { final String methodName = "findFile(): " ; String fileSeparator = System . getProperty ( "file.separator" ) ; for ( Iterator i = path . iterator ( ) ; i . hasNext ( ) ; ) { String directory = ( String ) i . next ( ) ; if ( ! directory . endsWith ( fileSeparator ) && ! fileName . startsWith ( fileSeparator ) ) { directory = directory + fileSeparator ; } File file = new File ( directory + fileName ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( methodName + " checking '" + file . getAbsolutePath ( ) + "'" ) ; } if ( file . exists ( ) && file . canRead ( ) ) { log . debug ( methodName + " found it - file is '" + file . getAbsolutePath ( ) + "'" ) ; cache . put ( fileName , new CacheEntry ( file ) ) ; return file ; } } return null ; }
Finds a file if it exists in a list of provided paths
14,818
public BaseField getCodeField ( ) { Record record = this . getOwner ( ) ; if ( m_iCodeField != null ) return record . getField ( m_iCodeField ) ; else return record . getKeyArea ( record . getCodeKeyArea ( ) ) . getField ( DBConstants . MAIN_KEY_FIELD ) ; }
Get the code field .
14,819
public int moveIDToCodeField ( ) { if ( this . getCodeField ( ) . isNull ( ) ) return getCodeField ( ) . moveFieldToThis ( ( BaseField ) this . getOwner ( ) . getCounterField ( ) ) ; else return DBConstants . NORMAL_RETURN ; }
Move the ID field to the code field .
14,820
public String tabsToSpaces ( String string ) { int iOffset = 0 ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { if ( string . charAt ( i ) == '\n' ) iOffset = i + 1 ; if ( string . charAt ( i ) == '\t' ) { int iSpaces = ( i - iOffset ) % 4 ; if ( iSpaces == 0 ) iSpaces = 4 ; string = string . substring ( 0 , i ) + FOUR_SPACES . substring ( 0 , iSpaces ) + string . substring ( i + 1 ) ; } } return string ; }
Convert the tabs to spaces .
14,821
public void setSampleStyle ( ) { Color colorBackground = ScreenUtil . getColor ( ScreenUtil . BACKGROUND_COLOR , null , properties ) ; Color colorControl = ScreenUtil . getColor ( ScreenUtil . CONTROL_COLOR , null , properties ) ; Color colorText = ScreenUtil . getColor ( ScreenUtil . TEXT_COLOR , null , properties ) ; samplePanel . setBackground ( colorBackground ) ; if ( colorBackground == null ) samplePanel . setBackground ( SystemColor . window ) ; Font font = ScreenUtil . getFont ( null , properties , true ) ; sampleLabel . setFont ( font ) ; sampleTextField . setFont ( font ) ; sampleTextField . setBackground ( colorControl ) ; if ( colorControl == null ) sampleTextField . setBackground ( SystemColor . text ) ; sampleLabel . setForeground ( colorText ) ; if ( colorText == null ) sampleLabel . setForeground ( SystemColor . textText ) ; sampleTextField . setForeground ( colorText ) ; if ( colorText == null ) sampleTextField . setForeground ( SystemColor . textText ) ; if ( colorBackground != null ) backgroundButton . setBackground ( colorBackground ) ; if ( colorControl != null ) controlColorButton . setBackground ( colorControl ) ; if ( colorText != null ) textColorButton . setBackground ( colorText ) ; this . invalidate ( ) ; }
Handle the button actions .
14,822
private JAXBContext getJAXBContext ( Class < ? extends CCBAPIResponse > responseClass ) { if ( ! jaxbContextCache . containsKey ( responseClass ) ) { synchronized ( jaxbContextCache ) { if ( ! jaxbContextCache . containsKey ( responseClass ) ) { try { final JAXBContext jaxbContext = JAXBContext . newInstance ( responseClass ) ; jaxbContextCache . put ( responseClass , jaxbContext ) ; } catch ( JAXBException e ) { throw new AssertionError ( "Could not construct JAXBContext for " + responseClass . getName ( ) , e ) ; } } } } return jaxbContextCache . get ( responseClass ) ; }
Find or create the JAXBContext for a CCBAPIResponse implementation .
14,823
public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { if ( m_bSetModified ) m_fldTarget . setModified ( true ) ; return m_fldTarget . handleFieldChanged ( bDisplayOption , iMoveMode ) ; }
The Field has Changed . Initialize the target field also .
14,824
public Object convert ( String property , Object value ) { if ( value == null ) { return defaultMap . get ( property ) ; } Class < ? > type = getType ( property ) ; if ( type == null ) { throw new IllegalArgumentException ( property + " unknown" ) ; } return ConvertUtil . convertTo ( value , type ) ; }
Tries to convert object to model type
14,825
public DataObjectModel view ( int from ) { DataObjectModel view = clone ( ) ; view . propertyList = propertyList . subList ( from , propertyList . size ( ) ) ; return view ; }
Returns a clone of this model where only propertyList starting from from are present .
14,826
public DataObjectModel view ( String ... properties ) { DataObjectModel view = clone ( ) ; view . propertyList = new ArrayList < String > ( ) ; for ( String property : properties ) { view . propertyList . add ( property ) ; } return view ; }
Returns a clone of this model where only listed propertyList are present .
14,827
public DataObjectModel view ( Collection < ? extends DataObject > dos ) { DataObjectModel view = clone ( ) ; view . propertyList = new ArrayList < String > ( ) ; Set < String > propertySet = new HashSet < String > ( ) ; for ( DataObject dob : dos ) { for ( String property : propertyList ) { Object value = dob . get ( property ) ; if ( value != null ) { propertySet . add ( property ) ; } } } for ( String property : propertyList ) { if ( propertySet . contains ( property ) ) { view . propertyList . add ( property ) ; } } return view ; }
Returns a clone of this model where only properties that have values are present
14,828
public DataObjectModel hide ( String ... properties ) { DataObjectModel view = clone ( ) ; view . propertyList = new ArrayList < String > ( ) ; view . propertyList . addAll ( this . propertyList ) ; for ( String property : properties ) { view . propertyList . remove ( property ) ; } return view ; }
Returns a clone of model where listed propertyList are hidden ;
14,829
protected final JButton getButtonOK ( ) { if ( buttonOK == null ) { buttonOK = new JButton ( ) ; buttonOK . setText ( "OK" ) ; buttonOK . setPreferredSize ( new Dimension ( 80 , 26 ) ) ; buttonOK . addActionListener ( new ActionListener ( ) { public void actionPerformed ( final ActionEvent e ) { if ( destDirSelector != null ) { destDirSelector . ok ( ) ; } } } ) ; } return buttonOK ; }
Returns the OK button for usage as default button .
14,830
protected final JButton getButtonCancel ( ) { if ( buttonCancel == null ) { buttonCancel = new JButton ( ) ; buttonCancel . setText ( "Cancel" ) ; buttonCancel . setPreferredSize ( new Dimension ( 80 , 26 ) ) ; buttonCancel . addActionListener ( new ActionListener ( ) { public void actionPerformed ( final ActionEvent e ) { if ( destDirSelector != null ) { destDirSelector . cancel ( ) ; } } } ) ; } return buttonCancel ; }
Returns the Cancel button for usage as default button .
14,831
public void open ( URL eventStreamURL ) throws IOException { log . info ( "Connecting to event stream |%s|." , eventStreamURL ) ; connection = ( HttpURLConnection ) eventStreamURL . openConnection ( ) ; connection . setConnectTimeout ( CONNECTION_TIMEOUT ) ; connection . setReadTimeout ( READ_TIMEOUT ) ; connection . setRequestProperty ( "Accept" , "text/event-stream" ) ; connection . setRequestProperty ( "Connection" , "keep-alive" ) ; connection . setRequestProperty ( "Pragma" , "no-cache" ) ; connection . setRequestProperty ( "Cache" , "no-cache" ) ; inputStream = connection . getInputStream ( ) ; }
Opens connection with given event stream and initialize internal input stream . Because this method involve networking and server side processes it is not instant . Anyway usually cannot exceed one second or two .
14,832
public void close ( ) throws InterruptedException { assert connection != null ; if ( connection != null ) { Files . close ( inputStream ) ; if ( thread . isAlive ( ) ) { synchronized ( this ) { if ( thread . isAlive ( ) ) { thread . wait ( THREAD_STOP_TIMEOUT ) ; } } } } }
Close this event stream client . This method stops receiving thread and closes internal input stream . It is not necessary if end of event stream is controlled by server side in with case this event stream client does auto - close .
14,833
public PropertyOwner retrieveUserProperties ( ) { Record record = this . getOwner ( ) . getRecord ( ) ; ComponentParent screen = null ; if ( record . getRecordOwner ( ) instanceof ComponentParent ) screen = ( ComponentParent ) record . getRecordOwner ( ) ; if ( screen != null ) return screen . retrieveUserProperties ( ) ; else return null ; }
Get the owner of this property key . The registration key is the screen s key . The property key is the field name .
14,834
private void select ( Type type , Object value ) { assert value != null ; reloadElement ( ) ; this . selectByType ( type , value ) ; }
this private method try to search the value of the select for n seconds specified by TIMEOUT static variable . The coerence if the data passed is or isn t the correct value is responsability of the test developer .
14,835
public boolean getState ( ) { if ( this . getData ( ) == null ) return m_bTrueIfNull ; int fieldValue = ( int ) this . getValue ( ) ; boolean returnValue = false ; if ( ( fieldValue & ( 1 << m_iBitNumber ) ) != 0 ) returnValue = true ; if ( m_bTrueIfMatch ) return returnValue ; else return ! returnValue ; }
For binary fields return the current state . Gets the state of the target bit .
14,836
public int setState ( boolean bState , boolean bDisplayOption , int iMoveMode ) { int iFieldValue = ( int ) this . getValue ( ) ; if ( ! m_bTrueIfMatch ) bState = ! bState ; if ( bState ) iFieldValue |= ( 1 << m_iBitNumber ) ; else iFieldValue &= ~ ( 1 << m_iBitNumber ) ; return this . setValue ( iFieldValue , bDisplayOption , iMoveMode ) ; }
For binary fields set the current state . Sets the target bit to the state .
14,837
private static InputStream findStream ( String filename ) { InputStream streamOnClass = JDefaultAddress . class . getResourceAsStream ( filename ) ; if ( streamOnClass != null ) { return streamOnClass ; } InputStream is = JDefaultAddress . class . getClassLoader ( ) . getResourceAsStream ( filename ) ; return is ; }
Finds the InputStream of a file in a Jar
14,838
protected static Object fetch ( String key ) { List valuesArray = ( List ) fetchObject ( key ) ; return valuesArray . get ( RandomUtils . nextInt ( valuesArray . size ( ) ) ) ; }
Fetches a random Object from the dictionary based on a key
14,839
protected static String fetchList ( String key ) { List valuesArray = ( List ) fetchObject ( key ) ; List < String > stringList1 = ( List < String > ) valuesArray . get ( 0 ) ; List < String > stringList2 = ( List < String > ) valuesArray . get ( 1 ) ; List < String > stringList3 = ( List < String > ) valuesArray . get ( 2 ) ; return stringList1 . get ( RandomUtils . nextInt ( stringList1 . size ( ) ) ) + " " + stringList2 . get ( RandomUtils . nextInt ( stringList2 . size ( ) ) ) + " " + stringList3 . get ( RandomUtils . nextInt ( stringList3 . size ( ) ) ) ; }
Fetches a List of of Values
14,840
protected static String fetchString ( String key ) { List < String > stringList = ( List < String > ) fetchObject ( key ) ; return stringList . get ( RandomUtils . nextInt ( stringList . size ( ) ) ) ; }
Fetches a value
14,841
protected static Object fetchObject ( String key ) { String [ ] path = key . split ( "\\." ) ; Object currentValue = fakeValuesMap ; for ( String pathSection : path ) { currentValue = ( ( Map < String , Object > ) currentValue ) . get ( pathSection ) ; } return currentValue ; }
Finds map of values based on a key
14,842
protected static String letterify ( String letterString ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < letterString . length ( ) ; i ++ ) { if ( letterString . charAt ( i ) == '?' ) { sb . append ( ( char ) ( 97 + RandomUtils . nextInt ( 26 ) ) ) ; } else { sb . append ( letterString . charAt ( i ) ) ; } } return sb . toString ( ) ; }
Replace ? in a string with random letters
14,843
protected static String parseFoundKey ( String value ) { String regex = "#\\{([A-Za-z]+\\.)?([^\\}]+)\\}" ; Pattern p = Pattern . compile ( regex ) ; Matcher matcher = p . matcher ( value ) ; while ( matcher . find ( ) ) { String keyMatched = matcher . group ( ) . trim ( ) ; String trimmedKey = StringUtils . substring ( keyMatched , 2 , keyMatched . length ( ) - 1 ) ; String replacedValue = fetchString ( trimmedKey ) ; if ( StringUtils . contains ( replacedValue , "#{" ) ) { replacedValue = parseFoundKey ( replacedValue ) ; } value = StringUtils . replace ( value , keyMatched , replacedValue ) ; } return value ; }
resolves an embedded key
14,844
public void run ( ) { if ( ! EventQueue . isDispatchThread ( ) ) { if ( ! m_syncPage . isPaintCalled ( ) ) { synchronized ( m_syncPage ) { while ( ! m_syncPage . isPaintCalled ( ) ) { try { m_syncPage . wait ( ) ; } catch ( InterruptedException e ) { } } } } synchronized ( m_syncPage ) { m_syncPage . setPaintCalled ( false ) ; this . runPageLoader ( ) ; while ( ! m_syncPage . isPaintCalled ( ) ) { try { m_syncPage . wait ( ) ; } catch ( InterruptedException e ) { } } this . afterPageDisplay ( ) ; } } }
Make sure everything goes in the right order .
14,845
public static boolean validatePassword ( BrokerSession session , String password ) { password = encrypt ( password , session . getServerCaps ( ) . getCipherKey ( ) ) ; return session . callRPCBool ( "RGCWFUSR VALIDPSW" , password ) ; }
Validates the current user s password .
14,846
public static String changePassword ( BrokerSession session , String oldPassword , String newPassword ) { String cipherKey = session . getServerCaps ( ) . getCipherKey ( ) ; String result = session . callRPC ( "RGNETBRP CVC" , encrypt ( oldPassword , cipherKey ) , encrypt ( newPassword , cipherKey ) ) ; return result . startsWith ( "0" ) ? null : StrUtil . piece ( result , StrUtil . U , 2 ) ; }
Change a password .
14,847
protected static String encrypt ( String value , String cipherKey ) { String [ ] cipher = CipherRegistry . getCipher ( cipherKey ) ; int associatorIndex = randomIndex ( cipher . length ) ; int identifierIndex ; do { identifierIndex = randomIndex ( cipher . length ) ; } while ( associatorIndex == identifierIndex ) ; return ( ( char ) ( associatorIndex + 32 ) ) + StrUtil . xlate ( value , cipher [ associatorIndex ] , cipher [ identifierIndex ] ) + ( ( char ) ( identifierIndex + 32 ) ) ; }
Encrypt a string value .
14,848
protected static final String decrypt ( String value , String cipherKey ) { int len = value == null ? 0 : value . length ( ) ; if ( len < 3 ) { return "" ; } int identifierIndex = value . charAt ( 0 ) - 32 ; int associatorIndex = value . charAt ( len - 1 ) - 32 ; String [ ] cipher = CipherRegistry . getCipher ( cipherKey ) ; return StrUtil . xlate ( value . substring ( 1 , len - 1 ) , cipher [ associatorIndex ] , cipher [ identifierIndex ] ) ; }
Decrypt a string value .
14,849
protected void processConditions ( final BuildData buildData , final SpecTopic specTopic , final Document doc ) { if ( buildData . getContentSpec ( ) . getPublicanCfg ( ) == null || ! buildData . getContentSpec ( ) . getPublicanCfg ( ) . contains ( "condition:" ) ) { super . processConditions ( buildData , specTopic , doc ) ; } }
Checks if the conditional pass should be done by checking to see if the publican . cfg has it s own condition set . If none are set then the conditions are processed .
14,850
private String applyPublicanCfgOverrides ( final BuildData buildData , final String publicanCfg ) { final Map < String , String > publicanCfgOverrides = buildData . getBuildOptions ( ) . getPublicanCfgOverrides ( ) ; String retValue = publicanCfg ; for ( final Map . Entry < String , String > publicanCfgOverrideEntry : publicanCfgOverrides . entrySet ( ) ) { retValue = retValue . replaceFirst ( publicanCfgOverrideEntry . getKey ( ) + "\\s*:.*?(\\r)?\\n" , "" ) ; retValue += publicanCfgOverrideEntry . getKey ( ) + ": " + publicanCfgOverrideEntry . getValue ( ) + "\n" ; } return retValue ; }
Applies custom user overrides to the publican . cfg file .
14,851
public StringBuffer addLinkTag ( StringBuffer sb ) { int iIndex = sb . lastIndexOf ( Utility . endTag ( this . getTableNames ( false ) ) ) ; if ( iIndex != - 1 ) { String strLink = Utility . encodeXML ( this . getLink ( ) ) ; String strHelpLink = strLink ; if ( strLink . indexOf ( '?' ) != - 1 ) strHelpLink = "?" + DBParams . HELP + "=" + "&amp;" + strLink . substring ( strLink . indexOf ( '?' ) + 1 ) ; sb . insert ( iIndex , Utility . startTag ( XMLTags . LINK ) + strLink + Utility . endTag ( XMLTags . LINK ) + XmlUtilities . NEWLINE + Utility . startTag ( XMLTags . HELPLINK ) + strHelpLink + Utility . endTag ( XMLTags . HELPLINK ) + XmlUtilities . NEWLINE ) ; } return sb ; }
Add a tag to this XML for the menu link .
14,852
public String getSubMenuXML ( ) { StringBuffer sbMenuArea = new StringBuffer ( ) ; if ( this . getEditMode ( ) == Constants . EDIT_CURRENT ) { if ( this . getField ( Menus . ICON_RESOURCE ) . isNull ( ) ) { String strIcon = this . getField ( Menus . TYPE ) . toString ( ) ; if ( strIcon . length ( ) > 0 ) strIcon = strIcon . substring ( 0 , 1 ) . toUpperCase ( ) + strIcon . substring ( 1 ) ; this . getField ( Menus . ICON_RESOURCE ) . setString ( strIcon ) ; } sbMenuArea . append ( XmlUtilities . createXMLStringRecord ( this ) ) ; sbMenuArea = this . addLinkTag ( sbMenuArea ) ; } if ( sbMenuArea . length ( ) == 0 ) sbMenuArea . append ( Utility . startTag ( this . getTableNames ( false ) ) + " <Name>Name</Name>" + " <Description>Description</Description>" + " <Program>Program</Program>" + " <Params>Params</Params>" + " <IconResource>IconResource</IconResource>" + " <Keywords>Keywords</Keywords>" + " <Html>Html</Html>" + Utility . endTag ( this . getTableNames ( false ) ) ) ; StringBuffer sbContentArea = new StringBuffer ( ) ; sbContentArea . append ( Utility . startTag ( XMLTags . MENU_LIST ) ) ; try { String strMenu = this . getField ( Menus . ID ) . toString ( ) ; this . setKeyArea ( Menus . PARENT_FOLDER_ID_KEY ) ; FileListener behavior = new StringSubFileFilter ( strMenu , this . getField ( Menus . PARENT_FOLDER_ID ) , null , null , null , null ) ; this . addListener ( behavior ) ; this . close ( ) ; while ( this . hasNext ( ) ) { this . next ( ) ; if ( this . getField ( Menus . ICON_RESOURCE ) . isNull ( ) ) { String strIcon = this . getField ( Menus . TYPE ) . toString ( ) ; if ( strIcon . length ( ) > 0 ) strIcon = strIcon . substring ( 0 , 1 ) . toUpperCase ( ) + strIcon . substring ( 1 ) ; this . getField ( Menus . ICON_RESOURCE ) . setString ( strIcon ) ; } StringBuffer sbMenuItem = new StringBuffer ( ) ; sbMenuItem . append ( XmlUtilities . createXMLStringRecord ( this ) ) ; sbMenuItem = this . addLinkTag ( sbMenuItem ) ; sbContentArea . append ( sbMenuItem ) ; } this . removeListener ( behavior , true ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } sbContentArea . append ( Utility . endTag ( XMLTags . MENU_LIST ) ) ; sbMenuArea . insert ( sbMenuArea . lastIndexOf ( Utility . endTag ( this . getTableNames ( false ) ) ) , sbContentArea ) ; return sbMenuArea . toString ( ) ; }
Get the XML for this menu item and it s sub - menus .
14,853
public String getSQLType ( boolean bIncludeLength , Map < String , Object > properties ) { String strType = ( String ) properties . get ( DBSQLTypes . FLOAT ) ; if ( strType == null ) strType = DBSQLTypes . FLOAT ; return strType ; }
Get the SQL type of this field . Typically FLOAT .
14,854
public void drawToImage ( String path ) { try { ImageOutputDisplay disp = new ImageOutputDisplay ( getPage ( ) . getWidth ( ) , getPage ( ) . getHeight ( ) ) ; disp . drawPage ( getPage ( ) ) ; disp . saveTo ( path ) ; } catch ( IOException e ) { log . error ( "Couldn't write to " + path + ": " + e . getMessage ( ) ) ; } }
Draws the current page to an image file .
14,855
public void drawToImageWithAreas ( String path , String areaNames ) { try { ImageOutputDisplay disp = new ImageOutputDisplay ( getPage ( ) . getWidth ( ) , getPage ( ) . getHeight ( ) ) ; disp . drawPage ( getPage ( ) ) ; showAreas ( disp , getAreaTree ( ) . getRoot ( ) , areaNames ) ; disp . saveTo ( path ) ; } catch ( IOException e ) { log . error ( "Couldn't write to " + path + ": " + e . getMessage ( ) ) ; } }
Draws the page to an image file and marks selected areas in the image .
14,856
public void mergeSourceRecord ( Record recSource , Record recDest ) { try { boolean bFound = this . readDestRecord ( recSource , recDest ) ; if ( ! bFound ) recDest . addNew ( ) ; else recDest . edit ( ) ; this . mergeSourceData ( recSource , recDest , bFound ) ; if ( recDest . isModified ( ) ) { if ( recDest . getEditMode ( ) == DBConstants . EDIT_ADD ) { boolean bAutoSequence = true ; if ( ! recDest . getCounterField ( ) . isNull ( ) ) bAutoSequence = false ; recDest . setAutoSequence ( bAutoSequence ) ; recDest . add ( ) ; recDest . setAutoSequence ( true ) ; } else if ( recDest . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) recDest . set ( ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } }
MergeSourceRecord Method .
14,857
public void mergeSourceData ( Record recSource , Record recDest , boolean bFound ) { for ( int iFieldSeq = 0 ; iFieldSeq < recSource . getFieldCount ( ) ; iFieldSeq ++ ) { BaseField fldSource = recSource . getField ( iFieldSeq ) ; BaseField fldDest = recDest . getField ( fldSource . getFieldName ( ) ) ; if ( fldDest != null ) if ( ! fldSource . isNull ( ) ) fldDest . moveFieldToThis ( fldSource ) ; } }
Merge this source record with the destination record .
14,858
public boolean readDestRecord ( FieldList recSource , Record recDest ) { FieldInfo fldSecond = recSource . getField ( "Name" ) ; if ( fldSecond == null ) fldSecond = recSource . getField ( "Description" ) ; if ( fldSecond == null ) return false ; recDest = BaseFixData . getRecordFromDescription ( fldSecond . toString ( ) , fldSecond . getFieldName ( ) , recDest ) ; return ( recDest != null ) ; }
Given this source record read the destination record .
14,859
public List < String > getCss ( ) { return stream ( properties . getOrDefault ( "css" , "" ) . split ( "," ) ) . map ( String :: trim ) . filter ( x -> x . length ( ) > 0 ) . collect ( toList ( ) ) ; }
Get any CSS document URLs
14,860
public ApplicationSettingJdo newBoolean ( final String key , final String description , final Boolean value ) { return newSetting ( key , description , SettingType . BOOLEAN , Boolean . toString ( value != null && value ) ) ; }
region > newBoolean
14,861
public void untilTrue ( Predicate < SebContext > isTrue ) { super . until ( new com . google . common . base . Predicate < SebContext > ( ) { public boolean apply ( SebContext input ) { return isTrue . test ( input ) ; } } ) ; }
Until method using predicate functional interface . It solves ambiguity when using basic until method without typed parameter .
14,862
public < V > V untilValid ( Function < SebContext , V > isTrue ) { return super . until ( new com . google . common . base . Function < SebContext , V > ( ) { public V apply ( SebContext input ) { return isTrue . apply ( input ) ; } } ) ; }
Until method using function functional interface . It solves ambiguity when using basic until method without typed parameter .
14,863
public SebContextWait sleep ( ) { try { sleeper . sleep ( timeout ) ; return this ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new WebDriverException ( e ) ; } }
Sleeps for defined timeout without checking for any condition .
14,864
public void freeAllSFields ( boolean bIncludeToolScreens ) { int iToolScreens = 0 ; while ( this . getSFieldCount ( ) > iToolScreens ) { ScreenField sField = this . getSField ( iToolScreens ) ; if ( ( ! bIncludeToolScreens ) && ( sField instanceof ToolScreen ) ) iToolScreens ++ ; else sField . free ( ) ; } }
Free all the child sFields .
14,865
public Record getRecord ( String strFileName ) { if ( m_screenParent != null ) return m_screenParent . getRecord ( strFileName ) ; else return null ; }
Lookup this record in this screen .
14,866
public boolean onAdd ( ) { Record record = this . getMainRecord ( ) ; if ( record == null ) return false ; try { if ( record . isModified ( false ) ) { if ( record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) record . set ( ) ; else if ( record . getEditMode ( ) == Constants . EDIT_ADD ) record . add ( ) ; } record . addNew ( ) ; this . clearStatusText ( ) ; } catch ( DBException ex ) { this . displayError ( ex ) ; return false ; } return true ; }
Process the Add toolbar command .
14,867
public boolean onHelp ( int iOptions ) { String strPrevAction = this . getScreenURL ( ) ; if ( ( strPrevAction == null ) || ( strPrevAction . length ( ) == 0 ) ) return false ; if ( this . getProperty ( "displayInitialHelp" ) != null ) if ( ( this . getProperty ( "helplanguage" ) != null ) && ( this . getProperty ( "helplanguage" ) . length ( ) > 0 ) ) if ( this . getTask ( ) != null ) if ( this . getTask ( ) . getApplication ( ) != null ) this . getTask ( ) . getApplication ( ) . setProperty ( "helplanguage" , this . getTask ( ) . getApplication ( ) . getLanguage ( true ) ) ; strPrevAction = Utility . fixDisplayURL ( strPrevAction , true , true , true , this ) ; BaseAppletReference applet = null ; if ( this . getAppletScreen ( ) != null ) if ( this . getAppletScreen ( ) . getScreenFieldView ( ) != null ) applet = ( BaseAppletReference ) this . getAppletScreen ( ) . getScreenFieldView ( ) . getControl ( ) ; if ( applet != null ) iOptions = applet . getHelpPageOptions ( iOptions ) ; if ( ( MenuConstants . HELP_WEB_OPTION & iOptions ) == MenuConstants . HELP_WEB_OPTION ) return this . getScreenFieldView ( ) . showDocument ( strPrevAction , iOptions & 1 ) ; else return this . getAppletScreen ( ) . showHelpScreen ( strPrevAction , iOptions ) ; }
Process the Help toolbar command .
14,868
public boolean onMove ( int nIDMoveCommand ) { Record record = this . getMainRecord ( ) ; if ( record == null ) return false ; try { if ( record . isModified ( false ) ) { if ( record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) record . set ( ) ; else if ( record . getEditMode ( ) == Constants . EDIT_ADD ) record . add ( ) ; } if ( ( nIDMoveCommand == Constants . NEXT_RECORD ) && ( ! record . hasNext ( ) ) ) this . onAdd ( ) ; else if ( ( nIDMoveCommand == Constants . PREVIOUS_RECORD ) && ( ! record . hasPrevious ( ) ) ) this . onMove ( Constants . FIRST_RECORD ) ; else record . move ( nIDMoveCommand ) ; record . isModified ( false ) ; this . clearStatusText ( ) ; } catch ( DBException ex ) { this . displayError ( ex ) ; return false ; } return true ; }
Process the Move Commands .
14,869
public boolean onRefresh ( ) { Record record = this . getMainRecord ( ) ; if ( record == null ) return false ; try { if ( record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) { if ( record . isRefreshedRecord ( ) ) return this . onDelete ( ) ; Object bookmark = record . getHandle ( DBConstants . BOOKMARK_HANDLE ) ; record . setHandle ( bookmark , DBConstants . BOOKMARK_HANDLE ) ; } if ( record . getEditMode ( ) == Constants . EDIT_ADD ) record . addNew ( ) ; this . clearStatusText ( ) ; } catch ( DBException ex ) { this . displayError ( ex ) ; return false ; } return true ; }
Process the Refresh Command .
14,870
public String addURLParam ( String strOldURL , String strParam , String strData ) { return Utility . addURLParam ( strOldURL , strParam , strData ) ; }
Get the command string that will restore this screen . Override in Screen GridScreen MenuScreen .
14,871
public boolean onBack ( ) { BasePanel parent = this . getParentScreen ( ) ; if ( parent == null ) return false ; parent . popHistory ( 1 , false ) ; String strLastCommand = parent . popHistory ( 1 , false ) ; if ( strLastCommand != null ) { parent . pushHistory ( strLastCommand , false ) ; strLastCommand = parent . popHistory ( 1 , true ) ; } if ( ( strLastCommand == null ) || ( strLastCommand . length ( ) == 0 ) ) { if ( parent . getParentScreen ( ) != null ) if ( ! ( parent . getParentScreen ( ) instanceof FrameScreen ) ) return parent . onBack ( ) ; parent . pushHistory ( this . getScreenURL ( ) , false ) ; } else this . handleCommand ( strLastCommand , this , ScreenConstants . USE_SAME_WINDOW | ScreenConstants . DONT_PUSH_TO_BROWSER ) ; return true ; }
Process the Back toolbar command .
14,872
public boolean onHome ( ) { if ( ! ( this instanceof BaseScreen ) ) return false ; BasePanel screenParent = this . getParentScreen ( ) ; int count = 0 ; while ( screenParent . popHistory ( 1 , false ) != null ) { count ++ ; } count -- ; if ( count > 0 ) screenParent . popHistory ( count , true ) ; String strLastCommand = Utility . addURLParam ( null , Params . MENU , Constant . BLANK ) ; this . handleCommand ( strLastCommand , this , ScreenConstants . USE_SAME_WINDOW | ScreenConstants . DONT_PUSH_TO_BROWSER ) ; return true ; }
Process the Home command .
14,873
public boolean removeSField ( ScreenField sField ) { boolean bFlag = false ; if ( m_SFieldList . contains ( sField ) ) { bFlag = m_SFieldList . removeElement ( sField ) ; if ( sField . getScreenFieldView ( ) != null ) if ( sField . getScreenFieldView ( ) . getControl ( ) != null ) sField . free ( ) ; } return bFlag ; }
Remove this screen field from this screen .
14,874
public ScreenField getSField ( int index ) { if ( ( index - DBConstants . MAIN_FIELD >= m_SFieldList . size ( ) ) || ( index < Constants . MAIN_FIELD ) ) return null ; try { return ( ScreenField ) m_SFieldList . elementAt ( index - Constants . MAIN_FIELD ) ; } catch ( ArrayIndexOutOfBoundsException e ) { } return null ; }
Get the SField at this index .
14,875
public void selectField ( ScreenField sfCurrent , int iSelectField ) { ScreenField sField = this . getComponentAfter ( sfCurrent , iSelectField ) ; if ( sField != null ) sField . requestFocus ( ) ; }
Move the focus to the next logical field .
14,876
public ScreenField getComponentAfter ( ScreenField sfCurrent , int iSelectField ) { ScreenField m_ChildFocused = ( ScreenField ) sfCurrent ; if ( m_ChildFocused == null ) iSelectField = DBConstants . SELECT_FIRST_FIELD ; ScreenField sField = null ; ScreenField sPrevScreenField = null ; ScreenField sNextScreenField = null ; ScreenField sTargetScreenField = null ; ScreenField sLastFocusTarget = null ; ScreenField sFirstFocusTarget = null ; for ( int iSField = 0 ; iSField < this . getSFieldCount ( ) ; iSField ++ ) { sField = this . getSField ( iSField ) ; if ( sField . isEnabled ( ) ) if ( sField . isFocusTarget ( ) ) { if ( sFirstFocusTarget == null ) sFirstFocusTarget = sField ; sLastFocusTarget = sField ; if ( sTargetScreenField != null ) if ( sNextScreenField == null ) sNextScreenField = sField ; if ( sField == m_ChildFocused ) sTargetScreenField = sField ; if ( sTargetScreenField == null ) sPrevScreenField = sField ; if ( sPrevScreenField != null ) if ( sTargetScreenField != null ) if ( sNextScreenField != null ) break ; } if ( sField == m_ChildFocused ) sTargetScreenField = sField ; } if ( sPrevScreenField == null ) sPrevScreenField = sLastFocusTarget ; if ( sNextScreenField == null ) sNextScreenField = sFirstFocusTarget ; if ( iSelectField == DBConstants . SELECT_PREV_FIELD ) sNextScreenField = sPrevScreenField ; if ( iSelectField == DBConstants . SELECT_FIRST_FIELD ) sNextScreenField = sFirstFocusTarget ; sField = sNextScreenField ; return sField ; }
Returns the Component that should receive the focus after aComponent .
14,877
public void setDefaultButton ( SBaseButton button ) { this . getScreenFieldView ( ) . setDefaultButton ( button == null ? null : button . getScreenFieldView ( ) ) ; }
Set the default button for this basepanel .
14,878
public static final < K , V > Stream < Entry < K , V > > stream ( K key , NavigableMap < K , V > map , boolean parallel ) { return StreamSupport . stream ( spliterator ( key , map ) , parallel ) ; }
Returns a stream that iterates all NavigableMap entries ascending starting from key and ending entry before key .
14,879
public static final < K , V > Spliterator < Entry < K , V > > spliterator ( K key , NavigableMap < K , V > map ) { return Spliterators . spliterator ( new RingIterator ( key , map ) , map . size ( ) , 0 ) ; }
Returns a spliterator that iterates all NavigableMap entries ascending starting from key and ending entry before key .
14,880
public static int compare ( CharSequence s1 , CharSequence s2 ) { return compare ( s1 , s2 , Funcs :: same ) ; }
Compares two CharSequences
14,881
public static int compare ( CharSequence s1 , CharSequence s2 , IntUnaryOperator op ) { return Streams . compare ( s1 . codePoints ( ) . map ( op ) , s2 . codePoints ( ) . map ( op ) ) ; }
Compares two CharSequences with codepoint mapping
14,882
public static boolean startsWith ( CharSequence seq , CharSequence pattern ) { return startsWith ( seq , pattern , Funcs :: same ) ; }
Return true if seq start match pattern exactly .
14,883
public static boolean startsWith ( CharSequence seq , CharSequence pattern , IntUnaryOperator op ) { if ( pattern . length ( ) > seq . length ( ) ) { return false ; } int length = pattern . length ( ) ; for ( int ii = 0 ; ii < length ; ii ++ ) { if ( op . applyAsInt ( seq . charAt ( ii ) ) != op . applyAsInt ( pattern . charAt ( ii ) ) ) { return false ; } } return true ; }
Return true if seq start match pattern after both characters have been converted with op .
14,884
public static boolean endsWith ( CharSequence seq , CharSequence pattern ) { return endsWith ( seq , pattern , Funcs :: same ) ; }
Return true if seq end match pattern exactly .
14,885
public static boolean endsWith ( CharSequence seq , CharSequence pattern , IntUnaryOperator op ) { if ( pattern . length ( ) > seq . length ( ) ) { return false ; } int ls = seq . length ( ) ; int lp = pattern . length ( ) ; for ( int ii = 1 ; ii <= lp ; ii ++ ) { if ( op . applyAsInt ( seq . charAt ( ls - ii ) ) != op . applyAsInt ( pattern . charAt ( lp - ii ) ) ) { return false ; } } return true ; }
Return true if seq end match pattern after both characters have been converted
14,886
public static int indexOf ( CharSequence seq , CharSequence pattern , int fromIndex ) { return indexOf ( seq , pattern , ( int a , int b ) -> { return a == b ; } , fromIndex ) ; }
Returns index of pattern starting at fromIndex or - 1 if pattern not found
14,887
public String asString ( Object object ) { Calendar calendar = Calendar . getInstance ( TimeZone . getTimeZone ( "GMT" ) ) ; calendar . setTime ( ( Date ) object ) ; StringBuilder builder = new StringBuilder ( ) ; int year = calendar . get ( Calendar . YEAR ) ; if ( calendar . get ( Calendar . ERA ) == 0 ) { if ( year > 1 ) { builder . append ( '-' ) ; } -- year ; } builder . append ( String . format ( "%04d" , year ) ) ; builder . append ( '-' ) ; builder . append ( String . format ( "%02d" , calendar . get ( Calendar . MONTH ) + 1 ) ) ; builder . append ( '-' ) ; builder . append ( String . format ( "%02d" , calendar . get ( Calendar . DATE ) ) ) ; builder . append ( 'T' ) ; builder . append ( String . format ( "%02d" , calendar . get ( Calendar . HOUR_OF_DAY ) ) ) ; builder . append ( ':' ) ; builder . append ( String . format ( "%02d" , calendar . get ( Calendar . MINUTE ) ) ) ; builder . append ( ':' ) ; builder . append ( String . format ( "%02d" , calendar . get ( Calendar . SECOND ) ) ) ; builder . append ( 'Z' ) ; return builder . toString ( ) ; }
Return ISO8601 string representation for given date instance .
14,888
public static Object convertPrimitive ( Object object ) { if ( object == null ) { return object ; } Class < ? > clazz = object . getClass ( ) ; if ( clazz . isPrimitive ( ) ) { if ( boolean . class . equals ( clazz ) ) { Boolean b = ( Boolean ) object ; return b ; } if ( byte . class . equals ( clazz ) ) { Byte b = ( Byte ) object ; return b ; } if ( char . class . equals ( clazz ) ) { Character c = ( Character ) object ; return c ; } if ( short . class . equals ( clazz ) ) { Short s = ( Short ) object ; return s ; } if ( int . class . equals ( clazz ) ) { Integer i = ( Integer ) object ; return i ; } if ( long . class . equals ( clazz ) ) { Long l = ( Long ) object ; return l ; } if ( float . class . equals ( clazz ) ) { Float f = ( Float ) object ; return f ; } if ( double . class . equals ( clazz ) ) { Double d = ( Double ) object ; return d ; } throw new IllegalArgumentException ( "Unknown primitive type'" + clazz ) ; } return object ; }
Convert a primitive object to its Class object
14,889
public void flushPTable ( PTable pTable ) { if ( pTable . getLookupKey ( ) instanceof String ) { try { String strFilePath = ( String ) pTable . getLookupKey ( ) ; String strFilename = this . getFilename ( strFilePath , true ) ; FileOutputStream ostream = new FileOutputStream ( strFilename ) ; ObjectOutputStream p = new ObjectOutputStream ( ostream ) ; p . writeObject ( pTable ) ; p . flush ( ) ; p . close ( ) ; ostream . close ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } }
Write the serial table to the file .
14,890
public void addPropertyListeners ( ) { BaseField fldProperties = this . getField ( PropertiesRecord . PROPERTIES ) ; if ( fldProperties . getListener ( CopyConvertersHandler . class ) != null ) return ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . FRAMES ) , DBParams . FRAMES ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . JAVA ) , DBParams . JAVA ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . HOME ) , DBParams . HOME ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . MENU ) , DBParams . MENU ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . BANNERS ) , DBParams . BANNERS ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . TRAILERS ) , DBParams . TRAILERS ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . MENUBARS ) , DBParams . MENUBARS ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . LOGOS ) , DBParams . LOGOS ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . NAV_MENUS ) , DBParams . NAVMENUS ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . MENU_DESC ) , DBParams . MENUDESC ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . HELP_PAGE ) , MenuConstants . USER_HELP_DISPLAY ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . LANGUAGE ) , DBParams . LANGUAGE ) ; Record recContactType = ( ( ReferenceField ) this . getField ( UserInfo . CONTACT_TYPE_ID ) ) . getReferenceRecord ( ) ; this . getField ( UserInfo . CONTACT_TYPE_ID ) . addListener ( new ReadSecondaryHandler ( recContactType ) ) ; BaseField fldContactTypeCode = recContactType . getField ( ContactType . CODE ) ; CopyConvertersHandler listener = new CopyConvertersHandler ( new PropertiesConverter ( fldProperties , DBParams . CONTACT_TYPE ) , fldContactTypeCode ) ; this . getField ( UserInfo . CONTACT_TYPE_ID ) . addListener ( listener ) ; listener . setRespondsToMode ( DBConstants . INIT_MOVE , false ) ; listener . setRespondsToMode ( DBConstants . READ_MOVE , false ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . CONTACT_TYPE_ID ) , DBParams . CONTACT_TYPE + DBParams . ID ) ; this . addPropertiesFieldBehavior ( this . getField ( UserInfo . CONTACT_ID ) , DBParams . CONTACT_ID ) ; }
Add The listeners to sync the property field with the virtual fields .
14,891
public boolean getUserInfo ( String strUser , boolean bForceRead ) { boolean bFound = false ; if ( ( strUser == null ) || ( strUser . length ( ) == 0 ) ) return false ; int iUserID = - 1 ; try { if ( Utility . isNumeric ( strUser ) ) if ( ( strUser != null ) && ( strUser . length ( ) > 0 ) ) iUserID = Integer . parseInt ( strUser ) ; if ( iUserID == 0 ) iUserID = - 1 ; } catch ( NumberFormatException ex ) { iUserID = - 1 ; } if ( ( iUserID == - 1 ) && ( strUser . length ( ) > 0 ) ) { if ( ! bForceRead ) if ( ( this . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( this . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) if ( this . getField ( UserInfo . USER_NAME ) . toString ( ) . equalsIgnoreCase ( strUser ) ) return true ; this . getField ( UserInfo . USER_NAME ) . setString ( strUser ) ; this . setKeyArea ( UserInfo . USER_NAME_KEY ) ; try { bFound = this . seek ( null ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; bFound = false ; } this . setKeyArea ( UserInfo . ID_KEY ) ; } if ( iUserID != - 1 ) { if ( ! bForceRead ) if ( ( this . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( this . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) if ( this . getField ( UserInfo . ID ) . getValue ( ) == iUserID ) return true ; this . getField ( UserInfo . ID ) . setValue ( iUserID ) ; try { this . setKeyArea ( UserInfo . ID_KEY ) ; bFound = this . seek ( null ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; bFound = false ; } } return bFound ; }
GetUserInfo Method .
14,892
public boolean validUserProperty ( String strProperty ) { if ( DBParams . FRAMES . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . MENUBARS . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . NAVMENUS . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . JAVA . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . BANNERS . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . LOGOS . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . TRAILERS . equalsIgnoreCase ( strProperty ) ) return true ; if ( DBParams . LANGUAGE . equalsIgnoreCase ( strProperty ) ) return true ; return false ; }
Is this a valid user property? .
14,893
public void commitStacktraceMD5 ( ) throws IOException , ServiceException { listEntry . getCustomElements ( ) . setValueLocal ( AcraReportHeader . STACK_TRACE_MD5 . tagName ( ) , getStacktraceMD5 ( ) ) ; listEntry . update ( ) ; }
Updates the stacktrace MD5 hash on the remote Google spreadsheet .
14,894
public static ArrayList < File > getFilesInDirectoryTree ( File file , String includeMask ) { return getContentsInDirectoryTree ( file , includeMask , true , false ) ; }
Retrieves all files from a directory and its subdirectories matching the given mask .
14,895
private static ArrayList < File > getContentsInDirectoryTree ( File directory , String includeMask , boolean returnFiles , boolean returnDirs ) { return getContentsInDirectoryTree ( directory , new FileFilterRuleSet ( directory . getPath ( ) ) . setIncludeFilesWithNameMask ( includeMask ) , returnFiles , returnDirs ) ; }
Retrieves contents from a directory and its subdirectories matching a given mask .
14,896
private static ArrayList < File > getContentsInDirectoryTree ( File directory , FileFilterRuleSet ruleSet , boolean returnFiles , boolean returnDirs ) { ArrayList < File > result = new ArrayList < File > ( ) ; if ( directory != null && directory . exists ( ) && directory . isDirectory ( ) ) { File [ ] files = directory . listFiles ( ) ; if ( files != null ) { for ( int i = 0 ; i < files . length ; i ++ ) { if ( files [ i ] . isDirectory ( ) ) { if ( returnDirs && ruleSet . fileMatchesRules ( files [ i ] ) ) { result . add ( files [ i ] ) ; } result . addAll ( getContentsInDirectoryTree ( files [ i ] , ruleSet , returnFiles , returnDirs ) ) ; } else if ( returnFiles && ruleSet . fileMatchesRules ( files [ i ] ) ) { result . add ( files [ i ] ) ; } } } } return result ; }
Retrieves contents from a directory and its subdirectories matching a given rule set .
14,897
public static ArrayList < File > getDirectoriesInDirectoryTree ( String path ) { File file = new File ( path ) ; return getContentsInDirectoryTree ( file , "*" , false , true ) ; }
Retrieves all directories from a directory and its subdirectories .
14,898
public static File getClassFileFromDirectoryInClassPath ( String className ) { String fileName = StringSupport . replaceAll ( className , "." , "/" ) ; fileName += ".class" ; return getFileFromDirectoryInClassPath ( fileName , System . getProperty ( "java.class.path" ) ) ; }
Tries to retrieve a class as File from all directories mentioned in system property java . class . path
14,899
public static File getFileFromDirectoryInClassPath ( String fileName , String classPath ) { Collection < String > paths = StringSupport . split ( classPath , ";:" , false ) ; for ( String singlePath : paths ) { File dir = new File ( singlePath ) ; if ( dir . isDirectory ( ) ) { File file = new File ( singlePath + '/' + fileName ) ; if ( file . exists ( ) ) { return file ; } } } return null ; }
Locates a file in the classpath .