idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
14,600 | @ SuppressWarnings ( "unchecked" ) public BridgeFactory getBridgeFactory ( Class < ? > farType ) { if ( ! farToNearType . containsKey ( farType ) ) { throw new IllegalStateException ( "Far type not registered: " + ( farType == null ? "null" : farType . getSimpleName ( ) ) ) ; } return farTypeToFactory . get ( farType ) ; } | Returns the bridge factory that corresponds to the given far type |
14,601 | public void init ( ServletConfig servletConfig ) throws ServletException { super . init ( servletConfig ) ; ServletTask . initServlet ( this , BasicServlet . SERVLET_TYPE . XML ) ; Enumeration < ? > paramNames = this . getInitParameterNames ( ) ; while ( paramNames . hasMoreElements ( ) ) { String strProperty = ( String ) paramNames . nextElement ( ) ; String strValue = this . getInitParameter ( strProperty ) ; m_initProperties . put ( strProperty , strValue ) ; } } | Initialize the servlet . |
14,602 | public String convertIndexToString ( int index ) { String tempString = null ; if ( index == 0 ) tempString = NO ; else if ( index == 1 ) tempString = YES ; return tempString ; } | Convert this index to a string . This method return N for 0 and Y for 1 . |
14,603 | public String getSQLType ( boolean bIncludeLength , Map < String , Object > properties ) { String strType = ( String ) properties . get ( DBSQLTypes . BOOLEAN ) ; if ( strType == null ) strType = DBSQLTypes . BYTE ; return strType ; } | Get the SQL type of this field . Typically BOOLEAN or BYTE . |
14,604 | public double getValue ( ) { Boolean bField = ( Boolean ) this . getData ( ) ; if ( bField == null ) return 0 ; boolean bValue = bField . booleanValue ( ) ; if ( bValue == false ) return 0 ; else return 1 ; } | Get the Value of this field as a double . For a boolean return 0 for false 1 for true . |
14,605 | public int setValue ( double value , boolean bDisplayOption , int iMoveMode ) { Boolean bField = Boolean . FALSE ; if ( value != 0 ) bField = Boolean . TRUE ; int errorCode = this . setData ( bField , bDisplayOption , iMoveMode ) ; return errorCode ; } | Set the Value of this field as a double . For a boolean 0 for false 1 for true . |
14,606 | public void setToLimit ( int iAreaDesc ) { Boolean bFlag = Boolean . TRUE ; if ( iAreaDesc == DBConstants . END_SELECT_KEY ) bFlag = Boolean . FALSE ; this . doSetData ( bFlag , DBConstants . DONT_DISPLAY , DBConstants . SCREEN_MOVE ) ; } | Set to the min or max . false is highest for boolean fields . |
14,607 | public BaseMessageFilter addRemoteMessageFilter ( BaseMessageFilter messageFilter , RemoteSession remoteSession ) throws RemoteException { BaseTransport transport = this . createProxyTransport ( ADD_REMOTE_MESSAGE_FILTER ) ; transport . addParam ( FILTER , messageFilter ) ; String strSessionPathID = null ; if ( remoteSession instanceof BaseProxy ) { strSessionPathID = ( ( BaseProxy ) remoteSession ) . getIDPath ( ) ; } transport . addParam ( SESSION , strSessionPathID ) ; Object strReturn = transport . sendMessageAndGetReply ( ) ; Object objReturn = transport . convertReturnObject ( strReturn ) ; return ( BaseMessageFilter ) objReturn ; } | Add a message filter to this remote receive queue . |
14,608 | public boolean removeRemoteMessageFilter ( BaseMessageFilter messageFilter , boolean bFreeFilter ) throws RemoteException { BaseTransport transport = this . createProxyTransport ( REMOVE_REMOTE_MESSAGE_FILTER ) ; transport . addParam ( FILTER , messageFilter ) ; transport . addParam ( FREE , bFreeFilter ) ; Object strReturn = transport . sendMessageAndGetReply ( ) ; Object objReturn = transport . convertReturnObject ( strReturn ) ; if ( objReturn instanceof Boolean ) return ( ( Boolean ) objReturn ) . booleanValue ( ) ; return true ; } | Remove this remote message filter . |
14,609 | public Record getRecord ( ) { ContactField field = ( ContactField ) m_field ; if ( field . getContactTypeField ( ) != null ) { String strContactTypeID = field . getContactTypeField ( ) . toString ( ) ; if ( field . PROFILE_CONTACT_TYPE_ID . equals ( strContactTypeID ) ) return field . m_recProfile ; } return m_record ; } | GetRecord Method . |
14,610 | private void doBefore ( ) throws Throwable { this . repository = this . createRepository ( ) ; doStateTransition ( State . CREATED ) ; this . initialize ( ) ; doStateTransition ( State . INITIALIZED ) ; } | Creates and initializes the repository . At first the repository is created transitioning the state to CREATED . Afterwards the repository is initialized and transitioned to INITIALIZED . |
14,611 | public Session login ( final String userId , final String password ) throws RepositoryException { assertStateAfterOrEqual ( State . CREATED ) ; return this . repository . login ( new SimpleCredentials ( userId , password . toCharArray ( ) ) ) ; } | Logs into the repository with the given credentials . The created session is not managed and be logged out after use by the caller . |
14,612 | public void clearACL ( String path , String ... principalNames ) throws RepositoryException { final Session session = this . getAdminSession ( ) ; final AccessControlManager acm = session . getAccessControlManager ( ) ; final AccessControlList acl = this . getAccessControlList ( session , path ) ; final String [ ] principals ; if ( principalNames . length == 0 ) { principals = new String [ ] { ANY_WILDCARD } ; } else { principals = principalNames ; } for ( String username : principals ) { this . removeAccessControlEntries ( acl , username ) ; } acm . setPolicy ( path , acl ) ; session . save ( ) ; } | Removes all ACLs on the node specified by the path . |
14,613 | private void removeAccessControlEntry ( final AccessControlList acList , final AccessControlEntry acEntry , final String principalName ) throws RepositoryException { if ( ANY_WILDCARD . equals ( principalName ) || acEntry . getPrincipal ( ) . getName ( ) . equals ( principalName ) ) { acList . removeAccessControlEntry ( acEntry ) ; } } | Removes the specified access control entry if the given principal name matches the principal associated with the entry . |
14,614 | protected final void checkMaxSize ( final Dimension screenSize , final Dimension frameSize ) { if ( frameSize . height > screenSize . height ) { frameSize . height = screenSize . height ; } if ( frameSize . width > screenSize . width ) { frameSize . width = screenSize . width ; } } | Adjusts the width and height of the fraem if it s greater than the screen . |
14,615 | public void add ( double x , double y ) { if ( count >= xarr . length ) { grow ( ) ; } xarr [ count ] = x ; yarr [ count ++ ] = y ; minX = Math . min ( minX , x ) ; minY = Math . min ( minY , y ) ; maxX = Math . max ( maxX , x ) ; maxY = Math . max ( maxY , y ) ; } | Adds sample and grows if necessary . |
14,616 | private static int compareTo ( Deque < String > first , Deque < String > second ) { if ( 0 == first . size ( ) && 0 == second . size ( ) ) { return 0 ; } if ( 0 == first . size ( ) ) { return 1 ; } if ( 0 == second . size ( ) ) { return - 1 ; } int headsComparation = ( Integer . valueOf ( first . remove ( ) ) ) . compareTo ( Integer . parseInt ( second . remove ( ) ) ) ; if ( 0 == headsComparation ) { return compareTo ( first , second ) ; } else { return headsComparation ; } } | Compares two string ordered lists containing numbers . |
14,617 | public void setControlValue ( Object objValue ) { if ( objValue instanceof String ) { if ( ( ( String ) objValue ) . equalsIgnoreCase ( Constants . TRUE ) ) objValue = Boolean . TRUE ; else if ( ( ( String ) objValue ) . equalsIgnoreCase ( Constants . FALSE ) ) objValue = Boolean . FALSE ; } super . setControlValue ( objValue ) ; } | Set the value of this control . |
14,618 | public String getIDPath ( ) { String strIDPath = this . getID ( ) ; if ( this . getParentProxy ( ) != null ) { String strParentPath = this . getParentProxy ( ) . getIDPath ( ) ; if ( strParentPath != null ) strIDPath = strParentPath + PATH_SEPARATOR + strIDPath ; } return strIDPath ; } | Get the object s lookup ID . |
14,619 | public BaseTransport createProxyTransport ( String strCommand ) { BaseTransport transport = null ; if ( m_parentProxy != null ) transport = m_parentProxy . createProxyTransport ( strCommand ) ; transport . setProperty ( TARGET , this . getIDPath ( ) ) ; return transport ; } | Create the proxy transport . |
14,620 | public void addChildProxy ( BaseProxy childProxy ) { String strID = childProxy . getID ( ) ; m_hmChildList . put ( strID , childProxy ) ; } | Add this child to the child list . |
14,621 | public DoubleBinaryOperator determinant ( ) { int sign = 1 ; SumBuilder sum = DoubleBinaryOperators . sumBuilder ( ) ; PermutationMatrix pm = PermutationMatrix . getInstance ( rows ) ; int perms = pm . rows ; for ( int p = 0 ; p < perms ; p ++ ) { MultiplyBuilder mul = DoubleBinaryOperators . multiplyBuilder ( ) ; for ( int i = 0 ; i < rows ; i ++ ) { mul . add ( get ( i , pm . get ( p , i ) ) ) ; } sum . add ( DoubleBinaryOperators . sign ( sign , mul . build ( ) ) ) ; sign = - sign ; } return sum . build ( ) ; } | Composes determinant by using permutations |
14,622 | public Component getTreeCellRendererComponent ( JTree tree , Object value , boolean selected , boolean expanded , boolean leaf , int row , boolean hasFocus ) { String stringValue = tree . convertValueToText ( value , selected , expanded , leaf , row , hasFocus ) ; this . setText ( stringValue ) ; NodeData userObject = ( NodeData ) ( ( DefaultMutableTreeNode ) value ) . getUserObject ( ) ; this . selected = selected ; if ( selected ) this . setOpaque ( true ) ; else this . setOpaque ( false ) ; return this ; } | This is messaged from JTree whenever it needs to get the size of the component or it wants to draw it . This attempts to set the font based on value which will be a TreeNode . |
14,623 | public void addMainKeyBehavior ( ) { Record record = this . getMainRecord ( ) ; if ( record == null ) return ; int keyCount = record . getKeyAreaCount ( ) ; for ( int keyNumber = DBConstants . MAIN_KEY_AREA ; keyNumber < keyCount + DBConstants . MAIN_KEY_AREA ; keyNumber ++ ) { KeyArea keyAreaInfo = record . getKeyArea ( keyNumber ) ; if ( ( ( keyAreaInfo . getUniqueKeyCode ( ) == DBConstants . UNIQUE ) || ( keyAreaInfo . getUniqueKeyCode ( ) == DBConstants . SECONDARY_KEY ) ) & ( keyAreaInfo . getKeyFields ( ) == 1 ) ) { BaseField mainField = keyAreaInfo . getField ( DBConstants . MAIN_KEY_FIELD ) ; MainFieldHandler readKeyed = new MainFieldHandler ( record . getKeyArea ( keyNumber ) . getKeyName ( ) ) ; mainField . addListener ( readKeyed ) ; } } } | Add the read - main - key listener . |
14,624 | public void addScreenMenus ( ) { AppletScreen appletScreen = this . getAppletScreen ( ) ; if ( appletScreen != null ) { ScreenField menuBar = appletScreen . getSField ( 0 ) ; if ( ( menuBar == null ) || ( ! ( menuBar instanceof SMenuBar ) ) ) { if ( menuBar instanceof SBaseMenuBar ) menuBar . free ( ) ; new SMenuBar ( new ScreenLocation ( ScreenConstants . FIRST_SCREEN_LOCATION , ScreenConstants . SET_ANCHOR ) , appletScreen , null , ScreenConstants . DONT_DISPLAY_FIELD_DESC , null ) ; } } } | Add the menus that belong with this screen . |
14,625 | public boolean onMove ( int nIDMoveCommand ) { boolean flag = super . onMove ( nIDMoveCommand ) ; this . selectField ( null , DBConstants . SELECT_FIRST_FIELD ) ; return flag ; } | Move Record Command . |
14,626 | @ SuppressWarnings ( "unchecked" ) public static < T > T that ( Object key , Supplier < T > what ) { if ( CACHE . get ( key ) != null ) { try { return ( T ) CACHE . get ( key ) ; } catch ( ClassCastException e ) { System . out . print ( "E/Cache: Can't use cached object: wrong type" ) ; } } T value = what . get ( ) ; CACHE . put ( key , value ) ; return value ; } | Registers creator of item and returns item from cache or creator |
14,627 | public static < T > T that ( Object key , T what ) { CACHE . put ( key , what ) ; return what ; } | Puts item to cache |
14,628 | @ SuppressWarnings ( "unchecked" ) public static < T > T get ( Object key ) { try { return ( T ) CACHE . get ( key ) ; } catch ( ClassCastException e ) { System . out . print ( "E/Cache: Can't use cached object: wrong type" ) ; } return null ; } | Returns cached item |
14,629 | @ SuppressWarnings ( "unchecked" ) public static < T > T poll ( Object key ) { try { return ( T ) CACHE . remove ( key ) ; } catch ( ClassCastException e ) { System . out . print ( "E/Cache: Can't use cached object: wrong type" ) ; } return null ; } | Returns cached item and removes it from cache |
14,630 | public void addOtherSFields ( ) { super . addOtherSFields ( ) ; UserInfo recUserInfo = ( UserInfo ) this . getRecord ( UserInfo . USER_INFO_FILE ) ; BaseField field = new StringField ( recUserInfo , "Sub-Domain" , 10 , null , null ) ; field . setVirtual ( true ) ; recUserInfo . addPropertiesFieldBehavior ( field , MenusMessageData . SITE_PREFIX ) ; field . setupDefaultView ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , ScreenConstants . DEFAULT_DISPLAY ) ; new SStaticString ( this . getNextLocation ( ScreenConstants . RIGHT_OF_LAST , ScreenConstants . DONT_SET_ANCHOR ) , this , "xxxxx.tourgeek.com" ) ; } | AddOtherSFields Method . |
14,631 | public void setCacheMinutes ( int iMinutes ) { if ( iMinutes == - 1 ) iMinutes = DEFAULT_CACHED_MINUTES ; cacheMinutes = iMinutes ; if ( iMinutes == 0 ) { if ( timerCache != null ) { timerCache . cancel ( ) ; timerCache = null ; this . stopCache ( ) ; } } else { if ( timerCache != null ) { timerCache . cancel ( ) ; } this . startCache ( ) ; timerTask = new DBTimerTask ( ) ; timerCache = new java . util . Timer ( ) ; timerCache . schedule ( timerTask , cacheMinutes * 60 * 1000 ) ; } } | This will set this database to start caching records until they haven t been used for iMinutes minutes . |
14,632 | private synchronized void startCache ( ) { for ( PDatabase pDatabase : m_htDBList . values ( ) ) { for ( PTable pTable : pDatabase . getTableList ( ) . values ( ) ) { this . addTableToCache ( pTable ) ; } } } | This will set this database to start caching records by bumping the use count of all the open tables . |
14,633 | private synchronized void checkCache ( ) { Object [ ] pTables = m_setTableCacheList . toArray ( ) ; for ( Object objTable : pTables ) { PTable pTable = ( PTable ) objTable ; if ( pTable . addPTableOwner ( null ) == 1 ) { long lTimeLastUsed = pTable . getLastUsed ( ) ; long lTimeCurrent = System . currentTimeMillis ( ) ; if ( ( lTimeCurrent - lTimeLastUsed ) > ( this . getCacheMinutes ( ) * 60 * 1000 ) ) { pTable . removePTableOwner ( this , true ) ; m_setTableCacheList . remove ( pTable ) ; } } } } | Check all the cached tables and flush the old ones . |
14,634 | public void invokeHandler ( OutputStream outputStream ) throws IOException { @ SuppressWarnings ( "unchecked" ) T t = OutputStream . class . equals ( this . streamClass ) ? ( T ) outputStream : Classes . newInstance ( streamClass , outputStream ) ; handle ( t ) ; t . flush ( ) ; t . close ( ) ; } | Helper method used to invoke concrete output stream handler method . Please note that given output stream is closed after handler invocation just before this method return . |
14,635 | public JMenuBar setupStandardMenu ( ActionListener targetAction , boolean bAddHelpMenu ) { Application application = BaseApplet . getSharedInstance ( ) . getApplication ( ) ; ResourceBundle oldResources = application . getResourceBundle ( ) ; application . getResources ( null , true ) ; this . setupActions ( targetAction ) ; JMenuBar menuBar = new JMenuBar ( ) { private static final long serialVersionUID = 1L ; public Dimension getMaximumSize ( ) { return new Dimension ( super . getMaximumSize ( ) . width , super . getPreferredSize ( ) . height ) ; } } ; menuBar . setOpaque ( false ) ; JMenu menu ; char [ ] rgchItemShortcuts = new char [ 20 ] ; menu = this . addMenu ( menuBar , ThinMenuConstants . FILE ) ; this . addMenuItem ( menu , ThinMenuConstants . PRINT , rgchItemShortcuts ) ; menu . addSeparator ( ) ; this . addMenuItem ( menu , ThinMenuConstants . LOGON , rgchItemShortcuts ) ; this . addMenuItem ( menu , ThinMenuConstants . LOGOUT , rgchItemShortcuts ) ; this . addMenuItem ( menu , ThinMenuConstants . CHANGE_PASSWORD , rgchItemShortcuts ) ; menu . addSeparator ( ) ; this . addMenuItem ( menu , ThinMenuConstants . CLOSE , rgchItemShortcuts ) ; rgchItemShortcuts = new char [ 20 ] ; menu = this . addMenu ( menuBar , ThinMenuConstants . EDIT ) ; this . addMenuItem ( menu , ThinMenuConstants . CUT , rgchItemShortcuts ) ; this . addMenuItem ( menu , ThinMenuConstants . COPY , rgchItemShortcuts ) ; this . addMenuItem ( menu , ThinMenuConstants . PASTE , rgchItemShortcuts ) ; menu . addSeparator ( ) ; this . addMenuItem ( menu , ThinMenuConstants . PREFERENCES , rgchItemShortcuts ) ; if ( oldResources != null ) application . setResourceBundle ( oldResources ) ; if ( bAddHelpMenu ) menu = this . addHelpMenu ( menuBar ) ; return menuBar ; } | Setup the standard menu items . |
14,636 | public JMenu addHelpMenu ( JMenuBar menuBar ) { Application application = BaseApplet . getSharedInstance ( ) . getApplication ( ) ; ResourceBundle oldResources = application . getResourceBundle ( ) ; application . getResources ( null , true ) ; char [ ] rgchItemShortcuts = new char [ 20 ] ; JMenu menu = this . addMenu ( menuBar , ThinMenuConstants . HELP_MENU ) ; this . addMenuItem ( menu , ThinMenuConstants . ABOUT , rgchItemShortcuts ) ; menu . addSeparator ( ) ; this . addMenuItem ( menu , ThinMenuConstants . HELP , rgchItemShortcuts ) ; if ( oldResources != null ) application . setResourceBundle ( oldResources ) ; return menu ; } | Add a standard help menu to this menu bar |
14,637 | public boolean isTablet ( Context context ) { boolean xlarge = ( ( context . getResources ( ) . getConfiguration ( ) . screenLayout & Configuration . SCREENLAYOUT_SIZE_MASK ) == 4 ) ; boolean large = ( ( context . getResources ( ) . getConfiguration ( ) . screenLayout & Configuration . SCREENLAYOUT_SIZE_MASK ) == Configuration . SCREENLAYOUT_SIZE_LARGE ) ; return ( xlarge || large ) ; } | This method is use to determine if the current Android device is a tablet or phone . |
14,638 | public Message receiveMessage ( ) { DualMessageQueue baseMessageQueue = ( DualMessageQueue ) this . getMessageQueue ( ) ; if ( baseMessageQueue == null ) return null ; return baseMessageQueue . getMessageStack ( ) . receiveMessage ( ) ; } | Process the receive message call . Do NOT receive from the remote server ... DO receive from the local queue . The worker thread handle remote receives and adds them to the local queue . |
14,639 | public static boolean isAnnotationPresent ( Class < ? > target , Class < ? extends Annotation > annotation ) { Class < ? > clazz = target ; if ( clazz . isAnnotationPresent ( annotation ) ) { return true ; } while ( ( clazz = clazz . getSuperclass ( ) ) != null ) { if ( clazz . isAnnotationPresent ( annotation ) ) { return true ; } } return false ; } | Returns true if the supplied annotation is present on the target class or any of its super classes . |
14,640 | public static boolean isAnyAnnotationPresent ( Class < ? > target , Class < ? extends Annotation > ... annotations ) { for ( Class < ? extends Annotation > annotationClass : annotations ) { if ( isAnnotationPresent ( target , annotationClass ) ) { return true ; } } return false ; } | Returns true if any of the supplied annotations is present on the target class or any of its super classes . |
14,641 | public static int getAnnotatedParameterIndex ( Method method , Class < ? extends Annotation > annotationClass ) { Annotation [ ] [ ] annotationsForParameters = method . getParameterAnnotations ( ) ; for ( int i = 0 ; i < annotationsForParameters . length ; i ++ ) { Annotation [ ] parameterAnnotations = annotationsForParameters [ i ] ; if ( hasAnnotation ( parameterAnnotations , annotationClass ) ) { return i ; } } return - 1 ; } | Returns index of the first parameter with matching annotationClass - 1 if no parameter found with the supplied annotation . |
14,642 | private static boolean hasAnnotation ( Annotation [ ] parameterAnnotations , Class < ? extends Annotation > annotationClass ) { for ( Annotation annotation : parameterAnnotations ) { if ( annotation . annotationType ( ) . equals ( annotationClass ) ) { return true ; } } return false ; } | Returns true if any annotation in parameterAnnotations matches annotationClass . |
14,643 | public String build ( ) { final StringBuilder description = new StringBuilder ( ) ; description . append ( IssueDescriptionUtils . getOccurrencesTableHeader ( ) ) . append ( '\n' ) ; for ( final ErrorOccurrence error : occurrences ) { description . append ( IssueDescriptionUtils . getOccurrencesTableLine ( error ) ) ; description . append ( '\n' ) ; } description . append ( "\n\n" ) ; description . append ( "*Stacktrace*" ) . append ( '\n' ) ; description . append ( "<pre class=\"javastacktrace\">" ) ; description . append ( stacktrace . trim ( ) ) . append ( "</pre>" ) ; description . append ( '\n' ) . append ( IssueDescriptionUtils . DESCRIPTION_VERSION_TAG ) ; return description . toString ( ) ; } | Builds the description . |
14,644 | public void setOccurrences ( final List < ErrorOccurrence > pOccurrences ) { occurrences . clear ( ) ; for ( final ErrorOccurrence error : pOccurrences ) { addOccurrence ( error ) ; } } | Sets the list of occurrences for this bug . |
14,645 | public static < D > String toJsonString ( D dataObject ) { try { return jsonMapper . writeValueAsString ( dataObject ) ; } catch ( Exception e ) { return JMExceptionManager . handleExceptionAndReturnNull ( log , e , "toJsonString" , dataObject ) ; } } | To json string string . |
14,646 | public static List < Map < String , Object > > toMapList ( String jsonMapListString ) { return withJsonString ( jsonMapListString , LIST_MAP_TYPE_REFERENCE ) ; } | To map list list . |
14,647 | public static < T > T withRestOrClasspathOrFilePath ( String resourceRestUrlOrClasspathOrFilePath , TypeReference < T > typeReference ) { return withJsonString ( JMRestfulResource . getStringWithRestOrClasspathOrFilePath ( resourceRestUrlOrClasspathOrFilePath ) , typeReference ) ; } | With rest or classpath or file path t . |
14,648 | public static < T > T withRestOrFilePathOrClasspath ( String resourceRestOrFilePathOrClasspath , TypeReference < T > typeReference ) { return withJsonString ( JMRestfulResource . getStringWithRestOrFilePathOrClasspath ( resourceRestOrFilePathOrClasspath ) , typeReference ) ; } | With rest or file path or classpath t . |
14,649 | public static < T > T withClasspathOrFilePath ( String resourceClasspathOrFilePath , TypeReference < T > typeReference ) { return withJsonString ( JMResources . getStringWithClasspathOrFilePath ( resourceClasspathOrFilePath ) , typeReference ) ; } | With classpath or file path t . |
14,650 | public static < T > T withFilePathOrClasspath ( String resourceFilePathOrClasspath , TypeReference < T > typeReference ) { return withJsonString ( JMResources . getStringWithFilePathOrClasspath ( resourceFilePathOrClasspath ) , typeReference ) ; } | With file path or classpath t . |
14,651 | public static < T > Map < String , Object > transformToMap ( T object ) { return transform ( object , MAP_TYPE_REFERENCE ) ; } | Transform to map map . |
14,652 | public static String toPrettyJsonString ( Object object ) { try { return jsonMapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( object ) ; } catch ( JsonProcessingException e ) { return JMExceptionManager . handleExceptionAndReturnNull ( log , e , "toPrettyJsonString" , object ) ; } } | To pretty json string string . |
14,653 | public static void modifyFile ( Path inFilePath , Path outFilePath , FileChangable modifier ) throws IOException { try ( BufferedReader bufferedReader = new BufferedReader ( new FileReader ( inFilePath . toFile ( ) ) ) ; Writer writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( outFilePath . toFile ( ) ) , "utf-8" ) ) ) { String readLine ; int counter = 0 ; while ( ( readLine = bufferedReader . readLine ( ) ) != null ) { writer . write ( modifier . apply ( counter , readLine ) ) ; counter ++ ; } } } | Modifies the input file line by line and writes the modification in the new output file |
14,654 | public int getRawRecordData ( Rec record ) { int iErrorCode = super . getRawRecordData ( record ) ; this . getRawFieldData ( record . getField ( UserInfo . USER_NAME ) ) ; this . getRawFieldData ( record . getField ( UserInfo . PASSWORD ) ) ; return iErrorCode ; } | Move the map values to the correct record fields . If this method is used is must be overidden to move the correct fields . |
14,655 | private static Folder getOrCreateFolder ( final Folder parentFolder , final String folderName ) throws IOException { Folder childFolder = null ; ItemIterable < CmisObject > children = parentFolder . getChildren ( ) ; if ( children . iterator ( ) . hasNext ( ) ) { for ( CmisObject cmisObject : children ) { if ( cmisObject instanceof Folder && cmisObject . getName ( ) . equals ( folderName ) ) { log . debug ( "Found '{}' folder." , folderName ) ; return childFolder = ( Folder ) cmisObject ; } } } log . debug ( "'{}' folder not found, about to create..." , folderName ) ; Map < String , String > folderProps = new HashMap < String , String > ( ) ; folderProps . put ( PropertyIds . OBJECT_TYPE_ID , "cmis:folder" ) ; folderProps . put ( PropertyIds . NAME , folderName ) ; childFolder = parentFolder . createFolder ( folderProps ) ; log . info ( "'{}' folder created!" , folderName ) ; return childFolder ; } | look for a child folder of the parent folder if not found create it and return it . |
14,656 | private static String utf8inputStream2String ( final InputStream inputStream ) throws IOException { StringBuilder stringBuilder = new StringBuilder ( ) ; try ( BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( inputStream , StandardCharsets . UTF_8 ) ) ) { String line = null ; while ( ( line = bufferedReader . readLine ( ) ) != null ) { stringBuilder . append ( line ) ; stringBuilder . append ( "\n" ) ; } } return stringBuilder . toString ( ) ; } | convert InputStream to String |
14,657 | public ImageIcon getHeaderIcon ( ) { return org . jbundle . thin . base . screen . BaseApplet . getSharedInstance ( ) . loadImageIcon ( "tour/buttons/Meal.gif" , "Meal" ) ; } | Get the icon for a meal . |
14,658 | public boolean existsAnyBroker ( ) { boolean result = false ; synchronized ( this . brokerDetails ) { Iterator < PerBrokerInfo > iter = this . brokerDetails . values ( ) . iterator ( ) ; while ( ( ! result ) && ( iter . hasNext ( ) ) ) { result = iter . next ( ) . exists ; } } return result ; } | Determine if this destination currently is known to exist on any broker registered for the destination . |
14,659 | public boolean existsOnBroker ( String brokerId ) { boolean result = false ; PerBrokerInfo info ; synchronized ( this . brokerDetails ) { info = this . brokerDetails . get ( brokerId ) ; } if ( ( info != null ) && ( info . exists ) ) { result = true ; } return result ; } | Determine whether this destination exists on the broker with the given ID . |
14,660 | public char getDefaultJava ( String strBrowser , String strOS ) { char chJavaLaunch = 'A' ; if ( "safari" . equalsIgnoreCase ( strBrowser ) ) chJavaLaunch = 'W' ; return chJavaLaunch ; } | Get best way to launch java |
14,661 | public ScreenModel checkSecurity ( ScreenModel screen , ScreenModel parentScreen ) { int iErrorCode = DBConstants . NORMAL_RETURN ; if ( screen != null ) iErrorCode = ( ( BaseScreen ) screen ) . checkSecurity ( ) ; if ( iErrorCode == Constants . READ_ACCESS ) { ( ( BaseScreen ) screen ) . setEditing ( false ) ; ( ( BaseScreen ) screen ) . setAppending ( false ) ; iErrorCode = DBConstants . NORMAL_RETURN ; } if ( iErrorCode == DBConstants . NORMAL_RETURN ) return screen ; else { if ( screen != null ) screen . free ( ) ; return this . getSecurityScreen ( iErrorCode , ( BasePanel ) parentScreen ) ; } } | Make sure I am allowed access to this screen . |
14,662 | public void changeParameters ( ) { String string = null ; String strPreferences = this . getProperty ( DBParams . PREFERENCES ) ; boolean bSetDefault = true ; if ( ( strPreferences == null ) || ( strPreferences . length ( ) == 0 ) ) bSetDefault = false ; Application application = ( BaseApplication ) this . getTask ( ) . getApplication ( ) ; string = this . getProperty ( DBParams . FRAMES ) ; if ( bSetDefault ) if ( string == null ) string = DBConstants . NO ; if ( string != null ) application . setProperty ( DBParams . FRAMES , string ) ; string = this . getProperty ( DBParams . MENUBARS ) ; if ( bSetDefault ) if ( string == null ) string = UserInfoModel . YES ; if ( string != null ) application . setProperty ( DBParams . MENUBARS , string ) ; string = this . getProperty ( DBParams . NAVMENUS ) ; if ( bSetDefault ) if ( string == null ) string = UserInfoModel . NO_ICONS ; if ( string != null ) application . setProperty ( DBParams . NAVMENUS , string ) ; string = this . getProperty ( DBParams . JAVA ) ; if ( bSetDefault ) if ( string == null ) string = UserInfoModel . DEFAULT ; if ( string != null ) application . setProperty ( DBParams . JAVA , string ) ; string = this . getProperty ( DBParams . BANNERS ) ; if ( bSetDefault ) if ( string == null ) string = DBConstants . NO ; if ( string != null ) application . setProperty ( DBParams . BANNERS , string ) ; string = this . getProperty ( DBParams . LOGOS ) ; if ( bSetDefault ) if ( string == null ) string = UserInfoModel . HOME_PAGE_ONLY ; if ( string != null ) application . setProperty ( DBParams . LOGOS , string ) ; string = this . getProperty ( DBParams . TRAILERS ) ; if ( bSetDefault ) if ( string == null ) string = UserInfoModel . HOME_PAGE_ONLY ; if ( string != null ) application . setProperty ( DBParams . TRAILERS , string ) ; string = this . getProperty ( DBConstants . SYSTEM_NAME ) ; if ( string != null ) application . setProperty ( DBConstants . SYSTEM_NAME , string ) ; string = this . getProperty ( DBConstants . MODE ) ; if ( string != null ) application . setProperty ( DBConstants . MODE , string ) ; string = this . getProperty ( DBParams . LANGUAGE ) ; if ( bSetDefault ) if ( string == null ) string = UserInfoModel . DEFAULT ; ; if ( string != null ) application . setLanguage ( string ) ; if ( application instanceof MainApplication ) { ( ( MainApplication ) application ) . readUserInfo ( true , true ) ; } } | Change the session parameters . |
14,663 | public void setValidators ( final Iterable < Validator < ? > > validators ) { this . validators . clear ( ) ; for ( final Validator < ? > validator : validators ) { this . validators . put ( validator . getSupportedClass ( ) , validator ) ; } } | Set the validators used by the service . This will clear any existing validators . This method is thread safe . |
14,664 | public ScreenParent makeScreen ( ScreenLoc itsLocation , ComponentParent parentScreen , int iDocMode , Map < String , Object > properties ) { ScreenParent screen = null ; if ( ( iDocMode & ScreenConstants . MAINT_MODE ) == ScreenConstants . MAINT_MODE ) screen = Record . makeNewScreen ( SCREEN_IN_SCREEN_CLASS , itsLocation , parentScreen , iDocMode | ScreenConstants . DONT_DISPLAY_FIELD_DESC , properties , this , true ) ; else if ( ( iDocMode & ScreenConstants . DISPLAY_MODE ) == ScreenConstants . DISPLAY_MODE ) screen = Record . makeNewScreen ( SCREEN_IN_GRID_SCREEN_CLASS , itsLocation , parentScreen , iDocMode | ScreenConstants . DONT_DISPLAY_FIELD_DESC , properties , this , true ) ; else screen = super . makeScreen ( itsLocation , parentScreen , iDocMode , properties ) ; return screen ; } | Make a default screen . |
14,665 | public static int getFlattenedItemsCount ( final Object ... items ) { return stream ( items ) . map ( item -> item . getClass ( ) . isArray ( ) ? getFlattenedItemsCount ( ( Object [ ] ) item ) : 1 ) . reduce ( 0 , Integer :: sum ) ; } | Returns the total number of non array items held in the specified array recursively descending in every array item . |
14,666 | public static byte [ ] absorbInputStream ( InputStream input ) throws IOException { ByteArrayOutputStream output = null ; try { output = new ByteArrayOutputStream ( ) ; absorbInputStream ( input , output ) ; return output . toByteArray ( ) ; } finally { output . close ( ) ; } } | Reads all bytes from an input stream . |
14,667 | public static < T > T precondition ( T reference , Predicate < T > predicate , Class < ? extends RuntimeException > ex , String msg ) throws RuntimeException { if ( predicate . test ( reference ) ) { return reference ; } final Constructor < ? extends RuntimeException > constructor ; try { constructor = ex . getConstructor ( String . class ) ; throw constructor . newInstance ( msg ) ; } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( msg ) ; } } | Test a Predicate against a reference value and if it fails throw a runtime exception with a message . |
14,668 | public static < T > T checkNotNull ( final T reference , final String errorMessage ) { return precondition ( reference , Predicates . < T > notNull ( ) , IllegalArgumentException . class , errorMessage ) ; } | Check that a reference is not null throwing a IllegalArgumentException if it is . |
14,669 | public static String checkNonEmptyString ( final String reference , final String errorMessage ) { return precondition ( reference , Predicates . notEmptyString ( ) , IllegalArgumentException . class , errorMessage ) ; } | Check that a String is not empty after removing whitespace . |
14,670 | public static Class isAssignableTo ( final Class < ? > reference , final Class < ? > toValue , final String message ) { return precondition ( reference , new Predicate < Class > ( ) { public boolean test ( Class testValue ) { return toValue . isAssignableFrom ( testValue ) ; } } , ClassCastException . class , message ) ; } | Check that one class is assignable to another . |
14,671 | public void convertAndWriteXML ( String xml , String path ) { ClassProject classProject = ( ClassProject ) this . getMainRecord ( ) ; Record recProgramControl = this . getRecord ( ProgramControl . PROGRAM_CONTROL_FILE ) ; Model model = ( Model ) this . unmarshalMessage ( xml ) ; String name = model . getName ( ) ; CodeType codeType = CodeType . THICK ; String thickDir = classProject . getFileName ( "" , null , codeType , true , false ) ; if ( name == null ) codeType = CodeType . THICK ; else if ( name . endsWith ( "model" ) ) codeType = CodeType . INTERFACE ; else if ( name . endsWith ( "thin" ) ) codeType = CodeType . THIN ; else if ( name . endsWith ( "res" ) ) codeType = CodeType . RESOURCE_PROPERTIES ; xml = replaceParams ( xml , codeType ) ; model = ( Model ) this . unmarshalMessage ( xml ) ; String strSourcePath = recProgramControl . getField ( ProgramControl . CLASS_DIRECTORY ) . toString ( ) ; String destDir = classProject . getFileName ( "" , null , codeType , true , false ) ; if ( codeType != CodeType . THICK ) if ( destDir . equals ( thickDir ) ) return ; if ( destDir . endsWith ( strSourcePath ) ) destDir = destDir . substring ( 0 , destDir . length ( ) - strSourcePath . length ( ) ) ; if ( name != null ) if ( name . endsWith ( "reactor" ) ) { if ( destDir . endsWith ( "/" ) ) destDir = destDir . substring ( 0 , destDir . length ( ) - 1 ) ; if ( destDir . lastIndexOf ( '/' ) != - 1 ) destDir = destDir . substring ( 0 , destDir . lastIndexOf ( '/' ) ) ; } path = "pom.xml" ; path = org . jbundle . base . model . Utility . addToPath ( destDir , path ) ; File fileOut = new File ( path ) ; File fileDir = fileOut . getParentFile ( ) ; if ( ! fileDir . exists ( ) ) fileDir . mkdirs ( ) ; Reader in = new StringReader ( xml ) ; org . jbundle . base . model . Utility . transferURLStream ( null , path , in , null ) ; } | ConvertAndWriteXML Method . |
14,672 | public String replaceParams ( String xml , CodeType codeType ) { ClassProject classProject = ( ClassProject ) this . getMainRecord ( ) ; Map < String , String > ht = new HashMap < String , String > ( ) ; ht . put ( START + "project" + END , classProject . getField ( ClassProject . NAME ) . toString ( ) ) ; ht . put ( START + "version" + END , "1.0.0-SNAPSHOT" ) ; ht . put ( START + "groupId" + END , classProject . getFullPackage ( CodeType . THICK , "" ) ) ; ht . put ( START + "packagedb" + END , classProject . getFullPackage ( CodeType . THICK , "" ) ) ; ht . put ( START + "packagethin" + END , classProject . getFullPackage ( CodeType . THIN , "" ) ) ; ht . put ( START + "packageres" + END , classProject . getFullPackage ( CodeType . RESOURCE_PROPERTIES , "" ) ) ; ht . put ( START + "packagemodel" + END , classProject . getFullPackage ( CodeType . INTERFACE , "" ) ) ; ht . put ( START + "package" + END , classProject . getFullPackage ( codeType , "" ) ) ; xml = org . jbundle . base . model . Utility . replace ( xml , ht ) ; return xml ; } | ReplaceParams Method . |
14,673 | public String transferStream ( InputStream in , int size ) { StringBuilder sb = new StringBuilder ( ) ; try { byte [ ] cbuf = new byte [ 1000 ] ; int iLen = Math . max ( size , cbuf . length ) ; while ( ( iLen = in . read ( cbuf , 0 , iLen ) ) > 0 ) { for ( int i = 0 ; i < iLen ; i ++ ) { sb . append ( Character . toChars ( cbuf [ i ] ) ) ; } size = size - iLen ; iLen = Math . max ( size , cbuf . length ) ; } } catch ( MalformedURLException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return sb . toString ( ) ; } | TransferStream Method . |
14,674 | public String marshalObject ( Object message ) { try { IBindingFactory jc = BindingDirectory . getFactory ( Model . class ) ; IMarshallingContext marshaller = jc . createMarshallingContext ( ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; marshaller . setIndent ( 2 ) ; marshaller . marshalDocument ( message , URL_ENCODING , null , out ) ; String xml = out . toString ( STRING_ENCODING ) ; return xml ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } catch ( JiBXException e ) { e . printStackTrace ( ) ; } return null ; } | Marshal this object to an XML string |
14,675 | public Object unmarshalMessage ( String xml ) { try { IBindingFactory jc = BindingDirectory . getFactory ( Model . class ) ; IUnmarshallingContext unmarshaller = jc . createUnmarshallingContext ( ) ; Reader inStream = new StringReader ( xml ) ; Object message = unmarshaller . unmarshalDocument ( inStream , BINDING_NAME ) ; return message ; } catch ( JiBXException e ) { e . printStackTrace ( ) ; } return null ; } | Unmarshal this xml Message to an object . |
14,676 | public Map < String , Object > getHiddenParams ( ) { Map < String , Object > mapParams = super . getHiddenParams ( ) ; if ( this . getTask ( ) instanceof ServletTask ) mapParams = ( ( ServletTask ) this . getTask ( ) ) . getRequestProperties ( ( ( ServletTask ) this . getTask ( ) ) . getServletRequest ( ) , false ) ; mapParams . remove ( DBParams . USER_NAME ) ; mapParams . remove ( DBParams . USER_ID ) ; return mapParams ; } | Get this screen s hidden params . |
14,677 | public static Header decode ( String header ) { JsonObject json ; try { json = Json . createReader ( new ByteArrayInputStream ( Base64 . getUrlDecoder ( ) . decode ( header ) ) ) . readObject ( ) ; } catch ( JsonException e ) { throw new DecodeException ( "Failed convert to JsonObject" , e ) ; } catch ( IllegalArgumentException e ) { throw new DecodeException ( "The header is not in valid Base64 scheme" , e ) ; } String type = json . containsKey ( "typ" ) ? json . getString ( "typ" ) : null ; if ( type != null && ! DEFAULT_TYPE . equals ( type ) ) throw new DecodeException ( "The header type '" + type + "' is not support." ) ; String algorithm = json . containsKey ( "alg" ) ? json . getString ( "alg" ) : null ; if ( algorithm != null && ! Algorithm . HS256 . name ( ) . equals ( algorithm ) ) throw new DecodeException ( "The header algorithm '" + algorithm + "' is not support." ) ; if ( DEFAULT_TYPE . equals ( type ) && Algorithm . HS256 . name ( ) . equals ( algorithm ) ) { return Header . DEFAULT ; } else { Header h = new Header ( ) ; h . type = type ; h . algorithm = ( algorithm != null ? Algorithm . valueOf ( algorithm ) : null ) ; return h ; } } | Decode the base64 - string to Header . |
14,678 | public static CipherRegistry registerCiphers ( String [ ] ... ciphers ) { for ( String [ ] cipher : ciphers ) { instance . register ( cipher ) ; } return instance ; } | Register multiple ciphers . |
14,679 | public static CipherRegistry registerCiphers ( InputStream source ) { try { if ( source == null ) { throw new IllegalArgumentException ( "Cipher source not found." ) ; } List < String > lines = IOUtils . readLines ( source ) ; int start = - 1 ; int index = 0 ; boolean error = false ; while ( index < lines . size ( ) ) { String line = lines . get ( index ) ; if ( line . trim ( ) . isEmpty ( ) ) { lines . remove ( index ) ; continue ; } if ( line . equals ( "-----BEGIN CIPHER-----" ) ) { if ( start == - 1 ) { start = index + 1 ; } else { error = true ; } } else if ( line . equals ( "-----END CIPHER-----" ) ) { if ( start > 0 ) { int length = index - start ; String [ ] cipher = new String [ length ] ; registerCipher ( lines . subList ( start , index ) . toArray ( cipher ) ) ; start = - 1 ; } else { error = true ; } } if ( error ) { throw new IllegalArgumentException ( "Unexpected text in cipher: " + line ) ; } index ++ ; } if ( start > 0 ) { throw new IllegalArgumentException ( "Missing end cipher token." ) ; } } catch ( IOException e ) { throw MiscUtil . toUnchecked ( e ) ; } finally { IOUtils . closeQuietly ( source ) ; } return instance ; } | Register one or more ciphers from an input stream . |
14,680 | public String [ ] get ( String key ) { String [ ] cipher = super . get ( key ) ; if ( cipher == null ) { throw new IllegalArgumentException ( "Cipher is unknown." ) ; } return cipher ; } | Override to return default cipher if input is null or throw an exception if the cipher key is not recognized . |
14,681 | public static String buildSubscript ( Iterable < Object > subscripts ) { StringBuilder sb = new StringBuilder ( ) ; for ( Object subscript : subscripts ) { String value = toString ( subscript ) ; if ( value . isEmpty ( ) ) { throw new RuntimeException ( "Null subscript not allowed." ) ; } if ( sb . length ( ) > 0 ) { sb . append ( "," ) ; } if ( StringUtils . isNumeric ( value ) ) { sb . append ( value ) ; } else { sb . append ( QT ) ; sb . append ( value . replaceAll ( QT , QT2 ) ) ; sb . append ( QT ) ; } } return sb . toString ( ) ; } | Converts a list of objects to a string of M subscripts . |
14,682 | public void merge ( final TagRequirements other ) { if ( other != null ) { matchAllOf . addAll ( other . matchAllOf ) ; matchOneOf . addAll ( other . matchOneOf ) ; } } | This method will merge the tag information stored in another TagRequirements object with the tag information stored in this object . |
14,683 | private static boolean isSecure ( String protocol ) throws BugError { if ( HTTP . equalsIgnoreCase ( protocol ) ) { return false ; } else if ( HTTPS . equalsIgnoreCase ( protocol ) ) { return true ; } else { throw new BugError ( "Unsupported protocol |%s| for HTTP transaction." , protocol ) ; } } | Predicate to test if given protocol is secure . |
14,684 | public void writeClass ( String strClassName , CodeType codeType ) { if ( ! this . readThisClass ( strClassName ) ) return ; this . writeHeading ( strClassName , this . getPackage ( codeType ) , codeType ) ; this . writeIncludes ( codeType ) ; if ( m_MethodNameList . size ( ) != 0 ) m_MethodNameList . removeAllElements ( ) ; this . writeClassInterface ( ) ; this . writeClassFields ( CodeType . THICK ) ; this . writeDefaultConstructor ( strClassName ) ; this . writeClassInit ( ) ; this . writeInit ( ) ; this . writeProgramDesc ( strClassName ) ; this . writeClassMethods ( CodeType . THICK ) ; this . writeEndCode ( true ) ; } | Create the Class for this field . |
14,685 | public boolean readThisClass ( String strClassName ) { try { Record recClassInfo = this . getMainRecord ( ) ; recClassInfo . getField ( ClassInfo . CLASS_NAME ) . setString ( strClassName ) ; recClassInfo . setKeyArea ( ClassInfo . CLASS_NAME_KEY ) ; return recClassInfo . seek ( "=" ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; return false ; } } | Read the class with this name . |
14,686 | public void writeClassInterface ( ) { Record recClassInfo = this . getMainRecord ( ) ; String strClassName = recClassInfo . getField ( ClassInfo . CLASS_NAME ) . getString ( ) ; String strBaseClass = recClassInfo . getField ( ClassInfo . BASE_CLASS_NAME ) . getString ( ) ; String strClassDesc = recClassInfo . getField ( ClassInfo . CLASS_DESC ) . getString ( ) ; String strClassInterface = recClassInfo . getField ( ClassInfo . CLASS_IMPLEMENTS ) . getString ( ) ; String implementsClass = null ; if ( ( ( ClassInfo ) recClassInfo ) . isARecord ( false ) ) implementsClass = strClassName + "Model" ; if ( ( implementsClass != null ) && ( implementsClass . length ( ) > 0 ) ) { m_IncludeNameList . addInclude ( this . getPackage ( CodeType . INTERFACE ) , null ) ; if ( ( strClassInterface == null ) || ( strClassInterface . length ( ) == 0 ) ) strClassInterface = implementsClass ; else strClassInterface = implementsClass + ", " + strClassInterface ; } m_IncludeNameList . addInclude ( strBaseClass , null ) ; m_StreamOut . writeit ( "\n/**\n *\t" + strClassName + " - " + strClassDesc + ".\n */\n" ) ; if ( ( strClassInterface == null ) || ( strClassInterface . length ( ) == 0 ) ) strClassInterface = "" ; else strClassInterface = "\n\t implements " + strClassInterface ; String strClassType = "class" ; if ( "interface" . equals ( recClassInfo . getField ( ClassInfo . CLASS_TYPE ) . toString ( ) ) ) strClassType = "interface" ; String strExtends = " extends " ; if ( strBaseClass . length ( ) == 0 ) strExtends = "" ; m_StreamOut . writeit ( "public " + strClassType + " " + strClassName + strExtends + strBaseClass + strClassInterface + "\n{\n" ) ; m_StreamOut . setTabs ( + 1 ) ; } | Start the interface . |
14,687 | public void writeEndCode ( boolean bJavaFile ) { m_StreamOut . setTabs ( - 1 ) ; if ( bJavaFile ) m_StreamOut . writeit ( "\n}" ) ; m_StreamOut . writeit ( "\n" ) ; m_StreamOut . free ( ) ; m_StreamOut = null ; m_IncludeNameList . free ( ) ; m_IncludeNameList = null ; } | Write the end of class code . |
14,688 | public boolean readThisMethod ( String strMethodName ) { Record recClassInfo = this . getMainRecord ( ) ; LogicFile recLogicFile = ( LogicFile ) this . getRecord ( LogicFile . LOGIC_FILE_FILE ) ; try { String strClassName = recClassInfo . getField ( ClassInfo . CLASS_NAME ) . getString ( ) ; recLogicFile . getField ( LogicFile . METHOD_CLASS_NAME ) . setString ( strClassName ) ; recLogicFile . getField ( LogicFile . METHOD_NAME ) . setString ( strMethodName ) ; recLogicFile . setKeyArea ( LogicFile . METHOD_CLASS_NAME_KEY ) ; if ( recLogicFile . seek ( "=" ) ) return true ; else { recLogicFile . handleNewRecord ( false ) ; recLogicFile . getField ( LogicFile . METHOD_CLASS_NAME ) . setString ( strClassName ) ; recLogicFile . getField ( LogicFile . METHOD_NAME ) . setString ( strMethodName ) ; return false ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { recLogicFile . setKeyArea ( LogicFile . SEQUENCE_KEY ) ; } return false ; } | Read this method . |
14,689 | public void writeDefaultMethodCode ( String strMethodName , String strMethodReturns , String strMethodInterface , String strClassName ) { String strBaseClass , strMethodVariables = DBConstants . BLANK ; Record recClassInfo = this . getMainRecord ( ) ; LogicFile recLogicFile = ( LogicFile ) this . getRecord ( LogicFile . LOGIC_FILE_FILE ) ; strBaseClass = recClassInfo . getField ( ClassInfo . BASE_CLASS_NAME ) . getString ( ) ; strMethodVariables = this . getMethodVariables ( strMethodInterface ) ; if ( strClassName . equals ( strMethodName ) ) { if ( strMethodVariables . equalsIgnoreCase ( "VOID" ) ) strMethodVariables = "" ; if ( strMethodInterface . length ( ) == 0 ) m_StreamOut . writeit ( "\tsuper();\n" ) ; else { boolean bSuperFound = false ; if ( ( strMethodReturns . length ( ) == 0 ) || ( strMethodReturns . equalsIgnoreCase ( "void" ) ) ) if ( recLogicFile . getField ( LogicFile . LOGIC_SOURCE ) . getLength ( ) > 0 ) strMethodReturns = strMethodVariables ; if ( ( strMethodReturns . length ( ) == 0 ) || ( strMethodReturns . equalsIgnoreCase ( "void" ) ) ) m_StreamOut . writeit ( "\tthis();\n\tthis.init(" + strMethodVariables + ");\n" ) ; else { if ( ! strMethodReturns . equalsIgnoreCase ( "INIT" ) ) { m_StreamOut . writeit ( "\tthis();\n\tthis.init(" + strMethodVariables + ");\n" ) ; m_StreamOut . writeit ( "}\n" ) ; m_strLastMethodInterface = strMethodInterface ; m_strLastMethod = strMethodName ; this . writeMethodInterface ( null , "init" , "void" , strMethodInterface , "" , "Initialize class fields" , null ) ; if ( strMethodReturns . equalsIgnoreCase ( "VOID" ) ) strMethodReturns = "" ; this . writeClassInitialize ( true ) ; } else bSuperFound = true ; if ( recLogicFile . getField ( LogicFile . LOGIC_SOURCE ) . getString ( ) . length ( ) != 0 ) { m_StreamOut . setTabs ( + 1 ) ; bSuperFound = bSuperFound | this . writeTextField ( recLogicFile . getField ( LogicFile . LOGIC_SOURCE ) , strBaseClass , "init" , strMethodReturns , strClassName ) ; m_StreamOut . setTabs ( - 1 ) ; } if ( ! bSuperFound ) m_StreamOut . writeit ( "\tsuper.init(" + strMethodReturns + ");\n" ) ; } } } else { if ( ! strMethodName . equals ( "setupSFields" ) ) { String beginString = "" ; if ( strMethodReturns . length ( ) == 0 ) beginString = "return " ; m_StreamOut . writeit ( "\t" + beginString + "super." + strMethodName + "(" + strMethodVariables + ");\n" ) ; } else this . writeSetupSCode ( strMethodName , strMethodReturns , strMethodInterface , strClassName ) ; } } | No code supplied write default code . |
14,690 | public void writeClassMethods ( CodeType codeType ) { LogicFile recLogicFile = ( LogicFile ) this . getRecord ( LogicFile . LOGIC_FILE_FILE ) ; try { Set < String > methodsIncluded = new HashSet < String > ( ) ; Set < String > methodInterfaces = new HashSet < String > ( ) ; recLogicFile . close ( ) ; while ( recLogicFile . hasNext ( ) ) { recLogicFile . next ( ) ; if ( ( ( IncludeScopeField ) recLogicFile . getField ( LogicFile . INCLUDE_SCOPE ) ) . includeThis ( codeType , false ) ) { this . writeThisMethod ( codeType ) ; String strMethodName = recLogicFile . getField ( LogicFile . METHOD_NAME ) . toString ( ) ; if ( strMethodName . length ( ) > 2 ) if ( strMethodName . charAt ( strMethodName . length ( ) - 2 ) == '*' ) strMethodName = strMethodName . substring ( 0 , strMethodName . length ( ) - 2 ) ; methodsIncluded . add ( strMethodName ) ; } if ( ( ( IncludeScopeField ) recLogicFile . getField ( LogicFile . INCLUDE_SCOPE ) ) . includeThis ( CodeType . INTERFACE , false ) ) { String strMethodName = recLogicFile . getField ( LogicFile . METHOD_NAME ) . toString ( ) ; if ( strMethodName . length ( ) > 2 ) if ( strMethodName . charAt ( strMethodName . length ( ) - 2 ) == '*' ) strMethodName = strMethodName . substring ( 0 , strMethodName . length ( ) - 2 ) ; methodInterfaces . add ( strMethodName ) ; } } recLogicFile . close ( ) ; while ( recLogicFile . hasNext ( ) ) { recLogicFile . next ( ) ; String strMethodName = recLogicFile . getField ( LogicFile . METHOD_NAME ) . toString ( ) ; if ( strMethodName . length ( ) > 2 ) if ( strMethodName . charAt ( strMethodName . length ( ) - 2 ) == '*' ) strMethodName = strMethodName . substring ( 0 , strMethodName . length ( ) - 2 ) ; if ( ( methodInterfaces . contains ( strMethodName ) ) && ( ! methodsIncluded . contains ( strMethodName ) ) ) this . writeThisMethod ( codeType ) ; } recLogicFile . close ( ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } } | Write the methods for this class . |
14,691 | public boolean writeTextField ( BaseField textField , String strBaseClass , String strMethodName , String strMethodInterface , String strClassName ) { if ( textField . getString ( ) . length ( ) == 0 ) return false ; String beforeMethodCode ; beforeMethodCode = textField . getString ( ) ; int inher = beforeMethodCode . indexOf ( "super;" ) ; if ( inher != - 1 ) { String strSuper = "super" ; if ( strClassName != strMethodName ) strSuper = "super." + strMethodName ; strMethodInterface = this . getMethodVariables ( strMethodInterface ) ; beforeMethodCode = beforeMethodCode . substring ( 0 , inher ) + strSuper + "(" + strMethodInterface + ");" + beforeMethodCode . substring ( inher + 6 , beforeMethodCode . length ( ) ) ; } m_StreamOut . writeit ( beforeMethodCode ) ; m_StreamOut . writeit ( "\n" ) ; return ( inher != - 1 ) ; } | Write this text field out - line by line . |
14,692 | public String fixSQLName ( String strName ) { int index = 0 ; while ( index != - 1 ) { index = strName . indexOf ( ' ' ) ; if ( index != - 1 ) strName = strName . substring ( 0 , index ) + strName . substring ( index + 1 , strName . length ( ) ) ; } return strName ; } | Take out the spaces in the name . |
14,693 | String convertDescToJavaDoc ( String strDesc ) { for ( int i = 0 ; i < strDesc . length ( ) - 1 ; i ++ ) { if ( strDesc . charAt ( i ) == '\n' ) strDesc = strDesc . substring ( 0 , i + 1 ) + " * " + strDesc . substring ( i + 1 ) ; } strDesc = " * " + strDesc ; if ( ! strDesc . endsWith ( "." ) ) strDesc += '.' ; return strDesc ; } | Convert the description to a javadoc compatible description . |
14,694 | public Object getControlValue ( ) { int iIndex = this . getSelectedIndex ( ) ; try { FieldTable table = m_record . getTable ( ) ; if ( m_strIndexValue != null ) if ( iIndex != 0 ) if ( table . get ( iIndex - 1 ) != null ) { FieldInfo field = m_record . getField ( m_strIndexValue ) ; if ( field == null ) field = m_record . getField ( 0 ) ; return field . getData ( ) ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } if ( iIndex == 0 ) return null ; return this . getSelectedItem ( ) ; } | Get this component s value as an object that FieldInfo can use . |
14,695 | public int valueToIndex ( Object value ) { if ( value != null ) if ( ! ( value instanceof String ) ) value = value . toString ( ) ; if ( ( m_record != null ) && ( m_strIndexValue != null ) ) { try { FieldTable table = m_record . getTable ( ) ; for ( int iIndex = 0 ; ; iIndex ++ ) { if ( table . get ( iIndex ) == null ) break ; FieldInfo field = m_record . getField ( m_strIndexValue ) ; if ( field == null ) field = m_record . getField ( 0 ) ; String strValue = field . getString ( ) ; if ( ( strValue != null ) && ( strValue . length ( ) > 0 ) ) if ( strValue . equals ( value ) ) return iIndex + 1 ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } else { this . setSelectedItem ( value ) ; if ( this . getSelectedIndex ( ) != - 1 ) return this . getSelectedIndex ( ) ; } return 0 ; } | Convert this value to a selection index . |
14,696 | public String callRPC ( String name , boolean async , int timeout , RPCParameters params ) { ensureConnection ( ) ; String version = "" ; String context = connectionParams . getAppid ( ) ; if ( name . contains ( ":" ) ) { String pcs [ ] = StrUtil . split ( name , ":" , 3 , true ) ; name = pcs [ 0 ] ; version = pcs [ 1 ] ; context = pcs [ 2 ] . isEmpty ( ) ? context : pcs [ 2 ] ; } Request request = new Request ( Action . RPC ) ; request . addParameter ( "UID" , id ) ; request . addParameter ( "CTX" , context ) ; request . addParameter ( "VER" , version ) ; request . addParameter ( "RPC" , name ) ; request . addParameter ( "ASY" , async ) ; if ( params != null ) { request . addParameters ( params ) ; } Response response = netCall ( request , timeout ) ; return response . getData ( ) ; } | Performs a remote procedure call . |
14,697 | private RPCParameters packageParams ( Object ... params ) { if ( params == null ) { return null ; } if ( params . length == 1 && params [ 0 ] instanceof RPCParameters ) { return ( RPCParameters ) params [ 0 ] ; } return new RPCParameters ( params ) ; } | Package parameters for RPC call . If parameters already packaged simply return the package . |
14,698 | public AuthResult authenticate ( String username , String password , String division ) { ensureConnection ( ) ; if ( isAuthenticated ( ) ) { return new AuthResult ( "0" ) ; } String av = username + ";" + password ; List < String > results = callRPCList ( "RGNETBRP AUTH:" + Constants . VERSION , null , connectionParams . getAppid ( ) , getLocalName ( ) , "" , ";" . equals ( av ) ? av : Security . encrypt ( av , serverCaps . getCipherKey ( ) ) , getLocalAddress ( ) , division ) ; AuthResult authResult = new AuthResult ( results . get ( 0 ) ) ; if ( authResult . status . succeeded ( ) ) { setPostLoginMessage ( results . subList ( 2 , results . size ( ) ) ) ; init ( results . get ( 1 ) ) ; } return authResult ; } | Request authentication from the server . |
14,699 | protected void init ( String init ) { String [ ] pcs = StrUtil . split ( init , StrUtil . U , 4 ) ; id = StrUtil . toInt ( pcs [ 0 ] ) ; serverCaps . domainName = pcs [ 1 ] ; serverCaps . siteName = pcs [ 2 ] ; userId = StrUtil . toInt ( pcs [ 3 ] ) ; } | Initializes the broker session with information returned by the server . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.