idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
141,300
public OIdentifiableIterator < REC > setReuseSameRecord ( final boolean reuseSameRecord ) { reusedRecord = ( ORecordInternal < ? > ) ( reuseSameRecord ? database . newInstance ( ) : null ) ; return this ; }
Tell to the iterator to use the same record for browsing . The record will be reset before every use . This improve the performance and reduce memory utilization since it does not create a new one for each operation but pay attention to copy the data of the record once read otherwise they will be reset to the next oper...
141,301
protected ORecordInternal < ? > getRecord ( ) { final ORecordInternal < ? > record ; if ( reusedRecord != null ) { record = reusedRecord ; record . reset ( ) ; } else record = null ; return record ; }
Return the record to use for the operation .
141,302
protected ORecordInternal < ? > readCurrentRecord ( ORecordInternal < ? > iRecord , final int iMovement ) { if ( limit > - 1 && browsedRecords >= limit ) return null ; current . clusterPosition += iMovement ; if ( iRecord != null ) { iRecord . setIdentity ( current ) ; iRecord = lowLevelDatabase . load ( iRecord , fetc...
Read the current record and increment the counter if the record was found .
141,303
public void bindParameters ( final Map < Object , Object > iArgs ) { if ( parameterItems == null || iArgs == null || iArgs . size ( ) == 0 ) return ; for ( Entry < Object , Object > entry : iArgs . entrySet ( ) ) { if ( entry . getKey ( ) instanceof Integer ) parameterItems . get ( ( ( Integer ) entry . getKey ( ) ) ) ...
Binds parameters .
141,304
public boolean send ( Context context , Report report ) { if ( url != null ) { String reportStr = report . asJSON ( ) . toString ( ) ; try { postReport ( url , reportStr ) ; return true ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return false ; }
If the reporter was configured correctly post the report to the set URL .
141,305
public static void post ( URL url , String params ) throws IOException { URLConnection conn = url . openConnection ( ) ; if ( conn instanceof HttpURLConnection ) { ( ( HttpURLConnection ) conn ) . setRequestMethod ( "POST" ) ; conn . setRequestProperty ( "Content-Type" , "application/json" ) ; } OutputStreamWriter writ...
Executes the given request as a HTTP POST action .
141,306
public static String read ( InputStream in ) throws IOException { InputStreamReader isReader = new InputStreamReader ( in , "UTF-8" ) ; BufferedReader reader = new BufferedReader ( isReader ) ; StringBuffer out = new StringBuffer ( ) ; char [ ] c = new char [ 4096 ] ; for ( int n ; ( n = reader . read ( c ) ) != - 1 ; ...
Reads an input stream and returns the result as a String .
141,307
public Object joinGame ( long id , String password ) { return client . sendRpcAndWait ( SERVICE , "joinGame" , id , password ) ; }
Join a password - protected game .
141,308
public Object observeGame ( long id , String password ) { return client . sendRpcAndWait ( SERVICE , "observeGame" , id , password ) ; }
Join a password - protected game as a spectator
141,309
public boolean switchToPlayer ( long id , PlayerSide team ) { return client . sendRpcAndWait ( SERVICE , "switchObserverToPlayer" , id , team . id ) ; }
Switch from observer to player
141,310
protected byte [ ] serializeStreamValue ( final int iIndex ) throws IOException { if ( serializedValues [ iIndex ] <= 0 ) { OProfiler . getInstance ( ) . updateCounter ( "OMVRBTreeMapEntry.serializeValue" , 1 ) ; return ( ( OMVRBTreeMapProvider < K , V > ) treeDataProvider ) . valueSerializer . toStream ( values [ iInd...
Serialize only the new values or the changed .
141,311
public MigrationJob [ ] retrieveJobs ( int batchSize , int startIndex , JobType jobType ) throws IOException , LightblueException { LOGGER . debug ( "Retrieving jobs: batchSize={}, startIndex={}" , batchSize , startIndex ) ; DataFindRequest findRequest = new DataFindRequest ( "migrationJob" , null ) ; List < Query > co...
Retrieves jobs that are available and their scheduled time has passed . Returns at most batchSize jobs starting at startIndex
141,312
public ActiveExecution lock ( String id ) throws Exception { LOGGER . debug ( "locking {}" , id ) ; if ( ! myLocks . contains ( id ) ) { if ( locking . acquire ( id , null ) ) { myLocks . add ( id ) ; ActiveExecution ae = new ActiveExecution ( ) ; ae . setMigrationJobId ( id ) ; ae . set_id ( id ) ; ae . setStartTime (...
Attempts to lock a migration job . If successful return the migration job and the active execution
141,313
public < H extends EventHandler > H getHandler ( GwtEvent . Type < H > type , int index ) { return this . eventBus . superGetHandler ( type , index ) ; }
Gets the handler at the given index .
141,314
public < H extends EventHandler > void removeHandler ( GwtEvent . Type < H > type , final H handler ) { this . eventBus . superDoRemove ( type , null , handler ) ; }
Removes the given handler from the specified event type .
141,315
public void sendFailure ( String message ) { System . out . print ( "Warning: " + message ) ; System . exit ( 1 ) ; }
logs message with status code 1 - warn
141,316
public void sendError ( String message ) { System . out . print ( "Critical: " + message ) ; System . exit ( 2 ) ; }
logs message with status code 2 - critical
141,317
public Object execute ( final Map < Object , Object > iArgs ) { if ( className == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; final ODatabaseRecord database = getDatabase ( ) ; if ( database . getMetadata ( ) . getSchema ( ) . existsClass ( className...
Execute the CREATE CLASS .
141,318
public boolean callbackHooks ( final TYPE iType , final OIdentifiable id ) { if ( ! OHookThreadLocal . INSTANCE . push ( id ) ) return false ; try { final ORecord < ? > rec = id . getRecord ( ) ; if ( rec == null ) return false ; boolean recordChanged = false ; for ( ORecordHook hook : hooks ) if ( hook . onTrigger ( i...
Callback the registeted hooks if any .
141,319
public String execute ( String url , String urlParameters , String clientId , String secret , String method ) throws Exception { HttpURLConnection connection ; String credentials = clientId + ":" + secret ; String authorizationHeader = "Basic " + Base64 . getEncoder ( ) . encodeToString ( credentials . getBytes ( ) ) ;...
Performs an HTTP call to the Keycloak server returning the server s response as String .
141,320
private void buildReport ( Context context ) { try { buildBaseReport ( ) ; buildApplicationData ( context ) ; buildDeviceData ( context ) ; buildLog ( ) ; report . put ( "application" , app ) ; report . put ( "device" , device ) ; report . put ( "log" , logs ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; }...
Creates the report as a JSON Object .
141,321
private void buildLog ( ) throws JSONException { logs = new JSONObject ( ) ; List < String > list = Log . getReportedEntries ( ) ; if ( list != null ) { logs . put ( "numberOfEntry" , list . size ( ) ) ; JSONArray array = new JSONArray ( ) ; for ( String s : list ) { array . put ( s ) ; } logs . put ( "log" , array ) ;...
Adds the log entries to the report .
141,322
private void buildDeviceData ( Context context ) throws JSONException { device = new JSONObject ( ) ; device . put ( "device" , Build . DEVICE ) ; device . put ( "brand" , Build . BRAND ) ; Object windowService = context . getSystemService ( Context . WINDOW_SERVICE ) ; if ( windowService instanceof WindowManager ) { D...
Adds the device data to the report .
141,323
private void buildApplicationData ( Context context ) throws JSONException { app = new JSONObject ( ) ; app . put ( "package" , context . getPackageName ( ) ) ; try { PackageInfo info = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) ; app . put ( "versionCode" , info . versionCode...
Adds the application data to the report .
141,324
public Set < ODocument > getEdgesBetweenVertexes ( final ODocument iVertex1 , final ODocument iVertex2 ) { return getEdgesBetweenVertexes ( iVertex1 , iVertex2 , null , null ) ; }
Returns all the edges between the vertexes iVertex1 and iVertex2 .
141,325
public Set < ODocument > getEdgesBetweenVertexes ( final ODocument iVertex1 , final ODocument iVertex2 , final String [ ] iLabels ) { return getEdgesBetweenVertexes ( iVertex1 , iVertex2 , iLabels , null ) ; }
Returns all the edges between the vertexes iVertex1 and iVertex2 with label between the array of labels passed as iLabels .
141,326
public Set < ODocument > getEdgesBetweenVertexes ( final ODocument iVertex1 , final ODocument iVertex2 , final String [ ] iLabels , final String [ ] iClassNames ) { final Set < ODocument > result = new HashSet < ODocument > ( ) ; if ( iVertex1 != null && iVertex2 != null ) { for ( OIdentifiable e : getOutEdges ( iVerte...
Returns all the edges between the vertexes iVertex1 and iVertex2 with label between the array of labels passed as iLabels and with class between the array of class names passed as iClassNames .
141,327
public Set < OIdentifiable > getOutEdgesHavingProperties ( final OIdentifiable iVertex , Iterable < String > iProperties ) { final ODocument vertex = iVertex . getRecord ( ) ; checkVertexClass ( vertex ) ; return filterEdgesByProperties ( ( OMVRBTreeRIDSet ) vertex . field ( VERTEX_FIELD_OUT ) , iProperties ) ; }
Retrieves the outgoing edges of vertex iVertex having the requested properties iProperties
141,328
public Set < OIdentifiable > getInEdgesHavingProperties ( final OIdentifiable iVertex , Iterable < String > iProperties ) { final ODocument vertex = iVertex . getRecord ( ) ; checkVertexClass ( vertex ) ; return filterEdgesByProperties ( ( OMVRBTreeRIDSet ) vertex . field ( VERTEX_FIELD_IN ) , iProperties ) ; }
Retrieves the incoming edges of vertex iVertex having the requested properties iProperties
141,329
public Set < OIdentifiable > getInEdgesHavingProperties ( final ODocument iVertex , final Map < String , Object > iProperties ) { checkVertexClass ( iVertex ) ; return filterEdgesByProperties ( ( OMVRBTreeRIDSet ) iVertex . field ( VERTEX_FIELD_IN ) , iProperties ) ; }
Retrieves the incoming edges of vertex iVertex having the requested properties iProperties set to the passed values
141,330
public synchronized OServerAdmin connect ( final String iUserName , final String iUserPassword ) throws IOException { storage . createConnectionPool ( ) ; storage . setSessionId ( - 1 ) ; try { final OChannelBinaryClient network = storage . beginRequest ( OChannelBinaryProtocol . REQUEST_CONNECT ) ; storage . sendClien...
Connects to a remote server .
141,331
@ SuppressWarnings ( "unchecked" ) public synchronized Map < String , String > listDatabases ( ) throws IOException { storage . checkConnection ( ) ; final ODocument result = new ODocument ( ) ; try { final OChannelBinaryClient network = storage . beginRequest ( OChannelBinaryProtocol . REQUEST_DB_LIST ) ; storage . en...
List the databases on a remote server .
141,332
public synchronized OServerAdmin createDatabase ( final String iDatabaseType , String iStorageMode ) throws IOException { storage . checkConnection ( ) ; try { if ( storage . getName ( ) == null || storage . getName ( ) . length ( ) <= 0 ) { OLogManager . instance ( ) . error ( this , "Cannot create unnamed remote stor...
Creates a database in a remote server .
141,333
public synchronized boolean existsDatabase ( ) throws IOException { storage . checkConnection ( ) ; try { final OChannelBinaryClient network = storage . beginRequest ( OChannelBinaryProtocol . REQUEST_DB_EXIST ) ; try { network . writeString ( storage . getName ( ) ) ; } finally { storage . endRequest ( network ) ; } t...
Checks if a database exists in the remote server .
141,334
public synchronized OServerAdmin dropDatabase ( ) throws IOException { storage . checkConnection ( ) ; boolean retry = true ; while ( retry ) try { final OChannelBinaryClient network = storage . beginRequest ( OChannelBinaryProtocol . REQUEST_DB_DROP ) ; try { network . writeString ( storage . getName ( ) ) ; } finally...
Drops a database from a remote server instance .
141,335
public ODocument clusterStatus ( ) { final ODocument response = sendRequest ( OChannelBinaryProtocol . REQUEST_CLUSTER , new ODocument ( ) . field ( "operation" , "status" ) , "Cluster status" ) ; OLogManager . instance ( ) . debug ( this , "Cluster status %s" , response . toJSON ( ) ) ; return response ; }
Gets the cluster status .
141,336
public synchronized OServerAdmin replicationStop ( final String iDatabaseName , final String iRemoteServer ) throws IOException { sendRequest ( OChannelBinaryProtocol . REQUEST_REPLICATION , new ODocument ( ) . field ( "operation" , "stop" ) . field ( "node" , iRemoteServer ) . field ( "db" , iDatabaseName ) , "Stop re...
Stops the replication between two servers .
141,337
public synchronized ODocument getReplicationJournal ( final String iDatabaseName , final String iRemoteServer ) throws IOException { OLogManager . instance ( ) . debug ( this , "Retrieving the replication log for database '%s' from server '%s'..." , iDatabaseName , storage . getURL ( ) ) ; final ODocument response = se...
Gets the replication journal for a database .
141,338
public OServerAdmin replicationAlign ( final String iDatabaseName , final String iRemoteServer , final String iOptions ) { OLogManager . instance ( ) . debug ( this , "Started the alignment of database '%s' from server '%s' to '%s' with options %s" , iDatabaseName , storage . getURL ( ) , iRemoteServer , iOptions ) ; s...
Aligns a database between two servers
141,339
public synchronized OServerAdmin copyDatabase ( final String iDatabaseName , final String iDatabaseUserName , final String iDatabaseUserPassword , final String iRemoteName , final String iRemoteEngine ) throws IOException { storage . checkConnection ( ) ; try { final OChannelBinaryClient network = storage . beginReques...
Copies a database to a remote server instance .
141,340
public Object execute ( final OIdentifiable o , final OCommandExecutor iRequester ) { for ( int i = 0 ; i < configuredParameters . length ; ++ i ) { if ( configuredParameters [ i ] instanceof OSQLFilterItemField ) runtimeParameters [ i ] = ( ( OSQLFilterItemField ) configuredParameters [ i ] ) . getValue ( o , null ) ;...
Execute a function .
141,341
public static EmbeddedJettyBuilder . ServletContextHandlerBuilder addWicketHandler ( EmbeddedJettyBuilder embeddedJettyBuilder , String contextPath , EventListener springContextloader , Class < ? extends WebApplication > wicketApplication , boolean development ) { EmbeddedJettyBuilder . ServletContextHandlerBuilder wic...
Adds wicket handler at root context .
141,342
public boolean add ( final OIdentifiable e ) { if ( e . getIdentity ( ) . isNew ( ) ) { final ORecord < ? > record = e . getRecord ( ) ; if ( newItems == null ) newItems = new IdentityHashMap < ORecord < ? > , Object > ( ) ; else if ( newItems . containsKey ( record ) ) return false ; newItems . put ( record , NEWMAP_V...
Adds the item in the underlying List preserving the order of the collection .
141,343
public int indexOf ( final OIdentifiable iElement ) { if ( delegate . isEmpty ( ) ) return - 1 ; final boolean prevConvert = delegate . isAutoConvertToRecord ( ) ; if ( prevConvert ) delegate . setAutoConvertToRecord ( false ) ; final int pos = Collections . binarySearch ( delegate , iElement ) ; if ( prevConvert ) del...
Returns the position of the element in the set . Execute a binary search since the elements are always ordered .
141,344
public ORDER compare ( OQueryOperator other ) { final Class < ? > thisClass = this . getClass ( ) ; final Class < ? > otherClass = other . getClass ( ) ; int thisPosition = - 1 ; int otherPosition = - 1 ; for ( int i = 0 ; i < DEFAULT_OPERATORS_ORDER . length ; i ++ ) { final Class < ? > clazz = DEFAULT_OPERATORS_ORDER...
Check priority of this operator compare to given operator .
141,345
public Object execute ( final Map < Object , Object > iArgs ) { if ( attribute == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; final ODatabaseRecord database = getDatabase ( ) ; database . checkSecurity ( ODatabaseSecurityResources . DATABASE , ORole ...
Execute the ALTER DATABASE .
141,346
public boolean open ( ) throws IOException { lock . acquireExclusiveLock ( ) ; try { super . open ( ) ; recoverTransactions ( ) ; return true ; } finally { lock . releaseExclusiveLock ( ) ; } }
Opens the file segment and recovers pending transactions if any
141,347
public void addLog ( final byte iOperation , final int iTxId , final int iClusterId , final long iClusterOffset , final byte iRecordType , final int iRecordVersion , final byte [ ] iRecordContent , int dataSegmentId ) throws IOException { final int contentSize = iRecordContent != null ? iRecordContent . length : 0 ; fi...
Appends a log entry
141,348
private Set < Integer > scanForTransactionsToRecover ( ) throws IOException { final Set < Integer > txToRecover = new HashSet < Integer > ( ) ; final Set < Integer > txToNotRecover = new HashSet < Integer > ( ) ; for ( long offset = 0 ; eof ( offset ) ; offset = nextEntry ( offset ) ) { final byte status = file . readB...
Scans the segment and returns the set of transactions ids to recover .
141,349
private int recoverTransaction ( final int iTxId ) throws IOException { int recordsRecovered = 0 ; final ORecordId rid = new ORecordId ( ) ; final List < Long > txRecordPositions = new ArrayList < Long > ( ) ; for ( long beginEntry = 0 ; eof ( beginEntry ) ; beginEntry = nextEntry ( beginEntry ) ) { long offset = begin...
Recover a transaction .
141,350
public static String pingJdbcEndpoint ( MuleContext muleContext , String muleJdbcDataSourceName , String tableName ) { DataSource ds = JdbcUtil . lookupDataSource ( muleContext , muleJdbcDataSourceName ) ; Connection c = null ; Statement s = null ; ResultSet rs = null ; try { c = ds . getConnection ( ) ; s = c . create...
Verify access to a JDBC endpoint by verifying that a specified table is accessible .
141,351
public static String pingJmsEndpoint ( MuleContext muleContext , String queueName ) { return pingJmsEndpoint ( muleContext , DEFAULT_MULE_JMS_CONNECTOR , queueName ) ; }
Verify access to a JMS endpoint by browsing a specified queue for messages .
141,352
@ SuppressWarnings ( "rawtypes" ) private static boolean isQueueEmpty ( MuleContext muleContext , String muleJmsConnectorName , String queueName ) throws JMSException { JmsConnector muleCon = ( JmsConnector ) MuleUtil . getSpringBean ( muleContext , muleJmsConnectorName ) ; Session s = null ; QueueBrowser b = null ; tr...
Browse a queue for messages
141,353
public T select ( Object item ) { if ( item == null ) { return null ; } if ( itemClass . isInstance ( item ) ) { return itemClass . cast ( item ) ; } logger . debug ( "item [{}] is not assignable to class [{}], returning null" , item , itemClass ) ; return null ; }
If the item is null return null . If the item is instance of the constructor parameter itemClass return the type cast result otherwise return null .
141,354
public BeanQuery < T > orderBy ( String orderByProperty , Comparator propertyValueComparator ) { this . comparator = new DelegatedSortOrderableComparator ( new PropertyComparator ( orderByProperty , propertyValueComparator ) ) ; return this ; }
Specify the property of the beans to be compared by the propertyValueComparator when sorting the result . If there is not a accessible public read method of the property the value of the property passed to the propertyValueComparator will be null .
141,355
public BeanQuery < T > orderBy ( Comparator ... beanComparator ) { this . comparator = new DelegatedSortOrderableComparator ( ComparatorUtils . chainedComparator ( beanComparator ) ) ; return this ; }
Using an array of Comparators applied in sequence until one returns not equal or the array is exhausted .
141,356
public T executeFrom ( Object bean ) { List < T > executeFromCollectionResult = executeFrom ( Collections . singleton ( bean ) ) ; if ( CollectionUtils . isEmpty ( executeFromCollectionResult ) ) { return null ; } else { return executeFromCollectionResult . get ( 0 ) ; } }
Execute from a bean to check does it match the filtering condition and convert it .
141,357
public List < T > execute ( ) { if ( CollectionUtils . isEmpty ( from ) ) { logger . info ( "Querying from an empty collection, returning empty list." ) ; return Collections . emptyList ( ) ; } List copied = new ArrayList ( this . from ) ; logger . info ( "Start apply predicate [{}] to collection with [{}] items." , pr...
Execute this Query . If query from a null or empty collection an empty list will be returned .
141,358
public static BeanQuery < Map < String , Object > > select ( KeyValueMapSelector ... selectors ) { return new BeanQuery < Map < String , Object > > ( new CompositeSelector ( selectors ) ) ; }
Create a BeanQuery instance with multiple Selectors .
141,359
public void write ( final Writer writer ) throws ConfigurationException , IOException { Preconditions . checkNotNull ( writer ) ; @ SuppressWarnings ( "unchecked" ) final HashMap < String , Object > settings = ( HashMap < String , Object > ) fromNode ( this . getModel ( ) . getInMemoryRepresentation ( ) ) ; this . mapp...
Writes the configuration .
141,360
private ImmutableNode toNode ( final Builder builder , final Object obj ) { assert ! ( obj instanceof List ) ; if ( obj instanceof Map ) { return mapToNode ( builder , ( Map < String , Object > ) obj ) ; } else { return valueToNode ( builder , obj ) ; } }
Creates a node for the specified object .
141,361
private ImmutableNode mapToNode ( final Builder builder , final Map < String , Object > map ) { for ( final Map . Entry < String , Object > entry : map . entrySet ( ) ) { final String key = entry . getKey ( ) ; final Object value = entry . getValue ( ) ; if ( value instanceof List ) { for ( final Object item : ( List )...
Creates a node for the specified map .
141,362
private void addChildNode ( final Builder builder , final String name , final Object value ) { assert ! ( value instanceof List ) ; final Builder childBuilder = new Builder ( ) ; childBuilder . name ( name ) ; final ImmutableNode childNode = toNode ( childBuilder , value ) ; builder . addChild ( childNode ) ; }
Adds a child node to the specified builder .
141,363
private ImmutableNode valueToNode ( final Builder builder , final Object value ) { return builder . value ( value ) . create ( ) ; }
Creates a node for the specified value .
141,364
private Object fromNode ( final ImmutableNode node ) { if ( ! node . getChildren ( ) . isEmpty ( ) ) { final Map < String , List < ImmutableNode > > children = getChildrenWithName ( node ) ; final HashMap < String , Object > map = new HashMap < > ( ) ; for ( final Map . Entry < String , List < ImmutableNode > > entry :...
Gets a serialization object from a node .
141,365
public ClassSelector except ( String ... propertyNames ) { if ( ArrayUtils . isEmpty ( propertyNames ) ) { return this ; } boolean updated = false ; for ( String propertyToRemove : propertyNames ) { if ( removePropertySelector ( propertyToRemove ) ) { updated = true ; } } if ( updated ) { compositeSelector = new Compos...
Exclude properties from the result map .
141,366
public ClassSelector add ( String ... propertyNames ) { if ( ArrayUtils . isNotEmpty ( propertyNames ) ) { for ( String propertyNameToAdd : propertyNames ) { addPropertySelector ( propertyNameToAdd ) ; } } return this ; }
Include properties in the result map .
141,367
public ViewSelectionAttributeAssert attribute ( String attributeName ) { isNotEmpty ( ) ; ViewSelectionAttribute attributeValues = new ViewSelectionAttribute ( actual , attributeName ) ; return new ViewSelectionAttributeAssert ( attributeValues ) ; }
Creates an object for making assertions about an attribute set extracted from each view in the selection . This always fails for an empty selection .
141,368
private static Message generateHeader ( HeaderValues param ) { HeaderFields header = new HeaderFields ( ) ; setValues ( header , param ) ; Message headerMsg = header . unwrap ( ) ; for ( String comment : param . comments ) { headerMsg . addComment ( comment ) ; } return headerMsg ; }
This more general generate method is private along with the HeaderValues object until we decide what the public API should be .
141,369
public ViewSelection selectViews ( View view ) { ViewSelection result = new ViewSelection ( ) ; for ( List < Selector > selectorParts : selectorGroups ) { result . addAll ( selectViewsForGroup ( selectorParts , view ) ) ; } return result ; }
Applies this selector to the given view selecting all descendants of the view that match this selector .
141,370
public int compareTo ( final Problem o ) { final int ix = this . severity . ordinal ( ) ; final int oid = o . severity . ordinal ( ) ; return ix - oid ; }
Compare such that most severe Problems will appear last least first .
141,371
public static String fixValue ( String value ) { if ( value != null && ! value . equals ( "" ) ) { final String [ ] words = value . toLowerCase ( ) . split ( "_" ) ; value = "" ; for ( final String word : words ) { if ( word . length ( ) > 1 ) { value += word . substring ( 0 , 1 ) . toUpperCase ( ) + word . substring (...
replace under score with space replace \ n char with platform indepent line . separator
141,372
public static String removeLast ( String original , String string ) { int lastIndexOf = original . lastIndexOf ( string ) ; if ( lastIndexOf == - 1 ) { return original ; } return original . substring ( 0 , lastIndexOf ) ; }
This method create nre properties from the origianl one and remove any key with the password then call toString method on this prperties .
141,373
public static String getFirstLine ( final String message ) { if ( isEmpty ( message ) ) { return message ; } if ( message . contains ( "\n" ) ) { return message . split ( "\n" ) [ 0 ] ; } return message ; }
Gets the first line .
141,374
public static void copyToClipboard ( String text ) { final StringSelection stringSelection = new StringSelection ( text ) ; final Clipboard clipboard = Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) ; clipboard . setContents ( stringSelection , stringSelection ) ; }
Copy to clipboard .
141,375
public String toQueryString ( ) { final StringBuffer buf = new StringBuffer ( ) ; final Object value1 = this . values . get ( 0 ) ; buf . append ( this . column . getName ( ) ) ; switch ( this . type ) { case STARTS_WIDTH : buf . append ( " like '" + value1 + "%'" ) ; break ; case CONTAINS : buf . append ( " like '%" +...
To query string .
141,376
public static String getNaturalAnalogueSequence ( PolymerNotation polymer ) throws HELM2HandledException , PeptideUtilsException , ChemistryException { checkPeptidePolymer ( polymer ) ; return FastaFormat . generateFastaFromPeptide ( MethodsMonomerUtils . getListOfHandledMonomers ( polymer . getListMonomers ( ) ) ) ; }
method to produce for a peptide PolymerNotation the natural analogue sequence
141,377
public static String getSequence ( PolymerNotation polymer ) throws HELM2HandledException , PeptideUtilsException , ChemistryException { checkPeptidePolymer ( polymer ) ; StringBuilder sb = new StringBuilder ( ) ; List < Monomer > monomers = MethodsMonomerUtils . getListOfHandledMonomers ( polymer . getListMonomers ( )...
method to produce for a peptide PolymerNotation the sequence
141,378
private static void processOtherMappings ( ) { codeToJavaMapping . clear ( ) ; codeToJKTypeMapping . clear ( ) ; shortListOfJKTypes . clear ( ) ; Set < Class < ? > > keySet = javaToCodeMapping . keySet ( ) ; for ( Class < ? > clas : keySet ) { List < Integer > codes = javaToCodeMapping . get ( clas ) ; for ( Integer co...
This method is used to avoid reconigure the mapping in the otherside again .
141,379
protected void loadDefaultConfigurations ( ) { if ( JK . getURL ( DEFAULT_LABLES_FILE_NAME ) != null ) { logger . debug ( "Load default lables from : " + DEFAULT_LABLES_FILE_NAME ) ; addLables ( JKIOUtil . readPropertiesFile ( DEFAULT_LABLES_FILE_NAME ) ) ; } }
Load default configurations .
141,380
public static < T > T cloneBean ( final Object bean ) { try { return ( T ) BeanUtils . cloneBean ( bean ) ; } catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e ) { throw new RuntimeException ( e ) ; } }
Clone bean .
141,381
public static Class < ? > getClass ( final String beanClassName ) { try { return Class . forName ( beanClassName ) ; } catch ( final ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
Gets the class .
141,382
public static < T > T getPropertyValue ( final Object instance , final String fieldName ) { try { return ( T ) PropertyUtils . getProperty ( instance , fieldName ) ; } catch ( final Exception e ) { throw new RuntimeException ( e ) ; } }
Gets the property value .
141,383
public static boolean isBoolean ( final Class type ) { if ( Boolean . class . isAssignableFrom ( type ) ) { return true ; } return type . getName ( ) . equals ( "boolean" ) ; }
Checks if is boolean .
141,384
public static void setPeopertyValue ( final Object target , final String fieldName , Object value ) { JK . logger . trace ( "setPeopertyValue On class({}) on field ({}) with value ({})" , target , fieldName , value ) ; try { if ( value != null ) { Field field = getFieldByName ( target . getClass ( ) , fieldName ) ; if ...
Sets the peoperty value .
141,385
public static void addItemToList ( final Object target , final String fieldName , final Object value ) { try { List list = ( List ) getFieldValue ( target , fieldName ) ; list . add ( value ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Adds the item to list .
141,386
public static Class < ? > toClass ( final String name ) { try { return Class . forName ( name ) ; } catch ( final ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
To class .
141,387
public static Class < ? > [ ] toClassesFromObjects ( final Object [ ] params ) { final Class < ? > [ ] classes = new Class < ? > [ params . length ] ; int i = 0 ; for ( final Object object : params ) { if ( object != null ) { classes [ i ++ ] = object . getClass ( ) ; } else { classes [ i ++ ] = Object . class ; } } re...
To classes from objects .
141,388
public static boolean isMethodDirectlyExists ( Object object , String methodName , Class < ? > ... params ) { try { Method method = object . getClass ( ) . getDeclaredMethod ( methodName , params ) ; return true ; } catch ( NoSuchMethodException e ) { return false ; } catch ( SecurityException e ) { throw new RuntimeEx...
Checks if is method directly exists .
141,389
public static Object toObject ( final String xml ) { final ByteArrayInputStream out = new ByteArrayInputStream ( xml . getBytes ( ) ) ; final XMLDecoder encoder = new XMLDecoder ( out ) ; final Object object = encoder . readObject ( ) ; encoder . close ( ) ; return object ; }
To object .
141,390
public static < T > Class < ? extends T > getGenericParamter ( String handler ) { ParameterizedType parameterizedType = ( ParameterizedType ) JKObjectUtil . getClass ( handler ) . getGenericInterfaces ( ) [ 0 ] ; Class < ? extends T > clas = ( Class < ? extends T > ) ( parameterizedType . getActualTypeArguments ( ) [ 0...
Gets the generic paramter .
141,391
public static boolean isClassAvilableInClassPath ( String string ) { try { Class . forName ( string ) ; return true ; } catch ( ClassNotFoundException e ) { return false ; } }
Checks if is class avilable in class path .
141,392
public static < T > String getInstanceVariables ( Class < T > clas ) { StringBuffer fieldsString = new StringBuffer ( ) ; Field [ ] fields = clas . getDeclaredFields ( ) ; int i = 0 ; for ( Field field : fields ) { if ( i ++ > 0 ) { fieldsString . append ( JK . CSV_SEPARATOR ) ; } fieldsString . append ( field . getNam...
Gets the instance variables .
141,393
public static String toJson ( Object obj ) { ObjectMapper mapper = new ObjectMapper ( ) ; try { return mapper . writeValueAsString ( obj ) ; } catch ( IOException e ) { JK . throww ( e ) ; return null ; } }
To json .
141,394
public static < T > Object jsonToObject ( String json , Class < T > clas ) { ObjectMapper mapper = new ObjectMapper ( ) ; try { return mapper . readValue ( json , clas ) ; } catch ( IOException e ) { JK . throww ( e ) ; return null ; } }
Json to object .
141,395
public static String getFieldNameByType ( Class < ? > classType , Class < ? > fieldType ) { Field [ ] declaredFields = classType . getDeclaredFields ( ) ; for ( Field field : declaredFields ) { if ( field . getType ( ) . isAssignableFrom ( fieldType ) ) { return field . getName ( ) ; } } if ( classType . getSuperclass ...
Gets the field name by type .
141,396
public static boolean isFieldExists ( Class < ? > clas , String fieldName ) { Field [ ] fields = clas . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( field . getName ( ) . equals ( fieldName ) ) { return true ; } } if ( clas . getSuperclass ( ) != null ) { return isFieldExists ( clas . getSuperclass ( ) ,...
Checks if is field exists .
141,397
public static List < String > getAllClassesInPackage ( String packageName ) { List < String > classesNames = new Vector < > ( ) ; final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider ( false ) ; provider . addIncludeFilter ( new RegexPatternTypeFilter ( Pattern . ...
Gets the all classes in package .
141,398
public static List < Field > getAllFields ( Class < ? > clas ) { JK . fixMe ( "add caching.." ) ; List < Field > list = new Vector < > ( ) ; if ( clas . getSuperclass ( ) != null ) { list . addAll ( getAllFields ( clas . getSuperclass ( ) ) ) ; } Field [ ] fields = clas . getDeclaredFields ( ) ; for ( Field field : fie...
Gets the all fields .
141,399
public static < T > T createInstanceForGenericClass ( Object parent ) { try { Object instance = getGenericClassFromParent ( parent ) . newInstance ( ) ; return ( T ) instance ; } catch ( InstantiationException | IllegalAccessException e ) { JK . throww ( e ) ; } return null ; }
Creates the instance for generic class .