idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
14,200
protected final void ok ( ) { final String dir = panel . getDirectory ( ) ; final boolean include = panel . isIncludeSubdirs ( ) ; close ( ) ; listener . finished ( dir , include ) ; }
The dialog was successfully finished .
14,201
public static void main ( final String [ ] args ) throws IOException { Utils4Swing . initSystemLookAndFeel ( ) ; DirectorySelector . Result result ; try { result = DirectorySelector . selectDirectory ( "Please select the destination directory:" , new File ( "." ) . getCanonicalPath ( ) , true ) ; System . out . println ( "SELECTED=" + result . getDirectory ( ) + ", SUBDIRS=" + result . isIncludeSubdirs ( ) ) ; } catch ( CanceledException e ) { System . out . println ( "CANCELED!" ) ; } }
Starts the selector for a test .
14,202
public int handleMessage ( BaseMessage message ) { Utility . getLogger ( ) . info ( "RemoteQueue handling message " + message ) ; if ( message . getProcessedByClientSession ( ) == this . getParentSession ( ) ) return DBConstants . NORMAL_RETURN ; if ( message == m_messageLastMessage ) return DBConstants . NORMAL_RETURN ; m_messageLastMessage = message ; this . getMessageStack ( ) . sendMessage ( message ) ; return DBConstants . NORMAL_RETURN ; }
Listen for messages .
14,203
public BaseMessageFilter addRemoteMessageFilter ( BaseMessageFilter messageFilter , RemoteSession remoteSession ) throws RemoteException { BaseMessageFilter remoteFilter = messageFilter ; messageFilter . setRegistryID ( null ) ; messageFilter . setFilterID ( null ) ; remoteFilter . setCreateRemoteFilter ( true ) ; remoteFilter . setUpdateRemoteFilter ( true ) ; Utility . getLogger ( ) . info ( "EJB addRemoteMessageFilter session: " + remoteSession ) ; MessageManager messageManager = ( ( Application ) this . getTask ( ) . getApplication ( ) ) . getMessageManager ( ) ; if ( remoteSession == null ) messageManager . addMessageFilter ( remoteFilter ) ; else { remoteFilter = remoteSession . setupRemoteSessionFilter ( remoteFilter ) ; remoteFilter = ( ( BaseMessageReceiver ) messageManager . getMessageQueue ( remoteFilter . getQueueName ( ) , remoteFilter . getQueueType ( ) ) . getMessageReceiver ( ) ) . getMessageFilter ( remoteFilter . getFilterID ( ) ) ; } remoteFilter . addMessageListener ( this ) ; messageFilter . setQueueName ( remoteFilter . getQueueName ( ) ) ; messageFilter . setQueueType ( remoteFilter . getQueueType ( ) ) ; messageFilter . setFilterID ( remoteFilter . getFilterID ( ) ) ; messageFilter . setRegistryID ( remoteFilter . getRegistryID ( ) ) ; return messageFilter ; }
Given a copy of the client s message filter set up a remote filter .
14,204
public static final Level brokenConnection ( Level level , Throwable thr ) { if ( thr instanceof EOFException ) { return level ; } if ( thr instanceof ClosedChannelException ) { return level ; } if ( ( thr instanceof IOException ) && ( "Broken pipe" . equals ( thr . getMessage ( ) ) || "Connection reset by peer" . equals ( thr . getMessage ( ) ) ) ) { return level ; } if ( ( thr instanceof ConnectException ) && ( "Connection timed out" . equals ( thr . getMessage ( ) ) || "Connection refused" . equals ( thr . getMessage ( ) ) ) ) { return level ; } Throwable cause = thr . getCause ( ) ; if ( cause != null ) { return brokenConnection ( level , cause ) ; } return Level . SEVERE ; }
Tries to detect if Throwable is caused by broken connection . If detected returns level else return SEVERE .
14,205
public int callRPCAsync ( String rpcName , Object ... args ) { abort ( ) ; this . rpcName = rpcName ; asyncHandle = broker . callRPCAsync ( rpcName , this , args ) ; return asyncHandle ; }
Make an asynchronous call .
14,206
public void abort ( ) { if ( asyncHandle != 0 ) { int handle = asyncHandle ; asyncHandle = 0 ; broker . callRPCAbort ( handle ) ; ZKUtil . fireEvent ( new AsyncRPCAbortEvent ( rpcName , target , handle ) ) ; rpcName = null ; } }
Abort any asynchronous RPC in progress .
14,207
public void onRPCComplete ( int handle , String data ) { if ( handle == asyncHandle ) { asyncHandle = 0 ; ZKUtil . fireEvent ( new AsyncRPCCompleteEvent ( rpcName , target , data , handle ) ) ; rpcName = null ; } }
RPC completion callback .
14,208
public void onRPCError ( int handle , int code , String text ) { if ( handle == asyncHandle ) { asyncHandle = 0 ; ZKUtil . fireEvent ( new AsyncRPCErrorEvent ( rpcName , target , code , text , handle ) ) ; rpcName = null ; } }
RPC error callback .
14,209
public int findElement ( Object bookmark , int iHandleType ) { int iTargetPosition ; Object thisBookmark = null ; if ( bookmark == null ) return - 1 ; boolean bDataRecordFormat = false ; for ( iTargetPosition = 0 ; iTargetPosition < m_iRecordListEnd ; iTargetPosition += m_iRecordListStep ) { thisBookmark = this . elementAt ( iTargetPosition ) ; if ( iTargetPosition == 0 ) if ( thisBookmark instanceof DataRecord ) bDataRecordFormat = true ; if ( bookmark . equals ( thisBookmark ) ) return iTargetPosition ; else if ( bDataRecordFormat ) if ( bookmark . equals ( ( ( DataRecord ) thisBookmark ) . getHandle ( iHandleType ) ) ) return iTargetPosition ; } return - 1 ; }
Search through this list for this bookmark .
14,210
public void growAccessList ( int iTargetPosition ) { int iArrayIndex ; if ( m_aRecords == null ) { m_aRecords = new Object [ MAX_RECORD_ARRAY_SIZE ] ; m_iRecordListStep = 1 ; m_iRecordListMax = MAX_RECORD_ARRAY_SIZE ; } else { for ( iArrayIndex = 1 ; iArrayIndex < MAX_RECORD_ARRAY_SIZE ; iArrayIndex += 2 ) { this . freeElement ( m_aRecords [ iArrayIndex ] ) ; m_aRecords [ iArrayIndex ] = null ; } int nSourceIndex , nDestIndex ; for ( nSourceIndex = 2 , nDestIndex = 1 ; nSourceIndex < MAX_RECORD_ARRAY_SIZE ; nSourceIndex += 2 , nDestIndex ++ ) { Object bookmark = m_aRecords [ nSourceIndex ] ; m_aRecords [ nDestIndex ] = bookmark ; m_aRecords [ nSourceIndex ] = null ; } m_iRecordListMax = m_iRecordListMax * 2 ; m_iRecordListStep = m_iRecordListStep * 2 ; } if ( iTargetPosition >= m_iRecordListMax ) this . growAccessList ( iTargetPosition ) ; }
Increase the granularity of the access list .
14,211
public List < ConstantField > getConstants ( Class < ? > aClass ) { List < ConstantField > constants = new ArrayList < > ( ) ; List < Field > fields = Arrays . asList ( aClass . getDeclaredFields ( ) ) ; for ( Field field : fields ) { if ( Modifier . isStatic ( field . getModifiers ( ) ) && ! Modifier . isFinal ( field . getModifiers ( ) ) ) { if ( ! Modifier . isPublic ( field . getModifiers ( ) ) ) if ( tryMakeAccessible ) field . setAccessible ( true ) ; else continue ; constants . add ( processField ( aClass , field ) ) ; } } Iterator < ConstantField > itr = constants . iterator ( ) ; while ( itr . hasNext ( ) ) { if ( itr . next ( ) == null ) itr . remove ( ) ; } return constants ; }
Gets all fields that are potential constants .
14,212
public static LocalDateInterval parseString ( final String input ) { String [ ] values = input . split ( "/" ) ; try { return new LocalDateInterval ( parseLocalDate ( values [ 0 ] ) , parseLocalDate ( values [ 1 ] ) , IntervalEnding . EXCLUDING_END_DATE ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Unable to parse " + input ) ; } }
Parse a string representation of a LocalDateInterval
14,213
private static LocalDate parseLocalDate ( final String input ) { if ( input . contains ( "--" ) || input . contains ( "*" ) ) { return null ; } return LocalDate . parse ( input ) ; }
Parse a string to a LocalDate
14,214
@ SuppressWarnings ( "unchecked" ) public SebListener disable ( Class < ? extends SebEvent > ... events ) { if ( events != null ) { enabledEvents = null ; if ( disabledEvents == null ) disabledEvents = new HashSet < > ( ) ; for ( Class < ? extends SebEvent > event : events ) { disabledEvents . add ( event ) ; } } return this ; }
Disables specific events only . It overrides all enabled events .
14,215
protected void saveFile ( SebEvent event , String content , String name , String extension ) { event . saveFile ( content , getListenerFileName ( name ) , extension ) ; }
Save string content into output file with given name and extension .
14,216
protected void saveFile ( SebEvent event , byte [ ] bytes , String name , String extension ) { event . saveFile ( bytes , getListenerFileName ( name ) , extension ) ; }
Save bytes into output file with given name and extension .
14,217
protected void saveFile ( SebEvent event , File file , String name , String extension ) { event . saveFile ( file , getListenerFileName ( name ) , extension ) ; }
Save file into output file with given name and extension .
14,218
public void setupPanel ( ) { this . setLayout ( new BoxLayout ( this , BoxLayout . Y_AXIS ) ) ; this . addGridHeading ( ) ; JPanel panel = new JPanel ( ) ; panel . setOpaque ( false ) ; panel . setMinimumSize ( new Dimension ( 20 , 20 ) ) ; panel . setLayout ( new BorderLayout ( ) ) ; JScrollPane scrollPane = new JScrollPane ( JScrollPane . VERTICAL_SCROLLBAR_AS_NEEDED , JScrollPane . HORIZONTAL_SCROLLBAR_AS_NEEDED ) ; panel . add ( scrollPane ) ; this . add ( panel ) ; m_panelGrid = new JPanel ( ) ; JPanel panelAligner = new JPanel ( ) ; panelAligner . add ( m_panelGrid ) ; panelAligner . setLayout ( new FlowLayout ( FlowLayout . LEADING ) ) ; scrollPane . getViewport ( ) . add ( panelAligner ) ; panelAligner . setOpaque ( false ) ; m_panelGrid . setOpaque ( false ) ; scrollPane . getViewport ( ) . setOpaque ( false ) ; scrollPane . setOpaque ( false ) ; this . addGridDetail ( ) ; }
Setup a new panel .
14,219
public void addGridDetailItem ( TableModel model , int iRowIndex , GridBagLayout gridbag , GridBagConstraints c ) { JComponent rgcompoments [ ] = new JComponent [ model . getColumnCount ( ) ] ; for ( int iColumnIndex = 0 ; iColumnIndex < rgcompoments . length ; iColumnIndex ++ ) { Object obj = model . getValueAt ( iRowIndex , iColumnIndex ) ; if ( ( obj == null ) || ( model . getRowCount ( ) <= iRowIndex ) ) return ; if ( iColumnIndex == rgcompoments . length - 1 ) { c . weightx = 1.0 ; c . gridwidth = GridBagConstraints . REMAINDER ; c . anchor = GridBagConstraints . WEST ; c . insets . right = 5 ; } Component component = this . addDetailComponent ( model , obj , iRowIndex , iColumnIndex , c ) ; if ( component == null ) continue ; gridbag . setConstraints ( component , c ) ; m_panelGrid . add ( component ) ; rgcompoments [ iColumnIndex ] = ( JComponent ) component ; } m_vComponentCache . addElement ( new ComponentCache ( iRowIndex , rgcompoments ) ) ; }
Add this item to the grid detail at this row .
14,220
public Component addDetailComponent ( TableModel model , Object aValue , int iRowIndex , int iColumnIndex , GridBagConstraints c ) { JComponent component = null ; String string = "" ; if ( aValue instanceof ImageIcon ) { component = new JLabel ( ( ImageIcon ) aValue ) ; } if ( aValue instanceof PortableImage ) { component = new JLabel ( new ImageIcon ( ( Image ) ( ( PortableImage ) aValue ) . getImage ( ) ) ) ; } else if ( aValue != null ) { string = aValue . toString ( ) ; if ( model . isCellEditable ( iRowIndex , iColumnIndex ) ) { if ( string . length ( ) == 0 ) component = new JTextField ( 3 ) ; else component = new JTextField ( string ) ; } else component = new JLabel ( string ) ; } return component ; }
Create the appropriate component and add it to the grid detail at this location .
14,221
public void dataToField ( ComponentCache componentCache , int iRowIndex , int iColumnIndex ) { if ( componentCache . m_rgcompoments [ iColumnIndex ] != null ) { String string = null ; if ( componentCache . m_rgcompoments [ iColumnIndex ] instanceof JTextComponent ) string = ( ( JTextComponent ) componentCache . m_rgcompoments [ iColumnIndex ] ) . getText ( ) ; if ( componentCache . m_rgcompoments [ iColumnIndex ] instanceof JCheckBox ) if ( ( ( JCheckBox ) componentCache . m_rgcompoments [ iColumnIndex ] ) . isSelected ( ) ) string = "1" ; this . getModel ( ) . setValueAt ( string , iRowIndex , iColumnIndex ) ; } }
Change the table by setting this field to the value in the component at this location .
14,222
public void fieldToData ( ComponentCache componentCache , int iRowIndex , int iColumnIndex ) { if ( componentCache . m_rgcompoments [ iColumnIndex ] != null ) { Object object = this . getModel ( ) . getValueAt ( iRowIndex , iColumnIndex ) ; String string = "" ; if ( object != null ) string = object . toString ( ) ; if ( componentCache . m_rgcompoments [ iColumnIndex ] instanceof JTextComponent ) ( ( JTextComponent ) componentCache . m_rgcompoments [ iColumnIndex ] ) . setText ( string ) ; else if ( componentCache . m_rgcompoments [ iColumnIndex ] instanceof JCheckBox ) { boolean bIsSelected = false ; if ( string != null ) if ( string . equals ( "1" ) ) bIsSelected = true ; ( ( JCheckBox ) componentCache . m_rgcompoments [ iColumnIndex ] ) . setSelected ( bIsSelected ) ; } } }
Move the data in this row and column in the table to this component .
14,223
public void tableChanged ( TableModelEvent e ) { if ( ( e . getFirstRow ( ) == TableModelEvent . HEADER_ROW ) || ( e . getLastRow ( ) >= m_vComponentCache . size ( ) ) ) { this . removeAll ( ) ; this . setupPanel ( ) ; this . validate ( ) ; } else if ( e . getType ( ) == TableModelEvent . UPDATE ) { int iFirstRow = e . getFirstRow ( ) ; int iLastRow = e . getLastRow ( ) ; for ( int iRowIndex = iFirstRow ; iRowIndex <= iLastRow ; iRowIndex ++ ) { if ( iRowIndex < m_vComponentCache . size ( ) ) { ComponentCache componentCache = ( ComponentCache ) m_vComponentCache . elementAt ( iRowIndex ) ; if ( componentCache != null ) { for ( int iColumnIndex = 0 ; iColumnIndex < componentCache . m_rgcompoments . length ; iColumnIndex ++ ) { this . fieldToData ( componentCache , iRowIndex , iColumnIndex ) ; } } } else break ; } } }
The table has changed update the grid .
14,224
public void write ( final OutputStream out , final Stream < ? extends Triple > triples , final IRI subject ) { final Writer writer = new OutputStreamWriter ( out , UTF_8 ) ; try { template . execute ( writer , new HtmlData ( namespaceService , subject , triples . collect ( toList ( ) ) , properties ) ) . flush ( ) ; } catch ( final IOException ex ) { throw new UncheckedIOException ( ex ) ; } }
Send the content to an output stream
14,225
private ContentType parseContentType ( String value ) { String [ ] pcs = value . split ( "\\;" ) ; String mimeType = pcs [ 0 ] . trim ( ) ; String charSet = "UTF-8" ; for ( int i = 1 ; i < pcs . length ; i ++ ) { String s = pcs [ i ] . trim ( ) . toUpperCase ( ) ; if ( s . startsWith ( "CHARSET=" ) ) { charSet = s . substring ( 8 ) ; break ; } } return ContentType . create ( mimeType , charSet ) ; }
Parse the returned content type .
14,226
public static String getRandomString ( final int size , final int start , final int length ) { final StringBuilder buff = new StringBuilder ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { buff . append ( ( char ) ( RAN . nextInt ( length ) + start ) ) ; } return buff . toString ( ) ; }
Creates a size byte long unicode string . All codes are &gt ; = start and &lt ; start + length
14,227
public static String getRandomString ( final int size , final String stringSet ) { final StringBuilder buff = new StringBuilder ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { final char nextChar = stringSet . charAt ( RAN . nextInt ( stringSet . length ( ) ) ) ; buff . append ( nextChar ) ; } return buff . toString ( ) ; }
Creates a size byte long unicode string . All codes are from the set stringSet
14,228
public void addChild ( Config child ) { Params . notNull ( child , "Child" ) ; child . parent = this ; children . add ( child ) ; }
Add child configuration object .
14,229
public void setAttribute ( String name , String value ) { Params . notNullOrEmpty ( name , "Attribute name" ) ; Params . notEmpty ( value , "Attribute value" ) ; if ( value != null ) { attributes . put ( name , value ) ; } else { attributes . remove ( name ) ; } }
Set configuration object attribute . If attribute already exists overwrite old value . Empty value is not accepted but null is considered indication to remove attribute . So that an existing attribute cannot be either null or empty .
14,230
public Config getRoot ( ) { Config root = this ; while ( root . parent != null ) { root = root . parent ; } return root ; }
Get root of the tree this configuration object is part of .
14,231
public boolean hasAttribute ( String name , String value ) { Params . notNullOrEmpty ( name , "Attribute name" ) ; Params . notNullOrEmpty ( value , "Attribute value" ) ; return value . equals ( attributes . get ( name ) ) ; }
Test if configuration object has an attribute with requested name and value .
14,232
public String getAttribute ( String name ) { Params . notNullOrEmpty ( name , "Attribute name" ) ; return attributes . get ( name ) ; }
Get attribute value or null if there is no attribute with requested name . An existing attribute value cannot ever be empty or null so if this method returns null is for missing attribute .
14,233
public String getAttribute ( String name , String defaultValue ) { Params . notNullOrEmpty ( name , "Attribute name" ) ; return getAttribute ( name , String . class , defaultValue ) ; }
Get attribute value or given default value if there is no attribute with requested name . If given default value is null and attribute is not found this method still returns null that is requested default value .
14,234
public < T > T getAttribute ( String name , Class < T > type ) { Params . notNullOrEmpty ( name , "Attribute name" ) ; Params . notNull ( type , "Attribute type" ) ; return getAttribute ( name , type , null ) ; }
Get attribute value converted to requested type or null if there is no attribute with requested name .
14,235
public < T > T getAttribute ( String name , Class < T > type , T defaultValue ) { Params . notNullOrEmpty ( name , "Attribute name" ) ; Params . notNull ( type , "Attribute type" ) ; String value = attributes . get ( name ) ; return value != null ? converter . asObject ( value , type ) : defaultValue ; }
Get attribute value converted to requested type or default value if there is no attribute with requested name . If given default value is null and attribute is not found this method still returns null that is the requested default value .
14,236
public String getProperty ( String name ) { Params . notNullOrEmpty ( name , "Property name" ) ; usedProperties . add ( name ) ; return properties . getProperty ( name ) ; }
Get configuration object property value or null if there is no property with requested name .
14,237
public < T > T getProperty ( String name , Class < T > type ) { return getProperty ( name , type , null ) ; }
Get configuration object property converter to requested type or null if there is no property with given name .
14,238
public < T > T getProperty ( String name , Class < T > type , T defaultValue ) { Params . notNullOrEmpty ( name , "Property name" ) ; Params . notNull ( type , "Property type" ) ; String value = getProperty ( name ) ; if ( value != null ) { return converter . asObject ( value , type ) ; } return defaultValue ; }
Get configuration object property converter to requested type or default value if there is no property with given name .
14,239
public boolean hasChild ( String name ) { Params . notNullOrEmpty ( name , "Child name" ) ; for ( Config child : children ) { if ( child . name . equals ( name ) ) { return true ; } } return false ; }
Test if configuration object has at least a child with requested name .
14,240
public Config getChild ( String name ) { Params . notNullOrEmpty ( name , "Child name" ) ; for ( Config child : children ) { if ( child . name . equals ( name ) ) { return child ; } } return null ; }
Get configuration object first child with requested name or null if there is no child with given name .
14,241
public Config getChild ( int index ) { Params . range ( index , 0 , children . size ( ) , "Index" ) ; return children . get ( index ) ; }
Get configuration object child by index . Given index should be in range so that invoking this method on empty children list will throw exception .
14,242
public List < Config > findChildren ( String ... name ) { Params . notNullOrEmpty ( name , "Children names" ) ; List < String > names = Arrays . asList ( name ) ; List < Config > results = new ArrayList < Config > ( ) ; for ( Config child : children ) { if ( names . contains ( child . name ) ) { results . add ( child ) ; } } return results ; }
Find configuration object children with requested names .
14,243
public < T > T getValue ( Class < T > type ) { Params . notNull ( type , "Value type" ) ; if ( value == null ) { return null ; } return converter . asObject ( value , type ) ; }
Get this configuration object value converted to requested type . Returns null if this configuration object has no value .
14,244
public String getChildValue ( String name ) { Config child = getChild ( name ) ; return child != null ? child . getValue ( ) : null ; }
Get named child string value or null if child not found or it has no value .
14,245
private void print ( Config config , int indent ) { for ( int i = 0 ; i < indent ; ++ i ) { System . out . print ( "\t" ) ; } System . out . print ( config . name ) ; System . out . print ( "\r\n" ) ; for ( Config child : config . children ) { print ( child , indent + 1 ) ; } }
Recursively print configuration object tree to standard out .
14,246
public synchronized Date setEndDate ( Date time ) { m_cachedInfo . setEndDate ( time ) ; int iThisIndex = m_model . indexOf ( this ) ; if ( iThisIndex != - 1 ) m_model . fireTableRowsUpdated ( iThisIndex , iThisIndex ) ; this . changeRemoteDate ( null , null , this , null , time ) ; return this . getEndDate ( ) ; }
Change the ending time of this service . First move the item on the screen then call the method to change the remote data .
14,247
public String [ ] getMealCache ( Date dateStart , Date dateEnd ) throws Exception { int iDays = ( int ) ( ( dateEnd . getTime ( ) - dateStart . getTime ( ) ) / Constants . KMS_IN_A_DAY ) + 2 ; if ( iDays <= 0 ) return null ; String [ ] rgstrMeals = new String [ iDays ] ; Date date = new Date ( dateStart . getTime ( ) ) ; for ( int iDay = 0 ; iDay < iDays ; iDay ++ ) { rgstrMeals [ iDay ] = this . getRemoteMealDesc ( date ) ; date . setTime ( date . getTime ( ) + Constants . KMS_IN_A_DAY ) ; } return rgstrMeals ; }
Get the meals on each day of this product and put them in an array .
14,248
public synchronized int setStatus ( int iStatus ) { m_cachedInfo . setStatus ( iStatus ) ; int iThisIndex = m_model . indexOf ( this ) ; if ( iThisIndex != - 1 ) m_model . fireTableRowsUpdated ( iThisIndex , iThisIndex ) ; return this . getStatus ( ) ; }
Set the status of this item .
14,249
public void printHtmlFooter ( PrintWriter out , ResourceBundle reg ) { String strHTML = reg . getString ( "htmlFooter" ) ; if ( ( strHTML == null ) || ( strHTML . length ( ) == 0 ) ) strHTML = "</body>\n</html>" ; out . println ( strHTML ) ; out . flush ( ) ; }
Bottom of HTML form .
14,250
public void printHtmlHeader ( PrintWriter out , String strTitle , String strHTMLStart , String strHTMLEnd ) { if ( ( strHTMLStart == null ) || ( strHTMLStart . length ( ) == 0 ) ) strHTMLStart = "<html>\n" + "<head>\n" + "<link rel=\"stylesheet\" type=\"text/css\" href=\"org/jbundle/res/docs/styles/css/style.css\" title=\"basicstyle\">" ; out . println ( strHTMLStart ) ; String strStyleParam = this . getProperty ( "style" ) ; if ( strStyleParam != null ) if ( strStyleParam . length ( ) > 0 ) { out . println ( "<style type=\"text/css\">" ) ; out . println ( "<!--" ) ; out . println ( "@import url(\"org/jbundle/res/docs/styles/css/" + strStyleParam + ".css\");" ) ; out . println ( " ) ; out . println ( "</style>" ) ; } String strParamTitle = this . getProperty ( "title" ) ; if ( strParamTitle != null ) if ( strParamTitle . length ( ) > 0 ) strTitle = strParamTitle ; if ( strTitle . length ( ) == 0 ) strTitle = "&nbsp;" ; if ( ( strHTMLEnd == null ) || ( strHTMLEnd . length ( ) == 0 ) ) strHTMLEnd = "<title>" + HtmlConstants . TITLE_TAG + "</title>\n" + "</head>\n" + "<body>\n" + "<h1>" + HtmlConstants . TITLE_TAG + "</h1>" ; strHTMLEnd = Utility . replace ( strHTMLEnd , HtmlConstants . TITLE_TAG , strTitle ) ; String strKeywords = this . getHtmlKeywords ( ) ; if ( ( strKeywords != null ) && ( strKeywords . length ( ) > 0 ) ) strKeywords += ", " ; strHTMLEnd = Utility . replace ( strHTMLEnd , "<keywords/>" , strKeywords ) ; String strMenudesc = this . getHtmlMenudesc ( ) ; strHTMLEnd = Utility . replace ( strHTMLEnd , HtmlConstants . MENU_DESC_TAG , strMenudesc ) ; out . println ( strHTMLEnd ) ; }
Default Form Header .
14,251
public void writeHtmlString ( String strHTML , PrintWriter out ) { int iIndex ; if ( strHTML == null ) return ; while ( ( iIndex = strHTML . indexOf ( HtmlConstants . TITLE_TAG ) ) != - 1 ) { strHTML = strHTML . substring ( 0 , iIndex ) + ( ( BasePanel ) this . getScreenField ( ) ) . getTitle ( ) + strHTML . substring ( iIndex + HtmlConstants . TITLE_TAG . length ( ) ) ; } out . println ( strHTML ) ; }
Parse the HTML for variables and print it .
14,252
public float write ( ) throws IOException { bitArray . setAll ( false ) ; for ( int ii = 0 ; ii < bytes ; ii ++ ) { bitArray . set ( ii , bb1 . get ( ii ) != bb2 . get ( ii ) ) ; } if ( ! bitArray . any ( ) ) { return 0 ; } if ( ! bitArray . and ( selfImportantArray ) ) { return 0 ; } if ( writeCount == 0 ) { DataOutputStream dos = new DataOutputStream ( out ) ; dos . writeUTF ( source ) ; dos . writeShort ( properties . size ( ) ) ; List < Property > props = new ArrayList < > ( properties . values ( ) ) ; props . sort ( null ) ; for ( Property prop : props ) { dos . writeUTF ( prop . getName ( ) ) ; dos . writeUTF ( prop . getType ( ) ) ; } dos . writeLong ( uuid . getMostSignificantBits ( ) ) ; dos . writeLong ( uuid . getLeastSignificantBits ( ) ) ; } out . write ( bits ) ; int cnt = 0 ; for ( int ii = 0 ; ii < bytes ; ii ++ ) { if ( bitArray . isSet ( ii ) ) { byte b = bb2 . get ( ii ) ; out . write ( b ) ; bb1 . put ( ii , b ) ; cnt ++ ; writeBytes ++ ; } } writeCount ++ ; return ( float ) cnt / ( float ) bytes ; }
Writes objects fields to stream
14,253
public String [ ] getRoles ( String username ) { if ( user_list . containsKey ( username ) ) { return user_list . get ( username ) . toArray ( new String [ 0 ] ) ; } else { if ( defaultRoles == null ) { return new String [ 0 ] ; } else { return defaultRoles ; } } }
Find and return all roles this user has .
14,254
public String [ ] getUsersInRole ( String role ) { if ( role_list . containsKey ( role ) ) { return role_list . get ( role ) . toArray ( new String [ 0 ] ) ; } else { return new String [ 0 ] ; } }
Returns a list of users who have a particular role .
14,255
public void setRole ( String username , String newrole ) throws RolesException { List < String > users_with_role = new ArrayList < String > ( ) ; if ( user_list . containsKey ( username ) ) { List < String > roles_of_user = user_list . get ( username ) ; if ( ! roles_of_user . contains ( newrole ) ) { roles_of_user . add ( newrole ) ; user_list . put ( username , roles_of_user ) ; if ( role_list . containsKey ( newrole ) ) users_with_role = role_list . get ( newrole ) ; users_with_role . add ( username ) ; role_list . put ( newrole , users_with_role ) ; String roles = StringUtils . join ( roles_of_user . toArray ( new String [ 0 ] ) , "," ) ; file_store . setProperty ( username , roles ) ; try { saveRoles ( ) ; } catch ( IOException e ) { throw new RolesException ( e ) ; } } else { throw new RolesException ( "User '" + username + "' already has role '" + newrole + "'!" ) ; } } else { List < String > empty = new ArrayList < String > ( ) ; user_list . put ( username , empty ) ; this . setRole ( username , newrole ) ; } }
Assign a role to a user .
14,256
public void removeRole ( String username , String oldrole ) throws RolesException { List < String > users_with_role = new ArrayList < String > ( ) ; if ( user_list . containsKey ( username ) ) { List < String > roles_of_user = user_list . get ( username ) ; if ( roles_of_user . contains ( oldrole ) ) { roles_of_user . remove ( oldrole ) ; user_list . put ( username , roles_of_user ) ; if ( role_list . containsKey ( oldrole ) ) users_with_role = role_list . get ( oldrole ) ; users_with_role . remove ( username ) ; if ( users_with_role . size ( ) < 1 ) { role_list . remove ( oldrole ) ; } else { role_list . put ( oldrole , users_with_role ) ; } String roles = StringUtils . join ( roles_of_user . toArray ( new String [ 0 ] ) , "," ) ; file_store . setProperty ( username , roles ) ; try { saveRoles ( ) ; } catch ( IOException e ) { throw new RolesException ( e ) ; } } else { throw new RolesException ( "User '" + username + "' does not have the role '" + oldrole + "'!" ) ; } } else { throw new RolesException ( "User '" + username + "' does not exist!" ) ; } }
Remove a role from a user .
14,257
public void deleteRole ( String rolename ) throws RolesException { if ( role_list . containsKey ( rolename ) ) { List < String > users_with_role = role_list . get ( rolename ) ; for ( String user : users_with_role ) { List < String > roles_of_user = user_list . get ( user ) ; roles_of_user . remove ( rolename ) ; user_list . put ( user , roles_of_user ) ; String roles = StringUtils . join ( roles_of_user . toArray ( new String [ 0 ] ) , "," ) ; file_store . setProperty ( user , roles ) ; } role_list . remove ( rolename ) ; try { saveRoles ( ) ; } catch ( IOException e ) { throw new RolesException ( e ) ; } } else { throw new RolesException ( "Cannot find role '" + rolename + "'!" ) ; } }
Delete a role .
14,258
public void renameRole ( String oldrole , String newrole ) throws RolesException { if ( role_list . containsKey ( oldrole ) ) { List < String > users_with_role = role_list . get ( oldrole ) ; for ( String user : users_with_role ) { List < String > roles_of_user = user_list . get ( user ) ; roles_of_user . remove ( oldrole ) ; roles_of_user . add ( newrole ) ; user_list . put ( user , roles_of_user ) ; String roles = StringUtils . join ( roles_of_user . toArray ( new String [ 0 ] ) , "," ) ; file_store . setProperty ( user , roles ) ; } role_list . remove ( oldrole ) ; role_list . put ( newrole , users_with_role ) ; try { saveRoles ( ) ; } catch ( IOException e ) { throw new RolesException ( e ) ; } } else { throw new RolesException ( "Cannot find role '" + oldrole + "'!" ) ; } }
Rename a role .
14,259
public String [ ] searchRoles ( String search ) throws RolesException { String [ ] roles = role_list . keySet ( ) . toArray ( new String [ role_list . size ( ) ] ) ; List < String > found = new ArrayList < String > ( ) ; for ( int i = 0 ; i < roles . length ; i ++ ) { if ( roles [ i ] . toLowerCase ( ) . contains ( search . toLowerCase ( ) ) ) { found . add ( roles [ i ] ) ; } } return found . toArray ( new String [ found . size ( ) ] ) ; }
Returns a list of roles matching the search .
14,260
public void run ( ) { Folder folder = this . getInboxFolder ( ) ; if ( folder != null ) this . processMail ( folder ) ; try { folder . close ( true ) ; } catch ( MessagingException e ) { e . printStackTrace ( ) ; } }
Run the code in this process .
14,261
public Folder getInboxFolder ( ) { String strMessageType = MessageTransportModel . EMAIL ; String strClassName = null ; Record recMessageTransport = this . getRecord ( MessageTransportModel . MESSAGE_TRANSPORT_FILE ) ; if ( recMessageTransport == null ) recMessageTransport = Record . makeRecordFromClassName ( MessageTransportModel . THICK_CLASS , this ) ; recMessageTransport . setKeyArea ( MessageTransportModel . CODE_KEY ) ; recMessageTransport . getField ( MessageTransportModel . CODE ) . setString ( strMessageType ) ; Map < String , Object > properties = null ; try { if ( recMessageTransport . seek ( null ) ) { PropertiesField fldProperty = ( PropertiesField ) recMessageTransport . getField ( MessageTransportModel . PROPERTIES ) ; strClassName = fldProperty . getProperty ( MessageTransportModel . TRANSPORT_CLASS_NAME_PARAM ) ; properties = fldProperty . loadProperties ( ) ; this . setProperties ( properties ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } if ( strClassName == null ) strClassName = EmailMessageTransport . class . getName ( ) ; String strHost = this . getProperty ( POP3_HOST ) ; int iPort = 110 ; if ( this . getProperty ( POP3_PORT ) != null ) iPort = Integer . parseInt ( this . getProperty ( POP3_PORT ) ) ; String strUsername = this . getProperty ( POP3_USERNAME ) ; String strPassword = this . getProperty ( POP3_PASSWORD ) ; strPassword = PasswordPropertiesField . decrypt ( strPassword ) ; String strInbox = this . getProperty ( POP3_INBOX ) ; if ( strInbox == null ) strInbox = DEFAULT_INBOX ; String strInterval = this . getProperty ( POP3_INTERVAL ) ; if ( strInterval == null ) strInterval = DEFAULT_INTERVAL ; try { Properties props = Utility . mapToProperties ( properties ) ; if ( ( props . getProperty ( POP3_SSL ) != null ) && ( props . getProperty ( POP3_SSL ) . equalsIgnoreCase ( DBConstants . TRUE ) ) ) { props . setProperty ( "mail.pop3.socketFactory.class" , SSL_FACTORY ) ; props . setProperty ( "mail.pop3.socketFactory.fallback" , "false" ) ; if ( this . getProperty ( POP3_PORT ) != null ) if ( this . getProperty ( "mail.pop3.socketFactory.port" ) == null ) props . setProperty ( "mail.pop3.socketFactory.port" , this . getProperty ( POP3_PORT ) ) ; } Session session = Session . getDefaultInstance ( props , null ) ; session . setDebug ( true ) ; URLName url = new URLName ( STORE_TYPE , strHost , iPort , "" , strUsername , strPassword ) ; Store store = session . getStore ( url ) ; store . connect ( ) ; Folder folder = store . getFolder ( strInbox ) ; if ( folder == null || ! folder . exists ( ) ) { Utility . getLogger ( ) . warning ( "Invalid folder" ) ; System . exit ( 1 ) ; } folder . open ( Folder . READ_WRITE ) ; return folder ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } return null ; }
Open the poop3 inbox .
14,262
public void processMail ( Folder folder ) { try { int iCount = folder . getMessageCount ( ) ; if ( iCount == 0 ) return ; String pattern = REPLY_STRING ; Message [ ] messages = null ; if ( this . getProperty ( PATTERN ) == null ) { messages = folder . getMessages ( ) ; } else { pattern = this . getProperty ( PATTERN ) ; SubjectTerm st = new SubjectTerm ( pattern ) ; messages = folder . search ( st ) ; } for ( int iMsgnum = 0 ; iMsgnum < messages . length ; iMsgnum ++ ) { Message message = messages [ iMsgnum ] ; String strSubject = message . getSubject ( ) ; if ( strSubject != null ) if ( ( pattern == null ) || ( strSubject . indexOf ( pattern ) != - 1 ) ) this . processThisMessage ( message ) ; message . setFlag ( Flags . Flag . SEEN , true ) ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } }
Go through all the mail and process the messages .
14,263
public String getContentString ( Message message ) { try { String strContentType = message . getContentType ( ) ; Object content = message . getContent ( ) ; if ( content instanceof MimeMultipart ) { for ( int index = 0 ; ; index ++ ) { BodyPart bodyPart = ( ( javax . mail . internet . MimeMultipart ) content ) . getBodyPart ( index ) ; Object contents = bodyPart . getContent ( ) ; if ( contents != null ) return contents . toString ( ) ; } } return message . getContent ( ) . toString ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } catch ( MessagingException ex ) { ex . printStackTrace ( ) ; } return null ; }
Get the message content as a string .
14,264
public Object createObject ( String className , Class clazz ) throws ClassNotFoundException { Object object ; try { object = clazz . newInstance ( ) ; } catch ( InstantiationException ie ) { String info = "Could not create " + description + " object: " + className + ". Could not access object constructor: " ; info += ie . getMessage ( ) ; throw new ClassNotFoundException ( info , ie ) ; } catch ( IllegalAccessException iae ) { String info = "Could not create " + description + " object: " + className + ". Could not instantiate object. Does the object classname refer to an abstract class, " + "an interface or the like?: " ; info += iae . getMessage ( ) ; throw new ClassNotFoundException ( info , iae ) ; } catch ( ClassCastException cce ) { String info = "Could not create " + description + " object: " + className + ". The specified object classname does not refer to the proper type: " ; info += cce . getMessage ( ) ; throw new ClassNotFoundException ( info , cce ) ; } return object ; }
Dynamically creates an object
14,265
public double fast ( ) { readLock . lock ( ) ; try { int count = count ( ) ; return toDegrees ( sinSum / count , cosSum / count ) ; } finally { readLock . unlock ( ) ; } }
Returns fast average . Fast calculation adds and subtracts values from sum field . This might cause difference in time to actual calculating sample by sample .
14,266
public double average ( ) { readLock . lock ( ) ; try { int count = count ( ) ; double s = 0 ; double c = 0 ; PrimitiveIterator . OfInt it = modIterator ( ) ; while ( it . hasNext ( ) ) { int m = it . nextInt ( ) ; s += sin [ m ] ; c += cos [ m ] ; } ; return toDegrees ( s / count , c / count ) ; } finally { readLock . unlock ( ) ; } }
Returns sample by sample calculated average .
14,267
public void remove ( EventQueueEntry entry ) { List < EventQueueEntry > container = queue . get ( entry . getPriority ( ) ) ; if ( container == null ) { return ; } container . remove ( entry ) ; }
Removes the given queue entry from the notification list .
14,268
public void removeAll ( Object object ) { for ( Entry < Integer , List < EventQueueEntry > > e : queue . entrySet ( ) ) { List < EventQueueEntry > entries = e . getValue ( ) ; List < EventQueueEntry > toRemove = new LinkedList < > ( ) ; synchronized ( entries ) { for ( EventQueueEntry entry : entries ) { if ( entry . getObject ( ) == object ) { toRemove . add ( entry ) ; } } entries . removeAll ( toRemove ) ; } } log . debug ( "Removed {} from notification queue for {}" , object , eventType ) ; }
Removes all handler methods in the given object from notifications by this queue .
14,269
public final int getRemaining ( ) { int rem = 0 ; for ( int ii = 0 ; ii < length ; ii ++ ) { rem += srcs [ offset + ii ] . remaining ( ) ; } return rem ; }
Returns the number of bytes that can be written .
14,270
public void updateImage ( ) { if ( m_iCurrentState == ON ) this . setIcon ( m_iconOn ) ; else if ( m_iCurrentState == OFF ) this . setIcon ( m_iconOff ) ; else this . setIcon ( m_iconNull ) ; }
Update the image to the current state .
14,271
public void toggleState ( ) { if ( m_iCurrentState == ON ) m_iCurrentState = NULL ; else if ( m_iCurrentState == OFF ) m_iCurrentState = ON ; else m_iCurrentState = OFF ; this . updateImage ( ) ; }
Toggle the button state .
14,272
private DirectoryService createDirectoryService ( ) { final DirectoryServiceFactory factory = new DefaultDirectoryServiceFactory ( ) ; try { factory . init ( "scribble" ) ; return factory . getDirectoryService ( ) ; } catch ( Exception e ) { throw new AssertionError ( "Unable to create directory service" , e ) ; } }
Creates a new DirectoryService instance for the test rule . Initialization of the service is done in the apply Statement phase by invoking the setupService method .
14,273
protected void setupService ( ) throws Exception { final DirectoryService service = this . getDirectoryService ( ) ; service . getChangeLog ( ) . setEnabled ( false ) ; this . workDir = getOuterRule ( ) . newFolder ( "dsworkdir" ) ; service . setInstanceLayout ( new InstanceLayout ( this . workDir ) ) ; final CacheService cacheService = new CacheService ( ) ; cacheService . initialize ( service . getInstanceLayout ( ) ) ; service . setCacheService ( cacheService ) ; service . setAccessControlEnabled ( this . acEnabled ) ; service . setAllowAnonymousAccess ( this . anonymousAllowed ) ; this . createPartitions ( ) ; this . importInitialLdif ( ) ; }
Applies the configuration to the service such as AccessControl and AnonymousAccess . Both are enabled as configured . Further the method initializes the cache service . The method does not start the service .
14,274
private void importInitialLdif ( ) throws IOException { if ( this . initialLdif != null ) { try ( InputStream ldifStream = this . initialLdif . openStream ( ) ) { this . importLdif ( ldifStream ) ; } } }
Initializes the directory with content from the initial ldif file . Note that a partition has to be created for the root of the ldif file .
14,275
private void createPartitions ( ) { for ( Map . Entry < String , String > partitionEntry : this . partitions . entrySet ( ) ) { try { this . addPartitionInternal ( partitionEntry . getKey ( ) , partitionEntry . getValue ( ) ) ; } catch ( Exception e ) { throw new AssertionError ( "Could not create partitions " + this . partitions , e ) ; } } }
Creates all paritions that are added on rule setup .
14,276
public void importLdif ( InputStream ldifData ) throws IOException { final File ldifFile = getOuterRule ( ) . newFile ( "scribble_import.ldif" ) ; try ( final Writer writer = new OutputStreamWriter ( new FileOutputStream ( ldifFile ) , Charsets . UTF_8 ) ) { IOUtils . copy ( ldifData , writer ) ; } final String pathToLdifFile = ldifFile . getAbsolutePath ( ) ; final CoreSession session = this . getDirectoryService ( ) . getAdminSession ( ) ; final LdifFileLoader loader = new LdifFileLoader ( session , pathToLdifFile ) ; loader . execute ( ) ; }
Imports directory content that is defined in LDIF format and provided as input stream . The method writes the stream content into a temporary file .
14,277
public void addPartition ( String partitionId , String suffix ) { this . partitions . put ( partitionId , suffix ) ; }
Adds a partition to the rule . The actual parititon is created when the rule is applied .
14,278
public void moveTheData ( boolean bDisplayOption , int iMoveType ) { if ( m_convCheckMark != null ) if ( m_bDisableOnMove ) m_fldDest . setEnabled ( ! m_convCheckMark . getState ( ) ) ; if ( ( m_convCheckMark == null ) || ( m_convCheckMark . getState ( ) ) ) { if ( ( this . getSourceField ( ) != null ) && ( ( ! this . getSourceField ( ) . isNull ( ) ) || ( ! m_bDontMoveNullSource ) ) ) m_fldDest . moveFieldToThis ( this . getSourceField ( ) , bDisplayOption , iMoveType ) ; else if ( m_strSource != null ) m_fldDest . setString ( m_strSource , bDisplayOption , iMoveType ) ; else if ( m_fldDest instanceof ReferenceField ) ( ( ReferenceField ) m_fldDest ) . setReference ( this . getOwner ( ) , bDisplayOption , iMoveType ) ; } else { if ( bDisplayOption ) m_fldDest . displayField ( ) ; } }
Actually move the data .
14,279
public Object convertToMessage ( ) { try { Object reply = this . getRawData ( ) ; org . w3c . dom . Node nodeBody = this . getMessageBody ( reply , false ) ; if ( this . getConvertToMessage ( ) == null ) return null ; Object msg = this . getConvertToMessage ( ) . unmarshalRootElement ( nodeBody , this ) ; return msg ; } catch ( Throwable ex ) { this . setMessageException ( ex ) ; } return null ; }
Convert this DOM Tree to the JAXB message tree . Don t override this method override the unmarshalRootElement method .
14,280
public void setMessageException ( Throwable ex ) { String strErrorMessage = ex . getMessage ( ) ; BaseMessage message = this . getMessage ( ) ; if ( ( message != null ) && ( message . getMessageHeader ( ) instanceof TrxMessageHeader ) ) ( ( TrxMessageHeader ) message . getMessageHeader ( ) ) . put ( TrxMessageHeader . MESSAGE_ERROR , strErrorMessage ) ; else ex . printStackTrace ( ) ; }
If an exception occurred set it in the message
14,281
public void addComponent ( JComponent component , boolean bLinkComponentToConverter ) { this . add ( Box . createHorizontalStrut ( 3 ) ) ; if ( this . getComponentCount ( ) < brgComponentsLinkedToConverter . length ) brgComponentsLinkedToConverter [ this . getComponentCount ( ) ] = bLinkComponentToConverter ; this . add ( component ) ; }
Add this component to this panel .
14,282
public void setControlValue ( Object objValue , Component component ) { Convert converter = null ; if ( component instanceof ScreenComponent ) converter = ( ( ScreenComponent ) component ) . getConverter ( ) ; if ( converter == null ) converter = m_converter ; if ( component instanceof FieldComponent ) ( ( FieldComponent ) component ) . setControlValue ( converter . getData ( ) ) ; else if ( component instanceof JTextComponent ) ( ( JTextComponent ) component ) . setText ( converter . toString ( ) ) ; }
Set this control to this value .
14,283
public Map < String , Object > getTransportProperties ( ) { Map < String , Object > propMessageTransport = null ; Record recMessageTransport = Record . makeRecordFromClassName ( MessageTransportModel . THICK_CLASS , this ) ; recMessageTransport . setKeyArea ( MessageTransportModel . CODE_KEY ) ; String strMessageType = this . getMessageTransportType ( ) ; recMessageTransport . getField ( MessageTransportModel . CODE ) . setString ( strMessageType ) ; try { if ( recMessageTransport . seek ( null ) ) { PropertiesField fldProperty = ( PropertiesField ) recMessageTransport . getField ( MessageTransportModel . PROPERTIES ) ; propMessageTransport = fldProperty . loadProperties ( ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { recMessageTransport . free ( ) ; recMessageTransport = null ; } return propMessageTransport ; }
Get the properties that go with this transport type .
14,284
public void setupReplyMessage ( BaseMessage messageReply , BaseMessage messageOut , String strMessageInfoType , String strMessageProcessType ) { if ( messageReply != null ) { TrxMessageHeader trxMessageHeaderIncomming = null ; if ( messageOut != null ) trxMessageHeaderIncomming = ( TrxMessageHeader ) messageOut . getMessageHeader ( ) ; if ( trxMessageHeaderIncomming != null ) { TrxMessageHeader replyHeader = ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ; if ( replyHeader == null ) messageReply . setMessageHeader ( replyHeader = new TrxMessageHeader ( null , null ) ) ; replyHeader . putAll ( trxMessageHeaderIncomming . createReplyHeader ( ) ) ; if ( strMessageInfoType != null ) ( ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ) . put ( TrxMessageHeader . MESSAGE_INFO_TYPE , strMessageInfoType ) ; if ( strMessageProcessType != null ) ( ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ) . put ( TrxMessageHeader . MESSAGE_PROCESS_TYPE , strMessageProcessType ) ; if ( ( ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ) . getMessageInfoMap ( ) != null ) ( ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ) . getMessageInfoMap ( ) . remove ( TrxMessageHeader . MESSAGE_PROCESSOR_CLASS ) ; Record recMessageProcessInfo = this . getRecord ( MessageProcessInfoModel . MESSAGE_PROCESS_INFO_FILE ) ; if ( recMessageProcessInfo == null ) recMessageProcessInfo = Record . makeRecordFromClassName ( MessageProcessInfoModel . THICK_CLASS , this ) ; this . addMessageTransportType ( messageReply ) ; ( ( MessageProcessInfoModel ) recMessageProcessInfo ) . setupMessageHeaderFromCode ( messageReply , null , null ) ; } if ( strMessageInfoType != null ) ( ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ) . put ( TrxMessageHeader . MESSAGE_INFO_TYPE , strMessageInfoType ) ; if ( strMessageProcessType != null ) ( ( TrxMessageHeader ) messageReply . getMessageHeader ( ) ) . put ( TrxMessageHeader . MESSAGE_PROCESS_TYPE , strMessageProcessType ) ; } }
Set up a message header for this reply using the message header for the original message .
14,285
public String getProperty ( TrxMessageHeader trxMessageHeader , String strParamName ) { String strProperty = ( String ) trxMessageHeader . get ( strParamName ) ; if ( strProperty == null ) strProperty = this . getProperty ( strParamName ) ; return strProperty ; }
Get this transport specific param . Get this param . The transport properties specify param names by adding the word param after it . For example to specify a different param for the messageClass for a SOAP transport the SOAP property messageClassParam = SOAPMessageClass should be set in the SOAP transport properties and the SOAPMessageClass should be set in the messageProperties so it knows which message class to use for SOAP messages .
14,286
public ContactTypeField getContactTypeField ( ) { BaseField field = this . getRecord ( ) . getField ( "ContactTypeID" ) ; if ( field instanceof ContactTypeField ) return ( ContactTypeField ) field ; return null ; }
Get the contact type field in the same record as this contact field .
14,287
public static PublicKey generatePublicKey ( String encodedPublicKey ) { try { byte [ ] decodedKey = Base64 . decode ( encodedPublicKey ) ; KeyFactory keyFactory = KeyFactory . getInstance ( KEY_FACTORY_ALGORITHM ) ; return keyFactory . generatePublic ( new X509EncodedKeySpec ( decodedKey ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new RuntimeException ( e ) ; } catch ( InvalidKeySpecException e ) { Log . e ( TAG , "Invalid key specification." ) ; throw new IllegalArgumentException ( e ) ; } catch ( Base64DecoderException e ) { Log . e ( TAG , "Base64 decoding failed." ) ; throw new IllegalArgumentException ( e ) ; } }
Generates a PublicKey instance from a string containing the Base64 - encoded public key .
14,288
private void logNodeTypes ( final NodeType ... nodeTypes ) { if ( LOG . isDebugEnabled ( ) ) { StringBuilder buf = new StringBuilder ( 32 ) ; buf . append ( "[\n" ) ; for ( NodeType nt : nodeTypes ) { buf . append ( nt . getName ( ) ) . append ( " > " ) ; for ( NodeType st : nt . getSupertypes ( ) ) { buf . append ( st . getName ( ) ) . append ( ", " ) ; } buf . append ( '\n' ) ; for ( PropertyDefinition pd : nt . getPropertyDefinitions ( ) ) { buf . append ( "\t" ) . append ( pd . getName ( ) ) . append ( " (" ) . append ( PropertyType . nameFromValue ( pd . getRequiredType ( ) ) ) . append ( ")\n" ) ; } } buf . append ( ']' ) ; LOG . debug ( "Registered NodeTypes: {}" , buf . toString ( ) ) ; } }
Helper method to logs a list of node types and their properties in a human readable way .
14,289
public void notifySubscribers ( final List < ? extends Subscriber > subscribers , final SyndFeed value , final SubscriptionSummaryCallback callback ) { String mimeType = null ; if ( value . getFeedType ( ) . startsWith ( "rss" ) ) { mimeType = "application/rss+xml" ; } else { mimeType = "application/atom+xml" ; } final SyndFeedOutput output = new SyndFeedOutput ( ) ; final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { output . output ( value , new OutputStreamWriter ( baos ) ) ; baos . close ( ) ; } catch ( final IOException ex ) { LOG . error ( "Unable to output the feed" , ex ) ; throw new RuntimeException ( "Unable to output the feed." , ex ) ; } catch ( final FeedException ex ) { LOG . error ( "Unable to output the feed" , ex ) ; throw new RuntimeException ( "Unable to output the feed." , ex ) ; } final byte [ ] payload = baos . toByteArray ( ) ; for ( final Subscriber s : subscribers ) { final Notification not = new Notification ( ) ; not . callback = callback ; not . lastRun = 0 ; not . mimeType = mimeType ; not . payload = payload ; not . retryCount = 0 ; not . subscriber = s ; enqueueNotification ( not ) ; } }
This method will serialize the synd feed and build Notifications for the implementation class to handle .
14,290
public static String fixPropertyValue ( String string , boolean bResourceListBundle ) { if ( string == null ) string = Constants . BLANK ; StringBuffer strBuff = new StringBuffer ( ) ; StringReader stringReader = new StringReader ( string ) ; LineNumberReader lineReader = new LineNumberReader ( stringReader ) ; boolean bFirstTime = true ; String strLine ; try { while ( ( strLine = lineReader . readLine ( ) ) != null ) { if ( ! bFirstTime ) { if ( bResourceListBundle ) strBuff . append ( " + \"\\n\" +" + "\n\t\t" ) ; else strBuff . append ( "\\n\\\n" ) ; } if ( bResourceListBundle ) strBuff . append ( '\"' ) ; if ( ! bFirstTime ) if ( ! bResourceListBundle ) if ( strLine . startsWith ( " " ) ) strBuff . append ( "\\" ) ; strBuff . append ( ResourcesUtilities . encodeLine ( strLine , bResourceListBundle ) ) ; if ( bResourceListBundle ) strBuff . append ( "\"" ) ; bFirstTime = false ; } } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return strBuff . toString ( ) ; }
Clean up this long string and convert it to a java quoted string .
14,291
public static String encodeLine ( String string , boolean bResourceListBundle ) { if ( string == null ) return string ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { if ( ( ( string . charAt ( i ) == '\"' ) || ( string . charAt ( i ) == '\\' ) ) || ( ( ! bResourceListBundle ) && ( string . charAt ( i ) == ':' ) ) ) { string = string . substring ( 0 , i ) + "\\" + string . substring ( i ) ; i ++ ; } else if ( string . charAt ( i ) > 127 ) { String strHex = "0123456789ABCDEF" ; String strOut = "\\u" ; strOut += strHex . charAt ( ( string . charAt ( i ) & 0xF000 ) >> 12 ) ; strOut += strHex . charAt ( ( string . charAt ( i ) & 0xF00 ) >> 8 ) ; strOut += strHex . charAt ( ( string . charAt ( i ) & 0xF0 ) >> 4 ) ; strOut += strHex . charAt ( string . charAt ( i ) & 0xF ) ; string = string . substring ( 0 , i ) + strOut + string . substring ( i + 1 ) ; i = i + strOut . length ( ) - 1 ; } } return string ; }
Encode the utf - 16 characters in this line to escaped java strings .
14,292
public static final < T > void doFor ( Object bean , String property , Consumer < T > consumer ) { T t = ( T ) getValue ( bean , property ) ; consumer . accept ( t ) ; }
Executes consumer for property .
14,293
public static final Object getValue ( Object bean , String property ) { return doFor ( bean , property , null , BeanHelper :: getValue , BeanHelper :: getValue , BeanHelper :: getFieldValue , BeanHelper :: getMethodValue ) ; }
Return propertys value .
14,294
public static final Class [ ] getParameterTypes ( Object bean , String property ) { Type type = ( Type ) doFor ( bean , property , null , ( Object a , int i ) -> { Object o = Array . get ( a , i ) ; return o != null ? o . getClass ( ) . getComponentType ( ) : null ; } , ( List l , int i ) -> { return l . get ( i ) . getClass ( ) . getGenericSuperclass ( ) ; } , ( Object o , Class c , String p ) -> { return getField ( c , p ) . getGenericType ( ) ; } , ( Object o , Method m ) -> { return m . getGenericReturnType ( ) ; } ) ; if ( type instanceof ParameterizedType ) { ParameterizedType pt = ( ParameterizedType ) type ; Type [ ] ata = pt . getActualTypeArguments ( ) ; if ( ata . length > 0 ) { Class [ ] ca = new Class [ ata . length ] ; for ( int ii = 0 ; ii < ca . length ; ii ++ ) { ca [ ii ] = ( Class ) ata [ ii ] ; } return ca ; } } if ( type instanceof Class ) { Class cls = ( Class ) type ; if ( cls . isArray ( ) ) { cls = cls . getComponentType ( ) ; } return new Class [ ] { cls } ; } return null ; }
Returns actual parameter types for property
14,295
public static Field getField ( Class cls , String fieldname ) throws NoSuchFieldException { while ( true ) { try { return cls . getDeclaredField ( fieldname ) ; } catch ( NoSuchFieldException ex ) { cls = cls . getSuperclass ( ) ; if ( Object . class . equals ( cls ) ) { throw ex ; } } catch ( SecurityException ex ) { throw new IllegalArgumentException ( ex ) ; } } }
Returns Declared field either from given class or it s super class
14,296
public static final Class getType ( Object bean , String property ) { return ( Class ) doFor ( bean , property , null , BeanHelper :: getObjectType , BeanHelper :: getObjectType , BeanHelper :: getFieldType , BeanHelper :: getMethodType ) ; }
Return property type .
14,297
public static final < T extends Annotation > T getAnnotation ( Object bean , String property , Class < T > annotationClass ) { return ( T ) doFor ( bean , property , null , ( Object a , int i ) -> { Object o = Array . get ( a , i ) ; return o != null ? o . getClass ( ) . getAnnotation ( annotationClass ) : null ; } , ( List l , int i ) -> { return l . get ( i ) . getClass ( ) . getAnnotation ( annotationClass ) ; } , ( Object b , Class c , String p ) -> { return getField ( c , p ) . getAnnotation ( annotationClass ) ; } , ( Object b , Method m ) -> { return m . getAnnotation ( annotationClass ) ; } ) ; }
Returns property annotation .
14,298
public static final boolean hasProperty ( Object bean , String property ) { try { return ( boolean ) doFor ( bean , property , null , ( Object a , int i ) -> { return true ; } , ( List l , int i ) -> { return true ; } , ( Object b , Class c , String p ) -> { getField ( c , p ) ; return true ; } , ( Object b , Method m ) -> { return true ; } ) ; } catch ( BeanHelperException ex ) { return false ; } }
Return true if property exists .
14,299
public static final < T > T defaultFactory ( Class < T > cls , String hint ) { try { return cls . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException ex ) { throw new IllegalArgumentException ( ex ) ; } }
Default object factory that calls newInstance method . Checked exceptions are wrapped in IllegalArgumentException .