idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
36,600
@ SuppressWarnings ( "resource" ) protected DatabaseConnection makeConnection ( Logger logger ) throws SQLException { Properties properties = new Properties ( ) ; if ( username != null ) { properties . setProperty ( "user" , username ) ; } if ( password != null ) { properties . setProperty ( "password" , password ) ; } DatabaseConnection connection = new JdbcDatabaseConnection ( DriverManager . getConnection ( url , properties ) ) ; connection . setAutoCommit ( true ) ; if ( connectionProxyFactory != null ) { connection = connectionProxyFactory . createProxy ( connection ) ; } logger . debug ( "opened connection to {} got #{}" , url , connection . hashCode ( ) ) ; return connection ; }
Make a connection to the database .
36,601
public void initialize ( ) throws SQLException { if ( ! Boolean . parseBoolean ( System . getProperty ( AUTO_CREATE_TABLES ) ) ) { return ; } if ( configuredDaos == null ) { throw new SQLException ( "configuredDaos was not set in " + getClass ( ) . getSimpleName ( ) ) ; } for ( Dao < ? , ? > dao : configuredDaos ) { Class < ? > clazz = dao . getDataClass ( ) ; try { DatabaseTableConfig < ? > tableConfig = null ; if ( dao instanceof BaseDaoImpl ) { tableConfig = ( ( BaseDaoImpl < ? , ? > ) dao ) . getTableConfig ( ) ; } if ( tableConfig == null ) { tableConfig = DatabaseTableConfig . fromClass ( connectionSource . getDatabaseType ( ) , clazz ) ; } TableUtils . createTable ( connectionSource , tableConfig ) ; createdClasses . add ( tableConfig ) ; } catch ( Exception e ) { System . err . println ( "Was unable to auto-create table for " + clazz ) ; e . printStackTrace ( ) ; } } }
If you are using the Spring type wiring this should be called after all of the set methods .
36,602
private Number getIdColumnData ( ResultSet resultSet , ResultSetMetaData metaData , int columnIndex ) throws SQLException { int typeVal = metaData . getColumnType ( columnIndex ) ; switch ( typeVal ) { case Types . BIGINT : case Types . DECIMAL : case Types . NUMERIC : return ( Number ) resultSet . getLong ( columnIndex ) ; case Types . INTEGER : return ( Number ) resultSet . getInt ( columnIndex ) ; default : String columnName = metaData . getColumnName ( columnIndex ) ; throw new SQLException ( "Unexpected ID column type " + TypeValMapper . getSqlTypeForTypeVal ( typeVal ) + " (typeVal " + typeVal + ") in column " + columnName + "(#" + columnIndex + ") is not a number" ) ; } }
Return the id associated with the column .
36,603
public static int getTypeValForSqlType ( SqlType sqlType ) throws SQLException { int [ ] typeVals = typeToValMap . get ( sqlType ) ; if ( typeVals == null ) { throw new SQLException ( "SqlType is unknown to type val mapping: " + sqlType ) ; } if ( typeVals . length == 0 ) { throw new SQLException ( "SqlType does not have any JDBC type value mapping: " + sqlType ) ; } else { return typeVals [ 0 ] ; } }
Returns the primary type value associated with the SqlType argument .
36,604
public static SqlType getSqlTypeForTypeVal ( int typeVal ) { for ( Map . Entry < SqlType , int [ ] > entry : typeToValMap . entrySet ( ) ) { for ( int val : entry . getValue ( ) ) { if ( val == typeVal ) { return entry . getKey ( ) ; } } } return SqlType . UNKNOWN ; }
Returns the SqlType value associated with the typeVal argument . Can be slow - er .
36,605
public static boolean isColorValue ( final String sValue ) { final String sRealValue = StringHelper . trim ( sValue ) ; if ( StringHelper . hasNoText ( sRealValue ) ) return false ; return isRGBColorValue ( sRealValue ) || isRGBAColorValue ( sRealValue ) || isHSLColorValue ( sRealValue ) || isHSLAColorValue ( sRealValue ) || isHexColorValue ( sRealValue ) || ECSSColor . isDefaultColorName ( sRealValue ) || ECSSColorName . isDefaultColorName ( sRealValue ) || sRealValue . equals ( CCSSValue . CURRENTCOLOR ) || sRealValue . equals ( CCSSValue . TRANSPARENT ) ; }
Check if the passed string is any color value .
36,606
public static String getRGBColorValue ( final int nRed , final int nGreen , final int nBlue ) { return new StringBuilder ( 16 ) . append ( CCSSValue . PREFIX_RGB_OPEN ) . append ( getRGBValue ( nRed ) ) . append ( ',' ) . append ( getRGBValue ( nGreen ) ) . append ( ',' ) . append ( getRGBValue ( nBlue ) ) . append ( CCSSValue . SUFFIX_RGB_CLOSE ) . toString ( ) ; }
Get the passed values as CSS RGB color value
36,607
public static String getRGBAColorValue ( final int nRed , final int nGreen , final int nBlue , final float fOpacity ) { return new StringBuilder ( 24 ) . append ( CCSSValue . PREFIX_RGBA_OPEN ) . append ( getRGBValue ( nRed ) ) . append ( ',' ) . append ( getRGBValue ( nGreen ) ) . append ( ',' ) . append ( getRGBValue ( nBlue ) ) . append ( ',' ) . append ( getOpacityToUse ( fOpacity ) ) . append ( CCSSValue . SUFFIX_RGBA_CLOSE ) . toString ( ) ; }
Get the passed values as CSS RGBA color value
36,608
public void adjustBeginLineColumn ( final int nNewLine , final int newCol ) { int start = m_nTokenBegin ; int newLine = nNewLine ; int len ; if ( m_nBufpos >= m_nTokenBegin ) { len = m_nBufpos - m_nTokenBegin + m_nInBuf + 1 ; } else { len = m_nBufsize - m_nTokenBegin + m_nBufpos + 1 + m_nInBuf ; } int nIdx = 0 ; int j = 0 ; int nextColDiff = 0 ; int columnDiff = 0 ; while ( true ) { if ( nIdx >= len ) break ; j = start % m_nBufsize ; ++ start ; final int k = start % m_nBufsize ; if ( m_aBufLine [ j ] != m_aBufLine [ k ] ) break ; m_aBufLine [ j ] = newLine ; nextColDiff = columnDiff + m_aBufColumn [ k ] - m_aBufColumn [ j ] ; m_aBufColumn [ j ] = newCol + columnDiff ; columnDiff = nextColDiff ; nIdx ++ ; } if ( nIdx < len ) { m_aBufLine [ j ] = newLine ++ ; m_aBufColumn [ j ] = newCol + columnDiff ; while ( nIdx ++ < len ) { j = start % m_nBufsize ; ++ start ; final int k = start % m_nBufsize ; if ( m_aBufLine [ j ] != m_aBufLine [ k ] ) m_aBufLine [ j ] = newLine ++ ; else m_aBufLine [ j ] = newLine ; } } m_nLine = m_aBufLine [ j ] ; m_nColumn = m_aBufColumn [ j ] ; }
Method to adjust line and column numbers for the start of a token .
36,609
public static String unescapeURL ( final String sEscapedURL ) { int nIndex = sEscapedURL . indexOf ( URL_ESCAPE_CHAR ) ; if ( nIndex < 0 ) { return sEscapedURL ; } final StringBuilder aSB = new StringBuilder ( sEscapedURL . length ( ) ) ; int nPrevIndex = 0 ; do { aSB . append ( sEscapedURL , nPrevIndex , nIndex ) ; aSB . append ( sEscapedURL , nIndex + 1 , nIndex + 2 ) ; nPrevIndex = nIndex + 2 ; nIndex = sEscapedURL . indexOf ( URL_ESCAPE_CHAR , nPrevIndex ) ; } while ( nIndex >= 0 ) ; aSB . append ( sEscapedURL . substring ( nPrevIndex ) ) ; return aSB . toString ( ) ; }
Unescape all escaped characters in a CSS URL . All characters masked with a \\ character replaced .
36,610
public CSSSimpleValueWithUnit setValue ( final BigDecimal aValue ) { m_aValue = ValueEnforcer . notNull ( aValue , "Value" ) ; return this ; }
Set the numerical value .
36,611
public CSSSimpleValueWithUnit setUnit ( final ECSSUnit eUnit ) { m_eUnit = ValueEnforcer . notNull ( eUnit , "Unit" ) ; return this ; }
Set the unit type .
36,612
public CSSSimpleValueWithUnit add ( final BigDecimal aDelta ) { return new CSSSimpleValueWithUnit ( m_aValue . add ( aDelta ) , m_eUnit ) ; }
Get a new object with the same unit but an added value .
36,613
public CSSSimpleValueWithUnit substract ( final BigDecimal aDelta ) { return new CSSSimpleValueWithUnit ( m_aValue . subtract ( aDelta ) , m_eUnit ) ; }
Get a new object with the same unit but a subtracted value .
36,614
public CSSSimpleValueWithUnit multiply ( final BigDecimal aValue ) { return new CSSSimpleValueWithUnit ( m_aValue . multiply ( aValue ) , m_eUnit ) ; }
Get a new object with the same unit but a multiplied value .
36,615
public CSSSimpleValueWithUnit divide ( final BigDecimal aDivisor , final int nScale , final RoundingMode eRoundingMode ) { return new CSSSimpleValueWithUnit ( m_aValue . divide ( aDivisor , nScale , eRoundingMode ) , m_eUnit ) ; }
Get a new object with the same unit but an divided value .
36,616
public static String [ ] getRectValues ( final String sCSSValue ) { String [ ] ret = null ; final String sRealValue = StringHelper . trim ( sCSSValue ) ; if ( StringHelper . hasText ( sRealValue ) ) { ret = RegExHelper . getAllMatchingGroupValues ( PATTERN_CURRENT_SYNTAX , sRealValue ) ; if ( ret == null ) ret = RegExHelper . getAllMatchingGroupValues ( PATTERN_OLD_SYNTAX , sRealValue ) ; } return ret ; }
Get all the values from within a CSS rectangle definition .
36,617
public EChange removeRules ( final Predicate < ? super ICSSTopLevelRule > aFilter ) { return EChange . valueOf ( m_aRules . removeIf ( aFilter ) ) ; }
Remove all rules matching the passed predicate .
36,618
public CSSStyleRule getStyleRuleAtIndex ( final int nIndex ) { return m_aRules . getAtIndexMapped ( r -> r instanceof CSSStyleRule , nIndex , r -> ( CSSStyleRule ) r ) ; }
Get the style rule at the specified index .
36,619
public CSSUnknownRule getUnknownRuleAtIndex ( final int nIndex ) { return m_aRules . getAtIndexMapped ( r -> r instanceof CSSUnknownRule , nIndex , r -> ( CSSUnknownRule ) r ) ; }
Get the unknown rule at the specified index .
36,620
public CSSMediaQuery addMediaExpression ( final CSSMediaExpression aMediaExpression ) { ValueEnforcer . notNull ( aMediaExpression , "MediaExpression" ) ; m_aMediaExpressions . add ( aMediaExpression ) ; return this ; }
Append a media expression to the list .
36,621
public CSSMediaQuery addMediaExpression ( final int nIndex , final CSSMediaExpression aMediaExpression ) { ValueEnforcer . isGE0 ( nIndex , "Index" ) ; ValueEnforcer . notNull ( aMediaExpression , "MediaExpression" ) ; if ( nIndex >= getMediaExpressionCount ( ) ) m_aMediaExpressions . add ( aMediaExpression ) ; else m_aMediaExpressions . add ( nIndex , aMediaExpression ) ; return this ; }
Add a media expression to the list at the specified index .
36,622
public static void setDefaultInterpretErrorHandler ( final ICSSInterpretErrorHandler aDefaultErrorHandler ) { ValueEnforcer . notNull ( aDefaultErrorHandler , "DefaultErrorHandler" ) ; s_aRWLock . writeLocked ( ( ) -> s_aDefaultInterpretErrorHandler = aDefaultErrorHandler ) ; }
Set the default interpret error handler to handle interpretation errors in successfully parsed CSS .
36,623
public static boolean isValidCSS ( final File aFile , final Charset aCharset , final ECSSVersion eVersion ) { return isValidCSS ( new FileSystemResource ( aFile ) , aCharset , eVersion ) ; }
Check if the passed CSS file can be parsed without error
36,624
public static boolean isURLValue ( final String sValue ) { final String sRealValue = StringHelper . trim ( sValue ) ; if ( StringHelper . hasNoText ( sRealValue ) ) return false ; if ( sRealValue . equals ( CCSSValue . NONE ) ) return true ; return sRealValue . length ( ) > 5 && sRealValue . startsWith ( CCSSValue . PREFIX_URL_OPEN ) && sRealValue . endsWith ( CCSSValue . SUFFIX_URL_CLOSE ) ; }
Check if the passed CSS value is an URL value . This is either a URL starting with url ( or it is the string none .
36,625
public static String getURLValue ( final String sValue ) { if ( isURLValue ( sValue ) ) { return CSSParseHelper . trimUrl ( sValue ) ; } return null ; }
Extract the real URL contained in a CSS URL value .
36,626
public static boolean isCSSURLRequiringQuotes ( final String sURL ) { ValueEnforcer . notNull ( sURL , "URL" ) ; for ( final char c : sURL . toCharArray ( ) ) if ( ! isValidCSSURLChar ( c ) ) return true ; return false ; }
Check if any character inside the passed URL needs escaping .
36,627
public static String getEscapedCSSURL ( final String sURL , final char cQuoteChar ) { ValueEnforcer . notNull ( sURL , "URL" ) ; if ( sURL . indexOf ( cQuoteChar ) < 0 && sURL . indexOf ( CSSParseHelper . URL_ESCAPE_CHAR ) < 0 ) { return sURL ; } final StringBuilder aSB = new StringBuilder ( sURL . length ( ) * 2 ) ; for ( final char c : sURL . toCharArray ( ) ) { if ( c == cQuoteChar || c == CSSParseHelper . URL_ESCAPE_CHAR ) aSB . append ( CSSParseHelper . URL_ESCAPE_CHAR ) ; aSB . append ( c ) ; } return aSB . toString ( ) ; }
Internal method to escape a CSS URL . Because this method is only called for quoted URLs only the quote character itself needs to be quoted .
36,628
public CSSMediaRule addMediaQuery ( final CSSMediaQuery aMediaQuery ) { ValueEnforcer . notNull ( aMediaQuery , "MediaQuery" ) ; m_aMediaQueries . add ( aMediaQuery ) ; return this ; }
Add a new media query .
36,629
public CSSMediaRule addMediaQuery ( final int nIndex , final CSSMediaQuery aMediaQuery ) { ValueEnforcer . isGE0 ( nIndex , "Index" ) ; ValueEnforcer . notNull ( aMediaQuery , "MediaQuery" ) ; if ( nIndex >= getMediaQueryCount ( ) ) m_aMediaQueries . add ( aMediaQuery ) ; else m_aMediaQueries . add ( nIndex , aMediaQuery ) ; return this ; }
Add a media query at the specified index .
36,630
public static boolean isValidCSS ( final IReadableResource aRes , final Charset aFallbackCharset , final ECSSVersion eVersion ) { ValueEnforcer . notNull ( aRes , "Resource" ) ; ValueEnforcer . notNull ( aFallbackCharset , "FallbackCharset" ) ; ValueEnforcer . notNull ( eVersion , "Version" ) ; final Reader aReader = aRes . getReader ( aFallbackCharset ) ; if ( aReader == null ) { LOGGER . warn ( "Failed to open CSS reader " + aRes ) ; return false ; } return isValidCSS ( aReader , eVersion ) ; }
Check if the passed CSS resource can be parsed without error
36,631
public CSSRect setTop ( final String sTop ) { ValueEnforcer . notEmpty ( sTop , "Top" ) ; m_sTop = sTop ; return this ; }
Set the top coordinate .
36,632
public CSSRect setRight ( final String sRight ) { ValueEnforcer . notEmpty ( sRight , "Right" ) ; m_sRight = sRight ; return this ; }
Set the right coordinate .
36,633
public CSSRect setBottom ( final String sBottom ) { ValueEnforcer . notEmpty ( sBottom , "Bottom" ) ; m_sBottom = sBottom ; return this ; }
Set the bottom coordinate .
36,634
public CSSRect setLeft ( final String sLeft ) { ValueEnforcer . notEmpty ( sLeft , "Left" ) ; m_sLeft = sLeft ; return this ; }
Set the left coordinate .
36,635
public CSSMediaList addMedium ( final ECSSMedium eMedium ) { ValueEnforcer . notNull ( eMedium , "Medium" ) ; m_aMedia . add ( eMedium ) ; return this ; }
Add a new medium to the list
36,636
public String getCSSAsString ( final CascadingStyleSheet aCSS ) { final NonBlockingStringWriter aSW = new NonBlockingStringWriter ( ) ; try { writeCSS ( aCSS , aSW ) ; } catch ( final IOException ex ) { throw new IllegalStateException ( "Totally unexpected" , ex ) ; } return aSW . getAsString ( ) ; }
Create the CSS without a specific charset .
36,637
public CSSExpressionMemberTermURI setURI ( final CSSURI aURI ) { m_aURI = ValueEnforcer . notNull ( aURI , "URI" ) ; return this ; }
Set a new URI
36,638
public static boolean canWrapInMediaQuery ( final CascadingStyleSheet aCSS , final boolean bAllowNestedMediaQueries ) { if ( aCSS == null ) return false ; if ( bAllowNestedMediaQueries ) return true ; return ! aCSS . hasMediaRules ( ) ; }
Check if the passed CSS can be wrapped in an external media rule .
36,639
public static String getMinifiedCSSFilename ( final String sCSSFilename ) { if ( ! isCSSFilename ( sCSSFilename ) ) throw new IllegalArgumentException ( "Passed file name '" + sCSSFilename + "' is not a CSS file name!" ) ; if ( isMinifiedCSSFilename ( sCSSFilename ) ) return sCSSFilename ; return StringHelper . trimEnd ( sCSSFilename , CCSS . FILE_EXTENSION_CSS ) + CCSS . FILE_EXTENSION_MIN_CSS ; }
Get the minified CSS filename from the passed filename . If the passed filename is already minified it is returned as is .
36,640
public CSSReaderSettings setCSSVersion ( final ECSSVersion eCSSVersion ) { ValueEnforcer . notNull ( eCSSVersion , "CSSVersion" ) ; m_eCSSVersion = eCSSVersion ; return this ; }
Set the CSS version to be read .
36,641
public CSSReaderSettings setTabSize ( final int nTabSize ) { ValueEnforcer . isGT0 ( nTabSize , "TabSize" ) ; m_nTabSize = nTabSize ; return this ; }
Set the tab size to be used to determine the source location .
36,642
public static CSSDataURL parseDataURL ( final String sDataURL ) { if ( ! isDataURL ( sDataURL ) ) return null ; final String sRest = sDataURL . trim ( ) . substring ( PREFIX_DATA_URL . length ( ) ) ; if ( StringHelper . hasNoText ( sRest ) ) { return new CSSDataURL ( ) ; } final int nIndexComma = sRest . indexOf ( SEPARATOR_CONTENT ) ; int nIndexBase64 = sRest . indexOf ( BASE64_MARKER ) ; boolean bBase64EncodingUsed = false ; int nMIMETypeEnd ; if ( nIndexBase64 >= 0 ) { if ( nIndexBase64 < nIndexComma || nIndexComma < 0 ) { while ( true ) { final int nIndexEquals = sRest . indexOf ( CMimeType . SEPARATOR_PARAMETER_NAME_VALUE , nIndexBase64 ) ; if ( nIndexEquals < 0 || nIndexEquals > nIndexComma || nIndexComma < 0 ) { nMIMETypeEnd = nIndexBase64 ; bBase64EncodingUsed = true ; break ; } nIndexBase64 = sRest . indexOf ( BASE64_MARKER , nIndexBase64 + BASE64_MARKER . length ( ) ) ; if ( nIndexBase64 < 0 ) { nMIMETypeEnd = nIndexComma ; break ; } } } else { nMIMETypeEnd = nIndexComma ; } } else { nMIMETypeEnd = nIndexComma ; } String sMimeType = nMIMETypeEnd < 0 ? null : sRest . substring ( 0 , nMIMETypeEnd ) . trim ( ) ; IMimeType aMimeType ; Charset aCharset = null ; if ( StringHelper . hasNoText ( sMimeType ) ) { aMimeType = DEFAULT_MIME_TYPE . getClone ( ) ; aCharset = DEFAULT_CHARSET ; } else { if ( sMimeType . charAt ( 0 ) == CMimeType . SEPARATOR_PARAMETER ) { sMimeType = DEFAULT_MIME_TYPE . getAsStringWithoutParameters ( ) + sMimeType ; } aMimeType = MimeTypeParser . safeParseMimeType ( sMimeType , EMimeQuoting . URL_ESCAPE ) ; if ( aMimeType == null ) { LOGGER . warn ( "Data URL contains invalid MIME type: '" + sMimeType + "'" ) ; return null ; } final String sCharsetParam = MimeTypeHelper . getCharsetNameFromMimeType ( aMimeType ) ; if ( sCharsetParam != null ) { aCharset = CharsetHelper . getCharsetFromNameOrNull ( sCharsetParam ) ; if ( aCharset == null ) { LOGGER . warn ( "Illegal charset '" + sCharsetParam + "' contained. Defaulting to '" + DEFAULT_CHARSET . name ( ) + "'" ) ; } } if ( aCharset == null ) aCharset = DEFAULT_CHARSET ; } String sContent = nIndexComma < 0 ? "" : sRest . substring ( nIndexComma + 1 ) . trim ( ) ; byte [ ] aContent = sContent . getBytes ( aCharset ) ; if ( bBase64EncodingUsed ) { aContent = Base64 . safeDecode ( aContent ) ; if ( aContent == null ) { LOGGER . warn ( "Failed to decode Base64 value: " + sContent ) ; return null ; } sContent = null ; } final CSSDataURL ret = new CSSDataURL ( aMimeType , bBase64EncodingUsed , aContent , aCharset , sContent ) ; return ret ; }
Parse a data URL into this type .
36,643
public CSSImportRule addMediaQuery ( final CSSMediaQuery aMediaQuery ) { ValueEnforcer . notNull ( aMediaQuery , "MediaQuery" ) ; m_aMediaQueries . add ( aMediaQuery ) ; return this ; }
Add a media query at the end of the list .
36,644
public CSSImportRule setLocation ( final CSSURI aLocation ) { ValueEnforcer . notNull ( aLocation , "Location" ) ; m_aLocation = aLocation ; return this ; }
Set the URI of the file to be imported .
36,645
public static boolean isNumberValue ( final String sCSSValue ) { final String sRealValue = StringHelper . trim ( sCSSValue ) ; return StringHelper . hasText ( sRealValue ) && StringParser . isDouble ( sRealValue ) ; }
Check if the passed value is a pure numeric value without a unit .
36,646
public void jjtAddChild ( final Node aNode , final int nIndex ) { if ( m_aChildren == null ) m_aChildren = new CSSNode [ nIndex + 1 ] ; else if ( nIndex >= m_aChildren . length ) { final CSSNode [ ] aTmpArray = new CSSNode [ nIndex + 1 ] ; System . arraycopy ( m_aChildren , 0 , aTmpArray , 0 , m_aChildren . length ) ; m_aChildren = aTmpArray ; } m_aChildren [ nIndex ] = ( CSSNode ) aNode ; }
Called from the highest index to the lowest index!
36,647
public CSSExpression addTermSimple ( final String sValue ) { return addMember ( new CSSExpressionMemberTermSimple ( sValue ) ) ; }
Shortcut method to add a simple text value .
36,648
public CSSExpression addString ( final int nIndex , final String sValue ) { return addTermSimple ( nIndex , getQuotedStringValue ( sValue ) ) ; }
Shortcut method to add a string value that is automatically quoted inside
36,649
public CSSExpression addURI ( final String sURI ) { return addMember ( new CSSExpressionMemberTermURI ( sURI ) ) ; }
Shortcut method to add a URI value
36,650
public static CSSExpression createSimple ( final String sValue ) { return new CSSExpression ( ) . addTermSimple ( sValue ) ; }
Create a CSS expression only containing a text value
36,651
public static CSSExpression createString ( final String sValue ) { return new CSSExpression ( ) . addString ( sValue ) ; }
Create a CSS expression only containing a string
36,652
public static CSSExpression createURI ( final String sURI ) { return new CSSExpression ( ) . addURI ( sURI ) ; }
Create a CSS expression only containing a URI
36,653
public static Charset getCharsetFromMimeTypeOrDefault ( final IMimeType aMimeType ) { final Charset ret = MimeTypeHelper . getCharsetFromMimeType ( aMimeType ) ; return ret != null ? ret : CSSDataURLHelper . DEFAULT_CHARSET ; }
Determine the charset from the passed MIME type . If no charset was found return the default charset .
36,654
public void writeContentBytes ( final OutputStream aOS ) throws IOException { aOS . write ( m_aContent , 0 , m_aContent . length ) ; }
Write all the binary content to the passed output stream . No Base64 encoding is performed in this method .
36,655
public String getContentAsString ( final Charset aCharset ) { if ( m_aCharset . equals ( aCharset ) ) { return getContentAsString ( ) ; } return new String ( m_aContent , aCharset ) ; }
Get the data content of this Data URL as String in the specified charset . No Base64 encoding is performed in this method .
36,656
public DelimiterWriterFactory addColumnTitles ( final Collection < String > columnTitles ) { if ( columnTitles != null ) { for ( final String columnTitle : columnTitles ) { addColumnTitle ( columnTitle ) ; } } return this ; }
Convenience method to add a series of cols in one go .
36,657
public static int getDelimiterOffset ( final String line , final int start , final char delimiter ) { int idx = line . indexOf ( delimiter , start ) ; if ( idx >= 0 ) { idx -= start - 1 ; } return idx ; }
reads from the specified point in the line and returns how many chars to the specified delimiter
36,658
public static String lTrim ( final String value ) { if ( value == null ) { return null ; } String trimmed = value ; int offset = 0 ; final int maxLength = value . length ( ) ; while ( offset < maxLength && ( value . charAt ( offset ) == ' ' || value . charAt ( offset ) == '\t' ) ) { offset ++ ; } if ( offset > 0 ) { trimmed = value . substring ( offset ) ; } return trimmed ; }
Removes empty space from the beginning of a string
36,659
public static String rTrim ( final String value ) { if ( value == null ) { return null ; } String trimmed = value ; int offset = value . length ( ) - 1 ; while ( offset > - 1 && ( value . charAt ( offset ) == ' ' || value . charAt ( offset ) == '\t' ) ) { offset -- ; } if ( offset < value . length ( ) - 1 ) { trimmed = value . substring ( 0 , offset + 1 ) ; } return trimmed ; }
Removes empty space from the end of a string
36,660
public static MetaData getPZMetaDataFromFile ( final String line , final char delimiter , final char qualifier , final Parser p , final boolean addSuffixToDuplicateColumnNames ) { final List < ColumnMetaData > results = new ArrayList < > ( ) ; final Set < String > dupCheck = new HashSet < > ( ) ; final List < String > lineData = splitLine ( line , delimiter , qualifier , FPConstants . SPLITLINE_SIZE_INIT , false , false ) ; for ( final String colName : lineData ) { final ColumnMetaData cmd = new ColumnMetaData ( ) ; String colNameToUse = colName ; if ( dupCheck . contains ( colNameToUse ) ) { if ( ! addSuffixToDuplicateColumnNames ) { throw new FPException ( "Duplicate Column Name In File: " + colNameToUse ) ; } else { int count = 2 ; while ( dupCheck . contains ( colNameToUse + count ) ) { count ++ ; } colNameToUse = colName + count ; } } cmd . setColName ( colNameToUse ) ; results . add ( cmd ) ; dupCheck . add ( cmd . getColName ( ) ) ; } return new MetaData ( results , buidColumnIndexMap ( results , p ) ) ; }
Returns a list of ColumnMetaData objects . This is for use with delimited files . The first line of the file which contains data will be used as the column names
36,661
public static boolean isMultiLine ( final char [ ] chrArry , final char delimiter , final char qualifier ) { if ( chrArry [ chrArry . length - 1 ] != qualifier ) { boolean qualiFound = false ; for ( int i = chrArry . length - 1 ; i >= 0 ; i -- ) { if ( chrArry [ i ] == ' ' ) { continue ; } if ( qualiFound ) { if ( chrArry [ i ] == delimiter ) { boolean qualifiedContent = chrArry [ 0 ] == qualifier ; for ( int index = 0 ; index < chrArry . length ; index ++ ) { final char currentChar = chrArry [ index ] ; qualifiedContent = currentChar == qualifier ; if ( qualifiedContent ) { for ( ; index < chrArry . length ; index ++ ) { if ( chrArry [ index ] == delimiter && chrArry [ ++ index ] == qualifier ) { qualifiedContent = false ; } } } } return qualifiedContent ; } qualiFound = chrArry [ i ] == qualifier ; } else if ( chrArry [ i ] == delimiter ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( chrArry [ j ] == ' ' ) { continue ; } else if ( chrArry [ j ] == qualifier ) { return false ; } break ; } } else if ( chrArry [ i ] == qualifier ) { qualiFound = true ; } } } else { for ( int i = chrArry . length - 1 ; i >= 0 ; i -- ) { if ( i == chrArry . length - 1 || chrArry [ i ] == ' ' ) { continue ; } if ( chrArry [ i ] == delimiter ) { boolean qualifiedContent = chrArry [ 0 ] == qualifier ; for ( int index = 0 ; index < chrArry . length ; index ++ ) { final char currentChar = chrArry [ index ] ; qualifiedContent = currentChar == qualifier ; if ( qualifiedContent ) { for ( ; index < chrArry . length ; index ++ ) { if ( chrArry [ index ] == delimiter && chrArry [ ++ index ] == qualifier ) { qualifiedContent = false ; } } } } return qualifiedContent ; } break ; } } return false ; }
Determines if the given line is the first part of a multiline record . It does this by verifying that the qualifer on the last element is not closed
36,662
public static String stripNonLongChars ( final String value ) { final StringBuilder newString = new StringBuilder ( ) ; for ( int i = 0 ; i < value . length ( ) ; i ++ ) { final char c = value . charAt ( i ) ; if ( c == '.' ) { break ; } else if ( c >= '0' && c <= '9' || c == '-' ) { newString . append ( c ) ; } } final int sLen = newString . length ( ) ; final String s = newString . toString ( ) ; if ( sLen == 0 || sLen == 1 && "-" . equals ( s ) ) { return "0" ; } return newString . toString ( ) ; }
Removes chars from the String that could not be parsed into a Long value
36,663
public static boolean isListElementsEmpty ( final List < String > l ) { for ( final String s : l ) { if ( s != null && s . trim ( ) . length ( ) > 0 ) { return false ; } } return true ; }
Checks a list of &lt ; String&gt ; elements to see if every element in the list is empty .
36,664
public static Object runPzConverter ( final Properties classXref , final String value , final Class < ? > typeToReturn ) { final String sConverter = classXref . getProperty ( typeToReturn . getName ( ) ) ; if ( sConverter == null ) { throw new FPConvertException ( typeToReturn . getName ( ) + " is not registered in pzconvert.properties" ) ; } try { final Converter pzconverter = ( Converter ) Class . forName ( sConverter ) . newInstance ( ) ; return pzconverter . convertValue ( value ) ; } catch ( final IllegalAccessException | InstantiationException | ClassNotFoundException ex ) { throw new FPConvertException ( ex ) ; } }
Converts a String value to the appropriate Object via the correct net . sf . flatpack . converter . PZConverter implementation
36,665
public static List < ColumnMetaData > buildMDFromSQLTable ( final Connection con , final String dataDefinition , final Parser parser ) throws SQLException { final List < ColumnMetaData > cmds = new ArrayList < > ( ) ; final String dfTbl = parser != null ? parser . getDataFileTable ( ) : "DATAFILE" ; final String dsTbl = parser != null ? parser . getDataStructureTable ( ) : "DATASTRUCTURE" ; final StringBuilder sqlSb = new StringBuilder ( ) ; sqlSb . append ( "SELECT * FROM " ) . append ( dfTbl ) . append ( " INNER JOIN " ) . append ( dsTbl ) . append ( " ON " ) . append ( dfTbl ) . append ( ".DATAFILE_NO = " ) . append ( dsTbl ) . append ( ".DATAFILE_NO " + "WHERE DATAFILE_DESC = ? ORDER BY DATASTRUCTURE_COL_ORDER" ) ; try ( PreparedStatement stmt = con . prepareStatement ( sqlSb . toString ( ) ) ) { stmt . setString ( 1 , dataDefinition ) ; try ( ResultSet rs = stmt . executeQuery ( ) ) { int recPosition = 1 ; while ( rs . next ( ) ) { final ColumnMetaData column = new ColumnMetaData ( ) ; column . setColName ( rs . getString ( "DATASTRUCTURE_COLUMN" ) ) ; column . setColLength ( rs . getInt ( DATASTRUCTURE_LENGTH ) ) ; column . setStartPosition ( recPosition ) ; column . setEndPosition ( recPosition + rs . getInt ( DATASTRUCTURE_LENGTH ) - 1 ) ; recPosition += rs . getInt ( DATASTRUCTURE_LENGTH ) ; cmds . add ( column ) ; } } if ( cmds . isEmpty ( ) ) { throw new FPException ( "Data File Key [" + dataDefinition + "] Is Not In The database OR No Columns Specified In Table" ) ; } } return cmds ; }
Returns a definition of pz column metadata from a given pz datastructure held in an SQL database
36,666
public static List < String > splitFixedText ( final List < ColumnMetaData > columnMetaData , final String lineToParse , final boolean preserveLeadingWhitespace , final boolean preserveTrailingWhitespace ) { final List < String > splitResult = new ArrayList < > ( ) ; int recPosition = 1 ; for ( final ColumnMetaData colMetaDataObj : columnMetaData ) { String tempValue = lineToParse . substring ( recPosition - 1 , recPosition + colMetaDataObj . getColLength ( ) - 1 ) ; recPosition += colMetaDataObj . getColLength ( ) ; if ( ! preserveLeadingWhitespace ) { tempValue = ParserUtils . lTrim ( tempValue ) ; } if ( ! preserveTrailingWhitespace ) { tempValue = ParserUtils . rTrim ( tempValue ) ; } splitResult . add ( tempValue ) ; } return splitResult ; }
Splits up a fixed width line of text
36,667
public static String getCMDKey ( final MetaData columnMD , final String line ) { if ( ! columnMD . isAnyRecordFormatSpecified ( ) ) { return FPConstants . DETAIL_ID ; } final Iterator < Entry < String , XMLRecordElement > > mapEntries = columnMD . xmlRecordIterator ( ) ; while ( mapEntries . hasNext ( ) ) { final Entry < String , XMLRecordElement > entry = mapEntries . next ( ) ; final XMLRecordElement recordXMLElement = entry . getValue ( ) ; if ( recordXMLElement . getEndPositition ( ) > line . length ( ) ) { continue ; } final int subfrm = recordXMLElement . getStartPosition ( ) - 1 ; final int subto = recordXMLElement . getEndPositition ( ) ; if ( line . substring ( subfrm , subto ) . equals ( recordXMLElement . getIndicator ( ) ) ) { return entry . getKey ( ) ; } } return FPConstants . DETAIL_ID ; }
Returns the key to the list of ColumnMetaData objects . Returns the correct MetaData per the mapping file and the data contained on the line
36,668
public int getColumnIndex ( final String colName ) { int idx = - 1 ; if ( columnIndex != null ) { final Integer i = columnIndex . get ( colName ) ; if ( i != null ) { idx = i . intValue ( ) ; } } return idx ; }
Returns the index of the column name .
36,669
public void writeExcelFile ( ) throws IOException , WriteException { WritableWorkbook excelWrkBook = null ; int curDsPointer = 0 ; try { final String [ ] columnNames = ds . getColumns ( ) ; final List < String > exportOnlyColumnsList = getExportOnlyColumns ( ) != null ? Arrays . asList ( exportOnlyColumns ) : null ; final List < String > excludeFromExportColumnsList = getExcludeFromExportColumns ( ) != null ? Arrays . asList ( excludeFromExportColumns ) : null ; final List < String > numericColumnList = getNumericColumns ( ) != null ? Arrays . asList ( getNumericColumns ( ) ) : new ArrayList < > ( ) ; curDsPointer = ds . getIndex ( ) ; ds . goTop ( ) ; excelWrkBook = Workbook . createWorkbook ( xlsFile ) ; final WritableSheet wrkSheet = excelWrkBook . createSheet ( "results" , 0 ) ; final WritableFont times10ptBold = new WritableFont ( WritableFont . TIMES , 10 , WritableFont . BOLD ) ; final WritableFont times10pt = new WritableFont ( WritableFont . TIMES , 10 , WritableFont . NO_BOLD ) ; WritableCellFormat cellFormat = new WritableCellFormat ( times10ptBold ) ; int colOffset = 0 ; for ( int i = 0 ; i < columnNames . length ; i ++ ) { if ( exportOnlyColumnsList != null && ! exportOnlyColumnsList . contains ( columnNames [ i ] ) || excludeFromExportColumnsList != null && excludeFromExportColumnsList . contains ( columnNames [ i ] ) ) { colOffset ++ ; continue ; } final Label xlsTextLbl = new Label ( i - colOffset , 0 , columnNames [ i ] , cellFormat ) ; wrkSheet . addCell ( xlsTextLbl ) ; } cellFormat = new WritableCellFormat ( times10pt ) ; int row = 1 ; while ( ds . next ( ) ) { if ( ! ds . isRecordID ( FPConstants . DETAIL_ID ) ) { continue ; } colOffset = 0 ; for ( int i = 0 ; i < columnNames . length ; i ++ ) { if ( exportOnlyColumnsList != null && ! exportOnlyColumnsList . contains ( columnNames [ i ] ) || excludeFromExportColumnsList != null && excludeFromExportColumnsList . contains ( columnNames [ i ] ) ) { colOffset ++ ; continue ; } WritableCell wc = null ; if ( numericColumnList . contains ( columnNames [ i ] ) ) { wc = new Number ( i - colOffset , row , ds . getDouble ( columnNames [ i ] ) , cellFormat ) ; } else { wc = new Label ( i - colOffset , row , ds . getString ( columnNames [ i ] ) , cellFormat ) ; } wrkSheet . addCell ( wc ) ; } row ++ ; } excelWrkBook . write ( ) ; } finally { if ( curDsPointer > - 1 ) { ds . absolute ( curDsPointer ) ; } if ( excelWrkBook != null ) { excelWrkBook . close ( ) ; } } }
Writes the Excel file to disk
36,670
public void absolute ( final int localPointer ) { if ( localPointer < 0 || localPointer >= rows . size ( ) ) { throw new IndexOutOfBoundsException ( "INVALID POINTER LOCATION: " + localPointer ) ; } pointer = localPointer ; currentRecord = new RowRecord ( rows . get ( pointer ) , metaData , parser . isColumnNamesCaseSensitive ( ) , pzConvertProps , strictNumericParse , upperCase , lowerCase , parser . isNullEmptyStrings ( ) ) ; }
Sets the absolute position of the record pointer
36,671
private static int convertAttributeToInt ( final String attribute ) { if ( attribute == null ) { return 0 ; } try { return Integer . parseInt ( attribute ) ; } catch ( final Exception ignore ) { return 0 ; } }
helper to convert to integer
36,672
public static Map < String , Object > buildParametersForColumns ( final String colsAsCsv ) { final Map < String , Object > mapping = new HashMap < > ( ) ; mapping . put ( FPConstants . DETAIL_ID , buildColumns ( colsAsCsv ) ) ; return mapping ; }
Creates a Mapping for a WriterFactory for the given list of columns .
36,673
public static List < ColumnMetaData > buildColumns ( final String colsAsCsv ) { final List < ColumnMetaData > listCol = new ArrayList < > ( ) ; buildColumns ( listCol , colsAsCsv ) ; return listCol ; }
Create a new list of ColumnMetaData based on a CSV list of column titles .
36,674
protected void addToCloseReaderList ( final Reader r ) { if ( readersToClose == null ) { readersToClose = new ArrayList < > ( ) ; } readersToClose . add ( r ) ; }
is completed .
36,675
protected String fetchNextRecord ( final BufferedReader br , final char qual , final char delim ) throws IOException { String line = null ; final StringBuilder lineData = new StringBuilder ( ) ; boolean processingMultiLine = false ; while ( ( line = br . readLine ( ) ) != null ) { lineCount ++ ; final String trimmed = line . trim ( ) ; final int trimmedLen = trimmed . length ( ) ; if ( ! processingMultiLine && trimmed . length ( ) == 0 ) { continue ; } final char [ ] chrArry = trimmed . toCharArray ( ) ; if ( ! processingMultiLine && delim > 0 && qual != FPConstants . NO_QUALIFIER ) { processingMultiLine = ParserUtils . isMultiLine ( chrArry , delim , qual ) ; } final String trimmedLineData = lineData . toString ( ) . trim ( ) ; if ( processingMultiLine && trimmedLineData . length ( ) > 0 && trimmedLen > 0 ) { if ( trimmed . charAt ( trimmed . length ( ) - 1 ) == qual && ! trimmed . endsWith ( "" + qual + qual ) ) { processingMultiLine = false ; lineData . append ( LINE_BREAK ) . append ( line ) ; } else { lineData . append ( LINE_BREAK ) . append ( line ) ; boolean qualiFound = false ; for ( final char element : chrArry ) { if ( qualiFound ) { if ( element == ' ' ) { continue ; } else if ( element == delim ) { processingMultiLine = ParserUtils . isMultiLine ( chrArry , delim , qual ) ; break ; } qualiFound = false ; } else if ( element == qual ) { qualiFound = true ; } } if ( processingMultiLine ) { continue ; } } } else { lineData . append ( trimmedLen == 0 ? LINE_BREAK : line ) ; if ( processingMultiLine ) { continue ; } } break ; } if ( line == null && lineData . length ( ) == 0 ) { return null ; } return lineData . toString ( ) ; }
Reads a record from a delimited file . This will account for records which could span multiple lines . NULL will be returned when the end of the file is reached
36,676
public int compare ( final Row row0 , final Row row1 ) { int result = 0 ; for ( int i = 0 ; i < orderbys . size ( ) ; i ++ ) { final OrderColumn oc = orderbys . get ( i ) ; final String mdkey0 = row0 . getMdkey ( ) == null ? FPConstants . DETAIL_ID : row0 . getMdkey ( ) ; final String mdkey1 = row1 . getMdkey ( ) == null ? FPConstants . DETAIL_ID : row1 . getMdkey ( ) ; if ( ! mdkey0 . equals ( FPConstants . DETAIL_ID ) && ! mdkey1 . equals ( FPConstants . DETAIL_ID ) ) { return 0 ; } else if ( ! mdkey0 . equals ( FPConstants . DETAIL_ID ) || ! mdkey1 . equals ( FPConstants . DETAIL_ID ) ) { return ! mdkey0 . equals ( FPConstants . DETAIL_ID ) ? 1 : 0 ; } result = compareCol ( row0 , row1 , oc ) ; if ( result != 0 ) { break ; } } return result ; }
overridden from the Comparator class .
36,677
public static TestContainer createContainer ( String configurationClassName ) throws Exception { Option [ ] options = getConfigurationOptions ( configurationClassName ) ; ExamSystem system = DefaultExamSystem . create ( options ) ; TestContainer testContainer = PaxExamRuntime . createContainer ( system ) ; testContainer . start ( ) ; return testContainer ; }
Creates and starts a test container using options from a configuration class .
36,678
private static void waitForStop ( TestContainer testContainer , int localPort ) { try { ServerSocket serverSocket = new ServerSocket ( localPort ) ; Socket socket = serverSocket . accept ( ) ; InputStreamReader isr = new InputStreamReader ( socket . getInputStream ( ) , "UTF-8" ) ; BufferedReader reader = new BufferedReader ( isr ) ; OutputStream os = socket . getOutputStream ( ) ; OutputStreamWriter writer = new OutputStreamWriter ( os , "UTF-8" ) ; PrintWriter pw = new PrintWriter ( writer , true ) ; boolean running = true ; while ( running ) { String command = reader . readLine ( ) ; LOG . debug ( "command = {}" , command ) ; if ( command . equals ( "stop" ) ) { testContainer . stop ( ) ; pw . println ( "stopped" ) ; writer . flush ( ) ; LOG . info ( "test container stopped" ) ; } else if ( command . equals ( "quit" ) ) { LOG . debug ( "quitting PaxExamRuntime" ) ; pw . close ( ) ; socket . close ( ) ; serverSocket . close ( ) ; running = false ; } } } catch ( IOException exc ) { LOG . debug ( "socket error" , exc ) ; } }
Opens a server socket listening for text commands on the given port . Each command is terminated by a newline . The server expects a stop command followed by a quit command .
36,679
private static void sanityCheck ( ) { List < TestContainerFactory > factories = new ArrayList < TestContainerFactory > ( ) ; Iterator < TestContainerFactory > iter = ServiceLoader . load ( TestContainerFactory . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { factories . add ( iter . next ( ) ) ; } if ( factories . size ( ) == 0 ) { throw new TestContainerException ( "No TestContainer implementation in Classpath" ) ; } else if ( factories . size ( ) > 1 ) { for ( TestContainerFactory fac : factories ) { LOG . error ( "Ambiguous TestContainer: " + fac . getClass ( ) . getName ( ) ) ; } throw new TestContainerException ( "Too many TestContainer implementations in Classpath" ) ; } else { return ; } }
Exits with an exception if Classpath not set up properly .
36,680
String determineCachingName ( final File file , final String defaultBundleSymbolicName ) { String bundleSymbolicName = null ; String bundleVersion = null ; JarFile jar = null ; try { jar = new JarFile ( file , false ) ; final Manifest manifest = jar . getManifest ( ) ; if ( manifest != null ) { bundleSymbolicName = manifest . getMainAttributes ( ) . getValue ( Constants . BUNDLE_SYMBOLICNAME ) ; bundleVersion = manifest . getMainAttributes ( ) . getValue ( Constants . BUNDLE_VERSION ) ; } } catch ( IOException ignore ) { } finally { if ( jar != null ) { try { jar . close ( ) ; } catch ( IOException ignore ) { } } } if ( bundleSymbolicName == null ) { bundleSymbolicName = defaultBundleSymbolicName ; } else { int semicolonPos = bundleSymbolicName . indexOf ( ";" ) ; if ( semicolonPos > 0 ) { bundleSymbolicName = bundleSymbolicName . substring ( 0 , semicolonPos ) ; } } if ( bundleVersion == null ) { bundleVersion = "0.0.0" ; } return bundleSymbolicName + "_" + bundleVersion + ".jar" ; }
Determine name to be used for caching on local file system .
36,681
public void join ( ) { try { UnicastRemoteObject . unexportObject ( registry , true ) ; javaRunner . shutdown ( ) ; } catch ( NoSuchObjectException exc ) { throw new TestContainerException ( exc ) ; } }
Waits for the remote framework to shutdown and frees all resources .
36,682
public void stop ( BundleContext bc ) throws Exception { String blockOnStop = System . getProperty ( "pax.exam.regression.blockOnStop" , "false" ) ; if ( Boolean . valueOf ( blockOnStop ) ) { Thread . sleep ( Long . MAX_VALUE ) ; } }
Optionally blocks framework shutdown for a shutdown timeout regression test .
36,683
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public void injectFields ( Object target ) { BeanManager mgr = BeanManagerLookup . getBeanManager ( ) ; AnnotatedType annotatedType = mgr . createAnnotatedType ( target . getClass ( ) ) ; InjectionTarget injectionTarget = mgr . createInjectionTarget ( annotatedType ) ; CreationalContext context = mgr . createCreationalContext ( null ) ; injectionTarget . inject ( target , context ) ; }
Injects dependencies into the given target object whose lifecycle is not managed by the BeanManager itself .
36,684
public JarProbeOption classes ( Class < ? > ... klass ) { for ( Class < ? > c : klass ) { String resource = c . getName ( ) . replaceAll ( "\\." , "/" ) + ".class" ; resources . add ( resource ) ; } return this ; }
Adds the given classes to the JAR .
36,685
public JarProbeOption resources ( String ... resourcePaths ) { for ( String resource : resourcePaths ) { resources . add ( resource ) ; } return this ; }
Adds the given resources from the current class path to the JAR .
36,686
public URI buildJar ( ) { if ( option . getName ( ) == null ) { option . name ( UUID . randomUUID ( ) . toString ( ) ) ; } try { File explodedJarDir = getExplodedJarDir ( ) ; File probeJar = new File ( tempDir , option . getName ( ) + ".jar" ) ; ZipBuilder builder = new ZipBuilder ( probeJar ) ; builder . addDirectory ( explodedJarDir , "" ) ; builder . close ( ) ; URI warUri = probeJar . toURI ( ) ; LOG . info ( "JAR probe = {}" , warUri ) ; return warUri ; } catch ( IOException exc ) { throw new TestContainerException ( exc ) ; } }
Builds a JAR from the given option .
36,687
public static MavenArtifactDeploymentOption mavenWar ( final String groupId , final String artifactId , final String version ) { return mavenWar ( ) . groupId ( groupId ) . artifactId ( artifactId ) . version ( version ) . type ( "war" ) ; }
Deploys a Maven WAR artifact with the given Maven coordinates .
36,688
private synchronized File createTemp ( File workingDirectory ) throws IOException { if ( workingDirectory == null ) { return createTempDir ( ) ; } else { workingDirectory . mkdirs ( ) ; return workingDirectory ; } }
Creates a fresh temp folder under the mentioned working folder . If workingFolder is null system wide temp location will be used .
36,689
public Option bundle ( String bsn ) { Collection < Option > urls = new ArrayList < > ( ) ; try { for ( File file : workspace . getProject ( bsn ) . getBuildFiles ( ) ) { urls . add ( url ( file . toURI ( ) . toASCIIString ( ) ) ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Underlying Bnd Exception: " , e ) ; } return composite ( urls . toArray ( new Option [ urls . size ( ) ] ) ) ; }
Add workspace - built bundle of name symbolicName to system - under - test .
36,690
public Option fromBndrun ( String runFileSpec ) { try { File runFile = workspace . getFile ( runFileSpec ) ; Run bndRunInstruction = new Run ( workspace , runFile . getParentFile ( ) , runFile ) ; return bndToExam ( bndRunInstruction ) ; } catch ( Exception e ) { throw new RuntimeException ( "Underlying Bnd Exception: " , e ) ; } }
Add all bundles resolved by bndrun file to system - under - test .
36,691
private List < Dependency > getProvisionableDependencies ( ) { List < Dependency > dependencies = new ArrayList < Dependency > ( ) ; getLog ( ) . info ( "Adding dependencies in scope " + dependencyScope ) ; for ( Dependency d : getDependencies ( ) ) { if ( d . getScope ( ) != null && d . getScope ( ) . equalsIgnoreCase ( dependencyScope ) ) { dependencies . add ( d ) ; } } return dependencies ; }
Dependency resolution inspired by servicemix depends - maven - plguin
36,692
private String createPaxRunnerScan ( Artifact artifact , String optionTokens ) { return "scan-bundle:" + artifact . getFile ( ) . toURI ( ) . normalize ( ) . toString ( ) + "@update" + optionTokens ; }
Creates scanner directives from artifact to be parsed by pax runner . Also includes options found and matched in settings part of configuration .
36,693
public void downloadAndInstall ( ) throws IOException { installDir . mkdirs ( ) ; File tempFile = File . createTempFile ( "pax-exam" , ".zip" ) ; FileOutputStream os = null ; LOG . info ( "downloading {} to {}" , zipUrl , tempFile ) ; try { os = new FileOutputStream ( tempFile ) ; StreamUtils . copyStream ( zipUrl . openStream ( ) , os , true ) ; LOG . info ( "unzipping into {}" , installDir ) ; ZipExploder exploder = new ZipExploder ( ) ; exploder . processFile ( tempFile , installDir ) ; } finally { tempFile . delete ( ) ; } }
Download and unpacks the archive .
36,694
public WarProbeOption overlay ( String overlayPath ) { overlays . add ( new File ( overlayPath ) . toURI ( ) . toString ( ) ) ; return this ; }
Adds an overlay from the given path to the WAR . This is similar to the overlay concept of the Maven WAR Plugin . If the overlay path is a directory its contents are copied recursively to the root of the WAR . If the overlay path is an archive its exploded contents are copied to the root of the WAR . All overlays are copied in the given order . All overlay are copied before any libraries classes or resources .
36,695
public WarProbeOption autoClasspath ( boolean includeDefaultFilters ) { useClasspath = true ; if ( includeDefaultFilters ) { for ( String filter : DEFAULT_CLASS_PATH_EXCLUDES ) { classpathFilters . add ( filter ) ; } } return this ; }
Automatically add libraries and class folders from the current classpath .
36,696
public static KarafDistributionBaseConfigurationOption karafDistributionConfiguration ( String frameworkURL , String name , String karafVersion ) { return new KarafDistributionConfigurationOption ( frameworkURL , name , karafVersion ) ; }
Configures which distribution options to use . Relevant are the frameworkURL the frameworkName and the Karaf version since all of those params are relevant to decide which wrapper configurations to use .
36,697
public static Option [ ] editConfigurationFilePut ( final String configurationFilePath , File source , String ... keysToUseFromSource ) { return createOptionListFromFile ( source , new FileOptionFactory ( ) { public Option createOption ( String key , Object value ) { return new KarafDistributionConfigurationFilePutOption ( configurationFilePath , key , value ) ; } } , keysToUseFromSource ) ; }
This option allows to configure each configuration file based on the karaf . home location . The value is put which means it is either replaced or added . For simpler configuration you can add a file source . If you want to put all values from this file do not configure any keysToUseFromSource ; otherwise define them to use only those specific values .
36,698
public static Option [ ] editConfigurationFileExtend ( final String configurationFilePath , File source , String ... keysToUseFromSource ) { return createOptionListFromFile ( source , new FileOptionFactory ( ) { public Option createOption ( String key , Object value ) { return new KarafDistributionConfigurationFileExtendOption ( configurationFilePath , key , value ) ; } } , keysToUseFromSource ) ; }
This option allows to configure each configuration file based on the karaf . home location . The value is extend which means it is either replaced or added . For simpler configuration you can add a file source . If you want to put all values from this file do not configure any keysToUseFromSource ; otherwise define them to use only those specific values .
36,699
private Registry getRegistry ( int port ) throws RemoteException { Registry reg ; String hostName = System . getProperty ( "java.rmi.server.hostname" ) ; if ( hostName != null && ! hostName . isEmpty ( ) ) { reg = LocateRegistry . getRegistry ( hostName , port ) ; } else { reg = LocateRegistry . getRegistry ( port ) ; } return reg ; }
shared utility module