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 ) ; MultipartEntityBuilder builder = MultipartEntityBuilder . create ( ) ; ContentBody body = new FileBody ( file ) ; FormBodyPart part = FormBodyPartBuilder . create ( "filedata" , body ) . build ( ) ; builder . addPart ( part ) ; HttpEntity entity = builder . build ( ) ; request . setEntity ( entity ) ; consumer . sign ( request ) ; httpClient = HttpClientBuilder . create ( ) . build ( ) ; HttpResponse response = httpClient . execute ( request ) ; HttpEntity responseEntity = response . getEntity ( ) ; String json = EntityUtils . toString ( responseEntity ) ; org . biouno . figshare . v1 . model . File uploadedFile = readFileFromJson ( json ) ; return uploadedFile ; } catch ( OAuthCommunicationException e ) { throw new FigShareClientException ( "Failed to get articles: " + e . getMessage ( ) , e ) ; } catch ( OAuthMessageSignerException e ) { throw new FigShareClientException ( "Failed to get articles: " + e . getMessage ( ) , e ) ; } catch ( OAuthExpectationFailedException e ) { throw new FigShareClientException ( "Failed to get articles: " + e . getMessage ( ) , e ) ; } catch ( ClientProtocolException e ) { throw new FigShareClientException ( "Failed to get articles: " + e . getMessage ( ) , e ) ; } catch ( IOException e ) { throw new FigShareClientException ( "Failed to get articles: " + e . getMessage ( ) , e ) ; } }
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 -> builder . put ( kv . getKey ( ) , ImmutableList . copyOf ( kv . getValue ( ) ) ) ) ; } return new Post ( id , slug , title , excerpt , content , authorId , author , publishTimestamp , modifiedTimestamp , status , parentId , guid , commentCount , metadata , type , mimeType , builder . build ( ) , children ) ; }
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 ( children ) : ImmutableList . of ( ) ) ; }
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 . getClassService ( ) . getClassFinder ( null ) != null ) url = ClassServiceUtility . getClassService ( ) . getClassFinder ( null ) . findResourceURL ( splashImage , null ) ; Container container = null ; Splash . splash ( container , url ) ; String main = Splash . getParam ( args , MAIN ) ; if ( ( main == null ) || ( main . length ( ) == 0 ) ) main = ROOT_PACKAGE + "Thin" ; else if ( main . charAt ( 0 ) == '.' ) main = ROOT_PACKAGE + main . substring ( 1 ) ; Splash . invokeMain ( main , args ) ; Splash . disposeSplash ( ) ; }
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 ) clazz = Class . forName ( className ) ; Method method = clazz . getMethod ( "main" , PARAMS ) ; Object [ ] objArgs = new Object [ ] { args } ; method . invoke ( null , objArgs ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } }
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 [ 2 * i2 + 1 ] ; double x3 = data [ 2 * i3 ] ; double y3 = data [ 2 * i3 + 1 ] ; if ( Vectors . isClockwise ( x1 , y1 , x2 , y2 , x3 , y3 ) ) { return false ; } } return true ; }
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 Hashtable < String , String > ( 11 ) ; props . put ( LdapContext . INITIAL_CONTEXT_FACTORY , "com.sun.jndi.ldap.LdapCtxFactory" ) ; props . put ( LdapContext . PROVIDER_URL , url . toString ( ) ) ; props . put ( LdapContext . SECURITY_AUTHENTICATION , "simple" ) ; props . put ( LdapContext . SECURITY_PRINCIPAL , additionalBindDN ) ; props . put ( LdapContext . SECURITY_CREDENTIALS , additionalBindPassword ) ; return props ; }
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 ( iIndexEnd == - 1 ) break ; String strKey = strMessage . substring ( iIndex , iIndexEnd ) ; if ( strKey . indexOf ( ' ' ) != - 1 ) strKey = strKey . substring ( strKey . lastIndexOf ( ' ' ) + 1 ) ; iIndex = this . getStartNextPropertyKey ( iIndexEnd + 1 , strMessage ) ; if ( iIndex >= iIndexEnd ) { for ( iIndexEnd = iIndexEnd + 1 ; iIndexEnd < iIndex ; iIndexEnd ++ ) { char chChar = strMessage . charAt ( iIndexEnd ) ; if ( ! this . isLeadingWhitespace ( chChar ) ) break ; } if ( iIndex == - 1 ) break ; for ( int i = iIndex - 1 ; i >= iIndexEnd ; i -- ) { char chChar = strMessage . charAt ( i ) ; if ( ! this . isLeadingWhitespace ( chChar ) ) { String strValue = strMessage . substring ( iIndexEnd , i + 1 ) ; this . putProperty ( properties , strKey , strValue ) ; break ; } } } } return properties ; }
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 = strMessage . indexOf ( END_OF_KEY_CHAR , iIndex ) ; if ( iNextProperty == - 1 ) return - 1 ; for ( int i = iNextProperty - 1 ; i >= 0 ; i -- ) { char chChar = strMessage . charAt ( i ) ; if ( this . isEndChar ( chChar ) ) { for ( int k = i + 1 ; k < strMessage . length ( ) ; k ++ ) { chChar = strMessage . charAt ( k ) ; if ( ! this . isLeadingWhitespace ( chChar ) ) { return k ; } } } } return - 1 ; }
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 ) ; } } return baos . toByteArray ( ) ; }
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 ] ; System . arraycopy ( b1 , 0 , b1_ , b2 . length - b1 . length , b1 . length ) ; b1 = b1_ ; } return xor ( b1 , b2 ) ; }
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 ( new PropertiesPropertyResolver ( props ) , ServiceConstants . PID ) ; final MavenSettings settings = new MavenSettingsImpl ( settingsFile . toURI ( ) . toURL ( ) ) ; config . setSettings ( settings ) ; return config ; }
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 [ ] pathArray = pathVar . split ( File . pathSeparator ) ; for ( String path : pathArray ) { File file = new File ( path , command ) ; if ( file . exists ( ) && file . isFile ( ) && file . canExecute ( ) ) { File exec = file . getCanonicalFile ( ) ; File home = exec . getParentFile ( ) . getParentFile ( ) ; return home ; } } throw new IllegalStateException ( "Maven home not found." ) ; }
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_SECOND ) , clock . getZone ( ) ) ; }
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 = new ProgramControl ( this . findRecordOwner ( ) ) ; String packagePath = DBConstants . BLANK ; if ( strPackage != null ) { strPackage = this . getFullPackage ( codeType , strPackage ) ; packagePath = strPackage . replace ( '.' , '/' ) + "/" ; } String strFileRoot = DBConstants . BLANK ; if ( fullPath ) { strFileRoot = recProgramControl . getBasePath ( ) ; if ( ! strFileRoot . endsWith ( "/" ) ) strFileRoot += "/" ; } String strSourcePath = null ; if ( sourcePath ) { strSourcePath = recProgramControl . getField ( ProgramControl . SOURCE_DIRECTORY ) . toString ( ) ; if ( codeType == CodeType . RESOURCE_PROPERTIES ) if ( ! recProgramControl . getField ( ProgramControl . RESOURCES_DIRECTORY ) . isNull ( ) ) strSourcePath = recProgramControl . getField ( ProgramControl . RESOURCES_DIRECTORY ) . toString ( ) ; } else strSourcePath = recProgramControl . getField ( ProgramControl . CLASS_DIRECTORY ) . toString ( ) ; if ( ( this . getEditMode ( ) == DBConstants . EDIT_CURRENT ) || ( this . getEditMode ( ) == DBConstants . EDIT_IN_PROGRESS ) ) { String strSrcPath = this . getPath ( codeType , false ) ; if ( strSrcPath . length ( ) > 0 ) { if ( ! strSrcPath . endsWith ( "/" ) ) strSrcPath += "/" ; if ( ! strSrcPath . endsWith ( strSourcePath ) ) strSourcePath = strSrcPath + strSourcePath ; else strSourcePath = strSrcPath ; } } if ( strFileName == null ) strFileName = DBConstants . BLANK ; if ( strFileName . length ( ) > 0 ) if ( strFileName . indexOf ( "." ) == - 1 ) { if ( codeType == CodeType . RESOURCE_PROPERTIES ) strFileName = strFileName + ".properties" ; else strFileName = strFileName + ".java" ; } strFileName = strFileRoot + strSourcePath + packagePath + strFileName ; return strFileName ; }
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 . brokerName , "*" , this . destinationType ) ; Set < ObjectName > found = connection . queryNames ( destinationPattern , null ) ; for ( ObjectName oneDestOName : found ) { String destName = this . jmxActiveMQUtil . extractDestinationName ( oneDestOName ) ; this . onFoundDestination ( destName ) ; remainingQueues . remove ( destName ) ; } for ( String missingQueue : remainingQueues ) { DestinationState destState = this . registry . get ( missingQueue ) ; if ( destState != null ) { if ( ! destState . existsAnyBroker ( ) ) { this . registry . remove ( missingQueue ) ; } else { destState . putBrokerInfo ( this . brokerId , false ) ; } } } } catch ( MalformedObjectNameException monExc ) { throw new RuntimeException ( "unexpected object name failure for destinationType=" + this . destinationType , monExc ) ; } finally { this . safeClose ( connection ) ; } }
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 , true ) ; } } }
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 . LOCK_TYPE_MASK ) | ( iOpenMode & DBConstants . LOCK_TYPE_MASK ) ) ; if ( record . getEditMode ( ) == Constants . EDIT_CURRENT ) record . edit ( ) ; Record recordBase = record . getTable ( ) . getCurrentTable ( ) . getRecord ( ) ; int iFieldTypes = this . getFieldTypes ( recordBase ) ; int iErrorCode = this . moveBufferToFields ( data , iFieldTypes , recordBase ) ; if ( iErrorCode != DBConstants . NORMAL_RETURN ) ; if ( DBConstants . TRUE . equals ( record . getTable ( ) . getProperty ( DBParams . SUPRESSREMOTEDBMESSAGES ) ) ) record . setSupressRemoteMessages ( true ) ; record . getTable ( ) . set ( recordBase ) ; } } catch ( DBException ex ) { throw ex ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; throw new DBException ( ex . getMessage ( ) ) ; } finally { record . setSupressRemoteMessages ( false ) ; this . getMainRecord ( ) . setOpenMode ( iOldOpenMode ) ; } }
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 ) gridTable . get ( iRowIndex ) ; int iRecordStatus = DBConstants . RECORD_NORMAL ; if ( record == null ) { if ( iRowIndex >= 0 ) iRecordStatus = DBConstants . RECORD_AT_EOF ; else iRecordStatus = DBConstants . RECORD_AT_BOF ; } else { if ( record . getEditMode ( ) == DBConstants . EDIT_NONE ) iRecordStatus = DBConstants . RECORD_NEW ; if ( record . getEditMode ( ) == DBConstants . EDIT_ADD ) iRecordStatus = DBConstants . RECORD_NEW ; } if ( iRecordStatus == DBConstants . NORMAL_RETURN ) { Record recordBase = this . getMainRecord ( ) . getTable ( ) . getCurrentTable ( ) . getRecord ( ) ; int iFieldTypes = this . getFieldTypes ( recordBase ) ; BaseBuffer buffer = new VectorBuffer ( null , iFieldTypes ) ; buffer . fieldsToBuffer ( recordBase , iFieldTypes ) ; return buffer . getPhysicalData ( ) ; } else return new Integer ( iRecordStatus ) ; } catch ( DBException ex ) { throw ex ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; throw new DBException ( ex . getMessage ( ) ) ; } }
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 . equalsIgnoreCase ( strFieldsToInclude ) ) bAllSelected = false ; if ( bAllSelected ) m_iFieldTypes = BaseBuffer . PHYSICAL_FIELDS ; else m_iFieldTypes = BaseBuffer . SELECTED_FIELDS ; if ( SELECTED . equalsIgnoreCase ( strFieldsToInclude ) ) m_iFieldTypes = BaseBuffer . SELECTED_FIELDS ; for ( int iFieldSeq = 0 ; iFieldSeq < record . getFieldCount ( ) ; iFieldSeq ++ ) { BaseField field = record . getField ( iFieldSeq ) ; if ( ( m_iFieldTypes == BaseBuffer . PHYSICAL_FIELDS ) || ( m_iFieldTypes == BaseBuffer . DATA_FIELDS ) ) if ( field . isVirtual ( ) ) continue ; if ( ( m_iFieldTypes == BaseBuffer . DATA_FIELDS ) || ( m_iFieldTypes == BaseBuffer . SELECTED_FIELDS ) ) if ( ! field . isSelected ( ) ) continue ; FieldInfo fieldInfo = new FieldInfo ( fieldList , field . getFieldName ( ) , field . getMaxLength ( ) , field . getFieldDesc ( ) , field . getDefault ( ) ) ; fieldInfo . setDataClass ( field . getDataClass ( ) ) ; } int iKeyFieldSeq = 0 ; { KeyArea keyArea = record . getKeyArea ( iKeyFieldSeq ) ; KeyAreaInfo keyAreaInfo = new KeyAreaInfo ( fieldList , keyArea . getUniqueKeyCode ( ) , keyArea . getKeyName ( ) ) ; int iKeyField = 0 ; keyAreaInfo . addKeyField ( keyArea . getField ( iKeyField ) . getFieldName ( ) , keyArea . getKeyOrder ( iKeyField ) ) ; } return fieldList ; } }
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 . MAIN_FIELD - 1 ; iFieldSeq ++ ) { BaseField field = record . getField ( iFieldSeq ) ; if ( ! buffer . skipField ( field ) ) { if ( field . isModified ( ) ) vector . set ( iCurrentIndex , BaseBuffer . DATA_SKIP ) ; iCurrentIndex ++ ; } } }
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 ) return createMatrix3 ( ) ; else return new MatrixImpl ( rowCount , colCount ) ; }
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 . getStringWithClasspathOrFilePath ( resourceWithRestOrClasspathOrFilePath , charsetName ) ; }
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 . getStringWithFilePathOrClasspath ( resourceWithRestOrFilePathOrClasspath , charsetName ) ; }
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 ( TRANSMITTER_ID_SIZE ) ) ) ; } this . baseId = baseId ; }
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_SIZE ) ) ) ; } this . mask = mask ; }
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 ; } offset . x = 0 ; offset . y = 0 ; }
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 = RandomStringUtils . random ( numberOfDigits - 1 , 0 , 8 , false , false , chars ) ; return sb . append ( secondHalf ) . toString ( ) ; }
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 second = cal . get ( Calendar . SECOND ) ; return String . format ( "-%4d-%02d-%02d_%02dh%02dm%02ds" , year , ( month + 1 ) , day , hour , minute , second ) ; }
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 ( ) . getName ( ) ; } File screenshotFolder = new File ( path ) ; if ( ! screenshotFolder . exists ( ) && ! screenshotFolder . mkdirs ( ) ) { throw new IOException ( ErrorMessages . ERROR_FOLDER_CANNOT_BE_CREATED ) ; } return screenshotFolder ; }
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 . getAbsolutePath ( ) , File . separatorChar , System . currentTimeMillis ( ) ) ; } return new File ( path ) ; }
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 ( "Unable to encode strings into UTF-16." ) ; e . printStackTrace ( ) ; } } } return messageLength ; }
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 ) ) getTraceWriters ( ) . remove ( tw ) ; } }
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 ( rc == 0 ) { count ++ ; } else { all -= rc ; } if ( count > 100 ) { throw new IOException ( "Couldn't write all." ) ; } } }
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_jTableScreen . repaint ( rect ) ; }
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 ( DBException ex ) { ex . printStackTrace ( ) ; } } return record ; }
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 . getBaseApplet ( ) ; if ( baseApplet != null ) { if ( converter instanceof FieldInfo ) baseApplet . setStatusText ( ( ( FieldInfo ) converter ) . getFieldTip ( ) ) ; else { TableColumnModel columnModel = m_jTableScreen . getTableHeader ( ) . getColumnModel ( ) ; TableColumn tableColumn = columnModel . getColumn ( iColumn ) ; TableCellEditor editor = tableColumn . getCellEditor ( ) ; String strTip = null ; if ( editor instanceof JComponent ) { String strName = ( ( JComponent ) editor ) . getName ( ) ; if ( strName != null ) { strName += Constants . TIP ; strTip = baseApplet . getString ( strName ) ; if ( strTip == strName ) strTip = baseApplet . getString ( ( ( JComponent ) editor ) . getName ( ) ) ; } } baseApplet . setStatusText ( strTip ) ; } String strLastError = baseApplet . getLastError ( 0 ) ; if ( ( strLastError != null ) && ( strLastError . length ( ) > 0 ) ) baseApplet . setStatusText ( strLastError ) ; } } } }
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 . indexOf ( '\"' , iStart ) ; if ( iStart != 6 ) if ( iEnd != - 1 ) { String strMatch = string . substring ( iStart , iEnd ) ; this . addMatch ( strMatch , false ) ; } iStart = string . indexOf ( "name=\"" ) + 6 ; iEnd = string . indexOf ( '\"' , iStart ) ; if ( iStart != 5 ) if ( iEnd != - 1 ) { String strName = string . substring ( iStart , iEnd ) ; this . addName ( strName , false ) ; } } if ( string . indexOf ( ">" ) != - 1 ) bTemplate = false ; } } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } }
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 ( strFilename ) ; try { File fileSource = new File ( strFilename ) ; FileInputStream fileIn = new FileInputStream ( fileSource ) ; InputStreamReader inStream = new InputStreamReader ( fileIn ) ; LineNumberReader reader = new LineNumberReader ( inStream ) ; PrintWriter dataOut = m_writer ; XslImportScanListener listener = new XslImportScanListener ( this , m_strSourcePrefix ) ; listener . setPrintWriter ( dataOut ) ; listener . setSourceFile ( fileSource ) ; Map < String , Object > oldProperties = m_parent . getProperties ( ) ; Map < String , Object > newProperties = new HashMap < String , Object > ( oldProperties ) ; m_parent . setProperties ( newProperties ) ; m_parent . setProperty ( ROOT_FILE , Boolean . FALSE . toString ( ) ) ; listener . moveSourceToDest ( reader , dataOut ) ; listener . free ( ) ; m_parent . setProperties ( oldProperties ) ; reader . close ( ) ; } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } }
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 ( '"' ) ; this . tmpBuffer . setLength ( 0 ) ; do { matcher . appendReplacement ( this . tmpBuffer , "\"\"" ) ; } while ( matcher . find ( ) ) ; matcher . appendTail ( this . tmpBuffer ) ; this . write ( this . tmpBuffer . toString ( ) ) ; this . write ( '"' ) ; return ; } matcher = specialCharsPattern . matcher ( field ) ; if ( matcher . find ( ) ) { this . write ( '"' ) ; this . write ( field ) ; this . write ( '"' ) ; return ; } this . append ( field ) ; }
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 ( ) , getSourceBound ( ) ) && TypeUtils . isAssignable ( copy . getTargetType ( ) . getType ( ) , getTargetBound ( ) ) ; }
By default rejects immutable target positions and ensures that type parameters are compatible .