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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
reinert/requestor | requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java | SerdesManagerImpl.getSerializer | @SuppressWarnings("unchecked")
public <T> Serializer<T> getSerializer(Class<T> type, String mediaType) throws SerializationException {
checkNotNull(type, "Type (Class<T>) cannot be null.");
checkNotNull(mediaType, "Media-Type cannot be null.");
final String typeName = getClassName(type);
final Key key = new Key(typeName, mediaType);
logger.log(Level.FINE, "Querying for Serializer of type '" + typeName + "' and " + "media-type '" + mediaType
+ "'.");
ArrayList<SerializerHolder> holders = serializers.get(typeName);
if (holders != null) {
for (SerializerHolder holder : holders) {
if (holder.key.matches(key)) {
logger.log(Level.FINE, "Serializer for type '" + holder.serializer.handledType() + "' and " +
"media-type '" + Arrays.toString(holder.serializer.mediaType()) + "' matched: " +
holder.serializer.getClass().getName());
return (Serializer<T>) holder.serializer;
}
}
}
logger.log(Level.WARNING, "There is no Serializer registered for type " + type.getName() +
" and media-type " + mediaType + ". If you're relying on auto-generated serializers," +
" please make sure you imported the correct GWT Module.");
return null;
} | java | @SuppressWarnings("unchecked")
public <T> Serializer<T> getSerializer(Class<T> type, String mediaType) throws SerializationException {
checkNotNull(type, "Type (Class<T>) cannot be null.");
checkNotNull(mediaType, "Media-Type cannot be null.");
final String typeName = getClassName(type);
final Key key = new Key(typeName, mediaType);
logger.log(Level.FINE, "Querying for Serializer of type '" + typeName + "' and " + "media-type '" + mediaType
+ "'.");
ArrayList<SerializerHolder> holders = serializers.get(typeName);
if (holders != null) {
for (SerializerHolder holder : holders) {
if (holder.key.matches(key)) {
logger.log(Level.FINE, "Serializer for type '" + holder.serializer.handledType() + "' and " +
"media-type '" + Arrays.toString(holder.serializer.mediaType()) + "' matched: " +
holder.serializer.getClass().getName());
return (Serializer<T>) holder.serializer;
}
}
}
logger.log(Level.WARNING, "There is no Serializer registered for type " + type.getName() +
" and media-type " + mediaType + ". If you're relying on auto-generated serializers," +
" please make sure you imported the correct GWT Module.");
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"Serializer",
"<",
"T",
">",
"getSerializer",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"mediaType",
")",
"throws",
"SerializationException",
"{",
"checkNotNull",
"(",
"ty... | Retrieve Serializer from manager.
@param type The type class of the serializer.
@param <T> The type of the serializer.
@return The serializer of the specified type.
@throws SerializationException if no serializer was registered for the class. | [
"Retrieve",
"Serializer",
"from",
"manager",
"."
] | 40163a75cd17815d5089935d0dd97b8d652ad6d4 | https://github.com/reinert/requestor/blob/40163a75cd17815d5089935d0dd97b8d652ad6d4/requestor/core/requestor-api/src/main/java/io/reinert/requestor/SerdesManagerImpl.java#L190-L218 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DataTableConversionUtility.java | DataTableConversionUtility.loadData | private RecordList loadData(AbstractDataTable table, DataSchema schema) {
RecordListBuilder recordListBuilder = new RecordListBuilder(RecordListBuilder.CompressionMode.CANONICAL, schema);
// simple check to ensure schema and table definitions are aligned
if(schema.size()!= table.getNumberOfColumns()){
final IllegalArgumentException illegalArgumentException = new IllegalArgumentException("schema row definition do not match table supplied");
logger.log(SEVERE,"Warning:", illegalArgumentException);
}
int columnLength = table.getNumberOfColumns();
// for each row
for (int rowIndex = 0; rowIndex < table.getNumberOfRows(); rowIndex++) {
//for each column
String[] fields = new String[columnLength];
for (int columnIndex = 0; columnIndex < columnLength; columnIndex++) {
if(table.getColumnType(columnIndex) == AbstractDataTable.ColumnType.DATE){
Date valueDate = table.getValueDate(rowIndex, columnIndex);
if(valueDate == null){ continue; }
String dateFormatted = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.ISO_8601).format(valueDate);
fields[columnIndex] = dateFormatted;
}else{
fields[columnIndex] = table.getFormattedValue(rowIndex, columnIndex);
}
}
recordListBuilder.addRecord((fields));
}
String dataSourceHash = "";
return recordListBuilder.createRecordList(dataSourceHash);
} | java | private RecordList loadData(AbstractDataTable table, DataSchema schema) {
RecordListBuilder recordListBuilder = new RecordListBuilder(RecordListBuilder.CompressionMode.CANONICAL, schema);
// simple check to ensure schema and table definitions are aligned
if(schema.size()!= table.getNumberOfColumns()){
final IllegalArgumentException illegalArgumentException = new IllegalArgumentException("schema row definition do not match table supplied");
logger.log(SEVERE,"Warning:", illegalArgumentException);
}
int columnLength = table.getNumberOfColumns();
// for each row
for (int rowIndex = 0; rowIndex < table.getNumberOfRows(); rowIndex++) {
//for each column
String[] fields = new String[columnLength];
for (int columnIndex = 0; columnIndex < columnLength; columnIndex++) {
if(table.getColumnType(columnIndex) == AbstractDataTable.ColumnType.DATE){
Date valueDate = table.getValueDate(rowIndex, columnIndex);
if(valueDate == null){ continue; }
String dateFormatted = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.ISO_8601).format(valueDate);
fields[columnIndex] = dateFormatted;
}else{
fields[columnIndex] = table.getFormattedValue(rowIndex, columnIndex);
}
}
recordListBuilder.addRecord((fields));
}
String dataSourceHash = "";
return recordListBuilder.createRecordList(dataSourceHash);
} | [
"private",
"RecordList",
"loadData",
"(",
"AbstractDataTable",
"table",
",",
"DataSchema",
"schema",
")",
"{",
"RecordListBuilder",
"recordListBuilder",
"=",
"new",
"RecordListBuilder",
"(",
"RecordListBuilder",
".",
"CompressionMode",
".",
"CANONICAL",
",",
"schema",
... | Given a schema, attempts to load table into internal structure
@param table the existing DataTable/DataView containing rows to load into RecordList | [
"Given",
"a",
"schema",
"attempts",
"to",
"load",
"table",
"into",
"internal",
"structure"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DataTableConversionUtility.java#L58-L85 | train |
lightblue-platform/lightblue-client | http/src/main/java/com/redhat/lightblue/client/http/auth/SslSocketFactories.java | SslSocketFactories.createNaiveTrustManager | private static TrustManager createNaiveTrustManager() {
return new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
} | java | private static TrustManager createNaiveTrustManager() {
return new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
} | [
"private",
"static",
"TrustManager",
"createNaiveTrustManager",
"(",
")",
"{",
"return",
"new",
"X509TrustManager",
"(",
")",
"{",
"public",
"void",
"checkClientTrusted",
"(",
"X509Certificate",
"[",
"]",
"chain",
",",
"String",
"authType",
")",
"throws",
"Certifi... | Naive trust manager trusts all. | [
"Naive",
"trust",
"manager",
"trusts",
"all",
"."
] | 03790aff34e90d3889f60fd6c603c21a21dc1a40 | https://github.com/lightblue-platform/lightblue-client/blob/03790aff34e90d3889f60fd6c603c21a21dc1a40/http/src/main/java/com/redhat/lightblue/client/http/auth/SslSocketFactories.java#L137-L149 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/AbstractYuiSliderGwtWidgetWithLabelMarkers.java | AbstractYuiSliderGwtWidgetWithLabelMarkers.onLoad | @Override
protected void onLoad() {
mainAbsolutePanel.setSize(
String.valueOf(yuiSliderGwtWidget.getOffsetWidth()),
String.valueOf(yuiSliderGwtWidget.getOffsetHeight())
);
setupMarkerLabels();
} | java | @Override
protected void onLoad() {
mainAbsolutePanel.setSize(
String.valueOf(yuiSliderGwtWidget.getOffsetWidth()),
String.valueOf(yuiSliderGwtWidget.getOffsetHeight())
);
setupMarkerLabels();
} | [
"@",
"Override",
"protected",
"void",
"onLoad",
"(",
")",
"{",
"mainAbsolutePanel",
".",
"setSize",
"(",
"String",
".",
"valueOf",
"(",
"yuiSliderGwtWidget",
".",
"getOffsetWidth",
"(",
")",
")",
",",
"String",
".",
"valueOf",
"(",
"yuiSliderGwtWidget",
".",
... | override onLoad to know when absolutePanel's size can be set | [
"override",
"onLoad",
"to",
"know",
"when",
"absolutePanel",
"s",
"size",
"can",
"be",
"set"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/AbstractYuiSliderGwtWidgetWithLabelMarkers.java#L67-L77 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgSaver.java | MsgSaver.urlCheckAndSave | public void urlCheckAndSave(BasicCheckInfo basicCheckInfo, ParamType paramType, ReqUrl reqUrl, Class<?> type) {
if (!this.validationConfig.isFreshUrlSave() || !basicCheckInfo.isUrlMapping()) {
return;
}
List<ValidationData> datas = this.validationDataRepository.findByParamTypeAndMethodAndUrl(paramType, reqUrl.getMethod(), reqUrl.getUrl());
if (datas.isEmpty()) {
this.saveParameter(basicCheckInfo.getDetailParam(), paramType, reqUrl, null, type, 0, this.validationConfig.getMaxDeepLevel());
this.validationDataRepository.flush();
this.validationStore.refresh();
}
} | java | public void urlCheckAndSave(BasicCheckInfo basicCheckInfo, ParamType paramType, ReqUrl reqUrl, Class<?> type) {
if (!this.validationConfig.isFreshUrlSave() || !basicCheckInfo.isUrlMapping()) {
return;
}
List<ValidationData> datas = this.validationDataRepository.findByParamTypeAndMethodAndUrl(paramType, reqUrl.getMethod(), reqUrl.getUrl());
if (datas.isEmpty()) {
this.saveParameter(basicCheckInfo.getDetailParam(), paramType, reqUrl, null, type, 0, this.validationConfig.getMaxDeepLevel());
this.validationDataRepository.flush();
this.validationStore.refresh();
}
} | [
"public",
"void",
"urlCheckAndSave",
"(",
"BasicCheckInfo",
"basicCheckInfo",
",",
"ParamType",
"paramType",
",",
"ReqUrl",
"reqUrl",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"!",
"this",
".",
"validationConfig",
".",
"isFreshUrlSave",
"(",
... | Url check and save.
@param basicCheckInfo the basic check info
@param paramType the param type
@param reqUrl the req url
@param type the type | [
"Url",
"check",
"and",
"save",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgSaver.java#L74-L85 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/map/MapBuilder.java | MapBuilder.configureMapDimension | public MapBuilder configureMapDimension(Integer width, Integer height) {
this.mapHeight = height;
this.mapWidth = width;
return this;
} | java | public MapBuilder configureMapDimension(Integer width, Integer height) {
this.mapHeight = height;
this.mapWidth = width;
return this;
} | [
"public",
"MapBuilder",
"configureMapDimension",
"(",
"Integer",
"width",
",",
"Integer",
"height",
")",
"{",
"this",
".",
"mapHeight",
"=",
"height",
";",
"this",
".",
"mapWidth",
"=",
"width",
";",
"return",
"this",
";",
"}"
] | Setup map display properties
@param width value in px
@param height value in px | [
"Setup",
"map",
"display",
"properties"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/map/MapBuilder.java#L100-L104 | train |
OpenCompare/OpenCompare | org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java | ImportMatrixLoader.detectTypes | protected void detectTypes(ImportMatrix matrix) {
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
ImportCell cell = matrix.getCell(row, column);
if (cell != null && cell.getInterpretation() == null) {
cell.setInterpretation(cellContentInterpreter.interpretString(cell.getContent()));
}
}
}
} | java | protected void detectTypes(ImportMatrix matrix) {
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
ImportCell cell = matrix.getCell(row, column);
if (cell != null && cell.getInterpretation() == null) {
cell.setInterpretation(cellContentInterpreter.interpretString(cell.getContent()));
}
}
}
} | [
"protected",
"void",
"detectTypes",
"(",
"ImportMatrix",
"matrix",
")",
"{",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"matrix",
".",
"getNumberOfRows",
"(",
")",
";",
"row",
"++",
")",
"{",
"for",
"(",
"int",
"column",
"=",
"0",
";",
"c... | Detect types of each cell of the matrix
@param matrix matrix | [
"Detect",
"types",
"of",
"each",
"cell",
"of",
"the",
"matrix"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java#L90-L101 | train |
OpenCompare/OpenCompare | org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java | ImportMatrixLoader.detectDirection | protected PCMDirection detectDirection(ImportMatrix matrix) {
// Compute homogeneity of rows
double sumHomogeneityOfRow = 0;
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
Map<String, Integer> types = new HashMap<>();
// Retrieve types of values
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
countType(matrix, row, column, types);
}
// Get the maximum proportion of a same type
if (!types.isEmpty()) {
double homogeneityOfRow = Collections.max(types.values()) / (double) matrix.getNumberOfColumns();
sumHomogeneityOfRow += homogeneityOfRow;
}
}
// Compute homogeneity of columns
double homogeneityOfColumns = 0;
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
Map<String, Integer> types = new HashMap<>();
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
countType(matrix, row, column, types);
}
// Get the maximum proportion of a same type
if (!types.isEmpty()) {
double homogeneityOfColumn = Collections.max(types.values()) / (double) matrix.getNumberOfRows();
homogeneityOfColumns += homogeneityOfColumn;
}
}
if (sumHomogeneityOfRow / matrix.getNumberOfRows() > homogeneityOfColumns / matrix.getNumberOfColumns()) {
return PCMDirection.PRODUCTS_AS_COLUMNS;
} else {
return PCMDirection.PRODUCTS_AS_LINES;
}
} | java | protected PCMDirection detectDirection(ImportMatrix matrix) {
// Compute homogeneity of rows
double sumHomogeneityOfRow = 0;
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
Map<String, Integer> types = new HashMap<>();
// Retrieve types of values
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
countType(matrix, row, column, types);
}
// Get the maximum proportion of a same type
if (!types.isEmpty()) {
double homogeneityOfRow = Collections.max(types.values()) / (double) matrix.getNumberOfColumns();
sumHomogeneityOfRow += homogeneityOfRow;
}
}
// Compute homogeneity of columns
double homogeneityOfColumns = 0;
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
Map<String, Integer> types = new HashMap<>();
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
countType(matrix, row, column, types);
}
// Get the maximum proportion of a same type
if (!types.isEmpty()) {
double homogeneityOfColumn = Collections.max(types.values()) / (double) matrix.getNumberOfRows();
homogeneityOfColumns += homogeneityOfColumn;
}
}
if (sumHomogeneityOfRow / matrix.getNumberOfRows() > homogeneityOfColumns / matrix.getNumberOfColumns()) {
return PCMDirection.PRODUCTS_AS_COLUMNS;
} else {
return PCMDirection.PRODUCTS_AS_LINES;
}
} | [
"protected",
"PCMDirection",
"detectDirection",
"(",
"ImportMatrix",
"matrix",
")",
"{",
"// Compute homogeneity of rows",
"double",
"sumHomogeneityOfRow",
"=",
"0",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"matrix",
".",
"getNumberOfRows",
"(",
... | Detect if products are represented by a line or a column
@param matrix matrix
@return direction of the matrix | [
"Detect",
"if",
"products",
"are",
"represented",
"by",
"a",
"line",
"or",
"a",
"column"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java#L108-L151 | train |
OpenCompare/OpenCompare | org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java | ImportMatrixLoader.detectFeatures | protected IONode<String> detectFeatures(ImportMatrix matrix, PCMContainer pcmContainer) {
IONode<String> root = new IONode<>(null);
List<IONode<String>> parents = new ArrayList<>();
// Init parents
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
parents.add(root);
}
// Detect features
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
List<IONode<String>> nextParents = new ArrayList<>(parents);
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
IOCell currentCell = matrix.getCell(row, column);
if (currentCell == null) {
currentCell = new IOCell("");
}
IONode<String> parent = parents.get(column);
boolean sameAsParent = currentCell.getContent().equals(parent.getContent());
boolean sameAsPrevious = false;
boolean sameParentAsPrevious = true;
if (column > 0) {
IOCell previousCell = matrix.getCell(row, column - 1);
if (previousCell == null) {
previousCell = new IOCell("");
}
sameAsPrevious = currentCell.getContent().equals(previousCell.getContent());
if (parent.getContent() != null) {
sameParentAsPrevious = parent.getContent().equals(parents.get(column - 1).getContent());
}
}
if (!sameAsParent && (!sameParentAsPrevious || !sameAsPrevious)) {
IONode<String> newNode = new IONode<>(currentCell.getContent());
newNode.getPositions().add(column);
parent.getChildren().add(newNode);
nextParents.set(column, newNode);
} else if (column > 0 && sameParentAsPrevious && sameAsPrevious) {
IONode<String> previousNode = nextParents.get(column - 1);
previousNode.getPositions().add(column);
nextParents.set(column, previousNode);
}
}
parents = nextParents;
// If number of getLeaves == number of rows : break;
if (root.getLeaves().size() == matrix.getNumberOfColumns()) {
break;
}
}
return root;
} | java | protected IONode<String> detectFeatures(ImportMatrix matrix, PCMContainer pcmContainer) {
IONode<String> root = new IONode<>(null);
List<IONode<String>> parents = new ArrayList<>();
// Init parents
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
parents.add(root);
}
// Detect features
for (int row = 0; row < matrix.getNumberOfRows(); row++) {
List<IONode<String>> nextParents = new ArrayList<>(parents);
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
IOCell currentCell = matrix.getCell(row, column);
if (currentCell == null) {
currentCell = new IOCell("");
}
IONode<String> parent = parents.get(column);
boolean sameAsParent = currentCell.getContent().equals(parent.getContent());
boolean sameAsPrevious = false;
boolean sameParentAsPrevious = true;
if (column > 0) {
IOCell previousCell = matrix.getCell(row, column - 1);
if (previousCell == null) {
previousCell = new IOCell("");
}
sameAsPrevious = currentCell.getContent().equals(previousCell.getContent());
if (parent.getContent() != null) {
sameParentAsPrevious = parent.getContent().equals(parents.get(column - 1).getContent());
}
}
if (!sameAsParent && (!sameParentAsPrevious || !sameAsPrevious)) {
IONode<String> newNode = new IONode<>(currentCell.getContent());
newNode.getPositions().add(column);
parent.getChildren().add(newNode);
nextParents.set(column, newNode);
} else if (column > 0 && sameParentAsPrevious && sameAsPrevious) {
IONode<String> previousNode = nextParents.get(column - 1);
previousNode.getPositions().add(column);
nextParents.set(column, previousNode);
}
}
parents = nextParents;
// If number of getLeaves == number of rows : break;
if (root.getLeaves().size() == matrix.getNumberOfColumns()) {
break;
}
}
return root;
} | [
"protected",
"IONode",
"<",
"String",
">",
"detectFeatures",
"(",
"ImportMatrix",
"matrix",
",",
"PCMContainer",
"pcmContainer",
")",
"{",
"IONode",
"<",
"String",
">",
"root",
"=",
"new",
"IONode",
"<>",
"(",
"null",
")",
";",
"List",
"<",
"IONode",
"<",
... | Detect features from the information contained in the matrix and the provided direction
@param matrix matrix
@param pcmContainer PCM container
@return graph representing the hierarchy of features | [
"Detect",
"features",
"from",
"the",
"information",
"contained",
"in",
"the",
"matrix",
"and",
"the",
"provided",
"direction"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java#L172-L235 | train |
OpenCompare/OpenCompare | org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java | ImportMatrixLoader.createProducts | protected void createProducts(ImportMatrix matrix, PCMContainer pcmContainer, Map<Integer, Feature> positionToFeature) {
int featuresDepth = pcmContainer.getPcm().getFeaturesDepth();
for (int row = featuresDepth; row < matrix.getNumberOfRows(); row++) {
Product product = factory.createProduct();
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
Cell cell = factory.createCell();
cell.setFeature(positionToFeature.get(column));
ImportCell ioCell = matrix.getCell(row, column);
if (ioCell == null) {
ioCell = new ImportCell("");
}
cell.setContent(ioCell.getContent());
cell.setRawContent(ioCell.getRawContent());
cell.setInterpretation(ioCell.getInterpretation());
product.addCell(cell);
}
pcmContainer.getPcm().addProduct(product);
pcmContainer.getMetadata().setProductPosition(product, row);
}
} | java | protected void createProducts(ImportMatrix matrix, PCMContainer pcmContainer, Map<Integer, Feature> positionToFeature) {
int featuresDepth = pcmContainer.getPcm().getFeaturesDepth();
for (int row = featuresDepth; row < matrix.getNumberOfRows(); row++) {
Product product = factory.createProduct();
for (int column = 0; column < matrix.getNumberOfColumns(); column++) {
Cell cell = factory.createCell();
cell.setFeature(positionToFeature.get(column));
ImportCell ioCell = matrix.getCell(row, column);
if (ioCell == null) {
ioCell = new ImportCell("");
}
cell.setContent(ioCell.getContent());
cell.setRawContent(ioCell.getRawContent());
cell.setInterpretation(ioCell.getInterpretation());
product.addCell(cell);
}
pcmContainer.getPcm().addProduct(product);
pcmContainer.getMetadata().setProductPosition(product, row);
}
} | [
"protected",
"void",
"createProducts",
"(",
"ImportMatrix",
"matrix",
",",
"PCMContainer",
"pcmContainer",
",",
"Map",
"<",
"Integer",
",",
"Feature",
">",
"positionToFeature",
")",
"{",
"int",
"featuresDepth",
"=",
"pcmContainer",
".",
"getPcm",
"(",
")",
".",
... | Detect and create products from the information contained in the matrix and the provided direction
@param matrix matrix
@param pcmContainer PCM container
@param positionToFeature map between positions and features | [
"Detect",
"and",
"create",
"products",
"from",
"the",
"information",
"contained",
"in",
"the",
"matrix",
"and",
"the",
"provided",
"direction"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/api-java/src/main/java/org/opencompare/api/java/io/ImportMatrixLoader.java#L270-L298 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationHttpUtil.java | ValidationHttpUtil.readBody | public static String readBody(HttpServletRequest request) {
BufferedReader input = null;
try {
input = new BufferedReader(new InputStreamReader(request.getInputStream()));
StringBuilder builder = new StringBuilder();
String buffer;
while ((buffer = input.readLine()) != null) {
if (builder.length() > 0) {
builder.append("\n");
}
builder.append(buffer);
}
return builder.toString();
} catch (IOException e) {
log.info("http io exception : " + e.getMessage());
}
return null;
} | java | public static String readBody(HttpServletRequest request) {
BufferedReader input = null;
try {
input = new BufferedReader(new InputStreamReader(request.getInputStream()));
StringBuilder builder = new StringBuilder();
String buffer;
while ((buffer = input.readLine()) != null) {
if (builder.length() > 0) {
builder.append("\n");
}
builder.append(buffer);
}
return builder.toString();
} catch (IOException e) {
log.info("http io exception : " + e.getMessage());
}
return null;
} | [
"public",
"static",
"String",
"readBody",
"(",
"HttpServletRequest",
"request",
")",
"{",
"BufferedReader",
"input",
"=",
"null",
";",
"try",
"{",
"input",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"request",
".",
"getInputStream",
"(",... | Read body string.
@param request the request
@return the string | [
"Read",
"body",
"string",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationHttpUtil.java#L25-L43 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DataTableExtensions.java | DataTableExtensions.convertDataTable | private RecordList convertDataTable(AbstractDataTable table, DataSchema schema) {
return dataTableConversionUtility.convertDataTableToRecordList(schema, table);
} | java | private RecordList convertDataTable(AbstractDataTable table, DataSchema schema) {
return dataTableConversionUtility.convertDataTableToRecordList(schema, table);
} | [
"private",
"RecordList",
"convertDataTable",
"(",
"AbstractDataTable",
"table",
",",
"DataSchema",
"schema",
")",
"{",
"return",
"dataTableConversionUtility",
".",
"convertDataTableToRecordList",
"(",
"schema",
",",
"table",
")",
";",
"}"
] | covert a gwtDatatable to an internal RecordList
@param table
@param schema
@return | [
"covert",
"a",
"gwtDatatable",
"to",
"an",
"internal",
"RecordList"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DataTableExtensions.java#L122-L124 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DataTableExtensions.java | DataTableExtensions.calculateRowsToFilter | private List<Integer> calculateRowsToFilter(DataView dataView, FilterQuery filterQuery, DataSchema schema) {
JsArray<JavaScriptObject> propertiesJsArray = convertToColumnIndexAndValueArray(filterQuery, schema);
JsArrayInteger jsArrayInteger = getFilteredRows(dataView, propertiesJsArray);
return toTypedObjectArray(jsArrayInteger);
} | java | private List<Integer> calculateRowsToFilter(DataView dataView, FilterQuery filterQuery, DataSchema schema) {
JsArray<JavaScriptObject> propertiesJsArray = convertToColumnIndexAndValueArray(filterQuery, schema);
JsArrayInteger jsArrayInteger = getFilteredRows(dataView, propertiesJsArray);
return toTypedObjectArray(jsArrayInteger);
} | [
"private",
"List",
"<",
"Integer",
">",
"calculateRowsToFilter",
"(",
"DataView",
"dataView",
",",
"FilterQuery",
"filterQuery",
",",
"DataSchema",
"schema",
")",
"{",
"JsArray",
"<",
"JavaScriptObject",
">",
"propertiesJsArray",
"=",
"convertToColumnIndexAndValueArray"... | Calculate the row indexes for rows that match all of the given filters.
Parses the filterQuery
@param dataView
@param filterQuery
@param schema
@return a list of rows to filter | [
"Calculate",
"the",
"row",
"indexes",
"for",
"rows",
"that",
"match",
"all",
"of",
"the",
"given",
"filters",
".",
"Parses",
"the",
"filterQuery"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/DataTableExtensions.java#L134-L138 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getDefaultObjectMapper | public static ObjectMapper getDefaultObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
} | java | public static ObjectMapper getDefaultObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
} | [
"public",
"static",
"ObjectMapper",
"getDefaultObjectMapper",
"(",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"new",
"ObjectMapper",
"(",
")",
";",
"mapper",
".",
"configure",
"(",
"DeserializationFeature",
".",
"FAIL_ON_UNKNOWN_PROPERTIES",
",",
"false",
")",
";",
... | Gets default object mapper.
@return the default object mapper | [
"Gets",
"default",
"object",
"mapper",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L34-L45 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.isNumberObj | public static boolean isNumberObj(Object type) {
try {
Double.valueOf(type + "");
} catch (NumberFormatException e) {
return false;
}
return true;
} | java | public static boolean isNumberObj(Object type) {
try {
Double.valueOf(type + "");
} catch (NumberFormatException e) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"isNumberObj",
"(",
"Object",
"type",
")",
"{",
"try",
"{",
"Double",
".",
"valueOf",
"(",
"type",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"... | Is number obj boolean.
@param type the type
@return the boolean | [
"Is",
"number",
"obj",
"boolean",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L70-L77 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.isDoubleType | public static boolean isDoubleType(Class<?> type) {
return (type.isPrimitive() && type == float.class) || (type.isPrimitive() && type == double.class)
|| (!type.isPrimitive() && type == Float.class) || (!type.isPrimitive() && type == Double.class);
} | java | public static boolean isDoubleType(Class<?> type) {
return (type.isPrimitive() && type == float.class) || (type.isPrimitive() && type == double.class)
|| (!type.isPrimitive() && type == Float.class) || (!type.isPrimitive() && type == Double.class);
} | [
"public",
"static",
"boolean",
"isDoubleType",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"(",
"type",
".",
"isPrimitive",
"(",
")",
"&&",
"type",
"==",
"float",
".",
"class",
")",
"||",
"(",
"type",
".",
"isPrimitive",
"(",
")",
"&&",
... | Is double type boolean.
@param type the type
@return the boolean | [
"Is",
"double",
"type",
"boolean",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L95-L98 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.isIntType | public static boolean isIntType(Class<?> type) {
return (type.isPrimitive() && type == int.class) || (type.isPrimitive() && type == long.class)
|| (!type.isPrimitive() && type == Integer.class) || (!type.isPrimitive() && type == Long.class);
} | java | public static boolean isIntType(Class<?> type) {
return (type.isPrimitive() && type == int.class) || (type.isPrimitive() && type == long.class)
|| (!type.isPrimitive() && type == Integer.class) || (!type.isPrimitive() && type == Long.class);
} | [
"public",
"static",
"boolean",
"isIntType",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"(",
"type",
".",
"isPrimitive",
"(",
")",
"&&",
"type",
"==",
"int",
".",
"class",
")",
"||",
"(",
"type",
".",
"isPrimitive",
"(",
")",
"&&",
"ty... | Is int type boolean.
@param type the type
@return the boolean | [
"Is",
"int",
"type",
"boolean",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L107-L110 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getSetterMethodNotCheckParamType | public static Method getSetterMethodNotCheckParamType(Class<?> cType, String fieldName) {
String methodName = getMethodName(fieldName, SET_METHOD_PREFIX);
Method[] methods = cType.getMethods();
for (Method m : methods) {
if (m.getName().equals(methodName) && m.getParameterCount() == 1) {
return m;
}
}
return null;
} | java | public static Method getSetterMethodNotCheckParamType(Class<?> cType, String fieldName) {
String methodName = getMethodName(fieldName, SET_METHOD_PREFIX);
Method[] methods = cType.getMethods();
for (Method m : methods) {
if (m.getName().equals(methodName) && m.getParameterCount() == 1) {
return m;
}
}
return null;
} | [
"public",
"static",
"Method",
"getSetterMethodNotCheckParamType",
"(",
"Class",
"<",
"?",
">",
"cType",
",",
"String",
"fieldName",
")",
"{",
"String",
"methodName",
"=",
"getMethodName",
"(",
"fieldName",
",",
"SET_METHOD_PREFIX",
")",
";",
"Method",
"[",
"]",
... | Gets setter method not check param type.
@param cType the c type
@param fieldName the field name
@return the setter method not check param type | [
"Gets",
"setter",
"method",
"not",
"check",
"param",
"type",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L141-L150 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getSetterMethod | public static Method getSetterMethod(Class<?> cType, String fieldName, Class<?> paramType) {
Class<?> subType = getSubType(paramType);
String methodName = getMethodName(fieldName, SET_METHOD_PREFIX);
try {
return cType.getMethod(methodName, paramType);
} catch (NoSuchMethodException e) {
try {
return cType.getMethod(methodName, subType);
} catch (NoSuchMethodException e1) {
//log.info("setter method not found : " + fieldName);
return null;
}
}
} | java | public static Method getSetterMethod(Class<?> cType, String fieldName, Class<?> paramType) {
Class<?> subType = getSubType(paramType);
String methodName = getMethodName(fieldName, SET_METHOD_PREFIX);
try {
return cType.getMethod(methodName, paramType);
} catch (NoSuchMethodException e) {
try {
return cType.getMethod(methodName, subType);
} catch (NoSuchMethodException e1) {
//log.info("setter method not found : " + fieldName);
return null;
}
}
} | [
"public",
"static",
"Method",
"getSetterMethod",
"(",
"Class",
"<",
"?",
">",
"cType",
",",
"String",
"fieldName",
",",
"Class",
"<",
"?",
">",
"paramType",
")",
"{",
"Class",
"<",
"?",
">",
"subType",
"=",
"getSubType",
"(",
"paramType",
")",
";",
"St... | Gets setter method.
@param cType the c type
@param fieldName the field name
@param paramType the param type
@return the setter method | [
"Gets",
"setter",
"method",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L160-L175 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getMethodName | public static String getMethodName(String name, String prefix) {
return prefix + name.substring(0, 1).toUpperCase() + name.substring(1);
} | java | public static String getMethodName(String name, String prefix) {
return prefix + name.substring(0, 1).toUpperCase() + name.substring(1);
} | [
"public",
"static",
"String",
"getMethodName",
"(",
"String",
"name",
",",
"String",
"prefix",
")",
"{",
"return",
"prefix",
"+",
"name",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"name",
".",
"substring",
"(",
"1",
... | Gets method name.
@param name the name
@param prefix the prefix
@return the method name | [
"Gets",
"method",
"name",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L184-L186 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getFieldNameFromMethod | public static String getFieldNameFromMethod(Method m) {
String methodName = m.getName();
if (methodName.startsWith(GET_METHOD_PREFIX)) {
methodName = methodName.replaceFirst(GET_METHOD_PREFIX, "");
} else if (methodName.startsWith(IS_METHOD_PREFIX)) {
methodName = methodName.replaceFirst(IS_METHOD_PREFIX, "");
} else if (methodName.startsWith(SET_METHOD_PREFIX)) {
methodName = methodName.replaceFirst(SET_METHOD_PREFIX, "");
}
return methodName.substring(0, 1).toLowerCase() + methodName.substring(1);
} | java | public static String getFieldNameFromMethod(Method m) {
String methodName = m.getName();
if (methodName.startsWith(GET_METHOD_PREFIX)) {
methodName = methodName.replaceFirst(GET_METHOD_PREFIX, "");
} else if (methodName.startsWith(IS_METHOD_PREFIX)) {
methodName = methodName.replaceFirst(IS_METHOD_PREFIX, "");
} else if (methodName.startsWith(SET_METHOD_PREFIX)) {
methodName = methodName.replaceFirst(SET_METHOD_PREFIX, "");
}
return methodName.substring(0, 1).toLowerCase() + methodName.substring(1);
} | [
"public",
"static",
"String",
"getFieldNameFromMethod",
"(",
"Method",
"m",
")",
"{",
"String",
"methodName",
"=",
"m",
".",
"getName",
"(",
")",
";",
"if",
"(",
"methodName",
".",
"startsWith",
"(",
"GET_METHOD_PREFIX",
")",
")",
"{",
"methodName",
"=",
"... | Gets field name from method.
@param m the m
@return the field name from method | [
"Gets",
"field",
"name",
"from",
"method",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L194-L207 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getGetterMethod | public static Method getGetterMethod(Class<?> c, String field) {
try {
return c.getMethod(getMethodName(field, GET_METHOD_PREFIX), EMPTY_CLASS);
} catch (NoSuchMethodException e) {
try {
return c.getMethod(getMethodName(field, IS_METHOD_PREFIX), EMPTY_CLASS);
} catch (NoSuchMethodException e1) {
//log.info("getter method not found : " + field);
return null;
}
}
} | java | public static Method getGetterMethod(Class<?> c, String field) {
try {
return c.getMethod(getMethodName(field, GET_METHOD_PREFIX), EMPTY_CLASS);
} catch (NoSuchMethodException e) {
try {
return c.getMethod(getMethodName(field, IS_METHOD_PREFIX), EMPTY_CLASS);
} catch (NoSuchMethodException e1) {
//log.info("getter method not found : " + field);
return null;
}
}
} | [
"public",
"static",
"Method",
"getGetterMethod",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"String",
"field",
")",
"{",
"try",
"{",
"return",
"c",
".",
"getMethod",
"(",
"getMethodName",
"(",
"field",
",",
"GET_METHOD_PREFIX",
")",
",",
"EMPTY_CLASS",
")",
... | Gets getter method.
@param c the c
@param field the field
@return the getter method | [
"Gets",
"getter",
"method",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L216-L228 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getValue | public static Object getValue(Object obj, String field) {
Method getter = getGetterMethod(obj.getClass(), field);
try {
return getter.invoke(obj);
} catch (IllegalAccessException | InvocationTargetException e) {
return null;
}
} | java | public static Object getValue(Object obj, String field) {
Method getter = getGetterMethod(obj.getClass(), field);
try {
return getter.invoke(obj);
} catch (IllegalAccessException | InvocationTargetException e) {
return null;
}
} | [
"public",
"static",
"Object",
"getValue",
"(",
"Object",
"obj",
",",
"String",
"field",
")",
"{",
"Method",
"getter",
"=",
"getGetterMethod",
"(",
"obj",
".",
"getClass",
"(",
")",
",",
"field",
")",
";",
"try",
"{",
"return",
"getter",
".",
"invoke",
... | Gets value.
@param obj the obj
@param field the field
@return the value | [
"Gets",
"value",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L237-L245 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.objDeepCopy | public static Object objDeepCopy(Object from, Object to, String... copyFields) {
if (from == null || to == null) {
log.error("object deep copy from or to is null ");
return to;
}
for (String field : copyFields) {
copyFromTo(from, to, field);
}
return to;
} | java | public static Object objDeepCopy(Object from, Object to, String... copyFields) {
if (from == null || to == null) {
log.error("object deep copy from or to is null ");
return to;
}
for (String field : copyFields) {
copyFromTo(from, to, field);
}
return to;
} | [
"public",
"static",
"Object",
"objDeepCopy",
"(",
"Object",
"from",
",",
"Object",
"to",
",",
"String",
"...",
"copyFields",
")",
"{",
"if",
"(",
"from",
"==",
"null",
"||",
"to",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"object deep copy from... | Obj deep copy object.
@param from the from
@param to the to
@param copyFields the copy fields
@return the object | [
"Obj",
"deep",
"copy",
"object",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L338-L349 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.objectDeepCopyWithWhiteList | public static <T> T objectDeepCopyWithWhiteList(Object from, Object to, String... copyFields) {
return (T) to.getClass().cast(objDeepCopy(from, to, copyFields));
} | java | public static <T> T objectDeepCopyWithWhiteList(Object from, Object to, String... copyFields) {
return (T) to.getClass().cast(objDeepCopy(from, to, copyFields));
} | [
"public",
"static",
"<",
"T",
">",
"T",
"objectDeepCopyWithWhiteList",
"(",
"Object",
"from",
",",
"Object",
"to",
",",
"String",
"...",
"copyFields",
")",
"{",
"return",
"(",
"T",
")",
"to",
".",
"getClass",
"(",
")",
".",
"cast",
"(",
"objDeepCopy",
... | Object deep copy with white list t.
@param <T> the type parameter
@param from the from
@param to the to
@param copyFields the copy fields
@return the t | [
"Object",
"deep",
"copy",
"with",
"white",
"list",
"t",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L360-L362 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.isGetterMethod | public static boolean isGetterMethod(Method m) {
String methodName = m.getName();
if (methodName.equals("getClass")) {
return false;
}
if (!methodName.startsWith(GET_METHOD_PREFIX) && !methodName.startsWith(IS_METHOD_PREFIX)) {
return false;
}
if (m.getParameterCount() > 0) {
return false;
}
return true;
} | java | public static boolean isGetterMethod(Method m) {
String methodName = m.getName();
if (methodName.equals("getClass")) {
return false;
}
if (!methodName.startsWith(GET_METHOD_PREFIX) && !methodName.startsWith(IS_METHOD_PREFIX)) {
return false;
}
if (m.getParameterCount() > 0) {
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"isGetterMethod",
"(",
"Method",
"m",
")",
"{",
"String",
"methodName",
"=",
"m",
".",
"getName",
"(",
")",
";",
"if",
"(",
"methodName",
".",
"equals",
"(",
"\"getClass\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"if... | Is getter method boolean.
@param m the m
@return the boolean | [
"Is",
"getter",
"method",
"boolean",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L370-L386 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getObjectSize | public static Double getObjectSize(Object value) {
double v = 1;
if (value instanceof String) {
v = ((String) value).length();
if (v < 1) {
return null;
}
} else if (value instanceof List) {
v = ((List) value).size();
} else if (ValidationObjUtil.isNumberObj(value)) {
v = Double.valueOf(value + "");
}
return v;
} | java | public static Double getObjectSize(Object value) {
double v = 1;
if (value instanceof String) {
v = ((String) value).length();
if (v < 1) {
return null;
}
} else if (value instanceof List) {
v = ((List) value).size();
} else if (ValidationObjUtil.isNumberObj(value)) {
v = Double.valueOf(value + "");
}
return v;
} | [
"public",
"static",
"Double",
"getObjectSize",
"(",
"Object",
"value",
")",
"{",
"double",
"v",
"=",
"1",
";",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"v",
"=",
"(",
"(",
"String",
")",
"value",
")",
".",
"length",
"(",
")",
";",
"if"... | Gets object size.
@param value the value
@return the object size | [
"Gets",
"object",
"size",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L481-L497 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationObjUtil.java | ValidationObjUtil.getListInnerClassFromGenericType | public static Class<?> getListInnerClassFromGenericType(Type genericType) {
ParameterizedType innerClass = (ParameterizedType) genericType;
return (Class<?>) innerClass.getActualTypeArguments()[0];
} | java | public static Class<?> getListInnerClassFromGenericType(Type genericType) {
ParameterizedType innerClass = (ParameterizedType) genericType;
return (Class<?>) innerClass.getActualTypeArguments()[0];
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"getListInnerClassFromGenericType",
"(",
"Type",
"genericType",
")",
"{",
"ParameterizedType",
"innerClass",
"=",
"(",
"ParameterizedType",
")",
"genericType",
";",
"return",
"(",
"Class",
"<",
"?",
">",
")",
"innerCla... | Gets list inner class from generic type.
@param genericType the generic type
@return the list inner class from generic type | [
"Gets",
"list",
"inner",
"class",
"from",
"generic",
"type",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationObjUtil.java#L505-L508 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgChecker.java | MsgChecker.replaceCallback | public MsgChecker replaceCallback(BasicCheckRule type, ValidationInvalidCallback cb) {
this.callbackMap.put(type.name(), cb);
return this;
} | java | public MsgChecker replaceCallback(BasicCheckRule type, ValidationInvalidCallback cb) {
this.callbackMap.put(type.name(), cb);
return this;
} | [
"public",
"MsgChecker",
"replaceCallback",
"(",
"BasicCheckRule",
"type",
",",
"ValidationInvalidCallback",
"cb",
")",
"{",
"this",
".",
"callbackMap",
".",
"put",
"(",
"type",
".",
"name",
"(",
")",
",",
"cb",
")",
";",
"return",
"this",
";",
"}"
] | Replace callback msg checker.
@param type the type
@param cb the cb
@return the msg checker | [
"Replace",
"callback",
"msg",
"checker",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L36-L39 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgChecker.java | MsgChecker.checkPoint | public void checkPoint(ValidationData param, ValidationRule rule, Object bodyObj, Object standardValue) {
//check
Object value = param.getValue(bodyObj);
BaseValidationCheck checker = this.validationRuleStore.getValidationChecker(rule);
if ((value != null && standardValue != null) || rule.getAssistType().isNullable()) {
boolean valid = checker.check(value, standardValue);
if (!valid) {
this.callExcpetion(param, rule, value, standardValue);
}
}
//replace value
Object replaceValue = checker.replace(value, standardValue, param);
if (replaceValue != null && replaceValue != value) {
param.replaceValue(bodyObj, replaceValue);
}
} | java | public void checkPoint(ValidationData param, ValidationRule rule, Object bodyObj, Object standardValue) {
//check
Object value = param.getValue(bodyObj);
BaseValidationCheck checker = this.validationRuleStore.getValidationChecker(rule);
if ((value != null && standardValue != null) || rule.getAssistType().isNullable()) {
boolean valid = checker.check(value, standardValue);
if (!valid) {
this.callExcpetion(param, rule, value, standardValue);
}
}
//replace value
Object replaceValue = checker.replace(value, standardValue, param);
if (replaceValue != null && replaceValue != value) {
param.replaceValue(bodyObj, replaceValue);
}
} | [
"public",
"void",
"checkPoint",
"(",
"ValidationData",
"param",
",",
"ValidationRule",
"rule",
",",
"Object",
"bodyObj",
",",
"Object",
"standardValue",
")",
"{",
"//check",
"Object",
"value",
"=",
"param",
".",
"getValue",
"(",
"bodyObj",
")",
";",
"BaseValid... | Check point.
@param param the param
@param rule the rule
@param bodyObj the body obj
@param standardValue the standard value | [
"Check",
"point",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L59-L76 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgChecker.java | MsgChecker.checkPointListChild | public void checkPointListChild(ValidationData param, ValidationRule rule, Object bodyObj, Object standardValue) {
ValidationData listParent = param.findListParent();
List list = (List) listParent.getValue(bodyObj);
if (list == null || list.isEmpty()) {
return;
}
list.stream().forEach(item -> {
this.checkPoint(param, rule, item, standardValue);
});
} | java | public void checkPointListChild(ValidationData param, ValidationRule rule, Object bodyObj, Object standardValue) {
ValidationData listParent = param.findListParent();
List list = (List) listParent.getValue(bodyObj);
if (list == null || list.isEmpty()) {
return;
}
list.stream().forEach(item -> {
this.checkPoint(param, rule, item, standardValue);
});
} | [
"public",
"void",
"checkPointListChild",
"(",
"ValidationData",
"param",
",",
"ValidationRule",
"rule",
",",
"Object",
"bodyObj",
",",
"Object",
"standardValue",
")",
"{",
"ValidationData",
"listParent",
"=",
"param",
".",
"findListParent",
"(",
")",
";",
"List",
... | Check point list child.
@param param the param
@param rule the rule
@param bodyObj the body obj
@param standardValue the standard value | [
"Check",
"point",
"list",
"child",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L86-L97 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgChecker.java | MsgChecker.checkDataInnerRules | public void checkDataInnerRules(ValidationData data, Object bodyObj) {
data.getValidationRules().stream().filter(vr -> vr.isUse()).forEach(rule -> {
if (data.isListChild()) {
this.checkPointListChild(data, rule, bodyObj, rule.getStandardValue());
} else {
this.checkPoint(data, rule, bodyObj, rule.getStandardValue());
}
});
} | java | public void checkDataInnerRules(ValidationData data, Object bodyObj) {
data.getValidationRules().stream().filter(vr -> vr.isUse()).forEach(rule -> {
if (data.isListChild()) {
this.checkPointListChild(data, rule, bodyObj, rule.getStandardValue());
} else {
this.checkPoint(data, rule, bodyObj, rule.getStandardValue());
}
});
} | [
"public",
"void",
"checkDataInnerRules",
"(",
"ValidationData",
"data",
",",
"Object",
"bodyObj",
")",
"{",
"data",
".",
"getValidationRules",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"vr",
"->",
"vr",
".",
"isUse",
"(",
")",
")",
".",
"f... | Check data inner rules.
@param data the data
@param bodyObj the body obj | [
"Check",
"data",
"inner",
"rules",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L105-L113 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgChecker.java | MsgChecker.checkRequest | public void checkRequest(BasicCheckInfo basicCheckInfo, Object bodyObj) {
String key = basicCheckInfo.getUniqueKey();
List<ValidationData> checkData = this.validationStore.getValidationDatas(basicCheckInfo.getParamType(), key);
if (checkData == null || checkData.isEmpty()) {
return;
}
checkData.stream().forEach(data -> {
this.checkDataInnerRules(data, bodyObj);
});
} | java | public void checkRequest(BasicCheckInfo basicCheckInfo, Object bodyObj) {
String key = basicCheckInfo.getUniqueKey();
List<ValidationData> checkData = this.validationStore.getValidationDatas(basicCheckInfo.getParamType(), key);
if (checkData == null || checkData.isEmpty()) {
return;
}
checkData.stream().forEach(data -> {
this.checkDataInnerRules(data, bodyObj);
});
} | [
"public",
"void",
"checkRequest",
"(",
"BasicCheckInfo",
"basicCheckInfo",
",",
"Object",
"bodyObj",
")",
"{",
"String",
"key",
"=",
"basicCheckInfo",
".",
"getUniqueKey",
"(",
")",
";",
"List",
"<",
"ValidationData",
">",
"checkData",
"=",
"this",
".",
"valid... | Check request.
@param basicCheckInfo the basic check info
@param bodyObj the body obj | [
"Check",
"request",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L121-L132 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.applyDefaultValues | private void applyDefaultValues(Map<String, Object> parameterValues) {
for (Parameter<?> parameter : allParameters) {
parameterValues.put(parameter.getName(), getParameterDefaultValue(parameter));
}
} | java | private void applyDefaultValues(Map<String, Object> parameterValues) {
for (Parameter<?> parameter : allParameters) {
parameterValues.put(parameter.getName(), getParameterDefaultValue(parameter));
}
} | [
"private",
"void",
"applyDefaultValues",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"{",
"for",
"(",
"Parameter",
"<",
"?",
">",
"parameter",
":",
"allParameters",
")",
"{",
"parameterValues",
".",
"put",
"(",
"parameter",
".",
... | Apply default values for all parameters.
@param parameterValues Parameter values | [
"Apply",
"default",
"values",
"for",
"all",
"parameters",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L120-L124 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.getParameterDefaultValue | private <T> T getParameterDefaultValue(Parameter<T> parameter) {
String defaultOsgiConfigProperty = parameter.getDefaultOsgiConfigProperty();
if (StringUtils.isNotBlank(defaultOsgiConfigProperty)) {
String[] parts = StringUtils.split(defaultOsgiConfigProperty, ":");
String className = parts[0];
String propertyName = parts[1];
ServiceReference ref = bundleContext.getServiceReference(className);
if (ref != null) {
Object value = ref.getProperty(propertyName);
return TypeConversion.osgiPropertyToObject(value, parameter.getType(), parameter.getDefaultValue());
}
}
return parameter.getDefaultValue();
} | java | private <T> T getParameterDefaultValue(Parameter<T> parameter) {
String defaultOsgiConfigProperty = parameter.getDefaultOsgiConfigProperty();
if (StringUtils.isNotBlank(defaultOsgiConfigProperty)) {
String[] parts = StringUtils.split(defaultOsgiConfigProperty, ":");
String className = parts[0];
String propertyName = parts[1];
ServiceReference ref = bundleContext.getServiceReference(className);
if (ref != null) {
Object value = ref.getProperty(propertyName);
return TypeConversion.osgiPropertyToObject(value, parameter.getType(), parameter.getDefaultValue());
}
}
return parameter.getDefaultValue();
} | [
"private",
"<",
"T",
">",
"T",
"getParameterDefaultValue",
"(",
"Parameter",
"<",
"T",
">",
"parameter",
")",
"{",
"String",
"defaultOsgiConfigProperty",
"=",
"parameter",
".",
"getDefaultOsgiConfigProperty",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotB... | Get default value for parameter - from OSGi configuration property or parameter definition itself.
@param parameter Parameter definition
@return Default value or null | [
"Get",
"default",
"value",
"for",
"parameter",
"-",
"from",
"OSGi",
"configuration",
"property",
"or",
"parameter",
"definition",
"itself",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L131-L144 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.applyOverrideSystemDefault | private void applyOverrideSystemDefault(Map<String, Object> parameterValues) {
for (Parameter<?> parameter : allParameters) {
Object overrideValue = parameterOverride.getOverrideSystemDefault(parameter);
if (overrideValue != null) {
parameterValues.put(parameter.getName(), overrideValue);
}
}
} | java | private void applyOverrideSystemDefault(Map<String, Object> parameterValues) {
for (Parameter<?> parameter : allParameters) {
Object overrideValue = parameterOverride.getOverrideSystemDefault(parameter);
if (overrideValue != null) {
parameterValues.put(parameter.getName(), overrideValue);
}
}
} | [
"private",
"void",
"applyOverrideSystemDefault",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"{",
"for",
"(",
"Parameter",
"<",
"?",
">",
"parameter",
":",
"allParameters",
")",
"{",
"Object",
"overrideValue",
"=",
"parameterOverride",... | Apply system-wide overrides for default values.
@param parameterValues Parameter values | [
"Apply",
"system",
"-",
"wide",
"overrides",
"for",
"default",
"values",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L150-L157 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.ensureValidValueTypes | private Map<String, Object> ensureValidValueTypes(Map<String, Object> parameterValues) {
Map<String, Object> transformedParameterValues = new HashMap<>();
for (Map.Entry<String, Object> entry : parameterValues.entrySet()) {
if (entry.getKey() == null || entry.getValue() == null) {
continue;
}
else {
Parameter<?> parameter = allParametersMap.get(entry.getKey());
if (parameter == null) {
continue;
}
else {
Object transformedValue = PersistenceTypeConversion.fromPersistenceType(entry.getValue(), parameter.getType());
if (!parameter.getType().isAssignableFrom(transformedValue.getClass())) {
continue;
}
transformedParameterValues.put(entry.getKey(), transformedValue);
}
}
}
return transformedParameterValues;
} | java | private Map<String, Object> ensureValidValueTypes(Map<String, Object> parameterValues) {
Map<String, Object> transformedParameterValues = new HashMap<>();
for (Map.Entry<String, Object> entry : parameterValues.entrySet()) {
if (entry.getKey() == null || entry.getValue() == null) {
continue;
}
else {
Parameter<?> parameter = allParametersMap.get(entry.getKey());
if (parameter == null) {
continue;
}
else {
Object transformedValue = PersistenceTypeConversion.fromPersistenceType(entry.getValue(), parameter.getType());
if (!parameter.getType().isAssignableFrom(transformedValue.getClass())) {
continue;
}
transformedParameterValues.put(entry.getKey(), transformedValue);
}
}
}
return transformedParameterValues;
} | [
"private",
"Map",
"<",
"String",
",",
"Object",
">",
"ensureValidValueTypes",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"transformedParameterValues",
"=",
"new",
"HashMap",
"<>",
"("... | Make sure value types match with declared parameter types. Values which types do not match, or for which no
parameter definition exists are removed. Types are converted from persistence format if required.
@return Cleaned up parameter values | [
"Make",
"sure",
"value",
"types",
"match",
"with",
"declared",
"parameter",
"types",
".",
"Values",
"which",
"types",
"do",
"not",
"match",
"or",
"for",
"which",
"no",
"parameter",
"definition",
"exists",
"are",
"removed",
".",
"Types",
"are",
"converted",
"... | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L198-L219 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.applyOverrideForce | private SortedSet<String> applyOverrideForce(String configurationId, Map<String, Object> parameterValues,
SortedSet<String> ancestorLockedParameterNames) {
for (Parameter<?> parameter : allParameters) {
Object overrideValue = parameterOverride.getOverrideForce(configurationId, parameter);
if (overrideValue != null) {
parameterValues.put(parameter.getName(), overrideValue);
}
}
Set<String> overrideLockedParameterNames = parameterOverride.getLockedParameterNames(configurationId);
// aggregate set of locked parameter names from ancestor levels and this level
return mergeSets(ancestorLockedParameterNames, overrideLockedParameterNames);
} | java | private SortedSet<String> applyOverrideForce(String configurationId, Map<String, Object> parameterValues,
SortedSet<String> ancestorLockedParameterNames) {
for (Parameter<?> parameter : allParameters) {
Object overrideValue = parameterOverride.getOverrideForce(configurationId, parameter);
if (overrideValue != null) {
parameterValues.put(parameter.getName(), overrideValue);
}
}
Set<String> overrideLockedParameterNames = parameterOverride.getLockedParameterNames(configurationId);
// aggregate set of locked parameter names from ancestor levels and this level
return mergeSets(ancestorLockedParameterNames, overrideLockedParameterNames);
} | [
"private",
"SortedSet",
"<",
"String",
">",
"applyOverrideForce",
"(",
"String",
"configurationId",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
",",
"SortedSet",
"<",
"String",
">",
"ancestorLockedParameterNames",
")",
"{",
"for",
"(",
"Par... | Apply forced overrides for a configurationId.
@param configurationId Configuration id
@param parameterValues Parameter values
@param ancestorLockedParameterNames Set of locked parameter names on the configuration levels above.
@return Set of locked parameter names on this configuration level combined with the from the levels above. | [
"Apply",
"forced",
"overrides",
"for",
"a",
"configurationId",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L228-L241 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.validateParameterProviders | private void validateParameterProviders() {
Set<String> parameterNames = new HashSet<>();
for (ParameterProvider provider : this.parameterProviders) {
Set<String> applicationIdsOfThisProvider = new HashSet<>();
for (Parameter<?> parameter : provider.getParameters()) {
if (StringUtils.isNotEmpty(parameter.getApplicationId())) {
applicationIdsOfThisProvider.add(parameter.getApplicationId());
}
if (parameterNames.contains(parameter.getName())) {
log.warn("Parameter name is not unique: {} (application: {})", parameter.getName(), parameter.getApplicationId());
}
else {
parameterNames.add(parameter.getName());
}
}
if (applicationIdsOfThisProvider.size() > 1) { //NOPMD
log.warn("Parameter provider {} defines parameters with multiple application Ids: {}", provider,
applicationIdsOfThisProvider.toArray(new String[applicationIdsOfThisProvider.size()]));
}
}
} | java | private void validateParameterProviders() {
Set<String> parameterNames = new HashSet<>();
for (ParameterProvider provider : this.parameterProviders) {
Set<String> applicationIdsOfThisProvider = new HashSet<>();
for (Parameter<?> parameter : provider.getParameters()) {
if (StringUtils.isNotEmpty(parameter.getApplicationId())) {
applicationIdsOfThisProvider.add(parameter.getApplicationId());
}
if (parameterNames.contains(parameter.getName())) {
log.warn("Parameter name is not unique: {} (application: {})", parameter.getName(), parameter.getApplicationId());
}
else {
parameterNames.add(parameter.getName());
}
}
if (applicationIdsOfThisProvider.size() > 1) { //NOPMD
log.warn("Parameter provider {} defines parameters with multiple application Ids: {}", provider,
applicationIdsOfThisProvider.toArray(new String[applicationIdsOfThisProvider.size()]));
}
}
} | [
"private",
"void",
"validateParameterProviders",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"parameterNames",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"ParameterProvider",
"provider",
":",
"this",
".",
"parameterProviders",
")",
"{",
"Set",
"<"... | Validate that application ids and configuration names are unique over all providers. | [
"Validate",
"that",
"application",
"ids",
"and",
"configuration",
"names",
"are",
"unique",
"over",
"all",
"providers",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L246-L266 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java | ParameterResolverImpl.mergeSets | private SortedSet<String> mergeSets(SortedSet<String> primary, Set<String> secondary) {
SortedSet<String> result = primary;
if (!secondary.isEmpty()) {
result = new TreeSet<>();
result.addAll(primary);
result.addAll(secondary);
}
return result;
} | java | private SortedSet<String> mergeSets(SortedSet<String> primary, Set<String> secondary) {
SortedSet<String> result = primary;
if (!secondary.isEmpty()) {
result = new TreeSet<>();
result.addAll(primary);
result.addAll(secondary);
}
return result;
} | [
"private",
"SortedSet",
"<",
"String",
">",
"mergeSets",
"(",
"SortedSet",
"<",
"String",
">",
"primary",
",",
"Set",
"<",
"String",
">",
"secondary",
")",
"{",
"SortedSet",
"<",
"String",
">",
"result",
"=",
"primary",
";",
"if",
"(",
"!",
"secondary",
... | Merge two sets. If secondary set is empty return primary.
@param primary Primary set
@param secondary Secondary set
@return Merged set | [
"Merge",
"two",
"sets",
".",
"If",
"secondary",
"set",
"is",
"empty",
"return",
"primary",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/ParameterResolverImpl.java#L274-L282 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.equalUrl | public boolean equalUrl(ReqUrl url) {
return url.getMethod().equalsIgnoreCase(this.method) && url.getUrl().equalsIgnoreCase(this.url);
} | java | public boolean equalUrl(ReqUrl url) {
return url.getMethod().equalsIgnoreCase(this.method) && url.getUrl().equalsIgnoreCase(this.url);
} | [
"public",
"boolean",
"equalUrl",
"(",
"ReqUrl",
"url",
")",
"{",
"return",
"url",
".",
"getMethod",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"this",
".",
"method",
")",
"&&",
"url",
".",
"getUrl",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"this",
".",
"ur... | Equal url boolean.
@param url the url
@return the boolean | [
"Equal",
"url",
"boolean",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L99-L101 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.replaceValue | public void replaceValue(Object bodyObj, Object replaceValue) {
Object parentObj = bodyObj;
if(this.listChild) {
ValidationData rootListParent = this.findListParent();
if(this.deepLevel - rootListParent.deepLevel > 1 ){
parentObj = this.parent.getValue(bodyObj);
}
}
else {
if (this.parentId != null) {
parentObj = this.parent.getValue(bodyObj);
}
}
this.setter(this, parentObj, replaceValue);
} | java | public void replaceValue(Object bodyObj, Object replaceValue) {
Object parentObj = bodyObj;
if(this.listChild) {
ValidationData rootListParent = this.findListParent();
if(this.deepLevel - rootListParent.deepLevel > 1 ){
parentObj = this.parent.getValue(bodyObj);
}
}
else {
if (this.parentId != null) {
parentObj = this.parent.getValue(bodyObj);
}
}
this.setter(this, parentObj, replaceValue);
} | [
"public",
"void",
"replaceValue",
"(",
"Object",
"bodyObj",
",",
"Object",
"replaceValue",
")",
"{",
"Object",
"parentObj",
"=",
"bodyObj",
";",
"if",
"(",
"this",
".",
"listChild",
")",
"{",
"ValidationData",
"rootListParent",
"=",
"this",
".",
"findListParen... | Replace value.
@param bodyObj the body obj
@param replaceValue the replace value | [
"Replace",
"value",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L137-L153 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.updateKey | public ValidationData updateKey(DetailParam detailParam) {
if (detailParam == null) {
return this;
}
this.methodKey = detailParam.getMethodKey();
this.parameterKey = this.paramType.getUniqueKey(this.methodKey);
this.urlMapping = detailParam.isUrlMapping();
return this;
} | java | public ValidationData updateKey(DetailParam detailParam) {
if (detailParam == null) {
return this;
}
this.methodKey = detailParam.getMethodKey();
this.parameterKey = this.paramType.getUniqueKey(this.methodKey);
this.urlMapping = detailParam.isUrlMapping();
return this;
} | [
"public",
"ValidationData",
"updateKey",
"(",
"DetailParam",
"detailParam",
")",
"{",
"if",
"(",
"detailParam",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"this",
".",
"methodKey",
"=",
"detailParam",
".",
"getMethodKey",
"(",
")",
";",
"this",
".... | Update key validation data.
@param detailParam the detail param
@return the validation data | [
"Update",
"key",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L216-L225 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.diffKey | public boolean diffKey(DetailParam detailParam){
if (detailParam == null) {
return false;
}
if(!detailParam.getMethodKey().equals(this.methodKey)){
return true;
}
return detailParam.isUrlMapping() != this.isUrlMapping();
} | java | public boolean diffKey(DetailParam detailParam){
if (detailParam == null) {
return false;
}
if(!detailParam.getMethodKey().equals(this.methodKey)){
return true;
}
return detailParam.isUrlMapping() != this.isUrlMapping();
} | [
"public",
"boolean",
"diffKey",
"(",
"DetailParam",
"detailParam",
")",
"{",
"if",
"(",
"detailParam",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"detailParam",
".",
"getMethodKey",
"(",
")",
".",
"equals",
"(",
"this",
".",
"... | Diff key boolean.
@param detailParam the detail param
@return the boolean | [
"Diff",
"key",
"boolean",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L233-L243 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.updateField | public void updateField(Field field) {
this.name = field.getName();
this.obj = TypeCheckUtil.isObjClass(field);
this.list = TypeCheckUtil.isListClass(field);
this.number = TypeCheckUtil.isNumberClass(field);
this.enumType = field.getType().isEnum();
this.typeClass = field.getType();
this.type = field.getType().getSimpleName();
if (this.list) {
this.innerClass = ValidationObjUtil.getListInnerClassFromGenericType(field.getGenericType());
this.type += "<" + this.innerClass.getSimpleName() + ">";
}
} | java | public void updateField(Field field) {
this.name = field.getName();
this.obj = TypeCheckUtil.isObjClass(field);
this.list = TypeCheckUtil.isListClass(field);
this.number = TypeCheckUtil.isNumberClass(field);
this.enumType = field.getType().isEnum();
this.typeClass = field.getType();
this.type = field.getType().getSimpleName();
if (this.list) {
this.innerClass = ValidationObjUtil.getListInnerClassFromGenericType(field.getGenericType());
this.type += "<" + this.innerClass.getSimpleName() + ">";
}
} | [
"public",
"void",
"updateField",
"(",
"Field",
"field",
")",
"{",
"this",
".",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"this",
".",
"obj",
"=",
"TypeCheckUtil",
".",
"isObjClass",
"(",
"field",
")",
";",
"this",
".",
"list",
"=",
"TypeCh... | Update field.
@param field the field | [
"Update",
"field",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L250-L263 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.minimalize | public ValidationData minimalize() {
this.setValidationRules(this.validationRules.stream().filter(vr -> vr.isUse()).collect(Collectors.toList()));
return this;
} | java | public ValidationData minimalize() {
this.setValidationRules(this.validationRules.stream().filter(vr -> vr.isUse()).collect(Collectors.toList()));
return this;
} | [
"public",
"ValidationData",
"minimalize",
"(",
")",
"{",
"this",
".",
"setValidationRules",
"(",
"this",
".",
"validationRules",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"vr",
"->",
"vr",
".",
"isUse",
"(",
")",
")",
".",
"collect",
"(",
"Collectors"... | Minimalize validation data.
@return the validation data | [
"Minimalize",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L294-L297 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.ruleSync | public ValidationData ruleSync(List<ValidationRule> rules) {
List<ValidationRule> ruleList = new ArrayList<>();
rules.forEach(rule -> {
ValidationRule existRule = this.getExistRule(rule);
ruleList.add(existRule != null ? existRule : rule);
});
this.validationRules.removeAll(ruleList);
this.tempRules.addAll(this.validationRules);
this.validationRules = ruleList;
this.validationRules.sort(new RuleSorter());
return this;
} | java | public ValidationData ruleSync(List<ValidationRule> rules) {
List<ValidationRule> ruleList = new ArrayList<>();
rules.forEach(rule -> {
ValidationRule existRule = this.getExistRule(rule);
ruleList.add(existRule != null ? existRule : rule);
});
this.validationRules.removeAll(ruleList);
this.tempRules.addAll(this.validationRules);
this.validationRules = ruleList;
this.validationRules.sort(new RuleSorter());
return this;
} | [
"public",
"ValidationData",
"ruleSync",
"(",
"List",
"<",
"ValidationRule",
">",
"rules",
")",
"{",
"List",
"<",
"ValidationRule",
">",
"ruleList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"rules",
".",
"forEach",
"(",
"rule",
"->",
"{",
"ValidationRu... | Rule sync validation data.
@param rules the rules
@return the validation data | [
"Rule",
"sync",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L313-L328 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ValidationData.java | ValidationData.findListParent | public ValidationData findListParent() {
if (!this.listChild) {
return null;
}
ValidationData parent = this.parent;
while (parent != null && !parent.isList()) {
parent = parent.parent;
}
return parent;
} | java | public ValidationData findListParent() {
if (!this.listChild) {
return null;
}
ValidationData parent = this.parent;
while (parent != null && !parent.isList()) {
parent = parent.parent;
}
return parent;
} | [
"public",
"ValidationData",
"findListParent",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"listChild",
")",
"{",
"return",
"null",
";",
"}",
"ValidationData",
"parent",
"=",
"this",
".",
"parent",
";",
"while",
"(",
"parent",
"!=",
"null",
"&&",
"!",
"... | Find list parent validation data.
@return the validation data | [
"Find",
"list",
"parent",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ValidationData.java#L335-L345 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/RecordList.java | RecordList.getUniqueRecordsBy | public RecordList getUniqueRecordsBy(String fieldName) {
Set<String> uniqueKeys = new HashSet<String>();
final RecordListBuilder uniqueRecordListBuilder = new RecordListBuilder(schema);
for (int rowIndex = 0; rowIndex < this.size(); rowIndex++) {
final Record currentRecord = this.records.get(rowIndex);
String uniqueKeyField = currentRecord.getValueByFieldName(fieldName);
if(!uniqueKeys.contains(uniqueKeyField)){
uniqueRecordListBuilder.add(currentRecord);
}
uniqueKeys.add(uniqueKeyField);
}
return uniqueRecordListBuilder.createRecordList(dataSourceHash);
} | java | public RecordList getUniqueRecordsBy(String fieldName) {
Set<String> uniqueKeys = new HashSet<String>();
final RecordListBuilder uniqueRecordListBuilder = new RecordListBuilder(schema);
for (int rowIndex = 0; rowIndex < this.size(); rowIndex++) {
final Record currentRecord = this.records.get(rowIndex);
String uniqueKeyField = currentRecord.getValueByFieldName(fieldName);
if(!uniqueKeys.contains(uniqueKeyField)){
uniqueRecordListBuilder.add(currentRecord);
}
uniqueKeys.add(uniqueKeyField);
}
return uniqueRecordListBuilder.createRecordList(dataSourceHash);
} | [
"public",
"RecordList",
"getUniqueRecordsBy",
"(",
"String",
"fieldName",
")",
"{",
"Set",
"<",
"String",
">",
"uniqueKeys",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"final",
"RecordListBuilder",
"uniqueRecordListBuilder",
"=",
"new",
"RecordLis... | Picks the first available record by given fieldName
@param fieldName the unique field value
@return | [
"Picks",
"the",
"first",
"available",
"record",
"by",
"given",
"fieldName"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/RecordList.java#L82-L94 | train |
OpenCompare/OpenCompare | org.opencompare/pcmdata-importers/src/main/java/pcm_Filter/mutate/Main.java | Main.main | public static void main(String[] args) throws IOException {
// TODO : le pcm mutate est bien différent du pcm de base, mais les changements ne sont pas pris en compte. A travailler !
// inputpath = args[0];
inputpath = "off_output/pcms/test_paget/input";
outputpath = "off_output/pcms/test_paget/output";
try {
Stream<Path> paths = Files.walk(Paths.get(inputpath));
paths.forEach(filePath -> {
if (Files.isRegularFile(filePath) && filePath.toString().endsWith(".pcm")) {
System.out.println("> PCM read from " + filePath);
//File pcmFile = new File(filePath.toString());
PCMContainer pcmC = null ;
//PCMContainer pcmC = JSONtoPCM.JSONFormatToPCM(JSONReader.importJSON(filePath.toString())) ;
//PCMLoader loader = new KMFJSONLoader();
//List<PCMContainer> pcmContainers = null;
try {
pcmC = JSONtoPCM.JSONFormatToPCM(JSONReader.importJSON(filePath.toString())) ;
} catch (Exception e) {
e.printStackTrace();
}
// for (PCMContainer pcmContainer : pcmContainers) {
// // Get the PCM
PCMInfoContainerMuted pcmic = null;
try {
System.out.println(pcmic.toString());
pcmic = new PCMInfoContainerMuted(pcmC);
} catch (Exception e) {
e.printStackTrace();
}
if (pcmic != null) {
if (pcmic.isSameSizePcm()) {
System.out.println("> PCM muted is the same");
} else {
pcmC.setPcm(pcmic.getMutedPcm().getPcm());
KMFJSONExporter pcmExporter = new KMFJSONExporter();
String pcmString = pcmExporter.export(pcmC);
Path p = Paths.get(outputpath + "muted_" ) ;//filePath.getFileName());
try {
Files.write(p, pcmString.getBytes());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("> PCM exported to " + p);
}
}
else {
System.out.println("> PCM corrompu");
}
}
});
// mongoClient.close();
paths.close();
} catch (Exception e) {
// mongoClient.close();
e.printStackTrace();
}
} | java | public static void main(String[] args) throws IOException {
// TODO : le pcm mutate est bien différent du pcm de base, mais les changements ne sont pas pris en compte. A travailler !
// inputpath = args[0];
inputpath = "off_output/pcms/test_paget/input";
outputpath = "off_output/pcms/test_paget/output";
try {
Stream<Path> paths = Files.walk(Paths.get(inputpath));
paths.forEach(filePath -> {
if (Files.isRegularFile(filePath) && filePath.toString().endsWith(".pcm")) {
System.out.println("> PCM read from " + filePath);
//File pcmFile = new File(filePath.toString());
PCMContainer pcmC = null ;
//PCMContainer pcmC = JSONtoPCM.JSONFormatToPCM(JSONReader.importJSON(filePath.toString())) ;
//PCMLoader loader = new KMFJSONLoader();
//List<PCMContainer> pcmContainers = null;
try {
pcmC = JSONtoPCM.JSONFormatToPCM(JSONReader.importJSON(filePath.toString())) ;
} catch (Exception e) {
e.printStackTrace();
}
// for (PCMContainer pcmContainer : pcmContainers) {
// // Get the PCM
PCMInfoContainerMuted pcmic = null;
try {
System.out.println(pcmic.toString());
pcmic = new PCMInfoContainerMuted(pcmC);
} catch (Exception e) {
e.printStackTrace();
}
if (pcmic != null) {
if (pcmic.isSameSizePcm()) {
System.out.println("> PCM muted is the same");
} else {
pcmC.setPcm(pcmic.getMutedPcm().getPcm());
KMFJSONExporter pcmExporter = new KMFJSONExporter();
String pcmString = pcmExporter.export(pcmC);
Path p = Paths.get(outputpath + "muted_" ) ;//filePath.getFileName());
try {
Files.write(p, pcmString.getBytes());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("> PCM exported to " + p);
}
}
else {
System.out.println("> PCM corrompu");
}
}
});
// mongoClient.close();
paths.close();
} catch (Exception e) {
// mongoClient.close();
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
"{",
"// TODO : le pcm mutate est bien différent du pcm de base, mais les changements ne sont pas pris en compte. A travailler !",
"// inputpath = args[0];",
"inputpath",
"=",
"\"off_... | give path with argv | [
"give",
"path",
"with",
"argv"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/pcmdata-importers/src/main/java/pcm_Filter/mutate/Main.java#L27-L100 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/excel/PoiWorkBook.java | PoiWorkBook.writeFile | public void writeFile(String fn, HttpServletResponse res) {
ValidationFileUtil.initFileSendHeader(res, ValidationFileUtil.getEncodingFileName(fn + ".xls"), null);
try {
this.workBook.write(res.getOutputStream());
} catch (IOException e) {
throw new ValidationLibException("workbook write error : " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, e);
}
} | java | public void writeFile(String fn, HttpServletResponse res) {
ValidationFileUtil.initFileSendHeader(res, ValidationFileUtil.getEncodingFileName(fn + ".xls"), null);
try {
this.workBook.write(res.getOutputStream());
} catch (IOException e) {
throw new ValidationLibException("workbook write error : " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, e);
}
} | [
"public",
"void",
"writeFile",
"(",
"String",
"fn",
",",
"HttpServletResponse",
"res",
")",
"{",
"ValidationFileUtil",
".",
"initFileSendHeader",
"(",
"res",
",",
"ValidationFileUtil",
".",
"getEncodingFileName",
"(",
"fn",
"+",
"\".xls\"",
")",
",",
"null",
")"... | Write file.
@param fn the fn
@param res the res | [
"Write",
"file",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/excel/PoiWorkBook.java#L62-L71 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/mvp/view/filter/FilterViewUI.java | FilterViewUI.onSelectFilter | @EventHandler
public void onSelectFilter(SelectFilterEvent selectFilterEvent){
for (FacetWidget facetWidget : filterList) {
if(facetWidget.getFacetField().equals(selectFilterEvent.getFilterName())){
for (FacetWidgetItem facetWidgetItem : facetWidget.getFacetWidgetItems()) {
if(facetWidgetItem.getValue().equals(selectFilterEvent.getFilterValue())){
facetWidget.selectItems(Arrays.asList(facetWidgetItem));
}
}
}
}
} | java | @EventHandler
public void onSelectFilter(SelectFilterEvent selectFilterEvent){
for (FacetWidget facetWidget : filterList) {
if(facetWidget.getFacetField().equals(selectFilterEvent.getFilterName())){
for (FacetWidgetItem facetWidgetItem : facetWidget.getFacetWidgetItems()) {
if(facetWidgetItem.getValue().equals(selectFilterEvent.getFilterValue())){
facetWidget.selectItems(Arrays.asList(facetWidgetItem));
}
}
}
}
} | [
"@",
"EventHandler",
"public",
"void",
"onSelectFilter",
"(",
"SelectFilterEvent",
"selectFilterEvent",
")",
"{",
"for",
"(",
"FacetWidget",
"facetWidget",
":",
"filterList",
")",
"{",
"if",
"(",
"facetWidget",
".",
"getFacetField",
"(",
")",
".",
"equals",
"(",... | When a SelectFilterEvent is triggered, this method will look for the filter and value and will select it. | [
"When",
"a",
"SelectFilterEvent",
"is",
"triggered",
"this",
"method",
"will",
"look",
"for",
"the",
"filter",
"and",
"value",
"and",
"will",
"select",
"it",
"."
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/mvp/view/filter/FilterViewUI.java#L414-L426 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/map/MapMarkerBuilder.java | MapMarkerBuilder.createMarker | public <T> GenericMarker<T> createMarker(T markerContext, GenericMapWidget mapWidget) {
this.map = mapWidget;
validateRequiredParameters();
if(map instanceof GoogleV3MapWidget){
return new GoogleV3Marker<T>(this, markerContext);
}
if(map instanceof OfflineMapWidget){
return new OfflineMapMarker<T>(this, markerContext);
}
throw new UnsupportedOperationException();
} | java | public <T> GenericMarker<T> createMarker(T markerContext, GenericMapWidget mapWidget) {
this.map = mapWidget;
validateRequiredParameters();
if(map instanceof GoogleV3MapWidget){
return new GoogleV3Marker<T>(this, markerContext);
}
if(map instanceof OfflineMapWidget){
return new OfflineMapMarker<T>(this, markerContext);
}
throw new UnsupportedOperationException();
} | [
"public",
"<",
"T",
">",
"GenericMarker",
"<",
"T",
">",
"createMarker",
"(",
"T",
"markerContext",
",",
"GenericMapWidget",
"mapWidget",
")",
"{",
"this",
".",
"map",
"=",
"mapWidget",
";",
"validateRequiredParameters",
"(",
")",
";",
"if",
"(",
"map",
"i... | Final build method of the builder, called once all parameters are setup for the Generic Marker
@param markerContext the marker context is intended to hold a reference to the record set backing the marker,
this used later in pop up panel and hover label construction to aid the client in building relevant
markup from the record set backing the marker
@param <T> A record set backing the marker such as RecordList.Record
@return an instance of generic marker | [
"Final",
"build",
"method",
"of",
"the",
"builder",
"called",
"once",
"all",
"parameters",
"are",
"setup",
"for",
"the",
"Generic",
"Marker"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/components/customwidgets/map/MapMarkerBuilder.java#L101-L111 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/impl/AdaptableUtil.java | AdaptableUtil.getResource | public static Resource getResource(Object adaptable) {
if (adaptable instanceof Resource) {
return (Resource)adaptable;
}
else if (adaptable instanceof SlingHttpServletRequest) {
SlingHttpServletRequest request = (SlingHttpServletRequest)adaptable;
return request.getResource();
}
return null;
} | java | public static Resource getResource(Object adaptable) {
if (adaptable instanceof Resource) {
return (Resource)adaptable;
}
else if (adaptable instanceof SlingHttpServletRequest) {
SlingHttpServletRequest request = (SlingHttpServletRequest)adaptable;
return request.getResource();
}
return null;
} | [
"public",
"static",
"Resource",
"getResource",
"(",
"Object",
"adaptable",
")",
"{",
"if",
"(",
"adaptable",
"instanceof",
"Resource",
")",
"{",
"return",
"(",
"Resource",
")",
"adaptable",
";",
"}",
"else",
"if",
"(",
"adaptable",
"instanceof",
"SlingHttpServ... | Tries to get the resource associated with the adaptable.
@param adaptable Adaptable
@return Resource or null | [
"Tries",
"to",
"get",
"the",
"resource",
"associated",
"with",
"the",
"adaptable",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/impl/AdaptableUtil.java#L39-L48 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwisterFast.java | MersenneTwisterFast.readState | public void readState(DataInputStream stream) throws IOException
{
int len = mt.length;
for(int x=0;x<len;x++) mt[x] = stream.readInt();
len = mag01.length;
for(int x=0;x<len;x++) mag01[x] = stream.readInt();
mti = stream.readInt();
__nextNextGaussian = stream.readDouble();
__haveNextNextGaussian = stream.readBoolean();
} | java | public void readState(DataInputStream stream) throws IOException
{
int len = mt.length;
for(int x=0;x<len;x++) mt[x] = stream.readInt();
len = mag01.length;
for(int x=0;x<len;x++) mag01[x] = stream.readInt();
mti = stream.readInt();
__nextNextGaussian = stream.readDouble();
__haveNextNextGaussian = stream.readBoolean();
} | [
"public",
"void",
"readState",
"(",
"DataInputStream",
"stream",
")",
"throws",
"IOException",
"{",
"int",
"len",
"=",
"mt",
".",
"length",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"len",
";",
"x",
"++",
")",
"mt",
"[",
"x",
"]",
"="... | Reads the entire state of the MersenneTwister RNG from the stream
@param stream
@throws IOException | [
"Reads",
"the",
"entire",
"state",
"of",
"the",
"MersenneTwister",
"RNG",
"from",
"the",
"stream"
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwisterFast.java#L215-L226 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwisterFast.java | MersenneTwisterFast.writeState | public void writeState(DataOutputStream stream) throws IOException
{
int len = mt.length;
for(int x=0;x<len;x++) stream.writeInt(mt[x]);
len = mag01.length;
for(int x=0;x<len;x++) stream.writeInt(mag01[x]);
stream.writeInt(mti);
stream.writeDouble(__nextNextGaussian);
stream.writeBoolean(__haveNextNextGaussian);
} | java | public void writeState(DataOutputStream stream) throws IOException
{
int len = mt.length;
for(int x=0;x<len;x++) stream.writeInt(mt[x]);
len = mag01.length;
for(int x=0;x<len;x++) stream.writeInt(mag01[x]);
stream.writeInt(mti);
stream.writeDouble(__nextNextGaussian);
stream.writeBoolean(__haveNextNextGaussian);
} | [
"public",
"void",
"writeState",
"(",
"DataOutputStream",
"stream",
")",
"throws",
"IOException",
"{",
"int",
"len",
"=",
"mt",
".",
"length",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"len",
";",
"x",
"++",
")",
"stream",
".",
"writeInt",... | Writes the entire state of the MersenneTwister RNG to the stream
@param stream
@throws IOException | [
"Writes",
"the",
"entire",
"state",
"of",
"the",
"MersenneTwister",
"RNG",
"to",
"the",
"stream"
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwisterFast.java#L231-L242 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwisterFast.java | MersenneTwisterFast.setSeed | synchronized public void setSeed(final int[] array)
{
if (array.length == 0)
throw new IllegalArgumentException("Array length must be greater than zero");
int i, j, k;
setSeed(19650218);
i=1; j=0;
k = (N>array.length ? N : array.length);
for (; k!=0; k--)
{
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >>> 30)) * 1664525)) + array[j] + j; /* non linear */
mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
i++;
j++;
if (i>=N) { mt[0] = mt[N-1]; i=1; }
if (j>=array.length) j=0;
}
for (k=N-1; k!=0; k--)
{
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >>> 30)) * 1566083941)) - i; /* non linear */
mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
i++;
if (i>=N)
{
mt[0] = mt[N-1]; i=1;
}
}
mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
} | java | synchronized public void setSeed(final int[] array)
{
if (array.length == 0)
throw new IllegalArgumentException("Array length must be greater than zero");
int i, j, k;
setSeed(19650218);
i=1; j=0;
k = (N>array.length ? N : array.length);
for (; k!=0; k--)
{
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >>> 30)) * 1664525)) + array[j] + j; /* non linear */
mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
i++;
j++;
if (i>=N) { mt[0] = mt[N-1]; i=1; }
if (j>=array.length) j=0;
}
for (k=N-1; k!=0; k--)
{
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >>> 30)) * 1566083941)) - i; /* non linear */
mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
i++;
if (i>=N)
{
mt[0] = mt[N-1]; i=1;
}
}
mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
} | [
"synchronized",
"public",
"void",
"setSeed",
"(",
"final",
"int",
"[",
"]",
"array",
")",
"{",
"if",
"(",
"array",
".",
"length",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Array length must be greater than zero\"",
")",
";",
"int",
"i... | Sets the seed of the MersenneTwister using an array of integers.
Your array must have a non-zero length. Only the first 624 integers
in the array are used; if the array is shorter than this then
integers are repeatedly used in a wrap-around fashion.
@param array | [
"Sets",
"the",
"seed",
"of",
"the",
"MersenneTwister",
"using",
"an",
"array",
"of",
"integers",
".",
"Your",
"array",
"must",
"have",
"a",
"non",
"-",
"zero",
"length",
".",
"Only",
"the",
"first",
"624",
"integers",
"in",
"the",
"array",
"are",
"used",... | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwisterFast.java#L316-L344 | train |
OpenCompare/OpenCompare | org.opencompare/pcmdata-importers/src/main/java/data_omdb/TexttoFile.java | Lireetecrire.lire | public void lire()
{
try
{
String adressedufichier = System.getProperty("user.dir") + "\\monfichier.txt";
FileReader fr = new FileReader(adressedufichier);
BufferedReader br = new BufferedReader(fr);
String texte = "";
int a = 0;
while(a<2) //petite boucle 2 fois
{
texte = texte + br.readLine() + "\n";
a++;
}
br.close();
//readLine pour lire une ligne
//note: si il n y a rien, la fonction retournera la valeur null
System.out.println(texte);
//on affiche le texte
}
catch(IOException ioe){System.out.println("erreur : " + ioe);}
} | java | public void lire()
{
try
{
String adressedufichier = System.getProperty("user.dir") + "\\monfichier.txt";
FileReader fr = new FileReader(adressedufichier);
BufferedReader br = new BufferedReader(fr);
String texte = "";
int a = 0;
while(a<2) //petite boucle 2 fois
{
texte = texte + br.readLine() + "\n";
a++;
}
br.close();
//readLine pour lire une ligne
//note: si il n y a rien, la fonction retournera la valeur null
System.out.println(texte);
//on affiche le texte
}
catch(IOException ioe){System.out.println("erreur : " + ioe);}
} | [
"public",
"void",
"lire",
"(",
")",
"{",
"try",
"{",
"String",
"adressedufichier",
"=",
"System",
".",
"getProperty",
"(",
"\"user.dir\"",
")",
"+",
"\"\\\\monfichier.txt\"",
";",
"FileReader",
"fr",
"=",
"new",
"FileReader",
"(",
"adressedufichier",
")",
";",... | je vais moins commenter cette partie c'est presque la meme chose | [
"je",
"vais",
"moins",
"commenter",
"cette",
"partie",
"c",
"est",
"presque",
"la",
"meme",
"chose"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/pcmdata-importers/src/main/java/data_omdb/TexttoFile.java#L73-L106 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/util/SerializationUtil.java | SerializationUtil.deserialize | public <T> T deserialize(Class<T> clazz, String stringContainingSerialisedInput) {
T instance;
try {
instance = storageSerializer.deserialize(clazz, stringContainingSerialisedInput);
} catch (SerializationException e) {
throw new IllegalStateException("unable to serialise", e);
}
return instance;
} | java | public <T> T deserialize(Class<T> clazz, String stringContainingSerialisedInput) {
T instance;
try {
instance = storageSerializer.deserialize(clazz, stringContainingSerialisedInput);
} catch (SerializationException e) {
throw new IllegalStateException("unable to serialise", e);
}
return instance;
} | [
"public",
"<",
"T",
">",
"T",
"deserialize",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"String",
"stringContainingSerialisedInput",
")",
"{",
"T",
"instance",
";",
"try",
"{",
"instance",
"=",
"storageSerializer",
".",
"deserialize",
"(",
"clazz",
",",
"s... | Returns an object from a serialised string
@param clazz Class.name value
@param stringContainingSerialisedInput
@param <T>
@return | [
"Returns",
"an",
"object",
"from",
"a",
"serialised",
"string"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/util/SerializationUtil.java#L65-L73 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/ClientSideSearchDataProvider.java | ClientSideSearchDataProvider.parseQuery | private BitSet parseQuery(FilterQuery filterQuery, DataSchema schema) {
BitSet queryBitSet = new BitSet();
if(filterQuery instanceof MatchAllQuery || filterQuery.getFilterQueries().size() < 1) return queryBitSet;
//facet drill down happens here
for (String filterField : filterQuery.getFilterQueries().keySet()) {
final int columnIndex = schema.getColumnIndex(filterField);
final Map<String, BitSet> map = fieldInvertedIndex.get(columnIndex);
final FilterQuery.FilterQueryElement filterQueryElement = filterQuery.getFilterQueries().get(filterField);
DataType type = schema.getType(columnIndex);
switch (type) {
case CoordinateLat:
case CoordinateLon:
case String:
case Boolean:
case Integer:
// if range query
if (filterQueryElement instanceof FilterQuery.FilterFieldRange) {
queryBitSet = processRangeQueryIntegerTypes(queryBitSet, map, filterQueryElement, type);
} else if (filterQueryElement instanceof FilterQuery.FilterFieldGreaterThanInteger) {
queryBitSet = processIntegerGreaterThanDefaultTypes(queryBitSet, map, filterQueryElement, type);
} else {
// does most of the commons multi value types
queryBitSet = processMultiValueQueryDefaultTypes(queryBitSet, map, filterQueryElement, type);
}
break;
case Date:
if (filterQueryElement instanceof FilterQuery.FilterFieldRangeDate) {
queryBitSet = processRangeQueryISODateTypes(queryBitSet, map, filterQueryElement, type);
} else {
queryBitSet = processRangeQueryMultiValueQueryDateYear(queryBitSet, map, filterQueryElement, type);
}
break;
case DateYear:
// if range query
if (filterQueryElement instanceof FilterQuery.FilterFieldRange) {
queryBitSet = processRangeQueryDateYearType(queryBitSet, map, filterQueryElement, type);
} else {
queryBitSet = processRangeQueryMultiValueQueryDateYear(queryBitSet, map, filterQueryElement, type);
}
break;
}
}
return queryBitSet;
} | java | private BitSet parseQuery(FilterQuery filterQuery, DataSchema schema) {
BitSet queryBitSet = new BitSet();
if(filterQuery instanceof MatchAllQuery || filterQuery.getFilterQueries().size() < 1) return queryBitSet;
//facet drill down happens here
for (String filterField : filterQuery.getFilterQueries().keySet()) {
final int columnIndex = schema.getColumnIndex(filterField);
final Map<String, BitSet> map = fieldInvertedIndex.get(columnIndex);
final FilterQuery.FilterQueryElement filterQueryElement = filterQuery.getFilterQueries().get(filterField);
DataType type = schema.getType(columnIndex);
switch (type) {
case CoordinateLat:
case CoordinateLon:
case String:
case Boolean:
case Integer:
// if range query
if (filterQueryElement instanceof FilterQuery.FilterFieldRange) {
queryBitSet = processRangeQueryIntegerTypes(queryBitSet, map, filterQueryElement, type);
} else if (filterQueryElement instanceof FilterQuery.FilterFieldGreaterThanInteger) {
queryBitSet = processIntegerGreaterThanDefaultTypes(queryBitSet, map, filterQueryElement, type);
} else {
// does most of the commons multi value types
queryBitSet = processMultiValueQueryDefaultTypes(queryBitSet, map, filterQueryElement, type);
}
break;
case Date:
if (filterQueryElement instanceof FilterQuery.FilterFieldRangeDate) {
queryBitSet = processRangeQueryISODateTypes(queryBitSet, map, filterQueryElement, type);
} else {
queryBitSet = processRangeQueryMultiValueQueryDateYear(queryBitSet, map, filterQueryElement, type);
}
break;
case DateYear:
// if range query
if (filterQueryElement instanceof FilterQuery.FilterFieldRange) {
queryBitSet = processRangeQueryDateYearType(queryBitSet, map, filterQueryElement, type);
} else {
queryBitSet = processRangeQueryMultiValueQueryDateYear(queryBitSet, map, filterQueryElement, type);
}
break;
}
}
return queryBitSet;
} | [
"private",
"BitSet",
"parseQuery",
"(",
"FilterQuery",
"filterQuery",
",",
"DataSchema",
"schema",
")",
"{",
"BitSet",
"queryBitSet",
"=",
"new",
"BitSet",
"(",
")",
";",
"if",
"(",
"filterQuery",
"instanceof",
"MatchAllQuery",
"||",
"filterQuery",
".",
"getFilt... | Calculates which documents are available given the current FilterQuery selection
@param filterQuery
@param schema
@return a restrictedBitSetOfDocumentsAvailableAfterQuery document order is preserved | [
"Calculates",
"which",
"documents",
"are",
"available",
"given",
"the",
"current",
"FilterQuery",
"selection"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/ClientSideSearchDataProvider.java#L578-L627 | train |
lightblue-platform/lightblue-client | core/src/main/java/com/redhat/lightblue/client/response/DefaultLightblueDataResponse.java | DefaultLightblueDataResponse.getResultMetadata | @Override
public ResultMetadata[] getResultMetadata() throws LightblueParseException {
JsonNode node=getJson().get("resultMetadata");
if(node instanceof ArrayNode) {
try {
return getMapper().readValue(node.traverse(),ResultMetadata[].class);
} catch (IOException e) {
throw new LightblueParseException("Error parsing lightblue response:"+getText()+"\n",e);
}
} else {
return null;
}
} | java | @Override
public ResultMetadata[] getResultMetadata() throws LightblueParseException {
JsonNode node=getJson().get("resultMetadata");
if(node instanceof ArrayNode) {
try {
return getMapper().readValue(node.traverse(),ResultMetadata[].class);
} catch (IOException e) {
throw new LightblueParseException("Error parsing lightblue response:"+getText()+"\n",e);
}
} else {
return null;
}
} | [
"@",
"Override",
"public",
"ResultMetadata",
"[",
"]",
"getResultMetadata",
"(",
")",
"throws",
"LightblueParseException",
"{",
"JsonNode",
"node",
"=",
"getJson",
"(",
")",
".",
"get",
"(",
"\"resultMetadata\"",
")",
";",
"if",
"(",
"node",
"instanceof",
"Arr... | Returns a result metadata array where each element corresponds
to the metadata for the result at the same index in processed
array. | [
"Returns",
"a",
"result",
"metadata",
"array",
"where",
"each",
"element",
"corresponds",
"to",
"the",
"metadata",
"for",
"the",
"result",
"at",
"the",
"same",
"index",
"in",
"processed",
"array",
"."
] | 03790aff34e90d3889f60fd6c603c21a21dc1a40 | https://github.com/lightblue-platform/lightblue-client/blob/03790aff34e90d3889f60fd6c603c21a21dc1a40/core/src/main/java/com/redhat/lightblue/client/response/DefaultLightblueDataResponse.java#L60-L72 | train |
OpenCompare/OpenCompare | org.opencompare/api-java-impl/src/main/java/org/opencompare/api/java/impl/PCMImpl.java | PCMImpl.diffFeatures | private Map<Feature, Feature> diffFeatures(List<Feature> pcm1Features, List<Feature> pcm2Features, PCMElementComparator comparator, DiffResult result) {
List<Feature> commonFeatures = new ArrayList<Feature>();
List<Feature> featuresOnlyInPCM1 = new ArrayList<Feature>();
List<Feature> featuresOnlyInPCM2 = new ArrayList<Feature>(pcm2Features);
Map<Feature, Feature> equivalentFeatures = new HashMap<Feature, Feature>();
for (Feature f1 : pcm1Features) {
boolean similarFeature = false;
for (Feature f2 : pcm2Features) {
similarFeature = comparator.similarFeature(f1, f2);
if (similarFeature) {
commonFeatures.add(f1);
featuresOnlyInPCM2.remove(f2);
equivalentFeatures.put(f1, f2);
break;
}
}
if (!similarFeature) {
featuresOnlyInPCM1.add(f1);
}
}
result.setCommonFeatures(commonFeatures);
result.setFeaturesOnlyInPCM1(featuresOnlyInPCM1);
result.setFeaturesOnlyInPCM2(featuresOnlyInPCM2);
return equivalentFeatures;
} | java | private Map<Feature, Feature> diffFeatures(List<Feature> pcm1Features, List<Feature> pcm2Features, PCMElementComparator comparator, DiffResult result) {
List<Feature> commonFeatures = new ArrayList<Feature>();
List<Feature> featuresOnlyInPCM1 = new ArrayList<Feature>();
List<Feature> featuresOnlyInPCM2 = new ArrayList<Feature>(pcm2Features);
Map<Feature, Feature> equivalentFeatures = new HashMap<Feature, Feature>();
for (Feature f1 : pcm1Features) {
boolean similarFeature = false;
for (Feature f2 : pcm2Features) {
similarFeature = comparator.similarFeature(f1, f2);
if (similarFeature) {
commonFeatures.add(f1);
featuresOnlyInPCM2.remove(f2);
equivalentFeatures.put(f1, f2);
break;
}
}
if (!similarFeature) {
featuresOnlyInPCM1.add(f1);
}
}
result.setCommonFeatures(commonFeatures);
result.setFeaturesOnlyInPCM1(featuresOnlyInPCM1);
result.setFeaturesOnlyInPCM2(featuresOnlyInPCM2);
return equivalentFeatures;
} | [
"private",
"Map",
"<",
"Feature",
",",
"Feature",
">",
"diffFeatures",
"(",
"List",
"<",
"Feature",
">",
"pcm1Features",
",",
"List",
"<",
"Feature",
">",
"pcm2Features",
",",
"PCMElementComparator",
"comparator",
",",
"DiffResult",
"result",
")",
"{",
"List",... | Compare the features of two PCMs
@param pcm1Features
@param pcm2Features
@param comparator
@param result
@return equivalent features | [
"Compare",
"the",
"features",
"of",
"two",
"PCMs"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/api-java-impl/src/main/java/org/opencompare/api/java/impl/PCMImpl.java#L383-L412 | train |
OpenCompare/OpenCompare | org.opencompare/api-java-impl/src/main/java/org/opencompare/api/java/impl/PCMImpl.java | PCMImpl.diffProducts | private Map<Product, Product> diffProducts(List<Product> pcm1Products, List<Product> pcm2Products, PCMElementComparator comparator, DiffResult result) {
List<Product> commonProducts = new ArrayList<Product>();
List<Product> productsOnlyInPCM1 = new ArrayList<Product>();
List<Product> productsOnlyInPCM2 = new ArrayList<Product>(pcm2Products);
Map<Product, Product> equivalentProducts = new HashMap<Product, Product>();
for (Product p1 : pcm1Products) {
boolean similarProduct = false;
for (Product p2 : pcm2Products) {
similarProduct = comparator.similarProduct(p1, p2);
if (similarProduct) {
commonProducts.add(p1);
productsOnlyInPCM2.remove(p2);
equivalentProducts.put(p1, p2);
break;
}
}
if (!similarProduct) {
productsOnlyInPCM1.add(p1);
}
}
result.setCommonProducts(commonProducts);
result.setProductsOnlyInPCM1(productsOnlyInPCM1);
result.setProductsOnlyInPCM2(productsOnlyInPCM2);
return equivalentProducts;
} | java | private Map<Product, Product> diffProducts(List<Product> pcm1Products, List<Product> pcm2Products, PCMElementComparator comparator, DiffResult result) {
List<Product> commonProducts = new ArrayList<Product>();
List<Product> productsOnlyInPCM1 = new ArrayList<Product>();
List<Product> productsOnlyInPCM2 = new ArrayList<Product>(pcm2Products);
Map<Product, Product> equivalentProducts = new HashMap<Product, Product>();
for (Product p1 : pcm1Products) {
boolean similarProduct = false;
for (Product p2 : pcm2Products) {
similarProduct = comparator.similarProduct(p1, p2);
if (similarProduct) {
commonProducts.add(p1);
productsOnlyInPCM2.remove(p2);
equivalentProducts.put(p1, p2);
break;
}
}
if (!similarProduct) {
productsOnlyInPCM1.add(p1);
}
}
result.setCommonProducts(commonProducts);
result.setProductsOnlyInPCM1(productsOnlyInPCM1);
result.setProductsOnlyInPCM2(productsOnlyInPCM2);
return equivalentProducts;
} | [
"private",
"Map",
"<",
"Product",
",",
"Product",
">",
"diffProducts",
"(",
"List",
"<",
"Product",
">",
"pcm1Products",
",",
"List",
"<",
"Product",
">",
"pcm2Products",
",",
"PCMElementComparator",
"comparator",
",",
"DiffResult",
"result",
")",
"{",
"List",... | Compare the products of two PCMs
@param pcm1Products
@param pcm2Products
@param comparator
@param result
@return equivalent products | [
"Compare",
"the",
"products",
"of",
"two",
"PCMs"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/api-java-impl/src/main/java/org/opencompare/api/java/impl/PCMImpl.java#L422-L454 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/PersistenceTypeConversion.java | PersistenceTypeConversion.toPersistenceType | public static Object toPersistenceType(Object value, Class<?> parameterType) {
if (!isTypeConversionRequired(parameterType)) {
return value;
}
if (Map.class.isAssignableFrom(parameterType) && (value instanceof Map)) {
Map<?, ?> map = (Map<?, ?>)value;
Map.Entry<?, ?>[] entries = Iterators.toArray(map.entrySet().iterator(), Map.Entry.class);
String[] stringArray = new String[entries.length];
for (int i = 0; i < entries.length; i++) {
Map.Entry<?, ?> entry = entries[i];
String entryKey = Objects.toString(entry.getKey(), "");
String entryValue = Objects.toString(entry.getValue(), "");
stringArray[i] = ConversionStringUtils.encodeString(entryKey) + KEY_VALUE_DELIMITER + ConversionStringUtils.encodeString(entryValue);
}
return stringArray;
}
throw new IllegalArgumentException("Type conversion not supported: " + parameterType.getName());
} | java | public static Object toPersistenceType(Object value, Class<?> parameterType) {
if (!isTypeConversionRequired(parameterType)) {
return value;
}
if (Map.class.isAssignableFrom(parameterType) && (value instanceof Map)) {
Map<?, ?> map = (Map<?, ?>)value;
Map.Entry<?, ?>[] entries = Iterators.toArray(map.entrySet().iterator(), Map.Entry.class);
String[] stringArray = new String[entries.length];
for (int i = 0; i < entries.length; i++) {
Map.Entry<?, ?> entry = entries[i];
String entryKey = Objects.toString(entry.getKey(), "");
String entryValue = Objects.toString(entry.getValue(), "");
stringArray[i] = ConversionStringUtils.encodeString(entryKey) + KEY_VALUE_DELIMITER + ConversionStringUtils.encodeString(entryValue);
}
return stringArray;
}
throw new IllegalArgumentException("Type conversion not supported: " + parameterType.getName());
} | [
"public",
"static",
"Object",
"toPersistenceType",
"(",
"Object",
"value",
",",
"Class",
"<",
"?",
">",
"parameterType",
")",
"{",
"if",
"(",
"!",
"isTypeConversionRequired",
"(",
"parameterType",
")",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"Map... | Convert object to be persisted.
@param value Configured value
@param parameterType Parameter type
@return value that can be persisted | [
"Convert",
"object",
"to",
"be",
"persisted",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/PersistenceTypeConversion.java#L63-L80 | train |
wcm-io/wcm-io-config | core/src/main/java/io/wcm/config/core/management/impl/PersistenceTypeConversion.java | PersistenceTypeConversion.fromPersistenceType | public static Object fromPersistenceType(Object value, Class<?> parameterType) {
if (!isTypeConversionRequired(parameterType)) {
return value;
}
if (Map.class.isAssignableFrom(parameterType) && (value instanceof String[])) {
String[] rows = (String[])value;
Map<String, String> map = new LinkedHashMap<>();
for (int i = 0; i < rows.length; i++) {
String[] keyValue = ConversionStringUtils.splitPreserveAllTokens(rows[i], KEY_VALUE_DELIMITER.charAt(0));
if (keyValue.length == 2 && StringUtils.isNotEmpty(keyValue[0])) {
String entryKey = keyValue[0];
String entryValue = StringUtils.isEmpty(keyValue[1]) ? null : keyValue[1];
map.put(ConversionStringUtils.decodeString(entryKey), ConversionStringUtils.decodeString(entryValue));
}
}
return map;
}
throw new IllegalArgumentException("Type conversion not supported: " + parameterType.getName());
} | java | public static Object fromPersistenceType(Object value, Class<?> parameterType) {
if (!isTypeConversionRequired(parameterType)) {
return value;
}
if (Map.class.isAssignableFrom(parameterType) && (value instanceof String[])) {
String[] rows = (String[])value;
Map<String, String> map = new LinkedHashMap<>();
for (int i = 0; i < rows.length; i++) {
String[] keyValue = ConversionStringUtils.splitPreserveAllTokens(rows[i], KEY_VALUE_DELIMITER.charAt(0));
if (keyValue.length == 2 && StringUtils.isNotEmpty(keyValue[0])) {
String entryKey = keyValue[0];
String entryValue = StringUtils.isEmpty(keyValue[1]) ? null : keyValue[1];
map.put(ConversionStringUtils.decodeString(entryKey), ConversionStringUtils.decodeString(entryValue));
}
}
return map;
}
throw new IllegalArgumentException("Type conversion not supported: " + parameterType.getName());
} | [
"public",
"static",
"Object",
"fromPersistenceType",
"(",
"Object",
"value",
",",
"Class",
"<",
"?",
">",
"parameterType",
")",
"{",
"if",
"(",
"!",
"isTypeConversionRequired",
"(",
"parameterType",
")",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"M... | Convert object from persistence to be used in configuration.
@param value Persisted value
@param parameterType Parameter type
@return Configured value | [
"Convert",
"object",
"from",
"persistence",
"to",
"be",
"used",
"in",
"configuration",
"."
] | 9a03d72a4314163a171c7ef815fb6a1eba181828 | https://github.com/wcm-io/wcm-io-config/blob/9a03d72a4314163a171c7ef815fb6a1eba181828/core/src/main/java/io/wcm/config/core/management/impl/PersistenceTypeConversion.java#L88-L106 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/FilterQuery.java | FilterQuery.addFilter | public void addFilter(String field, String valueToFilter){
if(StringUtils.isEmpty(field) || StringUtils.isEmpty(valueToFilter)){
throw new IllegalArgumentException("Expected all attributes to be non empty");
}
Set<String> valuesToFilter = new HashSet<String>();
valuesToFilter.add(valueToFilter);
filterQueries.put(field, new FilterFieldValue(field, valuesToFilter));
} | java | public void addFilter(String field, String valueToFilter){
if(StringUtils.isEmpty(field) || StringUtils.isEmpty(valueToFilter)){
throw new IllegalArgumentException("Expected all attributes to be non empty");
}
Set<String> valuesToFilter = new HashSet<String>();
valuesToFilter.add(valueToFilter);
filterQueries.put(field, new FilterFieldValue(field, valuesToFilter));
} | [
"public",
"void",
"addFilter",
"(",
"String",
"field",
",",
"String",
"valueToFilter",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"field",
")",
"||",
"StringUtils",
".",
"isEmpty",
"(",
"valueToFilter",
")",
")",
"{",
"throw",
"new",
"Illegal... | add a filter to the to build FilterQuery instance
@param field
@param valueToFilter | [
"add",
"a",
"filter",
"to",
"the",
"to",
"build",
"FilterQuery",
"instance"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/FilterQuery.java#L91-L98 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/FilterQuery.java | FilterQuery.addMultipleValuesFilter | public void addMultipleValuesFilter(String field, Set<String> valueToFilter){
if(!valueToFilter.isEmpty()){
filterQueries.put(field, new FilterFieldValue(field, valueToFilter));
}
} | java | public void addMultipleValuesFilter(String field, Set<String> valueToFilter){
if(!valueToFilter.isEmpty()){
filterQueries.put(field, new FilterFieldValue(field, valueToFilter));
}
} | [
"public",
"void",
"addMultipleValuesFilter",
"(",
"String",
"field",
",",
"Set",
"<",
"String",
">",
"valueToFilter",
")",
"{",
"if",
"(",
"!",
"valueToFilter",
".",
"isEmpty",
"(",
")",
")",
"{",
"filterQueries",
".",
"put",
"(",
"field",
",",
"new",
"F... | add a filter with multiple values to build FilterQuery instance
@param field
@param valueToFilter | [
"add",
"a",
"filter",
"with",
"multiple",
"values",
"to",
"build",
"FilterQuery",
"instance"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/FilterQuery.java#L105-L109 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwister.java | MersenneTwister.nextLong | public long nextLong(final long n)
{
if (n<=0)
throw new IllegalArgumentException("n must be > 0");
long bits, val;
do
{
bits = (nextLong() >>> 1);
val = bits % n;
}
while(bits - val + (n-1) < 0);
return val;
} | java | public long nextLong(final long n)
{
if (n<=0)
throw new IllegalArgumentException("n must be > 0");
long bits, val;
do
{
bits = (nextLong() >>> 1);
val = bits % n;
}
while(bits - val + (n-1) < 0);
return val;
} | [
"public",
"long",
"nextLong",
"(",
"final",
"long",
"n",
")",
"{",
"if",
"(",
"n",
"<=",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"n must be > 0\"",
")",
";",
"long",
"bits",
",",
"val",
";",
"do",
"{",
"bits",
"=",
"(",
"nextLong",... | This method is for completness' sake.
Returns a long drawn uniformly from 0 to n-1. Suffice it to say,
n must be > 0, or an IllegalArgumentException is raised.
@param n
@return ? | [
"This",
"method",
"is",
"for",
"completness",
"sake",
".",
"Returns",
"a",
"long",
"drawn",
"uniformly",
"from",
"0",
"to",
"n",
"-",
"1",
".",
"Suffice",
"it",
"to",
"say",
"n",
"must",
"be",
">",
"0",
"or",
"an",
"IllegalArgumentException",
"is",
"ra... | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/utilities/random/MersenneTwister.java#L470-L483 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/FieldInvertedIndex.java | FieldInvertedIndex.addDocument | public void addDocument(String... fields){
for (int i = 0; i < fields.length; i++) {
final DataType type = schema.getType(i);
String field = fields[i];
final Map<String, Set<Integer>> stringSetMap = this.fields.get(i);
if(type == DataType.DateYear){ // reformat field value for date year
field = field.split("-")[0];
}
Set<Integer> integers = stringSetMap.get(field);
if(integers == null){
integers = new TreeSet<>();
}
integers.add(docPosition);
stringSetMap.put(field, integers);
}
docPosition++;
} | java | public void addDocument(String... fields){
for (int i = 0; i < fields.length; i++) {
final DataType type = schema.getType(i);
String field = fields[i];
final Map<String, Set<Integer>> stringSetMap = this.fields.get(i);
if(type == DataType.DateYear){ // reformat field value for date year
field = field.split("-")[0];
}
Set<Integer> integers = stringSetMap.get(field);
if(integers == null){
integers = new TreeSet<>();
}
integers.add(docPosition);
stringSetMap.put(field, integers);
}
docPosition++;
} | [
"public",
"void",
"addDocument",
"(",
"String",
"...",
"fields",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"DataType",
"type",
"=",
"schema",
".",
"getType",
"(",
"i",
"... | add fields on index | [
"add",
"fields",
"on",
"index"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/client/core/FieldInvertedIndex.java#L78-L94 | train |
OpenCompare/OpenCompare | org.opencompare/pcmdata-importers/src/main/java/misc/hints/MyPCMPrinter.java | MyPCMPrinter.print | public void print(PCM pcm) {
// We start by listing the names of the products
System.out.println("--- Products ---");
for (Product product : pcm.getProducts()) {
System.out.println(product.getKeyContent());
}
// Then, we use a visitor to print the content of the cells that represent a boolean value
// System.out.println("--- Boolean values ---");
pcm.accept(this);
} | java | public void print(PCM pcm) {
// We start by listing the names of the products
System.out.println("--- Products ---");
for (Product product : pcm.getProducts()) {
System.out.println(product.getKeyContent());
}
// Then, we use a visitor to print the content of the cells that represent a boolean value
// System.out.println("--- Boolean values ---");
pcm.accept(this);
} | [
"public",
"void",
"print",
"(",
"PCM",
"pcm",
")",
"{",
"// We start by listing the names of the products",
"System",
".",
"out",
".",
"println",
"(",
"\"--- Products ---\"",
")",
";",
"for",
"(",
"Product",
"product",
":",
"pcm",
".",
"getProducts",
"(",
")",
... | Print some information contained in a PCM
@param pcm: PCM to print | [
"Print",
"some",
"information",
"contained",
"in",
"a",
"PCM"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/pcmdata-importers/src/main/java/misc/hints/MyPCMPrinter.java#L20-L32 | train |
OpenCompare/OpenCompare | org.opencompare/pcmdata-importers/src/main/java/misc/hints/MyPCMPrinter.java | MyPCMPrinter.visit | @Override
public void visit(PCM pcm) {
for (Product product : pcm.getProducts()) {
product.accept(this);
}
} | java | @Override
public void visit(PCM pcm) {
for (Product product : pcm.getProducts()) {
product.accept(this);
}
} | [
"@",
"Override",
"public",
"void",
"visit",
"(",
"PCM",
"pcm",
")",
"{",
"for",
"(",
"Product",
"product",
":",
"pcm",
".",
"getProducts",
"(",
")",
")",
"{",
"product",
".",
"accept",
"(",
"this",
")",
";",
"}",
"}"
] | Methods for the visitor | [
"Methods",
"for",
"the",
"visitor"
] | 6cd776466b375cb8ecca08fcd94e573d65e20b14 | https://github.com/OpenCompare/OpenCompare/blob/6cd776466b375cb8ecca08fcd94e573d65e20b14/org.opencompare/pcmdata-importers/src/main/java/misc/hints/MyPCMPrinter.java#L37-L42 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/domain/ReqUrl.java | ReqUrl.getSheetName | public String getSheetName(int idx) {
String name = method + "|" + url.replace("/", "|");
if (name.length() > 30) {
return name.substring(0, 29) + idx;
}
return name;
} | java | public String getSheetName(int idx) {
String name = method + "|" + url.replace("/", "|");
if (name.length() > 30) {
return name.substring(0, 29) + idx;
}
return name;
} | [
"public",
"String",
"getSheetName",
"(",
"int",
"idx",
")",
"{",
"String",
"name",
"=",
"method",
"+",
"\"|\"",
"+",
"url",
".",
"replace",
"(",
"\"/\"",
",",
"\"|\"",
")",
";",
"if",
"(",
"name",
".",
"length",
"(",
")",
">",
"30",
")",
"{",
"re... | Gets sheet name.
@param idx the idx
@return the sheet name | [
"Gets",
"sheet",
"name",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/domain/ReqUrl.java#L70-L76 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | SurveyorCore/src/main/java/org/wwarn/surveyor/server/core/LuceneSearchServiceImpl.java | LuceneSearchServiceImpl.setupIndexMonitor | private void setupIndexMonitor(final DataSchema dataSchema, final GenericDataSource dataSource) {
logger.log(FINE,"LuceneSearchServiceImpl::setupIndexMonitor Attempting to setup Index monitor...");
try {
if(GoogleAppEngineUtil.isGaeEnv()){
return; // only use for pure lucene tomcat implementation, doesn't work on GAE.
}
if (dataSource.getDataSourceType() != GenericDataSource.DataSourceType.ServletRelativeDataSource || dataSource.getLocation() == null) {
// only able to monitor servlet relative datasources
return;
} else {
// assertFilePathExists(dataSource.getLocation(), "jsonPath invalid:");
// File json = new File(dataSource.getLocation());
// try {
// fileChangeMonitor = FileChangeMonitor.getInstance();
// fileChangeMonitor.init(json.toPath());
// if(Log.isDebugEnabled()) Log.debug("LuceneSearchServiceImpl::setupIndexMonitor","Index monitor setup completed.");
// } catch (IOException e) {
// throw new SearchException("Unable to initialize file change monitor",e);
// }
}
fileChangeMonitor = FileChangeMonitor.getInstance();
fileChangeMonitor.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
JSONWithMetaData jsonContent;
try {
logger.log(FINE,"LuceneSearchServiceImpl::setupIndexMonitor", "Index monitor change noted.");
jsonContent = getJsonArrayFrom(dataSource);
} catch (SearchException e) {
throw new IllegalStateException(e);
}
setupIndex(dataSource, dataSchema, jsonContent);
}
});
} catch (Exception e) {
logger.log(SEVERE,"LuceneSearchServiceImpl::setupIndexMonitor Failed to setup monitor for indexed file changes", e);
}
} | java | private void setupIndexMonitor(final DataSchema dataSchema, final GenericDataSource dataSource) {
logger.log(FINE,"LuceneSearchServiceImpl::setupIndexMonitor Attempting to setup Index monitor...");
try {
if(GoogleAppEngineUtil.isGaeEnv()){
return; // only use for pure lucene tomcat implementation, doesn't work on GAE.
}
if (dataSource.getDataSourceType() != GenericDataSource.DataSourceType.ServletRelativeDataSource || dataSource.getLocation() == null) {
// only able to monitor servlet relative datasources
return;
} else {
// assertFilePathExists(dataSource.getLocation(), "jsonPath invalid:");
// File json = new File(dataSource.getLocation());
// try {
// fileChangeMonitor = FileChangeMonitor.getInstance();
// fileChangeMonitor.init(json.toPath());
// if(Log.isDebugEnabled()) Log.debug("LuceneSearchServiceImpl::setupIndexMonitor","Index monitor setup completed.");
// } catch (IOException e) {
// throw new SearchException("Unable to initialize file change monitor",e);
// }
}
fileChangeMonitor = FileChangeMonitor.getInstance();
fileChangeMonitor.addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
JSONWithMetaData jsonContent;
try {
logger.log(FINE,"LuceneSearchServiceImpl::setupIndexMonitor", "Index monitor change noted.");
jsonContent = getJsonArrayFrom(dataSource);
} catch (SearchException e) {
throw new IllegalStateException(e);
}
setupIndex(dataSource, dataSchema, jsonContent);
}
});
} catch (Exception e) {
logger.log(SEVERE,"LuceneSearchServiceImpl::setupIndexMonitor Failed to setup monitor for indexed file changes", e);
}
} | [
"private",
"void",
"setupIndexMonitor",
"(",
"final",
"DataSchema",
"dataSchema",
",",
"final",
"GenericDataSource",
"dataSource",
")",
"{",
"logger",
".",
"log",
"(",
"FINE",
",",
"\"LuceneSearchServiceImpl::setupIndexMonitor Attempting to setup Index monitor...\"",
")",
"... | setup a monitor to watch for changes in datasource
@param dataSchema
@param dataSource | [
"setup",
"a",
"monitor",
"to",
"watch",
"for",
"changes",
"in",
"datasource"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/SurveyorCore/src/main/java/org/wwarn/surveyor/server/core/LuceneSearchServiceImpl.java#L120-L158 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ValidationReqUrlUtil.java | ValidationReqUrlUtil.getUrlListFromValidationDatas | public static List<ReqUrl> getUrlListFromValidationDatas(List<ValidationData> datas) {
Map<String, ReqUrl> urlMap = new HashMap<>();
datas.stream().forEach(data -> {
ReqUrl url = new ReqUrl(data);
urlMap.put(url.getUniqueKey(), url);
});
return urlMap.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList());
} | java | public static List<ReqUrl> getUrlListFromValidationDatas(List<ValidationData> datas) {
Map<String, ReqUrl> urlMap = new HashMap<>();
datas.stream().forEach(data -> {
ReqUrl url = new ReqUrl(data);
urlMap.put(url.getUniqueKey(), url);
});
return urlMap.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList());
} | [
"public",
"static",
"List",
"<",
"ReqUrl",
">",
"getUrlListFromValidationDatas",
"(",
"List",
"<",
"ValidationData",
">",
"datas",
")",
"{",
"Map",
"<",
"String",
",",
"ReqUrl",
">",
"urlMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"datas",
".",
"st... | Gets url list from validation datas.
@param datas the datas
@return the url list from validation datas | [
"Gets",
"url",
"list",
"from",
"validation",
"datas",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ValidationReqUrlUtil.java#L22-L30 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/intset/ConciseSet.java | ConciseSet.appendLiteral | private void appendLiteral(int word)
{
// when we have a zero sequence of the maximum lenght (that is,
// 00.00000.1111111111111111111111111 = 0x01FFFFFF), it could happen
// that we try to append a zero literal because the result of the given operation must be an
// empty set. Whitout the following test, we would have increased the
// counter of the zero sequence, thus obtaining 0x02000000 that
// represents a sequence with the first bit set!
if (lastWordIndex == 0 && word == ConciseSetUtils.ALL_ZEROS_LITERAL && words[0] == 0x01FFFFFF) {
return;
}
// first addition
if (lastWordIndex < 0) {
words[lastWordIndex = 0] = word;
return;
}
final int lastWord = words[lastWordIndex];
if (word == ConciseSetUtils.ALL_ZEROS_LITERAL) {
if (lastWord == ConciseSetUtils.ALL_ZEROS_LITERAL) {
words[lastWordIndex] = 1;
} else if (isZeroSequence(lastWord)) {
words[lastWordIndex]++;
} else if (!simulateWAH && containsOnlyOneBit(getLiteralBits(lastWord))) {
words[lastWordIndex] = 1 | ((1 + Integer.numberOfTrailingZeros(lastWord)) << 25);
} else {
words[++lastWordIndex] = word;
}
} else if (word == ConciseSetUtils.ALL_ONES_LITERAL) {
if (lastWord == ConciseSetUtils.ALL_ONES_LITERAL) {
words[lastWordIndex] = ConciseSetUtils.SEQUENCE_BIT | 1;
} else if (isOneSequence(lastWord)) {
words[lastWordIndex]++;
} else if (!simulateWAH && containsOnlyOneBit(~lastWord)) {
words[lastWordIndex] = ConciseSetUtils.SEQUENCE_BIT | 1 | ((1 + Integer.numberOfTrailingZeros(~lastWord))
<< 25);
} else {
words[++lastWordIndex] = word;
}
} else {
words[++lastWordIndex] = word;
}
} | java | private void appendLiteral(int word)
{
// when we have a zero sequence of the maximum lenght (that is,
// 00.00000.1111111111111111111111111 = 0x01FFFFFF), it could happen
// that we try to append a zero literal because the result of the given operation must be an
// empty set. Whitout the following test, we would have increased the
// counter of the zero sequence, thus obtaining 0x02000000 that
// represents a sequence with the first bit set!
if (lastWordIndex == 0 && word == ConciseSetUtils.ALL_ZEROS_LITERAL && words[0] == 0x01FFFFFF) {
return;
}
// first addition
if (lastWordIndex < 0) {
words[lastWordIndex = 0] = word;
return;
}
final int lastWord = words[lastWordIndex];
if (word == ConciseSetUtils.ALL_ZEROS_LITERAL) {
if (lastWord == ConciseSetUtils.ALL_ZEROS_LITERAL) {
words[lastWordIndex] = 1;
} else if (isZeroSequence(lastWord)) {
words[lastWordIndex]++;
} else if (!simulateWAH && containsOnlyOneBit(getLiteralBits(lastWord))) {
words[lastWordIndex] = 1 | ((1 + Integer.numberOfTrailingZeros(lastWord)) << 25);
} else {
words[++lastWordIndex] = word;
}
} else if (word == ConciseSetUtils.ALL_ONES_LITERAL) {
if (lastWord == ConciseSetUtils.ALL_ONES_LITERAL) {
words[lastWordIndex] = ConciseSetUtils.SEQUENCE_BIT | 1;
} else if (isOneSequence(lastWord)) {
words[lastWordIndex]++;
} else if (!simulateWAH && containsOnlyOneBit(~lastWord)) {
words[lastWordIndex] = ConciseSetUtils.SEQUENCE_BIT | 1 | ((1 + Integer.numberOfTrailingZeros(~lastWord))
<< 25);
} else {
words[++lastWordIndex] = word;
}
} else {
words[++lastWordIndex] = word;
}
} | [
"private",
"void",
"appendLiteral",
"(",
"int",
"word",
")",
"{",
"// when we have a zero sequence of the maximum lenght (that is,\r",
"// 00.00000.1111111111111111111111111 = 0x01FFFFFF), it could happen\r",
"// that we try to append a zero literal because the result of the given operation must... | Append a literal word after the last word
@param word the new literal word. Note that the leftmost bit <b>must</b>
be set to 1. | [
"Append",
"a",
"literal",
"word",
"after",
"the",
"last",
"word"
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/intset/ConciseSet.java#L809-L852 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/index/util/ValidationIndexUtil.java | ValidationIndexUtil.addIndexData | public static void addIndexData(ValidationData data, ValidationDataIndex index) {
String key = index.getKey(data);
List<ValidationData> datas = index.get(key);
if (datas == null) {
datas = new ArrayList<>();
}
datas.add(data);
index.getMap().put(key, datas);
} | java | public static void addIndexData(ValidationData data, ValidationDataIndex index) {
String key = index.getKey(data);
List<ValidationData> datas = index.get(key);
if (datas == null) {
datas = new ArrayList<>();
}
datas.add(data);
index.getMap().put(key, datas);
} | [
"public",
"static",
"void",
"addIndexData",
"(",
"ValidationData",
"data",
",",
"ValidationDataIndex",
"index",
")",
"{",
"String",
"key",
"=",
"index",
".",
"getKey",
"(",
"data",
")",
";",
"List",
"<",
"ValidationData",
">",
"datas",
"=",
"index",
".",
"... | Add index data.
@param data the data
@param index the index | [
"Add",
"index",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/index/util/ValidationIndexUtil.java#L21-L29 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/index/util/ValidationIndexUtil.java | ValidationIndexUtil.removeIndexData | public static void removeIndexData(ValidationData data, ValidationDataIndex index) {
String key = index.getKey(data);
List<ValidationData> datas = index.get(key);
if (!datas.isEmpty()) {
datas = datas.stream().filter(d -> !d.getId().equals(data.getId())).collect(Collectors.toList());
}
if (datas.isEmpty()) {
index.getMap().remove(key);
} else {
index.getMap().put(key, datas);
}
} | java | public static void removeIndexData(ValidationData data, ValidationDataIndex index) {
String key = index.getKey(data);
List<ValidationData> datas = index.get(key);
if (!datas.isEmpty()) {
datas = datas.stream().filter(d -> !d.getId().equals(data.getId())).collect(Collectors.toList());
}
if (datas.isEmpty()) {
index.getMap().remove(key);
} else {
index.getMap().put(key, datas);
}
} | [
"public",
"static",
"void",
"removeIndexData",
"(",
"ValidationData",
"data",
",",
"ValidationDataIndex",
"index",
")",
"{",
"String",
"key",
"=",
"index",
".",
"getKey",
"(",
"data",
")",
";",
"List",
"<",
"ValidationData",
">",
"datas",
"=",
"index",
".",
... | Remove index data.
@param data the data
@param index the index | [
"Remove",
"index",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/index/util/ValidationIndexUtil.java#L37-L50 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/index/util/ValidationIndexUtil.java | ValidationIndexUtil.makeKey | public static String makeKey(String... keys) {
StringBuffer keyBuffer = new StringBuffer();
for (String s : keys) {
keyBuffer.append(s);
keyBuffer.append(":");
}
return keyBuffer.toString();
} | java | public static String makeKey(String... keys) {
StringBuffer keyBuffer = new StringBuffer();
for (String s : keys) {
keyBuffer.append(s);
keyBuffer.append(":");
}
return keyBuffer.toString();
} | [
"public",
"static",
"String",
"makeKey",
"(",
"String",
"...",
"keys",
")",
"{",
"StringBuffer",
"keyBuffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"String",
"s",
":",
"keys",
")",
"{",
"keyBuffer",
".",
"append",
"(",
"s",
")",
";",
... | Make key string.
@param keys the keys
@return the string | [
"Make",
"key",
"string",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/index/util/ValidationIndexUtil.java#L58-L65 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ParameterMapper.java | ParameterMapper.findMethod | public static Method findMethod(Class<?> c, String methodName) {
for (Method m : c.getMethods()) {
if (!m.getName().equalsIgnoreCase(methodName)) {
continue;
}
if (m.getParameterCount() != 1) {
continue;
}
return m;
}
return null;
} | java | public static Method findMethod(Class<?> c, String methodName) {
for (Method m : c.getMethods()) {
if (!m.getName().equalsIgnoreCase(methodName)) {
continue;
}
if (m.getParameterCount() != 1) {
continue;
}
return m;
}
return null;
} | [
"public",
"static",
"Method",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"String",
"methodName",
")",
"{",
"for",
"(",
"Method",
"m",
":",
"c",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"!",
"m",
".",
"getName",
"(",
")",
".",
... | Find method method.
@param c the c
@param methodName the method name
@return the method | [
"Find",
"method",
"method",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ParameterMapper.java#L92-L104 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ParameterMapper.java | ParameterMapper.castValue | @SuppressWarnings("PMD.LooseCoupling")
public static Object castValue(Method m, Class<?> castType, String value) {
try {
if (castType.isEnum()) {
Method valueOf;
try {
valueOf = castType.getMethod("valueOf", String.class);
return valueOf.invoke(null, value);
} catch (Exception e) {
log.info("enum value of excute error : (" + castType.getName() + ") | " + value);
return null;
}
} else if (castType == Integer.class || castType == int.class) {
return Integer.parseInt(value);
} else if (castType == Long.class || castType == long.class) {
return Long.parseLong(value);
} else if (castType == Double.class || castType == double.class) {
return Double.parseDouble(value);
} else if (castType == Boolean.class || castType == boolean.class) {
return Boolean.parseBoolean(value);
} else if (castType == Float.class || castType == float.class) {
return Float.parseFloat(value);
} else if (castType == String.class) {
return value;
} else if (castType == ArrayList.class || castType == List.class) {
ParameterizedType paramType = (ParameterizedType) m.getGenericParameterTypes()[0];
Class<?> paramClass = (Class<?>) paramType.getActualTypeArguments()[0];
List<Object> castList = new ArrayList<>();
String[] values = value.split(",");
for (String v : values) {
castList.add(castValue(m, paramClass, v));
}
return castList;
} else {
log.info("invalid castType : " + castType);
return null;
}
} catch (NumberFormatException e) {
log.info("value : " + value + " is invalid value, setter parameter type is : " + castType);
return null;
}
} | java | @SuppressWarnings("PMD.LooseCoupling")
public static Object castValue(Method m, Class<?> castType, String value) {
try {
if (castType.isEnum()) {
Method valueOf;
try {
valueOf = castType.getMethod("valueOf", String.class);
return valueOf.invoke(null, value);
} catch (Exception e) {
log.info("enum value of excute error : (" + castType.getName() + ") | " + value);
return null;
}
} else if (castType == Integer.class || castType == int.class) {
return Integer.parseInt(value);
} else if (castType == Long.class || castType == long.class) {
return Long.parseLong(value);
} else if (castType == Double.class || castType == double.class) {
return Double.parseDouble(value);
} else if (castType == Boolean.class || castType == boolean.class) {
return Boolean.parseBoolean(value);
} else if (castType == Float.class || castType == float.class) {
return Float.parseFloat(value);
} else if (castType == String.class) {
return value;
} else if (castType == ArrayList.class || castType == List.class) {
ParameterizedType paramType = (ParameterizedType) m.getGenericParameterTypes()[0];
Class<?> paramClass = (Class<?>) paramType.getActualTypeArguments()[0];
List<Object> castList = new ArrayList<>();
String[] values = value.split(",");
for (String v : values) {
castList.add(castValue(m, paramClass, v));
}
return castList;
} else {
log.info("invalid castType : " + castType);
return null;
}
} catch (NumberFormatException e) {
log.info("value : " + value + " is invalid value, setter parameter type is : " + castType);
return null;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"PMD.LooseCoupling\"",
")",
"public",
"static",
"Object",
"castValue",
"(",
"Method",
"m",
",",
"Class",
"<",
"?",
">",
"castType",
",",
"String",
"value",
")",
"{",
"try",
"{",
"if",
"(",
"castType",
".",
"isEnum",
"(",
"... | Cast value object.
@param m the m
@param castType the cast type
@param value the value
@return the object | [
"Cast",
"value",
"object",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ParameterMapper.java#L114-L157 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/util/ParameterMapper.java | ParameterMapper.mapToObject | public static Object mapToObject(Map<String, String> map, Class<?> c) {
Method m = null;
Object obj = null;
try {
obj = c.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
log.info("instance create fail : " + c.getName());
return null;
}
for (Map.Entry<String, String> entry : map.entrySet()) {
if (entry.getValue() == null || entry.getValue().trim().isEmpty()) {
continue;
}
if (entry.getValue().equalsIgnoreCase("undefined")) {
continue;
}
try {
m = findMethod(c, getSetMethodName(entry.getKey()));
if (m == null) {
log.info("not found mapping method : " + entry.getKey());
continue;
}
try {
m.invoke(obj, castValue(m, m.getParameterTypes()[0], entry.getValue()));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
log.info("method invoke error : " + m.getName());
}
} catch (SecurityException e) {
log.info("security exception : " + e.getMessage());
}
}
return obj;
} | java | public static Object mapToObject(Map<String, String> map, Class<?> c) {
Method m = null;
Object obj = null;
try {
obj = c.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
log.info("instance create fail : " + c.getName());
return null;
}
for (Map.Entry<String, String> entry : map.entrySet()) {
if (entry.getValue() == null || entry.getValue().trim().isEmpty()) {
continue;
}
if (entry.getValue().equalsIgnoreCase("undefined")) {
continue;
}
try {
m = findMethod(c, getSetMethodName(entry.getKey()));
if (m == null) {
log.info("not found mapping method : " + entry.getKey());
continue;
}
try {
m.invoke(obj, castValue(m, m.getParameterTypes()[0], entry.getValue()));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
log.info("method invoke error : " + m.getName());
}
} catch (SecurityException e) {
log.info("security exception : " + e.getMessage());
}
}
return obj;
} | [
"public",
"static",
"Object",
"mapToObject",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"Method",
"m",
"=",
"null",
";",
"Object",
"obj",
"=",
"null",
";",
"try",
"{",
"obj",
"=",
"c",
".",
... | Map to object object.
@param map the map
@param c the c
@return the object | [
"Map",
"to",
"object",
"object",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/util/ParameterMapper.java#L167-L206 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByIds | public List<ValidationData> findByIds(List<Long> ids) {
return this.datas.stream().filter(d -> ids.contains(d.getId())).collect(Collectors.toList());
} | java | public List<ValidationData> findByIds(List<Long> ids) {
return this.datas.stream().filter(d -> ids.contains(d.getId())).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"ValidationData",
">",
"findByIds",
"(",
"List",
"<",
"Long",
">",
"ids",
")",
"{",
"return",
"this",
".",
"datas",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"d",
"->",
"ids",
".",
"contains",
"(",
"d",
".",
"getId",
"(",
... | Find by ids list.
@param ids the ids
@return the list | [
"Find",
"by",
"ids",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L90-L92 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findAll | public List<ValidationData> findAll(boolean referenceCache) {
if (referenceCache && this.datas != null) {
return this.datas;
}
List<ValidationData> list = null;
File repositroyFile = new File(this.validationConfig.getRepositoryPath());
try {
String jsonStr = ValidationFileUtil.readFileToString(repositroyFile, Charset.forName("UTF-8"));
list = objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, ValidationData.class));
} catch (IOException e) {
log.error("repository json file read error : " + repositroyFile.getAbsolutePath());
list = new ArrayList<>();
}
this.parentObjInit(list);
if (referenceCache) {
this.datas = list;
}
return list;
} | java | public List<ValidationData> findAll(boolean referenceCache) {
if (referenceCache && this.datas != null) {
return this.datas;
}
List<ValidationData> list = null;
File repositroyFile = new File(this.validationConfig.getRepositoryPath());
try {
String jsonStr = ValidationFileUtil.readFileToString(repositroyFile, Charset.forName("UTF-8"));
list = objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, ValidationData.class));
} catch (IOException e) {
log.error("repository json file read error : " + repositroyFile.getAbsolutePath());
list = new ArrayList<>();
}
this.parentObjInit(list);
if (referenceCache) {
this.datas = list;
}
return list;
} | [
"public",
"List",
"<",
"ValidationData",
">",
"findAll",
"(",
"boolean",
"referenceCache",
")",
"{",
"if",
"(",
"referenceCache",
"&&",
"this",
".",
"datas",
"!=",
"null",
")",
"{",
"return",
"this",
".",
"datas",
";",
"}",
"List",
"<",
"ValidationData",
... | Find all list.
@param referenceCache the reference cache
@return the list | [
"Find",
"all",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L119-L142 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByParamTypeAndMethodAndUrl | public List<ValidationData> findByParamTypeAndMethodAndUrl(ParamType paramType, String method, String url) {
return this.findByMethodAndUrl(method, url).stream().filter(d -> d.getParamType().equals(paramType)).collect(Collectors.toList());
} | java | public List<ValidationData> findByParamTypeAndMethodAndUrl(ParamType paramType, String method, String url) {
return this.findByMethodAndUrl(method, url).stream().filter(d -> d.getParamType().equals(paramType)).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"ValidationData",
">",
"findByParamTypeAndMethodAndUrl",
"(",
"ParamType",
"paramType",
",",
"String",
"method",
",",
"String",
"url",
")",
"{",
"return",
"this",
".",
"findByMethodAndUrl",
"(",
"method",
",",
"url",
")",
".",
"stream",
... | Find by param type and method and url list.
@param paramType the param type
@param method the method
@param url the url
@return the list | [
"Find",
"by",
"param",
"type",
"and",
"method",
"and",
"url",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L170-L172 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByParamTypeAndMethodAndUrlAndName | public List<ValidationData> findByParamTypeAndMethodAndUrlAndName(ParamType paramType, String method, String url, String name) {
return this.findByMethodAndUrlAndName(method, url, name).stream().filter(vd -> vd.getParamType().equals(paramType)).collect(Collectors.toList());
} | java | public List<ValidationData> findByParamTypeAndMethodAndUrlAndName(ParamType paramType, String method, String url, String name) {
return this.findByMethodAndUrlAndName(method, url, name).stream().filter(vd -> vd.getParamType().equals(paramType)).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"ValidationData",
">",
"findByParamTypeAndMethodAndUrlAndName",
"(",
"ParamType",
"paramType",
",",
"String",
"method",
",",
"String",
"url",
",",
"String",
"name",
")",
"{",
"return",
"this",
".",
"findByMethodAndUrlAndName",
"(",
"method",
... | Find by param type and method and url and name list.
@param paramType the param type
@param method the method
@param url the url
@param name the name
@return the list | [
"Find",
"by",
"param",
"type",
"and",
"method",
"and",
"url",
"and",
"name",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L183-L185 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByParamTypeAndMethodAndUrlAndNameAndParentId | public ValidationData findByParamTypeAndMethodAndUrlAndNameAndParentId(ParamType paramType, String method, String url, String name, Long parentId) {
if (parentId == null) {
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream().filter(d -> d.getParentId() == null).findAny().orElse(null);
}
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream()
.filter(d -> d.getParentId() != null && d.getParentId().equals(parentId)).findAny().orElse(null);
} | java | public ValidationData findByParamTypeAndMethodAndUrlAndNameAndParentId(ParamType paramType, String method, String url, String name, Long parentId) {
if (parentId == null) {
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream().filter(d -> d.getParentId() == null).findAny().orElse(null);
}
return this.findByParamTypeAndMethodAndUrlAndName(paramType, method, url, name).stream()
.filter(d -> d.getParentId() != null && d.getParentId().equals(parentId)).findAny().orElse(null);
} | [
"public",
"ValidationData",
"findByParamTypeAndMethodAndUrlAndNameAndParentId",
"(",
"ParamType",
"paramType",
",",
"String",
"method",
",",
"String",
"url",
",",
"String",
"name",
",",
"Long",
"parentId",
")",
"{",
"if",
"(",
"parentId",
"==",
"null",
")",
"{",
... | Find by param type and method and url and name and parent id validation data.
@param paramType the param type
@param method the method
@param url the url
@param name the name
@param parentId the parent id
@return the validation data | [
"Find",
"by",
"param",
"type",
"and",
"method",
"and",
"url",
"and",
"name",
"and",
"parent",
"id",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L197-L204 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByMethodAndUrlAndName | public List<ValidationData> findByMethodAndUrlAndName(String method, String url, String name) {
return this.findByMethodAndUrl(method, url).stream().filter(d -> d.getName().equalsIgnoreCase(name)).collect(Collectors.toList());
} | java | public List<ValidationData> findByMethodAndUrlAndName(String method, String url, String name) {
return this.findByMethodAndUrl(method, url).stream().filter(d -> d.getName().equalsIgnoreCase(name)).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"ValidationData",
">",
"findByMethodAndUrlAndName",
"(",
"String",
"method",
",",
"String",
"url",
",",
"String",
"name",
")",
"{",
"return",
"this",
".",
"findByMethodAndUrl",
"(",
"method",
",",
"url",
")",
".",
"stream",
"(",
")",
... | Find by method and url and name list.
@param method the method
@param url the url
@param name the name
@return the list | [
"Find",
"by",
"method",
"and",
"url",
"and",
"name",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L214-L216 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByParentId | public List<ValidationData> findByParentId(Long id) {
return this.datas.stream().filter(d -> d.getParentId() != null && d.getParentId().equals(id)).collect(Collectors.toList());
} | java | public List<ValidationData> findByParentId(Long id) {
return this.datas.stream().filter(d -> d.getParentId() != null && d.getParentId().equals(id)).collect(Collectors.toList());
} | [
"public",
"List",
"<",
"ValidationData",
">",
"findByParentId",
"(",
"Long",
"id",
")",
"{",
"return",
"this",
".",
"datas",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"d",
"->",
"d",
".",
"getParentId",
"(",
")",
"!=",
"null",
"&&",
"d",
".",
"g... | Find by parent id list.
@param id the id
@return the list | [
"Find",
"by",
"parent",
"id",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L225-L227 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.findByMethodAndUrlAndNameAndParentId | public ValidationData findByMethodAndUrlAndNameAndParentId(String method, String url, String name, Long parentId) {
if (parentId == null) {
return this.findByMethodAndUrlAndName(method, url, name).stream().filter(d -> d.getParentId() == null).findAny().orElse(null);
}
return this.findByMethodAndUrlAndName(method, url, name).stream()
.filter(d -> d.getParentId() != null && d.getParentId().equals(parentId)).findAny().orElse(null);
} | java | public ValidationData findByMethodAndUrlAndNameAndParentId(String method, String url, String name, Long parentId) {
if (parentId == null) {
return this.findByMethodAndUrlAndName(method, url, name).stream().filter(d -> d.getParentId() == null).findAny().orElse(null);
}
return this.findByMethodAndUrlAndName(method, url, name).stream()
.filter(d -> d.getParentId() != null && d.getParentId().equals(parentId)).findAny().orElse(null);
} | [
"public",
"ValidationData",
"findByMethodAndUrlAndNameAndParentId",
"(",
"String",
"method",
",",
"String",
"url",
",",
"String",
"name",
",",
"Long",
"parentId",
")",
"{",
"if",
"(",
"parentId",
"==",
"null",
")",
"{",
"return",
"this",
".",
"findByMethodAndUrl... | Find by method and url and name and parent id validation data.
@param method the method
@param url the url
@param name the name
@param parentId the parent id
@return the validation data | [
"Find",
"by",
"method",
"and",
"url",
"and",
"name",
"and",
"parent",
"id",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L239-L246 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.saveAll | public List<ValidationData> saveAll(List<ValidationData> pDatas) {
pDatas.forEach(this::save);
return pDatas;
} | java | public List<ValidationData> saveAll(List<ValidationData> pDatas) {
pDatas.forEach(this::save);
return pDatas;
} | [
"public",
"List",
"<",
"ValidationData",
">",
"saveAll",
"(",
"List",
"<",
"ValidationData",
">",
"pDatas",
")",
"{",
"pDatas",
".",
"forEach",
"(",
"this",
"::",
"save",
")",
";",
"return",
"pDatas",
";",
"}"
] | Save all list.
@param pDatas the p datas
@return the list | [
"Save",
"all",
"list",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L255-L258 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java | ValidationDataRepository.save | public ValidationData save(ValidationData data) {
if (data.getParamType() == null || data.getUrl() == null || data.getMethod() == null || data.getType() == null || data.getTypeClass() == null) {
throw new ValidationLibException("mandatory field is null ", HttpStatus.BAD_REQUEST);
}
ValidationData existData = this.findById(data.getId());
if (existData == null) {
return this.addData(data);
} else {
existData.setValidationRules(data.getValidationRules());
return existData;
}
} | java | public ValidationData save(ValidationData data) {
if (data.getParamType() == null || data.getUrl() == null || data.getMethod() == null || data.getType() == null || data.getTypeClass() == null) {
throw new ValidationLibException("mandatory field is null ", HttpStatus.BAD_REQUEST);
}
ValidationData existData = this.findById(data.getId());
if (existData == null) {
return this.addData(data);
} else {
existData.setValidationRules(data.getValidationRules());
return existData;
}
} | [
"public",
"ValidationData",
"save",
"(",
"ValidationData",
"data",
")",
"{",
"if",
"(",
"data",
".",
"getParamType",
"(",
")",
"==",
"null",
"||",
"data",
".",
"getUrl",
"(",
")",
"==",
"null",
"||",
"data",
".",
"getMethod",
"(",
")",
"==",
"null",
... | Save validation data.
@param data the data
@return the validation data | [
"Save",
"validation",
"data",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/repository/ValidationDataRepository.java#L302-L315 | train |
reinert/requestor | requestor/core/requestor-api/src/main/java/io/reinert/requestor/uri/UriBuilder.java | UriBuilder.fromPath | public static UriBuilder fromPath(String path) {
if (path == null)
throw new IllegalArgumentException("Path cannot be null");
final UriBuilder builder = newInstance();
builder.path(path);
return builder;
} | java | public static UriBuilder fromPath(String path) {
if (path == null)
throw new IllegalArgumentException("Path cannot be null");
final UriBuilder builder = newInstance();
builder.path(path);
return builder;
} | [
"public",
"static",
"UriBuilder",
"fromPath",
"(",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Path cannot be null\"",
")",
";",
"final",
"UriBuilder",
"builder",
"=",
"newInstance",
"(",
... | Create a new instance representing a relative URI initialized from a URI path.
@param path a URI path that will be used to initialize the UriBuilder, may contain URI template parameters.
@return a new UriBuilder
@throws IllegalArgumentException if path is null | [
"Create",
"a",
"new",
"instance",
"representing",
"a",
"relative",
"URI",
"initialized",
"from",
"a",
"URI",
"path",
"."
] | 40163a75cd17815d5089935d0dd97b8d652ad6d4 | https://github.com/reinert/requestor/blob/40163a75cd17815d5089935d0dd97b8d652ad6d4/requestor/core/requestor-api/src/main/java/io/reinert/requestor/uri/UriBuilder.java#L39-L46 | train |
lightblue-platform/lightblue-client | core/src/main/java/com/redhat/lightblue/client/util/JSON.java | JSON.toJson | public static String toJson(Object obj) {
StringWriter sw = new StringWriter();
ObjectMapper mapper = getDefaultObjectMapper();
try {
JsonGenerator jg = mapper.getFactory().createGenerator(sw);
mapper.writeValue(jg, obj);
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return sw.toString();
} | java | public static String toJson(Object obj) {
StringWriter sw = new StringWriter();
ObjectMapper mapper = getDefaultObjectMapper();
try {
JsonGenerator jg = mapper.getFactory().createGenerator(sw);
mapper.writeValue(jg, obj);
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return sw.toString();
} | [
"public",
"static",
"String",
"toJson",
"(",
"Object",
"obj",
")",
"{",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"ObjectMapper",
"mapper",
"=",
"getDefaultObjectMapper",
"(",
")",
";",
"try",
"{",
"JsonGenerator",
"jg",
"=",
"mapper",... | Convert object to json. If object contains fields of type date, they will
be converted to strings using lightblue date format.
@param obj
@return | [
"Convert",
"object",
"to",
"json",
".",
"If",
"object",
"contains",
"fields",
"of",
"type",
"date",
"they",
"will",
"be",
"converted",
"to",
"strings",
"using",
"lightblue",
"date",
"format",
"."
] | 03790aff34e90d3889f60fd6c603c21a21dc1a40 | https://github.com/lightblue-platform/lightblue-client/blob/03790aff34e90d3889f60fd6c603c21a21dc1a40/core/src/main/java/com/redhat/lightblue/client/util/JSON.java#L72-L86 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java | HashIntSet.remove | @Override
public boolean remove(int element)
{
if (element < 0) {
throw new IndexOutOfBoundsException("element < 0: " + element);
}
int index = findElementOrEmpty(element);
if (index < 0) {
return false;
}
cells[index] = REMOVED;
modCount++;
size--;
return true;
} | java | @Override
public boolean remove(int element)
{
if (element < 0) {
throw new IndexOutOfBoundsException("element < 0: " + element);
}
int index = findElementOrEmpty(element);
if (index < 0) {
return false;
}
cells[index] = REMOVED;
modCount++;
size--;
return true;
} | [
"@",
"Override",
"public",
"boolean",
"remove",
"(",
"int",
"element",
")",
"{",
"if",
"(",
"element",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"element < 0: \"",
"+",
"element",
")",
";",
"}",
"int",
"index",
"=",
"findEleme... | Removes the specified element from the set. | [
"Removes",
"the",
"specified",
"element",
"from",
"the",
"set",
"."
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java#L297-L312 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java | HashIntSet.clear | @Override
public void clear()
{
size = 0;
Arrays.fill(cells, EMPTY);
freecells = cells.length;
modCount++;
} | java | @Override
public void clear()
{
size = 0;
Arrays.fill(cells, EMPTY);
freecells = cells.length;
modCount++;
} | [
"@",
"Override",
"public",
"void",
"clear",
"(",
")",
"{",
"size",
"=",
"0",
";",
"Arrays",
".",
"fill",
"(",
"cells",
",",
"EMPTY",
")",
";",
"freecells",
"=",
"cells",
".",
"length",
";",
"modCount",
"++",
";",
"}"
] | Removes all of the elements from this set. | [
"Removes",
"all",
"of",
"the",
"elements",
"from",
"this",
"set",
"."
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java#L317-L324 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java | HashIntSet.rehash | protected void rehash()
{
// do we need to increase capacity, or are there so many
// deleted objects hanging around that rehashing to the same
// size is sufficient? if 5% (arbitrarily chosen number) of
// cells can be freed up by a rehash, we do it.
int gargagecells = cells.length - (size + freecells);
if ((double) gargagecells / cells.length > 0.05D)
// rehash with same size
{
rehash(cells.length);
} else
// rehash with increased capacity
{
rehash((cells.length << 1) + 1);
}
} | java | protected void rehash()
{
// do we need to increase capacity, or are there so many
// deleted objects hanging around that rehashing to the same
// size is sufficient? if 5% (arbitrarily chosen number) of
// cells can be freed up by a rehash, we do it.
int gargagecells = cells.length - (size + freecells);
if ((double) gargagecells / cells.length > 0.05D)
// rehash with same size
{
rehash(cells.length);
} else
// rehash with increased capacity
{
rehash((cells.length << 1) + 1);
}
} | [
"protected",
"void",
"rehash",
"(",
")",
"{",
"// do we need to increase capacity, or are there so many\r",
"// deleted objects hanging around that rehashing to the same\r",
"// size is sufficient? if 5% (arbitrarily chosen number) of\r",
"// cells can be freed up by a rehash, we do it.\r",
"int... | Figures out correct size for rehashed set, then does the rehash. | [
"Figures",
"out",
"correct",
"size",
"for",
"rehashed",
"set",
"then",
"does",
"the",
"rehash",
"."
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java#L329-L346 | train |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java | HashIntSet.rehash | protected void rehash(int newCapacity)
{
HashIntSet rehashed = new HashIntSet(newCapacity);
@SuppressWarnings("hiding")
int[] cells = rehashed.cells;
for (int element : this.cells) {
if (element < 0)
// removed or empty
{
continue;
}
// add the element
cells[-(rehashed.findElementOrEmpty(element) + 1)] = element;
}
this.cells = cells;
freecells = newCapacity - size;
modCount++;
} | java | protected void rehash(int newCapacity)
{
HashIntSet rehashed = new HashIntSet(newCapacity);
@SuppressWarnings("hiding")
int[] cells = rehashed.cells;
for (int element : this.cells) {
if (element < 0)
// removed or empty
{
continue;
}
// add the element
cells[-(rehashed.findElementOrEmpty(element) + 1)] = element;
}
this.cells = cells;
freecells = newCapacity - size;
modCount++;
} | [
"protected",
"void",
"rehash",
"(",
"int",
"newCapacity",
")",
"{",
"HashIntSet",
"rehashed",
"=",
"new",
"HashIntSet",
"(",
"newCapacity",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"hiding\"",
")",
"int",
"[",
"]",
"cells",
"=",
"rehashed",
".",
"cells",
... | Rehashes to a bigger size. | [
"Rehashes",
"to",
"a",
"bigger",
"size",
"."
] | 0f77c28057fac9c1bd6d79fbe5425b8efe5742a8 | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/intset/HashIntSet.java#L351-L369 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/helper/CheckPointHelper.java | CheckPointHelper.replaceExceptionCallback | public CheckPointHelper replaceExceptionCallback(BasicCheckRule checkRule, ValidationInvalidCallback cb) {
this.msgChecker.replaceCallback(checkRule, cb);
return this;
} | java | public CheckPointHelper replaceExceptionCallback(BasicCheckRule checkRule, ValidationInvalidCallback cb) {
this.msgChecker.replaceCallback(checkRule, cb);
return this;
} | [
"public",
"CheckPointHelper",
"replaceExceptionCallback",
"(",
"BasicCheckRule",
"checkRule",
",",
"ValidationInvalidCallback",
"cb",
")",
"{",
"this",
".",
"msgChecker",
".",
"replaceCallback",
"(",
"checkRule",
",",
"cb",
")",
";",
"return",
"this",
";",
"}"
] | Replace the callback to be used basic exception.
@param checkRule basic rule type ex,, BasicCheckRule.Mandatory
@param cb callback class with implement ValidationInvalidCallback
@return CheckPointHeler check point helper | [
"Replace",
"the",
"callback",
"to",
"be",
"used",
"basic",
"exception",
"."
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/helper/CheckPointHelper.java#L49-L52 | train |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/helper/CheckPointHelper.java | CheckPointHelper.addValidationRule | public CheckPointHelper addValidationRule(String ruleName, StandardValueType standardValueType, BaseValidationCheck validationCheck, AssistType assistType) {
ValidationRule rule = new ValidationRule(ruleName, standardValueType, validationCheck);
if (assistType == null) {
assistType = AssistType.all();
}
rule.setAssistType(assistType);
this.validationRuleStore.addRule(rule);
return this;
} | java | public CheckPointHelper addValidationRule(String ruleName, StandardValueType standardValueType, BaseValidationCheck validationCheck, AssistType assistType) {
ValidationRule rule = new ValidationRule(ruleName, standardValueType, validationCheck);
if (assistType == null) {
assistType = AssistType.all();
}
rule.setAssistType(assistType);
this.validationRuleStore.addRule(rule);
return this;
} | [
"public",
"CheckPointHelper",
"addValidationRule",
"(",
"String",
"ruleName",
",",
"StandardValueType",
"standardValueType",
",",
"BaseValidationCheck",
"validationCheck",
",",
"AssistType",
"assistType",
")",
"{",
"ValidationRule",
"rule",
"=",
"new",
"ValidationRule",
"... | Add the fresh user rule
@param ruleName use rule name - must uniqueue
@param standardValueType rule check standardvalue type
@param validationCheck rule check class with extends BaseValidationCheck and overide replace or check method and exception method
@param assistType input field type
@return CheckPointHelper check point helper | [
"Add",
"the",
"fresh",
"user",
"rule"
] | 2c2b1a87a88485d49ea6afa34acdf16ef4134f19 | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/helper/CheckPointHelper.java#L63-L71 | train |
WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor | MapCore/src/main/java/org/wwarn/mapcore/client/utils/Track.java | Track.track | private static void track(String historyToken) {
if (historyToken == null) {
historyToken = "historyToken_null";
}
historyToken = URL.encode("/WWARN-GWT-Analytics/V1.0/" + historyToken);
boolean hasErrored = false;
try{
trackGoogleAnalytics(historyToken);
}catch (JavaScriptException e){
hasErrored = true;
GWT.log("Unable to track" ,e);
}
if(!hasErrored) GWT.log("Tracked " + historyToken);
} | java | private static void track(String historyToken) {
if (historyToken == null) {
historyToken = "historyToken_null";
}
historyToken = URL.encode("/WWARN-GWT-Analytics/V1.0/" + historyToken);
boolean hasErrored = false;
try{
trackGoogleAnalytics(historyToken);
}catch (JavaScriptException e){
hasErrored = true;
GWT.log("Unable to track" ,e);
}
if(!hasErrored) GWT.log("Tracked " + historyToken);
} | [
"private",
"static",
"void",
"track",
"(",
"String",
"historyToken",
")",
"{",
"if",
"(",
"historyToken",
"==",
"null",
")",
"{",
"historyToken",
"=",
"\"historyToken_null\"",
";",
"}",
"historyToken",
"=",
"URL",
".",
"encode",
"(",
"\"/WWARN-GWT-Analytics/V1.0... | track an event
@param historyToken | [
"track",
"an",
"event"
] | 224280bcd6e8045bda6b673584caf0aea5e4c841 | https://github.com/WorldwideAntimalarialResistanceNetwork/WWARN-Maps-Surveyor/blob/224280bcd6e8045bda6b673584caf0aea5e4c841/MapCore/src/main/java/org/wwarn/mapcore/client/utils/Track.java#L74-L89 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.