signature stringlengths 43 39.1k | implementation stringlengths 0 450k |
|---|---|
public class CleverTapAPI { /** * Event */
private void scheduleQueueFlush ( final Context context ) { } } | if ( commsRunnable == null ) commsRunnable = new Runnable ( ) { @ Override public void run ( ) { flushQueueAsync ( context ) ; } } ; // Cancel any outstanding send runnables , and issue a new delayed one
getHandlerUsingMainLooper ( ) . removeCallbacks ( commsRunnable ) ; getHandlerUsingMainLooper ( ) . postDelayed ( commsRunnable , Constants . PUSH_DELAY_MS ) ; getConfigLogger ( ) . verbose ( getAccountId ( ) , "Scheduling delayed queue flush on main event loop" ) ; |
public class DnsAddressResolverGroup { /** * Creates a new { @ link AddressResolver } . Override this method to create an alternative { @ link AddressResolver }
* implementation or override the default configuration . */
protected AddressResolver < InetSocketAddress > newAddressResolver ( EventLoop eventLoop , NameResolver < InetAddress > resolver ) throws Exception { } } | return new InetSocketAddressResolver ( eventLoop , resolver ) ; |
public class TransactionScope { /** * Returns the isolation level of the active transaction , or null if there
* is no active transaction . */
public IsolationLevel getIsolationLevel ( ) { } } | mLock . lock ( ) ; try { return ( mClosed || mActive == null ) ? null : mActive . getIsolationLevel ( ) ; } finally { mLock . unlock ( ) ; } |
public class CronTabList { /** * Returns true if the given calendar matches */
public synchronized boolean check ( Calendar cal ) { } } | for ( CronTab tab : tabs ) { if ( tab . check ( cal ) ) return true ; } return false ; |
public class CcgParse { /** * Gets all of the words spanned by this node of the parse tree ,
* in sentence order .
* @ return */
public List < String > getSpannedWords ( ) { } } | if ( isTerminal ( ) ) { return words ; } else { List < String > words = Lists . newArrayList ( ) ; words . addAll ( left . getSpannedWords ( ) ) ; words . addAll ( right . getSpannedWords ( ) ) ; return words ; } |
public class FileLogSet { /** * Create a new unique file name . If the source file is specified , the new
* file should be created by renaming the source file as the unique file .
* @ param srcFile the file to rename , or null to create a new file
* @ param show error message if showError is true
* @ return the newly created file , or null if the could not be created
* @ throws IOException if an unexpected I / O error occurs */
private File createNewUniqueFile ( File srcFile , boolean showError ) throws IOException { } } | String dateString = getDateString ( ) ; int index = findFileIndexAndUpdateCounter ( dateString ) ; String destFileName ; File destFile ; do { int counter = lastCounter ++ ; destFileName = fileName + dateString + '.' + counter + fileExtension ; destFile = new File ( directory , destFileName ) ; boolean success ; if ( srcFile == null ) { success = destFile . createNewFile ( ) ; } else { // We don ' t want to rename over an existing file , so try to
// avoid doing so with a racy exists ( ) check .
if ( ! destFile . exists ( ) ) { success = srcFile . renameTo ( destFile ) ; } else { success = false ; } } if ( success ) { // Add the file to our list , which will cause old files to be
// deleted if we ' ve reached the max .
addFile ( index , destFileName ) ; return destFile ; } } while ( destFile . isFile ( ) ) ; if ( srcFile != null && copyFileTo ( srcFile , destFile ) ) { addFile ( index , destFileName ) ; return LoggingFileUtils . deleteFile ( srcFile , showError ) ? destFile : null ; } // Unsafe to use FFDC or ras : log to raw stderr
if ( showError ) { String msg = Tr . formatMessage ( TraceSpecification . getTc ( ) , "UNABLE_TO_CREATE_RESOURCE_NOEX" , destFile ) ; BaseTraceService . rawSystemErr . println ( msg ) ; } return null ; |
public class PlainChangesLogImpl { /** * Search for an item state of item with given id and filter parameters .
* @ param id
* - item id
* @ param states
* - filter only the given list states ( ORed ) , or all if it ' s null
* @ param isPersisted
* - filter only persisted / not persisted , or all if it ' s null
* @ return - filtered { @ link ItemState }
* @ throws IllegalPathException */
public ItemState findItemState ( String id , Boolean isPersisted , int ... states ) throws IllegalPathException { } } | List < ItemState > allStates = getAllStates ( ) ; // search from the end for state
for ( int i = allStates . size ( ) - 1 ; i >= 0 ; i -- ) { ItemState istate = allStates . get ( i ) ; boolean byState = false ; if ( states != null ) { for ( int state : states ) { if ( istate . getState ( ) == state ) { byState = true ; break ; } } } else { byState = true ; } if ( byState && ( isPersisted != null ? istate . isPersisted ( ) == isPersisted : true ) && istate . getData ( ) . getIdentifier ( ) . equals ( id ) ) { return istate ; } } return null ; |
public class Marc { /** * Transform W3C document of the record in the ISO 2709 input stream by an XSL stylesheet .
* @ param factory the transformer factory
* @ param stylesheetUrl the URL of the stylesheet
* @ param result the result of the transformation
* @ throws IOException if transformation fails */
public void transform ( TransformerFactory factory , URL stylesheetUrl , Result result ) throws IOException { } } | try ( InputStream xslInputStream = stylesheetUrl . openStream ( ) ) { factory . newTemplates ( new StreamSource ( xslInputStream ) ) . newTransformer ( ) . transform ( new DOMSource ( document ( ) ) , result ) ; } catch ( TransformerException e ) { throw new IOException ( e ) ; } finally { if ( builder . getInputStream ( ) != null ) { // essential
builder . getInputStream ( ) . close ( ) ; } } |
public class VecUtils { /** * Create a new { @ link Vec } of numeric values from an existing { @ link Vec } .
* This method accepts all { @ link Vec } types as input . The original Vec is not mutated .
* If src is a categorical { @ link Vec } , a copy is returned .
* If src is a string { @ link Vec } , all values that can be are parsed into reals or integers , and all
* others become NA . See stringToNumeric for parsing details .
* If src is a numeric { @ link Vec } , a copy is made .
* If src is a time { @ link Vec } , the milliseconds since the epoch are used to populate the new Vec .
* If src is a UUID { @ link Vec } , the existing numeric storage is used to populate the new Vec .
* Throws H2OIllegalArgumentException ( ) if the resulting domain exceeds
* Categorical . MAX _ CATEGORICAL _ COUNT .
* @ param src A { @ link Vec } whose values will be used as the basis for a new numeric { @ link Vec }
* @ return the resulting numeric { @ link Vec } */
public static Vec toNumericVec ( Vec src ) { } } | switch ( src . get_type ( ) ) { case Vec . T_CAT : return categoricalToInt ( src ) ; case Vec . T_STR : return stringToNumeric ( src ) ; case Vec . T_NUM : case Vec . T_TIME : case Vec . T_UUID : return src . makeCopy ( null , Vec . T_NUM ) ; default : throw new H2OIllegalArgumentException ( "Unrecognized column type " + src . get_type_str ( ) + " given to toNumericVec()" ) ; } |
public class CoreOptions { /** * Creates a { @ link org . ops4j . pax . exam . options . MavenPluginGeneratedConfigOption } .
* @ param url of configuration to be used
* @ return Args option with file written from paxexam plugin */
public static MavenPluginGeneratedConfigOption mavenConfiguration ( String url ) { } } | validateNotEmpty ( url , "specified configuration url must not be empty " ) ; try { return mavenConfiguration ( new URL ( url ) ) ; } catch ( MalformedURLException mE ) { throw new IllegalArgumentException ( "url " + url + " is not a valid url" , mE ) ; } |
public class AbstractQueuedSynchronizer { /** * Acquires in exclusive uninterruptible mode for thread already in
* queue . Used by condition wait methods as well as acquire .
* @ param node the node
* @ param arg the acquire argument
* @ return { @ code true } if interrupted while waiting */
final boolean acquireQueued ( final Node node , int arg ) { } } | try { boolean interrupted = false ; for ( ; ; ) { final Node p = node . predecessor ( ) ; if ( p == head && tryAcquire ( arg ) ) { setHead ( node ) ; p . next = null ; // help GC
return interrupted ; } if ( shouldParkAfterFailedAcquire ( p , node ) && parkAndCheckInterrupt ( ) ) interrupted = true ; } } catch ( Throwable t ) { cancelAcquire ( node ) ; throw t ; } |
public class ServerNetwork { /** * Returns the socket pool as a load - balancer . */
public final ClientSocketFactory getLoadBalanceSocketPool ( ) { } } | ClientSocketFactory factory = getLoadBalanceSocketFactory ( ) ; if ( factory == null ) return null ; if ( _serverBartender . getState ( ) . isDisableSoft ( ) ) { factory . enableSessionOnly ( ) ; } else if ( _serverBartender . getState ( ) . isDisabled ( ) ) { // server / 269g
factory . disable ( ) ; } else { factory . enable ( ) ; } return factory ; |
public class SpaceAPI { /** * Returns a list of the members that have been removed from the space .
* @ param spaceId
* The id of the space
* @ return The active members of the space */
public List < SpaceMember > getEndedMembers ( int spaceId ) { } } | return getResourceFactory ( ) . getApiResource ( "/space/" + spaceId + "/member/ended/" ) . get ( new GenericType < List < SpaceMember > > ( ) { } ) ; |
public class SingleDbJDBCConnection { /** * { @ inheritDoc } */
@ Override protected int deleteReference ( String propertyCid ) throws SQLException { } } | if ( deleteReference == null ) { deleteReference = dbConnection . prepareStatement ( DELETE_REF ) ; } else { deleteReference . clearParameters ( ) ; } deleteReference . setString ( 1 , propertyCid ) ; return deleteReference . executeUpdate ( ) ; |
public class MutableBigInteger { /** * Subtracts the smaller of this and b from the larger and places the
* result into this MutableBigInteger . */
int subtract ( MutableBigInteger b ) { } } | MutableBigInteger a = this ; int [ ] result = value ; int sign = a . compare ( b ) ; if ( sign == 0 ) { reset ( ) ; return 0 ; } if ( sign < 0 ) { MutableBigInteger tmp = a ; a = b ; b = tmp ; } int resultLen = a . intLen ; if ( result . length < resultLen ) result = new int [ resultLen ] ; long diff = 0 ; int x = a . intLen ; int y = b . intLen ; int rstart = result . length - 1 ; // Subtract common parts of both numbers
while ( y > 0 ) { x -- ; y -- ; diff = ( a . value [ x + a . offset ] & LONG_MASK ) - ( b . value [ y + b . offset ] & LONG_MASK ) - ( ( int ) - ( diff >> 32 ) ) ; result [ rstart -- ] = ( int ) diff ; } // Subtract remainder of longer number
while ( x > 0 ) { x -- ; diff = ( a . value [ x + a . offset ] & LONG_MASK ) - ( ( int ) - ( diff >> 32 ) ) ; result [ rstart -- ] = ( int ) diff ; } value = result ; intLen = resultLen ; offset = value . length - resultLen ; normalize ( ) ; return sign ; |
public class BackedHashMap { /** * get */
public Object get ( Object key , int version ) { } } | if ( com . ibm . websphere . ras . TraceComponent . isAnyTracingEnabled ( ) && LoggingUtil . SESSION_LOGGER_WAS . isLoggable ( Level . FINE ) ) { LoggingUtil . SESSION_LOGGER_WAS . logp ( Level . FINE , methodClassName , methodNames [ GET ] , key + " " + version ) ; } String id = ( String ) key ; Object obj = getSession ( id , version , true ) ; // update the last access time ?
return obj ; |
public class HadoopKeyStoreManager { /** * Stores the keystore onto HDFS . Overwrites existing one .
* @ param path
* @ param keyStorePassword
* @ throws KeyStoreException
* @ throws NoSuchAlgorithmException
* @ throws CertificateException
* @ throws IOException */
public void store ( Path path , String keyStorePassword ) throws KeyStoreException , NoSuchAlgorithmException , CertificateException , IOException { } } | OutputStream os = this . fs . create ( path , true ) ; this . keystore . store ( os , keyStorePassword . toCharArray ( ) ) ; if ( os != null ) { os . close ( ) ; } |
public class AfplibPackageImpl { /** * < ! - - begin - user - doc - - >
* < ! - - end - user - doc - - >
* @ generated */
public EEnum getPPORGObjType ( ) { } } | if ( pporgObjTypeEEnum == null ) { pporgObjTypeEEnum = ( EEnum ) EPackage . Registry . INSTANCE . getEPackage ( AfplibPackage . eNS_URI ) . getEClassifiers ( ) . get ( 122 ) ; } return pporgObjTypeEEnum ; |
public class IntMap { /** * Finds the highest key LE ` max ` ,
* for which there is a value . */
public int findHighestKey ( int max ) { } } | int highest = Integer . MIN_VALUE ; int index = index ( hash ( max ) ) ; final int maxTry = capacity ; for ( int i = 0 ; i < maxTry ; i ++ ) { if ( ! slotIsFree ( index ) ) { int k = keys [ index ] ; if ( k == max ) return max ; if ( max > k && k > highest ) highest = k ; } index = nextIndex ( index ) ; } return highest ; |
public class Util { /** * Get the singleton object reference .
* This method returns a reference to the object of the Util class . If the
* class has not been initialised with it ' s init method , this method print a
* message and abort the device server process
* @ return The Util object reference */
public static Util instance ( ) { } } | if ( _instance == null ) { System . err . println ( "Util is not initialised !!!" ) ; System . err . println ( "Exiting" ) ; System . exit ( - 1 ) ; } return _instance ; |
public class MessageCombiner { /** * Sends the combined message to the target vertex .
* @ param combinedMessage
* @ throws Exception */
public final void sendCombinedMessage ( Message combinedMessage ) { } } | outValue . f1 = Either . Right ( combinedMessage ) ; out . collect ( outValue ) ; |
public class QueryAtomContainer { /** * Grows the atom array by a given size .
* @ see # growArraySize */
private void growAtomArray ( ) { } } | growArraySize = ( atoms . length < growArraySize ) ? growArraySize : atoms . length ; IAtom [ ] newatoms = new IAtom [ atoms . length + growArraySize ] ; System . arraycopy ( atoms , 0 , newatoms , 0 , atoms . length ) ; atoms = newatoms ; |
public class Validator { /** * Validate Required . Allow space characters . */
protected void validateRequired ( String field , String errorKey , String errorMessage ) { } } | String value = controller . getPara ( field ) ; if ( value == null || "" . equals ( value ) ) { // 经测试 , form表单域无输入时值为 " " , 跳格键值为 " \ t " , 输入空格则为空格 " "
addError ( errorKey , errorMessage ) ; } |
public class SaneClientAuthentication { /** * Returns { @ code true } if the configuration contains an entry for the given resource . */
@ Override public boolean canAuthenticate ( String resource ) { } } | if ( resource == null ) { return false ; } ClientCredential credential = getCredentialForResource ( resource ) ; return credential != null ; |
public class CollectionUtils { /** * Null - safe method returning the given { @ link Set } or an empty { @ link Set } if null .
* @ param < T > Class type of the elements in the { @ link Set } .
* @ param set { @ link Set } to evaluate .
* @ return the given { @ link Set } or an empty { @ link Set } if null .
* @ see java . util . Collections # emptySet ( )
* @ see java . util . Set */
@ NullSafe public static < T > Set < T > nullSafeSet ( Set < T > set ) { } } | return set != null ? set : Collections . emptySet ( ) ; |
public class TriangulateMetricLinearDLT { /** * Given N observations of the same point from two views and a known motion between the
* two views , triangulate the point ' s position in camera ' b ' reference frame .
* Modification of [ 1 ] to be less generic and use calibrated cameras .
* @ param observations Observation in each view in normalized coordinates . Not modified .
* @ param worldToView Transformations from world to the view . Not modified .
* @ param found ( Output ) 3D point in homogenous coordinates . Modified . */
public GeometricResult triangulate ( List < Point2D_F64 > observations , List < Se3_F64 > worldToView , Point4D_F64 found ) { } } | if ( observations . size ( ) != worldToView . size ( ) ) throw new IllegalArgumentException ( "Number of observations must match the number of motions" ) ; final int N = worldToView . size ( ) ; A . reshape ( 2 * N , 4 , false ) ; int index = 0 ; for ( int i = 0 ; i < N ; i ++ ) { index = addView ( worldToView . get ( i ) , observations . get ( i ) , index ) ; } return finishSolving ( found ) ; |
public class SingletonInitialContext { /** * A convenience method that registers the supplied object with the supplied name .
* @ param name the JNDI name
* @ param obj the object to be registered */
public static void register ( String name , Object obj ) { } } | register ( name , obj , null , null , null , null ) ; |
public class TagHandler { /** * Utility method for fetching a required TagAttribute
* @ param localName
* name of the attribute
* @ return TagAttribute if found , otherwise error
* @ throws TagException
* if the attribute was not found */
protected final TagAttribute getRequiredAttribute ( String localName ) throws TagException { } } | TagAttribute attr = this . getAttribute ( localName ) ; if ( attr == null ) { throw new TagException ( this . tag , "Attribute '" + localName + "' is required" ) ; } return attr ; |
public class CentralAnalyzer { /** * Determines if this analyzer is enabled .
* @ return < code > true < / code > if the analyzer is enabled ; otherwise
* < code > false < / code > */
private boolean checkEnabled ( ) { } } | boolean retVal = false ; try { if ( getSettings ( ) . getBoolean ( Settings . KEYS . ANALYZER_CENTRAL_ENABLED ) ) { if ( ! getSettings ( ) . getBoolean ( Settings . KEYS . ANALYZER_NEXUS_ENABLED ) || NexusAnalyzer . DEFAULT_URL . equals ( getSettings ( ) . getString ( Settings . KEYS . ANALYZER_NEXUS_URL ) ) ) { LOGGER . debug ( "Enabling the Central analyzer" ) ; retVal = true ; } else { LOGGER . info ( "Nexus analyzer is enabled, disabling the Central Analyzer" ) ; } } else { LOGGER . info ( "Central analyzer disabled" ) ; } } catch ( InvalidSettingException ise ) { LOGGER . warn ( "Invalid setting. Disabling the Central analyzer" ) ; } return retVal ; |
public class ObjectRange { /** * throws IllegalArgumentException if to and from are incompatible , meaning they e . g . ( likely ) produce infinite sequences .
* Called at construction time , subclasses may override cautiously ( using only members to and from ) . */
protected void checkBoundaryCompatibility ( ) { } } | if ( from instanceof String && to instanceof String ) { // this test depends deeply on the String . next implementation
// 009 . next is 00 : , not 010
final String start = from . toString ( ) ; final String end = to . toString ( ) ; if ( start . length ( ) != end . length ( ) ) { throw new IllegalArgumentException ( "Incompatible Strings for Range: different length" ) ; } final int length = start . length ( ) ; int i ; for ( i = 0 ; i < length ; i ++ ) { if ( start . charAt ( i ) != end . charAt ( i ) ) { break ; } } // strings must be equal except for the last character
if ( i < length - 1 ) { throw new IllegalArgumentException ( "Incompatible Strings for Range: String#next() will not reach the expected value" ) ; } } |
public class XBasicForLoopExpressionImpl { /** * < ! - - begin - user - doc - - >
* < ! - - end - user - doc - - >
* @ generated */
public EList < XExpression > getInitExpressions ( ) { } } | if ( initExpressions == null ) { initExpressions = new EObjectContainmentEList < XExpression > ( XExpression . class , this , XbasePackage . XBASIC_FOR_LOOP_EXPRESSION__INIT_EXPRESSIONS ) ; } return initExpressions ; |
public class SequenceResource { /** * Returns the mimetype of the first resource in the given Iterable , or
* " application / octet - stream " if no resources are provided .
* @ param resources
* The resources from which the mimetype should be retrieved .
* @ return
* The mimetype of the first resource , or " application / octet - stream "
* if no resources were provided . */
private static String getMimeType ( Iterable < Resource > resources ) { } } | // If no resources , just assume application / octet - stream
Iterator < Resource > resourceIterator = resources . iterator ( ) ; if ( ! resourceIterator . hasNext ( ) ) return "application/octet-stream" ; // Return mimetype of first resource
return resourceIterator . next ( ) . getMimeType ( ) ; |
public class AuthenticationServiceImpl { /** * { @ inheritDoc } */
@ Override public Subject authenticate ( String jaasEntryName , AuthenticationData authenticationData , Subject subject ) throws AuthenticationException { } } | ReentrantLock currentLock = optionallyObtainLockedLock ( authenticationData ) ; try { // If basic auth login to a different realm , then create a basic auth subject
if ( isBasicAuthLogin ( authenticationData ) ) { return createBasicAuthSubject ( authenticationData , subject ) ; } else { Subject authenticatedSubject = findSubjectInAuthCache ( authenticationData , subject ) ; if ( authenticatedSubject == null ) { authenticatedSubject = performJAASLogin ( jaasEntryName , authenticationData , subject ) ; insertSubjectInAuthCache ( authenticationData , authenticatedSubject ) ; } return authenticatedSubject ; } } finally { releaseLock ( authenticationData , currentLock ) ; } |
public class GeoPackageCoreImpl { /** * { @ inheritDoc } */
@ Override public AttributesTable createAttributesTable ( String tableName , String idColumnName , List < AttributesColumn > additionalColumns , List < UserUniqueConstraint < AttributesColumn > > uniqueConstraints ) { } } | if ( idColumnName == null ) { idColumnName = "id" ; } List < AttributesColumn > columns = new ArrayList < AttributesColumn > ( ) ; columns . add ( AttributesColumn . createPrimaryKeyColumn ( 0 , idColumnName ) ) ; if ( additionalColumns != null ) { columns . addAll ( additionalColumns ) ; } return createAttributesTable ( tableName , columns , uniqueConstraints ) ; |
public class B2buaHelperImpl { /** * Issue 1151 : For Contact header if present only the user part and some
* parameters are to be used as defined in 4.1.3 The Contact Header Field
* @ param newRequest
* @ param contactHeaderSet
* @ param newSipServletRequest
* @ param contactHeader
* @ throws ParseException */
private void setContactHeaders ( final List < String > contactHeaderSet , final SipServletRequestImpl newSipServletRequest , ContactHeader contactHeader ) throws ParseException { } } | // we parse and add the contact headers defined in the map
Request newRequest = ( Request ) newSipServletRequest . getMessage ( ) ; for ( String contactHeaderValue : contactHeaderSet ) { newSipServletRequest . addHeaderInternal ( ContactHeader . NAME , contactHeaderValue , true ) ; } // we set up a list of contact headers to be added to the request
List < ContactHeader > newContactHeaders = new ArrayList < ContactHeader > ( ) ; ListIterator < ContactHeader > contactHeaders = newRequest . getHeaders ( ContactHeader . NAME ) ; while ( contactHeaders . hasNext ( ) ) { // we clone the default Mobicents Sip Servlets Contact Header
ContactHeader newContactHeader = ( ContactHeader ) contactHeader . clone ( ) ; ContactHeader newRequestContactHeader = contactHeaders . next ( ) ; final URI newURI = newRequestContactHeader . getAddress ( ) . getURI ( ) ; newContactHeader . getAddress ( ) . setDisplayName ( newRequestContactHeader . getAddress ( ) . getDisplayName ( ) ) ; // and reset its user part and params accoridng to 4.1.3 The Contact Header Field
if ( newURI instanceof SipURI ) { SipURI newSipURI = ( SipURI ) newURI ; SipURI newContactSipURI = ( SipURI ) newContactHeader . getAddress ( ) . getURI ( ) ; ( ( SipURI ) newContactHeader . getAddress ( ) . getURI ( ) ) . setUser ( newSipURI . getUser ( ) ) ; Iterator < String > uriParameters = newSipURI . getParameterNames ( ) ; while ( uriParameters . hasNext ( ) ) { String parameter = uriParameters . next ( ) ; if ( ! CONTACT_FORBIDDEN_PARAMETER . contains ( parameter ) ) { String value = newSipURI . getParameter ( parameter ) ; newContactSipURI . setParameter ( parameter , "" . equals ( value ) ? null : value ) ; } } } // reset the header params according to 4.1.3 The Contact Header Field
Iterator < String > headerParameters = newRequestContactHeader . getParameterNames ( ) ; while ( headerParameters . hasNext ( ) ) { String parameter = headerParameters . next ( ) ; String value = newRequestContactHeader . getParameter ( parameter ) ; newContactHeader . setParameter ( parameter , "" . equals ( value ) ? null : value ) ; } newContactHeaders . add ( newContactHeader ) ; } // we remove the previously added contact headers
newRequest . removeHeader ( ContactHeader . NAME ) ; // and set the new correct ones
for ( ContactHeader newContactHeader : newContactHeaders ) { newRequest . addHeader ( newContactHeader ) ; } |
public class Utils { /** * Reads an long value from the buffer starting at the given index relative to the current
* position ( ) of the buffer , without mutating the buffer in any way ( so it ' s thread safe ) . */
public static long getLong ( ByteBuffer buf , int index ) { } } | return buf . order ( ) == BIG_ENDIAN ? getLongB ( buf , index ) : getLongL ( buf , index ) ; |
public class AbstractMkTree { /** * Performs a batch k - nearest neighbor query for a list of query objects .
* @ param node the node representing the subtree on which the query should be
* performed
* @ param ids the ids of the query objects
* @ param kmax Maximum k value
* @ deprecated Change to use by - object NN lookups instead . */
@ Deprecated protected final Map < DBID , KNNList > batchNN ( N node , DBIDs ids , int kmax ) { } } | Map < DBID , KNNList > res = new HashMap < > ( ids . size ( ) ) ; for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { DBID id = DBIDUtil . deref ( iter ) ; res . put ( id , knnq . getKNNForDBID ( id , kmax ) ) ; } return res ; |
public class VMath { /** * Returns a matrix which consists of this matrix and the specified columns .
* @ param m1 Input matrix
* @ param m2 the columns to be appended
* @ return the new matrix with the appended columns */
public static double [ ] [ ] appendColumns ( final double [ ] [ ] m1 , final double [ ] [ ] m2 ) { } } | final int columndimension = getColumnDimensionality ( m1 ) ; final int ccolumndimension = getColumnDimensionality ( m2 ) ; assert m1 . length == m2 . length : "m.getRowDimension() != column.getRowDimension()" ; final int rcolumndimension = columndimension + ccolumndimension ; final double [ ] [ ] result = new double [ m1 . length ] [ rcolumndimension ] ; for ( int i = 0 ; i < rcolumndimension ; i ++ ) { // FIXME : optimize - excess copying !
if ( i < columndimension ) { setCol ( result , i , getCol ( m1 , i ) ) ; } else { setCol ( result , i , getCol ( m2 , i - columndimension ) ) ; } } return result ; |
public class NodeDetailsMarshaller { /** * Marshall the given parameter object . */
public void marshall ( NodeDetails nodeDetails , ProtocolMarshaller protocolMarshaller ) { } } | if ( nodeDetails == null ) { throw new SdkClientException ( "Invalid argument passed to marshall(...)" ) ; } try { protocolMarshaller . marshall ( nodeDetails . getNodeIndex ( ) , NODEINDEX_BINDING ) ; protocolMarshaller . marshall ( nodeDetails . getIsMainNode ( ) , ISMAINNODE_BINDING ) ; } catch ( Exception e ) { throw new SdkClientException ( "Unable to marshall request to JSON: " + e . getMessage ( ) , e ) ; } |
public class FileSystem { /** * Verifies a directory and checks to see if it ' s writeable or not if
* configured
* @ param dir The path to check on
* @ param need _ write Set to true if the path needs write access
* @ param create Set to true if the directory should be created if it does not
* exist
* @ throws IllegalArgumentException if the path is empty , if it ' s not there
* and told not to create it or if it needs write access and can ' t
* be written to */
public static void checkDirectory ( final String dir , final boolean need_write , final boolean create ) { } } | if ( dir . isEmpty ( ) ) throw new IllegalArgumentException ( "Directory path is empty" ) ; final File f = new File ( dir ) ; if ( ! f . exists ( ) && ! ( create && f . mkdirs ( ) ) ) { throw new IllegalArgumentException ( "No such directory [" + dir + "]" ) ; } else if ( ! f . isDirectory ( ) ) { throw new IllegalArgumentException ( "Not a directory [" + dir + "]" ) ; } else if ( need_write && ! f . canWrite ( ) ) { throw new IllegalArgumentException ( "Cannot write to directory [" + dir + "]" ) ; } |
public class CmsXmlEntityResolver { /** * Proves if there is at least one xsd or dtd file in the list of resources to publish . < p >
* @ param publishHistoryId the publish history id
* @ return true , if there is at least one xsd or dtd file in the list of resources to publish , otherwise false */
private boolean isSchemaDefinitionInPublishList ( CmsUUID publishHistoryId ) { } } | if ( m_cms == null ) { // CmsObject not available , assume there may be a schema definition in the publish history
return true ; } try { List < CmsPublishedResource > publishedResources = m_cms . readPublishedResources ( publishHistoryId ) ; for ( CmsPublishedResource cmsPublishedResource : publishedResources ) { String resourceRootPath = cmsPublishedResource . getRootPath ( ) ; String resourceRootPathLowerCase = resourceRootPath . toLowerCase ( ) ; if ( resourceRootPathLowerCase . endsWith ( ".xsd" ) || resourceRootPathLowerCase . endsWith ( ".dtd" ) || m_cacheTemporary . containsKey ( getCacheKey ( resourceRootPath , true ) ) ) { return true ; } } } catch ( CmsException e ) { // error reading published Resources .
LOG . warn ( e . getMessage ( ) , e ) ; } return false ; |
public class lbvserver_stats { /** * Use this API to fetch statistics of lbvserver _ stats resource of given name . */
public static lbvserver_stats get ( nitro_service service , String name ) throws Exception { } } | lbvserver_stats obj = new lbvserver_stats ( ) ; obj . set_name ( name ) ; lbvserver_stats response = ( lbvserver_stats ) obj . stat_resource ( service ) ; return response ; |
public class HtmlTextareaRendererBase { /** * Subclasses can override the writing of the " text " value of the textarea */
protected void renderTextAreaValue ( FacesContext facesContext , UIComponent uiComponent ) throws IOException { } } | ResponseWriter writer = facesContext . getResponseWriter ( ) ; Object addNewLineAtStart = uiComponent . getAttributes ( ) . get ( ADD_NEW_LINE_AT_START_ATTR ) ; if ( addNewLineAtStart != null ) { boolean addNewLineAtStartBoolean = false ; if ( addNewLineAtStart instanceof String ) { addNewLineAtStartBoolean = Boolean . valueOf ( ( String ) addNewLineAtStart ) ; } else if ( addNewLineAtStart instanceof Boolean ) { addNewLineAtStartBoolean = ( Boolean ) addNewLineAtStart ; } if ( addNewLineAtStartBoolean ) { writer . writeText ( "\n" , null ) ; } } String strValue = org . apache . myfaces . shared . renderkit . RendererUtils . getStringValue ( facesContext , uiComponent ) ; if ( strValue != null ) { writer . writeText ( strValue , org . apache . myfaces . shared . renderkit . JSFAttr . VALUE_ATTR ) ; } |
public class JsType { /** * Returns a Soy assertion expression that asserts that the given value has this type , or { @ link
* Optional # absent ( ) } if no assertion is necessary . */
public final Optional < Expression > getSoyTypeAssertion ( Expression value , String valueName , Generator codeGenerator ) { } } | Optional < Expression > typeAssertion = getTypeAssertion ( value , codeGenerator ) ; if ( ! typeAssertion . isPresent ( ) ) { return Optional . absent ( ) ; } return Optional . of ( SOY_ASSERTS_ASSERT_TYPE . call ( typeAssertion . get ( ) , stringLiteral ( valueName ) , value , stringLiteral ( typeExpr ( ) ) ) ) ; |
public class DomImplIE { /** * { @ inheritDoc } */
@ Override public Element createElementNS ( String ns , String tag , String id ) { } } | Element element ; if ( Dom . NS_HTML . equals ( ns ) ) { element = DOM . createElement ( tag ) ; } else { element = DOM . createElement ( ns + ":" + tag ) ; } if ( id != null ) { DOM . setElementAttribute ( element , "id" , id ) ; } return element ; |
public class AbstractElementTransformer { /** * Returns true if that is the case , false otherwise */
private boolean isReadObjectOrWriteObjectMethod ( Symbol symbol ) { } } | if ( symbol instanceof DynamicFunctionSymbol ) { DynamicFunctionSymbol dfs = ( DynamicFunctionSymbol ) symbol ; if ( dfs . getDisplayName ( ) . equals ( "readObject" ) ) { IType [ ] argTypes = dfs . getArgTypes ( ) ; return argTypes != null && argTypes . length == 1 && argTypes [ 0 ] . equals ( JavaTypes . getJreType ( java . io . ObjectInputStream . class ) ) && dfs . getReturnType ( ) . equals ( JavaTypes . pVOID ( ) ) ; } else if ( dfs . getDisplayName ( ) . equals ( "writeObject" ) ) { IType [ ] argTypes = dfs . getArgTypes ( ) ; return argTypes != null && argTypes . length == 1 && argTypes [ 0 ] . equals ( JavaTypes . getJreType ( java . io . ObjectOutputStream . class ) ) && dfs . getReturnType ( ) . equals ( JavaTypes . pVOID ( ) ) ; } else { return false ; } } else { return false ; } |
public class NotificationBoardCallback { /** * Called only once after this callback is set .
* @ param board */
public void onBoardSetup ( NotificationBoard board ) { } } | if ( DBG ) Log . v ( TAG , "onBoardSetup" ) ; LayoutInflater inflater = board . getInflater ( ) ; View footer = inflater . inflate ( R . layout . notification_board_footer , null , false ) ; board . addFooterView ( footer ) ; board . setFooterHeight ( 200 ) ; // board . setHeaderHeight ( 150 ) ;
board . setHeaderMargin ( 0 , 150 , 0 , 0 ) ; board . setHeaderDivider ( R . drawable . divider_horizontal_dark ) ; board . setFooterDivider ( R . drawable . divider_horizontal_dark ) ; board . setRowDivider ( R . drawable . divider_horizontal_dark ) ; board . setBoardPadding ( 80 , 0 , 80 , 0 ) ; board . setRowMargin ( 20 , 0 , 20 , 0 ) ; board . setClearView ( footer . findViewById ( R . id . clear ) ) ; board . addStateListener ( new NotificationBoard . SimpleStateListener ( ) { @ Override public void onBoardTranslationY ( NotificationBoard board , float y ) { final float t = board . getBoardTranslationY ( ) ; if ( t == 0.0f ) { board . showClearView ( false ) ; } else if ( t == - board . getBoardHeight ( ) ) { board . showClearView ( false ) ; } else if ( y == 0.0f ) { board . showClearView ( board . getNotificationCount ( ) > 0 ) ; } } @ Override public void onBoardEndOpen ( NotificationBoard board ) { board . showClearView ( board . getNotificationCount ( ) > 0 ) ; } @ Override public void onBoardStartClose ( NotificationBoard board ) { board . showClearView ( false ) ; } } ) ; |
public class EventListenerListHelper { /** * Adds < code > listener < / code > to the list of registered listeners . If
* listener is already registered this method will do nothing .
* @ param listener The event listener to be registered .
* @ return true if the listener was registered , false if { @ code listener } was null or it is
* already registered with this list helper .
* @ throws IllegalArgumentException if { @ code listener } is not assignable to the class of
* listener that this instance manages . */
public boolean add ( Object listener ) { } } | if ( listener == null ) { return false ; } checkListenerType ( listener ) ; synchronized ( this ) { if ( listeners == EMPTY_OBJECT_ARRAY ) { listeners = new Object [ ] { listener } ; } else { int listenersLength = listeners . length ; for ( int i = 0 ; i < listenersLength ; i ++ ) { if ( listeners [ i ] == listener ) { return false ; } } Object [ ] tmp = new Object [ listenersLength + 1 ] ; tmp [ listenersLength ] = listener ; System . arraycopy ( listeners , 0 , tmp , 0 , listenersLength ) ; listeners = tmp ; } } return true ; |
public class CmsCategoryTree { /** * Sets the given tree list enabled / disabled . < p >
* @ param list the list of tree items
* @ param enabled < code > true < / code > to enable
* @ param disabledReason the disable reason , will be displayed as check box title */
private void setListEnabled ( CmsList < ? extends I_CmsListItem > list , boolean enabled , String disabledReason ) { } } | for ( Widget child : list ) { CmsTreeItem treeItem = ( CmsTreeItem ) child ; if ( enabled ) { treeItem . getCheckBox ( ) . enable ( ) ; } else { treeItem . getCheckBox ( ) . disable ( disabledReason ) ; } setListEnabled ( treeItem . getChildren ( ) , enabled , disabledReason ) ; } |
public class LabelGetterFactory { /** * フィールドのラベル情報を取得するためのアクセッサを作成します 。
* @ param beanClass フィールドが定義されているクラス情報
* @ param fieldName フィールドの名称
* @ return ラベル情報のgetterが存在しない場合は空を返す 。
* @ throws IllegalArgumentException { @ literal beanClass = = null or fieldName = = null }
* @ throws IllegalArgumentException { @ literal fieldName . isEmpty ( ) = true } */
public Optional < LabelGetter > create ( final Class < ? > beanClass , final String fieldName ) { } } | ArgUtils . notNull ( beanClass , "beanClass" ) ; ArgUtils . notEmpty ( fieldName , "fieldName" ) ; // フィールド Map labelsの場合
Optional < LabelGetter > LabelGetter = createMapField ( beanClass , fieldName ) ; if ( LabelGetter . isPresent ( ) ) { return LabelGetter ; } // setter メソッドの場合
LabelGetter = createMethod ( beanClass , fieldName ) ; if ( LabelGetter . isPresent ( ) ) { return LabelGetter ; } // フィールド + labelの場合
LabelGetter = createField ( beanClass , fieldName ) ; if ( LabelGetter . isPresent ( ) ) { return LabelGetter ; } return Optional . empty ( ) ; |
public class PathMappingUtil { /** * Returns the logger name from the specified { @ code pathish } . */
public static String newLoggerName ( @ Nullable String pathish ) { } } | if ( pathish == null ) { return UNKNOWN_LOGGER_NAME ; } String normalized = pathish ; if ( "/" . equals ( normalized ) ) { return ROOT_LOGGER_NAME ; } if ( normalized . startsWith ( "/" ) ) { normalized = normalized . substring ( 1 ) ; // Strip the first slash .
} final int end ; if ( normalized . endsWith ( "/" ) ) { end = normalized . length ( ) - 1 ; } else { end = normalized . length ( ) ; } final StringBuilder buf = new StringBuilder ( end ) ; boolean start = true ; for ( int i = 0 ; i < end ; i ++ ) { final char ch = normalized . charAt ( i ) ; if ( ch != '/' ) { if ( start ) { start = false ; if ( Character . isJavaIdentifierStart ( ch ) ) { buf . append ( ch ) ; } else { buf . append ( '_' ) ; if ( Character . isJavaIdentifierPart ( ch ) ) { buf . append ( ch ) ; } } } else { if ( Character . isJavaIdentifierPart ( ch ) ) { buf . append ( ch ) ; } else { buf . append ( '_' ) ; } } } else { start = true ; buf . append ( '.' ) ; } } return buf . toString ( ) ; |
public class HieroSettings { /** * Saves the settings to a file .
* @ param file The file we ' re saving to
* @ throws IOException if the file could not be saved . */
public void save ( File file ) throws IOException { } } | PrintStream out = new PrintStream ( new FileOutputStream ( file ) ) ; out . println ( "font.size=" + fontSize ) ; out . println ( "font.bold=" + bold ) ; out . println ( "font.italic=" + italic ) ; out . println ( ) ; out . println ( "pad.top=" + paddingTop ) ; out . println ( "pad.right=" + paddingRight ) ; out . println ( "pad.bottom=" + paddingBottom ) ; out . println ( "pad.left=" + paddingLeft ) ; out . println ( "pad.advance.x=" + paddingAdvanceX ) ; out . println ( "pad.advance.y=" + paddingAdvanceY ) ; out . println ( ) ; out . println ( "glyph.page.width=" + glyphPageWidth ) ; out . println ( "glyph.page.height=" + glyphPageHeight ) ; out . println ( ) ; for ( Iterator iter = effects . iterator ( ) ; iter . hasNext ( ) ; ) { ConfigurableEffect effect = ( ConfigurableEffect ) iter . next ( ) ; out . println ( "effect.class=" + effect . getClass ( ) . getName ( ) ) ; for ( Iterator iter2 = effect . getValues ( ) . iterator ( ) ; iter2 . hasNext ( ) ; ) { Value value = ( Value ) iter2 . next ( ) ; out . println ( "effect." + value . getName ( ) + "=" + value . getString ( ) ) ; } out . println ( ) ; } out . close ( ) ; |
public class HttpServlet { /** * Dispatches client requests to the protected
* < code > service < / code > method . There ' s no need to
* override this method .
* @ param req the { @ link HttpServletRequest } object that
* contains the request the client made of
* the servlet
* @ param res the { @ link HttpServletResponse } object that
* contains the response the servlet returns
* to the client
* @ throws IOException if an input or output error occurs
* while the servlet is handling the
* HTTP request
* @ throws ServletException if the HTTP request cannot
* be handled or if either parameter is not
* an instance of its respective { @ link HttpServletRequest }
* or { @ link HttpServletResponse } counterparts .
* @ see javax . servlet . Servlet # service */
@ Override public void service ( ServletRequest req , ServletResponse res ) throws ServletException , IOException { } } | HttpServletRequest request ; HttpServletResponse response ; if ( ! ( req instanceof HttpServletRequest && res instanceof HttpServletResponse ) ) { throw new ServletException ( "non-HTTP request or response" ) ; } request = ( HttpServletRequest ) req ; response = ( HttpServletResponse ) res ; service ( request , response ) ; |
public class RestUriVariablesFactory { /** * Returns the uri variables needed for a resume text request
* @ param params
* @ return */
public Map < String , String > getUriVariablesForResumeTextParse ( ResumeTextParseParams params ) { } } | if ( params == null ) { params = ParamFactory . resumeTextParseParams ( ) ; } Map < String , String > uriVariables = params . getParameterMap ( ) ; String bhRestToken = bullhornApiRest . getBhRestToken ( ) ; uriVariables . put ( BH_REST_TOKEN , bhRestToken ) ; return uriVariables ; |
public class Transaction { /** * Returns false if this transaction has at least one output that is owned by the given wallet and unspent , true
* otherwise . */
public boolean isEveryOwnedOutputSpent ( TransactionBag transactionBag ) { } } | for ( TransactionOutput output : outputs ) { if ( output . isAvailableForSpending ( ) && output . isMineOrWatched ( transactionBag ) ) return false ; } return true ; |
public class LogUtils { /** * Dynamically sets the log4j log level for the given class to the specified level .
* @ param loggerName Name of the logger to set its log level . If blank , root logger will be used .
* @ param logLevel One of the supported log levels : TRACE , DEBUG , INFO , WARN , ERROR , FATAL ,
* OFF . { @ code null } value is considered as ' OFF ' . */
public static boolean setLog4jLevel ( String loggerName , String logLevel ) { } } | String logLevelUpper = ( logLevel == null ) ? "OFF" : logLevel . toUpperCase ( ) ; try { Package log4jPackage = Package . getPackage ( LOG4J_CLASSIC ) ; if ( log4jPackage == null ) { LOG . warn ( "Log4j is not in the classpath!" ) ; return false ; } Class < ? > clz = Class . forName ( LOG4J_CLASSIC_LOGGER ) ; // Obtain logger by the name
Object loggerObtained ; if ( ( loggerName == null ) || loggerName . trim ( ) . isEmpty ( ) || loggerName . trim ( ) . equals ( "ROOT" ) ) { // Use ROOT logger if given logger name is blank .
Method method = clz . getMethod ( "getRootLogger" ) ; loggerObtained = method . invoke ( null ) ; loggerName = "ROOT" ; } else { Method method = clz . getMethod ( "getLogger" , String . class ) ; loggerObtained = method . invoke ( null , loggerName ) ; } if ( loggerObtained == null ) { // I don ' t know if this case occurs
LOG . warn ( "No logger for the name: {}" , loggerName ) ; return false ; } Object logLevelObj = getFieldVaulue ( LOG4J_CLASSIC_LEVEL , logLevelUpper ) ; if ( logLevelObj == null ) { LOG . warn ( "No such log level: {}" , logLevelUpper ) ; return false ; } Class < ? > [ ] paramTypes = { logLevelObj . getClass ( ) } ; Object [ ] params = { logLevelObj } ; Method method = clz . getMethod ( "setLevel" , paramTypes ) ; method . invoke ( loggerObtained , params ) ; LOG . info ( "Log4j level set to {} for the logger '{}'" , logLevelUpper , loggerName ) ; return true ; } catch ( NoClassDefFoundError e ) { LOG . warn ( "Couldn't set log4j level to {} for the logger '{}'" , logLevelUpper , loggerName , e ) ; return false ; } catch ( Exception e ) { LOG . warn ( "Couldn't set log4j level to {} for the logger '{}'" , logLevelUpper , loggerName ) ; return false ; } |
public class JDBC4PreparedStatement { /** * Sets the designated parameter to the given java . sql . Date value using the default time zone of the virtual machine that is running the application . */
@ Override public void setDate ( int parameterIndex , Date x ) throws SQLException { } } | checkParameterBounds ( parameterIndex ) ; throw SQLError . noSupport ( ) ; |
public class CollapsibleList { /** * Returns the list object associated with the specified section . */
public JList getSectionList ( int index ) { } } | @ SuppressWarnings ( "unchecked" ) JList list = ( JList ) getComponent ( index * 2 + 1 ) ; return list ; |
public class JKObjectUtil { /** * Gets the field name by type .
* @ param classType the class type
* @ param fieldType the field type
* @ return the field name by type */
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 ( ) != null ) { return getFieldNameByType ( classType . getSuperclass ( ) , fieldType ) ; } return null ; |
public class NonBlockingBufferedInputStream { /** * See the general contract of the < code > skip < / code > method of
* < code > InputStream < / code > .
* @ exception IOException
* if the stream does not support seek , or if this input stream has
* been closed by invoking its { @ link # close ( ) } method , or an I / O
* error occurs . */
@ Override public long skip ( final long nBytesToSkip ) throws IOException { } } | _getBufIfOpen ( ) ; // Check for closed stream
if ( nBytesToSkip <= 0 ) return 0 ; long nAvail = ( long ) m_nCount - m_nPos ; if ( nAvail <= 0 ) { // If no mark position set then don ' t keep in buffer
if ( m_nMarkPos < 0 ) return _getInIfOpen ( ) . skip ( nBytesToSkip ) ; // Fill in buffer to save bytes for reset
_fill ( ) ; nAvail = ( long ) m_nCount - m_nPos ; if ( nAvail <= 0 ) return 0 ; } final long nSkipped = nAvail < nBytesToSkip ? nAvail : nBytesToSkip ; m_nPos += nSkipped ; return nSkipped ; |
public class JarWithFile { /** * Readable if the jar is readable and the path refers to a file . */
public boolean canRead ( String path ) { } } | try { ZipEntry entry = getZipEntry ( path ) ; return entry != null && ! entry . isDirectory ( ) ; } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; return false ; } |
public class Job { /** * Gets the youngest build # m that satisfies { @ code n & lt ; = m } .
* This is useful when you ' d like to fetch a build but the exact build might
* be already gone ( deleted , rotated , etc . )
* @ see LazyBuildMixIn # getNearestBuild */
public RunT getNearestBuild ( int n ) { } } | SortedMap < Integer , ? extends RunT > m = _getRuns ( ) . headMap ( n - 1 ) ; // the map should
// include n , so n - 1
if ( m . isEmpty ( ) ) return null ; return m . get ( m . lastKey ( ) ) ; |
public class Connectors { /** * Determine there is a projection with the given alias and projected ( internal ) node key
* @ param alias the alias
* @ param externalNodeKey the node key of the projected ( internal ) node
* @ return true if there is such a projection , or false otherwise */
public boolean hasExternalProjection ( String alias , String externalNodeKey ) { } } | return this . snapshot . get ( ) . hasExternalProjection ( alias , externalNodeKey ) ; |
public class MapUtils { /** * Creates a copy of the supplied map with its keys transformed by the supplied function , which
* must be one - to - one on the keys of the original map . If two keys are mapped to the same value by
* { @ code injection } , an { @ code IllegalArgumentException } is thrown . */
public static < K1 , K2 , V > ImmutableMap < K2 , V > copyWithKeysTransformedByInjection ( final Map < K1 , V > map , final Function < ? super K1 , K2 > injection ) { } } | final ImmutableMap . Builder < K2 , V > ret = ImmutableMap . builder ( ) ; for ( final Map . Entry < K1 , V > entry : map . entrySet ( ) ) { ret . put ( injection . apply ( entry . getKey ( ) ) , entry . getValue ( ) ) ; } return ret . build ( ) ; |
public class EventServicesImpl { /** * Returns the ActivityInstance identified by the passed in Id
* @ param pActivityInstId
* @ return ActivityInstance */
public ActivityInstance getActivityInstance ( Long pActivityInstId ) throws ProcessException , DataAccessException { } } | ActivityInstance ai ; TransactionWrapper transaction = null ; EngineDataAccessDB edao = new EngineDataAccessDB ( ) ; try { transaction = edao . startTransaction ( ) ; ai = edao . getActivityInstance ( pActivityInstId ) ; } catch ( SQLException e ) { throw new ProcessException ( 0 , "Failed to get activity instance" , e ) ; } finally { edao . stopTransaction ( transaction ) ; } return ai ; |
public class CmsExport { /** * Writes the data for a resource ( like access - rights ) to the < code > manifest . xml < / code > file . < p >
* @ param resource the resource to get the data from
* @ param source flag to show if the source information in the xml file must be written
* @ param isSuperFolder flag to indicate that the resource is only a super folder of a module resource .
* This will prevent exporting uuid and creation date in the reduced export mode .
* @ throws CmsImportExportException if something goes wrong
* @ throws SAXException if something goes wrong processing the manifest . xml */
protected void appendResourceToManifest ( CmsResource resource , boolean source , boolean isSuperFolder ) throws CmsImportExportException , SAXException { } } | try { // only write < source > if resource is a file
String fileName = trimResourceName ( getCms ( ) . getSitePath ( resource ) ) ; if ( fileName . startsWith ( "system/orgunits" ) ) { // it is not allowed to export organizational unit resources
// export the organizational units instead
return ; } // define the file node
Element fileElement = m_resourceNode . addElement ( CmsImportVersion10 . N_FILE ) ; if ( resource . isFile ( ) ) { if ( source ) { fileElement . addElement ( CmsImportVersion10 . N_SOURCE ) . addText ( fileName ) ; } } else { m_exportCount ++ ; I_CmsReport report = getReport ( ) ; // output something to the report for the folder
report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_SUCCESSION_1 , String . valueOf ( m_exportCount ) ) , I_CmsReport . FORMAT_NOTE ) ; report . print ( Messages . get ( ) . container ( Messages . RPT_EXPORT_0 ) , I_CmsReport . FORMAT_NOTE ) ; report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_ARGUMENT_1 , getCms ( ) . getSitePath ( resource ) ) ) ; report . print ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_DOTS_0 ) ) ; report . println ( org . opencms . report . Messages . get ( ) . container ( org . opencms . report . Messages . RPT_OK_0 ) , I_CmsReport . FORMAT_OK ) ; if ( LOG . isInfoEnabled ( ) ) { LOG . info ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_EXPORTING_OK_2 , String . valueOf ( m_exportCount ) , getCms ( ) . getSitePath ( resource ) ) ) ; } } boolean isReducedExportMode = m_parameters . getExportMode ( ) . equals ( ExportMode . REDUCED ) ; boolean isMinimalMetaData = isReducedExportMode && isSuperFolder && exportWithMinimalMetaData ( fileName ) ; // < destination >
fileElement . addElement ( CmsImportVersion10 . N_DESTINATION ) . addText ( fileName ) ; // < type >
fileElement . addElement ( CmsImportVersion10 . N_TYPE ) . addText ( OpenCms . getResourceManager ( ) . getResourceType ( resource . getTypeId ( ) ) . getTypeName ( ) ) ; if ( ! isMinimalMetaData ) { // < uuidstructure >
fileElement . addElement ( CmsImportVersion10 . N_UUIDSTRUCTURE ) . addText ( resource . getStructureId ( ) . toString ( ) ) ; if ( resource . isFile ( ) ) { // < uuidresource >
fileElement . addElement ( CmsImportVersion10 . N_UUIDRESOURCE ) . addText ( resource . getResourceId ( ) . toString ( ) ) ; } } if ( ! isReducedExportMode ) { // < datelastmodified >
fileElement . addElement ( CmsImportVersion10 . N_DATELASTMODIFIED ) . addText ( getDateLastModifiedForExport ( resource ) ) ; // < userlastmodified >
String userNameLastModified = null ; try { userNameLastModified = getCms ( ) . readUser ( resource . getUserLastModified ( ) ) . getName ( ) ; } catch ( @ SuppressWarnings ( "unused" ) CmsException e ) { userNameLastModified = OpenCms . getDefaultUsers ( ) . getUserAdmin ( ) ; } fileElement . addElement ( CmsImportVersion10 . N_USERLASTMODIFIED ) . addText ( userNameLastModified ) ; } if ( ! isMinimalMetaData ) { // < datecreated >
fileElement . addElement ( CmsImportVersion10 . N_DATECREATED ) . addText ( CmsDateUtil . getHeaderDate ( resource . getDateCreated ( ) ) ) ; } if ( ! isReducedExportMode ) { // < usercreated >
String userNameCreated = null ; try { userNameCreated = getCms ( ) . readUser ( resource . getUserCreated ( ) ) . getName ( ) ; } catch ( @ SuppressWarnings ( "unused" ) CmsException e ) { userNameCreated = OpenCms . getDefaultUsers ( ) . getUserAdmin ( ) ; } fileElement . addElement ( CmsImportVersion10 . N_USERCREATED ) . addText ( userNameCreated ) ; } if ( ! isMinimalMetaData ) { // < release >
if ( resource . getDateReleased ( ) != CmsResource . DATE_RELEASED_DEFAULT ) { fileElement . addElement ( CmsImportVersion10 . N_DATERELEASED ) . addText ( CmsDateUtil . getHeaderDate ( resource . getDateReleased ( ) ) ) ; } // < expire >
if ( resource . getDateExpired ( ) != CmsResource . DATE_EXPIRED_DEFAULT ) { fileElement . addElement ( CmsImportVersion10 . N_DATEEXPIRED ) . addText ( CmsDateUtil . getHeaderDate ( resource . getDateExpired ( ) ) ) ; } // < flags >
int resFlags = resource . getFlags ( ) ; resFlags &= ~ CmsResource . FLAG_LABELED ; fileElement . addElement ( CmsImportVersion10 . N_FLAGS ) . addText ( Integer . toString ( resFlags ) ) ; // write the properties to the manifest
Element propertiesElement = fileElement . addElement ( CmsImportVersion10 . N_PROPERTIES ) ; List < CmsProperty > properties = getCms ( ) . readPropertyObjects ( getCms ( ) . getSitePath ( resource ) , false ) ; // sort the properties for a well defined output order
Collections . sort ( properties ) ; for ( int i = 0 , n = properties . size ( ) ; i < n ; i ++ ) { CmsProperty property = properties . get ( i ) ; if ( isIgnoredProperty ( property ) ) { continue ; } addPropertyNode ( propertiesElement , property . getName ( ) , property . getStructureValue ( ) , false ) ; addPropertyNode ( propertiesElement , property . getName ( ) , property . getResourceValue ( ) , true ) ; } // Write the relations to the manifest
List < CmsRelation > relations = getCms ( ) . getRelationsForResource ( resource , CmsRelationFilter . TARGETS . filterNotDefinedInContent ( ) ) ; Element relationsElement = fileElement . addElement ( CmsImportVersion10 . N_RELATIONS ) ; // iterate over the relations
for ( CmsRelation relation : relations ) { // relation may be broken already :
try { CmsResource target = relation . getTarget ( getCms ( ) , CmsResourceFilter . ALL ) ; String structureId = target . getStructureId ( ) . toString ( ) ; String sitePath = getCms ( ) . getSitePath ( target ) ; String relationType = relation . getType ( ) . getName ( ) ; addRelationNode ( relationsElement , structureId , sitePath , relationType ) ; } catch ( CmsVfsResourceNotFoundException crnfe ) { // skip this relation :
if ( LOG . isWarnEnabled ( ) ) { LOG . warn ( Messages . get ( ) . getBundle ( ) . key ( Messages . LOG_IMPORTEXPORT_WARN_DELETED_RELATIONS_2 , new String [ ] { relation . getTargetPath ( ) , resource . getRootPath ( ) } ) , crnfe ) ; } } } // append the nodes for access control entries
Element acl = fileElement . addElement ( CmsImportVersion10 . N_ACCESSCONTROL_ENTRIES ) ; // read the access control entries
List < CmsAccessControlEntry > fileAcEntries = getCms ( ) . getAccessControlEntries ( getCms ( ) . getSitePath ( resource ) , false ) ; Iterator < CmsAccessControlEntry > i = fileAcEntries . iterator ( ) ; // create xml elements for each access control entry
while ( i . hasNext ( ) ) { CmsAccessControlEntry ace = i . next ( ) ; Element a = acl . addElement ( CmsImportVersion10 . N_ACCESSCONTROL_ENTRY ) ; // now check if the principal is a group or a user
int flags = ace . getFlags ( ) ; String acePrincipalName = "" ; CmsUUID acePrincipal = ace . getPrincipal ( ) ; if ( ( flags & CmsAccessControlEntry . ACCESS_FLAGS_ALLOTHERS ) > 0 ) { acePrincipalName = CmsAccessControlEntry . PRINCIPAL_ALL_OTHERS_NAME ; } else if ( ( flags & CmsAccessControlEntry . ACCESS_FLAGS_OVERWRITE_ALL ) > 0 ) { acePrincipalName = CmsAccessControlEntry . PRINCIPAL_OVERWRITE_ALL_NAME ; } else if ( ( flags & CmsAccessControlEntry . ACCESS_FLAGS_GROUP ) > 0 ) { // the principal is a group
try { acePrincipalName = getCms ( ) . readGroup ( acePrincipal ) . getPrefixedName ( ) ; } catch ( @ SuppressWarnings ( "unused" ) CmsException e ) { // the group for this permissions does not exist anymore , so simply skip it
} } else if ( ( flags & CmsAccessControlEntry . ACCESS_FLAGS_USER ) > 0 ) { // the principal is a user
try { acePrincipalName = getCms ( ) . readUser ( acePrincipal ) . getPrefixedName ( ) ; } catch ( @ SuppressWarnings ( "unused" ) CmsException e ) { // the user for this permissions does not exist anymore , so simply skip it
} } else { // the principal is a role
acePrincipalName = CmsRole . PRINCIPAL_ROLE + "." + CmsRole . valueOfId ( acePrincipal ) . getRoleName ( ) ; } // only add the permission if a principal was set
if ( CmsStringUtil . isNotEmptyOrWhitespaceOnly ( acePrincipalName ) ) { a . addElement ( CmsImportVersion10 . N_ACCESSCONTROL_PRINCIPAL ) . addText ( acePrincipalName ) ; a . addElement ( CmsImportVersion10 . N_FLAGS ) . addText ( Integer . toString ( flags ) ) ; Element b = a . addElement ( CmsImportVersion10 . N_ACCESSCONTROL_PERMISSIONSET ) ; b . addElement ( CmsImportVersion10 . N_ACCESSCONTROL_ALLOWEDPERMISSIONS ) . addText ( Integer . toString ( ace . getAllowedPermissions ( ) ) ) ; b . addElement ( CmsImportVersion10 . N_ACCESSCONTROL_DENIEDPERMISSIONS ) . addText ( Integer . toString ( ace . getDeniedPermissions ( ) ) ) ; } } } else { fileElement . addElement ( CmsImportVersion10 . N_PROPERTIES ) ; } // write the XML
digestElement ( m_resourceNode , fileElement ) ; } catch ( CmsImportExportException e ) { throw e ; } catch ( CmsException e ) { CmsMessageContainer message = Messages . get ( ) . container ( Messages . ERR_IMPORTEXPORT_ERROR_APPENDING_RESOURCE_TO_MANIFEST_1 , resource . getRootPath ( ) ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( message . key ( ) , e ) ; } throw new CmsImportExportException ( message , e ) ; } |
public class Headers { /** * Get the first value found for this key even if there are multiple . If none , then
* return null .
* @ param name
* @ return */
public String getFirst ( String name ) { } } | HeaderName hn = getHeaderName ( name ) ; return getFirst ( hn ) ; |
public class FileUtils { /** * Verificamos que file es un fichero y que tenemos permisos de lectura
* @ param dir
* @ return */
public static String verifyReadFile ( String filePath ) { } } | if ( filePath == null ) { return "The path is null" ; } File dir = new File ( filePath ) ; return verifyReadFile ( dir ) ; |
public class ProxyOverrider { /** * Used by LittleProxy to connect to a downstream proxy if there is one . */
@ Override public void lookupChainedProxies ( HttpRequest request , Queue < ChainedProxy > chainedProxies ) { } } | final InetSocketAddress originalProxy = originalProxies . get ( URI . create ( request . getUri ( ) ) . getScheme ( ) ) ; if ( originalProxy != null ) { ChainedProxy chainProxy = new ChainedProxyAdapter ( ) { @ Override public InetSocketAddress getChainedProxyAddress ( ) { return originalProxy ; } } ; chainedProxies . add ( chainProxy ) ; } else { chainedProxies . add ( ChainedProxyAdapter . FALLBACK_TO_DIRECT_CONNECTION ) ; } |
public class TimerTrace { /** * End a preformance profiling with the < code > name < / code > given . Deal with
* profile hierarchy automatically , so caller don ' t have to be concern about it . */
public static void end ( ) { } } | if ( ! active ) return ; TimerStack stack = curStack . get ( ) ; if ( null == stack ) return ; TimerNode currentNode = stack . pop ( ) ; if ( currentNode != null ) { TimerNode parent = stack . peek ( ) ; long total = currentNode . end ( ) ; // if we are the root timer , then print out the times
if ( parent == null ) { printTimes ( currentNode ) ; curStack . set ( null ) ; // for those servers that use thread pooling
} else { if ( total > mintime ) parent . children . add ( currentNode ) ; } } |
public class ProbeManagerImpl { /** * Determine of the specified class can be monitored via the probes
* infrastructure .
* @ param clazz the monitoring candidate
* @ return false if the class can ' t be monitored */
public boolean isMonitorable ( Class < ? > clazz ) { } } | // Faster ( ? ) path
if ( notMonitorable . contains ( clazz ) ) { return false ; } else if ( monitorable . contains ( clazz ) ) { return true ; } boolean isMonitorable = true ; if ( ! instrumentation . isModifiableClass ( clazz ) ) { isMonitorable = false ; } else if ( clazz . isInterface ( ) ) { isMonitorable = false ; } else if ( clazz . isArray ( ) ) { isMonitorable = false ; } else if ( Proxy . isProxyClass ( clazz ) ) { isMonitorable = false ; } else if ( clazz . isPrimitive ( ) ) { isMonitorable = false ; } else if ( isExcludedClass ( Type . getInternalName ( clazz ) ) ) { isMonitorable = false ; } else if ( ! includeBootstrap && clazz . getClassLoader ( ) == null ) { isMonitorable = false ; } // Update collections
if ( ! isMonitorable ) { synchronized ( notMonitorable ) { notMonitorable . add ( clazz ) ; } } else { monitorable . add ( clazz ) ; } return isMonitorable ; |
public class JdbcDeepJobConfig { /** * { @ inheritDoc } */
@ Override public JdbcDeepJobConfig < T > partitionKey ( String partitionKey ) { } } | if ( dbTable != null ) { this . partitionKey = new DbColumn ( dbTable , partitionKey , "" , null , null ) ; } return this ; |
public class Stream { /** * Zip together the " a " , " b " and " c " iterators until all of them runs out of values .
* Each triple of values is combined into a single value using the supplied zipFunction function .
* @ param a
* @ param b
* @ param c
* @ param valueForNoneA value to fill if " a " runs out of values .
* @ param valueForNoneB value to fill if " b " runs out of values .
* @ param valueForNoneC value to fill if " c " runs out of values .
* @ param zipFunction
* @ return */
public static < R > Stream < R > zip ( final int [ ] a , final int [ ] b , final int [ ] c , final int valueForNoneA , final int valueForNoneB , final int valueForNoneC , final IntTriFunction < R > zipFunction ) { } } | return zip ( IntIteratorEx . of ( a ) , IntIteratorEx . of ( b ) , IntIteratorEx . of ( c ) , valueForNoneA , valueForNoneB , valueForNoneC , zipFunction ) ; |
public class NetworkBufferPool { /** * Destroys all buffer pools that allocate their buffers from this
* buffer pool ( created via { @ link # createBufferPool ( int , int ) } ) . */
public void destroyAllBufferPools ( ) { } } | synchronized ( factoryLock ) { // create a copy to avoid concurrent modification exceptions
LocalBufferPool [ ] poolsCopy = allBufferPools . toArray ( new LocalBufferPool [ allBufferPools . size ( ) ] ) ; for ( LocalBufferPool pool : poolsCopy ) { pool . lazyDestroy ( ) ; } // some sanity checks
if ( allBufferPools . size ( ) > 0 || numTotalRequiredBuffers > 0 ) { throw new IllegalStateException ( "NetworkBufferPool is not empty after destroying all LocalBufferPools" ) ; } } |
public class GetStaticIpsResult { /** * An array of key - value pairs containing information about your get static IPs request .
* < b > NOTE : < / b > This method appends the values to the existing list ( if any ) . Use
* { @ link # setStaticIps ( java . util . Collection ) } or { @ link # withStaticIps ( java . util . Collection ) } if you want to
* override the existing values .
* @ param staticIps
* An array of key - value pairs containing information about your get static IPs request .
* @ return Returns a reference to this object so that method calls can be chained together . */
public GetStaticIpsResult withStaticIps ( StaticIp ... staticIps ) { } } | if ( this . staticIps == null ) { setStaticIps ( new java . util . ArrayList < StaticIp > ( staticIps . length ) ) ; } for ( StaticIp ele : staticIps ) { this . staticIps . add ( ele ) ; } return this ; |
public class OAuthCredentialsCache { /** * Clear the cache .
* @ param oldToken for a comparison . Only revoke the cache if the oldToken matches the current one . */
void revokeUnauthToken ( HeaderToken oldToken ) { } } | synchronized ( lock ) { if ( headerCache . getToken ( ) == oldToken ) { LOG . warn ( "Got unauthenticated response from server, revoking the current token" ) ; headerCache = EMPTY_HEADER ; } else { LOG . info ( "Skipping revoke, since the revoked token has already changed" ) ; } } |
public class JenkinsServer { /** * Delete a job from Jenkins within a folder .
* @ param folder The folder where the given job is located .
* @ param jobName The job which should be deleted .
* @ throws IOException in case of an error . */
public JenkinsServer deleteJob ( FolderJob folder , String jobName ) throws IOException { } } | return deleteJob ( folder , jobName , false ) ; |
public class Version { /** * Creates a new instance of { @ code Version }
* for the specified version numbers .
* @ param major the major version number
* @ param minor the minor version number
* @ param patch the patch version number
* @ return a new instance of the { @ code Version } class
* @ throws IllegalArgumentException if a negative integer is passed
* @ since 0.7.0 */
public static Version forIntegers ( int major , int minor , int patch ) { } } | return new Version ( new NormalVersion ( major , minor , patch ) ) ; |
public class EmulatedFields { /** * Returns { @ code true } indicating the field called { @ code name } has not had
* a value explicitly assigned and that it still holds a default value for
* its type , or { @ code false } indicating that the field named has been
* assigned a value explicitly .
* @ param name
* the name of the field to test .
* @ return { @ code true } if { @ code name } still holds its default value ,
* { @ code false } otherwise
* @ throws IllegalArgumentException
* if { @ code name } is { @ code null } */
public boolean defaulted ( String name ) throws IllegalArgumentException { } } | ObjectSlot slot = findSlot ( name , null ) ; if ( slot == null ) { throw new IllegalArgumentException ( "no field '" + name + "'" ) ; } return slot . defaulted ; |
public class DataPipeline { /** * Return true if at least one source is active .
* @ param skipSource don ' t consider this data source when determining if the
* pipeline is active . */
public boolean isActive ( VehicleDataSource skipSource ) { } } | boolean connected = false ; for ( VehicleDataSource s : mSources ) { if ( s != skipSource ) { connected = connected || s . isConnected ( ) ; } } return connected ; |
public class MessageSerializer { /** * Serializes the exception containing the failure message sent to the
* { @ link org . apache . flink . queryablestate . network . Client } in case of
* protocol related errors .
* @ param allocThe { @ link ByteBufAllocator } used to allocate the buffer to serialize the message into .
* @ param requestIdThe id of the request to which the message refers to .
* @ param causeThe exception thrown at the server .
* @ return A { @ link ByteBuf } containing the serialized message . */
public static ByteBuf serializeRequestFailure ( final ByteBufAllocator alloc , final long requestId , final Throwable cause ) throws IOException { } } | final ByteBuf buf = alloc . ioBuffer ( ) ; // Frame length is set at the end
buf . writeInt ( 0 ) ; writeHeader ( buf , MessageType . REQUEST_FAILURE ) ; buf . writeLong ( requestId ) ; try ( ByteBufOutputStream bbos = new ByteBufOutputStream ( buf ) ; ObjectOutput out = new ObjectOutputStream ( bbos ) ) { out . writeObject ( cause ) ; } // Set frame length
int frameLength = buf . readableBytes ( ) - Integer . BYTES ; buf . setInt ( 0 , frameLength ) ; return buf ; |
public class EmoTableAllTablesReportDAO { /** * Accepts the table portion of a table report entry and converts it to a TableReportEntryTable . If the
* entry doesn ' t match all of the configured filters then null is returned . */
@ Nullable private TableReportEntryTable convertToTableReportEntryTable ( String tableId , Map < String , Object > map , Predicate < String > placementFilter , Predicate < Boolean > droppedFilter , Predicate < Boolean > facadeFilter ) { } } | // Check the filters for placement , dropped , and facade
String placement = ( String ) map . get ( "placement" ) ; if ( ! placementFilter . apply ( placement ) ) { return null ; } Boolean dropped = Objects . firstNonNull ( ( Boolean ) map . get ( "dropped" ) , false ) ; if ( ! droppedFilter . apply ( dropped ) ) { return null ; } Boolean facade = Objects . firstNonNull ( ( Boolean ) map . get ( "facade" ) , false ) ; if ( ! facadeFilter . apply ( facade ) ) { return null ; } List < Integer > shards = Lists . newArrayList ( ) ; // Aggregate the column , size and update statistics across all shards .
TableStatistics . Aggregator aggregator = TableStatistics . newAggregator ( ) ; Object shardJson = map . get ( "shards" ) ; if ( shardJson != null ) { Map < String , TableStatistics > shardMap = JsonHelper . convert ( shardJson , new TypeReference < Map < String , TableStatistics > > ( ) { } ) ; for ( Map . Entry < String , TableStatistics > entry : shardMap . entrySet ( ) ) { Integer shardId = Integer . parseInt ( entry . getKey ( ) ) ; shards . add ( shardId ) ; aggregator . add ( entry . getValue ( ) ) ; } } TableStatistics tableStatistics = aggregator . aggregate ( ) ; Collections . sort ( shards ) ; return new TableReportEntryTable ( tableId , placement , shards , dropped , facade , tableStatistics . getRecordCount ( ) , tableStatistics . getColumnStatistics ( ) . toStatistics ( ) , tableStatistics . getSizeStatistics ( ) . toStatistics ( ) , tableStatistics . getUpdateTimeStatistics ( ) . toStatistics ( ) ) ; |
public class FileUtils { /** * Writes map entries from symbols to file absolute paths to a file . Each line has a mapping with
* the key and value separated by a single tab . The file will have a trailing newline . Note that
* the same " key " may appear in the file with multiple mappings . */
public static void writeSymbolToFileEntries ( final Iterable < Map . Entry < Symbol , File > > entries , final CharSink sink ) throws IOException { } } | writeUnixLines ( transform ( MapUtils . transformValues ( entries , toAbsolutePathFunction ( ) ) , TO_TAB_SEPARATED_ENTRY ) , sink ) ; |
public class CETR { /** * Extracts the main content for an HTML page .
* @ param html
* @ param parameters
* @ return */
public String extract ( String html , CETR . Parameters parameters ) { } } | html = clearText ( html ) ; // preprocess the Document by removing irrelevant HTML tags and empty lines and break the document to its lines
List < String > rows = extractRows ( html ) ; List < Integer > selectedRowIds = selectRows ( rows , parameters ) ; StringBuilder sb = new StringBuilder ( html . length ( ) ) ; for ( Integer rowId : selectedRowIds ) { String row = rows . get ( rowId ) ; // extract the clear text from the selected row
row = StringCleaner . removeExtraSpaces ( HTMLParser . extractText ( row ) ) ; if ( row . isEmpty ( ) ) { continue ; } sb . append ( row ) . append ( " " ) ; } return sb . toString ( ) . trim ( ) ; |
public class ConsoleConsumer { /** * Creates and starts a daemon thread which pipes int { @ link InputStream } to the { @ link OutputStream } .
* @ param in the input stream that should be pipped
* @ param out the output stream where the data should be written
* @ return the thread that was started */
public static Thread start ( final InputStream in , final OutputStream out ) { } } | final Thread thread = new Thread ( new ConsoleConsumer ( in , out ) , "WildFly-Console-Consumer" ) ; thread . setDaemon ( true ) ; thread . start ( ) ; return thread ; |
public class RequestHelper { /** * Get the request path info without an eventually appended session
* ( " ; jsessionid = . . . " )
* @ param aHttpRequest
* The HTTP request
* @ return Returns any extra path information associated with the URL the
* client sent when it made this request . The extra path information
* follows the servlet path but precedes the query string and will
* start with a " / " character . The optional session ID is stripped . */
@ Nullable public static String getPathInfo ( @ Nonnull final HttpServletRequest aHttpRequest ) { } } | ValueEnforcer . notNull ( aHttpRequest , "HttpRequest" ) ; final String sPathInfo = ServletHelper . getRequestPathInfo ( aHttpRequest ) ; if ( StringHelper . hasNoText ( sPathInfo ) ) return sPathInfo ; return getWithoutSessionID ( sPathInfo ) ; |
public class PatriciaTrie { /** * Returns a copy of the keys contained in this trie as a Set
* @ return keys in the trie , not null */
@ Override public Set < String > keySet ( ) { } } | Set < String > keys = new HashSet < > ( ) ; keysR ( root . getLeft ( ) , - 1 , keys ) ; return keys ; |
public class CheckedInputStream { /** * Reads a byte . Will block if no input is available .
* @ return the byte read , or - 1 if the end of the stream is reached .
* @ exception IOException if an I / O error has occurred */
public int read ( ) throws IOException { } } | int b = in . read ( ) ; if ( b != - 1 ) { cksum . update ( b ) ; } return b ; |
public class DbLoadAction { /** * 分析整个数据 , 将datas划分为多个批次 . ddl sql前的DML并发执行 , 然后串行执行ddl后 , 再并发执行DML
* @ return */
private boolean isDdlDatas ( List < EventData > eventDatas ) { } } | boolean result = false ; for ( EventData eventData : eventDatas ) { result |= eventData . getEventType ( ) . isDdl ( ) ; if ( result && ! eventData . getEventType ( ) . isDdl ( ) ) { throw new LoadException ( "ddl/dml can't be in one batch, it's may be a bug , pls submit issues." , DbLoadDumper . dumpEventDatas ( eventDatas ) ) ; } } return result ; |
public class GraphRowSumValues { /** * Method used to getMaxX without taking in account out of range
* values . I . E . we don ' t take in account on value if the distance
* with the last point is greater than getGranulationValue ( ) * excludeCount .
* @ return the evaluated MaxX */
@ Override public long getMaxX ( ) { } } | if ( ! excludeOutOfRangeValues ) { return super . getMaxX ( ) ; } else { long retMax = 0 ; Iterator < Long > iter = values . keySet ( ) . iterator ( ) ; if ( iter . hasNext ( ) ) { retMax = iter . next ( ) ; } long excludeValue = getGranulationValue ( ) * excludeCount ; while ( iter . hasNext ( ) ) { long value = iter . next ( ) ; if ( value > retMax ) { if ( ( value - retMax ) < excludeValue ) { retMax = value ; } } } return retMax ; } |
public class PlanNode { /** * Find the first node with one of the specified types that are at or below this node .
* @ param order the order to traverse ; may not be null
* @ param firstTypeToFind the first type of node to find ; may not be null
* @ param additionalTypesToFind the additional types of node to find ; may not be null
* @ return the first node that is at or below this node that has one of the supplied types ; or null if there is no such node */
public PlanNode findAtOrBelow ( Traversal order , Type firstTypeToFind , Type ... additionalTypesToFind ) { } } | return findAtOrBelow ( order , EnumSet . of ( firstTypeToFind , additionalTypesToFind ) ) ; |
public class AppListenerUtil { /** * translate int definition of script protect to string definition
* @ param scriptProtect
* @ return */
public static String translateScriptProtect ( int scriptProtect ) { } } | if ( scriptProtect == ApplicationContext . SCRIPT_PROTECT_NONE ) return "none" ; if ( scriptProtect == ApplicationContext . SCRIPT_PROTECT_ALL ) return "all" ; Array arr = new ArrayImpl ( ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_CGI ) > 0 ) arr . appendEL ( "cgi" ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_COOKIE ) > 0 ) arr . appendEL ( "cookie" ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_FORM ) > 0 ) arr . appendEL ( "form" ) ; if ( ( scriptProtect & ApplicationContext . SCRIPT_PROTECT_URL ) > 0 ) arr . appendEL ( "url" ) ; try { return ListUtil . arrayToList ( arr , "," ) ; } catch ( PageException e ) { return "none" ; } |
public class LayoutExtensions { /** * Adds the component .
* @ param gbl
* the gbl
* @ param gbc
* the gbc
* @ param anchor
* the anchor
* @ param fill
* the fill
* @ param insets
* the insets
* @ param gridx
* the gridx
* @ param gridy
* the gridy
* @ param gridwidth
* the gridwidth
* @ param gridheight
* the gridheight
* @ param weightx
* the weightx
* @ param weighty
* the weighty
* @ param addComponentToPanel
* the add component to panel
* @ param panelToAdd
* the panel to add */
public static void addComponent ( final GridBagLayout gbl , final GridBagConstraints gbc , final int anchor , final int fill , final Insets insets , final int gridx , final int gridy , final int gridwidth , final int gridheight , final double weightx , final double weighty , final Component addComponentToPanel , final Container panelToAdd ) { } } | gbc . anchor = anchor ; gbc . fill = fill ; gbc . insets = insets ; gbc . gridx = gridx ; gbc . gridy = gridy ; gbc . gridwidth = gridwidth ; gbc . gridheight = gridheight ; gbc . weightx = weightx ; gbc . weighty = weighty ; gbl . setConstraints ( addComponentToPanel , gbc ) ; panelToAdd . add ( addComponentToPanel ) ; |
public class LongStream { /** * Returns a stream consisting of the results of replacing each element of
* this stream with the contents of a mapped stream produced by applying
* the provided mapping function to each element .
* < p > This is an intermediate operation .
* < p > Example :
* < pre >
* mapper : ( a ) - & gt ; [ a , a + 5]
* stream : [ 1 , 2 , 3 , 4]
* result : [ 1 , 6 , 2 , 7 , 3 , 8 , 4 , 9]
* < / pre >
* @ param mapper the mapper function used to apply to each element
* @ return the new stream
* @ see Stream # flatMap ( com . annimon . stream . function . Function ) */
@ NotNull public LongStream flatMap ( @ NotNull final LongFunction < ? extends LongStream > mapper ) { } } | return new LongStream ( params , new LongFlatMap ( iterator , mapper ) ) ; |
public class CubicInterpolation { /** * In C : again - two - registers cubic _ interpolate _ with _ x _ arr _ and _ y _ stride _ aux L1402 */
private static double interpolateUsingXArrAndYStride ( final double [ ] xArr , final double yStride , final int offset , final double x ) { } } | return cubicInterpolate ( xArr [ offset + 0 ] , yStride * ( offset + 0 ) , xArr [ offset + 1 ] , yStride * ( offset + 1 ) , xArr [ offset + 2 ] , yStride * ( offset + 2 ) , xArr [ offset + 3 ] , yStride * ( offset + 3 ) , x ) ; |
public class ExportRecordsScreen { /** * SetupSFields Method . */
public void setupSFields ( ) { } } | this . getRecord ( ClassInfo . CLASS_INFO_FILE ) . getField ( ClassInfo . CLASS_PACKAGE ) . setupDefaultView ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , ScreenConstants . DEFAULT_DISPLAY ) ; this . getRecord ( ClassInfo . CLASS_INFO_FILE ) . getField ( ClassInfo . CLASS_PROJECT_ID ) . setupDefaultView ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , ScreenConstants . DEFAULT_DISPLAY ) ; this . getRecord ( ClassInfoScreenRecord . CLASS_INFO_SCREEN_RECORD_FILE ) . getField ( ClassInfoScreenRecord . INCLUDE_EMPTY_FILES ) . setupDefaultView ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , ScreenConstants . DEFAULT_DISPLAY ) ; String strProcess = copyProcessParams ( ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . PROCESS , StandaloneProcessRunnerProcess . class . getName ( ) ) ; strProcess = Utility . addURLParam ( strProcess , StandaloneProcessRunnerProcess . STANDALONE_PROCESS , ExportRecordsToXmlProcess . class . getName ( ) ) ; strProcess = Utility . addURLParam ( strProcess , DBParams . TASK , ProcessRunnerTask . class . getName ( ) ) ; // Screen class
strProcess = Utility . addURLParam ( strProcess , ClassInfoScreenRecord . INCLUDE_EMPTY_FILES , this . getRecord ( ClassInfoScreenRecord . CLASS_INFO_SCREEN_RECORD_FILE ) . getField ( ClassInfoScreenRecord . INCLUDE_EMPTY_FILES ) . toString ( ) ) ; String basePath = ( ( ProgramControl ) this . getRecord ( ProgramControl . PROGRAM_CONTROL_FILE ) ) . getBasePath ( ) ; String path = this . getRecord ( ProgramControl . PROGRAM_CONTROL_FILE ) . getField ( ProgramControl . ARCHIVE_DIRECTORY ) . toString ( ) ; if ( ( ! path . startsWith ( "/" ) ) && ( ! path . startsWith ( File . separator ) ) ) path = Utility . addToPath ( basePath , path ) ; String strJob = Utility . addURLParam ( strProcess , ConvertCode . DIR_PREFIX , path ) ; strJob = Utility . addURLParam ( strJob , "package" , NON_SYSTEM_PACKAGE_FILTER ) ; new SCannedBox ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , null , ScreenConstants . DEFAULT_DISPLAY , null , "Export" , "Export" , strJob , null ) ; strJob = Utility . addURLParam ( strJob , ExportRecordsToXmlProcess . TRANSFER_MODE , ExportRecordsToXmlProcess . IMPORT ) ; new SCannedBox ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , null , ScreenConstants . DEFAULT_DISPLAY , null , "Import" , "Import" , strJob , null ) ; path = this . getRecord ( ProgramControl . PROGRAM_CONTROL_FILE ) . getField ( ProgramControl . DEV_ARCHIVE_DIRECTORY ) . toString ( ) ; if ( ( ! path . startsWith ( "/" ) ) && ( ! path . startsWith ( File . separator ) ) ) path = Utility . addToPath ( basePath , path ) ; strJob = Utility . addURLParam ( strProcess , ConvertCode . DIR_PREFIX , path ) ; strJob = Utility . addURLParam ( strJob , "package" , SYSTEM_PACKAGE_FILTER ) ; strJob = Utility . addURLParam ( strJob , ClassInfoScreenRecord . INCLUDE_EMPTY_FILES , this . getRecord ( ClassInfoScreenRecord . CLASS_INFO_SCREEN_RECORD_FILE ) . getField ( ClassInfoScreenRecord . INCLUDE_EMPTY_FILES ) . toString ( ) ) ; new SCannedBox ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , null , ScreenConstants . DEFAULT_DISPLAY , null , "Export System Files" , "Export" , strJob , null ) ; strJob = Utility . addURLParam ( strJob , ExportRecordsToXmlProcess . TRANSFER_MODE , ExportRecordsToXmlProcess . IMPORT ) ; new SCannedBox ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , null , ScreenConstants . DEFAULT_DISPLAY , null , "Import System Files" , "Import" , strJob , null ) ; |
public class AdminDictProtwordsAction { @ Execute public HtmlResponse create ( final CreateForm form ) { } } | verifyCrudMode ( form . crudMode , CrudMode . CREATE , form . dictId ) ; validate ( form , messages -> { } , ( ) -> asEditHtml ( ) ) ; verifyToken ( ( ) -> asEditHtml ( ) ) ; createProtwordsItem ( form , ( ) -> asEditHtml ( ) ) . ifPresent ( entity -> { protwordsService . store ( form . dictId , entity ) ; saveInfo ( messages -> messages . addSuccessCrudCreateCrudTable ( GLOBAL ) ) ; } ) . orElse ( ( ) -> throwValidationError ( messages -> messages . addErrorsCrudFailedToCreateInstance ( GLOBAL ) , ( ) -> asEditHtml ( ) ) ) ; return redirectWith ( getClass ( ) , moreUrl ( "list/1" ) . params ( "dictId" , form . dictId ) ) ; |
public class LongParameter { /** * Set the maximum value .
* < p > If a minimum value has been set then the maximum value must not be
* less than the minimum value .
* @ param maximumValue the maximum value
* @ return this */
public LongParameter setMaximumValue ( long maximumValue ) { } } | if ( hasMinimumValue ) { Util . checkParameter ( maximumValue >= minimumValue , "Maximum value (" + maximumValue + ") must be greater than or equal to minimum (" + minimumValue + ")" ) ; } this . hasMaximumValue = true ; this . maximumValue = maximumValue ; return this ; |
public class AlignmentTools { /** * Rotate the Atoms / Groups so they are aligned for the 3D visualisation
* @ param afpChain
* @ param ca1
* @ param ca2
* @ return an array of Groups that are transformed for 3D display
* @ throws StructureException */
public static Group [ ] prepareGroupsForDisplay ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { } } | if ( afpChain . getBlockRotationMatrix ( ) . length == 0 ) { // probably the alignment is too short !
System . err . println ( "No rotation matrix found to rotate 2nd structure!" ) ; afpChain . setBlockRotationMatrix ( new Matrix [ ] { Matrix . identity ( 3 , 3 ) } ) ; afpChain . setBlockShiftVector ( new Atom [ ] { new AtomImpl ( ) } ) ; } // List of groups to be rotated according to the alignment
Group [ ] twistedGroups = new Group [ ca2 . length ] ; // int blockNum = afpChain . getBlockNum ( ) ;
int i = - 1 ; // List of groups from the structure not included in ca2 ( e . g . ligands )
// Will be rotated according to first block
List < Group > hetatms2 = StructureTools . getUnalignedGroups ( ca2 ) ; if ( ( afpChain . getAlgorithmName ( ) . equals ( FatCatRigid . algorithmName ) ) || ( afpChain . getAlgorithmName ( ) . equals ( FatCatFlexible . algorithmName ) ) ) { for ( Atom a : ca2 ) { i ++ ; twistedGroups [ i ] = a . getGroup ( ) ; } twistedGroups = AFPTwister . twistOptimized ( afpChain , ca1 , ca2 ) ; // } else if ( ( blockNum = = 1 ) | | ( afpChain . getAlgorithmName ( ) . equals ( CeCPMain . algorithmName ) ) ) {
} else { Matrix m = afpChain . getBlockRotationMatrix ( ) [ 0 ] ; Atom shift = afpChain . getBlockShiftVector ( ) [ 0 ] ; shiftCA2 ( afpChain , ca2 , m , shift , twistedGroups ) ; } if ( afpChain . getBlockNum ( ) > 0 ) { // Superimpose ligands relative to the first block
if ( hetatms2 . size ( ) > 0 ) { if ( afpChain . getBlockRotationMatrix ( ) . length > 0 ) { Matrix m1 = afpChain . getBlockRotationMatrix ( ) [ 0 ] ; // m1 . print ( 3,3 ) ;
Atom vector1 = afpChain . getBlockShiftVector ( ) [ 0 ] ; // System . out . println ( " shift vector : " + vector1 ) ;
for ( Group g : hetatms2 ) { Calc . rotate ( g , m1 ) ; Calc . shift ( g , vector1 ) ; } } } } return twistedGroups ; |
public class Unchecked { /** * Wrap a { @ link CheckedToLongFunction } in a { @ link ToLongFunction } with a custom handler for checked exceptions .
* Example :
* < code > < pre >
* map . forEach ( Unchecked . toLongFunction (
* if ( k . length ( ) > 10)
* throw new Exception ( " Only short strings allowed " ) ;
* return 42L ;
* throw new IllegalStateException ( e ) ;
* < / pre > < / code > */
public static < T > ToLongFunction < T > toLongFunction ( CheckedToLongFunction < T > function , Consumer < Throwable > handler ) { } } | return t -> { try { return function . applyAsLong ( t ) ; } catch ( Throwable e ) { handler . accept ( e ) ; throw new IllegalStateException ( "Exception handler must throw a RuntimeException" , e ) ; } } ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.