id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
62,600
haraldk/TwelveMonkeys
imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/AdobePathBuilder.java
AdobePathBuilder.path
public Path2D path() throws IOException { List<List<AdobePathSegment>> subPaths = new ArrayList<List<AdobePathSegment>>(); List<AdobePathSegment> currentPath = null; int currentPathLength = 0; AdobePathSegment segment; while ((segment = nextSegment()) != null) { if ...
java
public Path2D path() throws IOException { List<List<AdobePathSegment>> subPaths = new ArrayList<List<AdobePathSegment>>(); List<AdobePathSegment> currentPath = null; int currentPathLength = 0; AdobePathSegment segment; while ((segment = nextSegment()) != null) { if ...
[ "public", "Path2D", "path", "(", ")", "throws", "IOException", "{", "List", "<", "List", "<", "AdobePathSegment", ">>", "subPaths", "=", "new", "ArrayList", "<", "List", "<", "AdobePathSegment", ">", ">", "(", ")", ";", "List", "<", "AdobePathSegment", ">"...
Builds the path. @return the path @throws javax.imageio.IIOException if the input contains a bad path data. @throws IOException if a general I/O exception occurs during reading.
[ "Builds", "the", "path", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/AdobePathBuilder.java#L93-L142
62,601
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/image/TextRenderer.java
TextRenderer.getFontStyle
private int getFontStyle(String pStyle) { if (pStyle == null || StringUtil.containsIgnoreCase(pStyle, FONT_STYLE_PLAIN)) { return Font.PLAIN; } // Try to find bold/italic int style = Font.PLAIN; if (StringUtil.containsIgnoreCase(pStyle, FONT_STYLE_BOLD)) { ...
java
private int getFontStyle(String pStyle) { if (pStyle == null || StringUtil.containsIgnoreCase(pStyle, FONT_STYLE_PLAIN)) { return Font.PLAIN; } // Try to find bold/italic int style = Font.PLAIN; if (StringUtil.containsIgnoreCase(pStyle, FONT_STYLE_BOLD)) { ...
[ "private", "int", "getFontStyle", "(", "String", "pStyle", ")", "{", "if", "(", "pStyle", "==", "null", "||", "StringUtil", ".", "containsIgnoreCase", "(", "pStyle", ",", "FONT_STYLE_PLAIN", ")", ")", "{", "return", "Font", ".", "PLAIN", ";", "}", "// Try ...
Returns the font style constant. @param pStyle a string containing either the word {@code "plain"} or one or more of {@code "bold"} and {@code italic}. @return the font style constant as defined in {@link Font}. @see Font#PLAIN @see Font#BOLD @see Font#ITALIC
[ "Returns", "the", "font", "style", "constant", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/image/TextRenderer.java#L301-L316
62,602
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/image/TextRenderer.java
TextRenderer.getAngle
private double getAngle(ServletRequest pRequest) { // Get angle double angle = ServletUtil.getDoubleParameter(pRequest, PARAM_TEXT_ROTATION, 0.0); // Convert to radians, if needed String units = pRequest.getParameter(PARAM_TEXT_ROTATION_UNITS); if (!StringUtil.isEmpty(unit...
java
private double getAngle(ServletRequest pRequest) { // Get angle double angle = ServletUtil.getDoubleParameter(pRequest, PARAM_TEXT_ROTATION, 0.0); // Convert to radians, if needed String units = pRequest.getParameter(PARAM_TEXT_ROTATION_UNITS); if (!StringUtil.isEmpty(unit...
[ "private", "double", "getAngle", "(", "ServletRequest", "pRequest", ")", "{", "// Get angle\r", "double", "angle", "=", "ServletUtil", ".", "getDoubleParameter", "(", "pRequest", ",", "PARAM_TEXT_ROTATION", ",", "0.0", ")", ";", "// Convert to radians, if needed\r", "...
Gets the angle of rotation from the request. @param pRequest the servlet request to get parameters from @return the angle in radians.
[ "Gets", "the", "angle", "of", "rotation", "from", "the", "request", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/image/TextRenderer.java#L324-L335
62,603
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ServletConfigMapAdapter.java
ServletConfigMapAdapter.getName
public final String getName() { switch (type) { case ServletConfig: return servletConfig.getServletName(); case FilterConfig: return filterConfig.getFilterName(); case ServletContext: return servletContext.getServletConte...
java
public final String getName() { switch (type) { case ServletConfig: return servletConfig.getServletName(); case FilterConfig: return filterConfig.getFilterName(); case ServletContext: return servletContext.getServletConte...
[ "public", "final", "String", "getName", "(", ")", "{", "switch", "(", "type", ")", "{", "case", "ServletConfig", ":", "return", "servletConfig", ".", "getServletName", "(", ")", ";", "case", "FilterConfig", ":", "return", "filterConfig", ".", "getFilterName", ...
Gets the servlet or filter name from the config. @return the servlet or filter name
[ "Gets", "the", "servlet", "or", "filter", "name", "from", "the", "config", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ServletConfigMapAdapter.java#L111-L122
62,604
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ServletConfigMapAdapter.java
ServletConfigMapAdapter.getServletContext
public final ServletContext getServletContext() { switch (type) { case ServletConfig: return servletConfig.getServletContext(); case FilterConfig: return filterConfig.getServletContext(); case ServletContext: return servl...
java
public final ServletContext getServletContext() { switch (type) { case ServletConfig: return servletConfig.getServletContext(); case FilterConfig: return filterConfig.getServletContext(); case ServletContext: return servl...
[ "public", "final", "ServletContext", "getServletContext", "(", ")", "{", "switch", "(", "type", ")", "{", "case", "ServletConfig", ":", "return", "servletConfig", ".", "getServletContext", "(", ")", ";", "case", "FilterConfig", ":", "return", "filterConfig", "."...
Gets the servlet context from the config. @return the servlet context
[ "Gets", "the", "servlet", "context", "from", "the", "config", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ServletConfigMapAdapter.java#L129-L140
62,605
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/enc/DecoderStream.java
DecoderStream.fill
protected int fill() throws IOException { buffer.clear(); int read = decoder.decode(in, buffer); // TODO: Enforce this in test case, leave here to aid debugging if (read > buffer.capacity()) { throw new AssertionError( String.format( ...
java
protected int fill() throws IOException { buffer.clear(); int read = decoder.decode(in, buffer); // TODO: Enforce this in test case, leave here to aid debugging if (read > buffer.capacity()) { throw new AssertionError( String.format( ...
[ "protected", "int", "fill", "(", ")", "throws", "IOException", "{", "buffer", ".", "clear", "(", ")", ";", "int", "read", "=", "decoder", ".", "decode", "(", "in", ",", "buffer", ")", ";", "// TODO: Enforce this in test case, leave here to aid debugging\r", "if"...
Fills the buffer, by decoding data from the underlying input stream. @return the number of bytes decoded, or {@code -1} if the end of the file is reached @throws IOException if an I/O error occurs
[ "Fills", "the", "buffer", "by", "decoding", "data", "from", "the", "underlying", "input", "stream", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/enc/DecoderStream.java#L178-L199
62,606
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java
Log.logDebug
public void logDebug(String message, Exception exception) { if (!(logDebug || globalLog.logDebug)) return; if (debugLog != null) log(debugLog, "DEBUG", owner, message, exception); else log(globalLog.debugLog, "DEBUG", owner, message, exception); ...
java
public void logDebug(String message, Exception exception) { if (!(logDebug || globalLog.logDebug)) return; if (debugLog != null) log(debugLog, "DEBUG", owner, message, exception); else log(globalLog.debugLog, "DEBUG", owner, message, exception); ...
[ "public", "void", "logDebug", "(", "String", "message", ",", "Exception", "exception", ")", "{", "if", "(", "!", "(", "logDebug", "||", "globalLog", ".", "logDebug", ")", ")", "return", ";", "if", "(", "debugLog", "!=", "null", ")", "log", "(", "debugL...
Prints debug info to the current debugLog @param message The message to log @param exception An Exception
[ "Prints", "debug", "info", "to", "the", "current", "debugLog" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java#L281-L289
62,607
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java
Log.logWarning
public void logWarning(String message, Exception exception) { if (!(logWarning || globalLog.logWarning)) return; if (warningLog != null) log(warningLog, "WARNING", owner, message, exception); else log(globalLog.warningLog, "WARNING", owner, message, e...
java
public void logWarning(String message, Exception exception) { if (!(logWarning || globalLog.logWarning)) return; if (warningLog != null) log(warningLog, "WARNING", owner, message, exception); else log(globalLog.warningLog, "WARNING", owner, message, e...
[ "public", "void", "logWarning", "(", "String", "message", ",", "Exception", "exception", ")", "{", "if", "(", "!", "(", "logWarning", "||", "globalLog", ".", "logWarning", ")", ")", "return", ";", "if", "(", "warningLog", "!=", "null", ")", "log", "(", ...
Prints warning info to the current warningLog @param message The message to log @param exception An Exception
[ "Prints", "warning", "info", "to", "the", "current", "warningLog" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java#L385-L393
62,608
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java
Log.logError
public void logError(String message, Exception exception) { if (!(logError || globalLog.logError)) return; if (errorLog != null) log(errorLog, "ERROR", owner, message, exception); else log(globalLog.errorLog, "ERROR", owner, message, exception); ...
java
public void logError(String message, Exception exception) { if (!(logError || globalLog.logError)) return; if (errorLog != null) log(errorLog, "ERROR", owner, message, exception); else log(globalLog.errorLog, "ERROR", owner, message, exception); ...
[ "public", "void", "logError", "(", "String", "message", ",", "Exception", "exception", ")", "{", "if", "(", "!", "(", "logError", "||", "globalLog", ".", "logError", ")", ")", "return", ";", "if", "(", "errorLog", "!=", "null", ")", "log", "(", "errorL...
Prints error info to the current errorLog @param message The message to log @param exception An Exception
[ "Prints", "error", "info", "to", "the", "current", "errorLog" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java#L488-L496
62,609
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java
Log.logInfo
public void logInfo(String message, Exception exception) { if (!(logInfo || globalLog.logInfo)) return; if (infoLog != null) log(infoLog, "INFO", owner, message, exception); else log(globalLog.infoLog, "INFO", owner, message, exception); }
java
public void logInfo(String message, Exception exception) { if (!(logInfo || globalLog.logInfo)) return; if (infoLog != null) log(infoLog, "INFO", owner, message, exception); else log(globalLog.infoLog, "INFO", owner, message, exception); }
[ "public", "void", "logInfo", "(", "String", "message", ",", "Exception", "exception", ")", "{", "if", "(", "!", "(", "logInfo", "||", "globalLog", ".", "logInfo", ")", ")", "return", ";", "if", "(", "infoLog", "!=", "null", ")", "log", "(", "infoLog", ...
Prints info info to the current infoLog @param message The message to log @param exception An Exception
[ "Prints", "info", "info", "to", "the", "current", "infoLog" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java#L591-L599
62,610
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java
Log.getStream
private static OutputStream getStream(String name) throws IOException { OutputStream os = null; synchronized (streamCache) { if ((os = (OutputStream) streamCache.get(name)) != null) return os; os = new FileOutputStream(name, true); strea...
java
private static OutputStream getStream(String name) throws IOException { OutputStream os = null; synchronized (streamCache) { if ((os = (OutputStream) streamCache.get(name)) != null) return os; os = new FileOutputStream(name, true); strea...
[ "private", "static", "OutputStream", "getStream", "(", "String", "name", ")", "throws", "IOException", "{", "OutputStream", "os", "=", "null", ";", "synchronized", "(", "streamCache", ")", "{", "if", "(", "(", "os", "=", "(", "OutputStream", ")", "streamCach...
Internal method to get a named stream
[ "Internal", "method", "to", "get", "a", "named", "stream" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java#L607-L619
62,611
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java
Log.log
private static void log(PrintStream ps, String header, String owner, String message, Exception ex) { // Only allow one instance to print to the given stream. synchronized (ps) { // Create output stream for logging LogStream logStream = new LogStr...
java
private static void log(PrintStream ps, String header, String owner, String message, Exception ex) { // Only allow one instance to print to the given stream. synchronized (ps) { // Create output stream for logging LogStream logStream = new LogStr...
[ "private", "static", "void", "log", "(", "PrintStream", "ps", ",", "String", "header", ",", "String", "owner", ",", "String", "message", ",", "Exception", "ex", ")", "{", "// Only allow one instance to print to the given stream.\r", "synchronized", "(", "ps", ")", ...
Internal log method
[ "Internal", "log", "method" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/Log.java#L625-L644
62,612
haraldk/TwelveMonkeys
imageio/imageio-bmp/src/main/java/com/twelvemonkeys/imageio/plugins/bmp/CURImageReader.java
CURImageReader.getHotSpot
public final Point getHotSpot(final int pImageIndex) throws IOException { DirectoryEntry.CUREntry entry = (DirectoryEntry.CUREntry) getEntry(pImageIndex); return entry.getHotspot(); }
java
public final Point getHotSpot(final int pImageIndex) throws IOException { DirectoryEntry.CUREntry entry = (DirectoryEntry.CUREntry) getEntry(pImageIndex); return entry.getHotspot(); }
[ "public", "final", "Point", "getHotSpot", "(", "final", "int", "pImageIndex", ")", "throws", "IOException", "{", "DirectoryEntry", ".", "CUREntry", "entry", "=", "(", "DirectoryEntry", ".", "CUREntry", ")", "getEntry", "(", "pImageIndex", ")", ";", "return", "...
Returns the hot spot location for the cursor. @param pImageIndex the index of the cursor in the current input. @return the hot spot location for the cursor @throws java.io.IOException if an I/O exception occurs during reading of image meta data @throws IndexOutOfBoundsException if {@code pImageIndex} is less than {@c...
[ "Returns", "the", "hot", "spot", "location", "for", "the", "cursor", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-bmp/src/main/java/com/twelvemonkeys/imageio/plugins/bmp/CURImageReader.java#L65-L68
62,613
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/convert/TimeConverter.java
TimeConverter.toObject
public Object toObject(String pString, Class pType, String pFormat) throws ConversionException { if (StringUtil.isEmpty(pString)) return null; TimeFormat format; try { if (pFormat == null) { // Use system default format ...
java
public Object toObject(String pString, Class pType, String pFormat) throws ConversionException { if (StringUtil.isEmpty(pString)) return null; TimeFormat format; try { if (pFormat == null) { // Use system default format ...
[ "public", "Object", "toObject", "(", "String", "pString", ",", "Class", "pType", ",", "String", "pFormat", ")", "throws", "ConversionException", "{", "if", "(", "StringUtil", ".", "isEmpty", "(", "pString", ")", ")", "return", "null", ";", "TimeFormat", "for...
Converts the string to a time, using the given format for parsing. @param pString the string to convert. @param pType the type to convert to. PropertyConverter implementations may choose to ignore this parameter. @param pFormat the format used for parsing. PropertyConverter implementations may choose to ignore this pa...
[ "Converts", "the", "string", "to", "a", "time", "using", "the", "given", "format", "for", "parsing", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/convert/TimeConverter.java#L71-L94
62,614
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/ole2/Entry.java
Entry.readEntry
static Entry readEntry(final DataInput pInput) throws IOException { Entry p = new Entry(); p.read(pInput); return p; }
java
static Entry readEntry(final DataInput pInput) throws IOException { Entry p = new Entry(); p.read(pInput); return p; }
[ "static", "Entry", "readEntry", "(", "final", "DataInput", "pInput", ")", "throws", "IOException", "{", "Entry", "p", "=", "new", "Entry", "(", ")", ";", "p", ".", "read", "(", "pInput", ")", ";", "return", "p", ";", "}" ]
Reads an entry from the input. @param pInput the input data @return the {@code Entry} read from the input data @throws IOException if an i/o exception occurs during reading
[ "Reads", "an", "entry", "from", "the", "input", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/ole2/Entry.java#L92-L96
62,615
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/ole2/Entry.java
Entry.read
private void read(final DataInput pInput) throws IOException { byte[] bytes = new byte[64]; pInput.readFully(bytes); // NOTE: Length is in bytes, including the null-terminator... int nameLength = pInput.readShort(); name = new String(bytes, 0, nameLength - 2, Charset.forNa...
java
private void read(final DataInput pInput) throws IOException { byte[] bytes = new byte[64]; pInput.readFully(bytes); // NOTE: Length is in bytes, including the null-terminator... int nameLength = pInput.readShort(); name = new String(bytes, 0, nameLength - 2, Charset.forNa...
[ "private", "void", "read", "(", "final", "DataInput", "pInput", ")", "throws", "IOException", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "64", "]", ";", "pInput", ".", "readFully", "(", "bytes", ")", ";", "// NOTE: Length is in bytes, including...
Reads this entry @param pInput the input data @throws IOException if an i/o exception occurs during reading
[ "Reads", "this", "entry" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/ole2/Entry.java#L104-L141
62,616
haraldk/TwelveMonkeys
imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java
Paths.readPath
public static Path2D readPath(final ImageInputStream stream) throws IOException { notNull(stream, "stream"); int magic = readMagic(stream); if (magic == PSD.RESOURCE_TYPE) { // This is a PSD Image Resource Block, we can parse directly return buildPathFromPhotoshopResour...
java
public static Path2D readPath(final ImageInputStream stream) throws IOException { notNull(stream, "stream"); int magic = readMagic(stream); if (magic == PSD.RESOURCE_TYPE) { // This is a PSD Image Resource Block, we can parse directly return buildPathFromPhotoshopResour...
[ "public", "static", "Path2D", "readPath", "(", "final", "ImageInputStream", "stream", ")", "throws", "IOException", "{", "notNull", "(", "stream", ",", "\"stream\"", ")", ";", "int", "magic", "=", "readMagic", "(", "stream", ")", ";", "if", "(", "magic", "...
Reads the clipping path from the given input stream, if any. Supports PSD, JPEG and TIFF as container formats for Photoshop resources, or a "bare" PSD Image Resource Block. @param stream the input stream to read from, not {@code null}. @return the path, or {@code null} if no path is found @throws IOException if a gene...
[ "Reads", "the", "clipping", "path", "from", "the", "given", "input", "stream", "if", "any", ".", "Supports", "PSD", "JPEG", "and", "TIFF", "as", "container", "formats", "for", "Photoshop", "resources", "or", "a", "bare", "PSD", "Image", "Resource", "Block", ...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java#L95-L146
62,617
haraldk/TwelveMonkeys
imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java
Paths.applyClippingPath
public static BufferedImage applyClippingPath(final Shape clip, final BufferedImage image) { return applyClippingPath(clip, notNull(image, "image"), new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB)); }
java
public static BufferedImage applyClippingPath(final Shape clip, final BufferedImage image) { return applyClippingPath(clip, notNull(image, "image"), new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB)); }
[ "public", "static", "BufferedImage", "applyClippingPath", "(", "final", "Shape", "clip", ",", "final", "BufferedImage", "image", ")", "{", "return", "applyClippingPath", "(", "clip", ",", "notNull", "(", "image", ",", "\"image\"", ")", ",", "new", "BufferedImage...
Applies the clipping path to the given image. All pixels outside the path will be transparent. @param clip the clipping path, not {@code null} @param image the image to clip, not {@code null} @return the clipped image. @throws java.lang.IllegalArgumentException if {@code clip} or {@code image} is {@code null}.
[ "Applies", "the", "clipping", "path", "to", "the", "given", "image", ".", "All", "pixels", "outside", "the", "path", "will", "be", "transparent", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java#L185-L187
62,618
haraldk/TwelveMonkeys
imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java
Paths.readClipped
public static BufferedImage readClipped(final ImageInputStream stream) throws IOException { Shape clip = readPath(stream); stream.seek(0); BufferedImage image = ImageIO.read(stream); if (clip == null) { return image; } return applyClippingPath(clip, image);...
java
public static BufferedImage readClipped(final ImageInputStream stream) throws IOException { Shape clip = readPath(stream); stream.seek(0); BufferedImage image = ImageIO.read(stream); if (clip == null) { return image; } return applyClippingPath(clip, image);...
[ "public", "static", "BufferedImage", "readClipped", "(", "final", "ImageInputStream", "stream", ")", "throws", "IOException", "{", "Shape", "clip", "=", "readPath", "(", "stream", ")", ";", "stream", ".", "seek", "(", "0", ")", ";", "BufferedImage", "image", ...
Reads the clipping path from the given input stream, if any, and applies it to the first image in the stream. If no path was found, the image is returned without any clipping. Supports PSD, JPEG and TIFF as container formats for Photoshop resources. @param stream the stream to read from, not {@code null} @return the c...
[ "Reads", "the", "clipping", "path", "from", "the", "given", "input", "stream", "if", "any", "and", "applies", "it", "to", "the", "first", "image", "in", "the", "stream", ".", "If", "no", "path", "was", "found", "the", "image", "is", "returned", "without"...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-clippath/src/main/java/com/twelvemonkeys/imageio/path/Paths.java#L244-L255
62,619
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ProxyServlet.java
ProxyServlet.service
protected void service(HttpServletRequest pRequest, HttpServletResponse pResponse) throws ServletException, IOException { // Sanity check configuration if (remoteServer == null) { log(MESSAGE_REMOTE_SERVER_NOT_CONFIGURED); pResponse.sendError(HttpServletResponse.SC_INTERNAL_S...
java
protected void service(HttpServletRequest pRequest, HttpServletResponse pResponse) throws ServletException, IOException { // Sanity check configuration if (remoteServer == null) { log(MESSAGE_REMOTE_SERVER_NOT_CONFIGURED); pResponse.sendError(HttpServletResponse.SC_INTERNAL_S...
[ "protected", "void", "service", "(", "HttpServletRequest", "pRequest", ",", "HttpServletResponse", "pResponse", ")", "throws", "ServletException", ",", "IOException", "{", "// Sanity check configuration\r", "if", "(", "remoteServer", "==", "null", ")", "{", "log", "("...
Services a single request. Supports HTTP and HTTPS. @param pRequest @param pResponse @throws ServletException @throws IOException @see ProxyServlet Class descrition
[ "Services", "a", "single", "request", ".", "Supports", "HTTP", "and", "HTTPS", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ProxyServlet.java#L156-L215
62,620
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ProxyServlet.java
ProxyServlet.createRemoteRequestURI
private String createRemoteRequestURI(HttpServletRequest pRequest) { StringBuilder requestURI = new StringBuilder(remotePath); requestURI.append(pRequest.getPathInfo()); if (!StringUtil.isEmpty(pRequest.getQueryString())) { requestURI.append("?"); requestURI.append...
java
private String createRemoteRequestURI(HttpServletRequest pRequest) { StringBuilder requestURI = new StringBuilder(remotePath); requestURI.append(pRequest.getPathInfo()); if (!StringUtil.isEmpty(pRequest.getQueryString())) { requestURI.append("?"); requestURI.append...
[ "private", "String", "createRemoteRequestURI", "(", "HttpServletRequest", "pRequest", ")", "{", "StringBuilder", "requestURI", "=", "new", "StringBuilder", "(", "remotePath", ")", ";", "requestURI", ".", "append", "(", "pRequest", ".", "getPathInfo", "(", ")", ")"...
Creates the remote request URI based on the incoming request. The URI will include any query strings etc. @param pRequest @return a {@code String} representing the remote request URI
[ "Creates", "the", "remote", "request", "URI", "based", "on", "the", "incoming", "request", ".", "The", "URI", "will", "include", "any", "query", "strings", "etc", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ProxyServlet.java#L323-L333
62,621
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/TimeoutMap.java
TimeoutMap.setExpiryTime
public void setExpiryTime(long pExpiryTime) { long oldEexpiryTime = expiryTime; expiryTime = pExpiryTime; if (expiryTime < oldEexpiryTime) { // Expire now nextExpiryTime = 0; removeExpiredEntries(); } }
java
public void setExpiryTime(long pExpiryTime) { long oldEexpiryTime = expiryTime; expiryTime = pExpiryTime; if (expiryTime < oldEexpiryTime) { // Expire now nextExpiryTime = 0; removeExpiredEntries(); } }
[ "public", "void", "setExpiryTime", "(", "long", "pExpiryTime", ")", "{", "long", "oldEexpiryTime", "=", "expiryTime", ";", "expiryTime", "=", "pExpiryTime", ";", "if", "(", "expiryTime", "<", "oldEexpiryTime", ")", "{", "// Expire now\r", "nextExpiryTime", "=", ...
Sets the maximum time any value will be kept in the map, before it expires. Removes any items that are older than the specified time. @param pExpiryTime the expiry time (time to live) for elements in this map
[ "Sets", "the", "maximum", "time", "any", "value", "will", "be", "kept", "in", "the", "map", "before", "it", "expires", ".", "Removes", "any", "items", "that", "are", "older", "than", "the", "specified", "time", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeoutMap.java#L148-L158
62,622
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/TimeoutMap.java
TimeoutMap.removeExpiredEntriesSynced
private synchronized void removeExpiredEntriesSynced(long pTime) { if (pTime > nextExpiryTime) { //// long next = Long.MAX_VALUE; nextExpiryTime = next; // Avoid multiple runs... for (Iterator<Entry<K, V>> iterator = new EntryIterator(); iterator.hasNext();) ...
java
private synchronized void removeExpiredEntriesSynced(long pTime) { if (pTime > nextExpiryTime) { //// long next = Long.MAX_VALUE; nextExpiryTime = next; // Avoid multiple runs... for (Iterator<Entry<K, V>> iterator = new EntryIterator(); iterator.hasNext();) ...
[ "private", "synchronized", "void", "removeExpiredEntriesSynced", "(", "long", "pTime", ")", "{", "if", "(", "pTime", ">", "nextExpiryTime", ")", "{", "////\r", "long", "next", "=", "Long", ".", "MAX_VALUE", ";", "nextExpiryTime", "=", "next", ";", "// Avoid mu...
Okay, I guess this do resemble DCL... @todo Write some exhausting multi-threaded unit-tests. @param pTime now
[ "Okay", "I", "guess", "this", "do", "resemble", "DCL", "..." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeoutMap.java#L307-L324
62,623
haraldk/TwelveMonkeys
imageio/imageio-pcx/src/main/java/com/twelvemonkeys/imageio/plugins/pcx/BitRotator.java
BitRotator.bitRotateCW
static void bitRotateCW(final byte[] pSrc, int pSrcPos, int pSrcStep, final byte[] pDst, int pDstPos, int pDstStep) { int idx = pSrcPos; int lonyb; int hinyb; long lo = 0; long hi = 0; for (int i = 0; i < 8; i++) { lonyb = pSrc[id...
java
static void bitRotateCW(final byte[] pSrc, int pSrcPos, int pSrcStep, final byte[] pDst, int pDstPos, int pDstStep) { int idx = pSrcPos; int lonyb; int hinyb; long lo = 0; long hi = 0; for (int i = 0; i < 8; i++) { lonyb = pSrc[id...
[ "static", "void", "bitRotateCW", "(", "final", "byte", "[", "]", "pSrc", ",", "int", "pSrcPos", ",", "int", "pSrcStep", ",", "final", "byte", "[", "]", "pDst", ",", "int", "pDstPos", ",", "int", "pDstStep", ")", "{", "int", "idx", "=", "pSrcPos", ";"...
Rotate bits clockwise. The IFFImageReader uses this to convert pixel bits from planar to chunky. Bits from the source are rotated 90 degrees clockwise written to the destination. @param pSrc source pixel data @param pSrcPos starting index of 8 x 8 bit source tile @param pSrcStep byte offset between adjacent rows ...
[ "Rotate", "bits", "clockwise", ".", "The", "IFFImageReader", "uses", "this", "to", "convert", "pixel", "bits", "from", "planar", "to", "chunky", ".", "Bits", "from", "the", "source", "are", "rotated", "90", "degrees", "clockwise", "written", "to", "the", "de...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pcx/src/main/java/com/twelvemonkeys/imageio/plugins/pcx/BitRotator.java#L79-L128
62,624
haraldk/TwelveMonkeys
imageio/imageio-hdr/src/main/java/com/twelvemonkeys/imageio/plugins/hdr/RGBE.java
RGBE.readPixels
public static void readPixels(DataInput in, float[] data, int numpixels) throws IOException { byte[] rgbe = new byte[4]; float[] rgb = new float[3]; int offset = 0; while (numpixels-- > 0) { in.readFully(rgbe); rgbe2float(rgb, rgbe, 0); data[offset+...
java
public static void readPixels(DataInput in, float[] data, int numpixels) throws IOException { byte[] rgbe = new byte[4]; float[] rgb = new float[3]; int offset = 0; while (numpixels-- > 0) { in.readFully(rgbe); rgbe2float(rgb, rgbe, 0); data[offset+...
[ "public", "static", "void", "readPixels", "(", "DataInput", "in", ",", "float", "[", "]", "data", ",", "int", "numpixels", ")", "throws", "IOException", "{", "byte", "[", "]", "rgbe", "=", "new", "byte", "[", "4", "]", ";", "float", "[", "]", "rgb", ...
Simple read routine. Will not correctly handle run length encoding.
[ "Simple", "read", "routine", ".", "Will", "not", "correctly", "handle", "run", "length", "encoding", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-hdr/src/main/java/com/twelvemonkeys/imageio/plugins/hdr/RGBE.java#L189-L203
62,625
haraldk/TwelveMonkeys
imageio/imageio-hdr/src/main/java/com/twelvemonkeys/imageio/plugins/hdr/RGBE.java
RGBE.float2rgbe
public static void float2rgbe(byte[] rgbe, float red, float green, float blue) { float v; int e; v = red; if (green > v) { v = green; } if (blue > v) { v = blue; } if (v < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3]...
java
public static void float2rgbe(byte[] rgbe, float red, float green, float blue) { float v; int e; v = red; if (green > v) { v = green; } if (blue > v) { v = blue; } if (v < 1e-32f) { rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3]...
[ "public", "static", "void", "float2rgbe", "(", "byte", "[", "]", "rgbe", ",", "float", "red", ",", "float", "green", ",", "float", "blue", ")", "{", "float", "v", ";", "int", "e", ";", "v", "=", "red", ";", "if", "(", "green", ">", "v", ")", "{...
Standard conversion from float pixels to rgbe pixels.
[ "Standard", "conversion", "from", "float", "pixels", "to", "rgbe", "pixels", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-hdr/src/main/java/com/twelvemonkeys/imageio/plugins/hdr/RGBE.java#L291-L313
62,626
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/image/CropFilter.java
CropFilter.doFilter
protected RenderedImage doFilter(BufferedImage pImage, ServletRequest pRequest, ImageServletResponse pResponse) { // Get crop coordinates int x = ServletUtil.getIntParameter(pRequest, PARAM_CROP_X, -1); int y = ServletUtil.getIntParameter(pRequest, PARAM_CROP_Y, -1); int width = Serv...
java
protected RenderedImage doFilter(BufferedImage pImage, ServletRequest pRequest, ImageServletResponse pResponse) { // Get crop coordinates int x = ServletUtil.getIntParameter(pRequest, PARAM_CROP_X, -1); int y = ServletUtil.getIntParameter(pRequest, PARAM_CROP_Y, -1); int width = Serv...
[ "protected", "RenderedImage", "doFilter", "(", "BufferedImage", "pImage", ",", "ServletRequest", "pRequest", ",", "ImageServletResponse", "pResponse", ")", "{", "// Get crop coordinates\r", "int", "x", "=", "ServletUtil", ".", "getIntParameter", "(", "pRequest", ",", ...
Reads the image from the requested URL, scales it, crops it, and returns it in the Servlet stream. See above for details on parameters.
[ "Reads", "the", "image", "from", "the", "requested", "URL", "scales", "it", "crops", "it", "and", "returns", "it", "in", "the", "Servlet", "stream", ".", "See", "above", "for", "details", "on", "parameters", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/image/CropFilter.java#L117-L138
62,627
mpetazzoni/ttorrent
common/src/main/java/com/turn/ttorrent/common/TorrentCreator.java
TorrentCreator.hashFile
private static String hashFile(final File file, final int pieceSize) throws InterruptedException, IOException { return hashFiles(Collections.singletonList(file), pieceSize); }
java
private static String hashFile(final File file, final int pieceSize) throws InterruptedException, IOException { return hashFiles(Collections.singletonList(file), pieceSize); }
[ "private", "static", "String", "hashFile", "(", "final", "File", "file", ",", "final", "int", "pieceSize", ")", "throws", "InterruptedException", ",", "IOException", "{", "return", "hashFiles", "(", "Collections", ".", "singletonList", "(", "file", ")", ",", "...
Return the concatenation of the SHA-1 hashes of a file's pieces. <p> Hashes the given file piece by piece using the default Torrent piece length (see {@link #DEFAULT_PIECE_LENGTH}) and returns the concatenation of these hashes, as a string. </p> <p> This is used for creating Torrent meta-info structures from a file. ...
[ "Return", "the", "concatenation", "of", "the", "SHA", "-", "1", "hashes", "of", "a", "file", "s", "pieces", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/TorrentCreator.java#L252-L255
62,628
mpetazzoni/ttorrent
common/src/main/java/com/turn/ttorrent/common/protocol/PeerMessage.java
PeerMessage.parse
public static PeerMessage parse(ByteBuffer buffer, TorrentInfo torrent) throws ParseException { int length = buffer.getInt(); if (length == 0) { return KeepAliveMessage.parse(buffer, torrent); } else if (length != buffer.remaining()) { throw new ParseException("Message size did not mat...
java
public static PeerMessage parse(ByteBuffer buffer, TorrentInfo torrent) throws ParseException { int length = buffer.getInt(); if (length == 0) { return KeepAliveMessage.parse(buffer, torrent); } else if (length != buffer.remaining()) { throw new ParseException("Message size did not mat...
[ "public", "static", "PeerMessage", "parse", "(", "ByteBuffer", "buffer", ",", "TorrentInfo", "torrent", ")", "throws", "ParseException", "{", "int", "length", "=", "buffer", ".", "getInt", "(", ")", ";", "if", "(", "length", "==", "0", ")", "{", "return", ...
Parse the given buffer into a peer protocol message. <p> Parses the provided byte array and builds the corresponding PeerMessage subclass object. </p> @param buffer The byte buffer containing the message data. @param torrent The torrent this message is about. @return A PeerMessage subclass instance. @throws ParseExc...
[ "Parse", "the", "given", "buffer", "into", "a", "peer", "protocol", "message", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/protocol/PeerMessage.java#L150-L189
62,629
mpetazzoni/ttorrent
ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackerRequestProcessor.java
TrackerRequestProcessor.serveError
private void serveError(Status status, String error, RequestHandler requestHandler) throws IOException { this.serveError(status, HTTPTrackerErrorMessage.craft(error), requestHandler); }
java
private void serveError(Status status, String error, RequestHandler requestHandler) throws IOException { this.serveError(status, HTTPTrackerErrorMessage.craft(error), requestHandler); }
[ "private", "void", "serveError", "(", "Status", "status", ",", "String", "error", ",", "RequestHandler", "requestHandler", ")", "throws", "IOException", "{", "this", ".", "serveError", "(", "status", ",", "HTTPTrackerErrorMessage", ".", "craft", "(", "error", ")...
Write an error message to the response with the given HTTP status code. @param status The HTTP status code to return. @param error The error message reported by the tracker.
[ "Write", "an", "error", "message", "to", "the", "response", "with", "the", "given", "HTTP", "status", "code", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackerRequestProcessor.java#L300-L302
62,630
mpetazzoni/ttorrent
ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackerRequestProcessor.java
TrackerRequestProcessor.serveError
private void serveError(Status status, ErrorMessage.FailureReason reason, RequestHandler requestHandler) throws IOException { this.serveError(status, reason.getMessage(), requestHandler); }
java
private void serveError(Status status, ErrorMessage.FailureReason reason, RequestHandler requestHandler) throws IOException { this.serveError(status, reason.getMessage(), requestHandler); }
[ "private", "void", "serveError", "(", "Status", "status", ",", "ErrorMessage", ".", "FailureReason", "reason", ",", "RequestHandler", "requestHandler", ")", "throws", "IOException", "{", "this", ".", "serveError", "(", "status", ",", "reason", ".", "getMessage", ...
Write a tracker failure reason code to the response with the given HTTP status code. @param status The HTTP status code to return. @param reason The failure reason reported by the tracker.
[ "Write", "a", "tracker", "failure", "reason", "code", "to", "the", "response", "with", "the", "given", "HTTP", "status", "code", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackerRequestProcessor.java#L311-L313
62,631
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java
TrackerClient.formatAnnounceEvent
protected String formatAnnounceEvent( AnnounceRequestMessage.RequestEvent event) { return AnnounceRequestMessage.RequestEvent.NONE.equals(event) ? "" : String.format(" %s", event.name()); }
java
protected String formatAnnounceEvent( AnnounceRequestMessage.RequestEvent event) { return AnnounceRequestMessage.RequestEvent.NONE.equals(event) ? "" : String.format(" %s", event.name()); }
[ "protected", "String", "formatAnnounceEvent", "(", "AnnounceRequestMessage", ".", "RequestEvent", "event", ")", "{", "return", "AnnounceRequestMessage", ".", "RequestEvent", ".", "NONE", ".", "equals", "(", "event", ")", "?", "\"\"", ":", "String", ".", "format", ...
Formats an announce event into a usable string.
[ "Formats", "an", "announce", "event", "into", "a", "usable", "string", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java#L141-L146
62,632
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java
TrackerClient.handleTrackerAnnounceResponse
protected void handleTrackerAnnounceResponse(TrackerMessage message, boolean inhibitEvents, String hexInfoHash) throws AnnounceException { if (message instanceof ErrorMessage) { ErrorMessage error = (ErrorMessage) message; throw new AnnounceException(error....
java
protected void handleTrackerAnnounceResponse(TrackerMessage message, boolean inhibitEvents, String hexInfoHash) throws AnnounceException { if (message instanceof ErrorMessage) { ErrorMessage error = (ErrorMessage) message; throw new AnnounceException(error....
[ "protected", "void", "handleTrackerAnnounceResponse", "(", "TrackerMessage", "message", ",", "boolean", "inhibitEvents", ",", "String", "hexInfoHash", ")", "throws", "AnnounceException", "{", "if", "(", "message", "instanceof", "ErrorMessage", ")", "{", "ErrorMessage", ...
Handle the announce response from the tracker. <p> Analyzes the response from the tracker and acts on it. If the response is an error, it is logged. Otherwise, the announce response is used to fire the corresponding announce and peer events to all announce listeners. </p> @param message The incoming {@link Trac...
[ "Handle", "the", "announce", "response", "from", "the", "tracker", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java#L161-L190
62,633
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java
TrackerClient.fireAnnounceResponseEvent
protected void fireAnnounceResponseEvent(int complete, int incomplete, int interval, String hexInfoHash) { for (AnnounceResponseListener listener : this.listeners) { listener.handleAnnounceResponse(interval, complete, incomplete, hexInfoHash); } }
java
protected void fireAnnounceResponseEvent(int complete, int incomplete, int interval, String hexInfoHash) { for (AnnounceResponseListener listener : this.listeners) { listener.handleAnnounceResponse(interval, complete, incomplete, hexInfoHash); } }
[ "protected", "void", "fireAnnounceResponseEvent", "(", "int", "complete", ",", "int", "incomplete", ",", "int", "interval", ",", "String", "hexInfoHash", ")", "{", "for", "(", "AnnounceResponseListener", "listener", ":", "this", ".", "listeners", ")", "{", "list...
Fire the announce response event to all listeners. @param complete The number of seeders on this torrent. @param incomplete The number of leechers on this torrent. @param interval The announce interval requested by the tracker.
[ "Fire", "the", "announce", "response", "event", "to", "all", "listeners", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java#L199-L203
62,634
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java
TrackerClient.fireDiscoveredPeersEvent
protected void fireDiscoveredPeersEvent(List<Peer> peers, String hexInfoHash) { for (AnnounceResponseListener listener : this.listeners) { listener.handleDiscoveredPeers(peers, hexInfoHash); } }
java
protected void fireDiscoveredPeersEvent(List<Peer> peers, String hexInfoHash) { for (AnnounceResponseListener listener : this.listeners) { listener.handleDiscoveredPeers(peers, hexInfoHash); } }
[ "protected", "void", "fireDiscoveredPeersEvent", "(", "List", "<", "Peer", ">", "peers", ",", "String", "hexInfoHash", ")", "{", "for", "(", "AnnounceResponseListener", "listener", ":", "this", ".", "listeners", ")", "{", "listener", ".", "handleDiscoveredPeers", ...
Fire the new peer discovery event to all listeners. @param peers The list of peers discovered.
[ "Fire", "the", "new", "peer", "discovery", "event", "to", "all", "listeners", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/TrackerClient.java#L210-L214
62,635
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/storage/FileStorage.java
FileStorage.finish
@Override public void finish() throws IOException { try { myLock.writeLock().lock(); logger.debug("Closing file channel to " + this.current.getName() + " (download complete)."); if (this.channel.isOpen()) { this.channel.force(true); } // Nothing more to do if w...
java
@Override public void finish() throws IOException { try { myLock.writeLock().lock(); logger.debug("Closing file channel to " + this.current.getName() + " (download complete)."); if (this.channel.isOpen()) { this.channel.force(true); } // Nothing more to do if w...
[ "@", "Override", "public", "void", "finish", "(", ")", "throws", "IOException", "{", "try", "{", "myLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "logger", ".", "debug", "(", "\"Closing file channel to \"", "+", "this", ".", "current", "...
Move the partial file to its final location.
[ "Move", "the", "partial", "file", "to", "its", "final", "location", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/storage/FileStorage.java#L182-L219
62,636
mpetazzoni/ttorrent
common/src/main/java/com/turn/ttorrent/common/protocol/http/HTTPAnnounceResponseMessage.java
HTTPAnnounceResponseMessage.craft
public static HTTPAnnounceResponseMessage craft(int interval, int complete, int incomplete, List<Peer> peers, String hexInfoHash) throws IOException, UnsupportedEncodingException { Map<String, BEValue> response = new...
java
public static HTTPAnnounceResponseMessage craft(int interval, int complete, int incomplete, List<Peer> peers, String hexInfoHash) throws IOException, UnsupportedEncodingException { Map<String, BEValue> response = new...
[ "public", "static", "HTTPAnnounceResponseMessage", "craft", "(", "int", "interval", ",", "int", "complete", ",", "int", "incomplete", ",", "List", "<", "Peer", ">", "peers", ",", "String", "hexInfoHash", ")", "throws", "IOException", ",", "UnsupportedEncodingExcep...
Craft a compact announce response message with a torrent identifier. @param interval @param complete @param incomplete @param peers
[ "Craft", "a", "compact", "announce", "response", "message", "with", "a", "torrent", "identifier", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/protocol/http/HTTPAnnounceResponseMessage.java#L198-L223
62,637
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/storage/FileCollectionStorage.java
FileCollectionStorage.select
private List<FileOffset> select(long offset, long length) { if (offset + length > this.size) { throw new IllegalArgumentException("Buffer overrun (" + offset + " + " + length + " > " + this.size + ") !"); } List<FileOffset> selected = new LinkedList<FileOffset>(); long bytes = 0; ...
java
private List<FileOffset> select(long offset, long length) { if (offset + length > this.size) { throw new IllegalArgumentException("Buffer overrun (" + offset + " + " + length + " > " + this.size + ") !"); } List<FileOffset> selected = new LinkedList<FileOffset>(); long bytes = 0; ...
[ "private", "List", "<", "FileOffset", ">", "select", "(", "long", "offset", ",", "long", "length", ")", "{", "if", "(", "offset", "+", "length", ">", "this", ".", "size", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Buffer overrun (\"", "+...
Select the group of files impacted by an operation. <p> This function selects which files are impacted by a read or write operation, with their respective relative offset and chunk length. </p> @param offset The offset of the operation, in bytes, relative to the complete byte storage. @param length The number of byte...
[ "Select", "the", "group", "of", "files", "impacted", "by", "an", "operation", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/storage/FileCollectionStorage.java#L215-L248
62,638
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java
UDPTrackerClient.handleTrackerAnnounceResponse
@Override protected void handleTrackerAnnounceResponse(TrackerMessage message, boolean inhibitEvents, String hexInfoHash) throws AnnounceException { this.validateTrackerResponse(message); super.handleTrackerAnnounceResponse(message, inhibitEvents, hexInfoHash); ...
java
@Override protected void handleTrackerAnnounceResponse(TrackerMessage message, boolean inhibitEvents, String hexInfoHash) throws AnnounceException { this.validateTrackerResponse(message); super.handleTrackerAnnounceResponse(message, inhibitEvents, hexInfoHash); ...
[ "@", "Override", "protected", "void", "handleTrackerAnnounceResponse", "(", "TrackerMessage", "message", ",", "boolean", "inhibitEvents", ",", "String", "hexInfoHash", ")", "throws", "AnnounceException", "{", "this", ".", "validateTrackerResponse", "(", "message", ")", ...
Handles the tracker announce response message. <p> Verifies the transaction ID of the message before passing it over to {@link Announce#()}. </p> @param message The message received from the tracker in response to the announce request.
[ "Handles", "the", "tracker", "announce", "response", "message", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java#L248-L253
62,639
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java
UDPTrackerClient.close
@Override protected void close() { this.stop = true; // Close the socket to force blocking operations to return. if (this.socket != null && !this.socket.isClosed()) { this.socket.close(); } }
java
@Override protected void close() { this.stop = true; // Close the socket to force blocking operations to return. if (this.socket != null && !this.socket.isClosed()) { this.socket.close(); } }
[ "@", "Override", "protected", "void", "close", "(", ")", "{", "this", ".", "stop", "=", "true", ";", "// Close the socket to force blocking operations to return.", "if", "(", "this", ".", "socket", "!=", "null", "&&", "!", "this", ".", "socket", ".", "isClosed...
Close this announce connection.
[ "Close", "this", "announce", "connection", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java#L258-L266
62,640
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java
UDPTrackerClient.validateTrackerResponse
private void validateTrackerResponse(TrackerMessage message) throws AnnounceException { if (message instanceof ErrorMessage) { throw new AnnounceException(((ErrorMessage) message).getReason()); } if (message instanceof UDPTrackerMessage && (((UDPTrackerMessage) message).getTrans...
java
private void validateTrackerResponse(TrackerMessage message) throws AnnounceException { if (message instanceof ErrorMessage) { throw new AnnounceException(((ErrorMessage) message).getReason()); } if (message instanceof UDPTrackerMessage && (((UDPTrackerMessage) message).getTrans...
[ "private", "void", "validateTrackerResponse", "(", "TrackerMessage", "message", ")", "throws", "AnnounceException", "{", "if", "(", "message", "instanceof", "ErrorMessage", ")", "{", "throw", "new", "AnnounceException", "(", "(", "(", "ErrorMessage", ")", "message",...
Validates an incoming tracker message. <p> Verifies that the message is not an error message (throws an exception with the error message if it is) and that the transaction ID matches the current one. </p> @param message The incoming tracker message.
[ "Validates", "an", "incoming", "tracker", "message", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java#L296-L306
62,641
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java
UDPTrackerClient.handleTrackerConnectResponse
private void handleTrackerConnectResponse(TrackerMessage message) throws AnnounceException { this.validateTrackerResponse(message); if (!(message instanceof ConnectionResponseMessage)) { throw new AnnounceException("Unexpected tracker message type " + message.getType().name() + "!...
java
private void handleTrackerConnectResponse(TrackerMessage message) throws AnnounceException { this.validateTrackerResponse(message); if (!(message instanceof ConnectionResponseMessage)) { throw new AnnounceException("Unexpected tracker message type " + message.getType().name() + "!...
[ "private", "void", "handleTrackerConnectResponse", "(", "TrackerMessage", "message", ")", "throws", "AnnounceException", "{", "this", ".", "validateTrackerResponse", "(", "message", ")", ";", "if", "(", "!", "(", "message", "instanceof", "ConnectionResponseMessage", "...
Handles the tracker connect response message. @param message The message received from the tracker in response to the connection request.
[ "Handles", "the", "tracker", "connect", "response", "message", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java#L314-L330
62,642
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java
UDPTrackerClient.send
private void send(ByteBuffer data) { try { this.socket.send(new DatagramPacket( data.array(), data.capacity(), this.address)); } catch (IOException ioe) { logger.info("Error sending datagram packet to tracker at {}: {}.", this.address, ioe.getMessage()); ...
java
private void send(ByteBuffer data) { try { this.socket.send(new DatagramPacket( data.array(), data.capacity(), this.address)); } catch (IOException ioe) { logger.info("Error sending datagram packet to tracker at {}: {}.", this.address, ioe.getMessage()); ...
[ "private", "void", "send", "(", "ByteBuffer", "data", ")", "{", "try", "{", "this", ".", "socket", ".", "send", "(", "new", "DatagramPacket", "(", "data", ".", "array", "(", ")", ",", "data", ".", "capacity", "(", ")", ",", "this", ".", "address", ...
Send a UDP packet to the tracker. @param data The {@link ByteBuffer} to send in a datagram packet to the tracker.
[ "Send", "a", "UDP", "packet", "to", "the", "tracker", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java#L338-L347
62,643
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java
UDPTrackerClient.recv
private ByteBuffer recv(int attempt) throws IOException, SocketException, SocketTimeoutException { int timeout = UDP_BASE_TIMEOUT_SECONDS * (int) Math.pow(2, attempt); logger.trace("Setting receive timeout to {}s for attempt {}...", timeout, attempt); this.socket.setSoTimeout(timeout *...
java
private ByteBuffer recv(int attempt) throws IOException, SocketException, SocketTimeoutException { int timeout = UDP_BASE_TIMEOUT_SECONDS * (int) Math.pow(2, attempt); logger.trace("Setting receive timeout to {}s for attempt {}...", timeout, attempt); this.socket.setSoTimeout(timeout *...
[ "private", "ByteBuffer", "recv", "(", "int", "attempt", ")", "throws", "IOException", ",", "SocketException", ",", "SocketTimeoutException", "{", "int", "timeout", "=", "UDP_BASE_TIMEOUT_SECONDS", "*", "(", "int", ")", "Math", ".", "pow", "(", "2", ",", "attem...
Receive a UDP packet from the tracker. @param attempt The attempt number, used to calculate the timeout for the receive operation. @retun Returns a {@link ByteBuffer} containing the packet data.
[ "Receive", "a", "UDP", "packet", "from", "the", "tracker", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/UDPTrackerClient.java#L356-L372
62,644
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java
BEValue.getString
public String getString(String encoding) throws InvalidBEncodingException { try { return new String(this.getBytes(), encoding); } catch (ClassCastException cce) { throw new InvalidBEncodingException(cce.toString()); } catch (UnsupportedEncodingException uee) { throw new InternalError(uee.t...
java
public String getString(String encoding) throws InvalidBEncodingException { try { return new String(this.getBytes(), encoding); } catch (ClassCastException cce) { throw new InvalidBEncodingException(cce.toString()); } catch (UnsupportedEncodingException uee) { throw new InternalError(uee.t...
[ "public", "String", "getString", "(", "String", "encoding", ")", "throws", "InvalidBEncodingException", "{", "try", "{", "return", "new", "String", "(", "this", ".", "getBytes", "(", ")", ",", "encoding", ")", ";", "}", "catch", "(", "ClassCastException", "c...
Returns this BEValue as a String, interpreted with the specified encoding. @param encoding The encoding to interpret the bytes as when converting them into a {@link String}. @throws InvalidBEncodingException If the value is not a byte[].
[ "Returns", "this", "BEValue", "as", "a", "String", "interpreted", "with", "the", "specified", "encoding", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java#L92-L100
62,645
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java
BEValue.getNumber
public Number getNumber() throws InvalidBEncodingException { try { return (Number) this.value; } catch (ClassCastException cce) { throw new InvalidBEncodingException(cce.toString()); } }
java
public Number getNumber() throws InvalidBEncodingException { try { return (Number) this.value; } catch (ClassCastException cce) { throw new InvalidBEncodingException(cce.toString()); } }
[ "public", "Number", "getNumber", "(", ")", "throws", "InvalidBEncodingException", "{", "try", "{", "return", "(", "Number", ")", "this", ".", "value", ";", "}", "catch", "(", "ClassCastException", "cce", ")", "{", "throw", "new", "InvalidBEncodingException", "...
Returns this BEValue as a Number. @throws InvalidBEncodingException If the value is not a {@link Number}.
[ "Returns", "this", "BEValue", "as", "a", "Number", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java#L120-L126
62,646
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java
BEValue.getList
@SuppressWarnings("unchecked") public List<BEValue> getList() throws InvalidBEncodingException { if (this.value instanceof ArrayList) { return (ArrayList<BEValue>) this.value; } else { throw new InvalidBEncodingException("Excepted List<BEvalue> !"); } }
java
@SuppressWarnings("unchecked") public List<BEValue> getList() throws InvalidBEncodingException { if (this.value instanceof ArrayList) { return (ArrayList<BEValue>) this.value; } else { throw new InvalidBEncodingException("Excepted List<BEvalue> !"); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "BEValue", ">", "getList", "(", ")", "throws", "InvalidBEncodingException", "{", "if", "(", "this", ".", "value", "instanceof", "ArrayList", ")", "{", "return", "(", "ArrayList", "<", ...
Returns this BEValue as a List of BEValues. @throws InvalidBEncodingException If the value is not an {@link ArrayList}.
[ "Returns", "this", "BEValue", "as", "a", "List", "of", "BEValues", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java#L161-L168
62,647
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java
BEValue.getMap
@SuppressWarnings("unchecked") public Map<String, BEValue> getMap() throws InvalidBEncodingException { if (this.value instanceof HashMap) { return (Map<String, BEValue>) this.value; } else { throw new InvalidBEncodingException("Expected Map<String, BEValue> !"); } }
java
@SuppressWarnings("unchecked") public Map<String, BEValue> getMap() throws InvalidBEncodingException { if (this.value instanceof HashMap) { return (Map<String, BEValue>) this.value; } else { throw new InvalidBEncodingException("Expected Map<String, BEValue> !"); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Map", "<", "String", ",", "BEValue", ">", "getMap", "(", ")", "throws", "InvalidBEncodingException", "{", "if", "(", "this", ".", "value", "instanceof", "HashMap", ")", "{", "return", "(", "Map",...
Returns this BEValue as a Map of String keys and BEValue values. @throws InvalidBEncodingException If the value is not a {@link HashMap}.
[ "Returns", "this", "BEValue", "as", "a", "Map", "of", "String", "keys", "and", "BEValue", "values", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BEValue.java#L175-L182
62,648
mpetazzoni/ttorrent
ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/Tracker.java
Tracker.start
public void start(final boolean startPeerCleaningThread) throws IOException { logger.info("Starting BitTorrent tracker on {}...", getAnnounceUrl()); connection = new SocketConnection(new ContainerServer(myTrackerServiceContainer)); List<SocketAddress> tries = new ArrayList<SocketAddress>() {{ ...
java
public void start(final boolean startPeerCleaningThread) throws IOException { logger.info("Starting BitTorrent tracker on {}...", getAnnounceUrl()); connection = new SocketConnection(new ContainerServer(myTrackerServiceContainer)); List<SocketAddress> tries = new ArrayList<SocketAddress>() {{ ...
[ "public", "void", "start", "(", "final", "boolean", "startPeerCleaningThread", ")", "throws", "IOException", "{", "logger", ".", "info", "(", "\"Starting BitTorrent tracker on {}...\"", ",", "getAnnounceUrl", "(", ")", ")", ";", "connection", "=", "new", "SocketConn...
Start the tracker thread.
[ "Start", "the", "tracker", "thread", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/Tracker.java#L148-L193
62,649
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/HTTPTrackerClient.java
HTTPTrackerClient.announce
public void announce(final AnnounceRequestMessage.RequestEvent event, boolean inhibitEvents, final AnnounceableInformation torrentInfo, final List<Peer> adresses) throws AnnounceException { logAnnounceRequest(event, torrentInfo); final List<HTTPTrackerMessage> trackerResponses = new Arra...
java
public void announce(final AnnounceRequestMessage.RequestEvent event, boolean inhibitEvents, final AnnounceableInformation torrentInfo, final List<Peer> adresses) throws AnnounceException { logAnnounceRequest(event, torrentInfo); final List<HTTPTrackerMessage> trackerResponses = new Arra...
[ "public", "void", "announce", "(", "final", "AnnounceRequestMessage", ".", "RequestEvent", "event", ",", "boolean", "inhibitEvents", ",", "final", "AnnounceableInformation", "torrentInfo", ",", "final", "List", "<", "Peer", ">", "adresses", ")", "throws", "AnnounceE...
Build, send and process a tracker announce request. <p> This function first builds an announce request for the specified event with all the required parameters. Then, the request is made to the tracker and the response analyzed. </p> <p> All registered {@link AnnounceResponseListener} objects are then fired with the ...
[ "Build", "send", "and", "process", "a", "tracker", "announce", "request", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/HTTPTrackerClient.java#L77-L104
62,650
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/HTTPTrackerClient.java
HTTPTrackerClient.buildAnnounceRequest
private HTTPAnnounceRequestMessage buildAnnounceRequest( AnnounceRequestMessage.RequestEvent event, AnnounceableInformation torrentInfo, Peer peer) throws IOException, MessageValidationException { // Build announce request message final long uploaded = torrentInfo.getUploaded(); ...
java
private HTTPAnnounceRequestMessage buildAnnounceRequest( AnnounceRequestMessage.RequestEvent event, AnnounceableInformation torrentInfo, Peer peer) throws IOException, MessageValidationException { // Build announce request message final long uploaded = torrentInfo.getUploaded(); ...
[ "private", "HTTPAnnounceRequestMessage", "buildAnnounceRequest", "(", "AnnounceRequestMessage", ".", "RequestEvent", "event", ",", "AnnounceableInformation", "torrentInfo", ",", "Peer", "peer", ")", "throws", "IOException", ",", "MessageValidationException", "{", "// Build an...
Build the announce request tracker message. @param event The announce event (can be <tt>NONE</tt> or <em>null</em>) @return Returns an instance of a {@link HTTPAnnounceRequestMessage} that can be used to generate the fully qualified announce URL, with parameters, to make the announce request. @throws UnsupportedEncodi...
[ "Build", "the", "announce", "request", "tracker", "message", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/HTTPTrackerClient.java#L309-L327
62,651
mpetazzoni/ttorrent
common/src/main/java/com/turn/ttorrent/common/protocol/http/HTTPAnnounceRequestMessage.java
HTTPAnnounceRequestMessage.buildAnnounceURL
public URL buildAnnounceURL(URL trackerAnnounceURL) throws UnsupportedEncodingException, MalformedURLException { String base = trackerAnnounceURL.toString(); StringBuilder url = new StringBuilder(base); url.append(base.contains("?") ? "&" : "?") .append("info_hash=") .appen...
java
public URL buildAnnounceURL(URL trackerAnnounceURL) throws UnsupportedEncodingException, MalformedURLException { String base = trackerAnnounceURL.toString(); StringBuilder url = new StringBuilder(base); url.append(base.contains("?") ? "&" : "?") .append("info_hash=") .appen...
[ "public", "URL", "buildAnnounceURL", "(", "URL", "trackerAnnounceURL", ")", "throws", "UnsupportedEncodingException", ",", "MalformedURLException", "{", "String", "base", "=", "trackerAnnounceURL", ".", "toString", "(", ")", ";", "StringBuilder", "url", "=", "new", ...
Build the announce request URL for the given tracker announce URL. @param trackerAnnounceURL The tracker's announce URL. @return The URL object representing the announce request URL.
[ "Build", "the", "announce", "request", "URL", "for", "the", "given", "tracker", "announce", "URL", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/protocol/http/HTTPAnnounceRequestMessage.java#L158-L188
62,652
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/peer/Rate.java
Rate.add
public synchronized void add(long count) { this.bytes += count; if (this.reset == 0) { this.reset = System.currentTimeMillis(); } this.last = System.currentTimeMillis(); }
java
public synchronized void add(long count) { this.bytes += count; if (this.reset == 0) { this.reset = System.currentTimeMillis(); } this.last = System.currentTimeMillis(); }
[ "public", "synchronized", "void", "add", "(", "long", "count", ")", "{", "this", ".", "bytes", "+=", "count", ";", "if", "(", "this", ".", "reset", "==", "0", ")", "{", "this", ".", "reset", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "...
Add a byte count to the current measurement. @param count The number of bytes exchanged since the last reset.
[ "Add", "a", "byte", "count", "to", "the", "current", "measurement", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/peer/Rate.java#L47-L53
62,653
mpetazzoni/ttorrent
common/src/main/java/com/turn/ttorrent/common/Peer.java
Peer.getRawIp
public byte[] getRawIp() { final InetAddress address = this.address.getAddress(); if (address == null) return null; return address.getAddress(); }
java
public byte[] getRawIp() { final InetAddress address = this.address.getAddress(); if (address == null) return null; return address.getAddress(); }
[ "public", "byte", "[", "]", "getRawIp", "(", ")", "{", "final", "InetAddress", "address", "=", "this", ".", "address", ".", "getAddress", "(", ")", ";", "if", "(", "address", "==", "null", ")", "return", "null", ";", "return", "address", ".", "getAddre...
Returns a binary representation of the peer's IP.
[ "Returns", "a", "binary", "representation", "of", "the", "peer", "s", "IP", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/Peer.java#L181-L185
62,654
mpetazzoni/ttorrent
cli/src/main/java/com/turn/ttorrent/cli/TrackerMain.java
TrackerMain.main
public static void main(String[] args) { BasicConfigurator.configure(new ConsoleAppender( new PatternLayout("%d [%-25t] %-5p: %m%n"))); CmdLineParser parser = new CmdLineParser(); CmdLineParser.Option help = parser.addBooleanOption('h', "help"); CmdLineParser.Option port = parser.addIntegerOption('p', "port...
java
public static void main(String[] args) { BasicConfigurator.configure(new ConsoleAppender( new PatternLayout("%d [%-25t] %-5p: %m%n"))); CmdLineParser parser = new CmdLineParser(); CmdLineParser.Option help = parser.addBooleanOption('h', "help"); CmdLineParser.Option port = parser.addIntegerOption('p', "port...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "BasicConfigurator", ".", "configure", "(", "new", "ConsoleAppender", "(", "new", "PatternLayout", "(", "\"%d [%-25t] %-5p: %m%n\"", ")", ")", ")", ";", "CmdLineParser", "parser", "...
Main function to start a tracker.
[ "Main", "function", "to", "start", "a", "tracker", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/cli/src/main/java/com/turn/ttorrent/cli/TrackerMain.java#L56-L117
62,655
mpetazzoni/ttorrent
cli/src/main/java/com/turn/ttorrent/cli/ClientMain.java
ClientMain.main
public static void main(String[] args) { BasicConfigurator.configure(new ConsoleAppender( new PatternLayout("%d [%-25t] %-5p: %m%n"))); CmdLineParser parser = new CmdLineParser(); CmdLineParser.Option help = parser.addBooleanOption('h', "help"); CmdLineParser.Option output = parser.addStrin...
java
public static void main(String[] args) { BasicConfigurator.configure(new ConsoleAppender( new PatternLayout("%d [%-25t] %-5p: %m%n"))); CmdLineParser parser = new CmdLineParser(); CmdLineParser.Option help = parser.addBooleanOption('h', "help"); CmdLineParser.Option output = parser.addStrin...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "BasicConfigurator", ".", "configure", "(", "new", "ConsoleAppender", "(", "new", "PatternLayout", "(", "\"%d [%-25t] %-5p: %m%n\"", ")", ")", ")", ";", "CmdLineParser", "parser", "...
Main client entry point for stand-alone operation.
[ "Main", "client", "entry", "point", "for", "stand", "-", "alone", "operation", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/cli/src/main/java/com/turn/ttorrent/cli/ClientMain.java#L107-L164
62,656
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/SharedTorrent.java
SharedTorrent.getPiece
public Piece getPiece(int index) { if (this.pieces == null) { throw new IllegalStateException("Torrent not initialized yet."); } if (index >= this.pieces.length) { throw new IllegalArgumentException("Invalid piece index!"); } return this.pieces[index]; }
java
public Piece getPiece(int index) { if (this.pieces == null) { throw new IllegalStateException("Torrent not initialized yet."); } if (index >= this.pieces.length) { throw new IllegalArgumentException("Invalid piece index!"); } return this.pieces[index]; }
[ "public", "Piece", "getPiece", "(", "int", "index", ")", "{", "if", "(", "this", ".", "pieces", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Torrent not initialized yet.\"", ")", ";", "}", "if", "(", "index", ">=", "this", ".", ...
Retrieve a piece object by index. @param index The index of the piece in this torrent.
[ "Retrieve", "a", "piece", "object", "by", "index", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/SharedTorrent.java#L297-L307
62,657
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/SharedTorrent.java
SharedTorrent.markCompleted
public synchronized void markCompleted(Piece piece) { if (this.completedPieces.get(piece.getIndex())) { return; } // A completed piece means that's that much data left to download for // this torrent. myTorrentStatistic.addLeft(-piece.size()); this.completedPieces.set(piece.getIndex()); ...
java
public synchronized void markCompleted(Piece piece) { if (this.completedPieces.get(piece.getIndex())) { return; } // A completed piece means that's that much data left to download for // this torrent. myTorrentStatistic.addLeft(-piece.size()); this.completedPieces.set(piece.getIndex()); ...
[ "public", "synchronized", "void", "markCompleted", "(", "Piece", "piece", ")", "{", "if", "(", "this", ".", "completedPieces", ".", "get", "(", "piece", ".", "getIndex", "(", ")", ")", ")", "{", "return", ";", "}", "// A completed piece means that's that much ...
Mark a piece as completed, decrementing the piece size in bytes from our left bytes to download counter.
[ "Mark", "a", "piece", "as", "completed", "decrementing", "the", "piece", "size", "in", "bytes", "from", "our", "left", "bytes", "to", "download", "counter", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/SharedTorrent.java#L395-L407
62,658
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/Announce.java
Announce.start
public void start(final URI defaultTrackerURI, final AnnounceResponseListener listener, final Peer[] peers, final int announceInterval) { myAnnounceInterval = announceInterval; myPeers.addAll(Arrays.asList(peers)); if (defaultTrackerURI != null) { try { myDefaultTracker = myTrackerClientFactor...
java
public void start(final URI defaultTrackerURI, final AnnounceResponseListener listener, final Peer[] peers, final int announceInterval) { myAnnounceInterval = announceInterval; myPeers.addAll(Arrays.asList(peers)); if (defaultTrackerURI != null) { try { myDefaultTracker = myTrackerClientFactor...
[ "public", "void", "start", "(", "final", "URI", "defaultTrackerURI", ",", "final", "AnnounceResponseListener", "listener", ",", "final", "Peer", "[", "]", "peers", ",", "final", "int", "announceInterval", ")", "{", "myAnnounceInterval", "=", "announceInterval", ";...
Start the announce request thread.
[ "Start", "the", "announce", "request", "thread", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/Announce.java#L109-L131
62,659
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/Announce.java
Announce.setAnnounceInterval
public void setAnnounceInterval(int announceInterval) { if (announceInterval <= 0) { this.stop(true); return; } if (this.myAnnounceInterval == announceInterval) { return; } logger.trace("Setting announce interval to {}s per tracker request.", announceInterval); th...
java
public void setAnnounceInterval(int announceInterval) { if (announceInterval <= 0) { this.stop(true); return; } if (this.myAnnounceInterval == announceInterval) { return; } logger.trace("Setting announce interval to {}s per tracker request.", announceInterval); th...
[ "public", "void", "setAnnounceInterval", "(", "int", "announceInterval", ")", "{", "if", "(", "announceInterval", "<=", "0", ")", "{", "this", ".", "stop", "(", "true", ")", ";", "return", ";", "}", "if", "(", "this", ".", "myAnnounceInterval", "==", "an...
Set the announce interval.
[ "Set", "the", "announce", "interval", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/Announce.java#L136-L149
62,660
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/Announce.java
Announce.getCurrentTrackerClient
public TrackerClient getCurrentTrackerClient(AnnounceableInformation torrent) { final URI uri = getURIForTorrent(torrent); if (uri == null) return null; return this.clients.get(uri.toString()); }
java
public TrackerClient getCurrentTrackerClient(AnnounceableInformation torrent) { final URI uri = getURIForTorrent(torrent); if (uri == null) return null; return this.clients.get(uri.toString()); }
[ "public", "TrackerClient", "getCurrentTrackerClient", "(", "AnnounceableInformation", "torrent", ")", "{", "final", "URI", "uri", "=", "getURIForTorrent", "(", "torrent", ")", ";", "if", "(", "uri", "==", "null", ")", "return", "null", ";", "return", "this", "...
Returns the current tracker client used for announces.
[ "Returns", "the", "current", "tracker", "client", "used", "for", "announces", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/announce/Announce.java#L284-L288
62,661
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java
BDecoder.bdecode
public static BEValue bdecode(ByteBuffer data) throws IOException { return BDecoder.bdecode(new ByteArrayInputStream(data.array())); }
java
public static BEValue bdecode(ByteBuffer data) throws IOException { return BDecoder.bdecode(new ByteArrayInputStream(data.array())); }
[ "public", "static", "BEValue", "bdecode", "(", "ByteBuffer", "data", ")", "throws", "IOException", "{", "return", "BDecoder", ".", "bdecode", "(", "new", "ByteArrayInputStream", "(", "data", ".", "array", "(", ")", ")", ")", ";", "}" ]
Decode a B-encoded byte buffer. <p> Automatically instantiates a new BDecoder for the provided buffer and decodes its root member. </p> @param data The {@link ByteBuffer} to read from.
[ "Decode", "a", "B", "-", "encoded", "byte", "buffer", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java#L99-L101
62,662
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java
BDecoder.bdecode
public BEValue bdecode() throws IOException { if (this.getNextIndicator() == -1) return null; if (this.indicator >= '0' && this.indicator <= '9') return this.bdecodeBytes(); else if (this.indicator == 'i') return this.bdecodeNumber(); else if (this.indicator == 'l') return this....
java
public BEValue bdecode() throws IOException { if (this.getNextIndicator() == -1) return null; if (this.indicator >= '0' && this.indicator <= '9') return this.bdecodeBytes(); else if (this.indicator == 'i') return this.bdecodeNumber(); else if (this.indicator == 'l') return this....
[ "public", "BEValue", "bdecode", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "getNextIndicator", "(", ")", "==", "-", "1", ")", "return", "null", ";", "if", "(", "this", ".", "indicator", ">=", "'", "'", "&&", "this", ".", "indicat...
Gets the next indicator and returns either null when the stream has ended or b-decodes the rest of the stream and returns the appropriate BEValue encoded object.
[ "Gets", "the", "next", "indicator", "and", "returns", "either", "null", "when", "the", "stream", "has", "ended", "or", "b", "-", "decodes", "the", "rest", "of", "the", "stream", "and", "returns", "the", "appropriate", "BEValue", "encoded", "object", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java#L126-L141
62,663
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java
BDecoder.bdecodeBytes
public BEValue bdecodeBytes() throws IOException { int c = this.getNextIndicator(); int num = c - '0'; if (num < 0 || num > 9) throw new InvalidBEncodingException("Number expected, not '" + (char) c + "'"); this.indicator = 0; c = this.read(); int i = c - '0'; while (i >...
java
public BEValue bdecodeBytes() throws IOException { int c = this.getNextIndicator(); int num = c - '0'; if (num < 0 || num > 9) throw new InvalidBEncodingException("Number expected, not '" + (char) c + "'"); this.indicator = 0; c = this.read(); int i = c - '0'; while (i >...
[ "public", "BEValue", "bdecodeBytes", "(", ")", "throws", "IOException", "{", "int", "c", "=", "this", ".", "getNextIndicator", "(", ")", ";", "int", "num", "=", "c", "-", "'", "'", ";", "if", "(", "num", "<", "0", "||", "num", ">", "9", ")", "thr...
Returns the next b-encoded value on the stream and makes sure it is a byte array. @throws InvalidBEncodingException If it is not a b-encoded byte array.
[ "Returns", "the", "next", "b", "-", "encoded", "value", "on", "the", "stream", "and", "makes", "sure", "it", "is", "a", "byte", "array", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java#L149-L172
62,664
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java
BDecoder.bdecodeNumber
public BEValue bdecodeNumber() throws IOException { int c = this.getNextIndicator(); if (c != 'i') { throw new InvalidBEncodingException("Expected 'i', not '" + (char) c + "'"); } this.indicator = 0; c = this.read(); if (c == '0') { c = this.read(); if (c == 'e')...
java
public BEValue bdecodeNumber() throws IOException { int c = this.getNextIndicator(); if (c != 'i') { throw new InvalidBEncodingException("Expected 'i', not '" + (char) c + "'"); } this.indicator = 0; c = this.read(); if (c == '0') { c = this.read(); if (c == 'e')...
[ "public", "BEValue", "bdecodeNumber", "(", ")", "throws", "IOException", "{", "int", "c", "=", "this", ".", "getNextIndicator", "(", ")", ";", "if", "(", "c", "!=", "'", "'", ")", "{", "throw", "new", "InvalidBEncodingException", "(", "\"Expected 'i', not '\...
Returns the next b-encoded value on the stream and makes sure it is a number. @throws InvalidBEncodingException If it is not a number.
[ "Returns", "the", "next", "b", "-", "encoded", "value", "on", "the", "stream", "and", "makes", "sure", "it", "is", "a", "number", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java#L180-L230
62,665
mpetazzoni/ttorrent
bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java
BDecoder.bdecodeList
public BEValue bdecodeList() throws IOException { int c = this.getNextIndicator(); if (c != 'l') { throw new InvalidBEncodingException("Expected 'l', not '" + (char) c + "'"); } this.indicator = 0; List<BEValue> result = new ArrayList<BEValue>(); c = this.getNextIndicator();...
java
public BEValue bdecodeList() throws IOException { int c = this.getNextIndicator(); if (c != 'l') { throw new InvalidBEncodingException("Expected 'l', not '" + (char) c + "'"); } this.indicator = 0; List<BEValue> result = new ArrayList<BEValue>(); c = this.getNextIndicator();...
[ "public", "BEValue", "bdecodeList", "(", ")", "throws", "IOException", "{", "int", "c", "=", "this", ".", "getNextIndicator", "(", ")", ";", "if", "(", "c", "!=", "'", "'", ")", "{", "throw", "new", "InvalidBEncodingException", "(", "\"Expected 'l', not '\""...
Returns the next b-encoded value on the stream and makes sure it is a list. @throws InvalidBEncodingException If it is not a list.
[ "Returns", "the", "next", "b", "-", "encoded", "value", "on", "the", "stream", "and", "makes", "sure", "it", "is", "a", "list", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/bencoding/src/main/java/com/turn/ttorrent/bcodec/BDecoder.java#L238-L255
62,666
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java
Piece.validate
public boolean validate(SharedTorrent torrent, Piece piece) throws IOException { logger.trace("Validating {}...", this); // TODO: remove cast to int when large ByteBuffer support is // implemented in Java. byte[] pieceBytes = data.array(); final byte[] calculatedHash = TorrentUtils.calculateSha1Ha...
java
public boolean validate(SharedTorrent torrent, Piece piece) throws IOException { logger.trace("Validating {}...", this); // TODO: remove cast to int when large ByteBuffer support is // implemented in Java. byte[] pieceBytes = data.array(); final byte[] calculatedHash = TorrentUtils.calculateSha1Ha...
[ "public", "boolean", "validate", "(", "SharedTorrent", "torrent", ",", "Piece", "piece", ")", "throws", "IOException", "{", "logger", ".", "trace", "(", "\"Validating {}...\"", ",", "this", ")", ";", "// TODO: remove cast to int when large ByteBuffer support is", "// im...
Validates this piece. @return Returns true if this piece, as stored in the underlying byte storage, is valid, i.e. its SHA1 sum matches the one from the torrent meta-info.
[ "Validates", "this", "piece", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java#L150-L162
62,667
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java
Piece._read
private ByteBuffer _read(long offset, long length, ByteBuffer buffer) throws IOException { if (offset + length > this.length) { throw new IllegalArgumentException("Piece#" + this.index + " overrun (" + offset + " + " + length + " > " + this.length + ") !"); } // TODO: remo...
java
private ByteBuffer _read(long offset, long length, ByteBuffer buffer) throws IOException { if (offset + length > this.length) { throw new IllegalArgumentException("Piece#" + this.index + " overrun (" + offset + " + " + length + " > " + this.length + ") !"); } // TODO: remo...
[ "private", "ByteBuffer", "_read", "(", "long", "offset", ",", "long", "length", ",", "ByteBuffer", "buffer", ")", "throws", "IOException", "{", "if", "(", "offset", "+", "length", ">", "this", ".", "length", ")", "{", "throw", "new", "IllegalArgumentExceptio...
Internal piece data read function. <p> This function will read the piece data without checking if the piece has been validated. It is simply meant at factoring-in the common read code from the validate and read functions. </p> @param offset Offset inside this piece where to start reading. @param length Number of byte...
[ "Internal", "piece", "data", "read", "function", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java#L181-L196
62,668
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java
Piece.read
public ByteBuffer read(long offset, int length, ByteBuffer block) throws IllegalArgumentException, IllegalStateException, IOException { if (!this.valid) { throw new IllegalStateException("Attempting to read an " + "known-to-be invalid piece!"); } return this._read(offset, leng...
java
public ByteBuffer read(long offset, int length, ByteBuffer block) throws IllegalArgumentException, IllegalStateException, IOException { if (!this.valid) { throw new IllegalStateException("Attempting to read an " + "known-to-be invalid piece!"); } return this._read(offset, leng...
[ "public", "ByteBuffer", "read", "(", "long", "offset", ",", "int", "length", ",", "ByteBuffer", "block", ")", "throws", "IllegalArgumentException", ",", "IllegalStateException", ",", "IOException", "{", "if", "(", "!", "this", ".", "valid", ")", "{", "throw", ...
Read a piece block from the underlying byte storage. <p> This is the public method for reading this piece's data, and it will only succeed if the piece is complete and valid on disk, thus ensuring any data that comes out of this function is valid piece data we can send to other peers. </p> @param offset Offset inside...
[ "Read", "a", "piece", "block", "from", "the", "underlying", "byte", "storage", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java#L218-L226
62,669
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java
Piece.record
public void record(ByteBuffer block, int offset) { if (this.data == null) { // TODO: remove cast to int when large ByteBuffer support is // implemented in Java. this.data = ByteBuffer.allocate((int) this.length); } int pos = block.position(); this.data.position(offset); this.data....
java
public void record(ByteBuffer block, int offset) { if (this.data == null) { // TODO: remove cast to int when large ByteBuffer support is // implemented in Java. this.data = ByteBuffer.allocate((int) this.length); } int pos = block.position(); this.data.position(offset); this.data....
[ "public", "void", "record", "(", "ByteBuffer", "block", ",", "int", "offset", ")", "{", "if", "(", "this", ".", "data", "==", "null", ")", "{", "// TODO: remove cast to int when large ByteBuffer support is", "// implemented in Java.", "this", ".", "data", "=", "By...
Record the given block at the given offset in this piece. @param block The ByteBuffer containing the block data. @param offset The block offset in this piece.
[ "Record", "the", "given", "block", "at", "the", "given", "offset", "in", "this", "piece", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java#L234-L245
62,670
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java
Piece.compareTo
public int compareTo(Piece other) { // return true for the same pieces, otherwise sort by time seen, then by index; if (this.equals(other)) { return 0; } else if (this.seen == other.seen) { return new Integer(this.index).compareTo(other.index); } else if (this.seen < other.seen) { retu...
java
public int compareTo(Piece other) { // return true for the same pieces, otherwise sort by time seen, then by index; if (this.equals(other)) { return 0; } else if (this.seen == other.seen) { return new Integer(this.index).compareTo(other.index); } else if (this.seen < other.seen) { retu...
[ "public", "int", "compareTo", "(", "Piece", "other", ")", "{", "// return true for the same pieces, otherwise sort by time seen, then by index;", "if", "(", "this", ".", "equals", "(", "other", ")", ")", "{", "return", "0", ";", "}", "else", "if", "(", "this", "...
Piece comparison function for ordering pieces based on their availability. @param other The piece to compare with, should not be <em>null</em>.
[ "Piece", "comparison", "function", "for", "ordering", "pieces", "based", "on", "their", "availability", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/Piece.java#L281-L292
62,671
mpetazzoni/ttorrent
ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackedTorrent.java
TrackedTorrent.addPeer
public void addPeer(TrackedPeer peer) { this.peers.put(new PeerUID(peer.getAddress(), this.getHexInfoHash()), peer); }
java
public void addPeer(TrackedPeer peer) { this.peers.put(new PeerUID(peer.getAddress(), this.getHexInfoHash()), peer); }
[ "public", "void", "addPeer", "(", "TrackedPeer", "peer", ")", "{", "this", ".", "peers", ".", "put", "(", "new", "PeerUID", "(", "peer", ".", "getAddress", "(", ")", ",", "this", ".", "getHexInfoHash", "(", ")", ")", ",", "peer", ")", ";", "}" ]
Add a peer exchanging on this torrent. @param peer The new Peer involved with this torrent.
[ "Add", "a", "peer", "exchanging", "on", "this", "torrent", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackedTorrent.java#L105-L107
62,672
mpetazzoni/ttorrent
ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackedTorrent.java
TrackedTorrent.getSomePeers
public List<Peer> getSomePeers(Peer peer) { List<Peer> peers = new LinkedList<Peer>(); // Extract answerPeers random peers List<TrackedPeer> candidates = new LinkedList<TrackedPeer>(this.peers.values()); Collections.shuffle(candidates); int count = 0; for (TrackedPeer candidate : candidates) {...
java
public List<Peer> getSomePeers(Peer peer) { List<Peer> peers = new LinkedList<Peer>(); // Extract answerPeers random peers List<TrackedPeer> candidates = new LinkedList<TrackedPeer>(this.peers.values()); Collections.shuffle(candidates); int count = 0; for (TrackedPeer candidate : candidates) {...
[ "public", "List", "<", "Peer", ">", "getSomePeers", "(", "Peer", "peer", ")", "{", "List", "<", "Peer", ">", "peers", "=", "new", "LinkedList", "<", "Peer", ">", "(", ")", ";", "// Extract answerPeers random peers", "List", "<", "TrackedPeer", ">", "candid...
Get a list of peers we can return in an announce response for this torrent. @param peer The peer making the request, so we can exclude it from the list of returned peers. @return A list of peers we can include in an announce response.
[ "Get", "a", "list", "of", "peers", "we", "can", "return", "in", "an", "announce", "response", "for", "this", "torrent", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackedTorrent.java#L238-L261
62,673
mpetazzoni/ttorrent
ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackedTorrent.java
TrackedTorrent.load
public static TrackedTorrent load(File torrent) throws IOException { TorrentMetadata torrentMetadata = new TorrentParser().parseFromFile(torrent); return new TrackedTorrent(torrentMetadata.getInfoHash()); }
java
public static TrackedTorrent load(File torrent) throws IOException { TorrentMetadata torrentMetadata = new TorrentParser().parseFromFile(torrent); return new TrackedTorrent(torrentMetadata.getInfoHash()); }
[ "public", "static", "TrackedTorrent", "load", "(", "File", "torrent", ")", "throws", "IOException", "{", "TorrentMetadata", "torrentMetadata", "=", "new", "TorrentParser", "(", ")", ".", "parseFromFile", "(", "torrent", ")", ";", "return", "new", "TrackedTorrent",...
Load a tracked torrent from the given torrent file. @param torrent The abstract {@link File} object representing the <tt>.torrent</tt> file to load. @throws IOException When the torrent file cannot be read.
[ "Load", "a", "tracked", "torrent", "from", "the", "given", "torrent", "file", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackedTorrent.java#L270-L274
62,674
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.addTorrent
public TorrentManager addTorrent(String dotTorrentFilePath, String downloadDirPath) throws IOException { return addTorrent(dotTorrentFilePath, downloadDirPath, FairPieceStorageFactory.INSTANCE); }
java
public TorrentManager addTorrent(String dotTorrentFilePath, String downloadDirPath) throws IOException { return addTorrent(dotTorrentFilePath, downloadDirPath, FairPieceStorageFactory.INSTANCE); }
[ "public", "TorrentManager", "addTorrent", "(", "String", "dotTorrentFilePath", ",", "String", "downloadDirPath", ")", "throws", "IOException", "{", "return", "addTorrent", "(", "dotTorrentFilePath", ",", "downloadDirPath", ",", "FairPieceStorageFactory", ".", "INSTANCE", ...
Adds torrent to storage, validate downloaded files and start seeding and leeching the torrent @param dotTorrentFilePath path to torrent metadata file @param downloadDirPath path to directory where downloaded files are placed @return {@link TorrentManager} instance for monitoring torrent state @throws IOException if...
[ "Adds", "torrent", "to", "storage", "validate", "downloaded", "files", "and", "start", "seeding", "and", "leeching", "the", "torrent" ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L129-L131
62,675
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.addTorrent
public TorrentManager addTorrent(String dotTorrentFilePath, String downloadDirPath, List<TorrentListener> listeners) throws IOException { return addTorrent(dotTorrentFilePath, downloadDirPath, FairPieceStorageFactory.INSTANCE, listeners); }
java
public TorrentManager addTorrent(String dotTorrentFilePath, String downloadDirPath, List<TorrentListener> listeners) throws IOException { return addTorrent(dotTorrentFilePath, downloadDirPath, FairPieceStorageFactory.INSTANCE, listeners); }
[ "public", "TorrentManager", "addTorrent", "(", "String", "dotTorrentFilePath", ",", "String", "downloadDirPath", ",", "List", "<", "TorrentListener", ">", "listeners", ")", "throws", "IOException", "{", "return", "addTorrent", "(", "dotTorrentFilePath", ",", "download...
Adds torrent to storage with specified listeners, validate downloaded files and start seeding and leeching the torrent @param dotTorrentFilePath path to torrent metadata file @param downloadDirPath path to directory where downloaded files are placed @param listeners specified listeners @return {@link Torre...
[ "Adds", "torrent", "to", "storage", "with", "specified", "listeners", "validate", "downloaded", "files", "and", "start", "seeding", "and", "leeching", "the", "torrent" ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L142-L144
62,676
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.addTorrent
public TorrentManager addTorrent(TorrentMetadataProvider metadataProvider, PieceStorage pieceStorage) throws IOException { return addTorrent(metadataProvider, pieceStorage, Collections.<TorrentListener>emptyList()); }
java
public TorrentManager addTorrent(TorrentMetadataProvider metadataProvider, PieceStorage pieceStorage) throws IOException { return addTorrent(metadataProvider, pieceStorage, Collections.<TorrentListener>emptyList()); }
[ "public", "TorrentManager", "addTorrent", "(", "TorrentMetadataProvider", "metadataProvider", ",", "PieceStorage", "pieceStorage", ")", "throws", "IOException", "{", "return", "addTorrent", "(", "metadataProvider", ",", "pieceStorage", ",", "Collections", ".", "<", "Tor...
Adds torrent to storage with any storage and metadata source @param metadataProvider specified metadata source @param pieceStorage specified storage of pieces @return {@link TorrentManager} instance for monitoring torrent state @throws IOException if IO error occurs in reading metadata file
[ "Adds", "torrent", "to", "storage", "with", "any", "storage", "and", "metadata", "source" ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L191-L193
62,677
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.addTorrent
public TorrentManager addTorrent(TorrentMetadataProvider metadataProvider, PieceStorage pieceStorage, List<TorrentListener> listeners) throws IOException { TorrentMetadata torrentMetadata = metadataProvider.getTorrentMetadata(); EventDispatch...
java
public TorrentManager addTorrent(TorrentMetadataProvider metadataProvider, PieceStorage pieceStorage, List<TorrentListener> listeners) throws IOException { TorrentMetadata torrentMetadata = metadataProvider.getTorrentMetadata(); EventDispatch...
[ "public", "TorrentManager", "addTorrent", "(", "TorrentMetadataProvider", "metadataProvider", ",", "PieceStorage", "pieceStorage", ",", "List", "<", "TorrentListener", ">", "listeners", ")", "throws", "IOException", "{", "TorrentMetadata", "torrentMetadata", "=", "metadat...
Adds torrent to storage with any storage, metadata source and specified listeners @param metadataProvider specified metadata source @param pieceStorage specified storage of pieces @param listeners specified listeners @return {@link TorrentManager} instance for monitoring torrent state @throws IOException if...
[ "Adds", "torrent", "to", "storage", "with", "any", "storage", "metadata", "source", "and", "specified", "listeners" ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L204-L231
62,678
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.removeTorrent
public void removeTorrent(String torrentHash) { logger.debug("Stopping seeding " + torrentHash); final Pair<SharedTorrent, LoadedTorrent> torrents = torrentsStorage.remove(torrentHash); SharedTorrent torrent = torrents.first(); if (torrent != null) { torrent.setClientState(ClientState.DONE); ...
java
public void removeTorrent(String torrentHash) { logger.debug("Stopping seeding " + torrentHash); final Pair<SharedTorrent, LoadedTorrent> torrents = torrentsStorage.remove(torrentHash); SharedTorrent torrent = torrents.first(); if (torrent != null) { torrent.setClientState(ClientState.DONE); ...
[ "public", "void", "removeTorrent", "(", "String", "torrentHash", ")", "{", "logger", ".", "debug", "(", "\"Stopping seeding \"", "+", "torrentHash", ")", ";", "final", "Pair", "<", "SharedTorrent", ",", "LoadedTorrent", ">", "torrents", "=", "torrentsStorage", "...
Removes specified torrent from storage. @param torrentHash specified torrent hash
[ "Removes", "specified", "torrent", "from", "storage", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L266-L280
62,679
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.isSeed
public boolean isSeed(String hexInfoHash) { SharedTorrent t = this.torrentsStorage.getTorrent(hexInfoHash); return t != null && t.isComplete(); }
java
public boolean isSeed(String hexInfoHash) { SharedTorrent t = this.torrentsStorage.getTorrent(hexInfoHash); return t != null && t.isComplete(); }
[ "public", "boolean", "isSeed", "(", "String", "hexInfoHash", ")", "{", "SharedTorrent", "t", "=", "this", ".", "torrentsStorage", ".", "getTorrent", "(", "hexInfoHash", ")", ";", "return", "t", "!=", "null", "&&", "t", ".", "isComplete", "(", ")", ";", "...
Tells whether we are a seed for the torrent we're sharing.
[ "Tells", "whether", "we", "are", "a", "seed", "for", "the", "torrent", "we", "re", "sharing", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L513-L516
62,680
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.handleAnnounceResponse
@Override public void handleAnnounceResponse(int interval, int complete, int incomplete, String hexInfoHash) { final SharedTorrent sharedTorrent = this.torrentsStorage.getTorrent(hexInfoHash); if (sharedTorrent != null) { sharedTorrent.setSeedersCount(complete); sharedTorrent.setLastAnnounceTime(S...
java
@Override public void handleAnnounceResponse(int interval, int complete, int incomplete, String hexInfoHash) { final SharedTorrent sharedTorrent = this.torrentsStorage.getTorrent(hexInfoHash); if (sharedTorrent != null) { sharedTorrent.setSeedersCount(complete); sharedTorrent.setLastAnnounceTime(S...
[ "@", "Override", "public", "void", "handleAnnounceResponse", "(", "int", "interval", ",", "int", "complete", ",", "int", "incomplete", ",", "String", "hexInfoHash", ")", "{", "final", "SharedTorrent", "sharedTorrent", "=", "this", ".", "torrentsStorage", ".", "g...
Handle an announce response event. @param interval The announce interval requested by the tracker. @param complete The number of seeders on this torrent. @param incomplete The number of leechers on this torrent.
[ "Handle", "an", "announce", "response", "event", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L604-L612
62,681
mpetazzoni/ttorrent
ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java
CommunicationManager.handleDiscoveredPeers
@Override public void handleDiscoveredPeers(List<Peer> peers, String hexInfoHash) { if (peers.size() == 0) return; SharedTorrent torrent = torrentsStorage.getTorrent(hexInfoHash); if (torrent != null && torrent.isFinished()) return; final LoadedTorrent announceableTorrent = torrentsStorage.getLoad...
java
@Override public void handleDiscoveredPeers(List<Peer> peers, String hexInfoHash) { if (peers.size() == 0) return; SharedTorrent torrent = torrentsStorage.getTorrent(hexInfoHash); if (torrent != null && torrent.isFinished()) return; final LoadedTorrent announceableTorrent = torrentsStorage.getLoad...
[ "@", "Override", "public", "void", "handleDiscoveredPeers", "(", "List", "<", "Peer", ">", "peers", ",", "String", "hexInfoHash", ")", "{", "if", "(", "peers", ".", "size", "(", ")", "==", "0", ")", "return", ";", "SharedTorrent", "torrent", "=", "torren...
Handle the discovery of new peers. @param peers The list of peers discovered (from the announce response or any other means like DHT/PEX, etc.).
[ "Handle", "the", "discovery", "of", "new", "peers", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-client/src/main/java/com/turn/ttorrent/client/CommunicationManager.java#L620-L676
62,682
mpetazzoni/ttorrent
common/src/main/java/com/turn/ttorrent/common/TorrentUtils.java
TorrentUtils.byteArrayToHexString
public static String byteArrayToHexString(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = HEX_SYMBOLS[v >>> 4]; hexChars[j * 2 + 1] = HEX_SYMBOLS[v & 0x0F]; } return new String(hexChars); ...
java
public static String byteArrayToHexString(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = HEX_SYMBOLS[v >>> 4]; hexChars[j * 2 + 1] = HEX_SYMBOLS[v & 0x0F]; } return new String(hexChars); ...
[ "public", "static", "String", "byteArrayToHexString", "(", "byte", "[", "]", "bytes", ")", "{", "char", "[", "]", "hexChars", "=", "new", "char", "[", "bytes", ".", "length", "*", "2", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "b...
Convert a byte string to a string containing an hexadecimal representation of the original data. @param bytes The byte array to convert.
[ "Convert", "a", "byte", "string", "to", "a", "string", "containing", "an", "hexadecimal", "representation", "of", "the", "original", "data", "." ]
ecd0e6caf853b63393c4ab63cfd8f20114f73f70
https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/TorrentUtils.java#L26-L34
62,683
spring-cloud/spring-cloud-zookeeper
spring-cloud-zookeeper-core/src/main/java/org/springframework/cloud/zookeeper/ZookeeperHealthAutoConfiguration.java
ZookeeperHealthAutoConfiguration.zookeeperHealthIndicator
@Bean @ConditionalOnMissingBean(ZookeeperHealthIndicator.class) @ConditionalOnBean(CuratorFramework.class) @ConditionalOnEnabledHealthIndicator("zookeeper") public ZookeeperHealthIndicator zookeeperHealthIndicator(CuratorFramework curator) { return new ZookeeperHealthIndicator(curator); }
java
@Bean @ConditionalOnMissingBean(ZookeeperHealthIndicator.class) @ConditionalOnBean(CuratorFramework.class) @ConditionalOnEnabledHealthIndicator("zookeeper") public ZookeeperHealthIndicator zookeeperHealthIndicator(CuratorFramework curator) { return new ZookeeperHealthIndicator(curator); }
[ "@", "Bean", "@", "ConditionalOnMissingBean", "(", "ZookeeperHealthIndicator", ".", "class", ")", "@", "ConditionalOnBean", "(", "CuratorFramework", ".", "class", ")", "@", "ConditionalOnEnabledHealthIndicator", "(", "\"zookeeper\"", ")", "public", "ZookeeperHealthIndicat...
If there is an active curator, if the zookeeper health endpoint is enabled and if a health indicator hasn't already been added by a user add one. @param curator The curator connection to zookeeper to use @return An instance of {@link ZookeeperHealthIndicator} to add to actuator health report
[ "If", "there", "is", "an", "active", "curator", "if", "the", "zookeeper", "health", "endpoint", "is", "enabled", "and", "if", "a", "health", "indicator", "hasn", "t", "already", "been", "added", "by", "a", "user", "add", "one", "." ]
1ed80350fe381c4e73fa797741f5ec319db22073
https://github.com/spring-cloud/spring-cloud-zookeeper/blob/1ed80350fe381c4e73fa797741f5ec319db22073/spring-cloud-zookeeper-core/src/main/java/org/springframework/cloud/zookeeper/ZookeeperHealthAutoConfiguration.java#L50-L56
62,684
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/ExplicitMappingBuilder.java
ExplicitMappingBuilder.createProxies
private void createProxies() { source = createProxy(sourceType); destination = createProxy(destinationType); for (VisitedMapping mapping : visitedMappings) { createAccessorProxies(source, mapping.sourceAccessors); createAccessorProxies(destination, mapping.destinationAccessors); } ...
java
private void createProxies() { source = createProxy(sourceType); destination = createProxy(destinationType); for (VisitedMapping mapping : visitedMappings) { createAccessorProxies(source, mapping.sourceAccessors); createAccessorProxies(destination, mapping.destinationAccessors); } ...
[ "private", "void", "createProxies", "(", ")", "{", "source", "=", "createProxy", "(", "sourceType", ")", ";", "destination", "=", "createProxy", "(", "destinationType", ")", ";", "for", "(", "VisitedMapping", "mapping", ":", "visitedMappings", ")", "{", "creat...
Creates the source and destination proxy models.
[ "Creates", "the", "source", "and", "destination", "proxy", "models", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/ExplicitMappingBuilder.java#L272-L280
62,685
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/ExplicitMappingBuilder.java
ExplicitMappingBuilder.validateRecordedMapping
private void validateRecordedMapping() { if (currentMapping.destinationMutators == null || currentMapping.destinationMutators.isEmpty()) errors.missingDestination(); // If mapping a field without a source else if (options.skipType == 0 && (currentMapping.sourceAccessors == null || current...
java
private void validateRecordedMapping() { if (currentMapping.destinationMutators == null || currentMapping.destinationMutators.isEmpty()) errors.missingDestination(); // If mapping a field without a source else if (options.skipType == 0 && (currentMapping.sourceAccessors == null || current...
[ "private", "void", "validateRecordedMapping", "(", ")", "{", "if", "(", "currentMapping", ".", "destinationMutators", "==", "null", "||", "currentMapping", ".", "destinationMutators", ".", "isEmpty", "(", ")", ")", "errors", ".", "missingDestination", "(", ")", ...
Validates the current mapping that was recorded via a MapExpression.
[ "Validates", "the", "current", "mapping", "that", "was", "recorded", "via", "a", "MapExpression", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/ExplicitMappingBuilder.java#L347-L360
62,686
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/TypeInfoRegistry.java
TypeInfoRegistry.typeInfoFor
@SuppressWarnings("unchecked") static <T> TypeInfoImpl<T> typeInfoFor(Class<T> sourceType, InheritingConfiguration configuration) { TypeInfoKey pair = new TypeInfoKey(sourceType, configuration); TypeInfoImpl<T> typeInfo = (TypeInfoImpl<T>) cache.get(pair); if (typeInfo == null) { synchronized...
java
@SuppressWarnings("unchecked") static <T> TypeInfoImpl<T> typeInfoFor(Class<T> sourceType, InheritingConfiguration configuration) { TypeInfoKey pair = new TypeInfoKey(sourceType, configuration); TypeInfoImpl<T> typeInfo = (TypeInfoImpl<T>) cache.get(pair); if (typeInfo == null) { synchronized...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "static", "<", "T", ">", "TypeInfoImpl", "<", "T", ">", "typeInfoFor", "(", "Class", "<", "T", ">", "sourceType", ",", "InheritingConfiguration", "configuration", ")", "{", "TypeInfoKey", "pair", "=", "new", ...
Returns a statically cached TypeInfoImpl instance for the given criteria.
[ "Returns", "a", "statically", "cached", "TypeInfoImpl", "instance", "for", "the", "given", "criteria", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/TypeInfoRegistry.java#L76-L92
62,687
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/util/Types.java
Types.mightContainsProperties
public static boolean mightContainsProperties(Class<?> type) { return type != Object.class && type != String.class && type != Date.class && type != Calendar.class && !Primitives.isPrimitive(type) && !Iterables.isIterable(type) && !Types.isGroovyType(type); }
java
public static boolean mightContainsProperties(Class<?> type) { return type != Object.class && type != String.class && type != Date.class && type != Calendar.class && !Primitives.isPrimitive(type) && !Iterables.isIterable(type) && !Types.isGroovyType(type); }
[ "public", "static", "boolean", "mightContainsProperties", "(", "Class", "<", "?", ">", "type", ")", "{", "return", "type", "!=", "Object", ".", "class", "&&", "type", "!=", "String", ".", "class", "&&", "type", "!=", "Date", ".", "class", "&&", "type", ...
Returns whether the type might contains properties or not.
[ "Returns", "whether", "the", "type", "might", "contains", "properties", "or", "not", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/util/Types.java#L189-L197
62,688
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/ImplicitMappingBuilder.java
ImplicitMappingBuilder.mergeMappings
private void mergeMappings(TypeMap<?, ?> destinationMap) { for (Mapping mapping : destinationMap.getMappings()) { InternalMapping internalMapping = (InternalMapping) mapping; mergedMappings.add(internalMapping.createMergedCopy( propertyNameInfo.getSourceProperties(), propertyNameInfo.getDe...
java
private void mergeMappings(TypeMap<?, ?> destinationMap) { for (Mapping mapping : destinationMap.getMappings()) { InternalMapping internalMapping = (InternalMapping) mapping; mergedMappings.add(internalMapping.createMergedCopy( propertyNameInfo.getSourceProperties(), propertyNameInfo.getDe...
[ "private", "void", "mergeMappings", "(", "TypeMap", "<", "?", ",", "?", ">", "destinationMap", ")", "{", "for", "(", "Mapping", "mapping", ":", "destinationMap", ".", "getMappings", "(", ")", ")", "{", "InternalMapping", "internalMapping", "=", "(", "Interna...
Merges mappings from an existing TypeMap into the type map under construction.
[ "Merges", "mappings", "from", "an", "existing", "TypeMap", "into", "the", "type", "map", "under", "construction", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/ImplicitMappingBuilder.java#L389-L395
62,689
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/ImplicitMappingBuilder.java
ImplicitMappingBuilder.isConvertable
private boolean isConvertable(Mapping mapping) { if (mapping == null || mapping.getProvider() != null || !(mapping instanceof PropertyMapping)) return false; PropertyMapping propertyMapping = (PropertyMapping) mapping; boolean hasSupportConverter = converterStore.getFirstSupported( prop...
java
private boolean isConvertable(Mapping mapping) { if (mapping == null || mapping.getProvider() != null || !(mapping instanceof PropertyMapping)) return false; PropertyMapping propertyMapping = (PropertyMapping) mapping; boolean hasSupportConverter = converterStore.getFirstSupported( prop...
[ "private", "boolean", "isConvertable", "(", "Mapping", "mapping", ")", "{", "if", "(", "mapping", "==", "null", "||", "mapping", ".", "getProvider", "(", ")", "!=", "null", "||", "!", "(", "mapping", "instanceof", "PropertyMapping", ")", ")", "return", "fa...
Indicates whether the mapping represents a PropertyMapping that is convertible to the destination type.
[ "Indicates", "whether", "the", "mapping", "represents", "a", "PropertyMapping", "that", "is", "convertible", "to", "the", "destination", "type", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/ImplicitMappingBuilder.java#L402-L416
62,690
modelmapper/modelmapper
examples/src/main/java/org/modelmapper/gettingstarted/GettingStartedExample.java
GettingStartedExample.mapAutomatically
static void mapAutomatically() { Order order = createOrder(); ModelMapper modelMapper = new ModelMapper(); OrderDTO orderDTO = modelMapper.map(order, OrderDTO.class); assertOrdersEqual(order, orderDTO); }
java
static void mapAutomatically() { Order order = createOrder(); ModelMapper modelMapper = new ModelMapper(); OrderDTO orderDTO = modelMapper.map(order, OrderDTO.class); assertOrdersEqual(order, orderDTO); }
[ "static", "void", "mapAutomatically", "(", ")", "{", "Order", "order", "=", "createOrder", "(", ")", ";", "ModelMapper", "modelMapper", "=", "new", "ModelMapper", "(", ")", ";", "OrderDTO", "orderDTO", "=", "modelMapper", ".", "map", "(", "order", ",", "Or...
This example demonstrates how ModelMapper automatically maps properties from Order to OrderDTO.
[ "This", "example", "demonstrates", "how", "ModelMapper", "automatically", "maps", "properties", "from", "Order", "to", "OrderDTO", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/examples/src/main/java/org/modelmapper/gettingstarted/GettingStartedExample.java#L20-L25
62,691
modelmapper/modelmapper
examples/src/main/java/org/modelmapper/gettingstarted/GettingStartedExample.java
GettingStartedExample.mapExplicitly
static void mapExplicitly() { Order order = createOrder(); ModelMapper modelMapper = new ModelMapper(); modelMapper.addMappings(new PropertyMap<Order, OrderDTO>() { @Override protected void configure() { map().setBillingStreet(source.getBillingAddress().getStreet()); map(source.b...
java
static void mapExplicitly() { Order order = createOrder(); ModelMapper modelMapper = new ModelMapper(); modelMapper.addMappings(new PropertyMap<Order, OrderDTO>() { @Override protected void configure() { map().setBillingStreet(source.getBillingAddress().getStreet()); map(source.b...
[ "static", "void", "mapExplicitly", "(", ")", "{", "Order", "order", "=", "createOrder", "(", ")", ";", "ModelMapper", "modelMapper", "=", "new", "ModelMapper", "(", ")", ";", "modelMapper", ".", "addMappings", "(", "new", "PropertyMap", "<", "Order", ",", ...
This example demonstrates how ModelMapper can be used to explicitly map properties from an Order to OrderDTO.
[ "This", "example", "demonstrates", "how", "ModelMapper", "can", "be", "used", "to", "explicitly", "map", "properties", "from", "an", "Order", "to", "OrderDTO", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/examples/src/main/java/org/modelmapper/gettingstarted/GettingStartedExample.java#L31-L44
62,692
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/util/MappingContextHelper.java
MappingContextHelper.createCollection
public static <T> Collection<T> createCollection(MappingContext<?, Collection<T>> context) { if (context.getDestinationType().isInterface()) if (SortedSet.class.isAssignableFrom(context.getDestinationType())) return new TreeSet<T>(); else if (Set.class.isAssignableFrom(context.getDes...
java
public static <T> Collection<T> createCollection(MappingContext<?, Collection<T>> context) { if (context.getDestinationType().isInterface()) if (SortedSet.class.isAssignableFrom(context.getDestinationType())) return new TreeSet<T>(); else if (Set.class.isAssignableFrom(context.getDes...
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "createCollection", "(", "MappingContext", "<", "?", ",", "Collection", "<", "T", ">", ">", "context", ")", "{", "if", "(", "context", ".", "getDestinationType", "(", ")", ".", "isInterface"...
Creates a collection based on the destination type. <ul> <li>Creates {@code TreeSet} for {@code SortedSet}</li> <li>Creates {@code HashSet} for {@code Set}</li> <li>Creates {@code ArrayList} for {@code List}</li> </ul> @param context the mapping context @param <T> the element type of the collection @return an empty c...
[ "Creates", "a", "collection", "based", "on", "the", "destination", "type", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/util/MappingContextHelper.java#L38-L47
62,693
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/Errors.java
Errors.format
public static String format(String heading, Collection<ErrorMessage> errorMessages) { @SuppressWarnings("resource") Formatter fmt = new Formatter().format(heading).format(":%n%n"); int index = 1; boolean displayCauses = getOnlyCause(errorMessages) == null; for (ErrorMessage errorMessage : err...
java
public static String format(String heading, Collection<ErrorMessage> errorMessages) { @SuppressWarnings("resource") Formatter fmt = new Formatter().format(heading).format(":%n%n"); int index = 1; boolean displayCauses = getOnlyCause(errorMessages) == null; for (ErrorMessage errorMessage : err...
[ "public", "static", "String", "format", "(", "String", "heading", ",", "Collection", "<", "ErrorMessage", ">", "errorMessages", ")", "{", "@", "SuppressWarnings", "(", "\"resource\"", ")", "Formatter", "fmt", "=", "new", "Formatter", "(", ")", ".", "format", ...
Returns the formatted message for an exception with the specified messages.
[ "Returns", "the", "formatted", "message", "for", "an", "exception", "with", "the", "specified", "messages", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/Errors.java#L93-L118
62,694
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/TypeInfoImpl.java
TypeInfoImpl.getAccessors
public Map<String, Accessor> getAccessors() { if (accessors == null) synchronized (this) { if (accessors == null) accessors = PropertyInfoSetResolver.resolveAccessors(source, type, configuration); } return accessors; }
java
public Map<String, Accessor> getAccessors() { if (accessors == null) synchronized (this) { if (accessors == null) accessors = PropertyInfoSetResolver.resolveAccessors(source, type, configuration); } return accessors; }
[ "public", "Map", "<", "String", ",", "Accessor", ">", "getAccessors", "(", ")", "{", "if", "(", "accessors", "==", "null", ")", "synchronized", "(", "this", ")", "{", "if", "(", "accessors", "==", "null", ")", "accessors", "=", "PropertyInfoSetResolver", ...
Lazily initializes and gets accessors.
[ "Lazily", "initializes", "and", "gets", "accessors", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/TypeInfoImpl.java#L55-L63
62,695
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/TypeInfoImpl.java
TypeInfoImpl.getMutators
public Map<String, Mutator> getMutators() { if (mutators == null) synchronized (this) { if (mutators == null) mutators = PropertyInfoSetResolver.resolveMutators(type, configuration); } return mutators; }
java
public Map<String, Mutator> getMutators() { if (mutators == null) synchronized (this) { if (mutators == null) mutators = PropertyInfoSetResolver.resolveMutators(type, configuration); } return mutators; }
[ "public", "Map", "<", "String", ",", "Mutator", ">", "getMutators", "(", ")", "{", "if", "(", "mutators", "==", "null", ")", "synchronized", "(", "this", ")", "{", "if", "(", "mutators", "==", "null", ")", "mutators", "=", "PropertyInfoSetResolver", ".",...
Lazily initializes and gets mutators.
[ "Lazily", "initializes", "and", "gets", "mutators", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/TypeInfoImpl.java#L72-L80
62,696
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java
PropertyInfoRegistry.accessorFor
static synchronized Accessor accessorFor(Class<?> type, Method method, Configuration configuration, String name) { PropertyInfoKey key = new PropertyInfoKey(type, name, configuration); Accessor accessor = ACCESSOR_CACHE.get(key); if (accessor == null) { accessor = new MethodAccessor(type, m...
java
static synchronized Accessor accessorFor(Class<?> type, Method method, Configuration configuration, String name) { PropertyInfoKey key = new PropertyInfoKey(type, name, configuration); Accessor accessor = ACCESSOR_CACHE.get(key); if (accessor == null) { accessor = new MethodAccessor(type, m...
[ "static", "synchronized", "Accessor", "accessorFor", "(", "Class", "<", "?", ">", "type", ",", "Method", "method", ",", "Configuration", "configuration", ",", "String", "name", ")", "{", "PropertyInfoKey", "key", "=", "new", "PropertyInfoKey", "(", "type", ","...
Returns an Accessor for the given accessor method. The method must be externally validated to ensure that it accepts zero arguments and does not return void.class.
[ "Returns", "an", "Accessor", "for", "the", "given", "accessor", "method", ".", "The", "method", "must", "be", "externally", "validated", "to", "ensure", "that", "it", "accepts", "zero", "arguments", "and", "does", "not", "return", "void", ".", "class", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java#L98-L108
62,697
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java
PropertyInfoRegistry.fieldPropertyFor
static synchronized FieldPropertyInfo fieldPropertyFor(Class<?> type, Field field, Configuration configuration, String name) { PropertyInfoKey key = new PropertyInfoKey(type, name, configuration); FieldPropertyInfo fieldPropertyInfo = FIELD_CACHE.get(key); if (fieldPropertyInfo == null) { f...
java
static synchronized FieldPropertyInfo fieldPropertyFor(Class<?> type, Field field, Configuration configuration, String name) { PropertyInfoKey key = new PropertyInfoKey(type, name, configuration); FieldPropertyInfo fieldPropertyInfo = FIELD_CACHE.get(key); if (fieldPropertyInfo == null) { f...
[ "static", "synchronized", "FieldPropertyInfo", "fieldPropertyFor", "(", "Class", "<", "?", ">", "type", ",", "Field", "field", ",", "Configuration", "configuration", ",", "String", "name", ")", "{", "PropertyInfoKey", "key", "=", "new", "PropertyInfoKey", "(", "...
Returns a FieldPropertyInfo instance for the given field.
[ "Returns", "a", "FieldPropertyInfo", "instance", "for", "the", "given", "field", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java#L113-L123
62,698
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java
PropertyInfoRegistry.mutatorFor
static synchronized Mutator mutatorFor(Class<?> type, Method method, Configuration configuration, String name) { PropertyInfoKey key = new PropertyInfoKey(type, name, configuration); Mutator mutator = MUTATOR_CACHE.get(key); if (mutator == null) { mutator = new MethodMutator(type, method, n...
java
static synchronized Mutator mutatorFor(Class<?> type, Method method, Configuration configuration, String name) { PropertyInfoKey key = new PropertyInfoKey(type, name, configuration); Mutator mutator = MUTATOR_CACHE.get(key); if (mutator == null) { mutator = new MethodMutator(type, method, n...
[ "static", "synchronized", "Mutator", "mutatorFor", "(", "Class", "<", "?", ">", "type", ",", "Method", "method", ",", "Configuration", "configuration", ",", "String", "name", ")", "{", "PropertyInfoKey", "key", "=", "new", "PropertyInfoKey", "(", "type", ",", ...
Returns a Mutator instance for the given mutator method. The method must be externally validated to ensure that it accepts one argument and returns void.class.
[ "Returns", "a", "Mutator", "instance", "for", "the", "given", "mutator", "method", ".", "The", "method", "must", "be", "externally", "validated", "to", "ensure", "that", "it", "accepts", "one", "argument", "and", "returns", "void", ".", "class", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java#L152-L162
62,699
modelmapper/modelmapper
core/src/main/java/org/modelmapper/internal/util/Iterables.java
Iterables.getLength
@SuppressWarnings("unchecked") public static int getLength(Object iterable) { Assert.state(isIterable(iterable.getClass())); return iterable.getClass().isArray() ? Array.getLength(iterable) : ((Collection<Object>) iterable).size(); }
java
@SuppressWarnings("unchecked") public static int getLength(Object iterable) { Assert.state(isIterable(iterable.getClass())); return iterable.getClass().isArray() ? Array.getLength(iterable) : ((Collection<Object>) iterable).size(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "int", "getLength", "(", "Object", "iterable", ")", "{", "Assert", ".", "state", "(", "isIterable", "(", "iterable", ".", "getClass", "(", ")", ")", ")", ";", "return", "iterable", "."...
Gets the length of an iterable. @param iterable the iterable @return the length of the iterable
[ "Gets", "the", "length", "of", "an", "iterable", "." ]
491d165ded9dc9aba7ce8b56984249e1a1363204
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/util/Iterables.java#L47-L51