idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
40,700
static public TypedPropertyDescriptor buildScriptablePropertyDescriptor ( String propertyName , Class beanClass , String getterName , String setterName ) { TypedPropertyDescriptor pd = _buildPropertyDescriptor ( propertyName , beanClass , getterName , setterName ) ; makeScriptable ( pd ) ; return pd ; }
Builds a scriptable property descriptor with the given information .
79
12
40,701
public static boolean isVisible ( FeatureDescriptor descriptor , IScriptabilityModifier constraint ) { if ( constraint == null ) { return true ; } IScriptabilityModifier modifier = getVisibilityModifier ( descriptor ) ; if ( modifier == null ) { return true ; } return modifier . satisfiesConstraint ( constraint ) ; }
Determine if the descriptor is visible given a visibility constraint .
71
13
40,702
protected static MethodDescriptor _buildMethodDescriptor ( Class actionClass , String methodName , String [ ] parameterNames , Class [ ] parameterTypes , Class [ ] actualParameterTypes ) { MethodDescriptor method ; assert ( parameterNames . length == parameterTypes . length ) : "Number of parameter names different from...
Builds a method descriptor with no explicit visibility .
241
10
40,703
protected static TypedPropertyDescriptor _buildPropertyDescriptor ( String propertyName , Class beanClass , String getterName , String setterName ) { try { return new TypedPropertyDescriptor ( propertyName , beanClass , getterName , setterName ) ; } catch ( IntrospectionException e ) { throw new RuntimeException ( "Fai...
Builds a property descriptor with no explicit visibility .
121
10
40,704
private static String makeFqn ( File file ) { String path = file . getAbsolutePath ( ) ; int srcIndex = path . indexOf ( "src" + File . separatorChar ) ; if ( srcIndex >= 0 ) { String fqn = path . substring ( srcIndex + 4 ) . replace ( File . separatorChar , ' ' ) ; return fqn . substring ( 0 , fqn . lastIndexOf ( ' ' ...
Note this is a giant hack we need to instead get the type name from the psiClass
175
18
40,705
private void assignSuperDfs ( IDynamicFunctionSymbol dfsDelegate , IGosuClass owner ) { IDynamicFunctionSymbol rawSuperDfs = dfsDelegate . getSuperDfs ( ) ; if ( rawSuperDfs instanceof DynamicFunctionSymbol ) { while ( rawSuperDfs . getBackingDfs ( ) instanceof DynamicFunctionSymbol && rawSuperDfs . getBackingDfs ( ) !...
Assign the super dfs in terms of the deriving class s type parameters
235
16
40,706
public static Throwable findExceptionCause ( Throwable e ) { Throwable error = e ; Throwable cause = e ; while ( ( error . getCause ( ) != null ) && ( error . getCause ( ) != error ) ) { cause = error . getCause ( ) ; error = cause ; } return cause ; }
Given an Exception finds the root cause and returns it . This may end up returning the originally passed exception if that was the root cause .
68
27
40,707
public static void throwArgMismatchException ( IllegalArgumentException exceptionToWrap , String featureName , Class [ ] actualParameters , Object [ ] args ) { String argTypes = "(" ; for ( int i = 0 ; i < actualParameters . length ; i ++ ) { Class aClass = actualParameters [ i ] ; if ( i > 0 ) { argTypes += " ," ; } a...
This method can be used to provide a more informative type - mismatch exception message than the standard java reflection does with its IllegalArgumentException .
234
28
40,708
public static < T extends Throwable > T findException ( Class < T > exceptionTypeToFind , Throwable t ) { Throwable cause = t ; while ( cause != null ) { if ( exceptionTypeToFind . isAssignableFrom ( cause . getClass ( ) ) ) { //noinspection unchecked return ( T ) cause ; } if ( cause == cause . getCause ( ) ) { return...
Given an Exception and an Exception type to look for finds the exception of that type or returns null if none of that type exist .
103
26
40,709
public ParseException removeParseException ( ResourceKey keyToRemove ) { if ( _lnf != null ) { return ( ParseException ) removeParseIssue ( keyToRemove , _lnf . _parseExceptions ) ; } return null ; }
Removes the specified parse exception or removes them all if the specified exception is null .
55
17
40,710
@ SuppressWarnings ( "unchecked" ) public < E extends IParsedElement > boolean getContainedParsedElementsByType ( Class < E > parsedElementType , List < E > listResults ) { return getContainedParsedElementsByTypes ( ( List < IParsedElement > ) listResults , parsedElementType ) ; }
Find all the parsed elements of a given type contained within this parsed element .
79
15
40,711
public String readUntil ( String character , boolean includeDeliminator ) { return readStreamUntil ( _javaProcess . getInputStream ( ) , includeDeliminator , character . toCharArray ( ) ) ; }
Reads a group of text from stdout . The line will start from the previous point until the read character . This method will block until the specified character is read .
45
34
40,712
protected < T extends IService , Q extends T > void defineService ( Class < ? extends T > service , Q defaultImplementation ) { if ( ! _definingServices ) { throw new IllegalStateException ( "Service definition must be done only in the defineServices() method." ) ; } if ( ! service . isInterface ( ) ) { throw new Illeg...
Defines a service provided by this ServiceKernel
195
10
40,713
@ Override public String getCurrentFunctionName ( ) { DynamicFunctionSymbol functionSymbol = _bodyContext . getCurrentDFS ( ) ; return ( functionSymbol == null ? null : functionSymbol . getName ( ) ) ; }
These methods should all be rolled directly onto FunctionBodyContext I believe
52
13
40,714
private static boolean isGosuClassAccessingProtectedOrInternalMethodOfClassInDifferentClassloader ( ICompilableTypeInternal callingClass , IType declaringClass , IRelativeTypeInfo . Accessibility accessibility ) { return ( accessibility != IRelativeTypeInfo . Accessibility . PUBLIC || AccessibilityUtil . forType ( decl...
Java will blow up if the package - level access is relied upon across class loaders though so we make the call reflectively .
167
26
40,715
@ SuppressWarnings ( "UnusedDeclaration" ) public static Bindings fromJson ( String json ) { try { return PARSER . get ( ) . parseJson ( json ) ; } catch ( ScriptException e ) { throw new RuntimeException ( e ) ; } }
Parse the JSON string as one of a javax . script . Bindings instance .
62
19
40,716
public static < S , T > Map < S , T > compactAndLockHashMap ( HashMap < S , T > map ) { if ( map == null || map . isEmpty ( ) ) { return Collections . emptyMap ( ) ; } if ( map . size ( ) == 1 ) { Map . Entry < S , T > stEntry = map . entrySet ( ) . iterator ( ) . next ( ) ; return Collections . singletonMap ( stEntry ...
Returns a compacted and locked map representing the map passed in . This method can freely change the implementation type of the map . I . e . it can return an emptyMap singletonMap or even a completely different map implementation .
163
46
40,717
public String parseDotPathWord ( String t ) { StringBuilder sb = t == null ? null : new StringBuilder ( t == null ? "" : t ) ; SourceCodeTokenizer tokenizer = getTokenizer ( ) ; while ( match ( null , ' ' ) ) { if ( sb != null ) { sb . append ( ' ' ) ; } int mark = tokenizer . mark ( ) ; if ( match ( null , null , Sour...
Parse a dot separated path as a single logical token
182
11
40,718
final void addError ( ParsedElement parsedElement , ResourceKey errorMsg ) { verify ( parsedElement , false , errorMsg , EMPTY_ARRAY ) ; }
Optimizations to avoid creating vararg array
35
9
40,719
protected IRExpression compileExpansionUsingArrayList ( IType rootType , IType rootComponentType , IType resultType , IType resultCompType , IType propertyType ) { // Evaluate the root and assign it to a temp variable IRSymbol tempRoot = _cc ( ) . makeAndIndexTempSymbol ( getDescriptor ( rootType ) ) ; IRStatement temp...
This method will compile the expansion using an ArrayList to collect temporary results . This is appropriate if the right - hand - side is a Collection or array if the root is an Iterable or Iterator or other object whose size can t easily be determined up - front or if the root is a nested Collection or array that wil...
348
71
40,720
private IType cacheType ( String name , Pair < IType , ITypeLoader > pair ) { if ( pair != null ) { IType type = pair . getFirst ( ) ; // We have to make sure we aren't replacing an existing type so we obey the return from the put. IType oldType = _typesByName . get ( name ) ; if ( oldType != null && oldType != CACHE_M...
Adds the type to the cache .
175
7
40,721
@ Override public ITypeRef create ( IType type ) { // already a proxy? return as is then if ( type instanceof ITypeRef ) { return ( ITypeRef ) type ; } if ( type instanceof INonLoadableType ) { throw new UnsupportedOperationException ( "Type references are not supported for nonloadable types: " + type . getName ( ) ) ;...
Wraps the actual class with a proxy .
194
9
40,722
private static void setupLoaderChainWithGosuUrl ( ClassLoader loader ) { UrlClassLoaderWrapper wrapped = UrlClassLoaderWrapper . wrapIfNotAlreadyVisited ( loader ) ; if ( wrapped == null ) { return ; } addGosuClassUrl ( wrapped ) ; if ( canWrapChain ( ) ) { if ( loader != ClassLoader . getSystemClassLoader ( ) ) { // w...
= null ;
140
3
40,723
public void update ( EditorHost editor ) { _editor = editor ; _icon . setIcon ( findIconForResults ( ) ) ; _feedback . repaint ( ) ; repaint ( ) ; editor . repaint ( ) ; }
Updates this panel with current parser feedback .
50
9
40,724
public final Object convertValue ( Object value , IType intrType ) { //================================================================================== // Null handling //================================================================================== if ( intrType == null ) { return null ; } //## todo: This is a h...
Given a value and a target Class return a compatible value via the target Class .
729
16
40,725
public Date makeDateFrom ( Object obj ) { if ( obj == null ) { return null ; } if ( obj instanceof IDimension ) { obj = ( ( IDimension ) obj ) . toNumber ( ) ; } if ( obj instanceof Date ) { return ( Date ) obj ; } if ( obj instanceof Number ) { return new Date ( ( ( Number ) obj ) . longValue ( ) ) ; } if ( obj instan...
Returns a new Date instance representing the object .
165
9
40,726
public Date parseDateTime ( String str ) throws java . text . ParseException { if ( str == null ) { return null ; } return DateFormat . getDateInstance ( ) . parse ( str ) ; }
Produce a date from a string using standard DateFormat parsing .
45
13
40,727
public static int getLineAtPosition ( JTextComponent editor , int position ) { if ( position <= 0 ) { return 1 ; } String s = editor . getText ( ) ; if ( position > s . length ( ) ) { position = s . length ( ) ; } try { return GosuStringUtil . countMatches ( editor . getText ( 0 , position ) , "\n" ) + 1 ; } catch ( Ba...
Gets the line at a given position in the editor
107
11
40,728
public static int getDeepestWhiteSpaceLineStartAfter ( String script , int offset ) { if ( offset < 0 ) { return offset ; } int i = offset ; while ( true ) { int lineStartAfter = getWhiteSpaceLineStartAfter ( script , i ) ; if ( lineStartAfter == - 1 ) { return i ; } else { i = lineStartAfter ; } } }
Eats whitespace lines after the given offset until it finds a non - whitespace line and returns the start of the last whitespace line found or the initial value if none was .
82
37
40,729
private void tryToEliminateTheScope ( ) { for ( int i = 0 ; i < _statements . length ; i ++ ) { Statement statement = _statements [ i ] ; if ( statement instanceof VarStatement || ( ! ( statement instanceof StatementList ) && statement . getContainedParsedElementsByType ( EvalExpression . class , null ) ) ) { return ; ...
A statement - list needs to push a new scope on the symbol table to provide a for local variable scoping . Since this is a relatively expensive operation we avoid pushing the scope if we know none of the statements declare variables .
94
45
40,730
public static String escapeAttribute ( String string ) { if ( string == null || string . length ( ) == 0 ) { return string ; } StringBuilder resultBuffer = null ; for ( int i = 0 , length = string . length ( ) ; i < length ; i ++ ) { String entity = null ; char ch = string . charAt ( i ) ; switch ( ch ) { case ' ' : en...
Escape a string for use as an HTML attribute by replacing all double quotes and & .
194
18
40,731
public static Map < String , ISettings > makeDefaultSettings ( Experiment experiment ) { Map < String , ISettings > settings = new TreeMap <> ( ) ; CompilerSettings compilerSettings = new CompilerSettings ( ) ; compilerSettings . resetToDefaultSettings ( experiment ) ; settings . put ( compilerSettings . getPath ( ) , ...
Reset Experiment - specific settings to defaults .
78
9
40,732
public static Map < String , ISettings > makeDefaultSettings ( ) { Map < String , ISettings > settings = new TreeMap <> ( ) ; AppearanceSettings appearanceSettings = new AppearanceSettings ( ) ; appearanceSettings . resetToDefaultSettings ( null ) ; settings . put ( appearanceSettings . getPath ( ) , appearanceSettings...
Reset Gosu Lab application - level settings to defaults .
74
12
40,733
public static Map < String , ISettings > mergeSettings ( Map < String , ISettings > old , Experiment experiment ) { Map < String , ISettings > defaultSettings = makeDefaultSettings ( experiment ) ; old . keySet ( ) . forEach ( key -> defaultSettings . put ( key , old . get ( key ) ) ) ; return defaultSettings ; }
Assumes settings map is ordered top - down in tree order
75
12
40,734
public void setSrcdir ( Path srcDir ) { if ( _src == null ) { _src = srcDir ; } else { _src . append ( srcDir ) ; } }
Set the source directories to find the source Gosu files .
40
12
40,735
public Curve25519KeyPair generateKeyPair ( ) { byte [ ] privateKey = provider . generatePrivateKey ( ) ; byte [ ] publicKey = provider . generatePublicKey ( privateKey ) ; return new Curve25519KeyPair ( publicKey , privateKey ) ; }
Generates a Curve25519 keypair .
61
9
40,736
public byte [ ] calculateAgreement ( byte [ ] publicKey , byte [ ] privateKey ) { if ( publicKey == null || privateKey == null ) { throw new IllegalArgumentException ( "Keys must not be null!" ) ; } if ( publicKey . length != 32 || privateKey . length != 32 ) { throw new IllegalArgumentException ( "Keys must be 32 byte...
Calculates an ECDH agreement .
100
9
40,737
public boolean verifySignature ( byte [ ] publicKey , byte [ ] message , byte [ ] signature ) { if ( publicKey == null || publicKey . length != 32 ) { throw new IllegalArgumentException ( "Invalid public key!" ) ; } if ( message == null || signature == null || signature . length != 64 ) { return false ; } return provid...
Verify a Curve25519 signature .
90
8
40,738
public byte [ ] calculateVrfSignature ( byte [ ] privateKey , byte [ ] message ) { if ( privateKey == null || privateKey . length != 32 ) { throw new IllegalArgumentException ( "Invalid private key!" ) ; } byte [ ] random = provider . getRandom ( 64 ) ; return provider . calculateVrfSignature ( random , privateKey , me...
Calculates a Unique Curve25519 signature .
83
10
40,739
public byte [ ] verifyVrfSignature ( byte [ ] publicKey , byte [ ] message , byte [ ] signature ) throws VrfSignatureVerificationFailedException { if ( publicKey == null || publicKey . length != 32 ) { throw new IllegalArgumentException ( "Invalid public key!" ) ; } if ( message == null || signature == null || signatur...
Verify a Unique Curve25519 signature .
124
9
40,740
private Record setDefault ( Record record ) { int size = record . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) if ( record . get ( i ) == null ) { @ SuppressWarnings ( "unchecked" ) Field < Object > field = ( Field < Object > ) record . field ( i ) ; if ( ! field . getDataType ( ) . nullable ( ) && ! field . getDataT...
Defaults fields that have a default value and are nullable .
123
13
40,741
protected Object convertToAsyncDriverTypes ( Object object ) { if ( object instanceof Enum ) { return ( ( Enum ) object ) . name ( ) ; } else if ( object instanceof LocalDateTime ) { LocalDateTime convert = ( LocalDateTime ) object ; return new org . joda . time . LocalDateTime ( convert . getYear ( ) , convert . getMo...
Async - driver uses joda - time instead of java - time so we need to convert it .
541
20
40,742
@ Override public void sql ( BindingSQLContext < JsonArray > ctx ) { // Depending on how you generate your SQL, you may need to explicitly distinguish // between jOOQ generating bind variables or inlined literals. If so, use this check: // ctx.render().paramType() == INLINED RenderContext context = ctx . render ( ) . v...
Rending a bind variable for the binding context s value and casting it to the json type
142
18
40,743
@ Override public void register ( BindingRegisterContext < JsonArray > ctx ) throws SQLException { ctx . statement ( ) . registerOutParameter ( ctx . index ( ) , Types . VARCHAR ) ; }
Registering VARCHAR types for JDBC CallableStatement OUT parameters
50
14
40,744
@ Override public void set ( BindingSetStatementContext < JsonArray > ctx ) throws SQLException { ctx . statement ( ) . setString ( ctx . index ( ) , Objects . toString ( ctx . convert ( converter ( ) ) . value ( ) , null ) ) ; }
Converting the JsonArray to a String value and setting that on a JDBC PreparedStatement
66
20
40,745
@ Override public void get ( BindingGetResultSetContext < JsonArray > ctx ) throws SQLException { ctx . convert ( converter ( ) ) . value ( ctx . resultSet ( ) . getString ( ctx . index ( ) ) ) ; }
Getting a String value from a JDBC ResultSet and converting that to a JsonArray
59
18
40,746
protected Collection < JavaWriter > writeExtraData ( SchemaDefinition definition , Function < File , JavaWriter > writerGenerator ) { return Collections . emptyList ( ) ; }
Write some extra data during code generation
36
7
40,747
@ Override protected void generateDao ( TableDefinition table , JavaWriter out1 ) { UniqueKeyDefinition key = table . getPrimaryKey ( ) ; if ( key == null ) { logger . info ( "Skipping DAO generation" , out1 . file ( ) . getName ( ) ) ; return ; } VertxJavaWriter out = ( VertxJavaWriter ) out1 ; generateDAO ( key , tab...
copied from jOOQ s JavaGenerator
95
10
40,748
@ Override public void get ( BindingGetStatementContext < JsonObject > ctx ) throws SQLException { ctx . convert ( converter ( ) ) . value ( ctx . statement ( ) . getString ( ctx . index ( ) ) ) ; }
Getting a String value from a JDBC CallableStatement and converting that to a JsonObject
57
19
40,749
boolean startsWith ( final Literal literal ) { // Check whether the answer is already in the cache final int index = literal . getIndex ( ) ; final Boolean cached = myPrefixCache . get ( index ) ; if ( cached != null ) { return cached . booleanValue ( ) ; } // Get the answer and cache the result final boolean result = ...
Indicates whether this instance starts with the specified prefix .
101
11
40,750
boolean endsWith ( final Literal literal ) { // Check whether the answer is already in the cache final int index = literal . getIndex ( ) ; final Boolean cached = myPostfixCache . get ( index ) ; if ( cached != null ) { return cached . booleanValue ( ) ; } // Get the answer and cache the result final boolean result = l...
Indicates whether this instance ends with the specified postfix .
112
12
40,751
int [ ] getIndices ( final Literal literal ) { // Check whether the answer is already in the cache final int index = literal . getIndex ( ) ; final int [ ] cached = myIndices [ index ] ; if ( cached != null ) { return cached ; } // Find all indices final int [ ] values = findIndices ( literal ) ; myIndices [ index ] = ...
Returns all indices where the literal argument can be found in this String . Results are cached for better performance .
88
21
40,752
private int [ ] findIndices ( final Literal literal ) { int count = 0 ; final char s = literal . getFirstChar ( ) ; for ( int i = 0 ; i < myChars . length ; i ++ ) { // Check the first char for better performance and check the complete string if ( ( myChars [ i ] == s || s == ' ' ) && literal . matches ( myChars , i ) ...
Returns all indices where the literal argument can be found in this String .
226
14
40,753
boolean matches ( final char [ ] value , final int from ) { // Check the bounds final int len = myCharacters . length ; if ( len + from > value . length || from < 0 ) { return false ; } // Bounds are ok, check all characters. // Allow question marks to match any character for ( int i = 0 ; i < len ; i ++ ) { if ( myCha...
Checks whether the value represents a complete substring from the from index .
118
15
40,754
boolean requires ( final String value ) { if ( requires ( myPrefix , value ) || requires ( myPostfix , value ) ) { return true ; } if ( mySuffixes == null ) { return false ; } for ( final Literal suffix : mySuffixes ) { if ( requires ( suffix , value ) ) { return true ; } } return false ; }
Tests whether this rule needs a specific string in the useragent to match .
82
16
40,755
private static int checkWildCard ( final SearchableString value , final Literal suffix , final int start ) { for ( final int index : value . getIndices ( suffix ) ) { if ( index >= start ) { return index ; } } return - 1 ; }
Return found index or - 1
56
6
40,756
String getPattern ( ) { final StringBuilder result = new StringBuilder ( ) ; if ( myPrefix != null ) { result . append ( myPrefix ) ; } if ( mySuffixes != null ) { result . append ( "*" ) ; for ( final Literal sub : mySuffixes ) { result . append ( sub ) ; result . append ( "*" ) ; } } if ( myPostfix != null ) { result...
Returns the reconstructed original pattern .
116
6
40,757
static Rule [ ] getOrderedRules ( final Rule [ ] rules ) { final Comparator < Rule > c = Comparator . comparing ( Rule :: getSize ) . reversed ( ) . thenComparing ( Rule :: getPattern ) ; final Rule [ ] result = Arrays . copyOf ( rules , rules . length ) ; parallelSort ( result , c ) ; return result ; }
Sort by size and alphabet so the first match can be returned immediately
80
13
40,758
public static UserAgentParser parse ( final Reader input , final Collection < BrowsCapField > fields ) throws IOException , ParseException { return new UserAgentFileParser ( fields ) . parse ( input ) ; }
Parses a csv stream of rules .
45
10
40,759
public UserAgentParser loadParser ( ) throws IOException , ParseException { // Use all default fields final Set < BrowsCapField > defaultFields = Stream . of ( BrowsCapField . values ( ) ) . filter ( BrowsCapField :: isDefault ) . collect ( toSet ( ) ) ; return createParserWithFields ( defaultFields ) ; }
Returns a parser based on the bundled BrowsCap version
79
11
40,760
private InputStream getCsvFileStream ( ) throws FileNotFoundException { if ( myZipFileStream == null ) { if ( myZipFilePath == null ) { final String csvFileName = getBundledCsvFileName ( ) ; return getClass ( ) . getClassLoader ( ) . getResourceAsStream ( csvFileName ) ; } else { return new FileInputStream ( myZipFileP...
Returns the InputStream to the CSV file . This is either the bundled ZIP file or the one passed in the constructor .
104
24
40,761
public static long sizeOfInstance ( Class < ? > type ) { long size = SPEC . getObjectHeaderSize ( ) + sizeOfDeclaredFields ( type ) ; while ( ( type = type . getSuperclass ( ) ) != Object . class && type != null ) size += roundTo ( sizeOfDeclaredFields ( type ) , SPEC . getSuperclassFieldPadding ( ) ) ; return roundTo ...
sizeOfInstanceWithUnsafe is safe against this miscounting
102
13
40,762
public static long sizeOfInstanceWithUnsafe ( Class < ? > type ) { while ( type != null ) { long size = 0 ; for ( Field f : declaredFieldsOf ( type ) ) size = Math . max ( size , unsafe . objectFieldOffset ( f ) + sizeOf ( f ) ) ; if ( size > 0 ) return roundTo ( size , SPEC . getObjectPadding ( ) ) ; type = type . get...
attemps to use sun . misc . Unsafe to find the maximum object offset this work around helps deal with long alignment
123
25
40,763
public static long sizeOfArray ( int length , long elementSize ) { return roundTo ( SPEC . getArrayHeaderSize ( ) + length * elementSize , SPEC . getObjectPadding ( ) ) ; }
Memory an array will consume
44
5
40,764
private static int getAlignment ( ) { RuntimeMXBean runtimeMxBean = ManagementFactory . getRuntimeMXBean ( ) ; for ( String arg : runtimeMxBean . getInputArguments ( ) ) { if ( arg . startsWith ( "-XX:ObjectAlignmentInBytes=" ) ) { try { return Integer . parseInt ( arg . substring ( "-XX:ObjectAlignmentInBytes=" . leng...
check if we have a non - standard object alignment we need to round to
111
15
40,765
public void configure ( Object obj , Element cfg , int startIdx ) throws Exception { String id = getAttribute ( cfg , "id" ) ; if ( id != null ) { _idMap . put ( id , obj ) ; } Element [ ] children = getChildren ( cfg ) ; for ( int i = startIdx ; i < children . length ; i ++ ) { Element node = children [ i ] ; //CHECKS...
Recursive configuration step . This method applies the remaining Set Put and Call elements to the current object .
358
20
40,766
protected void scanJspConfig ( ) throws IOException , SAXException { JspConfigDescriptor jspConfigDescriptor = context . getJspConfigDescriptor ( ) ; if ( jspConfigDescriptor == null ) { return ; } Collection < TaglibDescriptor > descriptors = jspConfigDescriptor . getTaglibs ( ) ; for ( TaglibDescriptor descriptor : d...
Scan for TLDs defined in &lt ; jsp - config&gt ; .
571
18
40,767
protected void scanResourcePaths ( String startPath ) throws IOException , SAXException { Set < String > dirList = context . getResourcePaths ( startPath ) ; if ( dirList != null ) { for ( String path : dirList ) { if ( path . startsWith ( "/WEB-INF/classes/" ) ) { // Skip: JSP.7.3.1 } else if ( path . startsWith ( "/W...
Scan web application resources for TLDs recursively .
235
12
40,768
private void trackHttpContexts ( final BundleContext bundleContext , ExtendedHttpServiceRuntime httpServiceRuntime ) { final ServiceTracker < HttpContext , HttpContextElement > httpContextTracker = HttpContextTracker . createTracker ( extenderContext , bundleContext , httpServiceRuntime ) ; httpContextTracker . open ( ...
Track http contexts .
147
4
40,769
private void trackResources ( final BundleContext bundleContext ) { ServiceTracker < Object , ResourceWebElement > resourceTracker = ResourceTracker . createTracker ( extenderContext , bundleContext ) ; resourceTracker . open ( ) ; trackers . add ( 0 , resourceTracker ) ; final ServiceTracker < ResourceMapping , Resour...
Track resources .
114
3
40,770
private void trackFilters ( final BundleContext bundleContext ) { final ServiceTracker < Filter , FilterWebElement > filterTracker = FilterTracker . createTracker ( extenderContext , bundleContext ) ; filterTracker . open ( ) ; trackers . add ( 0 , filterTracker ) ; // FIXME needed? final ServiceTracker < FilterMapping...
Track filters .
121
3
40,771
private void trackListeners ( final BundleContext bundleContext ) { final ServiceTracker < EventListener , ListenerWebElement > listenerTracker = ListenerTracker . createTracker ( extenderContext , bundleContext ) ; listenerTracker . open ( ) ; trackers . add ( 0 , listenerTracker ) ; // FIXME needed? final ServiceTrac...
Track listeners .
127
3
40,772
private void trackJspMappings ( final BundleContext bundleContext ) { final ServiceTracker < JspMapping , JspWebElement > jspMappingTracker = JspMappingTracker . createTracker ( extenderContext , bundleContext ) ; jspMappingTracker . open ( ) ; trackers . add ( 0 , jspMappingTracker ) ; }
Track JSPs .
77
5
40,773
private void trackWelcomeFiles ( final BundleContext bundleContext ) { final ServiceTracker < WelcomeFileMapping , WelcomeFileWebElement > welcomeFileTracker = WelcomeFileMappingTracker . createTracker ( extenderContext , bundleContext ) ; welcomeFileTracker . open ( ) ; trackers . add ( 0 , welcomeFileTracker ) ; }
Track welcome files
69
3
40,774
private void trackErrorPages ( final BundleContext bundleContext ) { final ServiceTracker < ErrorPageMapping , ErrorPageWebElement > errorPagesTracker = ErrorPageMappingTracker . createTracker ( extenderContext , bundleContext ) ; errorPagesTracker . open ( ) ; trackers . add ( 0 , errorPagesTracker ) ; }
Track error pages
69
3
40,775
public void sessionCreated ( final HttpSessionEvent event ) { counter ++ ; final HttpSession session = event . getSession ( ) ; final String id = session . getId ( ) ; SESSIONS . put ( id , session ) ; }
Fires whenever a new session is created .
52
9
40,776
public void sessionDestroyed ( final HttpSessionEvent event ) { final HttpSession session = event . getSession ( ) ; final String id = session . getId ( ) ; SESSIONS . remove ( id ) ; counter -- ; }
Fires whenever a session is destroyed .
51
8
40,777
public static synchronized List < Object > getAttributes ( final String name ) { final List < Object > data = new ArrayList <> ( ) ; for ( final String id : SESSIONS . keySet ( ) ) { final HttpSession session = SESSIONS . get ( id ) ; try { final Object o = session . getAttribute ( name ) ; data . add ( o ) ; //CHECKST...
Return a list with all session values for a given attribute name .
117
13
40,778
public void start ( BundleContext bc ) throws Exception { httpServiceRef = bc . getServiceReference ( HttpService . class ) ; if ( httpServiceRef != null ) { httpService = ( HttpService ) bc . getService ( httpServiceRef ) ; httpService . registerServlet ( "/status" , new StatusServlet ( ) , null , null ) ; httpService...
Called whenever the OSGi framework starts our bundle
112
10
40,779
public void stop ( BundleContext bc ) throws Exception { if ( httpService != null ) { bc . ungetService ( httpServiceRef ) ; httpServiceRef = null ; httpService = null ; } }
Called whenever the OSGi framework stops our bundle
43
10
40,780
@ Override public void setAttribute ( final String name , Object value ) { if ( HttpContext . AUTHENTICATION_TYPE . equals ( name ) ) { handleAuthenticationType ( value ) ; } else if ( HttpContext . REMOTE_USER . equals ( name ) ) { handleRemoteUser ( value ) ; } super . setAttribute ( name , value ) ; }
Filter the setting of authentication related attributes . If one of HttpContext . AUTHENTICATION_TYPE or HTTPContext . REMOTE_USER set the corresponding values in original request .
81
37
40,781
private void handleAuthenticationType ( final Object authenticationType ) { if ( request != null ) { if ( authenticationType != null ) { // be defensive if ( ! ( authenticationType instanceof String ) ) { final String message = "Attribute " + HttpContext . AUTHENTICATION_TYPE + " expected to be a String but was an [" +...
Handles setting of authentication type attribute .
204
8
40,782
private void handleRemoteUser ( final Object remoteUser ) { if ( request != null ) { Principal userPrincipal = null ; if ( remoteUser != null ) { // be defensive if ( ! ( remoteUser instanceof String ) ) { final String message = "Attribute " + HttpContext . REMOTE_USER + " expected to be a String but was an [" + remote...
Handles setting of remote user attribute .
220
8
40,783
public Compiler createCompiler ( ) { if ( jspCompiler != null ) { return jspCompiler ; } jspCompiler = null ; if ( options . getCompilerClassName ( ) != null ) { jspCompiler = createCompiler ( options . getCompilerClassName ( ) ) ; } else { if ( options . getCompiler ( ) == null ) { jspCompiler = createCompiler ( "org....
Create a Compiler object based on some init param data . This is not done yet . Right now we re just hardcoding the actual compilers that are created .
292
34
40,784
public String resolveRelativeUri ( String uri ) { // sometimes we get uri's massaged from File(String), so check for // a root directory separator char if ( uri . startsWith ( "/" ) || uri . startsWith ( File . separator ) ) { return uri ; } else { return baseURI + uri ; } }
Get the full value of a URI relative to this compilations context uses current file as the base .
78
21
40,785
public String getRealPath ( String path ) { if ( context != null ) { return context . getRealPath ( path ) ; } return path ; }
Gets the actual path of a URI relative to the context of the compilation .
32
16
40,786
public String getServletPackageName ( ) { if ( isTagFile ( ) ) { String className = tagInfo . getTagClassName ( ) ; int lastIndex = className . lastIndexOf ( ' ' ) ; String pkgName = "" ; if ( lastIndex != - 1 ) { pkgName = className . substring ( 0 , lastIndex ) ; } return pkgName ; } else { String dPackageName = getD...
Package name for the generated class is make up of the base package name which is user settable and the derived package name . The derived package name directly mirrors the file hierarchy of the JSP page .
139
40
40,787
public void visit ( final WebAppServlet webAppServlet ) { NullArgumentException . validateNotNull ( webAppServlet , "Web app servlet" ) ; final String [ ] urlPatterns = webAppServlet . getAliases ( ) ; if ( urlPatterns == null || urlPatterns . length == 0 ) { LOG . warn ( "Servlet [" + webAppServlet + "] does not have ...
Registers servlets with web container .
330
8
40,788
public void visit ( final WebAppFilter webAppFilter ) { NullArgumentException . validateNotNull ( webAppFilter , "Web app filter" ) ; LOG . debug ( "registering filter: {}" , webAppFilter ) ; final String [ ] urlPatterns = webAppFilter . getUrlPatterns ( ) ; final String [ ] servletNames = webAppFilter . getServletName...
Registers filters with web container .
558
7
40,789
public void visit ( final WebAppListener webAppListener ) { NullArgumentException . validateNotNull ( webAppListener , "Web app listener" ) ; try { final EventListener listener = RegisterWebAppVisitorHS . newInstance ( EventListener . class , bundleClassLoader , webAppListener . getListenerClass ( ) ) ; webAppListener ...
Registers listeners with web container .
136
7
40,790
public void visit ( final WebAppErrorPage webAppErrorPage ) { NullArgumentException . validateNotNull ( webAppErrorPage , "Web app error page" ) ; try { webContainer . registerErrorPage ( webAppErrorPage . getError ( ) , webAppErrorPage . getLocation ( ) , httpContext ) ; //CHECKSTYLE:OFF } catch ( Exception ignore ) {...
Registers error pages with web container .
113
8
40,791
private static void parseContextParams ( final ParamValueType contextParam , final WebApp webApp ) { final WebAppInitParam initParam = new WebAppInitParam ( ) ; initParam . setParamName ( contextParam . getParamName ( ) . getValue ( ) ) ; initParam . setParamValue ( contextParam . getParamValue ( ) . getValue ( ) ) ; w...
Parses context params out of web . xml .
94
11
40,792
private static void parseSessionConfig ( final SessionConfigType sessionConfigType , final WebApp webApp ) { // Fix for PAXWEB-201 if ( sessionConfigType . getSessionTimeout ( ) != null ) { webApp . setSessionTimeout ( sessionConfigType . getSessionTimeout ( ) . getValue ( ) . toString ( ) ) ; } if ( sessionConfigType ...
Parses session config out of web . xml .
445
11
40,793
private static void parseServlets ( final ServletType servletType , final WebApp webApp ) { final WebAppServlet servlet = new WebAppServlet ( ) ; servlet . setServletName ( servletType . getServletName ( ) . getValue ( ) ) ; if ( servletType . getServletClass ( ) != null ) { servlet . setServletClassName ( servletType ...
Parses servlets and servlet mappings out of web . xml .
673
16
40,794
private static void parseFilters ( final FilterType filterType , final WebApp webApp ) { final WebAppFilter filter = new WebAppFilter ( ) ; if ( filterType . getFilterName ( ) != null ) { filter . setFilterName ( filterType . getFilterName ( ) . getValue ( ) ) ; } if ( filterType . getFilterClass ( ) != null ) { filter...
Parses filters and filter mappings out of web . xml .
329
14
40,795
private static void parseErrorPages ( final ErrorPageType errorPageType , final WebApp webApp ) { final WebAppErrorPage errorPage = new WebAppErrorPage ( ) ; if ( errorPageType . getErrorCode ( ) != null ) { errorPage . setErrorCode ( errorPageType . getErrorCode ( ) . getValue ( ) . toString ( ) ) ; } if ( errorPageTy...
Parses error pages out of web . xml .
212
11
40,796
private static void parseWelcomeFiles ( final WelcomeFileListType welcomeFileList , final WebApp webApp ) { if ( welcomeFileList != null && welcomeFileList . getWelcomeFile ( ) != null && ! welcomeFileList . getWelcomeFile ( ) . isEmpty ( ) ) { welcomeFileList . getWelcomeFile ( ) . forEach ( webApp :: addWelcomeFile )...
Parses welcome files out of web . xml .
83
11
40,797
private static void parseMimeMappings ( final MimeMappingType mimeMappingType , final WebApp webApp ) { final WebAppMimeMapping mimeMapping = new WebAppMimeMapping ( ) ; mimeMapping . setExtension ( mimeMappingType . getExtension ( ) . getValue ( ) ) ; mimeMapping . setMimeType ( mimeMappingType . getMimeType ( ) . get...
Parses mime mappings out of web . xml .
122
13
40,798
private static String getTextContent ( final Element element ) { if ( element != null ) { String content = element . getTextContent ( ) ; if ( content != null ) { content = content . trim ( ) ; } return content ; } return null ; }
Returns the text content of an element or null if the element is null .
54
15
40,799
public static int parseInt ( byte [ ] b , int offset , int length , int base ) { int value = 0 ; //CHECKSTYLE:OFF if ( length < 0 ) { length = b . length - offset ; } //CHECKSTYLE:ON for ( int i = 0 ; i < length ; i ++ ) { char c = ( char ) ( _0XFF & b [ offset + i ] ) ; int digit = c - ' ' ; if ( digit < 0 || digit >=...
Parse an int from a byte array of ascii characters . Negative numbers are not handled .
191
20