idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
17,100
public org . biouno . figshare . v1 . model . File uploadFile ( long articleId , File file ) { HttpClient httpClient = null ; try { final String method = String . format ( "my_data/articles/%d/files" , articleId ) ; final String url = getURL ( endpoint , version , method ) ; final HttpPut request = new HttpPut ( url ) ...
Upload a file to an article .
17,101
protected org . biouno . figshare . v1 . model . File readFileFromJson ( String json ) { Gson gson = new Gson ( ) ; org . biouno . figshare . v1 . model . File file = gson . fromJson ( json , org . biouno . figshare . v1 . model . File . class ) ; return file ; }
Get a file from a JSON .
17,102
public int compareTo ( final Id id ) { return Integer . valueOf ( this . id ) . compareTo ( id . id ) ; }
Provides a natural ordering for the Id class such that Ids can be sorted into increasing numerical order .
17,103
public final Post modifiedNow ( ) { return new Post ( id , slug , title , excerpt , content , authorId , author , publishTimestamp , System . currentTimeMillis ( ) , status , parentId , guid , commentCount , metadata , type , mimeType , taxonomyTerms , children ) ; }
Changes the modified time of a post to the current time .
17,104
public final Post withContent ( final String content ) { return new Post ( id , slug , title , excerpt , content , authorId , author , publishTimestamp , modifiedTimestamp , status , parentId , guid , commentCount , metadata , type , mimeType , taxonomyTerms , children ) ; }
Replaces post content .
17,105
public final Post withAuthor ( final User user ) { return new Post ( id , slug , title , excerpt , content , authorId , user , publishTimestamp , modifiedTimestamp , status , parentId , guid , commentCount , metadata , type , mimeType , taxonomyTerms , children ) ; }
Adds an author to a post .
17,106
public final Post withTaxonomyTerms ( final Map < String , List < TaxonomyTerm > > taxonomyTerms ) { ImmutableMap . Builder < String , ImmutableList < TaxonomyTerm > > builder = ImmutableMap . builder ( ) ; if ( taxonomyTerms != null && taxonomyTerms . size ( ) > 0 ) { taxonomyTerms . entrySet ( ) . forEach ( kv -> bui...
Adds taxonomy terms to a post .
17,107
public final Post withChildren ( final List < Post > children ) { return new Post ( id , slug , title , excerpt , content , authorId , author , publishTimestamp , modifiedTimestamp , status , parentId , guid , commentCount , this . metadata , type , mimeType , taxonomyTerms , children != null ? ImmutableList . copyOf (...
Adds children to a post .
17,108
public final ImmutableList < TaxonomyTerm > terms ( final String taxonomy ) { ImmutableList < TaxonomyTerm > terms = taxonomyTerms . get ( taxonomy ) ; return terms != null ? terms : ImmutableList . of ( ) ; }
An immutable list of terms associated with this post from a specified taxonomy .
17,109
public final ImmutableList < TaxonomyTerm > tags ( ) { ImmutableList < TaxonomyTerm > tags = taxonomyTerms . get ( TAG_TAXONOMY ) ; return tags != null ? tags : ImmutableList . of ( ) ; }
An immutable list of tags associated with this post .
17,110
public final ImmutableList < TaxonomyTerm > categories ( ) { ImmutableList < TaxonomyTerm > categories = taxonomyTerms . get ( CATEGORY_TAXONOMY ) ; return categories != null ? categories : ImmutableList . of ( ) ; }
An immutable list of categories associated with this post .
17,111
public HttpServerBuilder contentFrom ( String contextRoot , String contentResource ) { URL resource = resolver . resolve ( contentResource , CallStack . getCallerClass ( ) ) ; resources . put ( contextRoot , resource ) ; return this ; }
Defines a ZIP resource on the classpath that provides the static content the server should host .
17,112
public HttpServerBuilder contentFrom ( final String contextRoot , final TemporaryFolder folder ) { resources . put ( contextRoot , folder ) ; return this ; }
Defines a folder resource whose content fill be hosted rule .
17,113
public HttpServerBuilder contentFrom ( final String path , final URL resource ) { resources . put ( path , resource ) ; return this ; }
Defines a file to be hosted on the specified path . The file s content is provided by the specified URL .
17,114
public static void main ( String [ ] args ) { String splashImage = Splash . getParam ( args , SPLASH ) ; if ( ( splashImage == null ) || ( splashImage . length ( ) == 0 ) ) splashImage = DEFAULT_SPLASH ; URL url = Splash . class . getResource ( splashImage ) ; if ( url == null ) if ( ClassServiceUtility . getClassServi...
Display splash and launch app .
17,115
public void paint ( Graphics g ) { g . drawImage ( image , 0 , 0 , this ) ; if ( ! paintCalled ) { paintCalled = true ; synchronized ( this ) { notifyAll ( ) ; } } }
Paints the image on the window .
17,116
public static void disposeSplash ( ) { if ( instance != null ) { Container container = instance ; while ( ( container = container . getParent ( ) ) != null ) { if ( container instanceof Window ) ( ( Window ) container ) . dispose ( ) ; } instance = null ; } }
Closes the splash window .
17,117
public static void invokeMain ( String className , String [ ] args ) { try { Class < ? > clazz = null ; if ( ClassServiceUtility . getClassService ( ) . getClassFinder ( null ) != null ) clazz = ClassServiceUtility . getClassService ( ) . getClassFinder ( null ) . findClass ( className , null ) ; if ( clazz == null ) c...
Invokes the main method of the provided class name .
17,118
public boolean isInside ( double testx , double testy ) { if ( ! bounds . isInside ( testx , testy ) ) { return false ; } return isRawHit ( points , testx , testy ) ; }
Returns true if point is inside a polygon .
17,119
public static boolean isConvex ( double [ ] data , int points ) { if ( points < 3 ) { return true ; } for ( int i1 = 0 ; i1 < points ; i1 ++ ) { int i2 = ( i1 + 1 ) % points ; int i3 = ( i2 + 1 ) % points ; double x1 = data [ 2 * i1 ] ; double y1 = data [ 2 * i1 + 1 ] ; double x2 = data [ 2 * i2 ] ; double y2 = data [ ...
Returns true if polygon is convex .
17,120
public boolean provide ( float value ) { FloatReference ref = new FloatReference ( value ) ; boolean res = queue . offer ( ref ) ; return res ; }
Provides new item to the generator
17,121
public float generate ( ) { try { FloatReference ref = queue . take ( ) ; float value = ref . getValue ( ) ; return value ; } catch ( InterruptedException ex ) { throw new IllegalArgumentException ( ex ) ; } }
Returns item provided in different thread
17,122
@ SuppressWarnings ( "UseOfObsoleteCollectionType" ) public Hashtable < String , String > getConnectionProperties ( ) { StringBuilder url = new StringBuilder ( "ldap://" ) ; url . append ( host ) . append ( ":" ) . append ( String . valueOf ( port ) ) . append ( "/" ) ; Hashtable < String , String > props = new Hashtab...
Returns jndi properties for the in memory directory server .
17,123
public boolean isEndChar ( char chChar ) { if ( ( chChar == '\n' ) || ( chChar == '\r' ) || ( chChar == JAVA_NEW_LINE ) ) return true ; if ( chChar == '<' ) return true ; return false ; }
Is this the ending character of the property?
17,124
public Map < String , Object > getEMailParams ( String strMessage ) { Map < String , Object > properties = new Hashtable < String , Object > ( ) ; int iIndex = this . getStartNextPropertyKey ( - 1 , strMessage ) ; while ( iIndex != - 1 ) { int iIndexEnd = strMessage . indexOf ( END_OF_KEY_CHAR , iIndex ) ; if ( iIndexE...
Scan through this message and get the params to descriptions map .
17,125
public int getStartNextPropertyKey ( int iIndex , String strMessage ) { for ( iIndex = iIndex + 1 ; iIndex < strMessage . length ( ) ; iIndex ++ ) { char chChar = strMessage . charAt ( iIndex ) ; if ( this . isEndChar ( chChar ) ) break ; } if ( iIndex >= strMessage . length ( ) ) return - 1 ; int iNextProperty = strMe...
Get the next property key after this location .
17,126
protected void resetAllValues ( ) { logic = new FilterFieldStringData ( CommonFilterConstants . LOGIC_FILTER_VAR , CommonFilterConstants . LOGIC_FILTER_VAR_DESC ) ; filterVars . clear ( ) ; filterVars . add ( logic ) ; }
Reset all of the Field Variables to their default values .
17,127
public static byte [ ] appendByte ( byte [ ] bytes , byte b ) { byte [ ] result = Arrays . copyOf ( bytes , bytes . length + 1 ) ; result [ result . length - 1 ] = b ; return result ; }
Creates a copy of bytes and appends b to the end of it
17,128
public static int matchingNibbleLength ( byte [ ] a , byte [ ] b ) { int i = 0 ; int length = a . length < b . length ? a . length : b . length ; while ( i < length ) { if ( a [ i ] != b [ i ] ) return i ; i ++ ; } return i ; }
Returns the amount of nibbles that match each other from 0 ... amount will never be larger than smallest input
17,129
public static byte [ ] longToBytesNoLeadZeroes ( long val ) { if ( val == 0 ) return EMPTY_BYTE_ARRAY ; byte [ ] data = ByteBuffer . allocate ( 8 ) . putLong ( val ) . array ( ) ; return stripLeadingZeroes ( data ) ; }
Converts a long value into a byte array .
17,130
public static String nibblesToPrettyString ( byte [ ] nibbles ) { StringBuilder builder = new StringBuilder ( ) ; for ( byte nibble : nibbles ) { final String nibbleString = oneByteToHexString ( nibble ) ; builder . append ( "\\x" ) . append ( nibbleString ) ; } return builder . toString ( ) ; }
Turn nibbles to a pretty looking output string
17,131
public static int numBytes ( String val ) { BigInteger bInt = new BigInteger ( val ) ; int bytes = 0 ; while ( ! bInt . equals ( BigInteger . ZERO ) ) { bInt = bInt . shiftRight ( 8 ) ; ++ bytes ; } if ( bytes == 0 ) ++ bytes ; return bytes ; }
Calculate the number of bytes need to encode the number
17,132
public static byte [ ] encodeDataList ( Object ... args ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; for ( Object arg : args ) { byte [ ] val = encodeValFor32Bits ( arg ) ; try { baos . write ( val ) ; } catch ( IOException e ) { throw new Error ( "Happen something that should never happen " , e ) ;...
encode the values and concatenate together
17,133
public static boolean increment ( byte [ ] bytes ) { final int startIndex = 0 ; int i ; for ( i = bytes . length - 1 ; i >= startIndex ; i -- ) { bytes [ i ] ++ ; if ( bytes [ i ] != 0 ) break ; } return ( i >= startIndex || bytes [ startIndex ] != 0 ) ; }
increment byte array as a number until max is reached
17,134
public static byte [ ] copyToArray ( BigInteger value ) { byte [ ] src = ByteUtil . bigIntegerToBytes ( value ) ; byte [ ] dest = ByteBuffer . allocate ( 32 ) . array ( ) ; System . arraycopy ( src , 0 , dest , dest . length - src . length , src . length ) ; return dest ; }
Utility function to copy a byte array into a new byte array with given size . If the src length is smaller than the given size the result will be left - padded with zeros .
17,135
public static byte [ ] xorAlignRight ( byte [ ] b1 , byte [ ] b2 ) { if ( b1 . length > b2 . length ) { byte [ ] b2_ = new byte [ b1 . length ] ; System . arraycopy ( b2 , 0 , b2_ , b1 . length - b2 . length , b2 . length ) ; b2 = b2_ ; } else if ( b2 . length > b1 . length ) { byte [ ] b1_ = new byte [ b2 . length ] ;...
XORs byte arrays of different lengths by aligning length of the shortest via adding zeros at beginning
17,136
public static byte [ ] hexStringToBytes ( String data ) { if ( data == null ) return EMPTY_BYTE_ARRAY ; if ( data . startsWith ( "0x" ) ) data = data . substring ( 2 ) ; return Hex . decode ( data ) ; }
Converts string hex representation to data bytes
17,137
public static MavenConfiguration getConfig ( final File settingsFile , final Properties props ) throws Exception { props . setProperty ( ServiceConstants . PID + MavenConstants . PROPERTY_SETTINGS_FILE , settingsFile . toURI ( ) . toASCIIString ( ) ) ; final MavenConfigurationImpl config = new MavenConfigurationImpl ( ...
Load settings . xml file and apply custom properties .
17,138
public static File getMavenHome ( ) throws Exception { final String command ; switch ( OS . current ( ) ) { case LINUX : case MAC : command = "mvn" ; break ; case WINDOWS : command = "mvn.bat" ; break ; default : throw new IllegalStateException ( "invalid o/s" ) ; } String pathVar = System . getenv ( "PATH" ) ; String ...
Discover maven home from executable on PATH using conventions .
17,139
public ZonedDateTime getZonedDateTime ( ) { return ZonedDateTime . of ( get ( ChronoField . YEAR ) , get ( ChronoField . MONTH_OF_YEAR ) , get ( ChronoField . DAY_OF_MONTH ) , get ( ChronoField . HOUR_OF_DAY ) , get ( ChronoField . MINUTE_OF_HOUR ) , get ( ChronoField . SECOND_OF_MINUTE ) , get ( ChronoField . NANO_OF_...
Returns ZonedDateTime created from latest update .
17,140
public void setMillis ( long millis ) { ZonedDateTime zonedDateTime = ZonedDateTime . ofInstant ( Instant . ofEpochMilli ( millis ) , ZoneOffset . UTC ) ; set ( zonedDateTime ) ; }
Sets time by using milli seconds from epoch .
17,141
public String getFileName ( String strFileName , String strPackage , CodeType codeType , boolean fullPath , boolean sourcePath ) { ProgramControl recProgramControl = ( ProgramControl ) this . getRecordOwner ( ) . getRecord ( ProgramControl . PROGRAM_CONTROL_FILE ) ; if ( recProgramControl == null ) recProgramControl = ...
Get the path to this file name .
17,142
private InputStream formatRawContent ( final Document document ) throws IOException { final String body = "<h1>" + escapeAndAddLineBreaks ( resolveTitle ( document ) ) + "</h1>" + "<p>" + escapeAndAddLineBreaks ( document . getContent ( ) ) + "</p>" ; return IOUtils . toInputStream ( body , StandardCharsets . UTF_8 ) ;...
Format the document s content for display in a browser
17,143
public void pollOnce ( ) throws IOException { MBeanAccessConnection connection = this . mBeanAccessConnectionFactory . createConnection ( ) ; Set < String > remainingQueues = new HashSet < > ( this . registry . keys ( ) ) ; try { ObjectName destinationPattern = this . jmxActiveMQUtil . getDestinationObjectName ( this ....
Poll for destinations and update the registry with new destinations found and clean out destinations not found and not existing on any broker .
17,144
protected void onFoundDestination ( String destName ) { if ( ( destName != null ) && ( ! destName . isEmpty ( ) ) ) { DestinationState destState = this . registry . putIfAbsent ( destName , new DestinationState ( destName , this . brokerId ) ) ; if ( destState != null ) { destState . putBrokerInfo ( this . brokerId , t...
For the destination represented by the named mbean add the destination to the registry .
17,145
public void set ( Object data , int iOpenMode ) throws DBException , RemoteException { Record record = this . getMainRecord ( ) ; int iOldOpenMode = record . getOpenMode ( ) ; try { Utility . getLogger ( ) . info ( "EJB Set" ) ; synchronized ( this . getTask ( ) ) { record . setOpenMode ( ( iOldOpenMode & ~ DBConstants...
Update the current record . This method has some wierd code to emulate the way behaviors are called on a write .
17,146
private Object getAtRow ( int iRowIndex ) throws DBException { try { Utility . getLogger ( ) . info ( "get row " + iRowIndex ) ; GridTable gridTable = this . getGridTable ( this . getMainRecord ( ) ) ; gridTable . getCurrentTable ( ) . getRecord ( ) . setEditMode ( Constants . EDIT_NONE ) ; Record record = ( Record ) g...
Retreive this relative record in the table . This method is used exclusively by the get method to read a single row of a grid table .
17,147
public org . jbundle . thin . base . db . FieldList makeFieldList ( String strFieldsToInclude ) throws RemoteException { synchronized ( this . getTask ( ) ) { FieldList fieldList = new FieldList ( null ) ; Record record = this . getMainRecord ( ) ; boolean bAllSelected = record . isAllSelected ( ) ; if ( SELECTED . equ...
Make a thin FieldList for this table .
17,148
public void cleanBuffer ( BaseBuffer buffer , Record record ) { Vector < Object > vector = ( Vector ) buffer . getPhysicalData ( ) ; int iCurrentIndex = 0 ; buffer . resetPosition ( ) ; int iFieldCount = record . getFieldCount ( ) ; for ( int iFieldSeq = Constants . MAIN_FIELD ; iFieldSeq <= iFieldCount + Constants . M...
Clean the buffer of fields that will change a field that has been modified by the client .
17,149
public int getMasterSlave ( ) { int iMasterSlave = super . getMasterSlave ( ) ; if ( iMasterSlave == RecordOwner . MASTER ) if ( this . getClass ( ) == org . jbundle . base . remote . db . TableSession . class ) return RecordOwner . SLAVE ; return iMasterSlave ; }
Is this recordowner the master or slave . The slave is typically the TableSessionObject that is created to manage a ClientTable .
17,150
public static Vector2 createVector ( double x , double y ) { Vector2 v = new Vector2Impl ( ) ; v . setX ( x ) ; v . setY ( y ) ; return v ; }
Creates and initializes a new 2D column vector .
17,151
public static Vector3 createVector ( double x , double y , double z ) { Vector3 v = new Vector3Impl ( ) ; v . setX ( x ) ; v . setY ( y ) ; v . setZ ( z ) ; return v ; }
Creates and initializes a new 3D column vector .
17,152
public static Vector4 createVector ( double x , double y , double z , double h ) { Vector4 v = new Vector4Impl ( ) ; v . setX ( x ) ; v . setY ( y ) ; v . setZ ( z ) ; v . setH ( h ) ; return v ; }
Creates and initializes a new 4D column vector .
17,153
public static Vector createVector ( int dimension ) { if ( dimension <= 0 ) throw new IllegalArgumentException ( ) ; switch ( dimension ) { case 2 : return createVector2 ( ) ; case 3 : return createVector3 ( ) ; case 4 : return createVector4 ( ) ; default : return new VectorImpl ( dimension ) ; } }
Creates a new column vector with all elements initialized to 0 .
17,154
public static Matrix createMatrix ( int rowCount , int colCount ) { if ( rowCount <= 0 || colCount <= 0 ) throw new IllegalArgumentException ( ) ; if ( colCount == 1 ) return createVector ( rowCount ) ; else if ( rowCount == 2 && colCount == 2 ) return createMatrix2 ( ) ; else if ( rowCount == 3 && colCount == 3 ) retu...
Creates a new matrix with all elements initialized to 0 .
17,155
private void setHeaders ( HttpServletResponse response ) { setHeader ( response , "Expires" , Long . valueOf ( System . currentTimeMillis ( ) + cacheTimeoutMs ) . toString ( ) ) ; setHeader ( response , "Cache-Control" , "public, must-revalidate, max-age=" + cacheTimeout ) ; setHeader ( response , "Pragma" , "public" )...
Set Cache headers .
17,156
public void command ( String ... args ) { addArgument ( File . class , "xml-config-file-path" ) ; super . command ( args ) ; configFile = getArgument ( "xml-config-file-path" ) ; readConfig ( ) ; if ( watch ) { Thread thread = new Thread ( this , configFile + " watcher" ) ; thread . start ( ) ; } }
Resolves command line arguments and starts watch thread if watch was true in constructor .
17,157
public Object getValue ( String name ) { Object value = super . getValue ( name ) ; if ( value != null ) { return value ; } else { return configMap . get ( name ) ; } }
Overrides getValue so that also config file values are returned .
17,158
public static String getStringWithRestOrClasspathOrFilePath ( String resourceWithRestOrClasspathOrFilePath , String charsetName ) { return resourceWithRestOrClasspathOrFilePath . startsWith ( HTTP ) ? HttpGetRequester . getResponseAsString ( resourceWithRestOrClasspathOrFilePath , charsetName ) : JMResources . getStrin...
Gets string with rest or classpath or file path .
17,159
public static List < String > readLinesWithRestOrClasspathOrFilePath ( String resourceWithRestOrClasspathOrFilePath , String charsetName ) { return JMCollections . buildListByLine ( getStringWithRestOrClasspathOrFilePath ( resourceWithRestOrClasspathOrFilePath , charsetName ) ) ; }
Read lines with rest or classpath or file path list .
17,160
public static String getStringWithRestOrFilePathOrClasspath ( String resourceWithRestOrFilePathOrClasspath , String charsetName ) { return resourceWithRestOrFilePathOrClasspath . startsWith ( HTTP ) ? HttpGetRequester . getResponseAsString ( resourceWithRestOrFilePathOrClasspath , charsetName ) : JMResources . getStrin...
Gets string with rest or file path or classpath .
17,161
public static List < String > readLinesWithRestOrFilePathOrClasspath ( String resourceWithRestOrFilePathOrClasspath , String charsetName ) { return JMCollections . buildListByLine ( getStringWithRestOrClasspathOrFilePath ( resourceWithRestOrFilePathOrClasspath , charsetName ) ) ; }
Read lines with rest or file path or classpath list .
17,162
protected void setupForExpandedWar ( ) { webapp . setServerClasses ( getServerClasses ( ) ) ; webapp . setDescriptor ( webapp + "/WEB-INF/web.xml" ) ; webapp . setResourceBase ( resourceBase ) ; webapp . setParentLoaderPriority ( false ) ; }
Setup for an expanded webapp with resource base as a relative path .
17,163
public void setBaseId ( byte [ ] baseId ) { if ( baseId == null ) { throw new IllegalArgumentException ( "Transmitter base ID cannot be null." ) ; } if ( baseId . length != TRANSMITTER_ID_SIZE ) { throw new IllegalArgumentException ( String . format ( "Transmitter base ID must be %d bytes long." , Integer . valueOf ( T...
Sets the base address for this transmitter .
17,164
public void setMask ( byte [ ] mask ) { if ( mask == null ) { throw new IllegalArgumentException ( "Transmitter mask cannot be null." ) ; } if ( mask . length != TRANSMITTER_ID_SIZE ) { throw new IllegalArgumentException ( String . format ( "Transmitter mask must be %d bytes long." , Integer . valueOf ( TRANSMITTER_ID_...
Sets the bit mask for this transmitter .
17,165
public void init ( ImageIcon imageBackground , Color colorBackground , Container compAnchor ) { m_imageBackground = imageBackground ; m_compAnchor = compAnchor ; if ( colorBackground != null ) this . setBackground ( colorBackground ) ; }
Constructor - Initialize this background .
17,166
public void calcOffset ( Container compAnchor , Point offset ) { offset . x = 0 ; offset . y = 0 ; Container parent = this ; while ( parent != null ) { offset . x -= parent . getLocation ( ) . x ; offset . y -= parent . getLocation ( ) . y ; parent = parent . getParent ( ) ; if ( parent == compAnchor ) return ; } offse...
Calculate the offset from the component to this component .
17,167
public static String number ( int numberOfDigits ) { if ( numberOfDigits < 1 ) { return "" ; } StringBuffer sb = new StringBuffer ( randomIntBetweenTwoNumbers ( 1 , 9 ) + "" ) ; if ( numberOfDigits == 1 ) { return sb . toString ( ) ; } char [ ] chars = "123456789" . toCharArray ( ) ; String secondHalf = RandomStringUti...
random number string without 0 being possible as the first digit
17,168
public static String randomNumberString ( int length ) { char [ ] chars = "0123456789" . toCharArray ( ) ; return RandomStringUtils . random ( length , 0 , 9 , false , false , chars ) ; }
random number string with zero possible in any position
17,169
public static int randomIntBetweenTwoNumbers ( int min , int max ) { int number = RandomUtils . nextInt ( max - min ) ; return number + min ; }
generate a random number between 2 numbers - inclusive
17,170
private String getDateSuffix ( ) { Calendar cal = Calendar . getInstance ( ) ; int year = cal . get ( Calendar . YEAR ) ; int month = cal . get ( Calendar . MONTH ) ; int day = cal . get ( Calendar . DAY_OF_MONTH ) ; int hour = cal . get ( Calendar . HOUR_OF_DAY ) ; int minute = cal . get ( Calendar . MINUTE ) ; int se...
Returns a date suffix string
17,171
private File createFolder ( ITestResult tr ) throws IOException { String path = ListenerGateway . getParameter ( SCREENSHOT_FOLDER ) ; if ( path == null || path . isEmpty ( ) ) { path = "." + File . separatorChar + "screenshots" ; } if ( tr != null ) { path += File . separatorChar + tr . getMethod ( ) . getTestClass ( ...
Generate if it doesn t exist the folder for screenshots taken . The user can pass this information by parameter in the testng . xml . If it s not passed this information the folder is created in the current location with the name screenshots .
17,172
private File createFile ( ITestResult tr , File parentFolder ) { String path ; if ( tr != null ) { path = String . format ( "%s%c%s.png" , parentFolder . getAbsolutePath ( ) , File . separatorChar , tr . getName ( ) , getDateSuffix ( ) ) ; } else { path = String . format ( "%s%ctest_%d.png" , parentFolder . getAbsolute...
Generate the file to save the screenshot taken .
17,173
public int getMessageLength ( ) { int messageLength = 1 ; messageLength += 4 ; if ( this . aliases != null ) { for ( AttributeAlias alias : this . aliases ) { messageLength += 8 ; try { messageLength += alias . attributeName . getBytes ( "UTF-16BE" ) . length ; } catch ( UnsupportedEncodingException e ) { log . error (...
Returns the length of this message as encoded according to the Client - World Model protocol .
17,174
public void removeTraceWriter ( String nameCriteria ) { for ( ITraceWriter tw : getTraceWriters ( ) ) { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "Trying to remove a trace writer. Looking for [" + nameCriteria + "] found [" + tw . getName ( ) + "]" ) ; if ( tw . getName ( ) . equals ( nameCriteria ) ) getTraceWrit...
Remove any trace writers that are writing to the given window name .
17,175
public static final String read ( ReadableByteChannel ch , int length , Charset charset ) throws IOException { return new String ( read ( ch , length ) , charset ) ; }
Read length bytes from channel and constructs a String using given charset . Throws EOFException if couldn t read length bytes because of eof .
17,176
public static final byte [ ] read ( ReadableByteChannel ch , int length ) throws IOException { ByteBuffer bb = ByteBuffer . allocate ( length ) ; readAll ( ch , bb ) ; if ( bb . hasRemaining ( ) ) { throw new EOFException ( "couldn't read " + length + " bytes" ) ; } return bb . array ( ) ; }
Read length bytes from channel . Throws EOFException if couldn t read length bytes because of eof .
17,177
public static final void write ( WritableByteChannel ch , String text , Charset charset ) throws IOException { write ( ch , text . getBytes ( charset ) ) ; }
Writes string bytes to channel using charset .
17,178
public static final void write ( WritableByteChannel ch , byte [ ] bytes ) throws IOException { write ( ch , bytes , 0 , bytes . length ) ; }
Writes bytes to channel
17,179
public static final void write ( WritableByteChannel ch , byte [ ] bytes , int offset , int length ) throws IOException { ByteBuffer bb = ByteBuffer . allocate ( length ) ; bb . put ( bytes , offset , length ) ; bb . flip ( ) ; writeAll ( ch , bb ) ; }
Writes length bytes to channel starting at offset
17,180
public static final int readAll ( ReadableByteChannel ch , ByteBuffer dst ) throws IOException { int count = 0 ; while ( dst . hasRemaining ( ) ) { int rc = ch . read ( dst ) ; if ( rc == - 1 ) { if ( count > 0 ) { return count ; } return - 1 ; } count += rc ; } return count ; }
Read channel until dst has remaining or eof .
17,181
public static final void align ( SeekableByteChannel ch , long align ) throws IOException { ch . position ( alignedPosition ( ch , align ) ) ; }
Increments position so that position mod align == 0
17,182
public static final long alignedPosition ( SeekableByteChannel ch , long align ) throws IOException { long position = ch . position ( ) ; long mod = position % align ; if ( mod > 0 ) { return position + align - mod ; } else { return position ; } }
Returns Incremented position so that position mod align == 0 but doesn t change channels position .
17,183
public static final void skip ( SeekableByteChannel ch , long skip ) throws IOException { ch . position ( ch . position ( ) + skip ) ; }
Adds skip to position .
17,184
public static void writeAll ( GatheringByteChannel ch , ByteBuffer [ ] bbs , int offset , int length ) throws IOException { long all = 0 ; for ( int ii = 0 ; ii < length ; ii ++ ) { all += bbs [ offset + ii ] . remaining ( ) ; } int count = 0 ; while ( all > 0 ) { long rc = ch . write ( bbs , offset , length ) ; if ( r...
Attempts to write all remaining data in bbs .
17,185
public static void writeAll ( WritableByteChannel ch , ByteBuffer bb ) throws IOException { int count = 0 ; while ( bb . hasRemaining ( ) ) { int rc = ch . write ( bb ) ; if ( rc == 0 ) { count ++ ; } if ( count > 100 ) { throw new IOException ( "Couldn't write all." ) ; } } }
Writes to ch until no remaining left or throws IOException
17,186
public boolean isFocusTarget ( int col ) { if ( this . getGridModel ( ) != null ) if ( this . getGridModel ( ) . getColumnClass ( col ) == String . class ) return true ; return false ; }
Is this control a focus target?
17,187
public void repaintCurrentRow ( ) { m_jTableScreen . removeEditor ( ) ; int iRow = m_jTableScreen . getSelectedRow ( ) ; int iColumn = m_jTableScreen . getColumnCount ( ) - 1 ; Rectangle rect = m_jTableScreen . getCellRect ( iRow , iColumn , false ) ; rect . width = rect . width + rect . x ; rect . x = 0 ; m_jTableScre...
Repaint the current row .
17,188
public FieldList makeSelectedRowCurrent ( ) { FieldList record = null ; int iRow = m_jTableScreen . getSelectedRow ( ) ; if ( iRow != - 1 ) record = m_thinTableModel . makeRowCurrent ( iRow , false ) ; if ( record == null ) { record = this . getFieldList ( ) ; try { record . getTable ( ) . addNew ( ) ; } catch ( DBExce...
Make the currently selected row current or create a newrecord is no current selection .
17,189
public void columnSelectionChanged ( ListSelectionEvent e ) { if ( ! e . getValueIsAdjusting ( ) ) { int iColumn = m_jTableScreen . getSelectedColumn ( ) ; if ( iColumn != - 1 ) if ( m_thinTableModel != null ) { Convert converter = m_thinTableModel . getFieldInfo ( iColumn ) ; BaseApplet baseApplet = this . getBaseAppl...
The column selection changed - display the correct tooltip .
17,190
public void scanTemplates ( LineNumberReader reader ) { try { String string ; boolean bTemplate = false ; while ( ( string = reader . readLine ( ) ) != null ) { if ( string . indexOf ( "<xsl:template " ) != - 1 ) bTemplate = true ; if ( bTemplate ) { int iStart = string . indexOf ( "match=\"" ) + 7 ; int iEnd = string ...
ScanTemplates Method .
17,191
public void addMatch ( String strMatch , boolean bAddAll ) { m_setMatches . add ( strMatch ) ; if ( bAddAll ) if ( m_parent instanceof XslImportScanListener ) ( ( XslImportScanListener ) m_parent ) . addMatch ( strMatch , bAddAll ) ; System . out . println ( "match " + strMatch ) ; }
AddMatch Method .
17,192
public void addName ( String strName , boolean bAddAll ) { m_setNames . add ( strName ) ; if ( bAddAll ) if ( m_parent instanceof XslImportScanListener ) ( ( XslImportScanListener ) m_parent ) . addName ( strName , bAddAll ) ; System . out . println ( "name " + strName ) ; }
AddName Method .
17,193
public boolean isMatch ( String strMatch ) { if ( m_setMatches . contains ( strMatch ) ) return true ; if ( m_parent instanceof XslImportScanListener ) return ( ( XslImportScanListener ) m_parent ) . isMatch ( strMatch ) ; return false ; }
IsMatch Method .
17,194
public boolean isName ( String strName ) { if ( m_setNames . contains ( strName ) ) return true ; if ( m_parent instanceof XslImportScanListener ) return ( ( XslImportScanListener ) m_parent ) . isName ( strName ) ; return false ; }
IsName Method .
17,195
public void writeImport ( String strFilename ) { strFilename = this . getProperty ( org . jbundle . app . program . manual . convert . ConvertCode . DIR_PREFIX ) + this . getProperty ( org . jbundle . app . program . manual . convert . ConvertCode . SOURCE_DIR ) + '/' + strFilename ; System . out . println ( strFilenam...
WriteImport Method .
17,196
public void writeField ( String field ) throws IOException { if ( this . newLine ) { this . newLine = false ; } else { this . write ( ',' ) ; } if ( ( field == null ) || ( field . length ( ) == 0 ) ) { return ; } Matcher matcher = escapePattern . matcher ( field ) ; if ( matcher . find ( ) ) { this . write ( '"' ) ; th...
Write a field to the output quoting as necessary and adding comma separators between fields .
17,197
public void putLotDownloadList ( int id ) { ClientResource resource = new ClientResource ( Route . DOWNLOADLIST_LOT . url ( id ) ) ; resource . setChallengeResponse ( this . auth . toChallenge ( ) ) ; resource . get ( ) ; }
Adds a file to the user s download list
17,198
public void deleteLotDownloadList ( int id ) { ClientResource resource = new ClientResource ( Route . DOWNLOADLIST_LOT . url ( id ) ) ; resource . setChallengeResponse ( this . auth . toChallenge ( ) ) ; resource . delete ( ) ; }
Removes a file from the user s download list
17,199
public boolean supports ( TherianContext context , Copy < ? extends SOURCE , ? extends TARGET > copy ) { if ( context . eval ( ImmutableCheck . of ( copy . getTargetPosition ( ) ) ) . booleanValue ( ) && isRejectImmutable ( ) ) { return false ; } return TypeUtils . isAssignable ( copy . getSourceType ( ) . getType ( ) ...
By default rejects immutable target positions and ensures that type parameters are compatible .