id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
17,600
gocd/gocd
util/src/main/java/com/thoughtworks/go/util/command/ExecScript.java
ExecScript.consumeLine
public synchronized void consumeLine(final String line) { // check if the output contains the error string if (StringUtils.isNotEmpty(errorStr)) { // YES: set error flag if (StringUtils.equalsIgnoreCase(line.trim(), errorStr)) { foundError = true; } } }
java
public synchronized void consumeLine(final String line) { // check if the output contains the error string if (StringUtils.isNotEmpty(errorStr)) { // YES: set error flag if (StringUtils.equalsIgnoreCase(line.trim(), errorStr)) { foundError = true; } } }
[ "public", "synchronized", "void", "consumeLine", "(", "final", "String", "line", ")", "{", "// check if the output contains the error string", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "errorStr", ")", ")", "{", "// YES: set error flag", "if", "(", "StringUtils", ".", "equalsIgnoreCase", "(", "line", ".", "trim", "(", ")", ",", "errorStr", ")", ")", "{", "foundError", "=", "true", ";", "}", "}", "}" ]
Ugly parsing of Exec output into some Elements. Gets called from StreamPumper. @param line the line of output to parse
[ "Ugly", "parsing", "of", "Exec", "output", "into", "some", "Elements", ".", "Gets", "called", "from", "StreamPumper", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/util/src/main/java/com/thoughtworks/go/util/command/ExecScript.java#L35-L44
17,601
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/dao/JobInstanceSqlMapDao.java
JobInstanceSqlMapDao.deleteJobPlanAssociatedEntities
public void deleteJobPlanAssociatedEntities(JobInstance job) { JobPlan jobPlan = loadPlan(job.getId()); environmentVariableDao.deleteAll(jobPlan.getVariables()); artifactPlanRepository.deleteAll(jobPlan.getArtifactPlansOfType(ArtifactPlanType.file)); artifactPropertiesGeneratorRepository.deleteAll(jobPlan.getPropertyGenerators()); resourceRepository.deleteAll(jobPlan.getResources()); if (jobPlan.requiresElasticAgent()) { jobAgentMetadataDao.delete(jobAgentMetadataDao.load(jobPlan.getJobId())); } }
java
public void deleteJobPlanAssociatedEntities(JobInstance job) { JobPlan jobPlan = loadPlan(job.getId()); environmentVariableDao.deleteAll(jobPlan.getVariables()); artifactPlanRepository.deleteAll(jobPlan.getArtifactPlansOfType(ArtifactPlanType.file)); artifactPropertiesGeneratorRepository.deleteAll(jobPlan.getPropertyGenerators()); resourceRepository.deleteAll(jobPlan.getResources()); if (jobPlan.requiresElasticAgent()) { jobAgentMetadataDao.delete(jobAgentMetadataDao.load(jobPlan.getJobId())); } }
[ "public", "void", "deleteJobPlanAssociatedEntities", "(", "JobInstance", "job", ")", "{", "JobPlan", "jobPlan", "=", "loadPlan", "(", "job", ".", "getId", "(", ")", ")", ";", "environmentVariableDao", ".", "deleteAll", "(", "jobPlan", ".", "getVariables", "(", ")", ")", ";", "artifactPlanRepository", ".", "deleteAll", "(", "jobPlan", ".", "getArtifactPlansOfType", "(", "ArtifactPlanType", ".", "file", ")", ")", ";", "artifactPropertiesGeneratorRepository", ".", "deleteAll", "(", "jobPlan", ".", "getPropertyGenerators", "(", ")", ")", ";", "resourceRepository", ".", "deleteAll", "(", "jobPlan", ".", "getResources", "(", ")", ")", ";", "if", "(", "jobPlan", ".", "requiresElasticAgent", "(", ")", ")", "{", "jobAgentMetadataDao", ".", "delete", "(", "jobAgentMetadataDao", ".", "load", "(", "jobPlan", ".", "getJobId", "(", ")", ")", ")", ";", "}", "}" ]
this will be called from Job Status Listener when Job is completed.
[ "this", "will", "be", "called", "from", "Job", "Status", "Listener", "when", "Job", "is", "completed", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/dao/JobInstanceSqlMapDao.java#L274-L283
17,602
gocd/gocd
domain/src/main/java/com/thoughtworks/go/util/SvnLogXmlParser.java
SvnLogXmlParser.convertDate
static Date convertDate(String date) throws ParseException { final int zIndex = date.indexOf('Z'); if (zIndex - 3 < 0) { throw new ParseException(date + " doesn't match the expected subversion date format", date.length()); } String withoutMicroSeconds = date.substring(0, zIndex - 3); return getOutDateFormatter().parse(withoutMicroSeconds); }
java
static Date convertDate(String date) throws ParseException { final int zIndex = date.indexOf('Z'); if (zIndex - 3 < 0) { throw new ParseException(date + " doesn't match the expected subversion date format", date.length()); } String withoutMicroSeconds = date.substring(0, zIndex - 3); return getOutDateFormatter().parse(withoutMicroSeconds); }
[ "static", "Date", "convertDate", "(", "String", "date", ")", "throws", "ParseException", "{", "final", "int", "zIndex", "=", "date", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "zIndex", "-", "3", "<", "0", ")", "{", "throw", "new", "ParseException", "(", "date", "+", "\" doesn't match the expected subversion date format\"", ",", "date", ".", "length", "(", ")", ")", ";", "}", "String", "withoutMicroSeconds", "=", "date", ".", "substring", "(", "0", ",", "zIndex", "-", "3", ")", ";", "return", "getOutDateFormatter", "(", ")", ".", "parse", "(", "withoutMicroSeconds", ")", ";", "}" ]
Converts the specified SVN date string into a Date. @param date with format "yyyy-MM-dd'T'HH:mm:ss.SSS" + "...Z" @return converted date @throws java.text.ParseException if specified date doesn't match the expected format
[ "Converts", "the", "specified", "SVN", "date", "string", "into", "a", "Date", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/domain/src/main/java/com/thoughtworks/go/util/SvnLogXmlParser.java#L102-L111
17,603
gocd/gocd
plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/material/packagerepository/PackageRevision.java
PackageRevision.addData
public void addData(String key, String value) throws InvalidPackageRevisionDataException { validateDataKey(key); data.put(key, value); }
java
public void addData(String key, String value) throws InvalidPackageRevisionDataException { validateDataKey(key); data.put(key, value); }
[ "public", "void", "addData", "(", "String", "key", ",", "String", "value", ")", "throws", "InvalidPackageRevisionDataException", "{", "validateDataKey", "(", "key", ")", ";", "data", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
Adds additional data related to the package revision @param key for additional data @param value for additional data @throws InvalidPackageRevisionDataException if the key is null or empty
[ "Adds", "additional", "data", "related", "to", "the", "package", "revision" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/material/packagerepository/PackageRevision.java#L150-L153
17,604
gocd/gocd
config/config-api/src/main/java/com/thoughtworks/go/config/BasicCruiseConfig.java
BasicCruiseConfig.addPipeline
@Override public void addPipeline(String groupName, PipelineConfig pipelineConfig) { groups.addPipeline(groupName, pipelineConfig); }
java
@Override public void addPipeline(String groupName, PipelineConfig pipelineConfig) { groups.addPipeline(groupName, pipelineConfig); }
[ "@", "Override", "public", "void", "addPipeline", "(", "String", "groupName", ",", "PipelineConfig", "pipelineConfig", ")", "{", "groups", ".", "addPipeline", "(", "groupName", ",", "pipelineConfig", ")", ";", "}" ]
when adding pipelines, groups or environments we must make sure that both merged and basic scopes are updated
[ "when", "adding", "pipelines", "groups", "or", "environments", "we", "must", "make", "sure", "that", "both", "merged", "and", "basic", "scopes", "are", "updated" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/config/config-api/src/main/java/com/thoughtworks/go/config/BasicCruiseConfig.java#L877-L880
17,605
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/dd/FanInGraph.java
FanInGraph.getScmMaterials
List<ScmMaterialConfig> getScmMaterials() { List<ScmMaterialConfig> scmMaterials = new ArrayList<>(); for (FanInNode node : nodes.values()) { if (node.materialConfig instanceof ScmMaterialConfig) { scmMaterials.add((ScmMaterialConfig) node.materialConfig); } } return scmMaterials; }
java
List<ScmMaterialConfig> getScmMaterials() { List<ScmMaterialConfig> scmMaterials = new ArrayList<>(); for (FanInNode node : nodes.values()) { if (node.materialConfig instanceof ScmMaterialConfig) { scmMaterials.add((ScmMaterialConfig) node.materialConfig); } } return scmMaterials; }
[ "List", "<", "ScmMaterialConfig", ">", "getScmMaterials", "(", ")", "{", "List", "<", "ScmMaterialConfig", ">", "scmMaterials", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "FanInNode", "node", ":", "nodes", ".", "values", "(", ")", ")", "{", "if", "(", "node", ".", "materialConfig", "instanceof", "ScmMaterialConfig", ")", "{", "scmMaterials", ".", "add", "(", "(", "ScmMaterialConfig", ")", "node", ".", "materialConfig", ")", ";", "}", "}", "return", "scmMaterials", ";", "}" ]
Used in test Only
[ "Used", "in", "test", "Only" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/dd/FanInGraph.java#L135-L143
17,606
gocd/gocd
plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/task/TaskConfig.java
TaskConfig.addProperty
public TaskConfigProperty addProperty(String propertyName) { TaskConfigProperty property = new TaskConfigProperty(propertyName); add(property); return property; }
java
public TaskConfigProperty addProperty(String propertyName) { TaskConfigProperty property = new TaskConfigProperty(propertyName); add(property); return property; }
[ "public", "TaskConfigProperty", "addProperty", "(", "String", "propertyName", ")", "{", "TaskConfigProperty", "property", "=", "new", "TaskConfigProperty", "(", "propertyName", ")", ";", "add", "(", "property", ")", ";", "return", "property", ";", "}" ]
Adds a property to the configuration of this task. @param propertyName Name of the property (or key) in the configuration. @return an instance of {@link com.thoughtworks.go.plugin.api.task.TaskConfigProperty}
[ "Adds", "a", "property", "to", "the", "configuration", "of", "this", "task", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/task/TaskConfig.java#L42-L46
17,607
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/PipelineHistoryService.java
PipelineHistoryService.populatePlaceHolderStages
private void populatePlaceHolderStages(PipelineInstanceModel pipeline) { StageInstanceModels stageHistory = pipeline.getStageHistory(); String pipelineName = pipeline.getName(); appendFollowingStagesFromConfig(pipelineName, stageHistory); }
java
private void populatePlaceHolderStages(PipelineInstanceModel pipeline) { StageInstanceModels stageHistory = pipeline.getStageHistory(); String pipelineName = pipeline.getName(); appendFollowingStagesFromConfig(pipelineName, stageHistory); }
[ "private", "void", "populatePlaceHolderStages", "(", "PipelineInstanceModel", "pipeline", ")", "{", "StageInstanceModels", "stageHistory", "=", "pipeline", ".", "getStageHistory", "(", ")", ";", "String", "pipelineName", "=", "pipeline", ".", "getName", "(", ")", ";", "appendFollowingStagesFromConfig", "(", "pipelineName", ",", "stageHistory", ")", ";", "}" ]
we need placeholder stage for unscheduled stages in pipeline, so we can trigger it
[ "we", "need", "placeholder", "stage", "for", "unscheduled", "stages", "in", "pipeline", "so", "we", "can", "trigger", "it" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/PipelineHistoryService.java#L192-L196
17,608
gocd/gocd
common/src/main/java/com/thoughtworks/go/util/URLService.java
URLService.getUploadUrlOfAgent
public String getUploadUrlOfAgent(JobIdentifier jobIdentifier, String filePath, int attempt) { return format("%s/%s/%s/%s?attempt=%d&buildId=%d", baseRemotingURL, "remoting", "files", jobIdentifier.artifactLocator(filePath), attempt, jobIdentifier.getBuildId()); }
java
public String getUploadUrlOfAgent(JobIdentifier jobIdentifier, String filePath, int attempt) { return format("%s/%s/%s/%s?attempt=%d&buildId=%d", baseRemotingURL, "remoting", "files", jobIdentifier.artifactLocator(filePath), attempt, jobIdentifier.getBuildId()); }
[ "public", "String", "getUploadUrlOfAgent", "(", "JobIdentifier", "jobIdentifier", ",", "String", "filePath", ",", "int", "attempt", ")", "{", "return", "format", "(", "\"%s/%s/%s/%s?attempt=%d&buildId=%d\"", ",", "baseRemotingURL", ",", "\"remoting\"", ",", "\"files\"", ",", "jobIdentifier", ".", "artifactLocator", "(", "filePath", ")", ",", "attempt", ",", "jobIdentifier", ".", "getBuildId", "(", ")", ")", ";", "}" ]
and therefore cannot locate job correctly when it is rescheduled
[ "and", "therefore", "cannot", "locate", "job", "correctly", "when", "it", "is", "rescheduled" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/common/src/main/java/com/thoughtworks/go/util/URLService.java#L70-L72
17,609
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/ScheduleService.java
ScheduleService.rerunStage
public Stage rerunStage(String pipelineName, Integer pipelineCounter, String stageName, HttpOperationResult result) { String identifier = StringUtils.join(Arrays.asList(pipelineName, pipelineCounter, stageName), "/"); HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forStage(pipelineName, stageName)); Stage stage = null; try { stage = rerunStage(pipelineName, pipelineCounter, stageName, new ResultUpdatingErrorHandler(result)); if (result.isSuccess()) { // this check is for clarity, but is not needed as failures result in RunTimeExceptions result.accepted(String.format("Request to schedule stage %s accepted", identifier), "", healthStateType); } } catch (RuntimeException e) { // if the result is successful, but there's still an exception, treat it as a 500 // else the result is assumed to contain the right status code and error message if (result.isSuccess()) { String message = String.format( "Stage rerun request for stage [%s] could not be completed " + "because of an unexpected failure. Cause: %s", identifier, e.getMessage() ); LOGGER.error(message, e); result.internalServerError(message, healthStateType); } } return stage; }
java
public Stage rerunStage(String pipelineName, Integer pipelineCounter, String stageName, HttpOperationResult result) { String identifier = StringUtils.join(Arrays.asList(pipelineName, pipelineCounter, stageName), "/"); HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forStage(pipelineName, stageName)); Stage stage = null; try { stage = rerunStage(pipelineName, pipelineCounter, stageName, new ResultUpdatingErrorHandler(result)); if (result.isSuccess()) { // this check is for clarity, but is not needed as failures result in RunTimeExceptions result.accepted(String.format("Request to schedule stage %s accepted", identifier), "", healthStateType); } } catch (RuntimeException e) { // if the result is successful, but there's still an exception, treat it as a 500 // else the result is assumed to contain the right status code and error message if (result.isSuccess()) { String message = String.format( "Stage rerun request for stage [%s] could not be completed " + "because of an unexpected failure. Cause: %s", identifier, e.getMessage() ); LOGGER.error(message, e); result.internalServerError(message, healthStateType); } } return stage; }
[ "public", "Stage", "rerunStage", "(", "String", "pipelineName", ",", "Integer", "pipelineCounter", ",", "String", "stageName", ",", "HttpOperationResult", "result", ")", "{", "String", "identifier", "=", "StringUtils", ".", "join", "(", "Arrays", ".", "asList", "(", "pipelineName", ",", "pipelineCounter", ",", "stageName", ")", ",", "\"/\"", ")", ";", "HealthStateType", "healthStateType", "=", "HealthStateType", ".", "general", "(", "HealthStateScope", ".", "forStage", "(", "pipelineName", ",", "stageName", ")", ")", ";", "Stage", "stage", "=", "null", ";", "try", "{", "stage", "=", "rerunStage", "(", "pipelineName", ",", "pipelineCounter", ",", "stageName", ",", "new", "ResultUpdatingErrorHandler", "(", "result", ")", ")", ";", "if", "(", "result", ".", "isSuccess", "(", ")", ")", "{", "// this check is for clarity, but is not needed as failures result in RunTimeExceptions", "result", ".", "accepted", "(", "String", ".", "format", "(", "\"Request to schedule stage %s accepted\"", ",", "identifier", ")", ",", "\"\"", ",", "healthStateType", ")", ";", "}", "}", "catch", "(", "RuntimeException", "e", ")", "{", "// if the result is successful, but there's still an exception, treat it as a 500", "// else the result is assumed to contain the right status code and error message", "if", "(", "result", ".", "isSuccess", "(", ")", ")", "{", "String", "message", "=", "String", ".", "format", "(", "\"Stage rerun request for stage [%s] could not be completed \"", "+", "\"because of an unexpected failure. Cause: %s\"", ",", "identifier", ",", "e", ".", "getMessage", "(", ")", ")", ";", "LOGGER", ".", "error", "(", "message", ",", "e", ")", ";", "result", ".", "internalServerError", "(", "message", ",", "healthStateType", ")", ";", "}", "}", "return", "stage", ";", "}" ]
Top-level operation only; consumes exceptions
[ "Top", "-", "level", "operation", "only", ";", "consumes", "exceptions" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/ScheduleService.java#L269-L294
17,610
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/ScheduleService.java
ScheduleService.isStageActive
private boolean isStageActive(Pipeline pipeline, StageConfig nextStage) { return stageDao.isStageActive(pipeline.getName(), CaseInsensitiveString.str(nextStage.name())); }
java
private boolean isStageActive(Pipeline pipeline, StageConfig nextStage) { return stageDao.isStageActive(pipeline.getName(), CaseInsensitiveString.str(nextStage.name())); }
[ "private", "boolean", "isStageActive", "(", "Pipeline", "pipeline", ",", "StageConfig", "nextStage", ")", "{", "return", "stageDao", ".", "isStageActive", "(", "pipeline", ".", "getName", "(", ")", ",", "CaseInsensitiveString", ".", "str", "(", "nextStage", ".", "name", "(", ")", ")", ")", ";", "}" ]
this method checks if specified stage is active in all pipelines
[ "this", "method", "checks", "if", "specified", "stage", "is", "active", "in", "all", "pipelines" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/ScheduleService.java#L403-L405
17,611
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/StageService.java
StageService.persistStage
private synchronized Stage persistStage(Pipeline pipeline, Stage stage) { long pipelineId = pipeline.getId(); stage.setOrderId(resolveStageOrder(pipelineId, stage.getName())); Stage savedStage = stageDao.save(pipeline, stage); savedStage.setIdentifier(new StageIdentifier(pipeline.getName(), pipeline.getCounter(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()))); for (JobInstance jobInstance : savedStage.getJobInstances()) { jobInstance.setIdentifier(new JobIdentifier(pipeline, savedStage, jobInstance)); } return savedStage; }
java
private synchronized Stage persistStage(Pipeline pipeline, Stage stage) { long pipelineId = pipeline.getId(); stage.setOrderId(resolveStageOrder(pipelineId, stage.getName())); Stage savedStage = stageDao.save(pipeline, stage); savedStage.setIdentifier(new StageIdentifier(pipeline.getName(), pipeline.getCounter(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()))); for (JobInstance jobInstance : savedStage.getJobInstances()) { jobInstance.setIdentifier(new JobIdentifier(pipeline, savedStage, jobInstance)); } return savedStage; }
[ "private", "synchronized", "Stage", "persistStage", "(", "Pipeline", "pipeline", ",", "Stage", "stage", ")", "{", "long", "pipelineId", "=", "pipeline", ".", "getId", "(", ")", ";", "stage", ".", "setOrderId", "(", "resolveStageOrder", "(", "pipelineId", ",", "stage", ".", "getName", "(", ")", ")", ")", ";", "Stage", "savedStage", "=", "stageDao", ".", "save", "(", "pipeline", ",", "stage", ")", ";", "savedStage", ".", "setIdentifier", "(", "new", "StageIdentifier", "(", "pipeline", ".", "getName", "(", ")", ",", "pipeline", ".", "getCounter", "(", ")", ",", "pipeline", ".", "getLabel", "(", ")", ",", "stage", ".", "getName", "(", ")", ",", "String", ".", "valueOf", "(", "stage", ".", "getCounter", "(", ")", ")", ")", ")", ";", "for", "(", "JobInstance", "jobInstance", ":", "savedStage", ".", "getJobInstances", "(", ")", ")", "{", "jobInstance", ".", "setIdentifier", "(", "new", "JobIdentifier", "(", "pipeline", ",", "savedStage", ",", "jobInstance", ")", ")", ";", "}", "return", "savedStage", ";", "}" ]
need to synchronize this method call to make sure no concurrent issues.
[ "need", "to", "synchronize", "this", "method", "call", "to", "make", "sure", "no", "concurrent", "issues", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/StageService.java#L259-L269
17,612
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/StageService.java
StageService.resolveStageOrder
private Integer resolveStageOrder(long pipelineId, String stageName) { Integer order = getStageOrderInPipeline(pipelineId, stageName); if (order == null) { order = getMaxStageOrderInPipeline(pipelineId) + 1; } return order; }
java
private Integer resolveStageOrder(long pipelineId, String stageName) { Integer order = getStageOrderInPipeline(pipelineId, stageName); if (order == null) { order = getMaxStageOrderInPipeline(pipelineId) + 1; } return order; }
[ "private", "Integer", "resolveStageOrder", "(", "long", "pipelineId", ",", "String", "stageName", ")", "{", "Integer", "order", "=", "getStageOrderInPipeline", "(", "pipelineId", ",", "stageName", ")", ";", "if", "(", "order", "==", "null", ")", "{", "order", "=", "getMaxStageOrderInPipeline", "(", "pipelineId", ")", "+", "1", ";", "}", "return", "order", ";", "}" ]
stage order in current pipeline by 1, as current stage's order
[ "stage", "order", "in", "current", "pipeline", "by", "1", "as", "current", "stage", "s", "order" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/StageService.java#L279-L285
17,613
gocd/gocd
plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/config/Property.java
Property.with
final public <T> Property with(Option<T> option, T value) { if(value != null){ options.addOrSet(option, value); } return this; }
java
final public <T> Property with(Option<T> option, T value) { if(value != null){ options.addOrSet(option, value); } return this; }
[ "final", "public", "<", "T", ">", "Property", "with", "(", "Option", "<", "T", ">", "option", ",", "T", "value", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "options", ".", "addOrSet", "(", "option", ",", "value", ")", ";", "}", "return", "this", ";", "}" ]
Adds an option @param option Option type to be added @param value Option value @param <T> Type of option value @return current property instance (this)
[ "Adds", "an", "option" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/config/Property.java#L91-L96
17,614
gocd/gocd
plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/config/Configuration.java
Configuration.get
public Property get(String key) { for (Property property : properties) { if (property.getKey().equals(key)) { return property; } } return null; }
java
public Property get(String key) { for (Property property : properties) { if (property.getKey().equals(key)) { return property; } } return null; }
[ "public", "Property", "get", "(", "String", "key", ")", "{", "for", "(", "Property", "property", ":", "properties", ")", "{", "if", "(", "property", ".", "getKey", "(", ")", ".", "equals", "(", "key", ")", ")", "{", "return", "property", ";", "}", "}", "return", "null", ";", "}" ]
Gets property for a given property key @param key the key whose associated property to be returned @return the property to which the specified key is mapped, or null if this property with given key not found
[ "Gets", "property", "for", "a", "given", "property", "key" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/config/Configuration.java#L44-L51
17,615
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.matchPath
protected static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { return SelectorUtils.matchPath(pattern, str, isCaseSensitive); }
java
protected static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { return SelectorUtils.matchPath(pattern, str, isCaseSensitive); }
[ "protected", "static", "boolean", "matchPath", "(", "String", "pattern", ",", "String", "str", ",", "boolean", "isCaseSensitive", ")", "{", "return", "SelectorUtils", ".", "matchPath", "(", "pattern", ",", "str", ",", "isCaseSensitive", ")", ";", "}" ]
Test whether or not a given path matches a given pattern. @param pattern The pattern to match against. Must not be <code>null</code>. @param str The path to match, as a String. Must not be <code>null</code>. @param isCaseSensitive Whether or not matching should be performed case sensitively. @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise.
[ "Test", "whether", "or", "not", "a", "given", "path", "matches", "a", "given", "pattern", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L444-L447
17,616
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.addDefaultExclude
public static boolean addDefaultExclude(String s) { if (defaultExcludes.indexOf(s) == -1) { defaultExcludes.add(s); return true; } return false; }
java
public static boolean addDefaultExclude(String s) { if (defaultExcludes.indexOf(s) == -1) { defaultExcludes.add(s); return true; } return false; }
[ "public", "static", "boolean", "addDefaultExclude", "(", "String", "s", ")", "{", "if", "(", "defaultExcludes", ".", "indexOf", "(", "s", ")", "==", "-", "1", ")", "{", "defaultExcludes", ".", "add", "(", "s", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add a pattern to the default excludes unless it is already a default exclude. @param s A string to add as an exclude pattern. @return <code>true</code> if the string was added; <code>false</code> if it already existed. @since Ant 1.6
[ "Add", "a", "pattern", "to", "the", "default", "excludes", "unless", "it", "is", "already", "a", "default", "exclude", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L514-L520
17,617
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.resetDefaultExcludes
public static void resetDefaultExcludes() { defaultExcludes = new Vector(); for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { defaultExcludes.add(DEFAULTEXCLUDES[i]); } }
java
public static void resetDefaultExcludes() { defaultExcludes = new Vector(); for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { defaultExcludes.add(DEFAULTEXCLUDES[i]); } }
[ "public", "static", "void", "resetDefaultExcludes", "(", ")", "{", "defaultExcludes", "=", "new", "Vector", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "DEFAULTEXCLUDES", ".", "length", ";", "i", "++", ")", "{", "defaultExcludes", ".", "add", "(", "DEFAULTEXCLUDES", "[", "i", "]", ")", ";", "}", "}" ]
Go back to the hardwired default exclude patterns. @since Ant 1.6
[ "Go", "back", "to", "the", "hardwired", "default", "exclude", "patterns", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L542-L547
17,618
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.scan
public DirectoryScanner scan() throws IllegalStateException { synchronized (scanLock) { if (scanning) { while (scanning) { try { scanLock.wait(); } catch (InterruptedException e) { continue; } } if (illegal != null) { throw illegal; } return this; } scanning = true; } try { synchronized (this) { illegal = null; clearResults(); // set in/excludes to reasonable defaults if needed: boolean nullIncludes = (includes == null); includes = nullIncludes ? new String[] {"**"} : includes; boolean nullExcludes = (excludes == null); excludes = nullExcludes ? new String[0] : excludes; if (basedir == null) { // if no basedir and no includes, nothing to do: if (nullIncludes) { return this; } } else { if (!basedir.exists()) { if (errorOnMissingDir) { illegal = new IllegalStateException( "basedir " + basedir + " does not exist"); } else { // Nothing to do - basedir does not exist return this; } } if (!basedir.isDirectory()) { illegal = new IllegalStateException("basedir " + basedir + " is not a directory"); } if (illegal != null) { throw illegal; } } if (isIncluded("")) { if (!isExcluded("")) { if (isSelected("", basedir)) { dirsIncluded.addElement(""); } else { dirsDeselected.addElement(""); } } else { dirsExcluded.addElement(""); } } else { dirsNotIncluded.addElement(""); } checkIncludePatterns(); clearCaches(); includes = nullIncludes ? null : includes; excludes = nullExcludes ? null : excludes; } } finally { synchronized (scanLock) { scanning = false; scanLock.notifyAll(); } } return this; }
java
public DirectoryScanner scan() throws IllegalStateException { synchronized (scanLock) { if (scanning) { while (scanning) { try { scanLock.wait(); } catch (InterruptedException e) { continue; } } if (illegal != null) { throw illegal; } return this; } scanning = true; } try { synchronized (this) { illegal = null; clearResults(); // set in/excludes to reasonable defaults if needed: boolean nullIncludes = (includes == null); includes = nullIncludes ? new String[] {"**"} : includes; boolean nullExcludes = (excludes == null); excludes = nullExcludes ? new String[0] : excludes; if (basedir == null) { // if no basedir and no includes, nothing to do: if (nullIncludes) { return this; } } else { if (!basedir.exists()) { if (errorOnMissingDir) { illegal = new IllegalStateException( "basedir " + basedir + " does not exist"); } else { // Nothing to do - basedir does not exist return this; } } if (!basedir.isDirectory()) { illegal = new IllegalStateException("basedir " + basedir + " is not a directory"); } if (illegal != null) { throw illegal; } } if (isIncluded("")) { if (!isExcluded("")) { if (isSelected("", basedir)) { dirsIncluded.addElement(""); } else { dirsDeselected.addElement(""); } } else { dirsExcluded.addElement(""); } } else { dirsNotIncluded.addElement(""); } checkIncludePatterns(); clearCaches(); includes = nullIncludes ? null : includes; excludes = nullExcludes ? null : excludes; } } finally { synchronized (scanLock) { scanning = false; scanLock.notifyAll(); } } return this; }
[ "public", "DirectoryScanner", "scan", "(", ")", "throws", "IllegalStateException", "{", "synchronized", "(", "scanLock", ")", "{", "if", "(", "scanning", ")", "{", "while", "(", "scanning", ")", "{", "try", "{", "scanLock", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "continue", ";", "}", "}", "if", "(", "illegal", "!=", "null", ")", "{", "throw", "illegal", ";", "}", "return", "this", ";", "}", "scanning", "=", "true", ";", "}", "try", "{", "synchronized", "(", "this", ")", "{", "illegal", "=", "null", ";", "clearResults", "(", ")", ";", "// set in/excludes to reasonable defaults if needed:", "boolean", "nullIncludes", "=", "(", "includes", "==", "null", ")", ";", "includes", "=", "nullIncludes", "?", "new", "String", "[", "]", "{", "\"**\"", "}", ":", "includes", ";", "boolean", "nullExcludes", "=", "(", "excludes", "==", "null", ")", ";", "excludes", "=", "nullExcludes", "?", "new", "String", "[", "0", "]", ":", "excludes", ";", "if", "(", "basedir", "==", "null", ")", "{", "// if no basedir and no includes, nothing to do:", "if", "(", "nullIncludes", ")", "{", "return", "this", ";", "}", "}", "else", "{", "if", "(", "!", "basedir", ".", "exists", "(", ")", ")", "{", "if", "(", "errorOnMissingDir", ")", "{", "illegal", "=", "new", "IllegalStateException", "(", "\"basedir \"", "+", "basedir", "+", "\" does not exist\"", ")", ";", "}", "else", "{", "// Nothing to do - basedir does not exist", "return", "this", ";", "}", "}", "if", "(", "!", "basedir", ".", "isDirectory", "(", ")", ")", "{", "illegal", "=", "new", "IllegalStateException", "(", "\"basedir \"", "+", "basedir", "+", "\" is not a directory\"", ")", ";", "}", "if", "(", "illegal", "!=", "null", ")", "{", "throw", "illegal", ";", "}", "}", "if", "(", "isIncluded", "(", "\"\"", ")", ")", "{", "if", "(", "!", "isExcluded", "(", "\"\"", ")", ")", "{", "if", "(", "isSelected", "(", "\"\"", ",", "basedir", ")", ")", "{", "dirsIncluded", ".", "addElement", "(", "\"\"", ")", ";", "}", "else", "{", "dirsDeselected", ".", "addElement", "(", "\"\"", ")", ";", "}", "}", "else", "{", "dirsExcluded", ".", "addElement", "(", "\"\"", ")", ";", "}", "}", "else", "{", "dirsNotIncluded", ".", "addElement", "(", "\"\"", ")", ";", "}", "checkIncludePatterns", "(", ")", ";", "clearCaches", "(", ")", ";", "includes", "=", "nullIncludes", "?", "null", ":", "includes", ";", "excludes", "=", "nullExcludes", "?", "null", ":", "excludes", ";", "}", "}", "finally", "{", "synchronized", "(", "scanLock", ")", "{", "scanning", "=", "false", ";", "scanLock", ".", "notifyAll", "(", ")", ";", "}", "}", "return", "this", ";", "}" ]
Scan for files which match at least one include pattern and don't match any exclude patterns. If there are selectors then the files must pass muster there, as well. Scans under basedir, if set; otherwise the include patterns without leading wildcards specify the absolute paths of the files that may be included. @exception IllegalStateException if the base directory was set incorrectly (i.e. if it doesn't exist or isn't a directory).
[ "Scan", "for", "files", "which", "match", "at", "least", "one", "include", "pattern", "and", "don", "t", "match", "any", "exclude", "patterns", ".", "If", "there", "are", "selectors", "then", "the", "files", "must", "pass", "muster", "there", "as", "well", ".", "Scans", "under", "basedir", "if", "set", ";", "otherwise", "the", "include", "patterns", "without", "leading", "wildcards", "specify", "the", "absolute", "paths", "of", "the", "files", "that", "may", "be", "included", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L759-L835
17,619
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.clearResults
protected synchronized void clearResults() { filesIncluded = new Vector(); filesNotIncluded = new Vector(); filesExcluded = new Vector(); filesDeselected = new Vector(); dirsIncluded = new Vector(); dirsNotIncluded = new Vector(); dirsExcluded = new Vector(); dirsDeselected = new Vector(); everythingIncluded = (basedir != null); scannedDirs.clear(); }
java
protected synchronized void clearResults() { filesIncluded = new Vector(); filesNotIncluded = new Vector(); filesExcluded = new Vector(); filesDeselected = new Vector(); dirsIncluded = new Vector(); dirsNotIncluded = new Vector(); dirsExcluded = new Vector(); dirsDeselected = new Vector(); everythingIncluded = (basedir != null); scannedDirs.clear(); }
[ "protected", "synchronized", "void", "clearResults", "(", ")", "{", "filesIncluded", "=", "new", "Vector", "(", ")", ";", "filesNotIncluded", "=", "new", "Vector", "(", ")", ";", "filesExcluded", "=", "new", "Vector", "(", ")", ";", "filesDeselected", "=", "new", "Vector", "(", ")", ";", "dirsIncluded", "=", "new", "Vector", "(", ")", ";", "dirsNotIncluded", "=", "new", "Vector", "(", ")", ";", "dirsExcluded", "=", "new", "Vector", "(", ")", ";", "dirsDeselected", "=", "new", "Vector", "(", ")", ";", "everythingIncluded", "=", "(", "basedir", "!=", "null", ")", ";", "scannedDirs", ".", "clear", "(", ")", ";", "}" ]
Clear the result caches for a scan.
[ "Clear", "the", "result", "caches", "for", "a", "scan", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L954-L965
17,620
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.scandir
protected void scandir(File dir, String vpath, boolean fast) { if (dir == null) { throw new RuntimeException("dir must not be null."); } String[] newfiles = dir.list(); if (newfiles == null) { if (!dir.exists()) { throw new RuntimeException(dir + " doesn't exist."); } else if (!dir.isDirectory()) { throw new RuntimeException(dir + " is not a directory."); } else { throw new RuntimeException("IO error scanning directory '" + dir.getAbsolutePath() + "'"); } } scandir(dir, vpath, fast, newfiles); }
java
protected void scandir(File dir, String vpath, boolean fast) { if (dir == null) { throw new RuntimeException("dir must not be null."); } String[] newfiles = dir.list(); if (newfiles == null) { if (!dir.exists()) { throw new RuntimeException(dir + " doesn't exist."); } else if (!dir.isDirectory()) { throw new RuntimeException(dir + " is not a directory."); } else { throw new RuntimeException("IO error scanning directory '" + dir.getAbsolutePath() + "'"); } } scandir(dir, vpath, fast, newfiles); }
[ "protected", "void", "scandir", "(", "File", "dir", ",", "String", "vpath", ",", "boolean", "fast", ")", "{", "if", "(", "dir", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"dir must not be null.\"", ")", ";", "}", "String", "[", "]", "newfiles", "=", "dir", ".", "list", "(", ")", ";", "if", "(", "newfiles", "==", "null", ")", "{", "if", "(", "!", "dir", ".", "exists", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "dir", "+", "\" doesn't exist.\"", ")", ";", "}", "else", "if", "(", "!", "dir", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "dir", "+", "\" is not a directory.\"", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"IO error scanning directory '\"", "+", "dir", ".", "getAbsolutePath", "(", ")", "+", "\"'\"", ")", ";", "}", "}", "scandir", "(", "dir", ",", "vpath", ",", "fast", ",", "newfiles", ")", ";", "}" ]
Scan the given directory for files and directories. Found files and directories are placed in their respective collections, based on the matching of includes, excludes, and the selectors. When a directory is found, it is scanned recursively. @param dir The directory to scan. Must not be <code>null</code>. @param vpath The path relative to the base directory (needed to prevent problems with an absolute path when using dir). Must not be <code>null</code>. @param fast Whether or not this call is part of a fast scan. @see #filesIncluded @see #filesNotIncluded @see #filesExcluded @see #dirsIncluded @see #dirsNotIncluded @see #dirsExcluded @see #slowScan
[ "Scan", "the", "given", "directory", "for", "files", "and", "directories", ".", "Found", "files", "and", "directories", "are", "placed", "in", "their", "respective", "collections", "based", "on", "the", "matching", "of", "includes", "excludes", "and", "the", "selectors", ".", "When", "a", "directory", "is", "found", "it", "is", "scanned", "recursively", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1051-L1067
17,621
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.accountForIncludedFile
private void accountForIncludedFile(String name, File file) { processIncluded(name, file, filesIncluded, filesExcluded, filesDeselected); }
java
private void accountForIncludedFile(String name, File file) { processIncluded(name, file, filesIncluded, filesExcluded, filesDeselected); }
[ "private", "void", "accountForIncludedFile", "(", "String", "name", ",", "File", "file", ")", "{", "processIncluded", "(", "name", ",", "file", ",", "filesIncluded", ",", "filesExcluded", ",", "filesDeselected", ")", ";", "}" ]
Process included file. @param name path of the file relative to the directory of the FileSet. @param file included File.
[ "Process", "included", "file", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1128-L1130
17,622
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.accountForIncludedDir
private void accountForIncludedDir(String name, File file, boolean fast) { processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) { scandir(file, name + File.separator, fast); } }
java
private void accountForIncludedDir(String name, File file, boolean fast) { processIncluded(name, file, dirsIncluded, dirsExcluded, dirsDeselected); if (fast && couldHoldIncluded(name) && !contentsExcluded(name)) { scandir(file, name + File.separator, fast); } }
[ "private", "void", "accountForIncludedDir", "(", "String", "name", ",", "File", "file", ",", "boolean", "fast", ")", "{", "processIncluded", "(", "name", ",", "file", ",", "dirsIncluded", ",", "dirsExcluded", ",", "dirsDeselected", ")", ";", "if", "(", "fast", "&&", "couldHoldIncluded", "(", "name", ")", "&&", "!", "contentsExcluded", "(", "name", ")", ")", "{", "scandir", "(", "file", ",", "name", "+", "File", ".", "separator", ",", "fast", ")", ";", "}", "}" ]
Process included directory. @param name path of the directory relative to the directory of the FileSet. @param file directory as File. @param fast whether to perform fast scans.
[ "Process", "included", "directory", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1139-L1144
17,623
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.isIncluded
protected boolean isIncluded(String name) { ensureNonPatternSetsReady(); if (isCaseSensitive() ? includeNonPatterns.contains(name) : includeNonPatterns.contains(name.toUpperCase())) { return true; } for (int i = 0; i < includePatterns.length; i++) { if (matchPath(includePatterns[i], name, isCaseSensitive())) { return true; } } return false; }
java
protected boolean isIncluded(String name) { ensureNonPatternSetsReady(); if (isCaseSensitive() ? includeNonPatterns.contains(name) : includeNonPatterns.contains(name.toUpperCase())) { return true; } for (int i = 0; i < includePatterns.length; i++) { if (matchPath(includePatterns[i], name, isCaseSensitive())) { return true; } } return false; }
[ "protected", "boolean", "isIncluded", "(", "String", "name", ")", "{", "ensureNonPatternSetsReady", "(", ")", ";", "if", "(", "isCaseSensitive", "(", ")", "?", "includeNonPatterns", ".", "contains", "(", "name", ")", ":", "includeNonPatterns", ".", "contains", "(", "name", ".", "toUpperCase", "(", ")", ")", ")", "{", "return", "true", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "includePatterns", ".", "length", ";", "i", "++", ")", "{", "if", "(", "matchPath", "(", "includePatterns", "[", "i", "]", ",", "name", ",", "isCaseSensitive", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Test whether or not a name matches against at least one include pattern. @param name The name to match. Must not be <code>null</code>. @return <code>true</code> when the name matches against at least one include pattern, or <code>false</code> otherwise.
[ "Test", "whether", "or", "not", "a", "name", "matches", "against", "at", "least", "one", "include", "pattern", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1176-L1190
17,624
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.couldHoldIncluded
protected boolean couldHoldIncluded(String name) { for (int i = 0; i < includes.length; i++) { if (matchPatternStart(includes[i], name, isCaseSensitive()) && isMorePowerfulThanExcludes(name, includes[i]) && isDeeper(includes[i], name)) { return true; } } return false; }
java
protected boolean couldHoldIncluded(String name) { for (int i = 0; i < includes.length; i++) { if (matchPatternStart(includes[i], name, isCaseSensitive()) && isMorePowerfulThanExcludes(name, includes[i]) && isDeeper(includes[i], name)) { return true; } } return false; }
[ "protected", "boolean", "couldHoldIncluded", "(", "String", "name", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "includes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "matchPatternStart", "(", "includes", "[", "i", "]", ",", "name", ",", "isCaseSensitive", "(", ")", ")", "&&", "isMorePowerfulThanExcludes", "(", "name", ",", "includes", "[", "i", "]", ")", "&&", "isDeeper", "(", "includes", "[", "i", "]", ",", "name", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Test whether or not a name matches the start of at least one include pattern. @param name The name to match. Must not be <code>null</code>. @return <code>true</code> when the name matches against the start of at least one include pattern, or <code>false</code> otherwise.
[ "Test", "whether", "or", "not", "a", "name", "matches", "the", "start", "of", "at", "least", "one", "include", "pattern", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1200-L1209
17,625
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.isDeeper
private boolean isDeeper(String pattern, String name) { Vector p = SelectorUtils.tokenizePath(pattern); Vector n = SelectorUtils.tokenizePath(name); return p.contains("**") || p.size() > n.size(); }
java
private boolean isDeeper(String pattern, String name) { Vector p = SelectorUtils.tokenizePath(pattern); Vector n = SelectorUtils.tokenizePath(name); return p.contains("**") || p.size() > n.size(); }
[ "private", "boolean", "isDeeper", "(", "String", "pattern", ",", "String", "name", ")", "{", "Vector", "p", "=", "SelectorUtils", ".", "tokenizePath", "(", "pattern", ")", ";", "Vector", "n", "=", "SelectorUtils", ".", "tokenizePath", "(", "name", ")", ";", "return", "p", ".", "contains", "(", "\"**\"", ")", "||", "p", ".", "size", "(", ")", ">", "n", ".", "size", "(", ")", ";", "}" ]
Verify that a pattern specifies files deeper than the level of the specified file. @param pattern the pattern to check. @param name the name to check. @return whether the pattern is deeper than the name. @since Ant 1.6.3
[ "Verify", "that", "a", "pattern", "specifies", "files", "deeper", "than", "the", "level", "of", "the", "specified", "file", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1219-L1223
17,626
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.contentsExcluded
private boolean contentsExcluded(String name) { name = (name.endsWith(File.separator)) ? name : name + File.separator; for (int i = 0; i < excludes.length; i++) { String e = excludes[i]; if (e.endsWith("**") && SelectorUtils.matchPath( e.substring(0, e.length() - 2), name, isCaseSensitive())) { return true; } } return false; }
java
private boolean contentsExcluded(String name) { name = (name.endsWith(File.separator)) ? name : name + File.separator; for (int i = 0; i < excludes.length; i++) { String e = excludes[i]; if (e.endsWith("**") && SelectorUtils.matchPath( e.substring(0, e.length() - 2), name, isCaseSensitive())) { return true; } } return false; }
[ "private", "boolean", "contentsExcluded", "(", "String", "name", ")", "{", "name", "=", "(", "name", ".", "endsWith", "(", "File", ".", "separator", ")", ")", "?", "name", ":", "name", "+", "File", ".", "separator", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "excludes", ".", "length", ";", "i", "++", ")", "{", "String", "e", "=", "excludes", "[", "i", "]", ";", "if", "(", "e", ".", "endsWith", "(", "\"**\"", ")", "&&", "SelectorUtils", ".", "matchPath", "(", "e", ".", "substring", "(", "0", ",", "e", ".", "length", "(", ")", "-", "2", ")", ",", "name", ",", "isCaseSensitive", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Test whether all contents of the specified directory must be excluded. @param name the directory name to check. @return whether all the specified directory's contents are excluded.
[ "Test", "whether", "all", "contents", "of", "the", "specified", "directory", "must", "be", "excluded", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1256-L1266
17,627
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.isExcluded
protected boolean isExcluded(String name) { ensureNonPatternSetsReady(); if (isCaseSensitive() ? excludeNonPatterns.contains(name) : excludeNonPatterns.contains(name.toUpperCase())) { return true; } for (int i = 0; i < excludePatterns.length; i++) { if (matchPath(excludePatterns[i], name, isCaseSensitive())) { return true; } } return false; }
java
protected boolean isExcluded(String name) { ensureNonPatternSetsReady(); if (isCaseSensitive() ? excludeNonPatterns.contains(name) : excludeNonPatterns.contains(name.toUpperCase())) { return true; } for (int i = 0; i < excludePatterns.length; i++) { if (matchPath(excludePatterns[i], name, isCaseSensitive())) { return true; } } return false; }
[ "protected", "boolean", "isExcluded", "(", "String", "name", ")", "{", "ensureNonPatternSetsReady", "(", ")", ";", "if", "(", "isCaseSensitive", "(", ")", "?", "excludeNonPatterns", ".", "contains", "(", "name", ")", ":", "excludeNonPatterns", ".", "contains", "(", "name", ".", "toUpperCase", "(", ")", ")", ")", "{", "return", "true", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "excludePatterns", ".", "length", ";", "i", "++", ")", "{", "if", "(", "matchPath", "(", "excludePatterns", "[", "i", "]", ",", "name", ",", "isCaseSensitive", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Test whether or not a name matches against at least one exclude pattern. @param name The name to match. Must not be <code>null</code>. @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code> otherwise.
[ "Test", "whether", "or", "not", "a", "name", "matches", "against", "at", "least", "one", "exclude", "pattern", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1276-L1290
17,628
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.getIncludedFiles
public synchronized String[] getIncludedFiles() { if (filesIncluded == null) { throw new IllegalStateException("Must call scan() first"); } String[] files = new String[filesIncluded.size()]; filesIncluded.copyInto(files); Arrays.sort(files); return files; }
java
public synchronized String[] getIncludedFiles() { if (filesIncluded == null) { throw new IllegalStateException("Must call scan() first"); } String[] files = new String[filesIncluded.size()]; filesIncluded.copyInto(files); Arrays.sort(files); return files; }
[ "public", "synchronized", "String", "[", "]", "getIncludedFiles", "(", ")", "{", "if", "(", "filesIncluded", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Must call scan() first\"", ")", ";", "}", "String", "[", "]", "files", "=", "new", "String", "[", "filesIncluded", ".", "size", "(", ")", "]", ";", "filesIncluded", ".", "copyInto", "(", "files", ")", ";", "Arrays", ".", "sort", "(", "files", ")", ";", "return", "files", ";", "}" ]
Return the names of the files which matched at least one of the include patterns and none of the exclude patterns. The names are relative to the base directory. @return the names of the files which matched at least one of the include patterns and none of the exclude patterns.
[ "Return", "the", "names", "of", "the", "files", "which", "matched", "at", "least", "one", "of", "the", "include", "patterns", "and", "none", "of", "the", "exclude", "patterns", ".", "The", "names", "are", "relative", "to", "the", "base", "directory", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1312-L1320
17,629
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.getNotIncludedFiles
public synchronized String[] getNotIncludedFiles() { slowScan(); String[] files = new String[filesNotIncluded.size()]; filesNotIncluded.copyInto(files); return files; }
java
public synchronized String[] getNotIncludedFiles() { slowScan(); String[] files = new String[filesNotIncluded.size()]; filesNotIncluded.copyInto(files); return files; }
[ "public", "synchronized", "String", "[", "]", "getNotIncludedFiles", "(", ")", "{", "slowScan", "(", ")", ";", "String", "[", "]", "files", "=", "new", "String", "[", "filesNotIncluded", ".", "size", "(", ")", "]", ";", "filesNotIncluded", ".", "copyInto", "(", "files", ")", ";", "return", "files", ";", "}" ]
Return the names of the files which matched none of the include patterns. The names are relative to the base directory. This involves performing a slow scan if one has not already been completed. @return the names of the files which matched none of the include patterns. @see #slowScan
[ "Return", "the", "names", "of", "the", "files", "which", "matched", "none", "of", "the", "include", "patterns", ".", "The", "names", "are", "relative", "to", "the", "base", "directory", ".", "This", "involves", "performing", "a", "slow", "scan", "if", "one", "has", "not", "already", "been", "completed", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1344-L1349
17,630
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.getExcludedFiles
public synchronized String[] getExcludedFiles() { slowScan(); String[] files = new String[filesExcluded.size()]; filesExcluded.copyInto(files); return files; }
java
public synchronized String[] getExcludedFiles() { slowScan(); String[] files = new String[filesExcluded.size()]; filesExcluded.copyInto(files); return files; }
[ "public", "synchronized", "String", "[", "]", "getExcludedFiles", "(", ")", "{", "slowScan", "(", ")", ";", "String", "[", "]", "files", "=", "new", "String", "[", "filesExcluded", ".", "size", "(", ")", "]", ";", "filesExcluded", ".", "copyInto", "(", "files", ")", ";", "return", "files", ";", "}" ]
Return the names of the files which matched at least one of the include patterns and at least one of the exclude patterns. The names are relative to the base directory. This involves performing a slow scan if one has not already been completed. @return the names of the files which matched at least one of the include patterns and at least one of the exclude patterns. @see #slowScan
[ "Return", "the", "names", "of", "the", "files", "which", "matched", "at", "least", "one", "of", "the", "include", "patterns", "and", "at", "least", "one", "of", "the", "exclude", "patterns", ".", "The", "names", "are", "relative", "to", "the", "base", "directory", ".", "This", "involves", "performing", "a", "slow", "scan", "if", "one", "has", "not", "already", "been", "completed", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1362-L1367
17,631
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.getIncludedDirectories
public synchronized String[] getIncludedDirectories() { if (dirsIncluded == null) { throw new IllegalStateException("Must call scan() first"); } String[] directories = new String[dirsIncluded.size()]; dirsIncluded.copyInto(directories); Arrays.sort(directories); return directories; }
java
public synchronized String[] getIncludedDirectories() { if (dirsIncluded == null) { throw new IllegalStateException("Must call scan() first"); } String[] directories = new String[dirsIncluded.size()]; dirsIncluded.copyInto(directories); Arrays.sort(directories); return directories; }
[ "public", "synchronized", "String", "[", "]", "getIncludedDirectories", "(", ")", "{", "if", "(", "dirsIncluded", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Must call scan() first\"", ")", ";", "}", "String", "[", "]", "directories", "=", "new", "String", "[", "dirsIncluded", ".", "size", "(", ")", "]", ";", "dirsIncluded", ".", "copyInto", "(", "directories", ")", ";", "Arrays", ".", "sort", "(", "directories", ")", ";", "return", "directories", ";", "}" ]
Return the names of the directories which matched at least one of the include patterns and none of the exclude patterns. The names are relative to the base directory. @return the names of the directories which matched at least one of the include patterns and none of the exclude patterns.
[ "Return", "the", "names", "of", "the", "directories", "which", "matched", "at", "least", "one", "of", "the", "include", "patterns", "and", "none", "of", "the", "exclude", "patterns", ".", "The", "names", "are", "relative", "to", "the", "base", "directory", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1395-L1403
17,632
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.getNotIncludedDirectories
public synchronized String[] getNotIncludedDirectories() { slowScan(); String[] directories = new String[dirsNotIncluded.size()]; dirsNotIncluded.copyInto(directories); return directories; }
java
public synchronized String[] getNotIncludedDirectories() { slowScan(); String[] directories = new String[dirsNotIncluded.size()]; dirsNotIncluded.copyInto(directories); return directories; }
[ "public", "synchronized", "String", "[", "]", "getNotIncludedDirectories", "(", ")", "{", "slowScan", "(", ")", ";", "String", "[", "]", "directories", "=", "new", "String", "[", "dirsNotIncluded", ".", "size", "(", ")", "]", ";", "dirsNotIncluded", ".", "copyInto", "(", "directories", ")", ";", "return", "directories", ";", "}" ]
Return the names of the directories which matched none of the include patterns. The names are relative to the base directory. This involves performing a slow scan if one has not already been completed. @return the names of the directories which matched none of the include patterns. @see #slowScan
[ "Return", "the", "names", "of", "the", "directories", "which", "matched", "none", "of", "the", "include", "patterns", ".", "The", "names", "are", "relative", "to", "the", "base", "directory", ".", "This", "involves", "performing", "a", "slow", "scan", "if", "one", "has", "not", "already", "been", "completed", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1427-L1432
17,633
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.getExcludedDirectories
public synchronized String[] getExcludedDirectories() { slowScan(); String[] directories = new String[dirsExcluded.size()]; dirsExcluded.copyInto(directories); return directories; }
java
public synchronized String[] getExcludedDirectories() { slowScan(); String[] directories = new String[dirsExcluded.size()]; dirsExcluded.copyInto(directories); return directories; }
[ "public", "synchronized", "String", "[", "]", "getExcludedDirectories", "(", ")", "{", "slowScan", "(", ")", ";", "String", "[", "]", "directories", "=", "new", "String", "[", "dirsExcluded", ".", "size", "(", ")", "]", ";", "dirsExcluded", ".", "copyInto", "(", "directories", ")", ";", "return", "directories", ";", "}" ]
Return the names of the directories which matched at least one of the include patterns and at least one of the exclude patterns. The names are relative to the base directory. This involves performing a slow scan if one has not already been completed. @return the names of the directories which matched at least one of the include patterns and at least one of the exclude patterns. @see #slowScan
[ "Return", "the", "names", "of", "the", "directories", "which", "matched", "at", "least", "one", "of", "the", "include", "patterns", "and", "at", "least", "one", "of", "the", "exclude", "patterns", ".", "The", "names", "are", "relative", "to", "the", "base", "directory", ".", "This", "involves", "performing", "a", "slow", "scan", "if", "one", "has", "not", "already", "been", "completed", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1445-L1450
17,634
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.addDefaultExcludes
public synchronized void addDefaultExcludes() { int excludesLength = excludes == null ? 0 : excludes.length; String[] newExcludes; newExcludes = new String[excludesLength + defaultExcludes.size()]; if (excludesLength > 0) { System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); } String[] defaultExcludesTemp = getDefaultExcludes(); for (int i = 0; i < defaultExcludesTemp.length; i++) { newExcludes[i + excludesLength] = defaultExcludesTemp[i].replace('/', File.separatorChar) .replace('\\', File.separatorChar); } excludes = newExcludes; }
java
public synchronized void addDefaultExcludes() { int excludesLength = excludes == null ? 0 : excludes.length; String[] newExcludes; newExcludes = new String[excludesLength + defaultExcludes.size()]; if (excludesLength > 0) { System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); } String[] defaultExcludesTemp = getDefaultExcludes(); for (int i = 0; i < defaultExcludesTemp.length; i++) { newExcludes[i + excludesLength] = defaultExcludesTemp[i].replace('/', File.separatorChar) .replace('\\', File.separatorChar); } excludes = newExcludes; }
[ "public", "synchronized", "void", "addDefaultExcludes", "(", ")", "{", "int", "excludesLength", "=", "excludes", "==", "null", "?", "0", ":", "excludes", ".", "length", ";", "String", "[", "]", "newExcludes", ";", "newExcludes", "=", "new", "String", "[", "excludesLength", "+", "defaultExcludes", ".", "size", "(", ")", "]", ";", "if", "(", "excludesLength", ">", "0", ")", "{", "System", ".", "arraycopy", "(", "excludes", ",", "0", ",", "newExcludes", ",", "0", ",", "excludesLength", ")", ";", "}", "String", "[", "]", "defaultExcludesTemp", "=", "getDefaultExcludes", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "defaultExcludesTemp", ".", "length", ";", "i", "++", ")", "{", "newExcludes", "[", "i", "+", "excludesLength", "]", "=", "defaultExcludesTemp", "[", "i", "]", ".", "replace", "(", "'", "'", ",", "File", ".", "separatorChar", ")", ".", "replace", "(", "'", "'", ",", "File", ".", "separatorChar", ")", ";", "}", "excludes", "=", "newExcludes", ";", "}" ]
Add default exclusions to the current exclusions set.
[ "Add", "default", "exclusions", "to", "the", "current", "exclusions", "set", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1473-L1487
17,635
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.list
private String[] list(File file) { String[] files = (String[]) fileListMap.get(file); if (files == null) { files = file.list(); if (files != null) { fileListMap.put(file, files); } } return files; }
java
private String[] list(File file) { String[] files = (String[]) fileListMap.get(file); if (files == null) { files = file.list(); if (files != null) { fileListMap.put(file, files); } } return files; }
[ "private", "String", "[", "]", "list", "(", "File", "file", ")", "{", "String", "[", "]", "files", "=", "(", "String", "[", "]", ")", "fileListMap", ".", "get", "(", "file", ")", ";", "if", "(", "files", "==", "null", ")", "{", "files", "=", "file", ".", "list", "(", ")", ";", "if", "(", "files", "!=", "null", ")", "{", "fileListMap", ".", "put", "(", "file", ",", "files", ")", ";", "}", "}", "return", "files", ";", "}" ]
Return a cached result of list performed on file, if available. Invokes the method and caches the result otherwise. @param file File (dir) to list. @since Ant 1.6
[ "Return", "a", "cached", "result", "of", "list", "performed", "on", "file", "if", "available", ".", "Invokes", "the", "method", "and", "caches", "the", "result", "otherwise", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1497-L1506
17,636
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.clearCaches
private synchronized void clearCaches() { fileListMap.clear(); includeNonPatterns.clear(); excludeNonPatterns.clear(); includePatterns = null; excludePatterns = null; areNonPatternSetsReady = false; }
java
private synchronized void clearCaches() { fileListMap.clear(); includeNonPatterns.clear(); excludeNonPatterns.clear(); includePatterns = null; excludePatterns = null; areNonPatternSetsReady = false; }
[ "private", "synchronized", "void", "clearCaches", "(", ")", "{", "fileListMap", ".", "clear", "(", ")", ";", "includeNonPatterns", ".", "clear", "(", ")", ";", "excludeNonPatterns", ".", "clear", "(", ")", ";", "includePatterns", "=", "null", ";", "excludePatterns", "=", "null", ";", "areNonPatternSetsReady", "=", "false", ";", "}" ]
Clear internal caches. @since Ant 1.6
[ "Clear", "internal", "caches", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1637-L1644
17,637
gocd/gocd
base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java
DirectoryScanner.ensureNonPatternSetsReady
private synchronized void ensureNonPatternSetsReady() { if (!areNonPatternSetsReady) { includePatterns = fillNonPatternSet(includeNonPatterns, includes); excludePatterns = fillNonPatternSet(excludeNonPatterns, excludes); areNonPatternSetsReady = true; } }
java
private synchronized void ensureNonPatternSetsReady() { if (!areNonPatternSetsReady) { includePatterns = fillNonPatternSet(includeNonPatterns, includes); excludePatterns = fillNonPatternSet(excludeNonPatterns, excludes); areNonPatternSetsReady = true; } }
[ "private", "synchronized", "void", "ensureNonPatternSetsReady", "(", ")", "{", "if", "(", "!", "areNonPatternSetsReady", ")", "{", "includePatterns", "=", "fillNonPatternSet", "(", "includeNonPatterns", ",", "includes", ")", ";", "excludePatterns", "=", "fillNonPatternSet", "(", "excludeNonPatterns", ",", "excludes", ")", ";", "areNonPatternSetsReady", "=", "true", ";", "}", "}" ]
Ensure that the in|exclude &quot;patterns&quot; have been properly divided up. @since Ant 1.6.3
[ "Ensure", "that", "the", "in|exclude", "&quot", ";", "patterns&quot", ";", "have", "been", "properly", "divided", "up", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/base/src/main/java/com/thoughtworks/go/util/DirectoryScanner.java#L1652-L1658
17,638
gocd/gocd
server/src/main/java/com/thoughtworks/go/server/service/AdminsConfigService.java
AdminsConfigService.deDuplicatedErrors
private String deDuplicatedErrors(List<ConfigErrors> allErrors) { Set<String> errors = allErrors.stream().map(ConfigErrors::firstError).collect(Collectors.toSet()); return StringUtils.join(errors, ","); }
java
private String deDuplicatedErrors(List<ConfigErrors> allErrors) { Set<String> errors = allErrors.stream().map(ConfigErrors::firstError).collect(Collectors.toSet()); return StringUtils.join(errors, ","); }
[ "private", "String", "deDuplicatedErrors", "(", "List", "<", "ConfigErrors", ">", "allErrors", ")", "{", "Set", "<", "String", ">", "errors", "=", "allErrors", ".", "stream", "(", ")", ".", "map", "(", "ConfigErrors", "::", "firstError", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ";", "return", "StringUtils", ".", "join", "(", "errors", ",", "\",\"", ")", ";", "}" ]
Hack to remove duplicate errors. See `AdminRole.addError`
[ "Hack", "to", "remove", "duplicate", "errors", ".", "See", "AdminRole", ".", "addError" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/server/src/main/java/com/thoughtworks/go/server/service/AdminsConfigService.java#L81-L84
17,639
gocd/gocd
plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/response/Result.java
Result.withSuccessMessages
public Result withSuccessMessages(String... successMessages) { List<String> msgList = Arrays.asList(successMessages); return withSuccessMessages(msgList); }
java
public Result withSuccessMessages(String... successMessages) { List<String> msgList = Arrays.asList(successMessages); return withSuccessMessages(msgList); }
[ "public", "Result", "withSuccessMessages", "(", "String", "...", "successMessages", ")", "{", "List", "<", "String", ">", "msgList", "=", "Arrays", ".", "asList", "(", "successMessages", ")", ";", "return", "withSuccessMessages", "(", "msgList", ")", ";", "}" ]
Creates instance of result with specified success messages @param successMessages the success messages with which instance should be created @return created instance
[ "Creates", "instance", "of", "result", "with", "specified", "success", "messages" ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/response/Result.java#L72-L75
17,640
gocd/gocd
plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/response/Result.java
Result.getMessagesForDisplay
public String getMessagesForDisplay() { if(messages.isEmpty()) { return ""; } StringBuilder stringBuilder = new StringBuilder(); for (String message : messages) { stringBuilder.append(message); stringBuilder.append("\n"); } String tempStr = stringBuilder.toString(); stringBuilder.deleteCharAt(tempStr.length() - 1); return stringBuilder.toString(); }
java
public String getMessagesForDisplay() { if(messages.isEmpty()) { return ""; } StringBuilder stringBuilder = new StringBuilder(); for (String message : messages) { stringBuilder.append(message); stringBuilder.append("\n"); } String tempStr = stringBuilder.toString(); stringBuilder.deleteCharAt(tempStr.length() - 1); return stringBuilder.toString(); }
[ "public", "String", "getMessagesForDisplay", "(", ")", "{", "if", "(", "messages", ".", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "}", "StringBuilder", "stringBuilder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "message", ":", "messages", ")", "{", "stringBuilder", ".", "append", "(", "message", ")", ";", "stringBuilder", ".", "append", "(", "\"\\n\"", ")", ";", "}", "String", "tempStr", "=", "stringBuilder", ".", "toString", "(", ")", ";", "stringBuilder", ".", "deleteCharAt", "(", "tempStr", ".", "length", "(", ")", "-", "1", ")", ";", "return", "stringBuilder", ".", "toString", "(", ")", ";", "}" ]
Formats the messages in the result to a suitable form so that it can be used in user interface. @return a string containing the formatted message.
[ "Formats", "the", "messages", "in", "the", "result", "to", "a", "suitable", "form", "so", "that", "it", "can", "be", "used", "in", "user", "interface", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/plugin-infra/go-plugin-api/src/main/java/com/thoughtworks/go/plugin/api/response/Result.java#L98-L110
17,641
gocd/gocd
api/api-elastic-profile-v2/src/main/java/com/thoughtworks/go/apiv2/elasticprofile/ElasticProfileControllerV2.java
ElasticProfileControllerV2.haltIfEntityWithSameIdExists
private void haltIfEntityWithSameIdExists(ElasticProfile elasticProfile) { if (elasticProfileService.findProfile(elasticProfile.getId()) == null) { return; } elasticProfile.addError("id", format("Elastic profile ids should be unique. Elastic profile with id '%s' already exists.", elasticProfile.getId())); throw haltBecauseEntityAlreadyExists(jsonWriter(elasticProfile), "elasticProfile", elasticProfile.getId()); }
java
private void haltIfEntityWithSameIdExists(ElasticProfile elasticProfile) { if (elasticProfileService.findProfile(elasticProfile.getId()) == null) { return; } elasticProfile.addError("id", format("Elastic profile ids should be unique. Elastic profile with id '%s' already exists.", elasticProfile.getId())); throw haltBecauseEntityAlreadyExists(jsonWriter(elasticProfile), "elasticProfile", elasticProfile.getId()); }
[ "private", "void", "haltIfEntityWithSameIdExists", "(", "ElasticProfile", "elasticProfile", ")", "{", "if", "(", "elasticProfileService", ".", "findProfile", "(", "elasticProfile", ".", "getId", "(", ")", ")", "==", "null", ")", "{", "return", ";", "}", "elasticProfile", ".", "addError", "(", "\"id\"", ",", "format", "(", "\"Elastic profile ids should be unique. Elastic profile with id '%s' already exists.\"", ",", "elasticProfile", ".", "getId", "(", ")", ")", ")", ";", "throw", "haltBecauseEntityAlreadyExists", "(", "jsonWriter", "(", "elasticProfile", ")", ",", "\"elasticProfile\"", ",", "elasticProfile", ".", "getId", "(", ")", ")", ";", "}" ]
this is done in command as well, keeping it here for early return instead of failing later during config update command.
[ "this", "is", "done", "in", "command", "as", "well", "keeping", "it", "here", "for", "early", "return", "instead", "of", "failing", "later", "during", "config", "update", "command", "." ]
59a8480e23d6c06de39127635108dff57603cb71
https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/api/api-elastic-profile-v2/src/main/java/com/thoughtworks/go/apiv2/elasticprofile/ElasticProfileControllerV2.java#L188-L195
17,642
CrawlScript/WebCollector
src/main/java/cn/edu/hfut/dmic/webcollector/example/DemoRedirectCrawler.java
DemoRedirectCrawler.createBingUrl
public static String createBingUrl(String keyword, int pageIndex) throws Exception { int first = pageIndex * 10 - 9; keyword = URLEncoder.encode(keyword, "utf-8"); return String.format("http://cn.bing.com/search?q=%s&first=%s", keyword, first); }
java
public static String createBingUrl(String keyword, int pageIndex) throws Exception { int first = pageIndex * 10 - 9; keyword = URLEncoder.encode(keyword, "utf-8"); return String.format("http://cn.bing.com/search?q=%s&first=%s", keyword, first); }
[ "public", "static", "String", "createBingUrl", "(", "String", "keyword", ",", "int", "pageIndex", ")", "throws", "Exception", "{", "int", "first", "=", "pageIndex", "*", "10", "-", "9", ";", "keyword", "=", "URLEncoder", ".", "encode", "(", "keyword", ",", "\"utf-8\"", ")", ";", "return", "String", ".", "format", "(", "\"http://cn.bing.com/search?q=%s&first=%s\"", ",", "keyword", ",", "first", ")", ";", "}" ]
construct the Bing Search url by the search keyword and the pageIndex @param keyword @param pageIndex @return the constructed url @throws Exception
[ "construct", "the", "Bing", "Search", "url", "by", "the", "search", "keyword", "and", "the", "pageIndex" ]
4ca71ec0e69d354feaf64319d76e64663159902d
https://github.com/CrawlScript/WebCollector/blob/4ca71ec0e69d354feaf64319d76e64663159902d/src/main/java/cn/edu/hfut/dmic/webcollector/example/DemoRedirectCrawler.java#L79-L83
17,643
CrawlScript/WebCollector
src/main/java/cn/edu/hfut/dmic/webcollector/crawldb/Generator.java
Generator.next
public CrawlDatum next(){ int topN = getConf().getTopN(); int maxExecuteCount = getConf().getOrDefault(Configuration.KEY_MAX_EXECUTE_COUNT, Integer.MAX_VALUE); if(topN > 0 && totalGenerate >= topN){ return null; } CrawlDatum datum; while (true) { try { datum = nextWithoutFilter(); if (datum == null) { return datum; } if(filter == null || (datum = filter.filter(datum))!=null){ if (datum.getExecuteCount() > maxExecuteCount) { continue; } totalGenerate += 1; return datum; } } catch (Exception e) { LOG.info("Exception when generating", e); return null; } } }
java
public CrawlDatum next(){ int topN = getConf().getTopN(); int maxExecuteCount = getConf().getOrDefault(Configuration.KEY_MAX_EXECUTE_COUNT, Integer.MAX_VALUE); if(topN > 0 && totalGenerate >= topN){ return null; } CrawlDatum datum; while (true) { try { datum = nextWithoutFilter(); if (datum == null) { return datum; } if(filter == null || (datum = filter.filter(datum))!=null){ if (datum.getExecuteCount() > maxExecuteCount) { continue; } totalGenerate += 1; return datum; } } catch (Exception e) { LOG.info("Exception when generating", e); return null; } } }
[ "public", "CrawlDatum", "next", "(", ")", "{", "int", "topN", "=", "getConf", "(", ")", ".", "getTopN", "(", ")", ";", "int", "maxExecuteCount", "=", "getConf", "(", ")", ".", "getOrDefault", "(", "Configuration", ".", "KEY_MAX_EXECUTE_COUNT", ",", "Integer", ".", "MAX_VALUE", ")", ";", "if", "(", "topN", ">", "0", "&&", "totalGenerate", ">=", "topN", ")", "{", "return", "null", ";", "}", "CrawlDatum", "datum", ";", "while", "(", "true", ")", "{", "try", "{", "datum", "=", "nextWithoutFilter", "(", ")", ";", "if", "(", "datum", "==", "null", ")", "{", "return", "datum", ";", "}", "if", "(", "filter", "==", "null", "||", "(", "datum", "=", "filter", ".", "filter", "(", "datum", ")", ")", "!=", "null", ")", "{", "if", "(", "datum", ".", "getExecuteCount", "(", ")", ">", "maxExecuteCount", ")", "{", "continue", ";", "}", "totalGenerate", "+=", "1", ";", "return", "datum", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "info", "(", "\"Exception when generating\"", ",", "e", ")", ";", "return", "null", ";", "}", "}", "}" ]
return null if there is no CrawlDatum to generate @return
[ "return", "null", "if", "there", "is", "no", "CrawlDatum", "to", "generate" ]
4ca71ec0e69d354feaf64319d76e64663159902d
https://github.com/CrawlScript/WebCollector/blob/4ca71ec0e69d354feaf64319d76e64663159902d/src/main/java/cn/edu/hfut/dmic/webcollector/crawldb/Generator.java#L49-L78
17,644
opensourceBIM/BIMserver
BimServer/src/org/bimserver/geometry/StreamingGeometryGenerator.java
StreamingGeometryGenerator.placement3DToMatrix
@SuppressWarnings("unchecked") public double[] placement3DToMatrix(AbstractHashMapVirtualObject ifcAxis2Placement3D) { EReference refDirectionFeature = packageMetaData.getEReference("IfcAxis2Placement3D", "RefDirection"); AbstractHashMapVirtualObject location = ifcAxis2Placement3D.getDirectFeature(packageMetaData.getEReference("IfcPlacement", "Location")); if (ifcAxis2Placement3D.getDirectFeature(packageMetaData.getEReference("IfcAxis2Placement3D", "Axis")) != null && ifcAxis2Placement3D.getDirectFeature(refDirectionFeature) != null) { AbstractHashMapVirtualObject axis = ifcAxis2Placement3D.getDirectFeature(packageMetaData.getEReference("IfcAxis2Placement3D", "Axis")); AbstractHashMapVirtualObject direction = ifcAxis2Placement3D.getDirectFeature(refDirectionFeature); List<Double> axisDirectionRatios = (List<Double>) axis.get("DirectionRatios"); List<Double> directionDirectionRatios = (List<Double>) direction.get("DirectionRatios"); List<Double> locationCoordinates = (List<Double>) location.get("Coordinates"); double[] cross = Vector.crossProduct(new double[]{axisDirectionRatios.get(0), axisDirectionRatios.get(1), axisDirectionRatios.get(2), 1}, new double[]{directionDirectionRatios.get(0), directionDirectionRatios.get(1), directionDirectionRatios.get(2), 1}); return new double[]{ directionDirectionRatios.get(0), directionDirectionRatios.get(1), directionDirectionRatios.get(2), 0, cross[0], cross[1], cross[2], 0, axisDirectionRatios.get(0), axisDirectionRatios.get(1), axisDirectionRatios.get(2), 0, locationCoordinates.get(0), locationCoordinates.get(1), locationCoordinates.get(2), 1 }; } else if (location != null) { List<Double> locationCoordinates = (List<Double>) location.get("Coordinates"); return new double[]{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, locationCoordinates.get(0), locationCoordinates.get(1), locationCoordinates.get(2), 1 }; } return Matrix.identity(); }
java
@SuppressWarnings("unchecked") public double[] placement3DToMatrix(AbstractHashMapVirtualObject ifcAxis2Placement3D) { EReference refDirectionFeature = packageMetaData.getEReference("IfcAxis2Placement3D", "RefDirection"); AbstractHashMapVirtualObject location = ifcAxis2Placement3D.getDirectFeature(packageMetaData.getEReference("IfcPlacement", "Location")); if (ifcAxis2Placement3D.getDirectFeature(packageMetaData.getEReference("IfcAxis2Placement3D", "Axis")) != null && ifcAxis2Placement3D.getDirectFeature(refDirectionFeature) != null) { AbstractHashMapVirtualObject axis = ifcAxis2Placement3D.getDirectFeature(packageMetaData.getEReference("IfcAxis2Placement3D", "Axis")); AbstractHashMapVirtualObject direction = ifcAxis2Placement3D.getDirectFeature(refDirectionFeature); List<Double> axisDirectionRatios = (List<Double>) axis.get("DirectionRatios"); List<Double> directionDirectionRatios = (List<Double>) direction.get("DirectionRatios"); List<Double> locationCoordinates = (List<Double>) location.get("Coordinates"); double[] cross = Vector.crossProduct(new double[]{axisDirectionRatios.get(0), axisDirectionRatios.get(1), axisDirectionRatios.get(2), 1}, new double[]{directionDirectionRatios.get(0), directionDirectionRatios.get(1), directionDirectionRatios.get(2), 1}); return new double[]{ directionDirectionRatios.get(0), directionDirectionRatios.get(1), directionDirectionRatios.get(2), 0, cross[0], cross[1], cross[2], 0, axisDirectionRatios.get(0), axisDirectionRatios.get(1), axisDirectionRatios.get(2), 0, locationCoordinates.get(0), locationCoordinates.get(1), locationCoordinates.get(2), 1 }; } else if (location != null) { List<Double> locationCoordinates = (List<Double>) location.get("Coordinates"); return new double[]{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, locationCoordinates.get(0), locationCoordinates.get(1), locationCoordinates.get(2), 1 }; } return Matrix.identity(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "double", "[", "]", "placement3DToMatrix", "(", "AbstractHashMapVirtualObject", "ifcAxis2Placement3D", ")", "{", "EReference", "refDirectionFeature", "=", "packageMetaData", ".", "getEReference", "(", "\"IfcAxis2Placement3D\"", ",", "\"RefDirection\"", ")", ";", "AbstractHashMapVirtualObject", "location", "=", "ifcAxis2Placement3D", ".", "getDirectFeature", "(", "packageMetaData", ".", "getEReference", "(", "\"IfcPlacement\"", ",", "\"Location\"", ")", ")", ";", "if", "(", "ifcAxis2Placement3D", ".", "getDirectFeature", "(", "packageMetaData", ".", "getEReference", "(", "\"IfcAxis2Placement3D\"", ",", "\"Axis\"", ")", ")", "!=", "null", "&&", "ifcAxis2Placement3D", ".", "getDirectFeature", "(", "refDirectionFeature", ")", "!=", "null", ")", "{", "AbstractHashMapVirtualObject", "axis", "=", "ifcAxis2Placement3D", ".", "getDirectFeature", "(", "packageMetaData", ".", "getEReference", "(", "\"IfcAxis2Placement3D\"", ",", "\"Axis\"", ")", ")", ";", "AbstractHashMapVirtualObject", "direction", "=", "ifcAxis2Placement3D", ".", "getDirectFeature", "(", "refDirectionFeature", ")", ";", "List", "<", "Double", ">", "axisDirectionRatios", "=", "(", "List", "<", "Double", ">", ")", "axis", ".", "get", "(", "\"DirectionRatios\"", ")", ";", "List", "<", "Double", ">", "directionDirectionRatios", "=", "(", "List", "<", "Double", ">", ")", "direction", ".", "get", "(", "\"DirectionRatios\"", ")", ";", "List", "<", "Double", ">", "locationCoordinates", "=", "(", "List", "<", "Double", ">", ")", "location", ".", "get", "(", "\"Coordinates\"", ")", ";", "double", "[", "]", "cross", "=", "Vector", ".", "crossProduct", "(", "new", "double", "[", "]", "{", "axisDirectionRatios", ".", "get", "(", "0", ")", ",", "axisDirectionRatios", ".", "get", "(", "1", ")", ",", "axisDirectionRatios", ".", "get", "(", "2", ")", ",", "1", "}", ",", "new", "double", "[", "]", "{", "directionDirectionRatios", ".", "get", "(", "0", ")", ",", "directionDirectionRatios", ".", "get", "(", "1", ")", ",", "directionDirectionRatios", ".", "get", "(", "2", ")", ",", "1", "}", ")", ";", "return", "new", "double", "[", "]", "{", "directionDirectionRatios", ".", "get", "(", "0", ")", ",", "directionDirectionRatios", ".", "get", "(", "1", ")", ",", "directionDirectionRatios", ".", "get", "(", "2", ")", ",", "0", ",", "cross", "[", "0", "]", ",", "cross", "[", "1", "]", ",", "cross", "[", "2", "]", ",", "0", ",", "axisDirectionRatios", ".", "get", "(", "0", ")", ",", "axisDirectionRatios", ".", "get", "(", "1", ")", ",", "axisDirectionRatios", ".", "get", "(", "2", ")", ",", "0", ",", "locationCoordinates", ".", "get", "(", "0", ")", ",", "locationCoordinates", ".", "get", "(", "1", ")", ",", "locationCoordinates", ".", "get", "(", "2", ")", ",", "1", "}", ";", "}", "else", "if", "(", "location", "!=", "null", ")", "{", "List", "<", "Double", ">", "locationCoordinates", "=", "(", "List", "<", "Double", ">", ")", "location", ".", "get", "(", "\"Coordinates\"", ")", ";", "return", "new", "double", "[", "]", "{", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "1", ",", "0", ",", "locationCoordinates", ".", "get", "(", "0", ")", ",", "locationCoordinates", ".", "get", "(", "1", ")", ",", "locationCoordinates", ".", "get", "(", "2", ")", ",", "1", "}", ";", "}", "return", "Matrix", ".", "identity", "(", ")", ";", "}" ]
Pretty sure this is working correctly
[ "Pretty", "sure", "this", "is", "working", "correctly" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/BimServer/src/org/bimserver/geometry/StreamingGeometryGenerator.java#L804-L832
17,645
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Vector.java
Vector.length
public static float length(float[] u){ return (float) Math.abs(Math.sqrt((u[X] *u[X]) + (u[Y] *u[Y]) + (u[Z] *u[Z]))); }
java
public static float length(float[] u){ return (float) Math.abs(Math.sqrt((u[X] *u[X]) + (u[Y] *u[Y]) + (u[Z] *u[Z]))); }
[ "public", "static", "float", "length", "(", "float", "[", "]", "u", ")", "{", "return", "(", "float", ")", "Math", ".", "abs", "(", "Math", ".", "sqrt", "(", "(", "u", "[", "X", "]", "*", "u", "[", "X", "]", ")", "+", "(", "u", "[", "Y", "]", "*", "u", "[", "Y", "]", ")", "+", "(", "u", "[", "Z", "]", "*", "u", "[", "Z", "]", ")", ")", ")", ";", "}" ]
mangnatude or length
[ "mangnatude", "or", "length" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Vector.java#L78-L80
17,646
opensourceBIM/BIMserver
BimServer/src/org/bimserver/GenericGeometryGenerator.java
GenericGeometryGenerator.getPlaneAngle
private static double getPlaneAngle(float[] v1, float[] v2, float[] v3, float[] u1, float[] u2, float[] u3) { float[] cross1 = Vector.crossProduct(new float[] { v2[0] - v1[0], v2[1] - v1[1], v2[2] - v1[2] }, new float[] { v3[0] - v1[0], v3[1] - v1[1], v3[2] - v1[2] }); float[] cross2 = Vector.crossProduct(new float[] { u2[0] - u1[0], u2[1] - u1[1], u2[2] - u1[2] }, new float[] { u3[0] - u1[0], u3[1] - u1[1], u3[2] - u1[2] }); float num = Vector.dot(cross1, cross2); float den = Vector.length(cross1) * Vector.length(cross2); float a = num / den; if (a > 1) { a = 1; } if (a < -1) { a = -1; } double result = Math.acos(a); return result; }
java
private static double getPlaneAngle(float[] v1, float[] v2, float[] v3, float[] u1, float[] u2, float[] u3) { float[] cross1 = Vector.crossProduct(new float[] { v2[0] - v1[0], v2[1] - v1[1], v2[2] - v1[2] }, new float[] { v3[0] - v1[0], v3[1] - v1[1], v3[2] - v1[2] }); float[] cross2 = Vector.crossProduct(new float[] { u2[0] - u1[0], u2[1] - u1[1], u2[2] - u1[2] }, new float[] { u3[0] - u1[0], u3[1] - u1[1], u3[2] - u1[2] }); float num = Vector.dot(cross1, cross2); float den = Vector.length(cross1) * Vector.length(cross2); float a = num / den; if (a > 1) { a = 1; } if (a < -1) { a = -1; } double result = Math.acos(a); return result; }
[ "private", "static", "double", "getPlaneAngle", "(", "float", "[", "]", "v1", ",", "float", "[", "]", "v2", ",", "float", "[", "]", "v3", ",", "float", "[", "]", "u1", ",", "float", "[", "]", "u2", ",", "float", "[", "]", "u3", ")", "{", "float", "[", "]", "cross1", "=", "Vector", ".", "crossProduct", "(", "new", "float", "[", "]", "{", "v2", "[", "0", "]", "-", "v1", "[", "0", "]", ",", "v2", "[", "1", "]", "-", "v1", "[", "1", "]", ",", "v2", "[", "2", "]", "-", "v1", "[", "2", "]", "}", ",", "new", "float", "[", "]", "{", "v3", "[", "0", "]", "-", "v1", "[", "0", "]", ",", "v3", "[", "1", "]", "-", "v1", "[", "1", "]", ",", "v3", "[", "2", "]", "-", "v1", "[", "2", "]", "}", ")", ";", "float", "[", "]", "cross2", "=", "Vector", ".", "crossProduct", "(", "new", "float", "[", "]", "{", "u2", "[", "0", "]", "-", "u1", "[", "0", "]", ",", "u2", "[", "1", "]", "-", "u1", "[", "1", "]", ",", "u2", "[", "2", "]", "-", "u1", "[", "2", "]", "}", ",", "new", "float", "[", "]", "{", "u3", "[", "0", "]", "-", "u1", "[", "0", "]", ",", "u3", "[", "1", "]", "-", "u1", "[", "1", "]", ",", "u3", "[", "2", "]", "-", "u1", "[", "2", "]", "}", ")", ";", "float", "num", "=", "Vector", ".", "dot", "(", "cross1", ",", "cross2", ")", ";", "float", "den", "=", "Vector", ".", "length", "(", "cross1", ")", "*", "Vector", ".", "length", "(", "cross2", ")", ";", "float", "a", "=", "num", "/", "den", ";", "if", "(", "a", ">", "1", ")", "{", "a", "=", "1", ";", "}", "if", "(", "a", "<", "-", "1", ")", "{", "a", "=", "-", "1", ";", "}", "double", "result", "=", "Math", ".", "acos", "(", "a", ")", ";", "return", "result", ";", "}" ]
Get the angle in radians between two planes @param v1 @param v2 @param v3 @param u1 @param u2 @param u3 @return
[ "Get", "the", "angle", "in", "radians", "between", "two", "planes" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/BimServer/src/org/bimserver/GenericGeometryGenerator.java#L162-L179
17,647
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/utils/RichIfcModel.java
RichIfcModel.addDecomposes
public void addDecomposes(IfcObjectDefinition parent, IfcObjectDefinition... children) throws IfcModelInterfaceException { IfcRelAggregates ifcRelAggregates = this.create(IfcRelAggregates.class); ifcRelAggregates.setRelatingObject(parent); for (IfcObjectDefinition child: children) { ifcRelAggregates.getRelatedObjects().add(child); } }
java
public void addDecomposes(IfcObjectDefinition parent, IfcObjectDefinition... children) throws IfcModelInterfaceException { IfcRelAggregates ifcRelAggregates = this.create(IfcRelAggregates.class); ifcRelAggregates.setRelatingObject(parent); for (IfcObjectDefinition child: children) { ifcRelAggregates.getRelatedObjects().add(child); } }
[ "public", "void", "addDecomposes", "(", "IfcObjectDefinition", "parent", ",", "IfcObjectDefinition", "...", "children", ")", "throws", "IfcModelInterfaceException", "{", "IfcRelAggregates", "ifcRelAggregates", "=", "this", ".", "create", "(", "IfcRelAggregates", ".", "class", ")", ";", "ifcRelAggregates", ".", "setRelatingObject", "(", "parent", ")", ";", "for", "(", "IfcObjectDefinition", "child", ":", "children", ")", "{", "ifcRelAggregates", ".", "getRelatedObjects", "(", ")", ".", "add", "(", "child", ")", ";", "}", "}" ]
Create a decomposes relationship @param parent The object that represents the nest or aggregation @param child The objects being nested or aggregated @throws IfcModelInterfaceException
[ "Create", "a", "decomposes", "relationship" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/utils/RichIfcModel.java#L78-L84
17,648
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/meta/SServicesMap.java
SServicesMap.findMethod
public SMethod findMethod(String methodName) { for (SService sService : servicesByName.values()) { SMethod method = sService.getSMethod(methodName); if (method != null) { return method; } } return null; }
java
public SMethod findMethod(String methodName) { for (SService sService : servicesByName.values()) { SMethod method = sService.getSMethod(methodName); if (method != null) { return method; } } return null; }
[ "public", "SMethod", "findMethod", "(", "String", "methodName", ")", "{", "for", "(", "SService", "sService", ":", "servicesByName", ".", "values", "(", ")", ")", "{", "SMethod", "method", "=", "sService", ".", "getSMethod", "(", "methodName", ")", ";", "if", "(", "method", "!=", "null", ")", "{", "return", "method", ";", "}", "}", "return", "null", ";", "}" ]
Inefficient method of getting a SMethod @param methodName @return
[ "Inefficient", "method", "of", "getting", "a", "SMethod" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/meta/SServicesMap.java#L229-L237
17,649
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/database/queries/om/Include.java
Include.addField
public void addField(String fieldName) throws QueryException { EReference feature = null; for (TypeDef typeDef : types) { if (typeDef.geteClass().getEStructuralFeature(fieldName) == null) { throw new QueryException("Class \"" + typeDef.geteClass().getName() + "\" does not have the field \"" + fieldName + "\""); } if (feature == null) { if (!(typeDef.geteClass().getEStructuralFeature(fieldName) instanceof EReference)) { throw new QueryException(fieldName + " is not a reference"); } feature = (EReference) typeDef.geteClass().getEStructuralFeature(fieldName); } else { if (feature != typeDef.geteClass().getEStructuralFeature(fieldName)) { throw new QueryException("Classes \"" + typeDef.geteClass().getName() + "\" and \"" + feature.getEContainingClass().getName() + "\" have fields with the same name, but they are not logically the same"); } } } if (fields == null) { fields = new ArrayList<>(); } fields.add(feature); }
java
public void addField(String fieldName) throws QueryException { EReference feature = null; for (TypeDef typeDef : types) { if (typeDef.geteClass().getEStructuralFeature(fieldName) == null) { throw new QueryException("Class \"" + typeDef.geteClass().getName() + "\" does not have the field \"" + fieldName + "\""); } if (feature == null) { if (!(typeDef.geteClass().getEStructuralFeature(fieldName) instanceof EReference)) { throw new QueryException(fieldName + " is not a reference"); } feature = (EReference) typeDef.geteClass().getEStructuralFeature(fieldName); } else { if (feature != typeDef.geteClass().getEStructuralFeature(fieldName)) { throw new QueryException("Classes \"" + typeDef.geteClass().getName() + "\" and \"" + feature.getEContainingClass().getName() + "\" have fields with the same name, but they are not logically the same"); } } } if (fields == null) { fields = new ArrayList<>(); } fields.add(feature); }
[ "public", "void", "addField", "(", "String", "fieldName", ")", "throws", "QueryException", "{", "EReference", "feature", "=", "null", ";", "for", "(", "TypeDef", "typeDef", ":", "types", ")", "{", "if", "(", "typeDef", ".", "geteClass", "(", ")", ".", "getEStructuralFeature", "(", "fieldName", ")", "==", "null", ")", "{", "throw", "new", "QueryException", "(", "\"Class \\\"\"", "+", "typeDef", ".", "geteClass", "(", ")", ".", "getName", "(", ")", "+", "\"\\\" does not have the field \\\"\"", "+", "fieldName", "+", "\"\\\"\"", ")", ";", "}", "if", "(", "feature", "==", "null", ")", "{", "if", "(", "!", "(", "typeDef", ".", "geteClass", "(", ")", ".", "getEStructuralFeature", "(", "fieldName", ")", "instanceof", "EReference", ")", ")", "{", "throw", "new", "QueryException", "(", "fieldName", "+", "\" is not a reference\"", ")", ";", "}", "feature", "=", "(", "EReference", ")", "typeDef", ".", "geteClass", "(", ")", ".", "getEStructuralFeature", "(", "fieldName", ")", ";", "}", "else", "{", "if", "(", "feature", "!=", "typeDef", ".", "geteClass", "(", ")", ".", "getEStructuralFeature", "(", "fieldName", ")", ")", "{", "throw", "new", "QueryException", "(", "\"Classes \\\"\"", "+", "typeDef", ".", "geteClass", "(", ")", ".", "getName", "(", ")", "+", "\"\\\" and \\\"\"", "+", "feature", ".", "getEContainingClass", "(", ")", ".", "getName", "(", ")", "+", "\"\\\" have fields with the same name, but they are not logically the same\"", ")", ";", "}", "}", "}", "if", "(", "fields", "==", "null", ")", "{", "fields", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "fields", ".", "add", "(", "feature", ")", ";", "}" ]
Add the fields _after_ adding the types, because the fields will be checked against the types, all types should have the given field. @param fieldName @throws QueryException
[ "Add", "the", "fields", "_after_", "adding", "the", "types", "because", "the", "fields", "will", "be", "checked", "against", "the", "types", "all", "types", "should", "have", "the", "given", "field", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/database/queries/om/Include.java#L88-L109
17,650
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.getNewIfcGloballyUniqueId
public static String getNewIfcGloballyUniqueId(){ Guid guid = getGuidFromUncompressedString(UUID.randomUUID().toString()); String shortString = getCompressedStringFromGuid(guid); return shortString; }
java
public static String getNewIfcGloballyUniqueId(){ Guid guid = getGuidFromUncompressedString(UUID.randomUUID().toString()); String shortString = getCompressedStringFromGuid(guid); return shortString; }
[ "public", "static", "String", "getNewIfcGloballyUniqueId", "(", ")", "{", "Guid", "guid", "=", "getGuidFromUncompressedString", "(", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ")", ";", "String", "shortString", "=", "getCompressedStringFromGuid", "(", "guid", ")", ";", "return", "shortString", ";", "}" ]
Generates a new GUID and returns a compressed string representation as used for IfcGloballyUniqueId @return String with a length of 22 characters
[ "Generates", "a", "new", "GUID", "and", "returns", "a", "compressed", "string", "representation", "as", "used", "for", "IfcGloballyUniqueId" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L58-L62
17,651
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.getGuidFromUncompressedString
public static Guid getGuidFromUncompressedString(String uncompressedGuidString){ String[] parts = uncompressedGuidString.split("-"); Guid guid = new Guid(); guid.Data1 = Long.parseLong(parts[0], 16); guid.Data2 = Integer.parseInt(parts[1],16); guid.Data3 = Integer.parseInt(parts[2], 16); String temp; temp = parts[3]; guid.Data4[0] = (char) Integer.parseInt(temp.substring(0, 2), 16); guid.Data4[1] = (char) Integer.parseInt(temp.substring(2, 4), 16); temp = parts[4]; guid.Data4[2] = (char) Integer.parseInt(temp.substring(0, 2), 16); guid.Data4[3] = (char) Integer.parseInt(temp.substring(2, 4), 16); guid.Data4[4] = (char) Integer.parseInt(temp.substring(4, 6), 16); guid.Data4[5] = (char) Integer.parseInt(temp.substring(6, 8), 16); guid.Data4[6] = (char) Integer.parseInt(temp.substring(8, 10), 16); guid.Data4[7] = (char) Integer.parseInt(temp.substring(10, 12), 16); return guid; }
java
public static Guid getGuidFromUncompressedString(String uncompressedGuidString){ String[] parts = uncompressedGuidString.split("-"); Guid guid = new Guid(); guid.Data1 = Long.parseLong(parts[0], 16); guid.Data2 = Integer.parseInt(parts[1],16); guid.Data3 = Integer.parseInt(parts[2], 16); String temp; temp = parts[3]; guid.Data4[0] = (char) Integer.parseInt(temp.substring(0, 2), 16); guid.Data4[1] = (char) Integer.parseInt(temp.substring(2, 4), 16); temp = parts[4]; guid.Data4[2] = (char) Integer.parseInt(temp.substring(0, 2), 16); guid.Data4[3] = (char) Integer.parseInt(temp.substring(2, 4), 16); guid.Data4[4] = (char) Integer.parseInt(temp.substring(4, 6), 16); guid.Data4[5] = (char) Integer.parseInt(temp.substring(6, 8), 16); guid.Data4[6] = (char) Integer.parseInt(temp.substring(8, 10), 16); guid.Data4[7] = (char) Integer.parseInt(temp.substring(10, 12), 16); return guid; }
[ "public", "static", "Guid", "getGuidFromUncompressedString", "(", "String", "uncompressedGuidString", ")", "{", "String", "[", "]", "parts", "=", "uncompressedGuidString", ".", "split", "(", "\"-\"", ")", ";", "Guid", "guid", "=", "new", "Guid", "(", ")", ";", "guid", ".", "Data1", "=", "Long", ".", "parseLong", "(", "parts", "[", "0", "]", ",", "16", ")", ";", "guid", ".", "Data2", "=", "Integer", ".", "parseInt", "(", "parts", "[", "1", "]", ",", "16", ")", ";", "guid", ".", "Data3", "=", "Integer", ".", "parseInt", "(", "parts", "[", "2", "]", ",", "16", ")", ";", "String", "temp", ";", "temp", "=", "parts", "[", "3", "]", ";", "guid", ".", "Data4", "[", "0", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "0", ",", "2", ")", ",", "16", ")", ";", "guid", ".", "Data4", "[", "1", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "2", ",", "4", ")", ",", "16", ")", ";", "temp", "=", "parts", "[", "4", "]", ";", "guid", ".", "Data4", "[", "2", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "0", ",", "2", ")", ",", "16", ")", ";", "guid", ".", "Data4", "[", "3", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "2", ",", "4", ")", ",", "16", ")", ";", "guid", ".", "Data4", "[", "4", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "4", ",", "6", ")", ",", "16", ")", ";", "guid", ".", "Data4", "[", "5", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "6", ",", "8", ")", ",", "16", ")", ";", "guid", ".", "Data4", "[", "6", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "8", ",", "10", ")", ",", "16", ")", ";", "guid", ".", "Data4", "[", "7", "]", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "temp", ".", "substring", "(", "10", ",", "12", ")", ",", "16", ")", ";", "return", "guid", ";", "}" ]
Converts an uncompressed String representation in an Guid-object @param uncompressedGuidString the uncompressed String representation of a GUID @return an Guid-object
[ "Converts", "an", "uncompressed", "String", "representation", "in", "an", "Guid", "-", "object" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L69-L91
17,652
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.getCompressedStringFromGuid
public static String getCompressedStringFromGuid(Guid guid) { long[] num = new long[6]; char[][] str = new char[6][5]; int i,j,n; String result = new String(); // // Creation of six 32 Bit integers from the components of the GUID structure // num[0] = (long)(guid.Data1 / 16777216); // 16. byte (pGuid->Data1 / 16777216) is the same as (pGuid->Data1 >> 24) num[1] = (long)(guid.Data1 % 16777216); // 15-13. bytes (pGuid->Data1 % 16777216) is the same as (pGuid->Data1 & 0xFFFFFF) num[2] = (long)(guid.Data2 * 256 + guid.Data3 / 256); // 12-10. bytes num[3] = (long)((guid.Data3 % 256) * 65536 + guid.Data4[0] * 256 + guid.Data4[1]); // 09-07. bytes num[4] = (long)(guid.Data4[2] * 65536 + guid.Data4[3] * 256 + guid.Data4[4]); // 06-04. bytes num[5] = (long)(guid.Data4[5] * 65536 + guid.Data4[6] * 256 + guid.Data4[7]); // 03-01. bytes // // Conversion of the numbers into a system using a base of 64 // n = 3; for (i = 0; i < 6; i++) { if (!cv_to_64 (num[i], str[i], n)) { return null; } for(j = 0; j<str[i].length; j++) if(str[i][j]!= '\0') result += str[i][j]; n = 5; } return result; }
java
public static String getCompressedStringFromGuid(Guid guid) { long[] num = new long[6]; char[][] str = new char[6][5]; int i,j,n; String result = new String(); // // Creation of six 32 Bit integers from the components of the GUID structure // num[0] = (long)(guid.Data1 / 16777216); // 16. byte (pGuid->Data1 / 16777216) is the same as (pGuid->Data1 >> 24) num[1] = (long)(guid.Data1 % 16777216); // 15-13. bytes (pGuid->Data1 % 16777216) is the same as (pGuid->Data1 & 0xFFFFFF) num[2] = (long)(guid.Data2 * 256 + guid.Data3 / 256); // 12-10. bytes num[3] = (long)((guid.Data3 % 256) * 65536 + guid.Data4[0] * 256 + guid.Data4[1]); // 09-07. bytes num[4] = (long)(guid.Data4[2] * 65536 + guid.Data4[3] * 256 + guid.Data4[4]); // 06-04. bytes num[5] = (long)(guid.Data4[5] * 65536 + guid.Data4[6] * 256 + guid.Data4[7]); // 03-01. bytes // // Conversion of the numbers into a system using a base of 64 // n = 3; for (i = 0; i < 6; i++) { if (!cv_to_64 (num[i], str[i], n)) { return null; } for(j = 0; j<str[i].length; j++) if(str[i][j]!= '\0') result += str[i][j]; n = 5; } return result; }
[ "public", "static", "String", "getCompressedStringFromGuid", "(", "Guid", "guid", ")", "{", "long", "[", "]", "num", "=", "new", "long", "[", "6", "]", ";", "char", "[", "]", "[", "]", "str", "=", "new", "char", "[", "6", "]", "[", "5", "]", ";", "int", "i", ",", "j", ",", "n", ";", "String", "result", "=", "new", "String", "(", ")", ";", "//", "// Creation of six 32 Bit integers from the components of the GUID structure", "//", "num", "[", "0", "]", "=", "(", "long", ")", "(", "guid", ".", "Data1", "/", "16777216", ")", ";", "// 16. byte (pGuid->Data1 / 16777216) is the same as (pGuid->Data1 >> 24)", "num", "[", "1", "]", "=", "(", "long", ")", "(", "guid", ".", "Data1", "%", "16777216", ")", ";", "// 15-13. bytes (pGuid->Data1 % 16777216) is the same as (pGuid->Data1 & 0xFFFFFF)", "num", "[", "2", "]", "=", "(", "long", ")", "(", "guid", ".", "Data2", "*", "256", "+", "guid", ".", "Data3", "/", "256", ")", ";", "// 12-10. bytes", "num", "[", "3", "]", "=", "(", "long", ")", "(", "(", "guid", ".", "Data3", "%", "256", ")", "*", "65536", "+", "guid", ".", "Data4", "[", "0", "]", "*", "256", "+", "guid", ".", "Data4", "[", "1", "]", ")", ";", "// 09-07. bytes", "num", "[", "4", "]", "=", "(", "long", ")", "(", "guid", ".", "Data4", "[", "2", "]", "*", "65536", "+", "guid", ".", "Data4", "[", "3", "]", "*", "256", "+", "guid", ".", "Data4", "[", "4", "]", ")", ";", "// 06-04. bytes", "num", "[", "5", "]", "=", "(", "long", ")", "(", "guid", ".", "Data4", "[", "5", "]", "*", "65536", "+", "guid", ".", "Data4", "[", "6", "]", "*", "256", "+", "guid", ".", "Data4", "[", "7", "]", ")", ";", "// 03-01. bytes", "//", "// Conversion of the numbers into a system using a base of 64", "//", "n", "=", "3", ";", "for", "(", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "if", "(", "!", "cv_to_64", "(", "num", "[", "i", "]", ",", "str", "[", "i", "]", ",", "n", ")", ")", "{", "return", "null", ";", "}", "for", "(", "j", "=", "0", ";", "j", "<", "str", "[", "i", "]", ".", "length", ";", "j", "++", ")", "if", "(", "str", "[", "i", "]", "[", "j", "]", "!=", "'", "'", ")", "result", "+=", "str", "[", "i", "]", "[", "j", "]", ";", "n", "=", "5", ";", "}", "return", "result", ";", "}" ]
Converts a Guid-object into a compressed string representation of a GUID @param guid the Guid-object @return String with a length of 22 characters
[ "Converts", "a", "Guid", "-", "object", "into", "a", "compressed", "string", "representation", "of", "a", "GUID" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L98-L128
17,653
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.cv_to_64
private static boolean cv_to_64(long number, char[] code, int len ) { long act; int iDigit, nDigits; char[] result = new char[5]; if (len > 5) return false; act = number; nDigits = len - 1; for (iDigit = 0; iDigit < nDigits; iDigit++) { result[nDigits - iDigit - 1] = cConversionTable[(int) (act % 64)]; act /= 64; } result[len - 1] = '\0'; if (act != 0) return false; for(int i = 0; i<result.length; i++) code[i] = result[i]; return true; }
java
private static boolean cv_to_64(long number, char[] code, int len ) { long act; int iDigit, nDigits; char[] result = new char[5]; if (len > 5) return false; act = number; nDigits = len - 1; for (iDigit = 0; iDigit < nDigits; iDigit++) { result[nDigits - iDigit - 1] = cConversionTable[(int) (act % 64)]; act /= 64; } result[len - 1] = '\0'; if (act != 0) return false; for(int i = 0; i<result.length; i++) code[i] = result[i]; return true; }
[ "private", "static", "boolean", "cv_to_64", "(", "long", "number", ",", "char", "[", "]", "code", ",", "int", "len", ")", "{", "long", "act", ";", "int", "iDigit", ",", "nDigits", ";", "char", "[", "]", "result", "=", "new", "char", "[", "5", "]", ";", "if", "(", "len", ">", "5", ")", "return", "false", ";", "act", "=", "number", ";", "nDigits", "=", "len", "-", "1", ";", "for", "(", "iDigit", "=", "0", ";", "iDigit", "<", "nDigits", ";", "iDigit", "++", ")", "{", "result", "[", "nDigits", "-", "iDigit", "-", "1", "]", "=", "cConversionTable", "[", "(", "int", ")", "(", "act", "%", "64", ")", "]", ";", "act", "/=", "64", ";", "}", "result", "[", "len", "-", "1", "]", "=", "'", "'", ";", "if", "(", "act", "!=", "0", ")", "return", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "code", "[", "i", "]", "=", "result", "[", "i", "]", ";", "return", "true", ";", "}" ]
Conversion of an integer into a number with base 64 using the table cConversionTable @param number @param code @param len @return true if no error occurred
[ "Conversion", "of", "an", "integer", "into", "a", "number", "with", "base", "64", "using", "the", "table", "cConversionTable" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L139-L164
17,654
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.cv_from_64
private static boolean cv_from_64(long[] res, char[] str ) { int len, i, j, index; for(len = 1; len<5; len++) if(str[len]=='\0') break; res[0]=0; for (i = 0; i < len; i++) { index = -1; for (j = 0; j < 64; j++) { if (cConversionTable[j] == str[i]) { index = j; break; } } if (index == -1) return false; res[0] = res[0] * 64 + index; } return true; }
java
private static boolean cv_from_64(long[] res, char[] str ) { int len, i, j, index; for(len = 1; len<5; len++) if(str[len]=='\0') break; res[0]=0; for (i = 0; i < len; i++) { index = -1; for (j = 0; j < 64; j++) { if (cConversionTable[j] == str[i]) { index = j; break; } } if (index == -1) return false; res[0] = res[0] * 64 + index; } return true; }
[ "private", "static", "boolean", "cv_from_64", "(", "long", "[", "]", "res", ",", "char", "[", "]", "str", ")", "{", "int", "len", ",", "i", ",", "j", ",", "index", ";", "for", "(", "len", "=", "1", ";", "len", "<", "5", ";", "len", "++", ")", "if", "(", "str", "[", "len", "]", "==", "'", "'", ")", "break", ";", "res", "[", "0", "]", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "index", "=", "-", "1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "64", ";", "j", "++", ")", "{", "if", "(", "cConversionTable", "[", "j", "]", "==", "str", "[", "i", "]", ")", "{", "index", "=", "j", ";", "break", ";", "}", "}", "if", "(", "index", "==", "-", "1", ")", "return", "false", ";", "res", "[", "0", "]", "=", "res", "[", "0", "]", "*", "64", "+", "index", ";", "}", "return", "true", ";", "}" ]
Calculate a numberer from the code @param res @param str @return true if no error occurred
[ "Calculate", "a", "numberer", "from", "the", "code" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L172-L194
17,655
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.getGuidFromCompressedString
public static boolean getGuidFromCompressedString(String string, Guid guid) throws InvalidGuidException { char[][] str = new char[6][5]; int len, i, j, m; long[][] num = new long[6][1]; len = string.length(); if (len != 22) throw new InvalidGuidException(string, "Length must be 22 (is: " + string.length() + ")"); j = 0; m = 2; for (i = 0; i < 6; i++) { for(int k = 0; k<m; k++){ str[i][k] = string.charAt(j+k); } str[i][m]= '\0'; j = j + m; m = 4; } for (i = 0; i < 6; i++) { if (!cv_from_64 (num[i], str[i])) { throw new InvalidGuidException(string); } } guid.Data1= (long) (num[0][0] * 16777216 + num[1][0]); // 16-13. bytes guid.Data2= (int) (num[2][0] / 256); // 12-11. bytes guid.Data3= (int) ((num[2][0] % 256) * 256 + num[3][0] / 65536); // 10-09. bytes guid.Data4[0] = (char) ((num[3][0] / 256) % 256); // 08. byte guid.Data4[1] = (char) (num[3][0] % 256); // 07. byte guid.Data4[2] = (char) (num[4][0] / 65536); // 06. byte guid.Data4[3] = (char) ((num[4][0] / 256) % 256); // 05. byte guid.Data4[4] = (char) (num[4][0] % 256); // 04. byte guid.Data4[5] = (char) (num[5][0] / 65536); // 03. byte guid.Data4[6] = (char) ((num[5][0] / 256) % 256); // 02. byte guid.Data4[7] = (char) (num[5][0] % 256); // 01. byte return true; }
java
public static boolean getGuidFromCompressedString(String string, Guid guid) throws InvalidGuidException { char[][] str = new char[6][5]; int len, i, j, m; long[][] num = new long[6][1]; len = string.length(); if (len != 22) throw new InvalidGuidException(string, "Length must be 22 (is: " + string.length() + ")"); j = 0; m = 2; for (i = 0; i < 6; i++) { for(int k = 0; k<m; k++){ str[i][k] = string.charAt(j+k); } str[i][m]= '\0'; j = j + m; m = 4; } for (i = 0; i < 6; i++) { if (!cv_from_64 (num[i], str[i])) { throw new InvalidGuidException(string); } } guid.Data1= (long) (num[0][0] * 16777216 + num[1][0]); // 16-13. bytes guid.Data2= (int) (num[2][0] / 256); // 12-11. bytes guid.Data3= (int) ((num[2][0] % 256) * 256 + num[3][0] / 65536); // 10-09. bytes guid.Data4[0] = (char) ((num[3][0] / 256) % 256); // 08. byte guid.Data4[1] = (char) (num[3][0] % 256); // 07. byte guid.Data4[2] = (char) (num[4][0] / 65536); // 06. byte guid.Data4[3] = (char) ((num[4][0] / 256) % 256); // 05. byte guid.Data4[4] = (char) (num[4][0] % 256); // 04. byte guid.Data4[5] = (char) (num[5][0] / 65536); // 03. byte guid.Data4[6] = (char) ((num[5][0] / 256) % 256); // 02. byte guid.Data4[7] = (char) (num[5][0] % 256); // 01. byte return true; }
[ "public", "static", "boolean", "getGuidFromCompressedString", "(", "String", "string", ",", "Guid", "guid", ")", "throws", "InvalidGuidException", "{", "char", "[", "]", "[", "]", "str", "=", "new", "char", "[", "6", "]", "[", "5", "]", ";", "int", "len", ",", "i", ",", "j", ",", "m", ";", "long", "[", "]", "[", "]", "num", "=", "new", "long", "[", "6", "]", "[", "1", "]", ";", "len", "=", "string", ".", "length", "(", ")", ";", "if", "(", "len", "!=", "22", ")", "throw", "new", "InvalidGuidException", "(", "string", ",", "\"Length must be 22 (is: \"", "+", "string", ".", "length", "(", ")", "+", "\")\"", ")", ";", "j", "=", "0", ";", "m", "=", "2", ";", "for", "(", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "for", "(", "int", "k", "=", "0", ";", "k", "<", "m", ";", "k", "++", ")", "{", "str", "[", "i", "]", "[", "k", "]", "=", "string", ".", "charAt", "(", "j", "+", "k", ")", ";", "}", "str", "[", "i", "]", "[", "m", "]", "=", "'", "'", ";", "j", "=", "j", "+", "m", ";", "m", "=", "4", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "if", "(", "!", "cv_from_64", "(", "num", "[", "i", "]", ",", "str", "[", "i", "]", ")", ")", "{", "throw", "new", "InvalidGuidException", "(", "string", ")", ";", "}", "}", "guid", ".", "Data1", "=", "(", "long", ")", "(", "num", "[", "0", "]", "[", "0", "]", "*", "16777216", "+", "num", "[", "1", "]", "[", "0", "]", ")", ";", "// 16-13. bytes", "guid", ".", "Data2", "=", "(", "int", ")", "(", "num", "[", "2", "]", "[", "0", "]", "/", "256", ")", ";", "// 12-11. bytes", "guid", ".", "Data3", "=", "(", "int", ")", "(", "(", "num", "[", "2", "]", "[", "0", "]", "%", "256", ")", "*", "256", "+", "num", "[", "3", "]", "[", "0", "]", "/", "65536", ")", ";", "// 10-09. bytes", "guid", ".", "Data4", "[", "0", "]", "=", "(", "char", ")", "(", "(", "num", "[", "3", "]", "[", "0", "]", "/", "256", ")", "%", "256", ")", ";", "// 08. byte", "guid", ".", "Data4", "[", "1", "]", "=", "(", "char", ")", "(", "num", "[", "3", "]", "[", "0", "]", "%", "256", ")", ";", "// 07. byte", "guid", ".", "Data4", "[", "2", "]", "=", "(", "char", ")", "(", "num", "[", "4", "]", "[", "0", "]", "/", "65536", ")", ";", "// 06. byte", "guid", ".", "Data4", "[", "3", "]", "=", "(", "char", ")", "(", "(", "num", "[", "4", "]", "[", "0", "]", "/", "256", ")", "%", "256", ")", ";", "// 05. byte", "guid", ".", "Data4", "[", "4", "]", "=", "(", "char", ")", "(", "num", "[", "4", "]", "[", "0", "]", "%", "256", ")", ";", "// 04. byte", "guid", ".", "Data4", "[", "5", "]", "=", "(", "char", ")", "(", "num", "[", "5", "]", "[", "0", "]", "/", "65536", ")", ";", "// 03. byte", "guid", ".", "Data4", "[", "6", "]", "=", "(", "char", ")", "(", "(", "num", "[", "5", "]", "[", "0", "]", "/", "256", ")", "%", "256", ")", ";", "// 02. byte", "guid", ".", "Data4", "[", "7", "]", "=", "(", "char", ")", "(", "num", "[", "5", "]", "[", "0", "]", "%", "256", ")", ";", "// 01. byte", "return", "true", ";", "}" ]
Reconstructs a Guid-object form an compressed String representation of a GUID @param string compressed String representation of a GUID, 22 character long @param guid contains the reconstructed Guid as a result of this method @return true if no error occurred
[ "Reconstructs", "a", "Guid", "-", "object", "form", "an", "compressed", "String", "representation", "of", "a", "GUID" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L203-L244
17,656
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.getUncompressedStringFromGuid
public static String getUncompressedStringFromGuid(Guid guid){ String result = new String(); result += String.format("%1$08x", guid.Data1); result += "-"; result += String.format("%1$04x", guid.Data2); result += "-"; result += String.format("%1$04x", guid.Data3); result += "-"; result += String.format("%1$02x%2$02x", (int)guid.Data4[0], (int)guid.Data4[1]); result += "-"; result += String.format("%1$02x%2$02x%3$02x%4$02x%5$02x%6$02x", (int)guid.Data4[2], (int)guid.Data4[3], (int)guid.Data4[4], (int)guid.Data4[5], (int)guid.Data4[6], (int)guid.Data4[7]); return result; }
java
public static String getUncompressedStringFromGuid(Guid guid){ String result = new String(); result += String.format("%1$08x", guid.Data1); result += "-"; result += String.format("%1$04x", guid.Data2); result += "-"; result += String.format("%1$04x", guid.Data3); result += "-"; result += String.format("%1$02x%2$02x", (int)guid.Data4[0], (int)guid.Data4[1]); result += "-"; result += String.format("%1$02x%2$02x%3$02x%4$02x%5$02x%6$02x", (int)guid.Data4[2], (int)guid.Data4[3], (int)guid.Data4[4], (int)guid.Data4[5], (int)guid.Data4[6], (int)guid.Data4[7]); return result; }
[ "public", "static", "String", "getUncompressedStringFromGuid", "(", "Guid", "guid", ")", "{", "String", "result", "=", "new", "String", "(", ")", ";", "result", "+=", "String", ".", "format", "(", "\"%1$08x\"", ",", "guid", ".", "Data1", ")", ";", "result", "+=", "\"-\"", ";", "result", "+=", "String", ".", "format", "(", "\"%1$04x\"", ",", "guid", ".", "Data2", ")", ";", "result", "+=", "\"-\"", ";", "result", "+=", "String", ".", "format", "(", "\"%1$04x\"", ",", "guid", ".", "Data3", ")", ";", "result", "+=", "\"-\"", ";", "result", "+=", "String", ".", "format", "(", "\"%1$02x%2$02x\"", ",", "(", "int", ")", "guid", ".", "Data4", "[", "0", "]", ",", "(", "int", ")", "guid", ".", "Data4", "[", "1", "]", ")", ";", "result", "+=", "\"-\"", ";", "result", "+=", "String", ".", "format", "(", "\"%1$02x%2$02x%3$02x%4$02x%5$02x%6$02x\"", ",", "(", "int", ")", "guid", ".", "Data4", "[", "2", "]", ",", "(", "int", ")", "guid", ".", "Data4", "[", "3", "]", ",", "(", "int", ")", "guid", ".", "Data4", "[", "4", "]", ",", "(", "int", ")", "guid", ".", "Data4", "[", "5", "]", ",", "(", "int", ")", "guid", ".", "Data4", "[", "6", "]", ",", "(", "int", ")", "guid", ".", "Data4", "[", "7", "]", ")", ";", "return", "result", ";", "}" ]
Converts a Guid-object into a uncompressed String representation of a GUID @param guid the Guid-object to be converted @return the uncompressed String representation of a GUID
[ "Converts", "a", "Guid", "-", "object", "into", "a", "uncompressed", "String", "representation", "of", "a", "GUID" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L252-L264
17,657
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.compressGuidString
public static String compressGuidString(String uncompressedString){ Guid guid = getGuidFromUncompressedString(uncompressedString); return getCompressedStringFromGuid(guid); }
java
public static String compressGuidString(String uncompressedString){ Guid guid = getGuidFromUncompressedString(uncompressedString); return getCompressedStringFromGuid(guid); }
[ "public", "static", "String", "compressGuidString", "(", "String", "uncompressedString", ")", "{", "Guid", "guid", "=", "getGuidFromUncompressedString", "(", "uncompressedString", ")", ";", "return", "getCompressedStringFromGuid", "(", "guid", ")", ";", "}" ]
Converts an uncompressed String representation of a GUID into a compressed one @param uncompressedString the String representation which gets compressed @return the compressed String representation with a length of 22 characters
[ "Converts", "an", "uncompressed", "String", "representation", "of", "a", "GUID", "into", "a", "compressed", "one" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L271-L274
17,658
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/shared/GuidCompressor.java
GuidCompressor.uncompressGuidString
public static String uncompressGuidString(String compressedString) throws InvalidGuidException{ Guid guid = new Guid(); getGuidFromCompressedString(compressedString, guid); return getUncompressedStringFromGuid(guid); }
java
public static String uncompressGuidString(String compressedString) throws InvalidGuidException{ Guid guid = new Guid(); getGuidFromCompressedString(compressedString, guid); return getUncompressedStringFromGuid(guid); }
[ "public", "static", "String", "uncompressGuidString", "(", "String", "compressedString", ")", "throws", "InvalidGuidException", "{", "Guid", "guid", "=", "new", "Guid", "(", ")", ";", "getGuidFromCompressedString", "(", "compressedString", ",", "guid", ")", ";", "return", "getUncompressedStringFromGuid", "(", "guid", ")", ";", "}" ]
Converts a compressed String representation of a GUID into an uncompressed one @param compressedString the String representation which gets uncompressed @return the uncompressed String representation @throws InvalidGuidException
[ "Converts", "a", "compressed", "String", "representation", "of", "a", "GUID", "into", "an", "uncompressed", "one" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/shared/GuidCompressor.java#L282-L286
17,659
opensourceBIM/BIMserver
Shared/src/org/bimserver/plugins/PluginManager.java
PluginManager.initAllLoadedPlugins
public void initAllLoadedPlugins() throws PluginException { LOGGER.debug("Initializig all loaded plugins"); for (Class<? extends Plugin> pluginClass : implementations.keySet()) { Set<PluginContext> set = implementations.get(pluginClass); for (PluginContext pluginContext : set) { try { pluginContext.initialize(pluginContext.getSystemSettings()); } catch (Throwable e) { LOGGER.error("", e); pluginContext.setEnabled(false, false); } } } }
java
public void initAllLoadedPlugins() throws PluginException { LOGGER.debug("Initializig all loaded plugins"); for (Class<? extends Plugin> pluginClass : implementations.keySet()) { Set<PluginContext> set = implementations.get(pluginClass); for (PluginContext pluginContext : set) { try { pluginContext.initialize(pluginContext.getSystemSettings()); } catch (Throwable e) { LOGGER.error("", e); pluginContext.setEnabled(false, false); } } } }
[ "public", "void", "initAllLoadedPlugins", "(", ")", "throws", "PluginException", "{", "LOGGER", ".", "debug", "(", "\"Initializig all loaded plugins\"", ")", ";", "for", "(", "Class", "<", "?", "extends", "Plugin", ">", "pluginClass", ":", "implementations", ".", "keySet", "(", ")", ")", "{", "Set", "<", "PluginContext", ">", "set", "=", "implementations", ".", "get", "(", "pluginClass", ")", ";", "for", "(", "PluginContext", "pluginContext", ":", "set", ")", "{", "try", "{", "pluginContext", ".", "initialize", "(", "pluginContext", ".", "getSystemSettings", "(", ")", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "LOGGER", ".", "error", "(", "\"\"", ",", "e", ")", ";", "pluginContext", ".", "setEnabled", "(", "false", ",", "false", ")", ";", "}", "}", "}", "}" ]
This method will initialize all the loaded plugins @throws PluginException
[ "This", "method", "will", "initialize", "all", "the", "loaded", "plugins" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/Shared/src/org/bimserver/plugins/PluginManager.java#L297-L310
17,660
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/utils/IfcUtils.java
IfcUtils.listProperties
public static Map<String, Object> listProperties(IfcObject ifcObject, String propertySetName) { Map<String, Object> result = new HashMap<>(); for (IfcRelDefines ifcRelDefines : ifcObject.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; if (ifcPropertySet.getName() != null && ifcPropertySet.getName().equalsIgnoreCase(propertySetName)) { for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { if (ifcProperty instanceof IfcPropertySingleValue) { IfcPropertySingleValue propertyValue = (IfcPropertySingleValue) ifcProperty; result.put(propertyValue.getName(), nominalValueToObject(propertyValue.getNominalValue())); } } } } } } return result; }
java
public static Map<String, Object> listProperties(IfcObject ifcObject, String propertySetName) { Map<String, Object> result = new HashMap<>(); for (IfcRelDefines ifcRelDefines : ifcObject.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; if (ifcPropertySet.getName() != null && ifcPropertySet.getName().equalsIgnoreCase(propertySetName)) { for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { if (ifcProperty instanceof IfcPropertySingleValue) { IfcPropertySingleValue propertyValue = (IfcPropertySingleValue) ifcProperty; result.put(propertyValue.getName(), nominalValueToObject(propertyValue.getNominalValue())); } } } } } } return result; }
[ "public", "static", "Map", "<", "String", ",", "Object", ">", "listProperties", "(", "IfcObject", "ifcObject", ",", "String", "propertySetName", ")", "{", "Map", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "IfcRelDefines", "ifcRelDefines", ":", "ifcObject", ".", "getIsDefinedBy", "(", ")", ")", "{", "if", "(", "ifcRelDefines", "instanceof", "IfcRelDefinesByProperties", ")", "{", "IfcRelDefinesByProperties", "ifcRelDefinesByProperties", "=", "(", "IfcRelDefinesByProperties", ")", "ifcRelDefines", ";", "IfcPropertySetDefinition", "propertySetDefinition", "=", "ifcRelDefinesByProperties", ".", "getRelatingPropertyDefinition", "(", ")", ";", "if", "(", "propertySetDefinition", "instanceof", "IfcPropertySet", ")", "{", "IfcPropertySet", "ifcPropertySet", "=", "(", "IfcPropertySet", ")", "propertySetDefinition", ";", "if", "(", "ifcPropertySet", ".", "getName", "(", ")", "!=", "null", "&&", "ifcPropertySet", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "propertySetName", ")", ")", "{", "for", "(", "IfcProperty", "ifcProperty", ":", "ifcPropertySet", ".", "getHasProperties", "(", ")", ")", "{", "if", "(", "ifcProperty", "instanceof", "IfcPropertySingleValue", ")", "{", "IfcPropertySingleValue", "propertyValue", "=", "(", "IfcPropertySingleValue", ")", "ifcProperty", ";", "result", ".", "put", "(", "propertyValue", ".", "getName", "(", ")", ",", "nominalValueToObject", "(", "propertyValue", ".", "getNominalValue", "(", ")", ")", ")", ";", "}", "}", "}", "}", "}", "}", "return", "result", ";", "}" ]
Lists all properties of a given IfcPopertySet that are of type IfcPropertySingleValue, all values are converted to the appropriate Java type @param ifcObject @param propertySetName @return
[ "Lists", "all", "properties", "of", "a", "given", "IfcPopertySet", "that", "are", "of", "type", "IfcPropertySingleValue", "all", "values", "are", "converted", "to", "the", "appropriate", "Java", "type" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/utils/IfcUtils.java#L319-L339
17,661
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.transposeM
public static void transposeM(float[] mTrans, int mTransOffset, float[] m, int mOffset) { for (int i = 0; i < 4; i++) { int mBase = i * 4 + mOffset; mTrans[i + mTransOffset] = m[mBase]; mTrans[i + 4 + mTransOffset] = m[mBase + 1]; mTrans[i + 8 + mTransOffset] = m[mBase + 2]; mTrans[i + 12 + mTransOffset] = m[mBase + 3]; } }
java
public static void transposeM(float[] mTrans, int mTransOffset, float[] m, int mOffset) { for (int i = 0; i < 4; i++) { int mBase = i * 4 + mOffset; mTrans[i + mTransOffset] = m[mBase]; mTrans[i + 4 + mTransOffset] = m[mBase + 1]; mTrans[i + 8 + mTransOffset] = m[mBase + 2]; mTrans[i + 12 + mTransOffset] = m[mBase + 3]; } }
[ "public", "static", "void", "transposeM", "(", "float", "[", "]", "mTrans", ",", "int", "mTransOffset", ",", "float", "[", "]", "m", ",", "int", "mOffset", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "int", "mBase", "=", "i", "*", "4", "+", "mOffset", ";", "mTrans", "[", "i", "+", "mTransOffset", "]", "=", "m", "[", "mBase", "]", ";", "mTrans", "[", "i", "+", "4", "+", "mTransOffset", "]", "=", "m", "[", "mBase", "+", "1", "]", ";", "mTrans", "[", "i", "+", "8", "+", "mTransOffset", "]", "=", "m", "[", "mBase", "+", "2", "]", ";", "mTrans", "[", "i", "+", "12", "+", "mTransOffset", "]", "=", "m", "[", "mBase", "+", "3", "]", ";", "}", "}" ]
Transposes a 4 x 4 matrix. @param mTrans the array that holds the output inverted matrix @param mTransOffset an offset into mInv where the inverted matrix is stored. @param m the input array @param mOffset an offset into m where the matrix is stored.
[ "Transposes", "a", "4", "x", "4", "matrix", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L210-L219
17,662
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.orthoM
public static void orthoM(float[] m, int mOffset, float left, float right, float bottom, float top, float near, float far) { if (left == right) { throw new IllegalArgumentException("left == right"); } if (bottom == top) { throw new IllegalArgumentException("bottom == top"); } if (near == far) { throw new IllegalArgumentException("near == far"); } final float r_width = 1.0f / (right - left); final float r_height = 1.0f / (top - bottom); final float r_depth = 1.0f / (far - near); final float x = 2.0f * (r_width); final float y = 2.0f * (r_height); final float z = -2.0f * (r_depth); final float tx = -(right + left) * r_width; final float ty = -(top + bottom) * r_height; final float tz = -(far + near) * r_depth; m[mOffset + 0] = x; m[mOffset + 5] = y; m[mOffset +10] = z; m[mOffset +12] = tx; m[mOffset +13] = ty; m[mOffset +14] = tz; m[mOffset +15] = 1.0f; m[mOffset + 1] = 0.0f; m[mOffset + 2] = 0.0f; m[mOffset + 3] = 0.0f; m[mOffset + 4] = 0.0f; m[mOffset + 6] = 0.0f; m[mOffset + 7] = 0.0f; m[mOffset + 8] = 0.0f; m[mOffset + 9] = 0.0f; m[mOffset + 11] = 0.0f; }
java
public static void orthoM(float[] m, int mOffset, float left, float right, float bottom, float top, float near, float far) { if (left == right) { throw new IllegalArgumentException("left == right"); } if (bottom == top) { throw new IllegalArgumentException("bottom == top"); } if (near == far) { throw new IllegalArgumentException("near == far"); } final float r_width = 1.0f / (right - left); final float r_height = 1.0f / (top - bottom); final float r_depth = 1.0f / (far - near); final float x = 2.0f * (r_width); final float y = 2.0f * (r_height); final float z = -2.0f * (r_depth); final float tx = -(right + left) * r_width; final float ty = -(top + bottom) * r_height; final float tz = -(far + near) * r_depth; m[mOffset + 0] = x; m[mOffset + 5] = y; m[mOffset +10] = z; m[mOffset +12] = tx; m[mOffset +13] = ty; m[mOffset +14] = tz; m[mOffset +15] = 1.0f; m[mOffset + 1] = 0.0f; m[mOffset + 2] = 0.0f; m[mOffset + 3] = 0.0f; m[mOffset + 4] = 0.0f; m[mOffset + 6] = 0.0f; m[mOffset + 7] = 0.0f; m[mOffset + 8] = 0.0f; m[mOffset + 9] = 0.0f; m[mOffset + 11] = 0.0f; }
[ "public", "static", "void", "orthoM", "(", "float", "[", "]", "m", ",", "int", "mOffset", ",", "float", "left", ",", "float", "right", ",", "float", "bottom", ",", "float", "top", ",", "float", "near", ",", "float", "far", ")", "{", "if", "(", "left", "==", "right", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"left == right\"", ")", ";", "}", "if", "(", "bottom", "==", "top", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"bottom == top\"", ")", ";", "}", "if", "(", "near", "==", "far", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"near == far\"", ")", ";", "}", "final", "float", "r_width", "=", "1.0f", "/", "(", "right", "-", "left", ")", ";", "final", "float", "r_height", "=", "1.0f", "/", "(", "top", "-", "bottom", ")", ";", "final", "float", "r_depth", "=", "1.0f", "/", "(", "far", "-", "near", ")", ";", "final", "float", "x", "=", "2.0f", "*", "(", "r_width", ")", ";", "final", "float", "y", "=", "2.0f", "*", "(", "r_height", ")", ";", "final", "float", "z", "=", "-", "2.0f", "*", "(", "r_depth", ")", ";", "final", "float", "tx", "=", "-", "(", "right", "+", "left", ")", "*", "r_width", ";", "final", "float", "ty", "=", "-", "(", "top", "+", "bottom", ")", "*", "r_height", ";", "final", "float", "tz", "=", "-", "(", "far", "+", "near", ")", "*", "r_depth", ";", "m", "[", "mOffset", "+", "0", "]", "=", "x", ";", "m", "[", "mOffset", "+", "5", "]", "=", "y", ";", "m", "[", "mOffset", "+", "10", "]", "=", "z", ";", "m", "[", "mOffset", "+", "12", "]", "=", "tx", ";", "m", "[", "mOffset", "+", "13", "]", "=", "ty", ";", "m", "[", "mOffset", "+", "14", "]", "=", "tz", ";", "m", "[", "mOffset", "+", "15", "]", "=", "1.0f", ";", "m", "[", "mOffset", "+", "1", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "2", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "3", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "4", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "6", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "7", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "8", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "9", "]", "=", "0.0f", ";", "m", "[", "mOffset", "+", "11", "]", "=", "0.0f", ";", "}" ]
Computes an orthographic projection matrix. @param m returns the result @param mOffset @param left @param right @param bottom @param top @param near @param far
[ "Computes", "an", "orthographic", "projection", "matrix", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L497-L535
17,663
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.frustumM
public static void frustumM(float[] m, int offset, float left, float right, float bottom, float top, float near, float far) { if (left == right) { throw new IllegalArgumentException("left == right"); } if (top == bottom) { throw new IllegalArgumentException("top == bottom"); } if (near == far) { throw new IllegalArgumentException("near == far"); } if (near <= 0.0f) { throw new IllegalArgumentException("near <= 0.0f"); } if (far <= 0.0f) { throw new IllegalArgumentException("far <= 0.0f"); } final float r_width = 1.0f / (right - left); final float r_height = 1.0f / (top - bottom); final float r_depth = 1.0f / (near - far); final float x = 2.0f * (near * r_width); final float y = 2.0f * (near * r_height); final float A = (right + left) * r_width; final float B = (top + bottom) * r_height; final float C = (far + near) * r_depth; final float D = 2.0f * (far * near * r_depth); m[offset + 0] = x; m[offset + 5] = y; m[offset + 8] = A; m[offset + 9] = B; m[offset + 10] = C; m[offset + 14] = D; m[offset + 11] = -1.0f; m[offset + 1] = 0.0f; m[offset + 2] = 0.0f; m[offset + 3] = 0.0f; m[offset + 4] = 0.0f; m[offset + 6] = 0.0f; m[offset + 7] = 0.0f; m[offset + 12] = 0.0f; m[offset + 13] = 0.0f; m[offset + 15] = 0.0f; }
java
public static void frustumM(float[] m, int offset, float left, float right, float bottom, float top, float near, float far) { if (left == right) { throw new IllegalArgumentException("left == right"); } if (top == bottom) { throw new IllegalArgumentException("top == bottom"); } if (near == far) { throw new IllegalArgumentException("near == far"); } if (near <= 0.0f) { throw new IllegalArgumentException("near <= 0.0f"); } if (far <= 0.0f) { throw new IllegalArgumentException("far <= 0.0f"); } final float r_width = 1.0f / (right - left); final float r_height = 1.0f / (top - bottom); final float r_depth = 1.0f / (near - far); final float x = 2.0f * (near * r_width); final float y = 2.0f * (near * r_height); final float A = (right + left) * r_width; final float B = (top + bottom) * r_height; final float C = (far + near) * r_depth; final float D = 2.0f * (far * near * r_depth); m[offset + 0] = x; m[offset + 5] = y; m[offset + 8] = A; m[offset + 9] = B; m[offset + 10] = C; m[offset + 14] = D; m[offset + 11] = -1.0f; m[offset + 1] = 0.0f; m[offset + 2] = 0.0f; m[offset + 3] = 0.0f; m[offset + 4] = 0.0f; m[offset + 6] = 0.0f; m[offset + 7] = 0.0f; m[offset + 12] = 0.0f; m[offset + 13] = 0.0f; m[offset + 15] = 0.0f; }
[ "public", "static", "void", "frustumM", "(", "float", "[", "]", "m", ",", "int", "offset", ",", "float", "left", ",", "float", "right", ",", "float", "bottom", ",", "float", "top", ",", "float", "near", ",", "float", "far", ")", "{", "if", "(", "left", "==", "right", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"left == right\"", ")", ";", "}", "if", "(", "top", "==", "bottom", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"top == bottom\"", ")", ";", "}", "if", "(", "near", "==", "far", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"near == far\"", ")", ";", "}", "if", "(", "near", "<=", "0.0f", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"near <= 0.0f\"", ")", ";", "}", "if", "(", "far", "<=", "0.0f", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"far <= 0.0f\"", ")", ";", "}", "final", "float", "r_width", "=", "1.0f", "/", "(", "right", "-", "left", ")", ";", "final", "float", "r_height", "=", "1.0f", "/", "(", "top", "-", "bottom", ")", ";", "final", "float", "r_depth", "=", "1.0f", "/", "(", "near", "-", "far", ")", ";", "final", "float", "x", "=", "2.0f", "*", "(", "near", "*", "r_width", ")", ";", "final", "float", "y", "=", "2.0f", "*", "(", "near", "*", "r_height", ")", ";", "final", "float", "A", "=", "(", "right", "+", "left", ")", "*", "r_width", ";", "final", "float", "B", "=", "(", "top", "+", "bottom", ")", "*", "r_height", ";", "final", "float", "C", "=", "(", "far", "+", "near", ")", "*", "r_depth", ";", "final", "float", "D", "=", "2.0f", "*", "(", "far", "*", "near", "*", "r_depth", ")", ";", "m", "[", "offset", "+", "0", "]", "=", "x", ";", "m", "[", "offset", "+", "5", "]", "=", "y", ";", "m", "[", "offset", "+", "8", "]", "=", "A", ";", "m", "[", "offset", "+", "9", "]", "=", "B", ";", "m", "[", "offset", "+", "10", "]", "=", "C", ";", "m", "[", "offset", "+", "14", "]", "=", "D", ";", "m", "[", "offset", "+", "11", "]", "=", "-", "1.0f", ";", "m", "[", "offset", "+", "1", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "2", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "3", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "4", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "6", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "7", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "12", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "13", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "15", "]", "=", "0.0f", ";", "}" ]
Define a projection matrix in terms of six clip planes @param m the float array that holds the perspective matrix @param offset the offset into float array m where the perspective matrix data is written @param left @param right @param bottom @param top @param near @param far
[ "Define", "a", "projection", "matrix", "in", "terms", "of", "six", "clip", "planes" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L550-L593
17,664
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.perspectiveM
public static void perspectiveM(float[] m, int offset, float fovy, float aspect, float zNear, float zFar) { float f = 1.0f / (float) Math.tan(fovy * (Math.PI / 360.0)); float rangeReciprocal = 1.0f / (zNear - zFar); m[offset + 0] = f / aspect; m[offset + 1] = 0.0f; m[offset + 2] = 0.0f; m[offset + 3] = 0.0f; m[offset + 4] = 0.0f; m[offset + 5] = f; m[offset + 6] = 0.0f; m[offset + 7] = 0.0f; m[offset + 8] = 0.0f; m[offset + 9] = 0.0f; m[offset + 10] = (zFar + zNear) * rangeReciprocal; m[offset + 11] = -1.0f; m[offset + 12] = 0.0f; m[offset + 13] = 0.0f; m[offset + 14] = 2.0f * zFar * zNear * rangeReciprocal; m[offset + 15] = 0.0f; }
java
public static void perspectiveM(float[] m, int offset, float fovy, float aspect, float zNear, float zFar) { float f = 1.0f / (float) Math.tan(fovy * (Math.PI / 360.0)); float rangeReciprocal = 1.0f / (zNear - zFar); m[offset + 0] = f / aspect; m[offset + 1] = 0.0f; m[offset + 2] = 0.0f; m[offset + 3] = 0.0f; m[offset + 4] = 0.0f; m[offset + 5] = f; m[offset + 6] = 0.0f; m[offset + 7] = 0.0f; m[offset + 8] = 0.0f; m[offset + 9] = 0.0f; m[offset + 10] = (zFar + zNear) * rangeReciprocal; m[offset + 11] = -1.0f; m[offset + 12] = 0.0f; m[offset + 13] = 0.0f; m[offset + 14] = 2.0f * zFar * zNear * rangeReciprocal; m[offset + 15] = 0.0f; }
[ "public", "static", "void", "perspectiveM", "(", "float", "[", "]", "m", ",", "int", "offset", ",", "float", "fovy", ",", "float", "aspect", ",", "float", "zNear", ",", "float", "zFar", ")", "{", "float", "f", "=", "1.0f", "/", "(", "float", ")", "Math", ".", "tan", "(", "fovy", "*", "(", "Math", ".", "PI", "/", "360.0", ")", ")", ";", "float", "rangeReciprocal", "=", "1.0f", "/", "(", "zNear", "-", "zFar", ")", ";", "m", "[", "offset", "+", "0", "]", "=", "f", "/", "aspect", ";", "m", "[", "offset", "+", "1", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "2", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "3", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "4", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "5", "]", "=", "f", ";", "m", "[", "offset", "+", "6", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "7", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "8", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "9", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "10", "]", "=", "(", "zFar", "+", "zNear", ")", "*", "rangeReciprocal", ";", "m", "[", "offset", "+", "11", "]", "=", "-", "1.0f", ";", "m", "[", "offset", "+", "12", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "13", "]", "=", "0.0f", ";", "m", "[", "offset", "+", "14", "]", "=", "2.0f", "*", "zFar", "*", "zNear", "*", "rangeReciprocal", ";", "m", "[", "offset", "+", "15", "]", "=", "0.0f", ";", "}" ]
Define a projection matrix in terms of a field of view angle, an aspect ratio, and z clip planes @param m the float array that holds the perspective matrix @param offset the offset into float array m where the perspective matrix data is written @param fovy field of view in y direction, in degrees @param aspect width to height aspect ratio of the viewport @param zNear @param zFar
[ "Define", "a", "projection", "matrix", "in", "terms", "of", "a", "field", "of", "view", "angle", "an", "aspect", "ratio", "and", "z", "clip", "planes" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L606-L630
17,665
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.setIdentityM
public static void setIdentityM(float[] sm, int smOffset) { for (int i=0 ; i<16 ; i++) { sm[smOffset + i] = 0; } for(int i = 0; i < 16; i += 5) { sm[smOffset + i] = 1.0f; } }
java
public static void setIdentityM(float[] sm, int smOffset) { for (int i=0 ; i<16 ; i++) { sm[smOffset + i] = 0; } for(int i = 0; i < 16; i += 5) { sm[smOffset + i] = 1.0f; } }
[ "public", "static", "void", "setIdentityM", "(", "float", "[", "]", "sm", ",", "int", "smOffset", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "16", ";", "i", "++", ")", "{", "sm", "[", "smOffset", "+", "i", "]", "=", "0", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "16", ";", "i", "+=", "5", ")", "{", "sm", "[", "smOffset", "+", "i", "]", "=", "1.0f", ";", "}", "}" ]
Sets matrix m to the identity matrix. @param sm returns the result @param smOffset index into sm where the result matrix starts
[ "Sets", "matrix", "m", "to", "the", "identity", "matrix", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L653-L660
17,666
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.scaleM
public static void scaleM(float[] sm, int smOffset, float[] m, int mOffset, float x, float y, float z) { for (int i=0 ; i<4 ; i++) { int smi = smOffset + i; int mi = mOffset + i; sm[ smi] = m[ mi] * x; sm[ 4 + smi] = m[ 4 + mi] * y; sm[ 8 + smi] = m[ 8 + mi] * z; sm[12 + smi] = m[12 + mi]; } }
java
public static void scaleM(float[] sm, int smOffset, float[] m, int mOffset, float x, float y, float z) { for (int i=0 ; i<4 ; i++) { int smi = smOffset + i; int mi = mOffset + i; sm[ smi] = m[ mi] * x; sm[ 4 + smi] = m[ 4 + mi] * y; sm[ 8 + smi] = m[ 8 + mi] * z; sm[12 + smi] = m[12 + mi]; } }
[ "public", "static", "void", "scaleM", "(", "float", "[", "]", "sm", ",", "int", "smOffset", ",", "float", "[", "]", "m", ",", "int", "mOffset", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "int", "smi", "=", "smOffset", "+", "i", ";", "int", "mi", "=", "mOffset", "+", "i", ";", "sm", "[", "smi", "]", "=", "m", "[", "mi", "]", "*", "x", ";", "sm", "[", "4", "+", "smi", "]", "=", "m", "[", "4", "+", "mi", "]", "*", "y", ";", "sm", "[", "8", "+", "smi", "]", "=", "m", "[", "8", "+", "mi", "]", "*", "z", ";", "sm", "[", "12", "+", "smi", "]", "=", "m", "[", "12", "+", "mi", "]", ";", "}", "}" ]
Scales matrix m by x, y, and z, putting the result in sm @param sm returns the result @param smOffset index into sm where the result matrix starts @param m source matrix @param mOffset index into m where the source matrix starts @param x scale factor x @param y scale factor y @param z scale factor z
[ "Scales", "matrix", "m", "by", "x", "y", "and", "z", "putting", "the", "result", "in", "sm" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L686-L697
17,667
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.translateM
public static void translateM(float[] tm, int tmOffset, float[] m, int mOffset, float x, float y, float z) { for (int i=0 ; i<12 ; i++) { tm[tmOffset + i] = m[mOffset + i]; } for (int i=0 ; i<4 ; i++) { int tmi = tmOffset + i; int mi = mOffset + i; tm[12 + tmi] = m[mi] * x + m[4 + mi] * y + m[8 + mi] * z + m[12 + mi]; } }
java
public static void translateM(float[] tm, int tmOffset, float[] m, int mOffset, float x, float y, float z) { for (int i=0 ; i<12 ; i++) { tm[tmOffset + i] = m[mOffset + i]; } for (int i=0 ; i<4 ; i++) { int tmi = tmOffset + i; int mi = mOffset + i; tm[12 + tmi] = m[mi] * x + m[4 + mi] * y + m[8 + mi] * z + m[12 + mi]; } }
[ "public", "static", "void", "translateM", "(", "float", "[", "]", "tm", ",", "int", "tmOffset", ",", "float", "[", "]", "m", ",", "int", "mOffset", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "12", ";", "i", "++", ")", "{", "tm", "[", "tmOffset", "+", "i", "]", "=", "m", "[", "mOffset", "+", "i", "]", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "int", "tmi", "=", "tmOffset", "+", "i", ";", "int", "mi", "=", "mOffset", "+", "i", ";", "tm", "[", "12", "+", "tmi", "]", "=", "m", "[", "mi", "]", "*", "x", "+", "m", "[", "4", "+", "mi", "]", "*", "y", "+", "m", "[", "8", "+", "mi", "]", "*", "z", "+", "m", "[", "12", "+", "mi", "]", ";", "}", "}" ]
Translates matrix m by x, y, and z, putting the result in tm @param tm returns the result @param tmOffset index into sm where the result matrix starts @param m source matrix @param mOffset index into m where the source matrix starts @param x translation factor x @param y translation factor y @param z translation factor z
[ "Translates", "matrix", "m", "by", "x", "y", "and", "z", "putting", "the", "result", "in", "tm" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L737-L749
17,668
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.translateM
public static void translateM( float[] m, int mOffset, float x, float y, float z) { for (int i=0 ; i<4 ; i++) { int mi = mOffset + i; m[12 + mi] += m[mi] * x + m[4 + mi] * y + m[8 + mi] * z; } }
java
public static void translateM( float[] m, int mOffset, float x, float y, float z) { for (int i=0 ; i<4 ; i++) { int mi = mOffset + i; m[12 + mi] += m[mi] * x + m[4 + mi] * y + m[8 + mi] * z; } }
[ "public", "static", "void", "translateM", "(", "float", "[", "]", "m", ",", "int", "mOffset", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "int", "mi", "=", "mOffset", "+", "i", ";", "m", "[", "12", "+", "mi", "]", "+=", "m", "[", "mi", "]", "*", "x", "+", "m", "[", "4", "+", "mi", "]", "*", "y", "+", "m", "[", "8", "+", "mi", "]", "*", "z", ";", "}", "}" ]
Translates matrix m by x, y, and z in place. @param m matrix @param mOffset index into m where the matrix starts @param x translation factor x @param y translation factor y @param z translation factor z
[ "Translates", "matrix", "m", "by", "x", "y", "and", "z", "in", "place", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L759-L766
17,669
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.setRotateEulerM
public static void setRotateEulerM(float[] rm, int rmOffset, float x, float y, float z) { x *= (float) (Math.PI / 180.0f); y *= (float) (Math.PI / 180.0f); z *= (float) (Math.PI / 180.0f); float cx = (float) Math.cos(x); float sx = (float) Math.sin(x); float cy = (float) Math.cos(y); float sy = (float) Math.sin(y); float cz = (float) Math.cos(z); float sz = (float) Math.sin(z); float cxsy = cx * sy; float sxsy = sx * sy; rm[rmOffset + 0] = cy * cz; rm[rmOffset + 1] = -cy * sz; rm[rmOffset + 2] = sy; rm[rmOffset + 3] = 0.0f; rm[rmOffset + 4] = cxsy * cz + cx * sz; rm[rmOffset + 5] = -cxsy * sz + cx * cz; rm[rmOffset + 6] = -sx * cy; rm[rmOffset + 7] = 0.0f; rm[rmOffset + 8] = -sxsy * cz + sx * sz; rm[rmOffset + 9] = sxsy * sz + sx * cz; rm[rmOffset + 10] = cx * cy; rm[rmOffset + 11] = 0.0f; rm[rmOffset + 12] = 0.0f; rm[rmOffset + 13] = 0.0f; rm[rmOffset + 14] = 0.0f; rm[rmOffset + 15] = 1.0f; }
java
public static void setRotateEulerM(float[] rm, int rmOffset, float x, float y, float z) { x *= (float) (Math.PI / 180.0f); y *= (float) (Math.PI / 180.0f); z *= (float) (Math.PI / 180.0f); float cx = (float) Math.cos(x); float sx = (float) Math.sin(x); float cy = (float) Math.cos(y); float sy = (float) Math.sin(y); float cz = (float) Math.cos(z); float sz = (float) Math.sin(z); float cxsy = cx * sy; float sxsy = sx * sy; rm[rmOffset + 0] = cy * cz; rm[rmOffset + 1] = -cy * sz; rm[rmOffset + 2] = sy; rm[rmOffset + 3] = 0.0f; rm[rmOffset + 4] = cxsy * cz + cx * sz; rm[rmOffset + 5] = -cxsy * sz + cx * cz; rm[rmOffset + 6] = -sx * cy; rm[rmOffset + 7] = 0.0f; rm[rmOffset + 8] = -sxsy * cz + sx * sz; rm[rmOffset + 9] = sxsy * sz + sx * cz; rm[rmOffset + 10] = cx * cy; rm[rmOffset + 11] = 0.0f; rm[rmOffset + 12] = 0.0f; rm[rmOffset + 13] = 0.0f; rm[rmOffset + 14] = 0.0f; rm[rmOffset + 15] = 1.0f; }
[ "public", "static", "void", "setRotateEulerM", "(", "float", "[", "]", "rm", ",", "int", "rmOffset", ",", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "x", "*=", "(", "float", ")", "(", "Math", ".", "PI", "/", "180.0f", ")", ";", "y", "*=", "(", "float", ")", "(", "Math", ".", "PI", "/", "180.0f", ")", ";", "z", "*=", "(", "float", ")", "(", "Math", ".", "PI", "/", "180.0f", ")", ";", "float", "cx", "=", "(", "float", ")", "Math", ".", "cos", "(", "x", ")", ";", "float", "sx", "=", "(", "float", ")", "Math", ".", "sin", "(", "x", ")", ";", "float", "cy", "=", "(", "float", ")", "Math", ".", "cos", "(", "y", ")", ";", "float", "sy", "=", "(", "float", ")", "Math", ".", "sin", "(", "y", ")", ";", "float", "cz", "=", "(", "float", ")", "Math", ".", "cos", "(", "z", ")", ";", "float", "sz", "=", "(", "float", ")", "Math", ".", "sin", "(", "z", ")", ";", "float", "cxsy", "=", "cx", "*", "sy", ";", "float", "sxsy", "=", "sx", "*", "sy", ";", "rm", "[", "rmOffset", "+", "0", "]", "=", "cy", "*", "cz", ";", "rm", "[", "rmOffset", "+", "1", "]", "=", "-", "cy", "*", "sz", ";", "rm", "[", "rmOffset", "+", "2", "]", "=", "sy", ";", "rm", "[", "rmOffset", "+", "3", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "4", "]", "=", "cxsy", "*", "cz", "+", "cx", "*", "sz", ";", "rm", "[", "rmOffset", "+", "5", "]", "=", "-", "cxsy", "*", "sz", "+", "cx", "*", "cz", ";", "rm", "[", "rmOffset", "+", "6", "]", "=", "-", "sx", "*", "cy", ";", "rm", "[", "rmOffset", "+", "7", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "8", "]", "=", "-", "sxsy", "*", "cz", "+", "sx", "*", "sz", ";", "rm", "[", "rmOffset", "+", "9", "]", "=", "sxsy", "*", "sz", "+", "sx", "*", "cz", ";", "rm", "[", "rmOffset", "+", "10", "]", "=", "cx", "*", "cy", ";", "rm", "[", "rmOffset", "+", "11", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "12", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "13", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "14", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "15", "]", "=", "1.0f", ";", "}" ]
Converts Euler angles to a rotation matrix @param rm returns the result @param rmOffset index into rm where the result matrix starts @param x angle of rotation, in degrees @param y angle of rotation, in degrees @param z angle of rotation, in degrees
[ "Converts", "Euler", "angles", "to", "a", "rotation", "matrix" ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L974-L1007
17,670
opensourceBIM/BIMserver
PluginBase/src/org/bimserver/geometry/Matrix.java
Matrix.setLookAtM
public static void setLookAtM(float[] rm, int rmOffset, float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { // See the OpenGL GLUT documentation for gluLookAt for a description // of the algorithm. We implement it in a straightforward way: float fx = centerX - eyeX; float fy = centerY - eyeY; float fz = centerZ - eyeZ; // Normalize f float rlf = 1.0f / Matrix.length(fx, fy, fz); fx *= rlf; fy *= rlf; fz *= rlf; // compute s = f x up (x means "cross product") float sx = fy * upZ - fz * upY; float sy = fz * upX - fx * upZ; float sz = fx * upY - fy * upX; // and normalize s float rls = 1.0f / Matrix.length(sx, sy, sz); sx *= rls; sy *= rls; sz *= rls; // compute u = s x f float ux = sy * fz - sz * fy; float uy = sz * fx - sx * fz; float uz = sx * fy - sy * fx; rm[rmOffset + 0] = sx; rm[rmOffset + 1] = ux; rm[rmOffset + 2] = -fx; rm[rmOffset + 3] = 0.0f; rm[rmOffset + 4] = sy; rm[rmOffset + 5] = uy; rm[rmOffset + 6] = -fy; rm[rmOffset + 7] = 0.0f; rm[rmOffset + 8] = sz; rm[rmOffset + 9] = uz; rm[rmOffset + 10] = -fz; rm[rmOffset + 11] = 0.0f; rm[rmOffset + 12] = 0.0f; rm[rmOffset + 13] = 0.0f; rm[rmOffset + 14] = 0.0f; rm[rmOffset + 15] = 1.0f; translateM(rm, rmOffset, -eyeX, -eyeY, -eyeZ); }
java
public static void setLookAtM(float[] rm, int rmOffset, float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { // See the OpenGL GLUT documentation for gluLookAt for a description // of the algorithm. We implement it in a straightforward way: float fx = centerX - eyeX; float fy = centerY - eyeY; float fz = centerZ - eyeZ; // Normalize f float rlf = 1.0f / Matrix.length(fx, fy, fz); fx *= rlf; fy *= rlf; fz *= rlf; // compute s = f x up (x means "cross product") float sx = fy * upZ - fz * upY; float sy = fz * upX - fx * upZ; float sz = fx * upY - fy * upX; // and normalize s float rls = 1.0f / Matrix.length(sx, sy, sz); sx *= rls; sy *= rls; sz *= rls; // compute u = s x f float ux = sy * fz - sz * fy; float uy = sz * fx - sx * fz; float uz = sx * fy - sy * fx; rm[rmOffset + 0] = sx; rm[rmOffset + 1] = ux; rm[rmOffset + 2] = -fx; rm[rmOffset + 3] = 0.0f; rm[rmOffset + 4] = sy; rm[rmOffset + 5] = uy; rm[rmOffset + 6] = -fy; rm[rmOffset + 7] = 0.0f; rm[rmOffset + 8] = sz; rm[rmOffset + 9] = uz; rm[rmOffset + 10] = -fz; rm[rmOffset + 11] = 0.0f; rm[rmOffset + 12] = 0.0f; rm[rmOffset + 13] = 0.0f; rm[rmOffset + 14] = 0.0f; rm[rmOffset + 15] = 1.0f; translateM(rm, rmOffset, -eyeX, -eyeY, -eyeZ); }
[ "public", "static", "void", "setLookAtM", "(", "float", "[", "]", "rm", ",", "int", "rmOffset", ",", "float", "eyeX", ",", "float", "eyeY", ",", "float", "eyeZ", ",", "float", "centerX", ",", "float", "centerY", ",", "float", "centerZ", ",", "float", "upX", ",", "float", "upY", ",", "float", "upZ", ")", "{", "// See the OpenGL GLUT documentation for gluLookAt for a description\r", "// of the algorithm. We implement it in a straightforward way:\r", "float", "fx", "=", "centerX", "-", "eyeX", ";", "float", "fy", "=", "centerY", "-", "eyeY", ";", "float", "fz", "=", "centerZ", "-", "eyeZ", ";", "// Normalize f\r", "float", "rlf", "=", "1.0f", "/", "Matrix", ".", "length", "(", "fx", ",", "fy", ",", "fz", ")", ";", "fx", "*=", "rlf", ";", "fy", "*=", "rlf", ";", "fz", "*=", "rlf", ";", "// compute s = f x up (x means \"cross product\")\r", "float", "sx", "=", "fy", "*", "upZ", "-", "fz", "*", "upY", ";", "float", "sy", "=", "fz", "*", "upX", "-", "fx", "*", "upZ", ";", "float", "sz", "=", "fx", "*", "upY", "-", "fy", "*", "upX", ";", "// and normalize s\r", "float", "rls", "=", "1.0f", "/", "Matrix", ".", "length", "(", "sx", ",", "sy", ",", "sz", ")", ";", "sx", "*=", "rls", ";", "sy", "*=", "rls", ";", "sz", "*=", "rls", ";", "// compute u = s x f\r", "float", "ux", "=", "sy", "*", "fz", "-", "sz", "*", "fy", ";", "float", "uy", "=", "sz", "*", "fx", "-", "sx", "*", "fz", ";", "float", "uz", "=", "sx", "*", "fy", "-", "sy", "*", "fx", ";", "rm", "[", "rmOffset", "+", "0", "]", "=", "sx", ";", "rm", "[", "rmOffset", "+", "1", "]", "=", "ux", ";", "rm", "[", "rmOffset", "+", "2", "]", "=", "-", "fx", ";", "rm", "[", "rmOffset", "+", "3", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "4", "]", "=", "sy", ";", "rm", "[", "rmOffset", "+", "5", "]", "=", "uy", ";", "rm", "[", "rmOffset", "+", "6", "]", "=", "-", "fy", ";", "rm", "[", "rmOffset", "+", "7", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "8", "]", "=", "sz", ";", "rm", "[", "rmOffset", "+", "9", "]", "=", "uz", ";", "rm", "[", "rmOffset", "+", "10", "]", "=", "-", "fz", ";", "rm", "[", "rmOffset", "+", "11", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "12", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "13", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "14", "]", "=", "0.0f", ";", "rm", "[", "rmOffset", "+", "15", "]", "=", "1.0f", ";", "translateM", "(", "rm", ",", "rmOffset", ",", "-", "eyeX", ",", "-", "eyeY", ",", "-", "eyeZ", ")", ";", "}" ]
Define a viewing transformation in terms of an eye point, a center of view, and an up vector. @param rm returns the result @param rmOffset index into rm where the result matrix starts @param eyeX eye point X @param eyeY eye point Y @param eyeZ eye point Z @param centerX center of view X @param centerY center of view Y @param centerZ center of view Z @param upX up vector X @param upY up vector Y @param upZ up vector Z
[ "Define", "a", "viewing", "transformation", "in", "terms", "of", "an", "eye", "point", "a", "center", "of", "view", "and", "an", "up", "vector", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/PluginBase/src/org/bimserver/geometry/Matrix.java#L1025-L1080
17,671
opensourceBIM/BIMserver
BimServer/src/org/bimserver/BimServer.java
BimServer.activateServices
public void activateServices() throws BimserverDatabaseException, BimserverLockConflictException { try (DatabaseSession session = bimDatabase.createSession()) { IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getUser(), OldQuery.getDefault()); for (User user : allOfType.getAll(User.class)) { updateUserSettings(session, user); UserSettings userSettings = user.getUserSettings(); for (InternalServicePluginConfiguration internalServicePluginConfiguration : userSettings.getServices()) { activateService(user.getOid(), internalServicePluginConfiguration); } } } }
java
public void activateServices() throws BimserverDatabaseException, BimserverLockConflictException { try (DatabaseSession session = bimDatabase.createSession()) { IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getUser(), OldQuery.getDefault()); for (User user : allOfType.getAll(User.class)) { updateUserSettings(session, user); UserSettings userSettings = user.getUserSettings(); for (InternalServicePluginConfiguration internalServicePluginConfiguration : userSettings.getServices()) { activateService(user.getOid(), internalServicePluginConfiguration); } } } }
[ "public", "void", "activateServices", "(", ")", "throws", "BimserverDatabaseException", ",", "BimserverLockConflictException", "{", "try", "(", "DatabaseSession", "session", "=", "bimDatabase", ".", "createSession", "(", ")", ")", "{", "IfcModelInterface", "allOfType", "=", "session", ".", "getAllOfType", "(", "StorePackage", ".", "eINSTANCE", ".", "getUser", "(", ")", ",", "OldQuery", ".", "getDefault", "(", ")", ")", ";", "for", "(", "User", "user", ":", "allOfType", ".", "getAll", "(", "User", ".", "class", ")", ")", "{", "updateUserSettings", "(", "session", ",", "user", ")", ";", "UserSettings", "userSettings", "=", "user", ".", "getUserSettings", "(", ")", ";", "for", "(", "InternalServicePluginConfiguration", "internalServicePluginConfiguration", ":", "userSettings", ".", "getServices", "(", ")", ")", "{", "activateService", "(", "user", ".", "getOid", "(", ")", ",", "internalServicePluginConfiguration", ")", ";", "}", "}", "}", "}" ]
Load all users from the database and their configured services. Registers each service. @param session @throws BimserverDatabaseException @throws BimserverLockConflictException
[ "Load", "all", "users", "from", "the", "database", "and", "their", "configured", "services", ".", "Registers", "each", "service", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/BimServer/src/org/bimserver/BimServer.java#L1266-L1278
17,672
opensourceBIM/BIMserver
BimServerJar/src/org/bimserver/starter/SpringUtilities.java
SpringUtilities.printSizes
public static void printSizes(Component c) { System.out.println("minimumSize = " + c.getMinimumSize()); System.out.println("preferredSize = " + c.getPreferredSize()); System.out.println("maximumSize = " + c.getMaximumSize()); }
java
public static void printSizes(Component c) { System.out.println("minimumSize = " + c.getMinimumSize()); System.out.println("preferredSize = " + c.getPreferredSize()); System.out.println("maximumSize = " + c.getMaximumSize()); }
[ "public", "static", "void", "printSizes", "(", "Component", "c", ")", "{", "System", ".", "out", ".", "println", "(", "\"minimumSize = \"", "+", "c", ".", "getMinimumSize", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"preferredSize = \"", "+", "c", ".", "getPreferredSize", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"maximumSize = \"", "+", "c", ".", "getMaximumSize", "(", ")", ")", ";", "}" ]
A debugging utility that prints to stdout the component's minimum, preferred, and maximum sizes.
[ "A", "debugging", "utility", "that", "prints", "to", "stdout", "the", "component", "s", "minimum", "preferred", "and", "maximum", "sizes", "." ]
116803c3047d1b32217366757cee1bb3880fda63
https://github.com/opensourceBIM/BIMserver/blob/116803c3047d1b32217366757cee1bb3880fda63/BimServerJar/src/org/bimserver/starter/SpringUtilities.java#L37-L41
17,673
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/dependency/naming/PurlIdentifier.java
PurlIdentifier.toGav
public String toGav() { if (purl.getNamespace() != null && purl.getVersion() != null) { return String.format("%s:%s:%s", purl.getNamespace(), purl.getName(), purl.getVersion()); } return null; }
java
public String toGav() { if (purl.getNamespace() != null && purl.getVersion() != null) { return String.format("%s:%s:%s", purl.getNamespace(), purl.getName(), purl.getVersion()); } return null; }
[ "public", "String", "toGav", "(", ")", "{", "if", "(", "purl", ".", "getNamespace", "(", ")", "!=", "null", "&&", "purl", ".", "getVersion", "(", ")", "!=", "null", ")", "{", "return", "String", ".", "format", "(", "\"%s:%s:%s\"", ",", "purl", ".", "getNamespace", "(", ")", ",", "purl", ".", "getName", "(", ")", ",", "purl", ".", "getVersion", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Returns the GAV representation of the Package URL as utilized in gradle builds. @return the GAV representation of the Package URL
[ "Returns", "the", "GAV", "representation", "of", "the", "Package", "URL", "as", "utilized", "in", "gradle", "builds", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/dependency/naming/PurlIdentifier.java#L206-L211
17,674
jeremylong/DependencyCheck
utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java
XmlUtils.buildSecureSaxParser
public static SAXParser buildSecureSaxParser(InputStream... schemaStream) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException, SAXException { final SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); //setting the following unfortunately breaks reading the old suppression files (version 1). //factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); final SAXParser saxParser = factory.newSAXParser(); saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); saxParser.setProperty(JAXP_SCHEMA_SOURCE, schemaStream); return saxParser; }
java
public static SAXParser buildSecureSaxParser(InputStream... schemaStream) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException, SAXException { final SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); //setting the following unfortunately breaks reading the old suppression files (version 1). //factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); final SAXParser saxParser = factory.newSAXParser(); saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); saxParser.setProperty(JAXP_SCHEMA_SOURCE, schemaStream); return saxParser; }
[ "public", "static", "SAXParser", "buildSecureSaxParser", "(", "InputStream", "...", "schemaStream", ")", "throws", "ParserConfigurationException", ",", "SAXNotRecognizedException", ",", "SAXNotSupportedException", ",", "SAXException", "{", "final", "SAXParserFactory", "factory", "=", "SAXParserFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setNamespaceAware", "(", "true", ")", ";", "factory", ".", "setValidating", "(", "true", ")", ";", "factory", ".", "setFeature", "(", "\"http://apache.org/xml/features/disallow-doctype-decl\"", ",", "true", ")", ";", "factory", ".", "setFeature", "(", "\"http://xml.org/sax/features/external-general-entities\"", ",", "false", ")", ";", "//setting the following unfortunately breaks reading the old suppression files (version 1).", "//factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);", "final", "SAXParser", "saxParser", "=", "factory", ".", "newSAXParser", "(", ")", ";", "saxParser", ".", "setProperty", "(", "JAXP_SCHEMA_LANGUAGE", ",", "W3C_XML_SCHEMA", ")", ";", "saxParser", ".", "setProperty", "(", "JAXP_SCHEMA_SOURCE", ",", "schemaStream", ")", ";", "return", "saxParser", ";", "}" ]
Constructs a validating secure SAX Parser. @param schemaStream One or more inputStreams with the schema(s) that the parser should be able to validate the XML against, one InputStream per schema @return a SAX Parser @throws javax.xml.parsers.ParserConfigurationException is thrown if there is a parser configuration exception @throws org.xml.sax.SAXNotRecognizedException thrown if there is an unrecognized feature @throws org.xml.sax.SAXNotSupportedException thrown if there is a non-supported feature @throws org.xml.sax.SAXException is thrown if there is a org.xml.sax.SAXException
[ "Constructs", "a", "validating", "secure", "SAX", "Parser", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java#L77-L91
17,675
jeremylong/DependencyCheck
utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java
XmlUtils.buildSecureSaxParser
public static SAXParser buildSecureSaxParser() throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException, SAXException { final SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); return factory.newSAXParser(); }
java
public static SAXParser buildSecureSaxParser() throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException, SAXException { final SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); return factory.newSAXParser(); }
[ "public", "static", "SAXParser", "buildSecureSaxParser", "(", ")", "throws", "ParserConfigurationException", ",", "SAXNotRecognizedException", ",", "SAXNotSupportedException", ",", "SAXException", "{", "final", "SAXParserFactory", "factory", "=", "SAXParserFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setFeature", "(", "\"http://apache.org/xml/features/disallow-doctype-decl\"", ",", "true", ")", ";", "factory", ".", "setFeature", "(", "\"http://xml.org/sax/features/external-general-entities\"", ",", "false", ")", ";", "factory", ".", "setFeature", "(", "XMLConstants", ".", "FEATURE_SECURE_PROCESSING", ",", "true", ")", ";", "return", "factory", ".", "newSAXParser", "(", ")", ";", "}" ]
Constructs a secure SAX Parser. @return a SAX Parser @throws javax.xml.parsers.ParserConfigurationException thrown if there is a parser configuration exception @throws org.xml.sax.SAXNotRecognizedException thrown if there is an unrecognized feature @throws org.xml.sax.SAXNotSupportedException thrown if there is a non-supported feature @throws org.xml.sax.SAXException is thrown if there is a org.xml.sax.SAXException
[ "Constructs", "a", "secure", "SAX", "Parser", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java#L131-L138
17,676
jeremylong/DependencyCheck
utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java
XmlUtils.buildSecureDocumentBuilder
public static DocumentBuilder buildSecureDocumentBuilder() throws ParserConfigurationException { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); return factory.newDocumentBuilder(); }
java
public static DocumentBuilder buildSecureDocumentBuilder() throws ParserConfigurationException { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); return factory.newDocumentBuilder(); }
[ "public", "static", "DocumentBuilder", "buildSecureDocumentBuilder", "(", ")", "throws", "ParserConfigurationException", "{", "final", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "factory", ".", "setFeature", "(", "\"http://apache.org/xml/features/disallow-doctype-decl\"", ",", "true", ")", ";", "factory", ".", "setFeature", "(", "\"http://xml.org/sax/features/external-general-entities\"", ",", "false", ")", ";", "factory", ".", "setFeature", "(", "XMLConstants", ".", "FEATURE_SECURE_PROCESSING", ",", "true", ")", ";", "return", "factory", ".", "newDocumentBuilder", "(", ")", ";", "}" ]
Constructs a new document builder with security features enabled. @return a new document builder @throws javax.xml.parsers.ParserConfigurationException thrown if there is a parser configuration exception
[ "Constructs", "a", "new", "document", "builder", "with", "security", "features", "enabled", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java#L147-L153
17,677
jeremylong/DependencyCheck
utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java
XmlUtils.getPrettyParseExceptionInfo
public static String getPrettyParseExceptionInfo(SAXParseException ex) { final StringBuilder sb = new StringBuilder(); if (ex.getSystemId() != null) { sb.append("systemId=").append(ex.getSystemId()).append(", "); } if (ex.getPublicId() != null) { sb.append("publicId=").append(ex.getPublicId()).append(", "); } if (ex.getLineNumber() > 0) { sb.append("Line=").append(ex.getLineNumber()); } if (ex.getColumnNumber() > 0) { sb.append(", Column=").append(ex.getColumnNumber()); } sb.append(": ").append(ex.getMessage()); return sb.toString(); }
java
public static String getPrettyParseExceptionInfo(SAXParseException ex) { final StringBuilder sb = new StringBuilder(); if (ex.getSystemId() != null) { sb.append("systemId=").append(ex.getSystemId()).append(", "); } if (ex.getPublicId() != null) { sb.append("publicId=").append(ex.getPublicId()).append(", "); } if (ex.getLineNumber() > 0) { sb.append("Line=").append(ex.getLineNumber()); } if (ex.getColumnNumber() > 0) { sb.append(", Column=").append(ex.getColumnNumber()); } sb.append(": ").append(ex.getMessage()); return sb.toString(); }
[ "public", "static", "String", "getPrettyParseExceptionInfo", "(", "SAXParseException", "ex", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "ex", ".", "getSystemId", "(", ")", "!=", "null", ")", "{", "sb", ".", "append", "(", "\"systemId=\"", ")", ".", "append", "(", "ex", ".", "getSystemId", "(", ")", ")", ".", "append", "(", "\", \"", ")", ";", "}", "if", "(", "ex", ".", "getPublicId", "(", ")", "!=", "null", ")", "{", "sb", ".", "append", "(", "\"publicId=\"", ")", ".", "append", "(", "ex", ".", "getPublicId", "(", ")", ")", ".", "append", "(", "\", \"", ")", ";", "}", "if", "(", "ex", ".", "getLineNumber", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "\"Line=\"", ")", ".", "append", "(", "ex", ".", "getLineNumber", "(", ")", ")", ";", "}", "if", "(", "ex", ".", "getColumnNumber", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "\", Column=\"", ")", ".", "append", "(", "ex", ".", "getColumnNumber", "(", ")", ")", ";", "}", "sb", ".", "append", "(", "\": \"", ")", ".", "append", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Builds a prettier exception message. @param ex the SAXParseException @return an easier to read exception message
[ "Builds", "a", "prettier", "exception", "message", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/XmlUtils.java#L161-L180
17,678
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java
DatabaseProperties.save
public synchronized void save(NvdCveInfo updatedValue) throws UpdateException { if (updatedValue == null) { return; } save(LAST_UPDATED_BASE + updatedValue.getId(), String.valueOf(updatedValue.getTimestamp())); }
java
public synchronized void save(NvdCveInfo updatedValue) throws UpdateException { if (updatedValue == null) { return; } save(LAST_UPDATED_BASE + updatedValue.getId(), String.valueOf(updatedValue.getTimestamp())); }
[ "public", "synchronized", "void", "save", "(", "NvdCveInfo", "updatedValue", ")", "throws", "UpdateException", "{", "if", "(", "updatedValue", "==", "null", ")", "{", "return", ";", "}", "save", "(", "LAST_UPDATED_BASE", "+", "updatedValue", ".", "getId", "(", ")", ",", "String", ".", "valueOf", "(", "updatedValue", ".", "getTimestamp", "(", ")", ")", ")", ";", "}" ]
Saves the last updated information to the properties file. @param updatedValue the updated NVD CVE entry @throws UpdateException is thrown if there is an update exception
[ "Saves", "the", "last", "updated", "information", "to", "the", "properties", "file", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java#L110-L115
17,679
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java
DatabaseProperties.save
public synchronized void save(String key, String value) throws UpdateException { properties.put(key, value); cveDB.saveProperty(key, value); }
java
public synchronized void save(String key, String value) throws UpdateException { properties.put(key, value); cveDB.saveProperty(key, value); }
[ "public", "synchronized", "void", "save", "(", "String", "key", ",", "String", "value", ")", "throws", "UpdateException", "{", "properties", ".", "put", "(", "key", ",", "value", ")", ";", "cveDB", ".", "saveProperty", "(", "key", ",", "value", ")", ";", "}" ]
Saves the key value pair to the properties store. @param key the property key @param value the property value @throws UpdateException is thrown if there is an update exception
[ "Saves", "the", "key", "value", "pair", "to", "the", "properties", "store", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java#L124-L127
17,680
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java
DatabaseProperties.getMetaData
public synchronized Map<String, String> getMetaData() { final Map<String, String> map = new TreeMap<>(); for (Entry<Object, Object> entry : properties.entrySet()) { final String key = (String) entry.getKey(); if (!"version".equals(key)) { if (key.startsWith("NVD CVE ")) { try { final long epoch = Long.parseLong((String) entry.getValue()); final DateTime date = new DateTime(epoch); final DateTimeFormatter format = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss"); final String formatted = format.print(date); // final Date date = new Date(epoch); // final DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); // final String formatted = format.format(date); map.put(key, formatted); } catch (Throwable ex) { //deliberately being broad in this catch clause LOGGER.debug("Unable to parse timestamp from DB", ex); map.put(key, (String) entry.getValue()); } } else { map.put(key, (String) entry.getValue()); } } } return map; }
java
public synchronized Map<String, String> getMetaData() { final Map<String, String> map = new TreeMap<>(); for (Entry<Object, Object> entry : properties.entrySet()) { final String key = (String) entry.getKey(); if (!"version".equals(key)) { if (key.startsWith("NVD CVE ")) { try { final long epoch = Long.parseLong((String) entry.getValue()); final DateTime date = new DateTime(epoch); final DateTimeFormatter format = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss"); final String formatted = format.print(date); // final Date date = new Date(epoch); // final DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); // final String formatted = format.format(date); map.put(key, formatted); } catch (Throwable ex) { //deliberately being broad in this catch clause LOGGER.debug("Unable to parse timestamp from DB", ex); map.put(key, (String) entry.getValue()); } } else { map.put(key, (String) entry.getValue()); } } } return map; }
[ "public", "synchronized", "Map", "<", "String", ",", "String", ">", "getMetaData", "(", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "TreeMap", "<>", "(", ")", ";", "for", "(", "Entry", "<", "Object", ",", "Object", ">", "entry", ":", "properties", ".", "entrySet", "(", ")", ")", "{", "final", "String", "key", "=", "(", "String", ")", "entry", ".", "getKey", "(", ")", ";", "if", "(", "!", "\"version\"", ".", "equals", "(", "key", ")", ")", "{", "if", "(", "key", ".", "startsWith", "(", "\"NVD CVE \"", ")", ")", "{", "try", "{", "final", "long", "epoch", "=", "Long", ".", "parseLong", "(", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "final", "DateTime", "date", "=", "new", "DateTime", "(", "epoch", ")", ";", "final", "DateTimeFormatter", "format", "=", "DateTimeFormat", ".", "forPattern", "(", "\"dd/MM/yyyy HH:mm:ss\"", ")", ";", "final", "String", "formatted", "=", "format", ".", "print", "(", "date", ")", ";", "// final Date date = new Date(epoch);", "// final DateFormat format = new SimpleDateFormat(\"dd/MM/yyyy HH:mm:ss\");", "// final String formatted = format.format(date);", "map", ".", "put", "(", "key", ",", "formatted", ")", ";", "}", "catch", "(", "Throwable", "ex", ")", "{", "//deliberately being broad in this catch clause", "LOGGER", ".", "debug", "(", "\"Unable to parse timestamp from DB\"", ",", "ex", ")", ";", "map", ".", "put", "(", "key", ",", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "else", "{", "map", ".", "put", "(", "key", ",", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "}", "return", "map", ";", "}" ]
Returns a map of the meta data from the database properties. This primarily contains timestamps of when the NVD CVE information was last updated. @return a map of the database meta data
[ "Returns", "a", "map", "of", "the", "meta", "data", "from", "the", "database", "properties", ".", "This", "primarily", "contains", "timestamps", "of", "when", "the", "NVD", "CVE", "information", "was", "last", "updated", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java#L168-L193
17,681
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/xml/pom/Model.java
Model.processProperties
public void processProperties(Properties properties) { this.groupId = interpolateString(this.groupId, properties); this.artifactId = interpolateString(this.artifactId, properties); this.version = interpolateString(this.version, properties); this.description = interpolateString(this.description, properties); for (License l : this.getLicenses()) { l.setName(interpolateString(l.getName(), properties)); l.setUrl(interpolateString(l.getUrl(), properties)); } this.name = interpolateString(this.name, properties); this.projectURL = interpolateString(this.projectURL, properties); this.organization = interpolateString(this.organization, properties); this.parentGroupId = interpolateString(this.parentGroupId, properties); this.parentArtifactId = interpolateString(this.parentArtifactId, properties); this.parentVersion = interpolateString(this.parentVersion, properties); }
java
public void processProperties(Properties properties) { this.groupId = interpolateString(this.groupId, properties); this.artifactId = interpolateString(this.artifactId, properties); this.version = interpolateString(this.version, properties); this.description = interpolateString(this.description, properties); for (License l : this.getLicenses()) { l.setName(interpolateString(l.getName(), properties)); l.setUrl(interpolateString(l.getUrl(), properties)); } this.name = interpolateString(this.name, properties); this.projectURL = interpolateString(this.projectURL, properties); this.organization = interpolateString(this.organization, properties); this.parentGroupId = interpolateString(this.parentGroupId, properties); this.parentArtifactId = interpolateString(this.parentArtifactId, properties); this.parentVersion = interpolateString(this.parentVersion, properties); }
[ "public", "void", "processProperties", "(", "Properties", "properties", ")", "{", "this", ".", "groupId", "=", "interpolateString", "(", "this", ".", "groupId", ",", "properties", ")", ";", "this", ".", "artifactId", "=", "interpolateString", "(", "this", ".", "artifactId", ",", "properties", ")", ";", "this", ".", "version", "=", "interpolateString", "(", "this", ".", "version", ",", "properties", ")", ";", "this", ".", "description", "=", "interpolateString", "(", "this", ".", "description", ",", "properties", ")", ";", "for", "(", "License", "l", ":", "this", ".", "getLicenses", "(", ")", ")", "{", "l", ".", "setName", "(", "interpolateString", "(", "l", ".", "getName", "(", ")", ",", "properties", ")", ")", ";", "l", ".", "setUrl", "(", "interpolateString", "(", "l", ".", "getUrl", "(", ")", ",", "properties", ")", ")", ";", "}", "this", ".", "name", "=", "interpolateString", "(", "this", ".", "name", ",", "properties", ")", ";", "this", ".", "projectURL", "=", "interpolateString", "(", "this", ".", "projectURL", ",", "properties", ")", ";", "this", ".", "organization", "=", "interpolateString", "(", "this", ".", "organization", ",", "properties", ")", ";", "this", ".", "parentGroupId", "=", "interpolateString", "(", "this", ".", "parentGroupId", ",", "properties", ")", ";", "this", ".", "parentArtifactId", "=", "interpolateString", "(", "this", ".", "parentArtifactId", ",", "properties", ")", ";", "this", ".", "parentVersion", "=", "interpolateString", "(", "this", ".", "parentVersion", ",", "properties", ")", ";", "}" ]
Process the Maven properties file and interpolate all properties. @param properties new value of properties
[ "Process", "the", "Maven", "properties", "file", "and", "interpolate", "all", "properties", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/xml/pom/Model.java#L306-L321
17,682
jeremylong/DependencyCheck
ant/src/main/java/org/owasp/dependencycheck/taskdefs/Update.java
Update.execute
@Override public void execute() throws BuildException { populateSettings(); try (Engine engine = new Engine(Update.class.getClassLoader(), getSettings())) { try { engine.doUpdates(); } catch (UpdateException ex) { if (this.isFailOnError()) { throw new BuildException(ex); } log(ex.getMessage(), Project.MSG_ERR); } } catch (DatabaseException ex) { final String msg = "Unable to connect to the dependency-check database; unable to update the NVD data"; if (this.isFailOnError()) { throw new BuildException(msg, ex); } log(msg, Project.MSG_ERR); } finally { getSettings().cleanup(); } }
java
@Override public void execute() throws BuildException { populateSettings(); try (Engine engine = new Engine(Update.class.getClassLoader(), getSettings())) { try { engine.doUpdates(); } catch (UpdateException ex) { if (this.isFailOnError()) { throw new BuildException(ex); } log(ex.getMessage(), Project.MSG_ERR); } } catch (DatabaseException ex) { final String msg = "Unable to connect to the dependency-check database; unable to update the NVD data"; if (this.isFailOnError()) { throw new BuildException(msg, ex); } log(msg, Project.MSG_ERR); } finally { getSettings().cleanup(); } }
[ "@", "Override", "public", "void", "execute", "(", ")", "throws", "BuildException", "{", "populateSettings", "(", ")", ";", "try", "(", "Engine", "engine", "=", "new", "Engine", "(", "Update", ".", "class", ".", "getClassLoader", "(", ")", ",", "getSettings", "(", ")", ")", ")", "{", "try", "{", "engine", ".", "doUpdates", "(", ")", ";", "}", "catch", "(", "UpdateException", "ex", ")", "{", "if", "(", "this", ".", "isFailOnError", "(", ")", ")", "{", "throw", "new", "BuildException", "(", "ex", ")", ";", "}", "log", "(", "ex", ".", "getMessage", "(", ")", ",", "Project", ".", "MSG_ERR", ")", ";", "}", "}", "catch", "(", "DatabaseException", "ex", ")", "{", "final", "String", "msg", "=", "\"Unable to connect to the dependency-check database; unable to update the NVD data\"", ";", "if", "(", "this", ".", "isFailOnError", "(", ")", ")", "{", "throw", "new", "BuildException", "(", "msg", ",", "ex", ")", ";", "}", "log", "(", "msg", ",", "Project", ".", "MSG_ERR", ")", ";", "}", "finally", "{", "getSettings", "(", ")", ".", "cleanup", "(", ")", ";", "}", "}" ]
Executes the update by initializing the settings, downloads the NVD XML data, and then processes the data storing it in the local database. @throws BuildException thrown if a connection to the local database cannot be made.
[ "Executes", "the", "update", "by", "initializing", "the", "settings", "downloads", "the", "NVD", "XML", "data", "and", "then", "processes", "the", "data", "storing", "it", "in", "the", "local", "database", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/ant/src/main/java/org/owasp/dependencycheck/taskdefs/Update.java#L342-L363
17,683
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java
EngineVersionCheck.update
@Override public boolean update(Engine engine) throws UpdateException { this.settings = engine.getSettings(); try { final CveDB db = engine.getDatabase(); final boolean autoupdate = settings.getBoolean(Settings.KEYS.AUTO_UPDATE, true); final boolean enabled = settings.getBoolean(Settings.KEYS.UPDATE_VERSION_CHECK_ENABLED, true); final String original = settings.getString(Settings.KEYS.CVE_ORIGINAL_JSON); final String current = settings.getString(Settings.KEYS.CVE_MODIFIED_JSON); /* * Only update if auto-update is enabled, the engine check is * enabled, and the NVD CVE URLs have not been modified (i.e. the * user has not configured them to point to an internal source). */ if (enabled && autoupdate && original != null && original.equals(current)) { LOGGER.debug("Begin Engine Version Check"); final DatabaseProperties properties = db.getDatabaseProperties(); final long lastChecked = Long.parseLong(properties.getProperty(ENGINE_VERSION_CHECKED_ON, "0")); final long now = System.currentTimeMillis(); updateToVersion = properties.getProperty(CURRENT_ENGINE_RELEASE, ""); final String currentVersion = settings.getString(Settings.KEYS.APPLICATION_VERSION, "0.0.0"); LOGGER.debug("Last checked: {}", lastChecked); LOGGER.debug("Now: {}", now); LOGGER.debug("Current version: {}", currentVersion); final boolean updateNeeded = shouldUpdate(lastChecked, now, properties, currentVersion); if (updateNeeded) { LOGGER.warn("A new version of dependency-check is available. Consider updating to version {}.", updateToVersion); } } } catch (DatabaseException ex) { LOGGER.debug("Database Exception opening databases to retrieve properties", ex); throw new UpdateException("Error occurred updating database properties."); } catch (InvalidSettingException ex) { LOGGER.debug("Unable to determine if autoupdate is enabled", ex); } return false; }
java
@Override public boolean update(Engine engine) throws UpdateException { this.settings = engine.getSettings(); try { final CveDB db = engine.getDatabase(); final boolean autoupdate = settings.getBoolean(Settings.KEYS.AUTO_UPDATE, true); final boolean enabled = settings.getBoolean(Settings.KEYS.UPDATE_VERSION_CHECK_ENABLED, true); final String original = settings.getString(Settings.KEYS.CVE_ORIGINAL_JSON); final String current = settings.getString(Settings.KEYS.CVE_MODIFIED_JSON); /* * Only update if auto-update is enabled, the engine check is * enabled, and the NVD CVE URLs have not been modified (i.e. the * user has not configured them to point to an internal source). */ if (enabled && autoupdate && original != null && original.equals(current)) { LOGGER.debug("Begin Engine Version Check"); final DatabaseProperties properties = db.getDatabaseProperties(); final long lastChecked = Long.parseLong(properties.getProperty(ENGINE_VERSION_CHECKED_ON, "0")); final long now = System.currentTimeMillis(); updateToVersion = properties.getProperty(CURRENT_ENGINE_RELEASE, ""); final String currentVersion = settings.getString(Settings.KEYS.APPLICATION_VERSION, "0.0.0"); LOGGER.debug("Last checked: {}", lastChecked); LOGGER.debug("Now: {}", now); LOGGER.debug("Current version: {}", currentVersion); final boolean updateNeeded = shouldUpdate(lastChecked, now, properties, currentVersion); if (updateNeeded) { LOGGER.warn("A new version of dependency-check is available. Consider updating to version {}.", updateToVersion); } } } catch (DatabaseException ex) { LOGGER.debug("Database Exception opening databases to retrieve properties", ex); throw new UpdateException("Error occurred updating database properties."); } catch (InvalidSettingException ex) { LOGGER.debug("Unable to determine if autoupdate is enabled", ex); } return false; }
[ "@", "Override", "public", "boolean", "update", "(", "Engine", "engine", ")", "throws", "UpdateException", "{", "this", ".", "settings", "=", "engine", ".", "getSettings", "(", ")", ";", "try", "{", "final", "CveDB", "db", "=", "engine", ".", "getDatabase", "(", ")", ";", "final", "boolean", "autoupdate", "=", "settings", ".", "getBoolean", "(", "Settings", ".", "KEYS", ".", "AUTO_UPDATE", ",", "true", ")", ";", "final", "boolean", "enabled", "=", "settings", ".", "getBoolean", "(", "Settings", ".", "KEYS", ".", "UPDATE_VERSION_CHECK_ENABLED", ",", "true", ")", ";", "final", "String", "original", "=", "settings", ".", "getString", "(", "Settings", ".", "KEYS", ".", "CVE_ORIGINAL_JSON", ")", ";", "final", "String", "current", "=", "settings", ".", "getString", "(", "Settings", ".", "KEYS", ".", "CVE_MODIFIED_JSON", ")", ";", "/*\n * Only update if auto-update is enabled, the engine check is\n * enabled, and the NVD CVE URLs have not been modified (i.e. the\n * user has not configured them to point to an internal source).\n */", "if", "(", "enabled", "&&", "autoupdate", "&&", "original", "!=", "null", "&&", "original", ".", "equals", "(", "current", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Begin Engine Version Check\"", ")", ";", "final", "DatabaseProperties", "properties", "=", "db", ".", "getDatabaseProperties", "(", ")", ";", "final", "long", "lastChecked", "=", "Long", ".", "parseLong", "(", "properties", ".", "getProperty", "(", "ENGINE_VERSION_CHECKED_ON", ",", "\"0\"", ")", ")", ";", "final", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "updateToVersion", "=", "properties", ".", "getProperty", "(", "CURRENT_ENGINE_RELEASE", ",", "\"\"", ")", ";", "final", "String", "currentVersion", "=", "settings", ".", "getString", "(", "Settings", ".", "KEYS", ".", "APPLICATION_VERSION", ",", "\"0.0.0\"", ")", ";", "LOGGER", ".", "debug", "(", "\"Last checked: {}\"", ",", "lastChecked", ")", ";", "LOGGER", ".", "debug", "(", "\"Now: {}\"", ",", "now", ")", ";", "LOGGER", ".", "debug", "(", "\"Current version: {}\"", ",", "currentVersion", ")", ";", "final", "boolean", "updateNeeded", "=", "shouldUpdate", "(", "lastChecked", ",", "now", ",", "properties", ",", "currentVersion", ")", ";", "if", "(", "updateNeeded", ")", "{", "LOGGER", ".", "warn", "(", "\"A new version of dependency-check is available. Consider updating to version {}.\"", ",", "updateToVersion", ")", ";", "}", "}", "}", "catch", "(", "DatabaseException", "ex", ")", "{", "LOGGER", ".", "debug", "(", "\"Database Exception opening databases to retrieve properties\"", ",", "ex", ")", ";", "throw", "new", "UpdateException", "(", "\"Error occurred updating database properties.\"", ")", ";", "}", "catch", "(", "InvalidSettingException", "ex", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to determine if autoupdate is enabled\"", ",", "ex", ")", ";", "}", "return", "false", ";", "}" ]
Downloads the current released version number and compares it to the running engine's version number. If the released version number is newer a warning is printed recommending an upgrade. @return returns false as no updates are made to the database that would require compaction @throws UpdateException thrown if the local database properties could not be updated
[ "Downloads", "the", "current", "released", "version", "number", "and", "compares", "it", "to", "the", "running", "engine", "s", "version", "number", ".", "If", "the", "released", "version", "number", "is", "newer", "a", "warning", "is", "printed", "recommending", "an", "upgrade", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java#L119-L158
17,684
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java
EngineVersionCheck.shouldUpdate
protected boolean shouldUpdate(final long lastChecked, final long now, final DatabaseProperties properties, String currentVersion) throws UpdateException { //check every 30 days if we know there is an update, otherwise check every 7 days final int checkRange = 30; if (!DateUtil.withinDateRange(lastChecked, now, checkRange)) { LOGGER.debug("Checking web for new version."); final String currentRelease = getCurrentReleaseVersion(); if (currentRelease != null) { final DependencyVersion v = new DependencyVersion(currentRelease); if (v.getVersionParts() != null && v.getVersionParts().size() >= 3) { updateToVersion = v.toString(); if (!currentRelease.equals(updateToVersion)) { properties.save(CURRENT_ENGINE_RELEASE, updateToVersion); } properties.save(ENGINE_VERSION_CHECKED_ON, Long.toString(now)); } } LOGGER.debug("Current Release: {}", updateToVersion); } if (updateToVersion == null) { LOGGER.debug("Unable to obtain current release"); return false; } final DependencyVersion running = new DependencyVersion(currentVersion); final DependencyVersion released = new DependencyVersion(updateToVersion); if (running.compareTo(released) < 0) { LOGGER.debug("Upgrade recommended"); return true; } LOGGER.debug("Upgrade not needed"); return false; }
java
protected boolean shouldUpdate(final long lastChecked, final long now, final DatabaseProperties properties, String currentVersion) throws UpdateException { //check every 30 days if we know there is an update, otherwise check every 7 days final int checkRange = 30; if (!DateUtil.withinDateRange(lastChecked, now, checkRange)) { LOGGER.debug("Checking web for new version."); final String currentRelease = getCurrentReleaseVersion(); if (currentRelease != null) { final DependencyVersion v = new DependencyVersion(currentRelease); if (v.getVersionParts() != null && v.getVersionParts().size() >= 3) { updateToVersion = v.toString(); if (!currentRelease.equals(updateToVersion)) { properties.save(CURRENT_ENGINE_RELEASE, updateToVersion); } properties.save(ENGINE_VERSION_CHECKED_ON, Long.toString(now)); } } LOGGER.debug("Current Release: {}", updateToVersion); } if (updateToVersion == null) { LOGGER.debug("Unable to obtain current release"); return false; } final DependencyVersion running = new DependencyVersion(currentVersion); final DependencyVersion released = new DependencyVersion(updateToVersion); if (running.compareTo(released) < 0) { LOGGER.debug("Upgrade recommended"); return true; } LOGGER.debug("Upgrade not needed"); return false; }
[ "protected", "boolean", "shouldUpdate", "(", "final", "long", "lastChecked", ",", "final", "long", "now", ",", "final", "DatabaseProperties", "properties", ",", "String", "currentVersion", ")", "throws", "UpdateException", "{", "//check every 30 days if we know there is an update, otherwise check every 7 days", "final", "int", "checkRange", "=", "30", ";", "if", "(", "!", "DateUtil", ".", "withinDateRange", "(", "lastChecked", ",", "now", ",", "checkRange", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Checking web for new version.\"", ")", ";", "final", "String", "currentRelease", "=", "getCurrentReleaseVersion", "(", ")", ";", "if", "(", "currentRelease", "!=", "null", ")", "{", "final", "DependencyVersion", "v", "=", "new", "DependencyVersion", "(", "currentRelease", ")", ";", "if", "(", "v", ".", "getVersionParts", "(", ")", "!=", "null", "&&", "v", ".", "getVersionParts", "(", ")", ".", "size", "(", ")", ">=", "3", ")", "{", "updateToVersion", "=", "v", ".", "toString", "(", ")", ";", "if", "(", "!", "currentRelease", ".", "equals", "(", "updateToVersion", ")", ")", "{", "properties", ".", "save", "(", "CURRENT_ENGINE_RELEASE", ",", "updateToVersion", ")", ";", "}", "properties", ".", "save", "(", "ENGINE_VERSION_CHECKED_ON", ",", "Long", ".", "toString", "(", "now", ")", ")", ";", "}", "}", "LOGGER", ".", "debug", "(", "\"Current Release: {}\"", ",", "updateToVersion", ")", ";", "}", "if", "(", "updateToVersion", "==", "null", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to obtain current release\"", ")", ";", "return", "false", ";", "}", "final", "DependencyVersion", "running", "=", "new", "DependencyVersion", "(", "currentVersion", ")", ";", "final", "DependencyVersion", "released", "=", "new", "DependencyVersion", "(", "updateToVersion", ")", ";", "if", "(", "running", ".", "compareTo", "(", "released", ")", "<", "0", ")", "{", "LOGGER", ".", "debug", "(", "\"Upgrade recommended\"", ")", ";", "return", "true", ";", "}", "LOGGER", ".", "debug", "(", "\"Upgrade not needed\"", ")", ";", "return", "false", ";", "}" ]
Determines if a new version of the dependency-check engine has been released. @param lastChecked the epoch time of the last version check @param now the current epoch time @param properties the database properties object @param currentVersion the current version of dependency-check @return <code>true</code> if a newer version of the database has been released; otherwise <code>false</code> @throws UpdateException thrown if there is an error connecting to the github documentation site or accessing the local database.
[ "Determines", "if", "a", "new", "version", "of", "the", "dependency", "-", "check", "engine", "has", "been", "released", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java#L173-L204
17,685
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java
EngineVersionCheck.getCurrentReleaseVersion
protected String getCurrentReleaseVersion() { HttpURLConnection conn = null; try { final String str = settings.getString(Settings.KEYS.ENGINE_VERSION_CHECK_URL, "http://jeremylong.github.io/DependencyCheck/current.txt"); final URL url = new URL(str); final URLConnectionFactory factory = new URLConnectionFactory(settings); conn = factory.createHttpURLConnection(url); conn.connect(); if (conn.getResponseCode() != 200) { return null; } final String releaseVersion = IOUtils.toString(conn.getInputStream(), StandardCharsets.UTF_8); if (releaseVersion != null) { return releaseVersion.trim(); } } catch (MalformedURLException ex) { LOGGER.debug("Unable to retrieve current release version of dependency-check - malformed url?"); } catch (URLConnectionFailureException ex) { LOGGER.debug("Unable to retrieve current release version of dependency-check - connection failed"); } catch (IOException ex) { LOGGER.debug("Unable to retrieve current release version of dependency-check - i/o exception"); } finally { if (conn != null) { conn.disconnect(); } } return null; }
java
protected String getCurrentReleaseVersion() { HttpURLConnection conn = null; try { final String str = settings.getString(Settings.KEYS.ENGINE_VERSION_CHECK_URL, "http://jeremylong.github.io/DependencyCheck/current.txt"); final URL url = new URL(str); final URLConnectionFactory factory = new URLConnectionFactory(settings); conn = factory.createHttpURLConnection(url); conn.connect(); if (conn.getResponseCode() != 200) { return null; } final String releaseVersion = IOUtils.toString(conn.getInputStream(), StandardCharsets.UTF_8); if (releaseVersion != null) { return releaseVersion.trim(); } } catch (MalformedURLException ex) { LOGGER.debug("Unable to retrieve current release version of dependency-check - malformed url?"); } catch (URLConnectionFailureException ex) { LOGGER.debug("Unable to retrieve current release version of dependency-check - connection failed"); } catch (IOException ex) { LOGGER.debug("Unable to retrieve current release version of dependency-check - i/o exception"); } finally { if (conn != null) { conn.disconnect(); } } return null; }
[ "protected", "String", "getCurrentReleaseVersion", "(", ")", "{", "HttpURLConnection", "conn", "=", "null", ";", "try", "{", "final", "String", "str", "=", "settings", ".", "getString", "(", "Settings", ".", "KEYS", ".", "ENGINE_VERSION_CHECK_URL", ",", "\"http://jeremylong.github.io/DependencyCheck/current.txt\"", ")", ";", "final", "URL", "url", "=", "new", "URL", "(", "str", ")", ";", "final", "URLConnectionFactory", "factory", "=", "new", "URLConnectionFactory", "(", "settings", ")", ";", "conn", "=", "factory", ".", "createHttpURLConnection", "(", "url", ")", ";", "conn", ".", "connect", "(", ")", ";", "if", "(", "conn", ".", "getResponseCode", "(", ")", "!=", "200", ")", "{", "return", "null", ";", "}", "final", "String", "releaseVersion", "=", "IOUtils", ".", "toString", "(", "conn", ".", "getInputStream", "(", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "if", "(", "releaseVersion", "!=", "null", ")", "{", "return", "releaseVersion", ".", "trim", "(", ")", ";", "}", "}", "catch", "(", "MalformedURLException", "ex", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to retrieve current release version of dependency-check - malformed url?\"", ")", ";", "}", "catch", "(", "URLConnectionFailureException", "ex", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to retrieve current release version of dependency-check - connection failed\"", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to retrieve current release version of dependency-check - i/o exception\"", ")", ";", "}", "finally", "{", "if", "(", "conn", "!=", "null", ")", "{", "conn", ".", "disconnect", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Retrieves the current released version number from the github documentation site. @return the current released version number
[ "Retrieves", "the", "current", "released", "version", "number", "from", "the", "github", "documentation", "site", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/update/EngineVersionCheck.java#L212-L239
17,686
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchFieldAnalyzer.java
SearchFieldAnalyzer.getStopWords
public static CharArraySet getStopWords() { final CharArraySet words = StopFilter.makeStopSet(ADDITIONAL_STOP_WORDS, true); words.addAll(EnglishAnalyzer.ENGLISH_STOP_WORDS_SET); return words; }
java
public static CharArraySet getStopWords() { final CharArraySet words = StopFilter.makeStopSet(ADDITIONAL_STOP_WORDS, true); words.addAll(EnglishAnalyzer.ENGLISH_STOP_WORDS_SET); return words; }
[ "public", "static", "CharArraySet", "getStopWords", "(", ")", "{", "final", "CharArraySet", "words", "=", "StopFilter", ".", "makeStopSet", "(", "ADDITIONAL_STOP_WORDS", ",", "true", ")", ";", "words", ".", "addAll", "(", "EnglishAnalyzer", ".", "ENGLISH_STOP_WORDS_SET", ")", ";", "return", "words", ";", "}" ]
Returns the set of stop words being used. @return the set of stop words being used
[ "Returns", "the", "set", "of", "stop", "words", "being", "used", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchFieldAnalyzer.java#L57-L61
17,687
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchFieldAnalyzer.java
SearchFieldAnalyzer.createComponents
@Override protected TokenStreamComponents createComponents(String fieldName) { //final Tokenizer source = new AlphaNumericTokenizer(); final Tokenizer source = new WhitespaceTokenizer(); TokenStream stream = source; stream = new UrlTokenizingFilter(stream); stream = new AlphaNumericFilter(stream); stream = new WordDelimiterGraphFilter(stream, WordDelimiterGraphFilter.GENERATE_WORD_PARTS //| WordDelimiterGraphFilter.GENERATE_NUMBER_PARTS | WordDelimiterGraphFilter.PRESERVE_ORIGINAL | WordDelimiterGraphFilter.SPLIT_ON_CASE_CHANGE | WordDelimiterGraphFilter.SPLIT_ON_NUMERICS | WordDelimiterGraphFilter.STEM_ENGLISH_POSSESSIVE, null); stream = new LowerCaseFilter(stream); stream = new StopFilter(stream, stopWords); concatenatingFilter = new TokenPairConcatenatingFilter(stream); return new TokenStreamComponents(source, concatenatingFilter); }
java
@Override protected TokenStreamComponents createComponents(String fieldName) { //final Tokenizer source = new AlphaNumericTokenizer(); final Tokenizer source = new WhitespaceTokenizer(); TokenStream stream = source; stream = new UrlTokenizingFilter(stream); stream = new AlphaNumericFilter(stream); stream = new WordDelimiterGraphFilter(stream, WordDelimiterGraphFilter.GENERATE_WORD_PARTS //| WordDelimiterGraphFilter.GENERATE_NUMBER_PARTS | WordDelimiterGraphFilter.PRESERVE_ORIGINAL | WordDelimiterGraphFilter.SPLIT_ON_CASE_CHANGE | WordDelimiterGraphFilter.SPLIT_ON_NUMERICS | WordDelimiterGraphFilter.STEM_ENGLISH_POSSESSIVE, null); stream = new LowerCaseFilter(stream); stream = new StopFilter(stream, stopWords); concatenatingFilter = new TokenPairConcatenatingFilter(stream); return new TokenStreamComponents(source, concatenatingFilter); }
[ "@", "Override", "protected", "TokenStreamComponents", "createComponents", "(", "String", "fieldName", ")", "{", "//final Tokenizer source = new AlphaNumericTokenizer();", "final", "Tokenizer", "source", "=", "new", "WhitespaceTokenizer", "(", ")", ";", "TokenStream", "stream", "=", "source", ";", "stream", "=", "new", "UrlTokenizingFilter", "(", "stream", ")", ";", "stream", "=", "new", "AlphaNumericFilter", "(", "stream", ")", ";", "stream", "=", "new", "WordDelimiterGraphFilter", "(", "stream", ",", "WordDelimiterGraphFilter", ".", "GENERATE_WORD_PARTS", "//| WordDelimiterGraphFilter.GENERATE_NUMBER_PARTS", "|", "WordDelimiterGraphFilter", ".", "PRESERVE_ORIGINAL", "|", "WordDelimiterGraphFilter", ".", "SPLIT_ON_CASE_CHANGE", "|", "WordDelimiterGraphFilter", ".", "SPLIT_ON_NUMERICS", "|", "WordDelimiterGraphFilter", ".", "STEM_ENGLISH_POSSESSIVE", ",", "null", ")", ";", "stream", "=", "new", "LowerCaseFilter", "(", "stream", ")", ";", "stream", "=", "new", "StopFilter", "(", "stream", ",", "stopWords", ")", ";", "concatenatingFilter", "=", "new", "TokenPairConcatenatingFilter", "(", "stream", ")", ";", "return", "new", "TokenStreamComponents", "(", "source", ",", "concatenatingFilter", ")", ";", "}" ]
Creates a the TokenStreamComponents used to analyze the stream. @param fieldName the field that this lucene analyzer will process @return the token stream filter chain
[ "Creates", "a", "the", "TokenStreamComponents", "used", "to", "analyze", "the", "stream", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/data/lucene/SearchFieldAnalyzer.java#L77-L99
17,688
jeremylong/DependencyCheck
utils/src/main/java/org/owasp/dependencycheck/utils/SSLSocketFactoryEx.java
SSLSocketFactoryEx.initSSLSocketFactoryEx
private void initSSLSocketFactoryEx(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws NoSuchAlgorithmException, KeyManagementException { sslCtxt = SSLContext.getInstance("TLS"); sslCtxt.init(km, tm, random); protocols = getProtocolList(); }
java
private void initSSLSocketFactoryEx(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws NoSuchAlgorithmException, KeyManagementException { sslCtxt = SSLContext.getInstance("TLS"); sslCtxt.init(km, tm, random); protocols = getProtocolList(); }
[ "private", "void", "initSSLSocketFactoryEx", "(", "KeyManager", "[", "]", "km", ",", "TrustManager", "[", "]", "tm", ",", "SecureRandom", "random", ")", "throws", "NoSuchAlgorithmException", ",", "KeyManagementException", "{", "sslCtxt", "=", "SSLContext", ".", "getInstance", "(", "\"TLS\"", ")", ";", "sslCtxt", ".", "init", "(", "km", ",", "tm", ",", "random", ")", ";", "protocols", "=", "getProtocolList", "(", ")", ";", "}" ]
Initializes the SSL Socket Factory Extension. @param km the key managers @param tm the trust managers @param random the secure random number generator @throws NoSuchAlgorithmException thrown when an algorithm is not supported @throws KeyManagementException thrown if initialization fails
[ "Initializes", "the", "SSL", "Socket", "Factory", "Extension", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/SSLSocketFactoryEx.java#L226-L232
17,689
jeremylong/DependencyCheck
utils/src/main/java/org/owasp/dependencycheck/utils/SSLSocketFactoryEx.java
SSLSocketFactoryEx.getProtocolList
@SuppressWarnings("StringSplitter") protected String[] getProtocolList() { SSLSocket socket = null; String[] availableProtocols = null; final String[] preferredProtocols = settings.getString( Settings.KEYS.DOWNLOADER_TLS_PROTOCOL_LIST, "TLSv1.1,TLSv1.2,TLSv1.3") .split(","); try { final SSLSocketFactory factory = sslCtxt.getSocketFactory(); socket = (SSLSocket) factory.createSocket(); availableProtocols = socket.getSupportedProtocols(); Arrays.sort(availableProtocols); if (LOGGER.isDebugEnabled() && !protocolsLogged) { protocolsLogged = true; LOGGER.debug("Available Protocols:"); for (String p : availableProtocols) { LOGGER.debug(p); } } } catch (Exception ex) { LOGGER.debug("Error getting protocol list, using TLSv1.1-1.3", ex); return new String[]{"TLSv1.1", "TLSv1.2", "TLSv1.3"}; } finally { if (socket != null) { try { socket.close(); } catch (IOException ex) { LOGGER.trace("Error closing socket", ex); } } } final List<String> aa = new ArrayList<>(); for (String preferredProtocol : preferredProtocols) { final int idx = Arrays.binarySearch(availableProtocols, preferredProtocol); if (idx >= 0) { aa.add(preferredProtocol); } } return aa.toArray(new String[0]); }
java
@SuppressWarnings("StringSplitter") protected String[] getProtocolList() { SSLSocket socket = null; String[] availableProtocols = null; final String[] preferredProtocols = settings.getString( Settings.KEYS.DOWNLOADER_TLS_PROTOCOL_LIST, "TLSv1.1,TLSv1.2,TLSv1.3") .split(","); try { final SSLSocketFactory factory = sslCtxt.getSocketFactory(); socket = (SSLSocket) factory.createSocket(); availableProtocols = socket.getSupportedProtocols(); Arrays.sort(availableProtocols); if (LOGGER.isDebugEnabled() && !protocolsLogged) { protocolsLogged = true; LOGGER.debug("Available Protocols:"); for (String p : availableProtocols) { LOGGER.debug(p); } } } catch (Exception ex) { LOGGER.debug("Error getting protocol list, using TLSv1.1-1.3", ex); return new String[]{"TLSv1.1", "TLSv1.2", "TLSv1.3"}; } finally { if (socket != null) { try { socket.close(); } catch (IOException ex) { LOGGER.trace("Error closing socket", ex); } } } final List<String> aa = new ArrayList<>(); for (String preferredProtocol : preferredProtocols) { final int idx = Arrays.binarySearch(availableProtocols, preferredProtocol); if (idx >= 0) { aa.add(preferredProtocol); } } return aa.toArray(new String[0]); }
[ "@", "SuppressWarnings", "(", "\"StringSplitter\"", ")", "protected", "String", "[", "]", "getProtocolList", "(", ")", "{", "SSLSocket", "socket", "=", "null", ";", "String", "[", "]", "availableProtocols", "=", "null", ";", "final", "String", "[", "]", "preferredProtocols", "=", "settings", ".", "getString", "(", "Settings", ".", "KEYS", ".", "DOWNLOADER_TLS_PROTOCOL_LIST", ",", "\"TLSv1.1,TLSv1.2,TLSv1.3\"", ")", ".", "split", "(", "\",\"", ")", ";", "try", "{", "final", "SSLSocketFactory", "factory", "=", "sslCtxt", ".", "getSocketFactory", "(", ")", ";", "socket", "=", "(", "SSLSocket", ")", "factory", ".", "createSocket", "(", ")", ";", "availableProtocols", "=", "socket", ".", "getSupportedProtocols", "(", ")", ";", "Arrays", ".", "sort", "(", "availableProtocols", ")", ";", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", "&&", "!", "protocolsLogged", ")", "{", "protocolsLogged", "=", "true", ";", "LOGGER", ".", "debug", "(", "\"Available Protocols:\"", ")", ";", "for", "(", "String", "p", ":", "availableProtocols", ")", "{", "LOGGER", ".", "debug", "(", "p", ")", ";", "}", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "LOGGER", ".", "debug", "(", "\"Error getting protocol list, using TLSv1.1-1.3\"", ",", "ex", ")", ";", "return", "new", "String", "[", "]", "{", "\"TLSv1.1\"", ",", "\"TLSv1.2\"", ",", "\"TLSv1.3\"", "}", ";", "}", "finally", "{", "if", "(", "socket", "!=", "null", ")", "{", "try", "{", "socket", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "LOGGER", ".", "trace", "(", "\"Error closing socket\"", ",", "ex", ")", ";", "}", "}", "}", "final", "List", "<", "String", ">", "aa", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "preferredProtocol", ":", "preferredProtocols", ")", "{", "final", "int", "idx", "=", "Arrays", ".", "binarySearch", "(", "availableProtocols", ",", "preferredProtocol", ")", ";", "if", "(", "idx", ">=", "0", ")", "{", "aa", ".", "add", "(", "preferredProtocol", ")", ";", "}", "}", "return", "aa", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "}" ]
Returns the protocol list. @return the protocol list
[ "Returns", "the", "protocol", "list", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/SSLSocketFactoryEx.java#L253-L296
17,690
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/utils/Filter.java
Filter.filter
public Iterable<T> filter(final Iterable<T> iterable) { return new Iterable<T>() { @Override public Iterator<T> iterator() { return filter(iterable.iterator()); } }; }
java
public Iterable<T> filter(final Iterable<T> iterable) { return new Iterable<T>() { @Override public Iterator<T> iterator() { return filter(iterable.iterator()); } }; }
[ "public", "Iterable", "<", "T", ">", "filter", "(", "final", "Iterable", "<", "T", ">", "iterable", ")", "{", "return", "new", "Iterable", "<", "T", ">", "(", ")", "{", "@", "Override", "public", "Iterator", "<", "T", ">", "iterator", "(", ")", "{", "return", "filter", "(", "iterable", ".", "iterator", "(", ")", ")", ";", "}", "}", ";", "}" ]
Filters a given iterable. @param iterable the iterable to filter @return the filtered iterable
[ "Filters", "a", "given", "iterable", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/utils/Filter.java#L45-L53
17,691
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.cpeIdentifiersMatch
private boolean cpeIdentifiersMatch(Dependency dependency1, Dependency dependency2) { if (dependency1 == null || dependency1.getVulnerableSoftwareIdentifiers() == null || dependency2 == null || dependency2.getVulnerableSoftwareIdentifiers() == null) { return false; } boolean matches = false; final int cpeCount1 = dependency1.getVulnerableSoftwareIdentifiers().size(); final int cpeCount2 = dependency2.getVulnerableSoftwareIdentifiers().size(); if (cpeCount1 > 0 && cpeCount1 == cpeCount2) { for (Identifier i : dependency1.getVulnerableSoftwareIdentifiers()) { matches |= dependency2.getVulnerableSoftwareIdentifiers().contains(i); if (!matches) { break; } } } LOGGER.debug("IdentifiersMatch={} ({}, {})", matches, dependency1.getFileName(), dependency2.getFileName()); return matches; }
java
private boolean cpeIdentifiersMatch(Dependency dependency1, Dependency dependency2) { if (dependency1 == null || dependency1.getVulnerableSoftwareIdentifiers() == null || dependency2 == null || dependency2.getVulnerableSoftwareIdentifiers() == null) { return false; } boolean matches = false; final int cpeCount1 = dependency1.getVulnerableSoftwareIdentifiers().size(); final int cpeCount2 = dependency2.getVulnerableSoftwareIdentifiers().size(); if (cpeCount1 > 0 && cpeCount1 == cpeCount2) { for (Identifier i : dependency1.getVulnerableSoftwareIdentifiers()) { matches |= dependency2.getVulnerableSoftwareIdentifiers().contains(i); if (!matches) { break; } } } LOGGER.debug("IdentifiersMatch={} ({}, {})", matches, dependency1.getFileName(), dependency2.getFileName()); return matches; }
[ "private", "boolean", "cpeIdentifiersMatch", "(", "Dependency", "dependency1", ",", "Dependency", "dependency2", ")", "{", "if", "(", "dependency1", "==", "null", "||", "dependency1", ".", "getVulnerableSoftwareIdentifiers", "(", ")", "==", "null", "||", "dependency2", "==", "null", "||", "dependency2", ".", "getVulnerableSoftwareIdentifiers", "(", ")", "==", "null", ")", "{", "return", "false", ";", "}", "boolean", "matches", "=", "false", ";", "final", "int", "cpeCount1", "=", "dependency1", ".", "getVulnerableSoftwareIdentifiers", "(", ")", ".", "size", "(", ")", ";", "final", "int", "cpeCount2", "=", "dependency2", ".", "getVulnerableSoftwareIdentifiers", "(", ")", ".", "size", "(", ")", ";", "if", "(", "cpeCount1", ">", "0", "&&", "cpeCount1", "==", "cpeCount2", ")", "{", "for", "(", "Identifier", "i", ":", "dependency1", ".", "getVulnerableSoftwareIdentifiers", "(", ")", ")", "{", "matches", "|=", "dependency2", ".", "getVulnerableSoftwareIdentifiers", "(", ")", ".", "contains", "(", "i", ")", ";", "if", "(", "!", "matches", ")", "{", "break", ";", "}", "}", "}", "LOGGER", ".", "debug", "(", "\"IdentifiersMatch={} ({}, {})\"", ",", "matches", ",", "dependency1", ".", "getFileName", "(", ")", ",", "dependency2", ".", "getFileName", "(", ")", ")", ";", "return", "matches", ";", "}" ]
Returns true if the CPE identifiers in the two supplied dependencies are equal. @param dependency1 a dependency2 to compare @param dependency2 a dependency2 to compare @return true if the identifiers in the two supplied dependencies are equal
[ "Returns", "true", "if", "the", "CPE", "identifiers", "in", "the", "two", "supplied", "dependencies", "are", "equal", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L258-L276
17,692
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.vulnerabilitiesMatch
private boolean vulnerabilitiesMatch(Dependency dependency1, Dependency dependency2) { final Set<Vulnerability> one = dependency1.getVulnerabilities(); final Set<Vulnerability> two = dependency2.getVulnerabilities(); return one != null && two != null && one.size() == two.size() && one.containsAll(two); }
java
private boolean vulnerabilitiesMatch(Dependency dependency1, Dependency dependency2) { final Set<Vulnerability> one = dependency1.getVulnerabilities(); final Set<Vulnerability> two = dependency2.getVulnerabilities(); return one != null && two != null && one.size() == two.size() && one.containsAll(two); }
[ "private", "boolean", "vulnerabilitiesMatch", "(", "Dependency", "dependency1", ",", "Dependency", "dependency2", ")", "{", "final", "Set", "<", "Vulnerability", ">", "one", "=", "dependency1", ".", "getVulnerabilities", "(", ")", ";", "final", "Set", "<", "Vulnerability", ">", "two", "=", "dependency2", ".", "getVulnerabilities", "(", ")", ";", "return", "one", "!=", "null", "&&", "two", "!=", "null", "&&", "one", ".", "size", "(", ")", "==", "two", ".", "size", "(", ")", "&&", "one", ".", "containsAll", "(", "two", ")", ";", "}" ]
Returns true if the two dependencies have the same vulnerabilities. @param dependency1 a dependency2 to compare @param dependency2 a dependency2 to compare @return true if the two dependencies have the same vulnerabilities
[ "Returns", "true", "if", "the", "two", "dependencies", "have", "the", "same", "vulnerabilities", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L285-L291
17,693
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.hasSameBasePath
private boolean hasSameBasePath(Dependency dependency1, Dependency dependency2) { if (dependency1 == null || dependency2 == null) { return false; } final File lFile = new File(dependency1.getFilePath()); String left = lFile.getParent(); final File rFile = new File(dependency2.getFilePath()); String right = rFile.getParent(); if (left == null) { return right == null; } else if (right == null) { return false; } if (left.equalsIgnoreCase(right)) { return true; } if (left.matches(".*[/\\\\](repository|local-repo)[/\\\\].*") && right.matches(".*[/\\\\](repository|local-repo)[/\\\\].*")) { left = getBaseRepoPath(left); right = getBaseRepoPath(right); } if (left.equalsIgnoreCase(right)) { return true; } //new code for (Dependency child : dependency2.getRelatedDependencies()) { if (hasSameBasePath(child, dependency1)) { return true; } } return false; }
java
private boolean hasSameBasePath(Dependency dependency1, Dependency dependency2) { if (dependency1 == null || dependency2 == null) { return false; } final File lFile = new File(dependency1.getFilePath()); String left = lFile.getParent(); final File rFile = new File(dependency2.getFilePath()); String right = rFile.getParent(); if (left == null) { return right == null; } else if (right == null) { return false; } if (left.equalsIgnoreCase(right)) { return true; } if (left.matches(".*[/\\\\](repository|local-repo)[/\\\\].*") && right.matches(".*[/\\\\](repository|local-repo)[/\\\\].*")) { left = getBaseRepoPath(left); right = getBaseRepoPath(right); } if (left.equalsIgnoreCase(right)) { return true; } //new code for (Dependency child : dependency2.getRelatedDependencies()) { if (hasSameBasePath(child, dependency1)) { return true; } } return false; }
[ "private", "boolean", "hasSameBasePath", "(", "Dependency", "dependency1", ",", "Dependency", "dependency2", ")", "{", "if", "(", "dependency1", "==", "null", "||", "dependency2", "==", "null", ")", "{", "return", "false", ";", "}", "final", "File", "lFile", "=", "new", "File", "(", "dependency1", ".", "getFilePath", "(", ")", ")", ";", "String", "left", "=", "lFile", ".", "getParent", "(", ")", ";", "final", "File", "rFile", "=", "new", "File", "(", "dependency2", ".", "getFilePath", "(", ")", ")", ";", "String", "right", "=", "rFile", ".", "getParent", "(", ")", ";", "if", "(", "left", "==", "null", ")", "{", "return", "right", "==", "null", ";", "}", "else", "if", "(", "right", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "left", ".", "equalsIgnoreCase", "(", "right", ")", ")", "{", "return", "true", ";", "}", "if", "(", "left", ".", "matches", "(", "\".*[/\\\\\\\\](repository|local-repo)[/\\\\\\\\].*\"", ")", "&&", "right", ".", "matches", "(", "\".*[/\\\\\\\\](repository|local-repo)[/\\\\\\\\].*\"", ")", ")", "{", "left", "=", "getBaseRepoPath", "(", "left", ")", ";", "right", "=", "getBaseRepoPath", "(", "right", ")", ";", "}", "if", "(", "left", ".", "equalsIgnoreCase", "(", "right", ")", ")", "{", "return", "true", ";", "}", "//new code", "for", "(", "Dependency", "child", ":", "dependency2", ".", "getRelatedDependencies", "(", ")", ")", "{", "if", "(", "hasSameBasePath", "(", "child", ",", "dependency1", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determines if the two dependencies have the same base path. @param dependency1 a Dependency object @param dependency2 a Dependency object @return true if the base paths of the dependencies are identical
[ "Determines", "if", "the", "two", "dependencies", "have", "the", "same", "base", "path", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L300-L331
17,694
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.isCore
protected boolean isCore(Dependency left, Dependency right) { final String leftName = left.getFileName().toLowerCase(); final String rightName = right.getFileName().toLowerCase(); final boolean returnVal; //TODO - should we get rid of this merging? It removes a true BOM... if (left.isVirtual() && !right.isVirtual()) { returnVal = true; } else if (!left.isVirtual() && right.isVirtual()) { returnVal = false; } else if ((!rightName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+") && leftName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+")) || (rightName.contains("core") && !leftName.contains("core")) || (rightName.contains("kernel") && !leftName.contains("kernel")) || (rightName.contains("akka-stream") && !leftName.contains("akka-stream")) || (rightName.contains("netty-transport") && !leftName.contains("netty-transport"))) { returnVal = false; } else if ((rightName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+") && !leftName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+")) || (!rightName.contains("core") && leftName.contains("core")) || (!rightName.contains("kernel") && leftName.contains("kernel")) || (!rightName.contains("akka-stream") && leftName.contains("akka-stream")) || (!rightName.contains("netty-transport") && leftName.contains("netty-transport"))) { returnVal = true; } else { /* * considered splitting the names up and comparing the components, * but decided that the file name length should be sufficient as the * "core" component, if this follows a normal naming protocol should * be shorter: * axis2-saaj-1.4.1.jar * axis2-1.4.1.jar <----- * axis2-kernel-1.4.1.jar */ returnVal = leftName.length() <= rightName.length(); } LOGGER.debug("IsCore={} ({}, {})", returnVal, left.getFileName(), right.getFileName()); return returnVal; }
java
protected boolean isCore(Dependency left, Dependency right) { final String leftName = left.getFileName().toLowerCase(); final String rightName = right.getFileName().toLowerCase(); final boolean returnVal; //TODO - should we get rid of this merging? It removes a true BOM... if (left.isVirtual() && !right.isVirtual()) { returnVal = true; } else if (!left.isVirtual() && right.isVirtual()) { returnVal = false; } else if ((!rightName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+") && leftName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+")) || (rightName.contains("core") && !leftName.contains("core")) || (rightName.contains("kernel") && !leftName.contains("kernel")) || (rightName.contains("akka-stream") && !leftName.contains("akka-stream")) || (rightName.contains("netty-transport") && !leftName.contains("netty-transport"))) { returnVal = false; } else if ((rightName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+") && !leftName.matches(".*\\.(tar|tgz|gz|zip|ear|war).+")) || (!rightName.contains("core") && leftName.contains("core")) || (!rightName.contains("kernel") && leftName.contains("kernel")) || (!rightName.contains("akka-stream") && leftName.contains("akka-stream")) || (!rightName.contains("netty-transport") && leftName.contains("netty-transport"))) { returnVal = true; } else { /* * considered splitting the names up and comparing the components, * but decided that the file name length should be sufficient as the * "core" component, if this follows a normal naming protocol should * be shorter: * axis2-saaj-1.4.1.jar * axis2-1.4.1.jar <----- * axis2-kernel-1.4.1.jar */ returnVal = leftName.length() <= rightName.length(); } LOGGER.debug("IsCore={} ({}, {})", returnVal, left.getFileName(), right.getFileName()); return returnVal; }
[ "protected", "boolean", "isCore", "(", "Dependency", "left", ",", "Dependency", "right", ")", "{", "final", "String", "leftName", "=", "left", ".", "getFileName", "(", ")", ".", "toLowerCase", "(", ")", ";", "final", "String", "rightName", "=", "right", ".", "getFileName", "(", ")", ".", "toLowerCase", "(", ")", ";", "final", "boolean", "returnVal", ";", "//TODO - should we get rid of this merging? It removes a true BOM...", "if", "(", "left", ".", "isVirtual", "(", ")", "&&", "!", "right", ".", "isVirtual", "(", ")", ")", "{", "returnVal", "=", "true", ";", "}", "else", "if", "(", "!", "left", ".", "isVirtual", "(", ")", "&&", "right", ".", "isVirtual", "(", ")", ")", "{", "returnVal", "=", "false", ";", "}", "else", "if", "(", "(", "!", "rightName", ".", "matches", "(", "\".*\\\\.(tar|tgz|gz|zip|ear|war).+\"", ")", "&&", "leftName", ".", "matches", "(", "\".*\\\\.(tar|tgz|gz|zip|ear|war).+\"", ")", ")", "||", "(", "rightName", ".", "contains", "(", "\"core\"", ")", "&&", "!", "leftName", ".", "contains", "(", "\"core\"", ")", ")", "||", "(", "rightName", ".", "contains", "(", "\"kernel\"", ")", "&&", "!", "leftName", ".", "contains", "(", "\"kernel\"", ")", ")", "||", "(", "rightName", ".", "contains", "(", "\"akka-stream\"", ")", "&&", "!", "leftName", ".", "contains", "(", "\"akka-stream\"", ")", ")", "||", "(", "rightName", ".", "contains", "(", "\"netty-transport\"", ")", "&&", "!", "leftName", ".", "contains", "(", "\"netty-transport\"", ")", ")", ")", "{", "returnVal", "=", "false", ";", "}", "else", "if", "(", "(", "rightName", ".", "matches", "(", "\".*\\\\.(tar|tgz|gz|zip|ear|war).+\"", ")", "&&", "!", "leftName", ".", "matches", "(", "\".*\\\\.(tar|tgz|gz|zip|ear|war).+\"", ")", ")", "||", "(", "!", "rightName", ".", "contains", "(", "\"core\"", ")", "&&", "leftName", ".", "contains", "(", "\"core\"", ")", ")", "||", "(", "!", "rightName", ".", "contains", "(", "\"kernel\"", ")", "&&", "leftName", ".", "contains", "(", "\"kernel\"", ")", ")", "||", "(", "!", "rightName", ".", "contains", "(", "\"akka-stream\"", ")", "&&", "leftName", ".", "contains", "(", "\"akka-stream\"", ")", ")", "||", "(", "!", "rightName", ".", "contains", "(", "\"netty-transport\"", ")", "&&", "leftName", ".", "contains", "(", "\"netty-transport\"", ")", ")", ")", "{", "returnVal", "=", "true", ";", "}", "else", "{", "/*\n * considered splitting the names up and comparing the components,\n * but decided that the file name length should be sufficient as the\n * \"core\" component, if this follows a normal naming protocol should\n * be shorter:\n * axis2-saaj-1.4.1.jar\n * axis2-1.4.1.jar <-----\n * axis2-kernel-1.4.1.jar\n */", "returnVal", "=", "leftName", ".", "length", "(", ")", "<=", "rightName", ".", "length", "(", ")", ";", "}", "LOGGER", ".", "debug", "(", "\"IsCore={} ({}, {})\"", ",", "returnVal", ",", "left", ".", "getFileName", "(", ")", ",", "right", ".", "getFileName", "(", ")", ")", ";", "return", "returnVal", ";", "}" ]
This is likely a very broken attempt at determining if the 'left' dependency is the 'core' library in comparison to the 'right' library. @param left the dependency to test @param right the dependency to test against @return a boolean indicating whether or not the left dependency should be considered the "core" version.
[ "This", "is", "likely", "a", "very", "broken", "attempt", "at", "determining", "if", "the", "left", "dependency", "is", "the", "core", "library", "in", "comparison", "to", "the", "right", "library", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L342-L379
17,695
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.hashesMatch
private boolean hashesMatch(Dependency dependency1, Dependency dependency2) { if (dependency1 == null || dependency2 == null || dependency1.getSha1sum() == null || dependency2.getSha1sum() == null) { return false; } return dependency1.getSha1sum().equals(dependency2.getSha1sum()); }
java
private boolean hashesMatch(Dependency dependency1, Dependency dependency2) { if (dependency1 == null || dependency2 == null || dependency1.getSha1sum() == null || dependency2.getSha1sum() == null) { return false; } return dependency1.getSha1sum().equals(dependency2.getSha1sum()); }
[ "private", "boolean", "hashesMatch", "(", "Dependency", "dependency1", ",", "Dependency", "dependency2", ")", "{", "if", "(", "dependency1", "==", "null", "||", "dependency2", "==", "null", "||", "dependency1", ".", "getSha1sum", "(", ")", "==", "null", "||", "dependency2", ".", "getSha1sum", "(", ")", "==", "null", ")", "{", "return", "false", ";", "}", "return", "dependency1", ".", "getSha1sum", "(", ")", ".", "equals", "(", "dependency2", ".", "getSha1sum", "(", ")", ")", ";", "}" ]
Compares the SHA1 hashes of two dependencies to determine if they are equal. @param dependency1 a dependency object to compare @param dependency2 a dependency object to compare @return true if the sha1 hashes of the two dependencies match; otherwise false
[ "Compares", "the", "SHA1", "hashes", "of", "two", "dependencies", "to", "determine", "if", "they", "are", "equal", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L390-L395
17,696
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.isShadedJar
protected boolean isShadedJar(Dependency dependency, Dependency nextDependency) { if (dependency == null || dependency.getFileName() == null || nextDependency == null || nextDependency.getFileName() == null || dependency.getSoftwareIdentifiers().isEmpty() || nextDependency.getSoftwareIdentifiers().isEmpty()) { return false; } final String mainName = dependency.getFileName().toLowerCase(); final String nextName = nextDependency.getFileName().toLowerCase(); if (mainName.endsWith(".jar") && nextName.endsWith("pom.xml")) { return dependency.getSoftwareIdentifiers().containsAll(nextDependency.getSoftwareIdentifiers()); } else if (nextName.endsWith(".jar") && mainName.endsWith("pom.xml")) { return nextDependency.getSoftwareIdentifiers().containsAll(dependency.getSoftwareIdentifiers()); } return false; }
java
protected boolean isShadedJar(Dependency dependency, Dependency nextDependency) { if (dependency == null || dependency.getFileName() == null || nextDependency == null || nextDependency.getFileName() == null || dependency.getSoftwareIdentifiers().isEmpty() || nextDependency.getSoftwareIdentifiers().isEmpty()) { return false; } final String mainName = dependency.getFileName().toLowerCase(); final String nextName = nextDependency.getFileName().toLowerCase(); if (mainName.endsWith(".jar") && nextName.endsWith("pom.xml")) { return dependency.getSoftwareIdentifiers().containsAll(nextDependency.getSoftwareIdentifiers()); } else if (nextName.endsWith(".jar") && mainName.endsWith("pom.xml")) { return nextDependency.getSoftwareIdentifiers().containsAll(dependency.getSoftwareIdentifiers()); } return false; }
[ "protected", "boolean", "isShadedJar", "(", "Dependency", "dependency", ",", "Dependency", "nextDependency", ")", "{", "if", "(", "dependency", "==", "null", "||", "dependency", ".", "getFileName", "(", ")", "==", "null", "||", "nextDependency", "==", "null", "||", "nextDependency", ".", "getFileName", "(", ")", "==", "null", "||", "dependency", ".", "getSoftwareIdentifiers", "(", ")", ".", "isEmpty", "(", ")", "||", "nextDependency", ".", "getSoftwareIdentifiers", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "final", "String", "mainName", "=", "dependency", ".", "getFileName", "(", ")", ".", "toLowerCase", "(", ")", ";", "final", "String", "nextName", "=", "nextDependency", ".", "getFileName", "(", ")", ".", "toLowerCase", "(", ")", ";", "if", "(", "mainName", ".", "endsWith", "(", "\".jar\"", ")", "&&", "nextName", ".", "endsWith", "(", "\"pom.xml\"", ")", ")", "{", "return", "dependency", ".", "getSoftwareIdentifiers", "(", ")", ".", "containsAll", "(", "nextDependency", ".", "getSoftwareIdentifiers", "(", ")", ")", ";", "}", "else", "if", "(", "nextName", ".", "endsWith", "(", "\".jar\"", ")", "&&", "mainName", ".", "endsWith", "(", "\"pom.xml\"", ")", ")", "{", "return", "nextDependency", ".", "getSoftwareIdentifiers", "(", ")", ".", "containsAll", "(", "dependency", ".", "getSoftwareIdentifiers", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
Determines if the jar is shaded and the created pom.xml identified the same CPE as the jar - if so, the pom.xml dependency should be removed. @param dependency a dependency to check @param nextDependency another dependency to check @return true if on of the dependencies is a pom.xml and the identifiers between the two collections match; otherwise false
[ "Determines", "if", "the", "jar", "is", "shaded", "and", "the", "created", "pom", ".", "xml", "identified", "the", "same", "CPE", "as", "the", "jar", "-", "if", "so", "the", "pom", ".", "xml", "dependency", "should", "be", "removed", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L406-L421
17,697
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.countChar
private int countChar(String string, char c) { int count = 0; final int max = string.length(); for (int i = 0; i < max; i++) { if (c == string.charAt(i)) { count++; } } return count; }
java
private int countChar(String string, char c) { int count = 0; final int max = string.length(); for (int i = 0; i < max; i++) { if (c == string.charAt(i)) { count++; } } return count; }
[ "private", "int", "countChar", "(", "String", "string", ",", "char", "c", ")", "{", "int", "count", "=", "0", ";", "final", "int", "max", "=", "string", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "max", ";", "i", "++", ")", "{", "if", "(", "c", "==", "string", ".", "charAt", "(", "i", ")", ")", "{", "count", "++", ";", "}", "}", "return", "count", ";", "}" ]
Counts the number of times the character is present in the string. @param string the string to count the characters in @param c the character to count @return the number of times the character is present in the string
[ "Counts", "the", "number", "of", "times", "the", "character", "is", "present", "in", "the", "string", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L455-L464
17,698
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.ecoSystemIs
private boolean ecoSystemIs(String ecoSystem, Dependency dependency, Dependency nextDependency) { return ecoSystem.equals(dependency.getEcosystem()) && ecoSystem.equals(nextDependency.getEcosystem()); }
java
private boolean ecoSystemIs(String ecoSystem, Dependency dependency, Dependency nextDependency) { return ecoSystem.equals(dependency.getEcosystem()) && ecoSystem.equals(nextDependency.getEcosystem()); }
[ "private", "boolean", "ecoSystemIs", "(", "String", "ecoSystem", ",", "Dependency", "dependency", ",", "Dependency", "nextDependency", ")", "{", "return", "ecoSystem", ".", "equals", "(", "dependency", ".", "getEcosystem", "(", ")", ")", "&&", "ecoSystem", ".", "equals", "(", "nextDependency", ".", "getEcosystem", "(", ")", ")", ";", "}" ]
Determine if the dependency ecosystem is equal in the given dependencies. @param ecoSystem the ecosystem to validate against @param dependency a dependency to compare @param nextDependency a dependency to compare @return true if the ecosystem is equal in both dependencies; otherwise false
[ "Determine", "if", "the", "dependency", "ecosystem", "is", "equal", "in", "the", "given", "dependencies", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L485-L487
17,699
jeremylong/DependencyCheck
core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
DependencyBundlingAnalyzer.namesAreEqual
private boolean namesAreEqual(Dependency dependency, Dependency nextDependency) { return dependency.getName() != null && dependency.getName().equals(nextDependency.getName()); }
java
private boolean namesAreEqual(Dependency dependency, Dependency nextDependency) { return dependency.getName() != null && dependency.getName().equals(nextDependency.getName()); }
[ "private", "boolean", "namesAreEqual", "(", "Dependency", "dependency", ",", "Dependency", "nextDependency", ")", "{", "return", "dependency", ".", "getName", "(", ")", "!=", "null", "&&", "dependency", ".", "getName", "(", ")", ".", "equals", "(", "nextDependency", ".", "getName", "(", ")", ")", ";", "}" ]
Determine if the dependency name is equal in the given dependencies. @param dependency a dependency to compare @param nextDependency a dependency to compare @return true if the name is equal in both dependencies; otherwise false
[ "Determine", "if", "the", "dependency", "name", "is", "equal", "in", "the", "given", "dependencies", "." ]
6cc7690ea12e4ca1454210ceaa2e9a5523f0926c
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L496-L498