repository_name
stringlengths
7
58
func_path_in_repository
stringlengths
18
192
func_name
stringlengths
5
108
whole_func_string
stringlengths
75
3.91k
language
stringclasses
1 value
func_code_string
stringlengths
75
3.91k
func_code_tokens
listlengths
21
629
func_documentation_string
stringlengths
61
1.98k
func_documentation_tokens
listlengths
1
647
split_name
stringclasses
1 value
func_code_url
stringlengths
111
306
jronrun/benayn
benayn-ustyle/src/main/java/com/benayn/ustyle/string/AbstrStrMatcher.java
AbstrStrMatcher.isEmpty
public boolean isEmpty(String... specialValueAsEmpty) { if (Strings.isNullOrEmpty(delegate.get())) { return true; } if (null == specialValueAsEmpty || specialValueAsEmpty.length < 1) { return false; } if (Gather.from(Arrays.asList(checkNotNull(specialValueAsEmpty))).filter(new Decision<String>(){ @Override public boolean apply(String input) { return isEqual(input, delegate.get()); } }).noneNullList().size() > 0) { return true; } return Decisions.isEmpty().apply(delegate.get()); }
java
public boolean isEmpty(String... specialValueAsEmpty) { if (Strings.isNullOrEmpty(delegate.get())) { return true; } if (null == specialValueAsEmpty || specialValueAsEmpty.length < 1) { return false; } if (Gather.from(Arrays.asList(checkNotNull(specialValueAsEmpty))).filter(new Decision<String>(){ @Override public boolean apply(String input) { return isEqual(input, delegate.get()); } }).noneNullList().size() > 0) { return true; } return Decisions.isEmpty().apply(delegate.get()); }
[ "public", "boolean", "isEmpty", "(", "String", "...", "specialValueAsEmpty", ")", "{", "if", "(", "Strings", ".", "isNullOrEmpty", "(", "delegate", ".", "get", "(", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "null", "==", "specialValueAsE...
Checks if a delegate string is empty ("") or null or special value. @param specialValueAsEmpty @return
[ "Checks", "if", "a", "delegate", "string", "is", "empty", "(", ")", "or", "null", "or", "special", "value", "." ]
train
https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/string/AbstrStrMatcher.java#L242-L260
geomajas/geomajas-project-geometry
core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java
GeometryIndexService.addChildren
public GeometryIndex addChildren(GeometryIndex index, GeometryIndexType type, int... values) { if (index == null) { return create(type, values); } if (getType(index) != GeometryIndexType.TYPE_GEOMETRY) { throw new IllegalArgumentException("Can only add children to an index of type geometry."); } GeometryIndex clone = new GeometryIndex(index); GeometryIndex deepestChild = clone; while (deepestChild.hasChild()) { deepestChild = deepestChild.getChild(); } deepestChild.setChild(create(type, values)); return clone; }
java
public GeometryIndex addChildren(GeometryIndex index, GeometryIndexType type, int... values) { if (index == null) { return create(type, values); } if (getType(index) != GeometryIndexType.TYPE_GEOMETRY) { throw new IllegalArgumentException("Can only add children to an index of type geometry."); } GeometryIndex clone = new GeometryIndex(index); GeometryIndex deepestChild = clone; while (deepestChild.hasChild()) { deepestChild = deepestChild.getChild(); } deepestChild.setChild(create(type, values)); return clone; }
[ "public", "GeometryIndex", "addChildren", "(", "GeometryIndex", "index", ",", "GeometryIndexType", "type", ",", "int", "...", "values", ")", "{", "if", "(", "index", "==", "null", ")", "{", "return", "create", "(", "type", ",", "values", ")", ";", "}", "...
Given a certain geometry index, add more levels to it (This method will not change the underlying geometry !). @param index The index to start out from. @param type Add more levels to it, where the deepest level should be of this type. @param values A list of integer values that determine the indices on each level in the index. @return The recursive geometry index resulting from adding the given parameters to the given parent index.
[ "Given", "a", "certain", "geometry", "index", "add", "more", "levels", "to", "it", "(", "This", "method", "will", "not", "change", "the", "underlying", "geometry", "!", ")", "." ]
train
https://github.com/geomajas/geomajas-project-geometry/blob/09a214fede69c9c01e41630828c4abbb551a557d/core/src/main/java/org/geomajas/geometry/service/GeometryIndexService.java#L71-L86
rototor/pdfbox-graphics2d
src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java
PdfBoxGraphics2DFontTextDrawer.mapFont
@SuppressWarnings("WeakerAccess") protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException { /* * If we have any font registering's, we must perform them now */ for (final FontEntry fontEntry : fontFiles) { if (fontEntry.overrideName == null) { Font javaFont = Font.createFont(Font.TRUETYPE_FONT, fontEntry.file); fontEntry.overrideName = javaFont.getFontName(); } if (fontEntry.file.getName().toLowerCase(Locale.US).endsWith(".ttc")) { TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file); collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() { @Override public void process(TrueTypeFont ttf) throws IOException { PDFont pdFont = PDType0Font.load(env.getDocument(), ttf, true); fontMap.put(fontEntry.overrideName, pdFont); fontMap.put(pdFont.getName(), pdFont); } }); } else { /* * We load the font using the file. */ PDFont pdFont = PDType0Font.load(env.getDocument(), fontEntry.file); fontMap.put(fontEntry.overrideName, pdFont); } } fontFiles.clear(); return fontMap.get(font.getFontName()); }
java
@SuppressWarnings("WeakerAccess") protected PDFont mapFont(final Font font, final IFontTextDrawerEnv env) throws IOException, FontFormatException { /* * If we have any font registering's, we must perform them now */ for (final FontEntry fontEntry : fontFiles) { if (fontEntry.overrideName == null) { Font javaFont = Font.createFont(Font.TRUETYPE_FONT, fontEntry.file); fontEntry.overrideName = javaFont.getFontName(); } if (fontEntry.file.getName().toLowerCase(Locale.US).endsWith(".ttc")) { TrueTypeCollection collection = new TrueTypeCollection(fontEntry.file); collection.processAllFonts(new TrueTypeCollection.TrueTypeFontProcessor() { @Override public void process(TrueTypeFont ttf) throws IOException { PDFont pdFont = PDType0Font.load(env.getDocument(), ttf, true); fontMap.put(fontEntry.overrideName, pdFont); fontMap.put(pdFont.getName(), pdFont); } }); } else { /* * We load the font using the file. */ PDFont pdFont = PDType0Font.load(env.getDocument(), fontEntry.file); fontMap.put(fontEntry.overrideName, pdFont); } } fontFiles.clear(); return fontMap.get(font.getFontName()); }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "protected", "PDFont", "mapFont", "(", "final", "Font", "font", ",", "final", "IFontTextDrawerEnv", "env", ")", "throws", "IOException", ",", "FontFormatException", "{", "/*\n\t\t * If we have any font registering's, ...
Try to map the java.awt.Font to a PDFont. @param font the java.awt.Font for which a mapping should be found @param env environment of the font mapper @return the PDFont or null if none can be found.
[ "Try", "to", "map", "the", "java", ".", "awt", ".", "Font", "to", "a", "PDFont", "." ]
train
https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java#L408-L439
sarl/sarl
main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java
SARLQuickfixProvider.fixInvalidImplementedType
@Fix(io.sarl.lang.validation.IssueCodes.INVALID_IMPLEMENTED_TYPE) public void fixInvalidImplementedType(final Issue issue, IssueResolutionAcceptor acceptor) { ImplementedTypeRemoveModification.accept(this, issue, acceptor, RemovalType.OTHER); }
java
@Fix(io.sarl.lang.validation.IssueCodes.INVALID_IMPLEMENTED_TYPE) public void fixInvalidImplementedType(final Issue issue, IssueResolutionAcceptor acceptor) { ImplementedTypeRemoveModification.accept(this, issue, acceptor, RemovalType.OTHER); }
[ "@", "Fix", "(", "io", ".", "sarl", ".", "lang", ".", "validation", ".", "IssueCodes", ".", "INVALID_IMPLEMENTED_TYPE", ")", "public", "void", "fixInvalidImplementedType", "(", "final", "Issue", "issue", ",", "IssueResolutionAcceptor", "acceptor", ")", "{", "Imp...
Quick fix for "Invalid implemented type". @param issue the issue. @param acceptor the quick fix acceptor.
[ "Quick", "fix", "for", "Invalid", "implemented", "type", "." ]
train
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java#L805-L808
geomajas/geomajas-project-client-gwt
client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java
Feature.setStringAttribute
public void setStringAttribute(String name, String value) { Attribute attribute = getAttributes().get(name); if (!(attribute instanceof StringAttribute)) { throw new IllegalStateException("Cannot set boolean value on attribute with different type, " + attribute.getClass().getName() + " setting value " + value); } ((StringAttribute) attribute).setValue(value); }
java
public void setStringAttribute(String name, String value) { Attribute attribute = getAttributes().get(name); if (!(attribute instanceof StringAttribute)) { throw new IllegalStateException("Cannot set boolean value on attribute with different type, " + attribute.getClass().getName() + " setting value " + value); } ((StringAttribute) attribute).setValue(value); }
[ "public", "void", "setStringAttribute", "(", "String", "name", ",", "String", "value", ")", "{", "Attribute", "attribute", "=", "getAttributes", "(", ")", ".", "get", "(", "name", ")", ";", "if", "(", "!", "(", "attribute", "instanceof", "StringAttribute", ...
Set attribute value of given type. @param name attribute name @param value attribute value
[ "Set", "attribute", "value", "of", "given", "type", "." ]
train
https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java#L350-L357
mygreen/xlsmapper
src/main/java/com/gh/mygreen/xlsmapper/XlsLoader.java
XlsLoader.loadDetail
public <P> SheetBindingErrors<P> loadDetail(final InputStream xlsIn, final Class<P> clazz) throws XlsMapperException, IOException { ArgUtils.notNull(xlsIn, "xlsIn"); ArgUtils.notNull(clazz, "clazz"); final AnnotationReader annoReader = new AnnotationReader(configuration.getAnnotationMapping().orElse(null)); final XlsSheet sheetAnno = annoReader.getAnnotation(clazz, XlsSheet.class); if(sheetAnno == null) { throw new AnnotationInvalidException(sheetAnno, MessageBuilder.create("anno.notFound") .varWithClass("property", clazz) .varWithAnno("anno", XlsSheet.class) .format()); } final Workbook book; try { book = WorkbookFactory.create(xlsIn); } catch (InvalidFormatException e) { throw new XlsMapperException(MessageBuilder.create("file.failLoadExcel.notSupportType").format(), e); } try { final Sheet[] xlsSheet = configuration.getSheetFinder().findForLoading(book, sheetAnno, annoReader, clazz); return loadSheet(xlsSheet[0], clazz, annoReader); } catch(SheetNotFoundException e) { if(configuration.isIgnoreSheetNotFound()){ logger.warn(MessageBuilder.create("log.skipNotFoundSheet").format(), e); return null; } else { throw e; } } }
java
public <P> SheetBindingErrors<P> loadDetail(final InputStream xlsIn, final Class<P> clazz) throws XlsMapperException, IOException { ArgUtils.notNull(xlsIn, "xlsIn"); ArgUtils.notNull(clazz, "clazz"); final AnnotationReader annoReader = new AnnotationReader(configuration.getAnnotationMapping().orElse(null)); final XlsSheet sheetAnno = annoReader.getAnnotation(clazz, XlsSheet.class); if(sheetAnno == null) { throw new AnnotationInvalidException(sheetAnno, MessageBuilder.create("anno.notFound") .varWithClass("property", clazz) .varWithAnno("anno", XlsSheet.class) .format()); } final Workbook book; try { book = WorkbookFactory.create(xlsIn); } catch (InvalidFormatException e) { throw new XlsMapperException(MessageBuilder.create("file.failLoadExcel.notSupportType").format(), e); } try { final Sheet[] xlsSheet = configuration.getSheetFinder().findForLoading(book, sheetAnno, annoReader, clazz); return loadSheet(xlsSheet[0], clazz, annoReader); } catch(SheetNotFoundException e) { if(configuration.isIgnoreSheetNotFound()){ logger.warn(MessageBuilder.create("log.skipNotFoundSheet").format(), e); return null; } else { throw e; } } }
[ "public", "<", "P", ">", "SheetBindingErrors", "<", "P", ">", "loadDetail", "(", "final", "InputStream", "xlsIn", ",", "final", "Class", "<", "P", ">", "clazz", ")", "throws", "XlsMapperException", ",", "IOException", "{", "ArgUtils", ".", "notNull", "(", ...
Excelファイルの1シートを読み込み、任意のクラスにマッピングする。 @param <P> シートをマッピングするクラスタイプ @param xlsIn 読み込み元のExcelファイルのストリーム。 @param clazz マッピング先のクラスタイプ。 @return マッピングの詳細情報。 {@link Configuration#isIgnoreSheetNotFound()}の値がtrueで、シートが見つからない場合、nullを返します。 @throws IllegalArgumentException {@literal xlsIn == null or clazz == null} @throws XlsMapperException Excelファイルのマッピングに失敗した場合 @throws IOException ファイルの読み込みに失敗した場合
[ "Excelファイルの1シートを読み込み、任意のクラスにマッピングする。" ]
train
https://github.com/mygreen/xlsmapper/blob/a0c6b25c622e5f3a50b199ef685d2ee46ad5483c/src/main/java/com/gh/mygreen/xlsmapper/XlsLoader.java#L102-L139
craftercms/commons
utilities/src/main/java/org/craftercms/commons/zip/ZipUtils.java
ZipUtils.zipFiles
public static void zipFiles(List<File> files, OutputStream outputStream) throws IOException { ZipOutputStream zos = new ZipOutputStream(outputStream); for (File file : files) { if (file.isDirectory()) { //if it's a folder addFolderToZip("", file, zos); } else { addFileToZip("", file, zos); } } zos.finish(); }
java
public static void zipFiles(List<File> files, OutputStream outputStream) throws IOException { ZipOutputStream zos = new ZipOutputStream(outputStream); for (File file : files) { if (file.isDirectory()) { //if it's a folder addFolderToZip("", file, zos); } else { addFileToZip("", file, zos); } } zos.finish(); }
[ "public", "static", "void", "zipFiles", "(", "List", "<", "File", ">", "files", ",", "OutputStream", "outputStream", ")", "throws", "IOException", "{", "ZipOutputStream", "zos", "=", "new", "ZipOutputStream", "(", "outputStream", ")", ";", "for", "(", "File", ...
Zips a collection of files to a destination zip output stream. @param files A collection of files and directories @param outputStream The output stream of the destination zip file @throws FileNotFoundException @throws IOException
[ "Zips", "a", "collection", "of", "files", "to", "a", "destination", "zip", "output", "stream", "." ]
train
https://github.com/craftercms/commons/blob/3074fe49e56c2a4aae0832f40b17ae563335dc83/utilities/src/main/java/org/craftercms/commons/zip/ZipUtils.java#L53-L65