idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
121,100
private Node getFirstChild ( Node node ) { if ( node == null ) return null ; Node newNode = node . getFirstChild ( ) ; if ( newNode == null ) return null ; int accept = acceptNode ( newNode ) ; if ( accept == NodeFilter . FILTER_ACCEPT ) return newNode ; else if ( accept == NodeFilter . FILTER_SKIP && newNode . hasChil...
Internal function . Return the first child Node from the input node after applying filter whatToshow . The current node is not consulted or set .
121,101
private Node getLastChild ( Node node ) { if ( node == null ) return null ; Node newNode = node . getLastChild ( ) ; if ( newNode == null ) return null ; int accept = acceptNode ( newNode ) ; if ( accept == NodeFilter . FILTER_ACCEPT ) return newNode ; else if ( accept == NodeFilter . FILTER_SKIP && newNode . hasChildN...
Internal function . Return the last child Node from the input node after applying filter whatToshow . The current node is not consulted or set .
121,102
private short acceptNode ( Node node ) { if ( ( whatToShow & ( 1 << node . getNodeType ( ) - 1 ) ) != 0 ) return NodeFilter . FILTER_ACCEPT ; else return NodeFilter . FILTER_SKIP ; }
Internal function . The node whatToShow and the filter are combined into one result .
121,103
public void computeSpecificity ( CombinedSelector . Specificity spec ) { for ( SelectorPart item : list ) { item . computeSpecificity ( spec ) ; } }
Computes specificity of this selector
121,104
private CSSProperty createInherit ( int i ) { try { Class < ? extends CSSProperty > clazz = types . get ( i ) ; CSSProperty property = CSSProperty . Translator . createInherit ( clazz ) ; if ( property != null ) return property ; throw new IllegalAccessException ( "No inherit value for: " + clazz . getName ( ) ) ; } ca...
Creates INHERIT value of given class
121,105
public boolean vary ( Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { if ( terms . size ( ) == 1 && checkInherit ( ALL_VARIANTS , terms . get ( 0 ) , properties ) ) return true ; for ( IntegerRef i = new IntegerRef ( 0 ) ; i . get ( ) < terms . size ( ) ; i . inc ( ) ) { boolean passed ...
Test all terms
121,106
public boolean tryOneTermVariant ( int variant , Declaration d , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { if ( d . size ( ) != 1 ) return false ; if ( checkInherit ( variant , d . get ( 0 ) , properties ) ) return true ; this . terms = new ArrayList < Term < ? > > ( ) ; this . te...
Uses variator functionality to test selected variant on term
121,107
public boolean tryMultiTermVariant ( int variant , Map < String , CSSProperty > properties , Map < String , Term < ? > > values , Term < ? > ... terms ) { this . terms = Arrays . asList ( terms ) ; if ( this . terms . size ( ) == 1 && checkInherit ( variant , this . terms . get ( 0 ) , properties ) ) return true ; retu...
Uses variator functionality to test selected variant on more terms . This is used when variant is represented by more terms . Since usually only one term per variant is used only one multiple variant is allowed per variator and should be placed as the last one
121,108
public void assignDefaults ( Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { SupportedCSS css = CSSFactory . getSupportedCSS ( ) ; for ( String name : names ) { CSSProperty dp = css . getDefaultProperty ( name ) ; if ( dp != null ) properties . put ( name , dp ) ; Term < ? > dv = css . ...
Assigns the default values to all the properties .
121,109
public int getOriginOrder ( ) { if ( important ) { if ( origin == StyleSheet . Origin . AUTHOR ) return 4 ; else if ( origin == StyleSheet . Origin . AGENT ) return 1 ; else return 5 ; } else { if ( origin == StyleSheet . Origin . AUTHOR ) return 3 ; else if ( origin == StyleSheet . Origin . AGENT ) return 1 ; else ret...
Computes the priority order of the declaration based on its origin and importance according to the CSS specification .
121,110
public void addDeclaration ( Element el , PseudoElementType pseudo , Declaration decl ) { List < Declaration > list = getOrCreate ( el , pseudo ) ; list . add ( decl ) ; }
Adds a declaration for a specified list . If the list does not exist yet it is created .
121,111
public void sortDeclarations ( Element el , PseudoElementType pseudo ) { List < Declaration > list = get ( el , pseudo ) ; if ( list != null ) Collections . sort ( list ) ; }
Sorts the given list according to the rule specificity .
121,112
private static int [ ] hslToRgb ( float h , float s , float l ) { int [ ] ret = new int [ 3 ] ; float m2 = ( l <= 0.5f ) ? l * ( s + 1 ) : l + s - l * s ; float m1 = l * 2 - m2 ; ret [ 0 ] = Math . round ( hueToRgb ( m1 , m2 , h + 1.0f / 3.0f ) * MAX_VALUE ) ; ret [ 1 ] = Math . round ( hueToRgb ( m1 , m2 , h ) * MAX_V...
Converts the HSL color model to RGB
121,113
public Token nextToken ( ) { if ( lexer . _input == null ) { throw new IllegalStateException ( "nextToken requires a non-null input stream." ) ; } else { int tokenStartMarker = lexer . _input . mark ( ) ; try { Token ttype1 ; label110 : while ( ! lexer . _hitEOF ) { lexer . _token = null ; lexer . _channel = Token . DE...
Implements Lexer s next token with extra token passing from recovery function
121,114
public CSSToken generateEOFRecover ( ) { CSSToken t = null ; if ( ls . aposOpen ) { ls . aposOpen = false ; t = new CSSToken ( typeMapper . get ( APOS ) , ls , lexerTypeMapper ) ; t . setText ( "'" ) ; } else if ( ls . quotOpen ) { ls . quotOpen = false ; t = new CSSToken ( typeMapper . get ( QUOT ) , ls , lexerTypeMap...
Recovers from unexpected EOF by preparing new token
121,115
private void consumeUntilBalanced ( IntervalSet follow ) { log . debug ( "Lexer entered consumeUntilBalanced with {} and follow {}" , ls , follow ) ; int c ; do { c = input . LA ( 1 ) ; if ( c == '\'' && ls . quotOpen == false ) { ls . aposOpen = ! ls . aposOpen ; } else if ( c == '"' && ls . aposOpen == false ) { ls ....
Eats characters until on from follow is found and Lexer state is balanced at the moment
121,116
private boolean consumeAnyButEOF ( ) { int c = input . LA ( 1 ) ; if ( c == CharStream . EOF ) return false ; if ( log . isTraceEnabled ( ) ) log . trace ( "Lexer consumes '{}' while consumeButEOF" , Character . toString ( ( char ) c ) ) ; input . consume ( ) ; return true ; }
Consumes arbitrary character but EOF
121,117
public static final TermFactory getTermFactory ( ) { if ( tf == null ) { try { @ SuppressWarnings ( "unchecked" ) Class < ? extends TermFactory > clazz = ( Class < ? extends TermFactory > ) Class . forName ( DEFAULT_TERM_FACTORY ) ; Method m = clazz . getMethod ( "getInstance" ) ; registerTermFactory ( ( TermFactory ) ...
Returns TermFactory registered in step above
121,118
public static final SupportedCSS getSupportedCSS ( ) { if ( css == null ) { try { @ SuppressWarnings ( "unchecked" ) Class < ? extends SupportedCSS > clazz = ( Class < ? extends SupportedCSS > ) Class . forName ( DEFAULT_SUPPORTED_CSS ) ; Method m = clazz . getMethod ( "getInstance" ) ; registerSupportedCSS ( ( Support...
Returns registered SupportedCSS
121,119
public static final RuleFactory getRuleFactory ( ) { if ( rf == null ) { try { @ SuppressWarnings ( "unchecked" ) Class < ? extends RuleFactory > clazz = ( Class < ? extends RuleFactory > ) Class . forName ( DEFAULT_RULE_FACTORY ) ; Method m = clazz . getMethod ( "getInstance" ) ; registerRuleFactory ( ( RuleFactory ) ...
Returns registered RuleFactory
121,120
public static final DeclarationTransformer getDeclarationTransformer ( ) { if ( dt == null ) { try { @ SuppressWarnings ( "unchecked" ) Class < ? extends DeclarationTransformerImpl > clazz = ( Class < ? extends DeclarationTransformerImpl > ) Class . forName ( DEFAULT_DECLARATION_TRANSFORMER ) ; Method m = clazz . getMe...
Returns the registered DeclarationTransformer
121,121
public static final void registerNodeDataInstance ( Class < ? extends NodeData > clazz ) { try { @ SuppressWarnings ( "unused" ) NodeData test = clazz . newInstance ( ) ; ndImpl = clazz ; } catch ( InstantiationException e ) { throw new RuntimeException ( "NodeData implemenation (" + clazz . getName ( ) + ") doesn't pr...
Registers node data instance . Instance must provide no - argument Constructor
121,122
public static final NodeData createNodeData ( ) { if ( ndImpl == null ) { try { @ SuppressWarnings ( "unchecked" ) Class < ? extends NodeData > clazz = ( Class < ? extends NodeData > ) Class . forName ( DEFAULT_NODE_DATA_IMPL ) ; registerNodeDataInstance ( clazz ) ; log . debug ( "Registered {} as default NodeData inst...
Creates instance of NodeData
121,123
public static final StyleSheet parse ( String fileName , String encoding ) throws CSSException , IOException { try { File f = new File ( fileName ) ; URL url = f . toURI ( ) . toURL ( ) ; return parse ( url , encoding ) ; } catch ( MalformedURLException e ) { String message = "Unable to construct URL from fileName: " +...
Parses file into StyleSheet . Internally transforms file to URL
121,124
public static final StyleSheet parse ( String css ) throws IOException , CSSException { URL base = new URL ( "file:///base/url/is/not/specified" ) ; return getCSSParserFactory ( ) . parse ( css , getNetworkProcessor ( ) , null , SourceType . EMBEDDED , base ) ; }
Parses text into StyleSheet
121,125
public boolean matches ( MediaQuery q ) { if ( q . getType ( ) != null ) { if ( q . getType ( ) . equals ( "all" ) ) { if ( q . isNegative ( ) ) return false ; } else if ( q . getType ( ) . equals ( this . getType ( ) ) == q . isNegative ( ) ) return false ; } for ( MediaExpression e : q ) { if ( ! this . matches ( e )...
Checks if this media specification matches a given media query .
121,126
public boolean matches ( MediaExpression e ) { String fs = e . getFeature ( ) ; boolean isMin = false ; boolean isMax = false ; if ( fs . startsWith ( "min-" ) ) { isMin = true ; fs = fs . substring ( 4 ) ; } else if ( fs . startsWith ( "max-" ) ) { isMax = true ; fs = fs . substring ( 4 ) ; } Feature feature = getFeat...
Checks if this media specification matches a given media query expression .
121,127
public boolean matchesOneOf ( List < MediaQuery > queries ) { for ( MediaQuery q : queries ) { if ( matches ( q ) ) return true ; } return false ; }
Checks whether this media specification matches to at least one of the given media queries .
121,128
protected Float getExpressionLengthPx ( MediaExpression e ) { if ( e . size ( ) == 1 ) { Term < ? > term = e . get ( 0 ) ; if ( term instanceof TermLength ) return pxLength ( ( TermLength ) term ) ; else return null ; } else return null ; }
Obtains the length specified by the given media query expression .
121,129
protected Float getExpressionResolution ( MediaExpression e ) { if ( e . size ( ) == 1 ) { Term < ? > term = e . get ( 0 ) ; if ( term instanceof TermResolution ) return dpiResolution ( ( TermResolution ) term ) ; else return null ; } else return null ; }
Obtains the resolution specified by the given media query expression .
121,130
protected Float getExpressionRatio ( MediaExpression e ) { if ( e . size ( ) == 2 ) { Term < ? > term1 = e . get ( 0 ) ; Term < ? > term2 = e . get ( 1 ) ; if ( term1 instanceof TermInteger && term2 instanceof TermInteger && ( ( ( TermInteger ) term2 ) . getOperator ( ) == Operator . SLASH ) ) return ( ( TermInteger ) ...
Obtains the ratio specified by the given media query expression .
121,131
protected Integer getExpressionInteger ( MediaExpression e ) { if ( e . size ( ) == 1 ) { Term < ? > term = e . get ( 0 ) ; if ( term instanceof TermInteger ) return ( ( TermInteger ) term ) . getIntValue ( ) ; else return null ; } else return null ; }
Obtains the integer specified by the given media query expression .
121,132
protected String getExpressionIdentifier ( MediaExpression e ) { if ( e . size ( ) == 1 ) { Term < ? > term = e . get ( 0 ) ; if ( term instanceof TermIdent ) return ( ( TermIdent ) term ) . getValue ( ) . trim ( ) . toLowerCase ( Locale . ENGLISH ) ; else return null ; } else return null ; }
Obtains the identifier specified by the given media query expression .
121,133
protected Float pxLength ( TermLength spec ) { float nval = spec . getValue ( ) ; TermLength . Unit unit = spec . getUnit ( ) ; switch ( unit ) { case pt : return ( nval * dpi ) / 72.0f ; case in : return nval * dpi ; case cm : return ( nval * dpi ) / 2.54f ; case mm : return ( nval * dpi ) / 25.4f ; case q : return ( ...
Converts a length from a CSS length to px .
121,134
protected Float dpiResolution ( TermResolution spec ) { float nval = spec . getValue ( ) ; TermLength . Unit unit = spec . getUnit ( ) ; switch ( unit ) { case dpi : return nval ; case dpcm : return nval * 2.54f ; case dppx : return nval * getResolution ( ) ; default : return null ; } }
Converts a resolution from a CSS length to dpi .
121,135
protected void loadDefaults ( ) { width = 1100 ; height = 850 ; deviceWidth = 1920 ; deviceHeight = 1200 ; color = 8 ; colorIndex = 0 ; monochrome = 0 ; resolution = 96 ; scanInterlace = false ; grid = 0 ; }
Loads some reasonable defaults that correspond to a normal desktop configuration .
121,136
protected List < TermFunction . Gradient . ColorStop > decodeColorStops ( List < List < Term < ? > > > args , int firstStop ) { boolean valid = true ; List < TermFunction . Gradient . ColorStop > colorStops = null ; if ( args . size ( ) > firstStop ) { colorStops = new ArrayList < > ( ) ; for ( int i = firstStop ; vali...
Loads the color stops from the gunction arguments .
121,137
public D get ( E el , P pseudo ) { D ret ; if ( pseudo == null ) ret = mainMap . get ( el ) ; else { HashMap < P , D > map = pseudoMaps . get ( el ) ; if ( map == null ) ret = null ; else ret = map . get ( pseudo ) ; } return ret ; }
Gets the data for the given element and pseudo - element .
121,138
public D getOrCreate ( E el , P pseudo ) { D ret ; if ( pseudo == null ) { ret = mainMap . get ( el ) ; if ( ret == null ) { ret = createDataInstance ( ) ; mainMap . put ( el , ret ) ; } } else { HashMap < P , D > map = pseudoMaps . get ( el ) ; if ( map == null ) { map = new HashMap < P , D > ( ) ; pseudoMaps . put ( ...
Gets the data or creates an empty list if it does not exist yet .
121,139
public void put ( E el , P pseudo , D data ) { if ( pseudo == null ) mainMap . put ( el , data ) ; else { HashMap < P , D > map = pseudoMaps . get ( el ) ; if ( map == null ) { map = new HashMap < P , D > ( ) ; pseudoMaps . put ( el , map ) ; } map . put ( pseudo , data ) ; } }
Sets the data for the specified element and pseudo - element .
121,140
public Set < P > pseudoSet ( E el ) { HashMap < P , D > map = pseudoMaps . get ( el ) ; if ( map == null ) return Collections . emptySet ( ) ; else return map . keySet ( ) ; }
Gets all the pseudo elements that are available for the given element .
121,141
public boolean hasPseudo ( E el , P pseudo ) { HashMap < P , D > map = pseudoMaps . get ( el ) ; if ( map == null ) return false ; else return map . containsKey ( pseudo ) ; }
Checks if the given pseudo element is available for the given element
121,142
private void considerType ( TermFloatValue term ) { TermNumeric . Unit unit = term . getUnit ( ) ; if ( utype == Type . none ) { if ( unit != null && unit . getType ( ) != Type . none ) { utype = unit . getType ( ) ; } else if ( term instanceof TermPercent ) { utype = Type . length ; } else if ( term instanceof TermNum...
isLength isFrequency isAngle isTime isNumber isInteger
121,143
private URL extractBase ( TerminalNode node ) { CSSToken ct = ( CSSToken ) node . getSymbol ( ) ; return ct . getBase ( ) ; }
extract base from parse tree node
121,144
private String extractIdUnescaped ( String id ) { if ( ! id . isEmpty ( ) && ! Character . isDigit ( id . charAt ( 0 ) ) ) { return org . unbescape . css . CssEscape . unescapeCss ( id ) ; } return null ; }
check if string is valid ID
121,145
private String generateSpaces ( int count ) { String spaces = "" ; for ( int i = 0 ; i < count ; i ++ ) { spaces += " " ; } return spaces ; }
generate spaces for pretty debug printing
121,146
private List < ParseTree > filterSpaceTokens ( List < ParseTree > inputArrayList ) { List < ParseTree > ret = new ArrayList < ParseTree > ( inputArrayList . size ( ) ) ; for ( ParseTree item : inputArrayList ) { if ( ! ( item instanceof TerminalNode ) || ( ( TerminalNodeImpl ) item ) . getSymbol ( ) . getType ( ) != CS...
remove terminal node emtpy tokens from input list
121,147
private boolean ctxHasErrorNode ( ParserRuleContext ctx ) { for ( int i = 0 ; i < ctx . children . size ( ) ; i ++ ) { if ( ctx . getChild ( i ) instanceof ErrorNode ) { return true ; } } return false ; }
check if rule context contains error node
121,148
public void addMatch ( Element e , PseudoClassType pseudoClass ) { if ( elements == null ) elements = new HashMap < Element , Set < PseudoClassType > > ( ) ; Set < PseudoClassType > classes = elements . get ( e ) ; if ( classes == null ) { classes = new HashSet < PseudoClassType > ( 2 ) ; elements . put ( e , classes )...
Assigns a pseudo class to the given element . Multiple pseudo classes may be assigned to a single element .
121,149
public void removeMatch ( Element e , PseudoClassType pseudoClass ) { if ( elements != null ) { Set < PseudoClassType > classes = elements . get ( e ) ; if ( classes != null ) classes . remove ( pseudoClass ) ; } }
Removes the pseudo class from the given element .
121,150
public void addMatch ( String name , PseudoClassType pseudoClass ) { if ( names == null ) names = new HashMap < String , Set < PseudoClassType > > ( ) ; Set < PseudoClassType > classes = names . get ( name ) ; if ( classes == null ) { classes = new HashSet < PseudoClassType > ( 2 ) ; names . put ( name , classes ) ; } ...
Assigns a pseudo class to the given element name . Element names are case - insensitive . Multiple pseudo classes may be assigned to a single element name .
121,151
public void removeMatch ( String name , PseudoClassType pseudoClass ) { if ( names != null ) { Set < PseudoClassType > classes = names . get ( name ) ; if ( classes != null ) classes . remove ( pseudoClass ) ; } }
Removes the pseudo class from the given element name . Element names are case - insensitive .
121,152
public StyleMap evaluateDOM ( Document doc , MediaSpec media , final boolean inherit ) { DeclarationMap declarations = assingDeclarationsToDOM ( doc , media , inherit ) ; StyleMap nodes = new StyleMap ( declarations . size ( ) ) ; Traversal < StyleMap > traversal = new Traversal < StyleMap > ( doc , ( Object ) declarat...
Evaluates CSS properties of DOM tree
121,153
protected DeclarationMap assingDeclarationsToDOM ( Document doc , MediaSpec media , final boolean inherit ) { classifyAllSheets ( media ) ; DeclarationMap declarations = new DeclarationMap ( ) ; if ( rules != null && ! rules . isEmpty ( ) ) { Traversal < DeclarationMap > traversal = new Traversal < DeclarationMap > ( d...
Creates map of declarations assigned to each element of a DOM tree
121,154
protected void classifyAllSheets ( MediaSpec mediaspec ) { rules = new Holder ( ) ; AnalyzerUtil . classifyAllSheets ( sheets , rules , mediaspec ) ; }
Classifies the rules in all the style sheets .
121,155
public Specificity computeSpecificity ( ) { Specificity spec = new SpecificityImpl ( ) ; for ( Selector s : list ) s . computeSpecificity ( spec ) ; return spec ; }
Computes specificity of selector
121,156
public StyleSheet parse ( Object source , NetworkProcessor network , String encoding , SourceType type , Element inline , boolean inlinePriority , URL base ) throws IOException , CSSException { StyleSheet sheet = ( StyleSheet ) CSSFactory . getRuleFactory ( ) . createStyleSheet ( ) . unlock ( ) ; Preparator preparator ...
Parses source of given type
121,157
public StyleSheet parse ( Object source , NetworkProcessor network , String encoding , SourceType type , URL base ) throws IOException , CSSException { if ( type == SourceType . INLINE ) throw new IllegalArgumentException ( "Missing element for INLINE input" ) ; return parse ( source , network , encoding , type , null ...
Parses source of given type . Uses no element .
121,158
public StyleSheet append ( Object source , NetworkProcessor network , String encoding , SourceType type , Element inline , boolean inlinePriority , StyleSheet sheet , URL base ) throws IOException , CSSException { Preparator preparator = new SimplePreparator ( inline , inlinePriority ) ; return parseAndImport ( source ...
Appends parsed source to passed style sheet . This style sheet must be IMPERATIVELY parsed by this factory to guarantee proper appending
121,159
protected StyleSheet parseAndImport ( Object source , NetworkProcessor network , String encoding , SourceType type , StyleSheet sheet , Preparator preparator , URL base , List < MediaQuery > media ) throws CSSException , IOException { CSSParser parser = createParser ( source , network , encoding , type , base ) ; CSSPa...
Parses the source using the given infrastructure and returns the resulting style sheet . The imports are handled recursively .
121,160
private static CSSParser createParser ( Object source , NetworkProcessor network , String encoding , SourceType type , URL base ) throws IOException , CSSException { CSSInputStream input = getInput ( source , network , encoding , type ) ; input . setBase ( base ) ; return createParserForInput ( input ) ; }
creates the parser
121,161
protected static CSSException encapsulateException ( Throwable t , String msg ) { log . error ( "THROWN:" , t ) ; return new CSSException ( msg , t ) ; }
Creates new CSSException which encapsulates cause
121,162
public boolean repeat ( Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { for ( int i = 0 ; i < times ; i ++ ) { if ( ! operation ( i , properties , values ) ) return false ; } return true ; }
Repeats operations on terms
121,163
public void assignPropertyNames ( String ... propertyNames ) throws IllegalArgumentException { if ( propertyNames . length != times ) throw new IllegalArgumentException ( "Invalid length of propertyNames in Repeater." ) ; this . names = Arrays . asList ( propertyNames ) ; }
Assigns property names
121,164
public void assignTerms ( Term < ? > ... terms ) throws IllegalArgumentException { if ( terms . length != times ) throw new IllegalArgumentException ( "Invalid length of terms in Repeater." ) ; this . terms = Arrays . asList ( terms ) ; }
Assigns terms to repeater
121,165
public boolean parseDeclaration ( Declaration d , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { final String propertyName = d . getProperty ( ) ; if ( ! css . isSupportedCSSProperty ( propertyName ) || d . isEmpty ( ) ) return false ; try { Method m = methods . get ( propertyName ) ; ...
Core function . Parses CSS declaration into structure applicable to DataNodeImpl
121,166
public < T extends CSSProperty > T genericPropertyRaw ( Class < T > type , Set < T > intersection , TermIdent term ) { try { String name = term . getValue ( ) . replace ( "-" , "_" ) . toUpperCase ( ) ; T property = CSSProperty . Translator . valueOf ( type , name ) ; if ( intersection != null && intersection . contain...
Converts TermIdent into CSSProperty using intersection set . CSSProperty . Translator is used .
121,167
protected < T extends CSSProperty > boolean genericProperty ( Class < T > type , TermIdent term , boolean avoidInherit , Map < String , CSSProperty > properties , String propertyName ) { T property = genericPropertyRaw ( type , null , term ) ; if ( property == null || ( avoidInherit && property . equalsInherit ( ) ) ) ...
Converts TermIdent into value of enum of given class and stores it into properties map under key property
121,168
protected < T extends CSSProperty > boolean genericTermIdent ( Class < T > type , Term < ? > term , boolean avoidInherit , String propertyName , Map < String , CSSProperty > properties ) { if ( term instanceof TermIdent ) { return genericProperty ( type , ( TermIdent ) term , avoidInherit , properties , propertyName ) ...
Converts TermIdent into value of CSSProperty for given class
121,169
protected < T extends CSSProperty > boolean genericTermColor ( Term < ? > term , String propertyName , T colorIdentification , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { if ( term instanceof TermColor ) { properties . put ( propertyName , colorIdentification ) ; values . put ( prop...
Converts term into Color and stored values and types in maps
121,170
protected < T extends CSSProperty > boolean genericTermLength ( Term < ? > term , String propertyName , T lengthIdentification , ValueRange range , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { if ( term instanceof TermInteger && ( ( TermInteger ) term ) . getUnit ( ) . equals ( TermN...
Converts term into TermLength and stores values and types in maps
121,171
protected < T extends CSSProperty > boolean genericTerm ( Class < ? extends Term < ? > > termType , Term < ? > term , String propertyName , T typeIdentification , ValueRange range , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { if ( termType . isInstance ( term ) ) { if ( range != Val...
Check whether given declaration contains one term of given type . It is able to check even whether is above zero for numeric values
121,172
protected < T extends CSSProperty > boolean genericOneIdent ( Class < T > type , Declaration d , Map < String , CSSProperty > properties ) { if ( d . size ( ) != 1 ) return false ; return genericTermIdent ( type , d . get ( 0 ) , ALLOW_INH , d . getProperty ( ) , properties ) ; }
Processes declaration which is supposed to contain one identification term
121,173
protected < T extends CSSProperty > boolean genericOneIdentOrColor ( Class < T > type , T colorIdentification , Declaration d , Map < String , CSSProperty > properties , Map < String , Term < ? > > values ) { if ( d . size ( ) != 1 ) return false ; return genericTermIdent ( type , d . get ( 0 ) , ALLOW_INH , d . getPro...
Processes declaration which is supposed to contain one identification term or one TermColor
121,174
@ SuppressWarnings ( "unchecked" ) protected < R > R service ( ServiceRequest < R > request ) throws WssServiceException { R result ; String response = "" ; try { HttpRequestBase httpRequest = createHttpRequest ( request ) ; RequestConfig requestConfig = RequestConfig . custom ( ) . setCookieSpec ( CookieSpecs . STANDA...
The method service the given request .
121,175
public static void copyResource ( String resource , File destination ) throws IOException { InputStream is = null ; FileOutputStream fos = null ; try { is = FileUtils . class . getResourceAsStream ( "/" + resource ) ; fos = new FileOutputStream ( destination ) ; final byte [ ] buffer = new byte [ 10 * 1024 ] ; int len ...
Copy a classpath resource to a destination file .
121,176
public static boolean deleteRecursive ( File path ) throws FileNotFoundException { if ( ! path . exists ( ) ) { throw new FileNotFoundException ( path . getAbsolutePath ( ) ) ; } boolean success = true ; if ( path . isDirectory ( ) ) { for ( File f : path . listFiles ( ) ) { success = success && FileUtils . deleteRecur...
Delete all files rooted in the given path .
121,177
public UpdateInventoryRequest offlineUpdate ( String orgToken , String product , Boolean removeBeforeAdd , String productVersion , Collection < AgentProjectInfo > projectInfos , String userKey , String requesterEmail , String scanComment , String productToken ) { return requestFactory . newUpdateInventoryRequest ( orgT...
Generates a file with json representation of the update request .
121,178
public GetDependencyDataResult getDependencyData ( String orgToken , String product , String productVersion , Collection < AgentProjectInfo > projectInfos , String userKey , String requesterEmail , String productToken ) throws WssServiceException { return client . getDependencyData ( requestFactory . newDependencyDataR...
Gets additional data for given dependencies .
121,179
public CheckVulnerabilitiesResult checkVulnerabilities ( String orgToken , String product , String productVersion , Collection < AgentProjectInfo > projectInfos , String userKey , String requesterEmail , String productToken ) throws WssServiceException { return client . checkVulnerabilities ( requestFactory . newCheckV...
Gets vulnerabilities data for given dependencies .
121,180
public File generate ( File outputDir , boolean zip , boolean prettyJson ) throws IOException { if ( request == null ) { throw new IllegalStateException ( "Update inventory request is null" ) ; } File workDir = new File ( outputDir , "whitesource" ) ; if ( ! workDir . exists ( ) && ! workDir . mkdir ( ) ) { throw new I...
The method generates the update request file .
121,181
public Map < ChecksumType , String > calculateJavaScriptHashes ( File file ) throws WssHashException { Map < ChecksumType , String > checksums = new EnumMap < > ( ChecksumType . class ) ; try { long fileLength = file . length ( ) ; if ( fileLength >= FILE_MAX_SIZE_THRESHOLD ) { logger . debug ( "Ignore file {}, ({}): m...
Removes all JavaScript comments from the file and calculates SHA - 1 checksum .
121,182
public Map < ChecksumType , String > calculateJavaScriptHashes ( byte [ ] byteArray ) throws WssHashException { Map < ChecksumType , String > checksums = new EnumMap < > ( ChecksumType . class ) ; try { String fileContent = IOUtils . toString ( byteArray , UTF_8 ) ; ParseResult parseResult = new JavaScriptParser ( ) . ...
Removes all JavaScript header comments from the file and calculates SHA - 1 checksum .
121,183
public String calculateSha1ByNameVersionAndType ( String name , String version , DependencyType dependencyType ) throws IOException { String sha1ToCalc = name + UNDERSCORE + version + UNDERSCORE + dependencyType . toString ( ) ; return calculateByteArraySHA1 ( sha1ToCalc . getBytes ( StandardCharsets . UTF_8 ) ) ; }
Calculates SHA - 1 for library by name version and dependencyType
121,184
private byte [ ] stripWhiteSpaces ( byte [ ] data ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; for ( byte b : data ) { if ( ! WHITESPACES . contains ( b ) ) { bos . write ( b ) ; } } return bos . toByteArray ( ) ; }
Removes all whitespaces from the text - the same way that Shir is doing for source files .
121,185
public static String compress ( String text ) throws IOException { String result ; if ( text != null && text . length ( ) > 0 ) { try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( text . length ( ) ) ; GZIPOutputStream gzipos = new GZIPOutputStream ( baos ) ; ) { gzipos . write ( text . getBytes ( UTF_8 ) ...
The method compresses the string using gzip .
121,186
public static String decompress ( String text ) throws IOException { if ( text == null || text . length ( ) == 0 ) { return text ; } byte [ ] bytes = Base64 . decodeBase64 ( text ) ; try ( GZIPInputStream gis = new GZIPInputStream ( new ByteArrayInputStream ( bytes ) ) ; BufferedReader bf = new BufferedReader ( new Inp...
The method decompresses the string using gzip .
121,187
public static void compressString ( InputStream inputStream , OutputStream outputStream ) throws IOException { try ( ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ( ) ) { fillExportStreamCompress ( inputStream , byteArrayOutputStream ) ; String result = getStringFromEncode ( byteArrayOutputStr...
The method compresses the big strings using gzip - low memory via Streams
121,188
public static void decompressString ( InputStream inputStream , OutputStream outputStream ) throws IOException { try ( InputStream bufferedInputStream = new BufferedInputStream ( inputStream ) ; PrintWriter printWriter = new PrintWriter ( outputStream ) ; ) { byte [ ] buffer = new byte [ BYTES_BUFFER_SIZE ] ; int len ;...
The method decompresses the big strings using gzip - low memory via Streams
121,189
public static String compressChunks ( String text ) throws IOException { Path tempFolder = Paths . get ( JAVA_TEMP_DIR , ZIP_UTILS ) ; File tempFileIn = File . createTempFile ( TMP_IN_ , ZIP_UTILS_SUFFIX , tempFolder . toFile ( ) ) ; File tempFileOut = File . createTempFile ( TMP_OUT_ , ZIP_UTILS_SUFFIX , tempFolder . ...
The method compresses the big strings using gzip - low memory via the File system
121,190
private static void writeChunkBytes ( String text , File tempFileIn ) throws IOException { try ( FileOutputStream writer = new FileOutputStream ( tempFileIn ) ) { int chunk = text . length ( ) ; if ( text . length ( ) > STRING_MAX_SIZE ) { chunk = text . length ( ) / STRING_MAX_SIZE ; } int startString = 0 ; while ( st...
Writes a string piece by piece to file
121,191
protected VelocityEngine createTemplateEngine ( Properties properties ) { Properties actualProperties = properties ; if ( actualProperties == null ) { actualProperties = new Properties ( ) ; } String resourceLoader = actualProperties . getProperty ( VelocityEngine . RESOURCE_LOADER ) ; if ( StringUtils . isBlank ( reso...
Create and initialize a template engine to use for generating reports .
121,192
protected VelocityContext createTemplateContext ( ) { VelocityContext context = new VelocityContext ( ) ; context . put ( "result" , result ) ; context . put ( "hasRejections" , result . hasRejections ( ) ) ; context . put ( "licenses" , createLicenseHistogram ( result ) ) ; context . put ( "creationTime" , new SimpleD...
Create the context holding all the information of the report .
121,193
protected void copyReportResources ( File workDir ) throws IOException { FileUtils . copyResource ( TEMPLATE_FOLDER + CSS_FILE , new File ( workDir , CSS_FILE ) ) ; }
Copy required resources for the report .
121,194
public ParseResult parse ( String fileContent ) { ParseResult result = null ; CompilerEnvirons environment = new CompilerEnvirons ( ) ; environment . setLanguageVersion ( 180 ) ; environment . setStrictMode ( false ) ; environment . setRecordingComments ( true ) ; environment . setAllowSharpComments ( true ) ; environm...
Parse the file content and return variants of the file .
121,195
private String removeHeaderComments ( String fileContent , SortedSet < Comment > comments ) { String headerlessFileContent = fileContent ; for ( Comment comment : comments ) { String commentValue = comment . getValue ( ) ; if ( headerlessFileContent . startsWith ( commentValue ) ) { headerlessFileContent = headerlessFi...
Go over each comment and remove from content until reaching the beginning of the actual code .
121,196
private static String executePowerShellCommand ( String command ) { try { String [ ] commandList = { POWER_SHELL , POWER_SHELL_COMMAND , command } ; ProcessBuilder pb = new ProcessBuilder ( commandList ) ; Process process = pb . start ( ) ; InputStream is = process . getInputStream ( ) ; InputStreamReader isr = new Inp...
Get the signature from file by execute process from power shell
121,197
private static List < String > getGenericTypeParameters ( String parameters ) { List < String > paramList = new ArrayList < String > ( ) ; int balanced = 0 ; StringBuilder current = new StringBuilder ( ) ; for ( int i = 0 ; i < parameters . length ( ) ; i ++ ) { char c = parameters . charAt ( i ) ; if ( balanced == 0 &...
parse generic type parameters making sure nested generics are taken into account
121,198
public < A extends Annotation > A findAnnotationOnBean ( Class < A > annotationType ) { return applicationContext . findAnnotationOnBean ( beanName , annotationType ) ; }
Attempts to find and return an annotation of the specified type declared on this side bar item .
121,199
public void destroy ( ) { if ( executorService != null ) { LOGGER . info ( "Shutting down message provider cache cleanup thread" ) ; cleanupJob . cancel ( true ) ; executorService . shutdown ( ) ; } }
Shuts down the cleanup thread .