idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
23,000
public static < T extends WindupVertexFrame > T addTypeToModel ( GraphContext graphContext , WindupVertexFrame frame , Class < T > type ) { Vertex vertex = frame . getElement ( ) ; graphContext . getGraphTypeManager ( ) . addTypeToElement ( type , vertex ) ; return graphContext . getFramed ( ) . frameElement ( vertex ,...
Adds the specified type to this frame and returns a new object that implements this type .
23,001
public static < T extends WindupVertexFrame > WindupVertexFrame removeTypeFromModel ( GraphContext graphContext , WindupVertexFrame frame , Class < T > type ) { Vertex vertex = frame . getElement ( ) ; graphContext . getGraphTypeManager ( ) . removeTypeFromElement ( type , vertex ) ; return graphContext . getFramed ( )...
Removes the specified type from the frame .
23,002
@ SuppressWarnings ( "unchecked" ) private static synchronized Map < String , Boolean > getCache ( GraphRewrite event ) { Map < String , Boolean > result = ( Map < String , Boolean > ) event . getRewriteContext ( ) . get ( ClassificationServiceCache . class ) ; if ( result == null ) { result = Collections . synchronize...
Keep a cache of items files associated with classification in order to improve performance .
23,003
public static String getEffortLevelDescription ( Verbosity verbosity , int points ) { EffortLevel level = EffortLevel . forPoints ( points ) ; switch ( verbosity ) { case ID : return level . name ( ) ; case VERBOSE : return level . getVerboseDescription ( ) ; case SHORT : default : return level . getShortDescription ( ...
Returns the right string representation of the effort level based on given number of points .
23,004
public WindupConfiguration setOptionValue ( String name , Object value ) { configurationOptions . put ( name , value ) ; return this ; }
Sets a configuration option to the specified value .
23,005
@ SuppressWarnings ( "unchecked" ) public < T > T getOptionValue ( String name ) { return ( T ) configurationOptions . get ( name ) ; }
Returns the configuration value with the specified name .
23,006
private void logTimeTakenByRuleProvider ( GraphContext graphContext , Context context , int ruleIndex , int timeTaken ) { AbstractRuleProvider ruleProvider = ( AbstractRuleProvider ) context . get ( RuleMetadataType . RULE_PROVIDER ) ; if ( ruleProvider == null ) return ; if ( ! timeTakenByProvider . containsKey ( rule...
Logs the time taken by this rule and attaches this to the total for the RuleProvider
23,007
private void logTimeTakenByPhase ( GraphContext graphContext , Class < ? extends RulePhase > phase , int timeTaken ) { if ( ! timeTakenByPhase . containsKey ( phase ) ) { RulePhaseExecutionStatisticsModel model = new GraphService < > ( graphContext , RulePhaseExecutionStatisticsModel . class ) . create ( ) ; model . se...
Logs the time taken by this rule and adds this to the total time taken for this phase
23,008
public static String transformXPath ( String originalXPath ) { List < StringBuilder > compiledXPaths = new ArrayList < > ( 1 ) ; int frameIdx = - 1 ; boolean inQuote = false ; int conditionLevel = 0 ; char startQuoteChar = 0 ; StringBuilder currentXPath = new StringBuilder ( ) ; compiledXPaths . add ( currentXPath ) ; ...
Performs the conversion from standard XPath to xpath with parameterization support .
23,009
public void accept ( IBinaryType binaryType , PackageBinding packageBinding , AccessRestriction accessRestriction ) { if ( this . options . verbose ) { this . out . println ( Messages . bind ( Messages . compilation_loadBinary , new String ( binaryType . getName ( ) ) ) ) ; } LookupEnvironment env = packageBinding . en...
Add an additional binary type
23,010
public void accept ( ICompilationUnit sourceUnit , AccessRestriction accessRestriction ) { CompilationResult unitResult = new CompilationResult ( sourceUnit , this . totalUnits , this . totalUnits , this . options . maxProblemsPerUnit ) ; unitResult . checkSecondaryTypes = true ; try { if ( this . options . verbose ) {...
Add an additional compilation unit into the loop - > build compilation unit declarations their bindings and record their results .
23,011
public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding , AccessRestriction accessRestriction ) { this . problemReporter . abortDueToInternalError ( Messages . bind ( Messages . abort_againstSourceModel , new String [ ] { String . valueOf ( sourceTypes [ 0 ] . getName ( ) ) , String . valueOf (...
Add additional source types
23,012
protected void reportProgress ( String taskDecription ) { if ( this . progress != null ) { if ( this . progress . isCanceled ( ) ) { throw new AbortCompilation ( true , null ) ; } this . progress . setTaskName ( taskDecription ) ; } }
Checks whether the compilation has been canceled and reports the given progress to the compiler progress .
23,013
protected void reportWorked ( int workIncrement , int currentUnitIndex ) { if ( this . progress != null ) { if ( this . progress . isCanceled ( ) ) { throw new AbortCompilation ( true , null ) ; } this . progress . worked ( workIncrement , ( this . totalUnits * this . remainingIterations ) - currentUnitIndex - 1 ) ; } ...
Checks whether the compilation has been canceled and reports the given work increment to the compiler progress .
23,014
private void compile ( ICompilationUnit [ ] sourceUnits , boolean lastRound ) { this . stats . startTime = System . currentTimeMillis ( ) ; try { reportProgress ( Messages . compilation_beginningToCompile ) ; if ( this . options . complianceLevel >= ClassFileConstants . JDK9 ) { sortModuleDeclarationsFirst ( sourceUnit...
General API - > compile each of supplied files - > recompile any required types for which we have an incomplete principle structure
23,015
public void process ( CompilationUnitDeclaration unit , int i ) { this . lookupEnvironment . unitBeingCompleted = unit ; long parseStart = System . currentTimeMillis ( ) ; this . parser . getMethodBodies ( unit ) ; long resolveStart = System . currentTimeMillis ( ) ; this . stats . parseTime += resolveStart - parseStar...
Process a compilation unit already parsed and build .
23,016
public void loadTagDefinitions ( ) { Map < Addon , List < URL > > addonToResourcesMap = scanner . scanForAddonMap ( new FileExtensionFilter ( "tags.xml" ) ) ; for ( Map . Entry < Addon , List < URL > > entry : addonToResourcesMap . entrySet ( ) ) { for ( URL resource : entry . getValue ( ) ) { log . info ( "Reading tag...
Loads the tag definitions from the files with a . tags . xml suffix from the addons .
23,017
public static BatchASTFuture analyze ( final BatchASTListener listener , final WildcardImportResolver importResolver , final Set < String > libraryPaths , final Set < String > sourcePaths , Set < Path > sourceFiles ) { final String [ ] encodings = null ; final String [ ] bindingKeys = new String [ 0 ] ; final ExecutorS...
Process the given batch of files and pass the results back to the listener as each file is processed .
23,018
public AnnotationTypeCondition addCondition ( String element , AnnotationCondition condition ) { this . conditions . put ( element , condition ) ; return this ; }
Adds another condition for an element within this annotation .
23,019
public DecompilationResult decompileClassFile ( Path rootDir , Path classFilePath , Path outputDir ) throws DecompilationException { Checks . checkDirectoryToBeRead ( rootDir . toFile ( ) , "Classes root dir" ) ; File classFile = classFilePath . toFile ( ) ; Checks . checkFileToBeRead ( classFile , "Class file" ) ; Che...
Decompiles the given . class file and creates the specified output source file .
23,020
private void refreshMetadataCache ( final Queue < WindupMetadataSystem > metadataSystemCache , final DecompilerSettings settings ) { metadataSystemCache . clear ( ) ; for ( int i = 0 ; i < this . getNumberOfThreads ( ) ; i ++ ) { metadataSystemCache . add ( new NoRetryMetadataSystem ( settings . getTypeLoader ( ) ) ) ;...
The metadata cache can become huge over time . This simply flushes it periodically .
23,021
private File decompileType ( final DecompilerSettings settings , final WindupMetadataSystem metadataSystem , final String typeName ) throws IOException { log . fine ( "Decompiling " + typeName ) ; final TypeReference type ; if ( typeName . length ( ) == 1 ) { final MetadataParser parser = new MetadataParser ( IMetadata...
Decompiles a single type .
23,022
private DecompilerSettings getDefaultSettings ( File outputDir ) { DecompilerSettings settings = new DecompilerSettings ( ) ; procyonConf . setDecompilerSettings ( settings ) ; settings . setOutputDirectory ( outputDir . getPath ( ) ) ; settings . setShowSyntheticMembers ( false ) ; settings . setForceExplicitImports (...
Default settings set type loader to ClasspathTypeLoader if not set before .
23,023
private JarFile loadJar ( File archive ) throws DecompilationException { try { return new JarFile ( archive ) ; } catch ( IOException ex ) { throw new DecompilationException ( "Can't load .jar: " + archive . getPath ( ) , ex ) ; } }
Opens the jar wraps any IOException .
23,024
private static synchronized FileOutputWriter createFileWriter ( final TypeDefinition type , final DecompilerSettings settings ) throws IOException { final String outputDirectory = settings . getOutputDirectory ( ) ; final String fileName = type . getName ( ) + settings . getLanguage ( ) . getFileExtension ( ) ; final S...
Constructs the path from FQCN validates writability and creates a writer .
23,025
protected static void printValuesSorted ( String message , Set < String > values ) { System . out . println ( ) ; System . out . println ( message + ":" ) ; List < String > sorted = new ArrayList < > ( values ) ; Collections . sort ( sorted ) ; for ( String value : sorted ) { System . out . println ( "\t" + value ) ; }...
Print the given values after displaying the provided message .
23,026
public static String getTypeValue ( Class < ? extends WindupFrame > clazz ) { TypeValue typeValueAnnotation = clazz . getAnnotation ( TypeValue . class ) ; if ( typeValueAnnotation == null ) throw new IllegalArgumentException ( "Class " + clazz . getCanonicalName ( ) + " lacks a @TypeValue annotation" ) ; return typeVa...
Returns the type discriminator value for given Frames model class extracted from the
23,027
public static Configuration getDefaultFreemarkerConfiguration ( ) { freemarker . template . Configuration configuration = new freemarker . template . Configuration ( Configuration . VERSION_2_3_26 ) ; DefaultObjectWrapperBuilder objectWrapperBuilder = new DefaultObjectWrapperBuilder ( Configuration . VERSION_2_3_26 ) ;...
Gets the default configuration for Freemarker within Windup .
23,028
public static Map < String , Object > findFreeMarkerContextVariables ( Variables variables , String ... varNames ) { Map < String , Object > results = new HashMap < > ( ) ; for ( String varName : varNames ) { WindupVertexFrame payload = null ; try { payload = Iteration . getCurrentPayload ( variables , null , varName )...
Finds all variables in the context with the given names and also attaches all WindupFreeMarkerMethods from all addons into the map .
23,029
public ClassificationModel attachLink ( ClassificationModel classificationModel , LinkModel linkModel ) { for ( LinkModel existing : classificationModel . getLinks ( ) ) { if ( StringUtils . equals ( existing . getLink ( ) , linkModel . getLink ( ) ) ) { return classificationModel ; } } classificationModel . addLink ( ...
Attach the given link to the classification while checking for duplicates .
23,030
private MavenProjectModel getMavenStubProject ( MavenProjectService mavenProjectService , String groupId , String artifactId , String version ) { Iterable < MavenProjectModel > mavenProjectModels = mavenProjectService . findByGroupArtifactVersion ( groupId , artifactId , version ) ; if ( ! mavenProjectModels . iterator...
A Maven stub is a Maven Project for which we have found information but the project has not yet been located within the input application . If we have found an application of the same GAV within the input app we should fill out this stub instead of creating a new one .
23,031
public static Path getRootFolderForSource ( Path sourceFilePath , String packageName ) { if ( packageName == null || packageName . trim ( ) . isEmpty ( ) ) { return sourceFilePath . getParent ( ) ; } String [ ] packageNameComponents = packageName . split ( "\\." ) ; Path currentPath = sourceFilePath . getParent ( ) ; f...
Returns the root path for this source file based upon the package name .
23,032
public static boolean isInSubDirectory ( File dir , File file ) { if ( file == null ) return false ; if ( file . equals ( dir ) ) return true ; return isInSubDirectory ( dir , file . getParentFile ( ) ) ; }
Returns true if file is a subfile or subdirectory of dir .
23,033
public static void createDirectory ( Path dir , String dirDesc ) { try { Files . createDirectories ( dir ) ; } catch ( IOException ex ) { throw new WindupException ( "Error creating " + dirDesc + " folder: " + dir . toString ( ) + " due to: " + ex . getMessage ( ) , ex ) ; } }
Creates the given directory . Fails if it already exists .
23,034
private ClassReference processType ( Type type , TypeReferenceLocation typeReferenceLocation , int lineNumber , int columnNumber , int length , String line ) { if ( type == null ) return null ; ITypeBinding resolveBinding = type . resolveBinding ( ) ; if ( resolveBinding == null ) { ResolveClassnameResult resolvedResul...
The method determines if the type can be resolved and if not will try to guess the qualified name using the information from the imports .
23,035
private void addAnnotationValues ( ClassReference annotatedReference , AnnotationClassReference typeRef , Annotation node ) { Map < String , AnnotationValue > annotationValueMap = new HashMap < > ( ) ; if ( node instanceof SingleMemberAnnotation ) { SingleMemberAnnotation singleMemberAnnotation = ( SingleMemberAnnotati...
Adds parameters contained in the annotation into the annotation type reference
23,036
public boolean visit ( VariableDeclarationStatement node ) { for ( int i = 0 ; i < node . fragments ( ) . size ( ) ; ++ i ) { String nodeType = node . getType ( ) . toString ( ) ; VariableDeclarationFragment frag = ( VariableDeclarationFragment ) node . fragments ( ) . get ( i ) ; state . getNames ( ) . add ( frag . ge...
Declaration of the variable within a block
23,037
public QueryBuilderFind excludingType ( final Class < ? extends WindupVertexFrame > type ) { pipelineCriteria . add ( new QueryGremlinCriterion ( ) { public void query ( GraphRewrite event , GraphTraversal < ? , Vertex > pipeline ) { pipeline . filter ( it -> ! GraphTypeManager . hasType ( type , it . get ( ) ) ) ; } }...
Excludes Vertices that are of the provided type .
23,038
private boolean addonDependsOnReporting ( Addon addon ) { for ( AddonDependency dep : addon . getDependencies ( ) ) { if ( dep . getDependency ( ) . equals ( this . addon ) ) { return true ; } boolean subDep = addonDependsOnReporting ( dep . getDependency ( ) ) ; if ( subDep ) { return true ; } } return false ; }
Returns true if the addon depends on reporting .
23,039
public static TagModel getSingleParent ( TagModel tag ) { final Iterator < TagModel > parents = tag . getDesignatedByTags ( ) . iterator ( ) ; if ( ! parents . hasNext ( ) ) throw new WindupException ( "Tag is not designated by any tags: " + tag ) ; final TagModel maybeOnlyParent = parents . next ( ) ; if ( parents . h...
Returns a single parent of the given tag . If there are multiple parents throws a WindupException .
23,040
public static GraphTraversal < Vertex , Vertex > addPipeFor ( GraphTraversal < Vertex , Vertex > pipeline , Class < ? extends WindupVertexFrame > clazz ) { pipeline . has ( WindupVertexFrame . TYPE_PROP , GraphTypeManager . getTypeValue ( clazz ) ) ; return pipeline ; }
Adds a criterion to given pipeline which filters out vertices representing given WindupVertexFrame .
23,041
public static boolean strictCheckMatchingTags ( Collection < String > tags , Set < String > includeTags , Set < String > excludeTags ) { boolean includeTagsEnabled = ! includeTags . isEmpty ( ) ; for ( String tag : tags ) { boolean isIncluded = includeTags . contains ( tag ) ; boolean isExcluded = excludeTags . contain...
Returns true if - includeTags is not empty and tag is in includeTags - includeTags is empty and tag is not in excludeTags
23,042
private static List < Path > expandMultiAppInputDirs ( List < Path > input ) { List < Path > expanded = new LinkedList < > ( ) ; for ( Path path : input ) { if ( Files . isRegularFile ( path ) ) { expanded . add ( path ) ; continue ; } if ( ! Files . isDirectory ( path ) ) { String pathString = ( path == null ) ? "" : ...
Expands the directories from the given list and and returns a list of subfiles . Files from the original list are kept as is .
23,043
public static String ruleToRuleContentsString ( Rule originalRule , int indentLevel ) { if ( originalRule instanceof Context && ( ( Context ) originalRule ) . containsKey ( RuleMetadataType . RULE_XML ) ) { return ( String ) ( ( Context ) originalRule ) . get ( RuleMetadataType . RULE_XML ) ; } if ( ! ( originalRule in...
Attempts to create a human - readable String representation of the provided rule .
23,044
public < E > DynamicType . Builder < E > processMethod ( final DynamicType . Builder < E > builder , final Method method , final Annotation annotation ) { String methodName = method . getName ( ) ; if ( ReflectionUtility . isGetMethod ( method ) ) return createInterceptor ( builder , method ) ; else if ( ReflectionUtil...
The handling method .
23,045
public void associateTypeJndiResource ( JNDIResourceModel resource , String type ) { if ( type == null || resource == null ) { return ; } if ( StringUtils . equals ( type , "javax.sql.DataSource" ) && ! ( resource instanceof DataSourceModel ) ) { DataSourceModel ds = GraphService . addTypeToModel ( this . getGraphConte...
Associate a type with the given resource model .
23,046
private boolean addDeploymentTypeBasedDependencies ( ProjectModel projectModel , Pom modulePom ) { if ( projectModel . getProjectType ( ) == null ) return true ; switch ( projectModel . getProjectType ( ) ) { case "ear" : break ; case "war" : modulePom . getDependencies ( ) . add ( new SimpleDependency ( Dependency . R...
Adds the dependencies typical for particular deployment types . This is not accurate and doesn t cover the real needs of the project . Basically it s just to have something for the initial implementation .
23,047
public void readTags ( InputStream tagsXML ) { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; try { SAXParser saxParser = factory . newSAXParser ( ) ; saxParser . parse ( tagsXML , new TagsSaxHandler ( this ) ) ; } catch ( ParserConfigurationException | SAXException | IOException ex ) { throw new Runti...
Read the tag structure from the provided stream .
23,048
public List < Tag > getPrimeTags ( ) { return this . definedTags . values ( ) . stream ( ) . filter ( Tag :: isPrime ) . collect ( Collectors . toList ( ) ) ; }
Gets all tags that are prime tags .
23,049
public List < Tag > getRootTags ( ) { return this . definedTags . values ( ) . stream ( ) . filter ( Tag :: isRoot ) . collect ( Collectors . toList ( ) ) ; }
Returns the tags that were root in the definition files . These serve as entry point shortcuts when browsing the graph . We could reduce this to just fewer as the root tags may be connected through parents = ... .
23,050
public Set < Tag > getAncestorTags ( Tag tag ) { Set < Tag > ancestors = new HashSet < > ( ) ; getAncestorTags ( tag , ancestors ) ; return ancestors ; }
Returns all tags that designate this tag . E . g . for tesla - model3 this would return car vehicle vendor - tesla etc .
23,051
public void writeTagsToJavaScript ( Writer writer ) throws IOException { writer . append ( "function fillTagService(tagService) {\n" ) ; writer . append ( "\t// (name, isPrime, isPseudo, color), [parent tags]\n" ) ; for ( Tag tag : definedTags . values ( ) ) { writer . append ( "\ttagService.registerTag(new Tag(" ) ; e...
Writes the JavaScript code describing the tags as Tag classes to given writer .
23,052
public Path getReportDirectory ( ) { WindupConfigurationModel cfg = WindupConfigurationService . getConfigurationModel ( getGraphContext ( ) ) ; Path path = cfg . getOutputPath ( ) . asFile ( ) . toPath ( ) . resolve ( REPORTS_DIR ) ; createDirectoryIfNeeded ( path ) ; return path . toAbsolutePath ( ) ; }
Returns the output directory for reporting .
23,053
@ SuppressWarnings ( "unchecked" ) public < T extends ReportModel > T getReportByName ( String name , Class < T > clazz ) { WindupVertexFrame model = this . getUniqueByProperty ( ReportModel . REPORT_NAME , name ) ; try { return ( T ) model ; } catch ( ClassCastException ex ) { throw new WindupException ( "The vertex i...
Returns the ReportModel with given name .
23,054
public String getUniqueFilename ( String baseFileName , String extension , boolean cleanBaseFileName , String ... ancestorFolders ) { if ( cleanBaseFileName ) { baseFileName = PathUtil . cleanFileName ( baseFileName ) ; } if ( ancestorFolders != null ) { Path pathToFile = Paths . get ( "" , Stream . of ( ancestorFolder...
Returns a unique file name
23,055
public TagSetModel getOrCreate ( GraphRewrite event , Set < String > tags ) { Map < Set < String > , Vertex > cache = getCache ( event ) ; Vertex vertex = cache . get ( tags ) ; if ( vertex == null ) { TagSetModel model = create ( ) ; model . setTags ( tags ) ; cache . put ( tags , model . getElement ( ) ) ; return mod...
This essentially ensures that we only store a single Vertex for each unique Set of tags .
23,056
private static Set < ProjectModel > getAllApplications ( GraphContext graphContext ) { Set < ProjectModel > apps = new HashSet < > ( ) ; Iterable < ProjectModel > appProjects = graphContext . findAll ( ProjectModel . class ) ; for ( ProjectModel appProject : appProjects ) apps . add ( appProject ) ; return apps ; }
Returns all ApplicationProjectModels .
23,057
private static TechReportPlacement processPlaceLabels ( GraphContext graphContext , Set < String > tagNames ) { TagGraphService tagService = new TagGraphService ( graphContext ) ; if ( tagNames . size ( ) < 3 ) throw new WindupException ( "There should always be exactly 3 placement labels - row, sector, column/box. It ...
From three tagNames if one is under sectorTag and one under rowTag returns the remaining one which is supposedly the a box label . Otherwise returns null .
23,058
public static Artifact withVersion ( Version v ) { Artifact artifact = new Artifact ( ) ; artifact . version = v ; return artifact ; }
Start with specifying the artifact version
23,059
public static Artifact withGroupId ( String groupId ) { Artifact artifact = new Artifact ( ) ; artifact . groupId = new RegexParameterizedPatternParser ( groupId ) ; return artifact ; }
Start with specifying the groupId
23,060
public static Artifact withArtifactId ( String artifactId ) { Artifact artifact = new Artifact ( ) ; artifact . artifactId = new RegexParameterizedPatternParser ( artifactId ) ; return artifact ; }
Start with specifying the artifactId
23,061
public void setSingletonVariable ( String name , WindupVertexFrame frame ) { setVariable ( name , Collections . singletonList ( frame ) ) ; }
Type - safe wrapper around setVariable which sets only one framed vertex .
23,062
public void setVariable ( String name , Iterable < ? extends WindupVertexFrame > frames ) { Map < String , Iterable < ? extends WindupVertexFrame > > frame = peek ( ) ; if ( ! Iteration . DEFAULT_VARIABLE_LIST_STRING . equals ( name ) && findVariable ( name ) != null ) { throw new IllegalArgumentException ( "Variable \...
Set a variable in the top variables layer to given collection of the vertex frames . Can t be reassigned - throws on attempt to reassign .
23,063
public void removeVariable ( String name ) { Map < String , Iterable < ? extends WindupVertexFrame > > frame = peek ( ) ; frame . remove ( name ) ; }
Remove a variable in the top variables layer .
23,064
public Iterable < ? extends WindupVertexFrame > findVariable ( String name , int maxDepth ) { int currentDepth = 0 ; Iterable < ? extends WindupVertexFrame > result = null ; for ( Map < String , Iterable < ? extends WindupVertexFrame > > frame : deque ) { result = frame . get ( name ) ; if ( result != null ) { break ; ...
Searches the variables layers top to bottom for given name and returns if found ; null otherwise .
23,065
@ SuppressWarnings ( "unchecked" ) public < T extends WindupVertexFrame > Iterable < T > findVariableOfType ( Class < T > type ) { for ( Map < String , Iterable < ? extends WindupVertexFrame > > topOfStack : deque ) { for ( Iterable < ? extends WindupVertexFrame > frames : topOfStack . values ( ) ) { boolean empty = tr...
Searches the variables layers top to bottom for the iterable having all of it s items of the given type . Return null if not found .
23,066
protected void checkVariableName ( GraphRewrite event , EvaluationContext context ) { if ( getInputVariablesName ( ) == null ) { setInputVariablesName ( Iteration . getPayloadVariableName ( event , context ) ) ; } }
Check the variable name and if not set set it with the singleton variable being on the top of the stack .
23,067
private static Map < String , Integer > findClasses ( Path path ) { List < String > paths = findPaths ( path , true ) ; Map < String , Integer > results = new HashMap < > ( ) ; for ( String subPath : paths ) { if ( subPath . endsWith ( ".java" ) || subPath . endsWith ( ".class" ) ) { String qualifiedName = PathUtil . c...
Recursively scan the provided path and return a list of all Java packages contained therein .
23,068
public Path getTransformedXSLTPath ( FileModel payload ) { ReportService reportService = new ReportService ( getGraphContext ( ) ) ; Path outputPath = reportService . getReportDirectory ( ) ; outputPath = outputPath . resolve ( this . getRelativeTransformedXSLTPath ( payload ) ) ; if ( ! Files . isDirectory ( outputPat...
Gets the path used for the results of XSLT Transforms .
23,069
public static String resolveDataSourceTypeFromDialect ( String dialect ) { if ( StringUtils . contains ( dialect , "Oracle" ) ) { return "Oracle" ; } else if ( StringUtils . contains ( dialect , "MySQL" ) ) { return "MySQL" ; } else if ( StringUtils . contains ( dialect , "DB2390Dialect" ) ) { return "DB2/390" ; } else...
Converts the given dislect to a human - readable datasource type .
23,070
public static void load ( File file ) { try ( FileInputStream inputStream = new FileInputStream ( file ) ) { LineIterator it = IOUtils . lineIterator ( inputStream , "UTF-8" ) ; while ( it . hasNext ( ) ) { String line = it . next ( ) ; if ( ! line . startsWith ( "#" ) && ! line . trim ( ) . isEmpty ( ) ) { add ( line ...
Load the given configuration file .
23,071
public void perform ( Rewrite event , EvaluationContext context ) { perform ( ( GraphRewrite ) event , context ) ; }
Called internally to actually process the Iteration .
23,072
private final < T > Set < T > join ( Set < T > ... sets ) { Set < T > result = new HashSet < > ( ) ; if ( sets == null ) return result ; for ( Set < T > set : sets ) { if ( set != null ) result . addAll ( set ) ; } return result ; }
Join N sets .
23,073
public List < IssueCategory > getIssueCategories ( ) { return this . issueCategories . values ( ) . stream ( ) . sorted ( ( category1 , category2 ) -> category1 . getPriority ( ) - category2 . getPriority ( ) ) . collect ( Collectors . toList ( ) ) ; }
Returns a list ordered from the highest priority to the lowest .
23,074
private void addDefaults ( ) { this . issueCategories . putIfAbsent ( MANDATORY , new IssueCategory ( MANDATORY , IssueCategoryRegistry . class . getCanonicalName ( ) , "Mandatory" , MANDATORY , 1000 , true ) ) ; this . issueCategories . putIfAbsent ( OPTIONAL , new IssueCategory ( OPTIONAL , IssueCategoryRegistry . cl...
Make sure that we have some reasonable defaults available . These would typically be provided by the rulesets in the real world .
23,075
private static void renderFreemarkerTemplate ( Path templatePath , Map vars , Path outputPath ) throws IOException , TemplateException { if ( templatePath == null ) throw new WindupException ( "templatePath is null" ) ; freemarker . template . Configuration freemarkerConfig = new freemarker . template . Configuration (...
Renders the given FreeMarker template to given directory using given variables .
23,076
public static synchronized ExecutionStatistics get ( ) { Thread currentThread = Thread . currentThread ( ) ; if ( stats . get ( currentThread ) == null ) { stats . put ( currentThread , new ExecutionStatistics ( ) ) ; } return stats . get ( currentThread ) ; }
Gets the instance associated with the current thread .
23,077
public void merge ( ) { Thread currentThread = Thread . currentThread ( ) ; if ( ! stats . get ( currentThread ) . equals ( this ) || currentThread instanceof WindupChildThread ) { throw new IllegalArgumentException ( "Trying to merge executionstatistics from a " + "different thread that is not registered as main threa...
Merge this ExecutionStatistics with all the statistics created within the child threads . All the child threads had to be created using Windup - specific ThreadFactory in order to contain a reference to the parent thread .
23,078
private void merge ( ExecutionStatistics otherStatistics ) { for ( String s : otherStatistics . executionInfo . keySet ( ) ) { TimingData thisStats = this . executionInfo . get ( s ) ; TimingData otherStats = otherStatistics . executionInfo . get ( s ) ; if ( thisStats == null ) { this . executionInfo . put ( s , other...
Merge two ExecutionStatistics into one . This method is private in order not to be synchronized ( merging .
23,079
public void serializeTimingData ( Path outputPath ) { merge ( ) ; try ( FileWriter fw = new FileWriter ( outputPath . toFile ( ) ) ) { fw . write ( "Number Of Executions, Total Milliseconds, Milliseconds per execution, Type\n" ) ; for ( Map . Entry < String , TimingData > timing : executionInfo . entrySet ( ) ) { Timi...
Serializes the timing data to a ~ delimited file at outputPath .
23,080
public void begin ( String key ) { if ( key == null ) { return ; } TimingData data = executionInfo . get ( key ) ; if ( data == null ) { data = new TimingData ( key ) ; executionInfo . put ( key , data ) ; } data . begin ( ) ; }
Start timing an operation with the given identifier .
23,081
public void end ( String key ) { if ( key == null ) { return ; } TimingData data = executionInfo . get ( key ) ; if ( data == null ) { LOG . info ( "Called end with key: " + key + " without ever calling begin" ) ; return ; } data . end ( ) ; }
Complete timing the operation with the given identifier . If you had not previously started a timing operation with this identifier then this will effectively be a noop .
23,082
private void registerPackageInTypeInterestFactory ( String pkg ) { TypeInterestFactory . registerInterest ( pkg + "_pkg" , pkg . replace ( "." , "\\." ) , pkg , TypeReferenceLocation . IMPORT ) ; }
So that we get these packages caught Java class analysis .
23,083
public static void cache ( XmlFileModel key , Document document ) { String cacheKey = getKey ( key ) ; map . put ( cacheKey , new CacheDocument ( false , document ) ) ; }
Add the provided document to the cache .
23,084
public static void cacheParseFailure ( XmlFileModel key ) { map . put ( getKey ( key ) , new CacheDocument ( true , null ) ) ; }
Cache a parse failure for this document .
23,085
public static Result get ( XmlFileModel key ) { String cacheKey = getKey ( key ) ; Result result = null ; CacheDocument reference = map . get ( cacheKey ) ; if ( reference == null ) return new Result ( false , null ) ; if ( reference . parseFailure ) return new Result ( true , null ) ; Document document = reference . g...
Retrieve the currently cached value for the given document .
23,086
public void reformatFile ( ) throws IOException { List < LineNumberPosition > lineBrokenPositions = new ArrayList < > ( ) ; List < String > brokenLines = breakLines ( lineBrokenPositions ) ; emitFormatted ( brokenLines , lineBrokenPositions ) ; }
Rewrites the file passed to this constructor so that the actual line numbers match the recipe passed to this constructor .
23,087
public static PackageNameMappingWithPackagePattern fromPackage ( String packagePattern ) { PackageNameMapping packageNameMapping = new PackageNameMapping ( ) ; packageNameMapping . setPackagePattern ( packagePattern ) ; return packageNameMapping ; }
Sets the package pattern to match against .
23,088
public static boolean isExclusivelyKnownArchive ( GraphRewrite event , String filePath ) { String extension = StringUtils . substringAfterLast ( filePath , "." ) ; if ( ! StringUtils . equalsIgnoreCase ( extension , "jar" ) ) return false ; ZipFile archive ; try { archive = new ZipFile ( filePath ) ; } catch ( IOExcept...
Indicates that all of the packages within an archive are known by the package mapper . Generally this indicates that the archive does not contain customer code .
23,089
private RandomVariable getShortRate ( int timeIndex ) throws CalculationException { double time = getProcess ( ) . getTime ( timeIndex ) ; double timePrev = timeIndex > 0 ? getProcess ( ) . getTime ( timeIndex - 1 ) : time ; double timeNext = getProcess ( ) . getTime ( timeIndex + 1 ) ; RandomVariable zeroRate = getZer...
Returns the short rate from timeIndex to timeIndex + 1 .
23,090
public static double blackScholesATMOptionValue ( double volatility , double optionMaturity , double forward , double payoffUnit ) { if ( optionMaturity < 0 ) { return 0.0 ; } double dPlus = 0.5 * volatility * Math . sqrt ( optionMaturity ) ; double dMinus = - dPlus ; double valueAnalytic = ( NormalDistribution . cumul...
Calculates the Black - Scholes option value of an atm call option .
23,091
public static double blackScholesOptionRho ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionStrike <= 0.0 || optionMaturity <= 0.0 ) { return 0.0 ; } else { double dMinus = ( Math . log ( initialStockValue / optionStrike ) + ( riskFreeRate...
This static method calculated the rho of a call option under a Black - Scholes model
23,092
public static double blackScholesDigitalOptionValue ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionStrike <= 0.0 ) { return 1.0 ; } else { double dPlus = ( Math . log ( initialStockValue / optionStrike ) + ( riskFreeRate + 0.5 * volatili...
Calculates the Black - Scholes option value of a digital call option .
23,093
public static double blackScholesDigitalOptionDelta ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionStrike <= 0.0 || optionMaturity <= 0.0 ) { return 0.0 ; } else { double dPlus = ( Math . log ( initialStockValue / optionStrike ) + ( risk...
Calculates the delta of a digital option under a Black - Scholes model
23,094
public static double blackScholesDigitalOptionVega ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionStrike <= 0.0 || optionMaturity <= 0.0 ) { return 0.0 ; } else { double dPlus = ( Math . log ( initialStockValue / optionStrike ) + ( riskF...
Calculates the vega of a digital option under a Black - Scholes model
23,095
public static double blackScholesDigitalOptionRho ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionMaturity <= 0.0 ) { return 0.0 ; } else if ( optionStrike <= 0.0 ) { double rho = - optionMaturity * Math . exp ( - riskFreeRate * optionMat...
Calculates the rho of a digital option under a Black - Scholes model
23,096
public static double blackModelCapletValue ( double forward , double volatility , double optionMaturity , double optionStrike , double periodLength , double discountFactor ) { return AnalyticFormulas . blackScholesGeneralizedOptionValue ( forward , volatility , optionMaturity , optionStrike , periodLength * discountFac...
Calculate the value of a caplet assuming the Black 76 model .
23,097
public static double blackModelDgitialCapletValue ( double forward , double volatility , double periodLength , double discountFactor , double optionMaturity , double optionStrike ) { return AnalyticFormulas . blackScholesDigitalOptionValue ( forward , 0.0 , volatility , optionMaturity , optionStrike ) * periodLength * ...
Calculate the value of a digital caplet assuming the Black 76 model .
23,098
public static double blackModelSwaptionValue ( double forwardSwaprate , double volatility , double optionMaturity , double optionStrike , double swapAnnuity ) { return AnalyticFormulas . blackScholesGeneralizedOptionValue ( forwardSwaprate , volatility , optionMaturity , optionStrike , swapAnnuity ) ; }
Calculate the value of a swaption assuming the Black 76 model .
23,099
public static double huntKennedyCMSOptionValue ( double forwardSwaprate , double volatility , double swapAnnuity , double optionMaturity , double swapMaturity , double payoffUnit , double optionStrike ) { double a = 1.0 / swapMaturity ; double b = ( payoffUnit / swapAnnuity - a ) / forwardSwaprate ; double convexityAdj...
Calculate the value of a CMS option using the Black - Scholes model for the swap rate together with the Hunt - Kennedy convexity adjustment .