repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.getDirectoryname
public static String getDirectoryname(final String pPath, final char pSeparator) { int index = pPath.lastIndexOf(pSeparator); if (index < 0) { return ""; // Assume only filename } return pPath.substring(0, index); }
java
public static String getDirectoryname(final String pPath, final char pSeparator) { int index = pPath.lastIndexOf(pSeparator); if (index < 0) { return ""; // Assume only filename } return pPath.substring(0, index); }
[ "public", "static", "String", "getDirectoryname", "(", "final", "String", "pPath", ",", "final", "char", "pSeparator", ")", "{", "int", "index", "=", "pPath", ".", "lastIndexOf", "(", "pSeparator", ")", ";", "if", "(", "index", "<", "0", ")", "{", "retur...
Extracts the directory path without the filename, from a complete filename path. @param pPath The full filename path. @param pSeparator the separator char used in {@code pPath} @return the path without the filename. @see File#getParent @see #getFilename
[ "Extracts", "the", "directory", "path", "without", "the", "filename", "from", "a", "complete", "filename", "path", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L436-L443
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.getFilename
public static String getFilename(final String pPath, final char pSeparator) { int index = pPath.lastIndexOf(pSeparator); if (index < 0) { return pPath; // Assume only filename } return pPath.substring(index + 1); }
java
public static String getFilename(final String pPath, final char pSeparator) { int index = pPath.lastIndexOf(pSeparator); if (index < 0) { return pPath; // Assume only filename } return pPath.substring(index + 1); }
[ "public", "static", "String", "getFilename", "(", "final", "String", "pPath", ",", "final", "char", "pSeparator", ")", "{", "int", "index", "=", "pPath", ".", "lastIndexOf", "(", "pSeparator", ")", ";", "if", "(", "index", "<", "0", ")", "{", "return", ...
Extracts the filename of a complete filename path. @param pPath The full filename path. @param pSeparator The file separator. @return the extracted filename. @see File#getName @see #getDirectoryname
[ "Extracts", "the", "filename", "of", "a", "complete", "filename", "path", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L466-L474
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.isEmpty
public static boolean isEmpty(File pFile) { if (pFile.isDirectory()) { return (pFile.list().length == 0); } return (pFile.length() == 0); }
java
public static boolean isEmpty(File pFile) { if (pFile.isDirectory()) { return (pFile.list().length == 0); } return (pFile.length() == 0); }
[ "public", "static", "boolean", "isEmpty", "(", "File", "pFile", ")", "{", "if", "(", "pFile", ".", "isDirectory", "(", ")", ")", "{", "return", "(", "pFile", ".", "list", "(", ")", ".", "length", "==", "0", ")", ";", "}", "return", "(", "pFile", ...
Tests if a file or directory has no content. A file is empty if it has a length of 0L. A non-existing file is also considered empty. A directory is considered empty if it contains no files. @param pFile The file to test @return {@code true} if the file is empty, otherwise {@code false}.
[ "Tests", "if", "a", "file", "or", "directory", "has", "no", "content", ".", "A", "file", "is", "empty", "if", "it", "has", "a", "length", "of", "0L", ".", "A", "non", "-", "existing", "file", "is", "also", "considered", "empty", ".", "A", "directory"...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L487-L492
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.getTempDir
public static String getTempDir() { synchronized (FileUtil.class) { if (TEMP_DIR == null) { // Get the 'java.io.tmpdir' property String tmpDir = System.getProperty("java.io.tmpdir"); if (StringUtil.isEmpty(tmpDir)) { // Stupid fallback... // TODO: Delegate to FileSystem? if (new File("/temp").exists()) { tmpDir = "/temp"; // Windows } else { tmpDir = "/tmp"; // Unix } } TEMP_DIR = tmpDir; } } return TEMP_DIR; }
java
public static String getTempDir() { synchronized (FileUtil.class) { if (TEMP_DIR == null) { // Get the 'java.io.tmpdir' property String tmpDir = System.getProperty("java.io.tmpdir"); if (StringUtil.isEmpty(tmpDir)) { // Stupid fallback... // TODO: Delegate to FileSystem? if (new File("/temp").exists()) { tmpDir = "/temp"; // Windows } else { tmpDir = "/tmp"; // Unix } } TEMP_DIR = tmpDir; } } return TEMP_DIR; }
[ "public", "static", "String", "getTempDir", "(", ")", "{", "synchronized", "(", "FileUtil", ".", "class", ")", "{", "if", "(", "TEMP_DIR", "==", "null", ")", "{", "// Get the 'java.io.tmpdir' property\r", "String", "tmpDir", "=", "System", ".", "getProperty", ...
Gets the default temp directory for the system. @return a {@code String}, representing the path to the default temp directory. @see File#createTempFile
[ "Gets", "the", "default", "temp", "directory", "for", "the", "system", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L511-L531
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.read
public static byte[] read(File pFile) throws IOException { // Custom implementation, as we know the size of a file if (!pFile.exists()) { throw new FileNotFoundException(pFile.toString()); } byte[] bytes = new byte[(int) pFile.length()]; InputStream in = null; try { // Use buffer size two times byte array, to avoid i/o bottleneck in = new BufferedInputStream(new FileInputStream(pFile), BUF_SIZE * 2); int off = 0; int len; while ((len = in.read(bytes, off, in.available())) != -1 && (off < bytes.length)) { off += len; // System.out.println("read:" + len); } } // Just pass any IOException on up the stack finally { close(in); } return bytes; }
java
public static byte[] read(File pFile) throws IOException { // Custom implementation, as we know the size of a file if (!pFile.exists()) { throw new FileNotFoundException(pFile.toString()); } byte[] bytes = new byte[(int) pFile.length()]; InputStream in = null; try { // Use buffer size two times byte array, to avoid i/o bottleneck in = new BufferedInputStream(new FileInputStream(pFile), BUF_SIZE * 2); int off = 0; int len; while ((len = in.read(bytes, off, in.available())) != -1 && (off < bytes.length)) { off += len; // System.out.println("read:" + len); } } // Just pass any IOException on up the stack finally { close(in); } return bytes; }
[ "public", "static", "byte", "[", "]", "read", "(", "File", "pFile", ")", "throws", "IOException", "{", "// Custom implementation, as we know the size of a file\r", "if", "(", "!", "pFile", ".", "exists", "(", ")", ")", "{", "throw", "new", "FileNotFoundException",...
Gets the contents of the given file, as a byte array. @param pFile the file to get content from @return the content of the file as a byte array. @throws IOException if the read operation fails
[ "Gets", "the", "contents", "of", "the", "given", "file", "as", "a", "byte", "array", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L551-L577
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.read
public static byte[] read(InputStream pInput) throws IOException { // Create byte array ByteArrayOutputStream bytes = new FastByteArrayOutputStream(BUF_SIZE); // Copy from stream to byte array copy(pInput, bytes); return bytes.toByteArray(); }
java
public static byte[] read(InputStream pInput) throws IOException { // Create byte array ByteArrayOutputStream bytes = new FastByteArrayOutputStream(BUF_SIZE); // Copy from stream to byte array copy(pInput, bytes); return bytes.toByteArray(); }
[ "public", "static", "byte", "[", "]", "read", "(", "InputStream", "pInput", ")", "throws", "IOException", "{", "// Create byte array\r", "ByteArrayOutputStream", "bytes", "=", "new", "FastByteArrayOutputStream", "(", "BUF_SIZE", ")", ";", "// Copy from stream to byte ar...
Reads all data from the input stream to a byte array. @param pInput The input stream to read from @return The content of the stream as a byte array. @throws IOException if an i/o error occurs during read.
[ "Reads", "all", "data", "from", "the", "input", "stream", "to", "a", "byte", "array", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L586-L594
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.write
public static boolean write(File pFile, byte[] pData) throws IOException { boolean success = false; OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(pFile)); success = write(out, pData); } finally { close(out); } return success; }
java
public static boolean write(File pFile, byte[] pData) throws IOException { boolean success = false; OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(pFile)); success = write(out, pData); } finally { close(out); } return success; }
[ "public", "static", "boolean", "write", "(", "File", "pFile", ",", "byte", "[", "]", "pData", ")", "throws", "IOException", "{", "boolean", "success", "=", "false", ";", "OutputStream", "out", "=", "null", ";", "try", "{", "out", "=", "new", "BufferedOut...
Writes the contents from a byte array to a file. @param pFile The file to write to @param pData The byte array to write @return {@code true}, otherwise an IOException is thrown. @throws IOException if an i/o error occurs during write.
[ "Writes", "the", "contents", "from", "a", "byte", "array", "to", "a", "file", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L620-L632
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java
FileUtil.delete
public static boolean delete(final File pFile, final boolean pForce) throws IOException { if (pForce && pFile.isDirectory()) { return deleteDir(pFile); } return pFile.exists() && pFile.delete(); }
java
public static boolean delete(final File pFile, final boolean pForce) throws IOException { if (pForce && pFile.isDirectory()) { return deleteDir(pFile); } return pFile.exists() && pFile.delete(); }
[ "public", "static", "boolean", "delete", "(", "final", "File", "pFile", ",", "final", "boolean", "pForce", ")", "throws", "IOException", "{", "if", "(", "pForce", "&&", "pFile", ".", "isDirectory", "(", ")", ")", "{", "return", "deleteDir", "(", "pFile", ...
Deletes the specified file. @param pFile The file to delete @param pForce Forces delete, even if the parameter is a directory, and is not empty. Be careful! @return {@code true}, if the file existed and was deleted. @throws IOException if an i/o error occurs during delete.
[ "Deletes", "the", "specified", "file", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/FileUtil.java#L655-L660
train
haraldk/TwelveMonkeys
imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/KCMSSanitizerStrategy.java
KCMSSanitizerStrategy.fixProfileXYZTag
private static boolean fixProfileXYZTag(final ICC_Profile profile, final int tagSignature) { byte[] data = profile.getData(tagSignature); // The CMM expects 0x64 65 73 63 ('XYZ ') but is 0x17 A5 05 B8..? if (data != null && intFromBigEndian(data, 0) == CORBIS_RGB_ALTERNATE_XYZ) { intToBigEndian(ICC_Profile.icSigXYZData, data, 0); profile.setData(tagSignature, data); return true; } return false; }
java
private static boolean fixProfileXYZTag(final ICC_Profile profile, final int tagSignature) { byte[] data = profile.getData(tagSignature); // The CMM expects 0x64 65 73 63 ('XYZ ') but is 0x17 A5 05 B8..? if (data != null && intFromBigEndian(data, 0) == CORBIS_RGB_ALTERNATE_XYZ) { intToBigEndian(ICC_Profile.icSigXYZData, data, 0); profile.setData(tagSignature, data); return true; } return false; }
[ "private", "static", "boolean", "fixProfileXYZTag", "(", "final", "ICC_Profile", "profile", ",", "final", "int", "tagSignature", ")", "{", "byte", "[", "]", "data", "=", "profile", ".", "getData", "(", "tagSignature", ")", ";", "// The CMM expects 0x64 65 73 63 ('...
Fixes problematic 'XYZ ' tags in Corbis RGB profile. @return {@code true} if found and fixed, otherwise {@code false} for short-circuiting to avoid unnecessary array copying.
[ "Fixes", "problematic", "XYZ", "tags", "in", "Corbis", "RGB", "profile", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/KCMSSanitizerStrategy.java#L81-L93
train
haraldk/TwelveMonkeys
imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/YCbCrConverter.java
YCbCrConverter.buildYCCtoRGBtable
private static void buildYCCtoRGBtable() { if (ColorSpaces.DEBUG) { System.err.println("Building YCC conversion table"); } for (int i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { // i is the actual input pixel value, in the range 0..MAXJSAMPLE // The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE // Cr=>R value is nearest int to 1.40200 * x Cr_R_LUT[i] = (int) ((1.40200 * (1 << SCALEBITS) + 0.5) * x + ONE_HALF) >> SCALEBITS; // Cb=>B value is nearest int to 1.77200 * x Cb_B_LUT[i] = (int) ((1.77200 * (1 << SCALEBITS) + 0.5) * x + ONE_HALF) >> SCALEBITS; // Cr=>G value is scaled-up -0.71414 * x Cr_G_LUT[i] = -(int) (0.71414 * (1 << SCALEBITS) + 0.5) * x; // Cb=>G value is scaled-up -0.34414 * x // We also add in ONE_HALF so that need not do it in inner loop Cb_G_LUT[i] = -(int) ((0.34414) * (1 << SCALEBITS) + 0.5) * x + ONE_HALF; } }
java
private static void buildYCCtoRGBtable() { if (ColorSpaces.DEBUG) { System.err.println("Building YCC conversion table"); } for (int i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { // i is the actual input pixel value, in the range 0..MAXJSAMPLE // The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE // Cr=>R value is nearest int to 1.40200 * x Cr_R_LUT[i] = (int) ((1.40200 * (1 << SCALEBITS) + 0.5) * x + ONE_HALF) >> SCALEBITS; // Cb=>B value is nearest int to 1.77200 * x Cb_B_LUT[i] = (int) ((1.77200 * (1 << SCALEBITS) + 0.5) * x + ONE_HALF) >> SCALEBITS; // Cr=>G value is scaled-up -0.71414 * x Cr_G_LUT[i] = -(int) (0.71414 * (1 << SCALEBITS) + 0.5) * x; // Cb=>G value is scaled-up -0.34414 * x // We also add in ONE_HALF so that need not do it in inner loop Cb_G_LUT[i] = -(int) ((0.34414) * (1 << SCALEBITS) + 0.5) * x + ONE_HALF; } }
[ "private", "static", "void", "buildYCCtoRGBtable", "(", ")", "{", "if", "(", "ColorSpaces", ".", "DEBUG", ")", "{", "System", ".", "err", ".", "println", "(", "\"Building YCC conversion table\"", ")", ";", "}", "for", "(", "int", "i", "=", "0", ",", "x",...
Initializes tables for YCC->RGB color space conversion.
[ "Initializes", "tables", "for", "YCC", "-", ">", "RGB", "color", "space", "conversion", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/YCbCrConverter.java#L56-L74
train
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/droplet/taglib/OparamTag.java
OparamTag.getOparamCountFromRequest
private int getOparamCountFromRequest(HttpServletRequest pRequest) { // Use request.attribute for incrementing oparam counter Integer count = (Integer) pRequest.getAttribute(COUNTER); if (count == null) { count = new Integer(0); } else { count = new Integer(count.intValue() + 1); } // ... and set it back pRequest.setAttribute(COUNTER, count); return count.intValue(); }
java
private int getOparamCountFromRequest(HttpServletRequest pRequest) { // Use request.attribute for incrementing oparam counter Integer count = (Integer) pRequest.getAttribute(COUNTER); if (count == null) { count = new Integer(0); } else { count = new Integer(count.intValue() + 1); } // ... and set it back pRequest.setAttribute(COUNTER, count); return count.intValue(); }
[ "private", "int", "getOparamCountFromRequest", "(", "HttpServletRequest", "pRequest", ")", "{", "// Use request.attribute for incrementing oparam counter\r", "Integer", "count", "=", "(", "Integer", ")", "pRequest", ".", "getAttribute", "(", "COUNTER", ")", ";", "if", "...
Gets the current oparam count for this request
[ "Gets", "the", "current", "oparam", "count", "for", "this", "request" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/droplet/taglib/OparamTag.java#L205-L219
train
haraldk/TwelveMonkeys
common/common-image/src/main/java/com/twelvemonkeys/image/ResampleOp.java
ResampleOp.getFilterType
private static int getFilterType(RenderingHints pHints) { if (pHints == null) { return FILTER_UNDEFINED; } if (pHints.containsKey(KEY_RESAMPLE_INTERPOLATION)) { Object value = pHints.get(KEY_RESAMPLE_INTERPOLATION); // NOTE: Workaround for a bug in RenderingHints constructor (Bug id# 5084832) if (!KEY_RESAMPLE_INTERPOLATION.isCompatibleValue(value)) { throw new IllegalArgumentException(value + " incompatible with key " + KEY_RESAMPLE_INTERPOLATION); } return value != null ? ((Value) value).getFilterType() : FILTER_UNDEFINED; } else if (RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR.equals(pHints.get(RenderingHints.KEY_INTERPOLATION)) || (!pHints.containsKey(RenderingHints.KEY_INTERPOLATION) && (RenderingHints.VALUE_RENDER_SPEED.equals(pHints.get(RenderingHints.KEY_RENDERING)) || RenderingHints.VALUE_COLOR_RENDER_SPEED.equals(pHints.get(RenderingHints.KEY_COLOR_RENDERING))))) { // Nearest neighbour, or prioritize speed return FILTER_POINT; } else if (RenderingHints.VALUE_INTERPOLATION_BILINEAR.equals(pHints.get(RenderingHints.KEY_INTERPOLATION))) { // Triangle equals bi-linear interpolation return FILTER_TRIANGLE; } else if (RenderingHints.VALUE_INTERPOLATION_BICUBIC.equals(pHints.get(RenderingHints.KEY_INTERPOLATION))) { return FILTER_QUADRATIC;// No idea if this is correct..? } else if (RenderingHints.VALUE_RENDER_QUALITY.equals(pHints.get(RenderingHints.KEY_RENDERING)) || RenderingHints.VALUE_COLOR_RENDER_QUALITY.equals(pHints.get(RenderingHints.KEY_COLOR_RENDERING))) { // Prioritize quality return FILTER_MITCHELL; } // NOTE: Other hints are ignored return FILTER_UNDEFINED; }
java
private static int getFilterType(RenderingHints pHints) { if (pHints == null) { return FILTER_UNDEFINED; } if (pHints.containsKey(KEY_RESAMPLE_INTERPOLATION)) { Object value = pHints.get(KEY_RESAMPLE_INTERPOLATION); // NOTE: Workaround for a bug in RenderingHints constructor (Bug id# 5084832) if (!KEY_RESAMPLE_INTERPOLATION.isCompatibleValue(value)) { throw new IllegalArgumentException(value + " incompatible with key " + KEY_RESAMPLE_INTERPOLATION); } return value != null ? ((Value) value).getFilterType() : FILTER_UNDEFINED; } else if (RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR.equals(pHints.get(RenderingHints.KEY_INTERPOLATION)) || (!pHints.containsKey(RenderingHints.KEY_INTERPOLATION) && (RenderingHints.VALUE_RENDER_SPEED.equals(pHints.get(RenderingHints.KEY_RENDERING)) || RenderingHints.VALUE_COLOR_RENDER_SPEED.equals(pHints.get(RenderingHints.KEY_COLOR_RENDERING))))) { // Nearest neighbour, or prioritize speed return FILTER_POINT; } else if (RenderingHints.VALUE_INTERPOLATION_BILINEAR.equals(pHints.get(RenderingHints.KEY_INTERPOLATION))) { // Triangle equals bi-linear interpolation return FILTER_TRIANGLE; } else if (RenderingHints.VALUE_INTERPOLATION_BICUBIC.equals(pHints.get(RenderingHints.KEY_INTERPOLATION))) { return FILTER_QUADRATIC;// No idea if this is correct..? } else if (RenderingHints.VALUE_RENDER_QUALITY.equals(pHints.get(RenderingHints.KEY_RENDERING)) || RenderingHints.VALUE_COLOR_RENDER_QUALITY.equals(pHints.get(RenderingHints.KEY_COLOR_RENDERING))) { // Prioritize quality return FILTER_MITCHELL; } // NOTE: Other hints are ignored return FILTER_UNDEFINED; }
[ "private", "static", "int", "getFilterType", "(", "RenderingHints", "pHints", ")", "{", "if", "(", "pHints", "==", "null", ")", "{", "return", "FILTER_UNDEFINED", ";", "}", "if", "(", "pHints", ".", "containsKey", "(", "KEY_RESAMPLE_INTERPOLATION", ")", ")", ...
Gets the filter type specified by the given hints. @param pHints rendering hints @return a filter type constant
[ "Gets", "the", "filter", "type", "specified", "by", "the", "given", "hints", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/ResampleOp.java#L456-L491
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.getColumn
public String getColumn(String pProperty) { if (mPropertiesMap == null || pProperty == null) return null; return (String) mPropertiesMap.get(pProperty); }
java
public String getColumn(String pProperty) { if (mPropertiesMap == null || pProperty == null) return null; return (String) mPropertiesMap.get(pProperty); }
[ "public", "String", "getColumn", "(", "String", "pProperty", ")", "{", "if", "(", "mPropertiesMap", "==", "null", "||", "pProperty", "==", "null", ")", "return", "null", ";", "return", "(", "String", ")", "mPropertiesMap", ".", "get", "(", "pProperty", ")"...
Gets the column for a given property. @param property The property @return The name of the matching database column, on the form table.column
[ "Gets", "the", "column", "for", "a", "given", "property", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L264-L268
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.getTable
public String getTable(String pProperty) { String table = getColumn(pProperty); if (table != null) { int dotIdx = 0; if ((dotIdx = table.lastIndexOf(".")) >= 0) table = table.substring(0, dotIdx); else return null; } return table; }
java
public String getTable(String pProperty) { String table = getColumn(pProperty); if (table != null) { int dotIdx = 0; if ((dotIdx = table.lastIndexOf(".")) >= 0) table = table.substring(0, dotIdx); else return null; } return table; }
[ "public", "String", "getTable", "(", "String", "pProperty", ")", "{", "String", "table", "=", "getColumn", "(", "pProperty", ")", ";", "if", "(", "table", "!=", "null", ")", "{", "int", "dotIdx", "=", "0", ";", "if", "(", "(", "dotIdx", "=", "table",...
Gets the table name for a given property. @param property The property @return The name of the matching database table.
[ "Gets", "the", "table", "name", "for", "a", "given", "property", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L277-L289
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.getProperty
public String getProperty(String pColumn) { if (mColumnMap == null || pColumn == null) return null; String property = (String) mColumnMap.get(pColumn); int dotIdx = 0; if (property == null && (dotIdx = pColumn.lastIndexOf(".")) >= 0) property = (String) mColumnMap.get(pColumn.substring(dotIdx + 1)); return property; }
java
public String getProperty(String pColumn) { if (mColumnMap == null || pColumn == null) return null; String property = (String) mColumnMap.get(pColumn); int dotIdx = 0; if (property == null && (dotIdx = pColumn.lastIndexOf(".")) >= 0) property = (String) mColumnMap.get(pColumn.substring(dotIdx + 1)); return property; }
[ "public", "String", "getProperty", "(", "String", "pColumn", ")", "{", "if", "(", "mColumnMap", "==", "null", "||", "pColumn", "==", "null", ")", "return", "null", ";", "String", "property", "=", "(", "String", ")", "mColumnMap", ".", "get", "(", "pColum...
Gets the property for a given database column. If the column incudes table qualifier, the table qualifier is removed. @param column The name of the column @return The name of the mathcing property
[ "Gets", "the", "property", "for", "a", "given", "database", "column", ".", "If", "the", "column", "incudes", "table", "qualifier", "the", "table", "qualifier", "is", "removed", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L299-L310
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.mapObjects
public synchronized Object[] mapObjects(ResultSet pRSet) throws SQLException { Vector result = new Vector(); ResultSetMetaData meta = pRSet.getMetaData(); int cols = meta.getColumnCount(); // Get colum names String[] colNames = new String[cols]; for (int i = 0; i < cols; i++) { colNames[i] = meta.getColumnName(i + 1); // JDBC cols start at 1... /* System.out.println(meta.getColumnLabel(i + 1)); System.out.println(meta.getColumnName(i + 1)); System.out.println(meta.getColumnType(i + 1)); System.out.println(meta.getColumnTypeName(i + 1)); // System.out.println(meta.getTableName(i + 1)); // System.out.println(meta.getCatalogName(i + 1)); // System.out.println(meta.getSchemaName(i + 1)); // Last three NOT IMPLEMENTED!! */ } // Loop through rows in resultset while (pRSet.next()) { Object obj = null; try { obj = mInstanceClass.newInstance(); // Asserts empty constructor! } catch (IllegalAccessException iae) { mLog.logError(iae); // iae.printStackTrace(); } catch (InstantiationException ie) { mLog.logError(ie); // ie.printStackTrace(); } // Read each colum from this row into object for (int i = 0; i < cols; i++) { String property = (String) mColumnMap.get(colNames[i]); if (property != null) { // This column is mapped to a property mapColumnProperty(pRSet, i + 1, property, obj); } } // Add object to the result Vector result.addElement(obj); } return result.toArray((Object[]) Array.newInstance(mInstanceClass, result.size())); }
java
public synchronized Object[] mapObjects(ResultSet pRSet) throws SQLException { Vector result = new Vector(); ResultSetMetaData meta = pRSet.getMetaData(); int cols = meta.getColumnCount(); // Get colum names String[] colNames = new String[cols]; for (int i = 0; i < cols; i++) { colNames[i] = meta.getColumnName(i + 1); // JDBC cols start at 1... /* System.out.println(meta.getColumnLabel(i + 1)); System.out.println(meta.getColumnName(i + 1)); System.out.println(meta.getColumnType(i + 1)); System.out.println(meta.getColumnTypeName(i + 1)); // System.out.println(meta.getTableName(i + 1)); // System.out.println(meta.getCatalogName(i + 1)); // System.out.println(meta.getSchemaName(i + 1)); // Last three NOT IMPLEMENTED!! */ } // Loop through rows in resultset while (pRSet.next()) { Object obj = null; try { obj = mInstanceClass.newInstance(); // Asserts empty constructor! } catch (IllegalAccessException iae) { mLog.logError(iae); // iae.printStackTrace(); } catch (InstantiationException ie) { mLog.logError(ie); // ie.printStackTrace(); } // Read each colum from this row into object for (int i = 0; i < cols; i++) { String property = (String) mColumnMap.get(colNames[i]); if (property != null) { // This column is mapped to a property mapColumnProperty(pRSet, i + 1, property, obj); } } // Add object to the result Vector result.addElement(obj); } return result.toArray((Object[]) Array.newInstance(mInstanceClass, result.size())); }
[ "public", "synchronized", "Object", "[", "]", "mapObjects", "(", "ResultSet", "pRSet", ")", "throws", "SQLException", "{", "Vector", "result", "=", "new", "Vector", "(", ")", ";", "ResultSetMetaData", "meta", "=", "pRSet", ".", "getMetaData", "(", ")", ";", ...
Maps each row of the given result set to an object ot this OM's type. @param rs The ResultSet to process (map to objects) @return An array of objects (of this OM's class). If there are no rows in the ResultSet, an empty (zero-length) array will be returned.
[ "Maps", "each", "row", "of", "the", "given", "result", "set", "to", "an", "object", "ot", "this", "OM", "s", "type", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L321-L377
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.buildIdentitySQL
String buildIdentitySQL(String[] pKeys) { mTables = new Hashtable(); mColumns = new Vector(); // Get columns to select mColumns.addElement(getPrimaryKey()); // Get tables to select (and join) from and their joins tableJoins(null, false); for (int i = 0; i < pKeys.length; i++) { tableJoins(getColumn(pKeys[i]), true); } // All data read, build SQL query string return "SELECT " + getPrimaryKey() + " " + buildFromClause() + buildWhereClause(); }
java
String buildIdentitySQL(String[] pKeys) { mTables = new Hashtable(); mColumns = new Vector(); // Get columns to select mColumns.addElement(getPrimaryKey()); // Get tables to select (and join) from and their joins tableJoins(null, false); for (int i = 0; i < pKeys.length; i++) { tableJoins(getColumn(pKeys[i]), true); } // All data read, build SQL query string return "SELECT " + getPrimaryKey() + " " + buildFromClause() + buildWhereClause(); }
[ "String", "buildIdentitySQL", "(", "String", "[", "]", "pKeys", ")", "{", "mTables", "=", "new", "Hashtable", "(", ")", ";", "mColumns", "=", "new", "Vector", "(", ")", ";", "// Get columns to select\r", "mColumns", ".", "addElement", "(", "getPrimaryKey", "...
Creates a SQL query string to get the primary keys for this ObjectMapper.
[ "Creates", "a", "SQL", "query", "string", "to", "get", "the", "primary", "keys", "for", "this", "ObjectMapper", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L462-L479
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.buildSQL
public String buildSQL() { mTables = new Hashtable(); mColumns = new Vector(); String key = null; for (Enumeration keys = mPropertiesMap.keys(); keys.hasMoreElements();) { key = (String) keys.nextElement(); // Get columns to select String column = (String) mPropertiesMap.get(key); mColumns.addElement(column); tableJoins(column, false); } // All data read, build SQL query string return buildSelectClause() + buildFromClause() + buildWhereClause(); }
java
public String buildSQL() { mTables = new Hashtable(); mColumns = new Vector(); String key = null; for (Enumeration keys = mPropertiesMap.keys(); keys.hasMoreElements();) { key = (String) keys.nextElement(); // Get columns to select String column = (String) mPropertiesMap.get(key); mColumns.addElement(column); tableJoins(column, false); } // All data read, build SQL query string return buildSelectClause() + buildFromClause() + buildWhereClause(); }
[ "public", "String", "buildSQL", "(", ")", "{", "mTables", "=", "new", "Hashtable", "(", ")", ";", "mColumns", "=", "new", "Vector", "(", ")", ";", "String", "key", "=", "null", ";", "for", "(", "Enumeration", "keys", "=", "mPropertiesMap", ".", "keys",...
Creates a SQL query string to get objects for this ObjectMapper.
[ "Creates", "a", "SQL", "query", "string", "to", "get", "objects", "for", "this", "ObjectMapper", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L485-L503
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.buildSelectClause
private String buildSelectClause() { StringBuilder sqlBuf = new StringBuilder(); sqlBuf.append("SELECT "); String column = null; for (Enumeration select = mColumns.elements(); select.hasMoreElements();) { column = (String) select.nextElement(); /* String subColumn = column.substring(column.indexOf(".") + 1); // System.err.println("DEBUG: col=" + subColumn); String mapType = (String) mMapTypes.get(mColumnMap.get(subColumn)); */ String mapType = (String) mMapTypes.get(getProperty(column)); if (mapType == null || mapType.equals(DIRECTMAP)) { sqlBuf.append(column); sqlBuf.append(select.hasMoreElements() ? ", " : " "); } } return sqlBuf.toString(); }
java
private String buildSelectClause() { StringBuilder sqlBuf = new StringBuilder(); sqlBuf.append("SELECT "); String column = null; for (Enumeration select = mColumns.elements(); select.hasMoreElements();) { column = (String) select.nextElement(); /* String subColumn = column.substring(column.indexOf(".") + 1); // System.err.println("DEBUG: col=" + subColumn); String mapType = (String) mMapTypes.get(mColumnMap.get(subColumn)); */ String mapType = (String) mMapTypes.get(getProperty(column)); if (mapType == null || mapType.equals(DIRECTMAP)) { sqlBuf.append(column); sqlBuf.append(select.hasMoreElements() ? ", " : " "); } } return sqlBuf.toString(); }
[ "private", "String", "buildSelectClause", "(", ")", "{", "StringBuilder", "sqlBuf", "=", "new", "StringBuilder", "(", ")", ";", "sqlBuf", ".", "append", "(", "\"SELECT \"", ")", ";", "String", "column", "=", "null", ";", "for", "(", "Enumeration", "select", ...
Builds a SQL SELECT clause from the columns Vector
[ "Builds", "a", "SQL", "SELECT", "clause", "from", "the", "columns", "Vector" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L509-L533
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java
ObjectMapper.tableJoins
private void tableJoins(String pColumn, boolean pWhereJoin) { String join = null; String table = null; if (pColumn == null) { // Identity join = getIdentityJoin(); table = getTable(getProperty(getPrimaryKey())); } else { // Normal int dotIndex = -1; if ((dotIndex = pColumn.lastIndexOf(".")) <= 0) { // No table qualifier return; } // Get table qualifier. table = pColumn.substring(0, dotIndex); // Don't care about the tables that are not supposed to be selected from String property = (String) getProperty(pColumn); if (property != null) { String mapType = (String) mMapTypes.get(property); if (!pWhereJoin && mapType != null && !mapType.equals(DIRECTMAP)) { return; } join = (String) mJoins.get(property); } } // If table is not in the tables Hash, add it, and check for joins. if (mTables.get(table) == null) { if (join != null) { mTables.put(table, join); StringTokenizer tok = new StringTokenizer(join, "= "); String next = null; while(tok.hasMoreElements()) { next = tok.nextToken(); // Don't care about SQL keywords if (next.equals("AND") || next.equals("OR") || next.equals("NOT") || next.equals("IN")) { continue; } // Check for new tables and joins in this join clause. tableJoins(next, false); } } else { // No joins for this table. join = ""; mTables.put(table, join); } } }
java
private void tableJoins(String pColumn, boolean pWhereJoin) { String join = null; String table = null; if (pColumn == null) { // Identity join = getIdentityJoin(); table = getTable(getProperty(getPrimaryKey())); } else { // Normal int dotIndex = -1; if ((dotIndex = pColumn.lastIndexOf(".")) <= 0) { // No table qualifier return; } // Get table qualifier. table = pColumn.substring(0, dotIndex); // Don't care about the tables that are not supposed to be selected from String property = (String) getProperty(pColumn); if (property != null) { String mapType = (String) mMapTypes.get(property); if (!pWhereJoin && mapType != null && !mapType.equals(DIRECTMAP)) { return; } join = (String) mJoins.get(property); } } // If table is not in the tables Hash, add it, and check for joins. if (mTables.get(table) == null) { if (join != null) { mTables.put(table, join); StringTokenizer tok = new StringTokenizer(join, "= "); String next = null; while(tok.hasMoreElements()) { next = tok.nextToken(); // Don't care about SQL keywords if (next.equals("AND") || next.equals("OR") || next.equals("NOT") || next.equals("IN")) { continue; } // Check for new tables and joins in this join clause. tableJoins(next, false); } } else { // No joins for this table. join = ""; mTables.put(table, join); } } }
[ "private", "void", "tableJoins", "(", "String", "pColumn", ",", "boolean", "pWhereJoin", ")", "{", "String", "join", "=", "null", ";", "String", "table", "=", "null", ";", "if", "(", "pColumn", "==", "null", ")", "{", "// Identity\r", "join", "=", "getId...
Finds tables used in mappings and joins and adds them to the tables Hashtable, with the table name as key, and the join as value.
[ "Finds", "tables", "used", "in", "mappings", "and", "joins", "and", "adds", "them", "to", "the", "tables", "Hashtable", "with", "the", "table", "name", "as", "key", "and", "the", "join", "as", "value", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/sql/ObjectMapper.java#L603-L661
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/SeekableOutputStream.java
SeekableOutputStream.seek
public final void seek(long pPosition) throws IOException { checkOpen(); // TODO: This is correct according to javax.imageio (IndexOutOfBoundsException), // but it's inconsistent with reset that throws IOException... if (pPosition < flushedPosition) { throw new IndexOutOfBoundsException("position < flushedPosition!"); } seekImpl(pPosition); position = pPosition; }
java
public final void seek(long pPosition) throws IOException { checkOpen(); // TODO: This is correct according to javax.imageio (IndexOutOfBoundsException), // but it's inconsistent with reset that throws IOException... if (pPosition < flushedPosition) { throw new IndexOutOfBoundsException("position < flushedPosition!"); } seekImpl(pPosition); position = pPosition; }
[ "public", "final", "void", "seek", "(", "long", "pPosition", ")", "throws", "IOException", "{", "checkOpen", "(", ")", ";", "// TODO: This is correct according to javax.imageio (IndexOutOfBoundsException),\r", "// but it's inconsistent with reset that throws IOException...\r", "if"...
probably a good idea to extract a delegate..?
[ "probably", "a", "good", "idea", "to", "extract", "a", "delegate", "..", "?" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/SeekableOutputStream.java#L63-L74
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java
MIMEUtil.getMIMEType
public static String getMIMEType(final String pFileExt) { List<String> types = sExtToMIME.get(StringUtil.toLowerCase(pFileExt)); return (types == null || types.isEmpty()) ? null : types.get(0); }
java
public static String getMIMEType(final String pFileExt) { List<String> types = sExtToMIME.get(StringUtil.toLowerCase(pFileExt)); return (types == null || types.isEmpty()) ? null : types.get(0); }
[ "public", "static", "String", "getMIMEType", "(", "final", "String", "pFileExt", ")", "{", "List", "<", "String", ">", "types", "=", "sExtToMIME", ".", "get", "(", "StringUtil", ".", "toLowerCase", "(", "pFileExt", ")", ")", ";", "return", "(", "types", ...
Returns the default MIME type for the given file extension. @param pFileExt the file extension @return a {@code String} containing the MIME type, or {@code null} if there are no known MIME types for the given file extension.
[ "Returns", "the", "default", "MIME", "type", "for", "the", "given", "file", "extension", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java#L109-L112
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java
MIMEUtil.getMIMETypes
public static List<String> getMIMETypes(final String pFileExt) { List<String> types = sExtToMIME.get(StringUtil.toLowerCase(pFileExt)); return maskNull(types); }
java
public static List<String> getMIMETypes(final String pFileExt) { List<String> types = sExtToMIME.get(StringUtil.toLowerCase(pFileExt)); return maskNull(types); }
[ "public", "static", "List", "<", "String", ">", "getMIMETypes", "(", "final", "String", "pFileExt", ")", "{", "List", "<", "String", ">", "types", "=", "sExtToMIME", ".", "get", "(", "StringUtil", ".", "toLowerCase", "(", "pFileExt", ")", ")", ";", "retu...
Returns all MIME types for the given file extension. @param pFileExt the file extension @return a {@link List} of {@code String}s containing the MIME types, or an empty list, if there are no known MIME types for the given file extension.
[ "Returns", "all", "MIME", "types", "for", "the", "given", "file", "extension", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java#L122-L125
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java
MIMEUtil.getExtensionForWildcard
private static List<String> getExtensionForWildcard(final String pMIME) { final String family = pMIME.substring(0, pMIME.length() - 1); Set<String> extensions = new LinkedHashSet<String>(); for (Map.Entry<String, List<String>> mimeToExt : sMIMEToExt.entrySet()) { if ("*/".equals(family) || mimeToExt.getKey().startsWith(family)) { extensions.addAll(mimeToExt.getValue()); } } return Collections.unmodifiableList(new ArrayList<String>(extensions)); }
java
private static List<String> getExtensionForWildcard(final String pMIME) { final String family = pMIME.substring(0, pMIME.length() - 1); Set<String> extensions = new LinkedHashSet<String>(); for (Map.Entry<String, List<String>> mimeToExt : sMIMEToExt.entrySet()) { if ("*/".equals(family) || mimeToExt.getKey().startsWith(family)) { extensions.addAll(mimeToExt.getValue()); } } return Collections.unmodifiableList(new ArrayList<String>(extensions)); }
[ "private", "static", "List", "<", "String", ">", "getExtensionForWildcard", "(", "final", "String", "pMIME", ")", "{", "final", "String", "family", "=", "pMIME", ".", "substring", "(", "0", ",", "pMIME", ".", "length", "(", ")", "-", "1", ")", ";", "Se...
Gets all extensions for a wildcard MIME type
[ "Gets", "all", "extensions", "for", "a", "wildcard", "MIME", "type" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java#L173-L182
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java
MIMEUtil.maskNull
private static List<String> maskNull(List<String> pTypes) { return (pTypes == null) ? Collections.<String>emptyList() : pTypes; }
java
private static List<String> maskNull(List<String> pTypes) { return (pTypes == null) ? Collections.<String>emptyList() : pTypes; }
[ "private", "static", "List", "<", "String", ">", "maskNull", "(", "List", "<", "String", ">", "pTypes", ")", "{", "return", "(", "pTypes", "==", "null", ")", "?", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ":", "pTypes", ";", "}" ...
Returns the list or empty list if list is null
[ "Returns", "the", "list", "or", "empty", "list", "if", "list", "is", "null" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/net/MIMEUtil.java#L230-L232
train
haraldk/TwelveMonkeys
imageio/imageio-pcx/src/main/java/com/twelvemonkeys/imageio/plugins/pcx/RLEDecoder.java
RLEDecoder.decode
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException { while (buffer.remaining() >= 64) { int val = stream.read(); if (val < 0) { break; // EOF } if ((val & COMPRESSED_RUN_MASK) == COMPRESSED_RUN_MASK) { int count = val & ~COMPRESSED_RUN_MASK; int pixel = stream.read(); if (pixel < 0) { break; // EOF } for (int i = 0; i < count; i++) { buffer.put((byte) pixel); } } else { buffer.put((byte) val); } } return buffer.position(); }
java
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException { while (buffer.remaining() >= 64) { int val = stream.read(); if (val < 0) { break; // EOF } if ((val & COMPRESSED_RUN_MASK) == COMPRESSED_RUN_MASK) { int count = val & ~COMPRESSED_RUN_MASK; int pixel = stream.read(); if (pixel < 0) { break; // EOF } for (int i = 0; i < count; i++) { buffer.put((byte) pixel); } } else { buffer.put((byte) val); } } return buffer.position(); }
[ "public", "int", "decode", "(", "final", "InputStream", "stream", ",", "final", "ByteBuffer", "buffer", ")", "throws", "IOException", "{", "while", "(", "buffer", ".", "remaining", "(", ")", ">=", "64", ")", "{", "int", "val", "=", "stream", ".", "read",...
even if this will make the output larger.
[ "even", "if", "this", "will", "make", "the", "output", "larger", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pcx/src/main/java/com/twelvemonkeys/imageio/plugins/pcx/RLEDecoder.java#L47-L72
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/regex/REWildcardStringParser.java
REWildcardStringParser.buildRegexpParser
private boolean buildRegexpParser() { // Convert wildcard string mask to regular expression String regexp = convertWildcardExpressionToRegularExpression(mStringMask); if (regexp == null) { out.println(DebugUtil.getPrefixErrorMessage(this) + "irregularity in regexp conversion - now not able to parse any strings, all strings will be rejected!"); return false; } // Instantiate a regular expression parser try { mRegexpParser = Pattern.compile(regexp); } catch (PatternSyntaxException e) { if (mDebugging) { out.println(DebugUtil.getPrefixErrorMessage(this) + "RESyntaxException \"" + e.getMessage() + "\" caught - now not able to parse any strings, all strings will be rejected!"); } if (mDebugging) { e.printStackTrace(System.err); } return false; } if (mDebugging) { out.println(DebugUtil.getPrefixDebugMessage(this) + "regular expression parser from regular expression " + regexp + " extracted from wildcard string mask " + mStringMask + "."); } return true; }
java
private boolean buildRegexpParser() { // Convert wildcard string mask to regular expression String regexp = convertWildcardExpressionToRegularExpression(mStringMask); if (regexp == null) { out.println(DebugUtil.getPrefixErrorMessage(this) + "irregularity in regexp conversion - now not able to parse any strings, all strings will be rejected!"); return false; } // Instantiate a regular expression parser try { mRegexpParser = Pattern.compile(regexp); } catch (PatternSyntaxException e) { if (mDebugging) { out.println(DebugUtil.getPrefixErrorMessage(this) + "RESyntaxException \"" + e.getMessage() + "\" caught - now not able to parse any strings, all strings will be rejected!"); } if (mDebugging) { e.printStackTrace(System.err); } return false; } if (mDebugging) { out.println(DebugUtil.getPrefixDebugMessage(this) + "regular expression parser from regular expression " + regexp + " extracted from wildcard string mask " + mStringMask + "."); } return true; }
[ "private", "boolean", "buildRegexpParser", "(", ")", "{", "// Convert wildcard string mask to regular expression\r", "String", "regexp", "=", "convertWildcardExpressionToRegularExpression", "(", "mStringMask", ")", ";", "if", "(", "regexp", "==", "null", ")", "{", "out", ...
Builds the regexp parser.
[ "Builds", "the", "regexp", "parser", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/regex/REWildcardStringParser.java#L196-L226
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/regex/REWildcardStringParser.java
REWildcardStringParser.checkStringToBeParsed
private boolean checkStringToBeParsed(final String pStringToBeParsed) { // Check for nullness if (pStringToBeParsed == null) { if (mDebugging) { out.println(DebugUtil.getPrefixDebugMessage(this) + "string to be parsed is null - rejection!"); } return false; } // Check if valid character (element in alphabet) for (int i = 0; i < pStringToBeParsed.length(); i++) { if (!isInAlphabet(pStringToBeParsed.charAt(i))) { if (mDebugging) { out.println(DebugUtil.getPrefixDebugMessage(this) + "one or more characters in string to be parsed are not legal characters - rejection!"); } return false; } } return true; }
java
private boolean checkStringToBeParsed(final String pStringToBeParsed) { // Check for nullness if (pStringToBeParsed == null) { if (mDebugging) { out.println(DebugUtil.getPrefixDebugMessage(this) + "string to be parsed is null - rejection!"); } return false; } // Check if valid character (element in alphabet) for (int i = 0; i < pStringToBeParsed.length(); i++) { if (!isInAlphabet(pStringToBeParsed.charAt(i))) { if (mDebugging) { out.println(DebugUtil.getPrefixDebugMessage(this) + "one or more characters in string to be parsed are not legal characters - rejection!"); } return false; } } return true; }
[ "private", "boolean", "checkStringToBeParsed", "(", "final", "String", "pStringToBeParsed", ")", "{", "// Check for nullness\r", "if", "(", "pStringToBeParsed", "==", "null", ")", "{", "if", "(", "mDebugging", ")", "{", "out", ".", "println", "(", "DebugUtil", "...
Simple check of the string to be parsed.
[ "Simple", "check", "of", "the", "string", "to", "be", "parsed", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/regex/REWildcardStringParser.java#L231-L252
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/regex/REWildcardStringParser.java
REWildcardStringParser.isInAlphabet
public static boolean isInAlphabet(final char pCharToCheck) { for (int i = 0; i < ALPHABET.length; i++) { if (pCharToCheck == ALPHABET[i]) { return true; } } return false; }
java
public static boolean isInAlphabet(final char pCharToCheck) { for (int i = 0; i < ALPHABET.length; i++) { if (pCharToCheck == ALPHABET[i]) { return true; } } return false; }
[ "public", "static", "boolean", "isInAlphabet", "(", "final", "char", "pCharToCheck", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ALPHABET", ".", "length", ";", "i", "++", ")", "{", "if", "(", "pCharToCheck", "==", "ALPHABET", "[", "i"...
Tests if a certain character is a valid character in the alphabet that is applying for this automaton.
[ "Tests", "if", "a", "certain", "character", "is", "a", "valid", "character", "in", "the", "alphabet", "that", "is", "applying", "for", "this", "automaton", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/regex/REWildcardStringParser.java#L257-L265
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java
CollectionUtil.main
@SuppressWarnings({"UnusedDeclaration", "UnusedAssignment", "unchecked"}) public static void main(String[] pArgs) { int howMany = 1000; if (pArgs.length > 0) { howMany = Integer.parseInt(pArgs[0]); } long start; long end; /* int[] intArr1 = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int[] intArr2 = new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; start = System.currentTimeMillis(); for (int i = 0; i < howMany; i++) { intArr1 = (int[]) mergeArrays(intArr1, 0, intArr1.length, intArr2, 0, intArr2.length); } end = System.currentTimeMillis(); System.out.println("mergeArrays: " + howMany + " * " + intArr2.length + " ints took " + (end - start) + " milliseconds (" + intArr1.length + ")"); */ //////////////////////////////// String[] stringArr1 = new String[]{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; /* String[] stringArr2 = new String[] { "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; start = System.currentTimeMillis(); for (int i = 0; i < howMany; i++) { stringArr1 = (String[]) mergeArrays(stringArr1, 0, stringArr1.length, stringArr2, 0, stringArr2.length); } end = System.currentTimeMillis(); System.out.println("mergeArrays: " + howMany + " * " + stringArr2.length + " Strings took " + (end - start) + " milliseconds (" + stringArr1.length + ")"); start = System.currentTimeMillis(); while (intArr1.length > stringArr2.length) { intArr1 = (int[]) subArray(intArr1, 0, intArr1.length - stringArr2.length); } end = System.currentTimeMillis(); System.out.println("subArray: " + howMany + " * " + intArr2.length + " ints took " + (end - start) + " milliseconds (" + intArr1.length + ")"); start = System.currentTimeMillis(); while (stringArr1.length > stringArr2.length) { stringArr1 = (String[]) subArray(stringArr1, stringArr2.length); } end = System.currentTimeMillis(); System.out.println("subArray: " + howMany + " * " + stringArr2.length + " Strings took " + (end - start) + " milliseconds (" + stringArr1.length + ")"); */ stringArr1 = new String[]{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; System.out.println("\nFilterIterators:\n"); List list = Arrays.asList(stringArr1); Iterator iter = new FilterIterator(list.iterator(), new FilterIterator.Filter() { public boolean accept(Object pElement) { return ((String) pElement).length() > 5; } }); while (iter.hasNext()) { String str = (String) iter.next(); System.out.println(str + " has more than 5 letters!"); } iter = new FilterIterator(list.iterator(), new FilterIterator.Filter() { public boolean accept(Object pElement) { return ((String) pElement).length() <= 5; } }); while (iter.hasNext()) { String str = (String) iter.next(); System.out.println(str + " has less than, or exactly 5 letters!"); } start = System.currentTimeMillis(); for (int i = 0; i < howMany; i++) { iter = new FilterIterator(list.iterator(), new FilterIterator.Filter() { public boolean accept(Object pElement) { return ((String) pElement).length() <= 5; } }); while (iter.hasNext()) { iter.next(); System.out.print(""); } } // end = System.currentTimeMillis(); // System.out.println("Time: " + (end - start) + " ms"); // System.out.println("\nClosureCollection:\n"); // forEach(list, new Closure() { // // public void execute(Object pElement) { // // String str = (String) pElement; // // if (str.length() > 5) { // System.out.println(str + " has more than 5 letters!"); // } // else { // System.out.println(str + " has less than, or exactly 5 letters!"); // } // } // }); // start = System.currentTimeMillis(); // for (int i = 0; i < howMany; i++) { // forEach(list, new Closure() { // // public void execute(Object pElement) { // // String str = (String) pElement; // // if (str.length() <= 5) { // System.out.print(""); // } // } // }); // } // end = System.currentTimeMillis(); // System.out.println("Time: " + (end - start) + " ms"); }
java
@SuppressWarnings({"UnusedDeclaration", "UnusedAssignment", "unchecked"}) public static void main(String[] pArgs) { int howMany = 1000; if (pArgs.length > 0) { howMany = Integer.parseInt(pArgs[0]); } long start; long end; /* int[] intArr1 = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int[] intArr2 = new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; start = System.currentTimeMillis(); for (int i = 0; i < howMany; i++) { intArr1 = (int[]) mergeArrays(intArr1, 0, intArr1.length, intArr2, 0, intArr2.length); } end = System.currentTimeMillis(); System.out.println("mergeArrays: " + howMany + " * " + intArr2.length + " ints took " + (end - start) + " milliseconds (" + intArr1.length + ")"); */ //////////////////////////////// String[] stringArr1 = new String[]{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; /* String[] stringArr2 = new String[] { "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; start = System.currentTimeMillis(); for (int i = 0; i < howMany; i++) { stringArr1 = (String[]) mergeArrays(stringArr1, 0, stringArr1.length, stringArr2, 0, stringArr2.length); } end = System.currentTimeMillis(); System.out.println("mergeArrays: " + howMany + " * " + stringArr2.length + " Strings took " + (end - start) + " milliseconds (" + stringArr1.length + ")"); start = System.currentTimeMillis(); while (intArr1.length > stringArr2.length) { intArr1 = (int[]) subArray(intArr1, 0, intArr1.length - stringArr2.length); } end = System.currentTimeMillis(); System.out.println("subArray: " + howMany + " * " + intArr2.length + " ints took " + (end - start) + " milliseconds (" + intArr1.length + ")"); start = System.currentTimeMillis(); while (stringArr1.length > stringArr2.length) { stringArr1 = (String[]) subArray(stringArr1, stringArr2.length); } end = System.currentTimeMillis(); System.out.println("subArray: " + howMany + " * " + stringArr2.length + " Strings took " + (end - start) + " milliseconds (" + stringArr1.length + ")"); */ stringArr1 = new String[]{ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; System.out.println("\nFilterIterators:\n"); List list = Arrays.asList(stringArr1); Iterator iter = new FilterIterator(list.iterator(), new FilterIterator.Filter() { public boolean accept(Object pElement) { return ((String) pElement).length() > 5; } }); while (iter.hasNext()) { String str = (String) iter.next(); System.out.println(str + " has more than 5 letters!"); } iter = new FilterIterator(list.iterator(), new FilterIterator.Filter() { public boolean accept(Object pElement) { return ((String) pElement).length() <= 5; } }); while (iter.hasNext()) { String str = (String) iter.next(); System.out.println(str + " has less than, or exactly 5 letters!"); } start = System.currentTimeMillis(); for (int i = 0; i < howMany; i++) { iter = new FilterIterator(list.iterator(), new FilterIterator.Filter() { public boolean accept(Object pElement) { return ((String) pElement).length() <= 5; } }); while (iter.hasNext()) { iter.next(); System.out.print(""); } } // end = System.currentTimeMillis(); // System.out.println("Time: " + (end - start) + " ms"); // System.out.println("\nClosureCollection:\n"); // forEach(list, new Closure() { // // public void execute(Object pElement) { // // String str = (String) pElement; // // if (str.length() > 5) { // System.out.println(str + " has more than 5 letters!"); // } // else { // System.out.println(str + " has less than, or exactly 5 letters!"); // } // } // }); // start = System.currentTimeMillis(); // for (int i = 0; i < howMany; i++) { // forEach(list, new Closure() { // // public void execute(Object pElement) { // // String str = (String) pElement; // // if (str.length() <= 5) { // System.out.print(""); // } // } // }); // } // end = System.currentTimeMillis(); // System.out.println("Time: " + (end - start) + " ms"); }
[ "@", "SuppressWarnings", "(", "{", "\"UnusedDeclaration\"", ",", "\"UnusedAssignment\"", ",", "\"unchecked\"", "}", ")", "public", "static", "void", "main", "(", "String", "[", "]", "pArgs", ")", "{", "int", "howMany", "=", "1000", ";", "if", "(", "pArgs", ...
Testing only. @param pArgs command line arguents
[ "Testing", "only", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java#L58-L205
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java
CollectionUtil.mergeArrays
public static Object mergeArrays(Object pArray1, Object pArray2) { return mergeArrays(pArray1, 0, Array.getLength(pArray1), pArray2, 0, Array.getLength(pArray2)); }
java
public static Object mergeArrays(Object pArray1, Object pArray2) { return mergeArrays(pArray1, 0, Array.getLength(pArray1), pArray2, 0, Array.getLength(pArray2)); }
[ "public", "static", "Object", "mergeArrays", "(", "Object", "pArray1", ",", "Object", "pArray2", ")", "{", "return", "mergeArrays", "(", "pArray1", ",", "0", ",", "Array", ".", "getLength", "(", "pArray1", ")", ",", "pArray2", ",", "0", ",", "Array", "."...
Merges two arrays into a new array. Elements from array1 and array2 will be copied into a new array, that has array1.length + array2.length elements. @param pArray1 First array @param pArray2 Second array, must be compatible with (assignable from) the first array @return A new array, containing the values of array1 and array2. The array (wrapped as an object), will have the length of array1 + array2, and can be safely cast to the type of the array1 parameter. @see #mergeArrays(Object,int,int,Object,int,int) @see java.lang.System#arraycopy(Object,int,Object,int,int)
[ "Merges", "two", "arrays", "into", "a", "new", "array", ".", "Elements", "from", "array1", "and", "array2", "will", "be", "copied", "into", "a", "new", "array", "that", "has", "array1", ".", "length", "+", "array2", ".", "length", "elements", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java#L225-L227
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java
CollectionUtil.mergeArrays
@SuppressWarnings({"SuspiciousSystemArraycopy"}) public static Object mergeArrays(Object pArray1, int pOffset1, int pLength1, Object pArray2, int pOffset2, int pLength2) { Class class1 = pArray1.getClass(); Class type = class1.getComponentType(); // Create new array of the new length Object array = Array.newInstance(type, pLength1 + pLength2); System.arraycopy(pArray1, pOffset1, array, 0, pLength1); System.arraycopy(pArray2, pOffset2, array, pLength1, pLength2); return array; }
java
@SuppressWarnings({"SuspiciousSystemArraycopy"}) public static Object mergeArrays(Object pArray1, int pOffset1, int pLength1, Object pArray2, int pOffset2, int pLength2) { Class class1 = pArray1.getClass(); Class type = class1.getComponentType(); // Create new array of the new length Object array = Array.newInstance(type, pLength1 + pLength2); System.arraycopy(pArray1, pOffset1, array, 0, pLength1); System.arraycopy(pArray2, pOffset2, array, pLength1, pLength2); return array; }
[ "@", "SuppressWarnings", "(", "{", "\"SuspiciousSystemArraycopy\"", "}", ")", "public", "static", "Object", "mergeArrays", "(", "Object", "pArray1", ",", "int", "pOffset1", ",", "int", "pLength1", ",", "Object", "pArray2", ",", "int", "pOffset2", ",", "int", "...
Merges two arrays into a new array. Elements from pArray1 and pArray2 will be copied into a new array, that has pLength1 + pLength2 elements. @param pArray1 First array @param pOffset1 the offset into the first array @param pLength1 the number of elements to copy from the first array @param pArray2 Second array, must be compatible with (assignable from) the first array @param pOffset2 the offset into the second array @param pLength2 the number of elements to copy from the second array @return A new array, containing the values of pArray1 and pArray2. The array (wrapped as an object), will have the length of pArray1 + pArray2, and can be safely cast to the type of the pArray1 parameter. @see java.lang.System#arraycopy(Object,int,Object,int,int)
[ "Merges", "two", "arrays", "into", "a", "new", "array", ".", "Elements", "from", "pArray1", "and", "pArray2", "will", "be", "copied", "into", "a", "new", "array", "that", "has", "pLength1", "+", "pLength2", "elements", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java#L246-L257
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java
CollectionUtil.addAll
public static <E> void addAll(Collection<E> pCollection, Iterator<? extends E> pIterator) { while (pIterator.hasNext()) { pCollection.add(pIterator.next()); } }
java
public static <E> void addAll(Collection<E> pCollection, Iterator<? extends E> pIterator) { while (pIterator.hasNext()) { pCollection.add(pIterator.next()); } }
[ "public", "static", "<", "E", ">", "void", "addAll", "(", "Collection", "<", "E", ">", "pCollection", ",", "Iterator", "<", "?", "extends", "E", ">", "pIterator", ")", "{", "while", "(", "pIterator", ".", "hasNext", "(", ")", ")", "{", "pCollection", ...
Adds all elements of the iterator to the collection. @param pCollection the collection @param pIterator the elements to add @throws UnsupportedOperationException if {@code add} is not supported by the given collection. @throws ClassCastException class of the specified element prevents it from being added to this collection. @throws NullPointerException if the specified element is {@code null} and this collection does not support {@code null} elements. @throws IllegalArgumentException some aspect of this element prevents it from being added to this collection.
[ "Adds", "all", "elements", "of", "the", "iterator", "to", "the", "collection", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/CollectionUtil.java#L414-L418
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java
ServiceRegistry.registerSPIs
<T> void registerSPIs(final URL pResource, final Class<T> pCategory, final ClassLoader pLoader) { Properties classNames = new Properties(); try { classNames.load(pResource.openStream()); } catch (IOException e) { throw new ServiceConfigurationError(e); } if (!classNames.isEmpty()) { @SuppressWarnings({"unchecked"}) CategoryRegistry<T> registry = categoryMap.get(pCategory); Set providerClassNames = classNames.keySet(); for (Object providerClassName : providerClassNames) { String className = (String) providerClassName; try { @SuppressWarnings({"unchecked"}) Class<T> providerClass = (Class<T>) Class.forName(className, true, pLoader); T provider = providerClass.newInstance(); registry.register(provider); } catch (ClassNotFoundException e) { throw new ServiceConfigurationError(e); } catch (IllegalAccessException e) { throw new ServiceConfigurationError(e); } catch (InstantiationException e) { throw new ServiceConfigurationError(e); } catch (IllegalArgumentException e) { throw new ServiceConfigurationError(e); } } } }
java
<T> void registerSPIs(final URL pResource, final Class<T> pCategory, final ClassLoader pLoader) { Properties classNames = new Properties(); try { classNames.load(pResource.openStream()); } catch (IOException e) { throw new ServiceConfigurationError(e); } if (!classNames.isEmpty()) { @SuppressWarnings({"unchecked"}) CategoryRegistry<T> registry = categoryMap.get(pCategory); Set providerClassNames = classNames.keySet(); for (Object providerClassName : providerClassNames) { String className = (String) providerClassName; try { @SuppressWarnings({"unchecked"}) Class<T> providerClass = (Class<T>) Class.forName(className, true, pLoader); T provider = providerClass.newInstance(); registry.register(provider); } catch (ClassNotFoundException e) { throw new ServiceConfigurationError(e); } catch (IllegalAccessException e) { throw new ServiceConfigurationError(e); } catch (InstantiationException e) { throw new ServiceConfigurationError(e); } catch (IllegalArgumentException e) { throw new ServiceConfigurationError(e); } } } }
[ "<", "T", ">", "void", "registerSPIs", "(", "final", "URL", "pResource", ",", "final", "Class", "<", "T", ">", "pCategory", ",", "final", "ClassLoader", "pLoader", ")", "{", "Properties", "classNames", "=", "new", "Properties", "(", ")", ";", "try", "{",...
Registers all SPIs listed in the given resource. @param pResource the resource to load SPIs from @param pCategory the category class @param pLoader the class loader to use
[ "Registers", "all", "SPIs", "listed", "in", "the", "given", "resource", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java#L147-L185
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java
ServiceRegistry.getRegistry
private <T> CategoryRegistry<T> getRegistry(final Class<T> pCategory) { @SuppressWarnings({"unchecked"}) CategoryRegistry<T> registry = categoryMap.get(pCategory); if (registry == null) { throw new IllegalArgumentException("No such category: " + pCategory.getName()); } return registry; }
java
private <T> CategoryRegistry<T> getRegistry(final Class<T> pCategory) { @SuppressWarnings({"unchecked"}) CategoryRegistry<T> registry = categoryMap.get(pCategory); if (registry == null) { throw new IllegalArgumentException("No such category: " + pCategory.getName()); } return registry; }
[ "private", "<", "T", ">", "CategoryRegistry", "<", "T", ">", "getRegistry", "(", "final", "Class", "<", "T", ">", "pCategory", ")", "{", "@", "SuppressWarnings", "(", "{", "\"unchecked\"", "}", ")", "CategoryRegistry", "<", "T", ">", "registry", "=", "ca...
Gets the category registry for the given category. @param pCategory the category class @return the {@code CategoryRegistry} for the given category
[ "Gets", "the", "category", "registry", "for", "the", "given", "category", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java#L288-L295
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java
ServiceRegistry.register
public boolean register(final Object pProvider) { Iterator<Class<?>> categories = compatibleCategories(pProvider); boolean registered = false; while (categories.hasNext()) { Class<?> category = categories.next(); if (registerImpl(pProvider, category) && !registered) { registered = true; } } return registered; }
java
public boolean register(final Object pProvider) { Iterator<Class<?>> categories = compatibleCategories(pProvider); boolean registered = false; while (categories.hasNext()) { Class<?> category = categories.next(); if (registerImpl(pProvider, category) && !registered) { registered = true; } } return registered; }
[ "public", "boolean", "register", "(", "final", "Object", "pProvider", ")", "{", "Iterator", "<", "Class", "<", "?", ">", ">", "categories", "=", "compatibleCategories", "(", "pProvider", ")", ";", "boolean", "registered", "=", "false", ";", "while", "(", "...
Registers the given provider for all categories it matches. @param pProvider the provider instance @return {@code true} if {@code pProvider} is now registered in one or more categories it was not registered in before. @see #compatibleCategories(Object)
[ "Registers", "the", "given", "provider", "for", "all", "categories", "it", "matches", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java#L305-L315
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java
ServiceRegistry.register
public <T> boolean register(final T pProvider, final Class<? super T> pCategory) { return registerImpl(pProvider, pCategory); }
java
public <T> boolean register(final T pProvider, final Class<? super T> pCategory) { return registerImpl(pProvider, pCategory); }
[ "public", "<", "T", ">", "boolean", "register", "(", "final", "T", "pProvider", ",", "final", "Class", "<", "?", "super", "T", ">", "pCategory", ")", "{", "return", "registerImpl", "(", "pProvider", ",", "pCategory", ")", ";", "}" ]
Registers the given provider for the given category. @param pProvider the provider instance @param pCategory the category class @return {@code true} if {@code pProvider} is now registered in the given category
[ "Registers", "the", "given", "provider", "for", "the", "given", "category", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java#L329-L331
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java
ServiceRegistry.deregister
public boolean deregister(final Object pProvider) { Iterator<Class<?>> categories = containingCategories(pProvider); boolean deregistered = false; while (categories.hasNext()) { Class<?> category = categories.next(); if (deregister(pProvider, category) && !deregistered) { deregistered = true; } } return deregistered; }
java
public boolean deregister(final Object pProvider) { Iterator<Class<?>> categories = containingCategories(pProvider); boolean deregistered = false; while (categories.hasNext()) { Class<?> category = categories.next(); if (deregister(pProvider, category) && !deregistered) { deregistered = true; } } return deregistered; }
[ "public", "boolean", "deregister", "(", "final", "Object", "pProvider", ")", "{", "Iterator", "<", "Class", "<", "?", ">", ">", "categories", "=", "containingCategories", "(", "pProvider", ")", ";", "boolean", "deregistered", "=", "false", ";", "while", "(",...
De-registers the given provider from all categories it's currently registered in. @param pProvider the provider instance @return {@code true} if {@code pProvider} was previously registered in any category and is now de-registered. @see #containingCategories(Object)
[ "De", "-", "registers", "the", "given", "provider", "from", "all", "categories", "it", "s", "currently", "registered", "in", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/service/ServiceRegistry.java#L342-L354
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.isEmpty
public static boolean isEmpty(String[] pStringArray) { // No elements to test if (pStringArray == null) { return true; } // Test all the elements for (String string : pStringArray) { if (!isEmpty(string)) { return false; } } // All elements are empty return true; }
java
public static boolean isEmpty(String[] pStringArray) { // No elements to test if (pStringArray == null) { return true; } // Test all the elements for (String string : pStringArray) { if (!isEmpty(string)) { return false; } } // All elements are empty return true; }
[ "public", "static", "boolean", "isEmpty", "(", "String", "[", "]", "pStringArray", ")", "{", "// No elements to test\r", "if", "(", "pStringArray", "==", "null", ")", "{", "return", "true", ";", "}", "// Test all the elements\r", "for", "(", "String", "string", ...
Tests a string array, to see if all items are null or an empty string. @param pStringArray The string array to check. @return true if the string array is null or only contains string items that are null or contain only whitespace, otherwise false.
[ "Tests", "a", "string", "array", "to", "see", "if", "all", "items", "are", "null", "or", "an", "empty", "string", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L167-L182
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.contains
public static boolean contains(String pContainer, String pLookFor) { return ((pContainer != null) && (pLookFor != null) && (pContainer.indexOf(pLookFor) >= 0)); }
java
public static boolean contains(String pContainer, String pLookFor) { return ((pContainer != null) && (pLookFor != null) && (pContainer.indexOf(pLookFor) >= 0)); }
[ "public", "static", "boolean", "contains", "(", "String", "pContainer", ",", "String", "pLookFor", ")", "{", "return", "(", "(", "pContainer", "!=", "null", ")", "&&", "(", "pLookFor", "!=", "null", ")", "&&", "(", "pContainer", ".", "indexOf", "(", "pLo...
Tests if a string contains another string. @param pContainer The string to test @param pLookFor The string to look for @return {@code true} if the container string is contains the string, and both parameters are non-{@code null}, otherwise {@code false}.
[ "Tests", "if", "a", "string", "contains", "another", "string", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L192-L194
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.containsIgnoreCase
public static boolean containsIgnoreCase(String pString, int pChar) { return ((pString != null) && ((pString.indexOf(Character.toLowerCase((char) pChar)) >= 0) || (pString.indexOf(Character.toUpperCase((char) pChar)) >= 0))); // NOTE: I don't convert the string to uppercase, but instead test // the string (potentially) two times, as this is more efficient for // long strings (in most cases). }
java
public static boolean containsIgnoreCase(String pString, int pChar) { return ((pString != null) && ((pString.indexOf(Character.toLowerCase((char) pChar)) >= 0) || (pString.indexOf(Character.toUpperCase((char) pChar)) >= 0))); // NOTE: I don't convert the string to uppercase, but instead test // the string (potentially) two times, as this is more efficient for // long strings (in most cases). }
[ "public", "static", "boolean", "containsIgnoreCase", "(", "String", "pString", ",", "int", "pChar", ")", "{", "return", "(", "(", "pString", "!=", "null", ")", "&&", "(", "(", "pString", ".", "indexOf", "(", "Character", ".", "toLowerCase", "(", "(", "ch...
Tests if a string contains a specific character, ignoring case. @param pString The string to check. @param pChar The character to search for. @return true if the string contains the specific character.
[ "Tests", "if", "a", "string", "contains", "a", "specific", "character", "ignoring", "case", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L227-L235
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.indexOfIgnoreCase
public static int indexOfIgnoreCase(String pString, int pChar, int pPos) { if ((pString == null)) { return -1; } // Get first char char lower = Character.toLowerCase((char) pChar); char upper = Character.toUpperCase((char) pChar); int indexLower; int indexUpper; // Test for char indexLower = pString.indexOf(lower, pPos); indexUpper = pString.indexOf(upper, pPos); if (indexLower < 0) { /* if (indexUpper < 0) return -1; // First char not found else */ return indexUpper;// Only upper } else if (indexUpper < 0) { return indexLower;// Only lower } else { // Both found, select first occurence return (indexLower < indexUpper) ? indexLower : indexUpper; } }
java
public static int indexOfIgnoreCase(String pString, int pChar, int pPos) { if ((pString == null)) { return -1; } // Get first char char lower = Character.toLowerCase((char) pChar); char upper = Character.toUpperCase((char) pChar); int indexLower; int indexUpper; // Test for char indexLower = pString.indexOf(lower, pPos); indexUpper = pString.indexOf(upper, pPos); if (indexLower < 0) { /* if (indexUpper < 0) return -1; // First char not found else */ return indexUpper;// Only upper } else if (indexUpper < 0) { return indexLower;// Only lower } else { // Both found, select first occurence return (indexLower < indexUpper) ? indexLower : indexUpper; } }
[ "public", "static", "int", "indexOfIgnoreCase", "(", "String", "pString", ",", "int", "pChar", ",", "int", "pPos", ")", "{", "if", "(", "(", "pString", "==", "null", ")", ")", "{", "return", "-", "1", ";", "}", "// Get first char\r", "char", "lower", "...
Returns the index within this string of the first occurrence of the specified character, starting at the specified index. @param pString The string to test @param pChar The character to look for @param pPos The first index to test @return if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned. @see String#indexOf(int,int)
[ "Returns", "the", "index", "within", "this", "string", "of", "the", "first", "occurrence", "of", "the", "specified", "character", "starting", "at", "the", "specified", "index", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L465-L496
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.lastIndexOfIgnoreCase
public static int lastIndexOfIgnoreCase(String pString, int pChar) { return lastIndexOfIgnoreCase(pString, pChar, pString != null ? pString.length() : -1); }
java
public static int lastIndexOfIgnoreCase(String pString, int pChar) { return lastIndexOfIgnoreCase(pString, pChar, pString != null ? pString.length() : -1); }
[ "public", "static", "int", "lastIndexOfIgnoreCase", "(", "String", "pString", ",", "int", "pChar", ")", "{", "return", "lastIndexOfIgnoreCase", "(", "pString", ",", "pChar", ",", "pString", "!=", "null", "?", "pString", ".", "length", "(", ")", ":", "-", "...
Returns the index within this string of the last occurrence of the specified character. @param pString The string to test @param pChar The character to look for @return if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned. @see String#lastIndexOf(int)
[ "Returns", "the", "index", "within", "this", "string", "of", "the", "last", "occurrence", "of", "the", "specified", "character", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L509-L511
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.lastIndexOfIgnoreCase
public static int lastIndexOfIgnoreCase(String pString, int pChar, int pPos) { if ((pString == null)) { return -1; } // Get first char char lower = Character.toLowerCase((char) pChar); char upper = Character.toUpperCase((char) pChar); int indexLower; int indexUpper; // Test for char indexLower = pString.lastIndexOf(lower, pPos); indexUpper = pString.lastIndexOf(upper, pPos); if (indexLower < 0) { /* if (indexUpper < 0) return -1; // First char not found else */ return indexUpper;// Only upper } else if (indexUpper < 0) { return indexLower;// Only lower } else { // Both found, select last occurence return (indexLower > indexUpper) ? indexLower : indexUpper; } }
java
public static int lastIndexOfIgnoreCase(String pString, int pChar, int pPos) { if ((pString == null)) { return -1; } // Get first char char lower = Character.toLowerCase((char) pChar); char upper = Character.toUpperCase((char) pChar); int indexLower; int indexUpper; // Test for char indexLower = pString.lastIndexOf(lower, pPos); indexUpper = pString.lastIndexOf(upper, pPos); if (indexLower < 0) { /* if (indexUpper < 0) return -1; // First char not found else */ return indexUpper;// Only upper } else if (indexUpper < 0) { return indexLower;// Only lower } else { // Both found, select last occurence return (indexLower > indexUpper) ? indexLower : indexUpper; } }
[ "public", "static", "int", "lastIndexOfIgnoreCase", "(", "String", "pString", ",", "int", "pChar", ",", "int", "pPos", ")", "{", "if", "(", "(", "pString", "==", "null", ")", ")", "{", "return", "-", "1", ";", "}", "// Get first char\r", "char", "lower",...
Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index. @param pString The string to test @param pChar The character to look for @param pPos The last index to test @return if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned. @see String#lastIndexOf(int,int)
[ "Returns", "the", "index", "within", "this", "string", "of", "the", "last", "occurrence", "of", "the", "specified", "character", "searching", "backward", "starting", "at", "the", "specified", "index", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L525-L556
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.ltrim
public static String ltrim(String pString) { if ((pString == null) || (pString.length() == 0)) { return pString;// Null or empty string } for (int i = 0; i < pString.length(); i++) { if (!Character.isWhitespace(pString.charAt(i))) { if (i == 0) { return pString;// First char is not whitespace } else { return pString.substring(i);// Return rest after whitespace } } } // If all whitespace, return empty string return ""; }
java
public static String ltrim(String pString) { if ((pString == null) || (pString.length() == 0)) { return pString;// Null or empty string } for (int i = 0; i < pString.length(); i++) { if (!Character.isWhitespace(pString.charAt(i))) { if (i == 0) { return pString;// First char is not whitespace } else { return pString.substring(i);// Return rest after whitespace } } } // If all whitespace, return empty string return ""; }
[ "public", "static", "String", "ltrim", "(", "String", "pString", ")", "{", "if", "(", "(", "pString", "==", "null", ")", "||", "(", "pString", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "pString", ";", "// Null or empty string\r", "}"...
Trims the argument string for whitespace on the left side only. @param pString the string to trim @return the string with no whitespace on the left, or {@code null} if the string argument is {@code null}. @see #rtrim @see String#trim()
[ "Trims", "the", "argument", "string", "for", "whitespace", "on", "the", "left", "side", "only", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L567-L584
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.replace
public static String replace(String pSource, String pPattern, String pReplace) { if (pPattern.length() == 0) { return pSource;// Special case: No pattern to replace } int match; int offset = 0; StringBuilder result = new StringBuilder(); // Loop string, until last occurence of pattern, and replace while ((match = pSource.indexOf(pPattern, offset)) != -1) { // Append everything until pattern result.append(pSource.substring(offset, match)); // Append the replace string result.append(pReplace); offset = match + pPattern.length(); } // Append rest of string and return result.append(pSource.substring(offset)); return result.toString(); }
java
public static String replace(String pSource, String pPattern, String pReplace) { if (pPattern.length() == 0) { return pSource;// Special case: No pattern to replace } int match; int offset = 0; StringBuilder result = new StringBuilder(); // Loop string, until last occurence of pattern, and replace while ((match = pSource.indexOf(pPattern, offset)) != -1) { // Append everything until pattern result.append(pSource.substring(offset, match)); // Append the replace string result.append(pReplace); offset = match + pPattern.length(); } // Append rest of string and return result.append(pSource.substring(offset)); return result.toString(); }
[ "public", "static", "String", "replace", "(", "String", "pSource", ",", "String", "pPattern", ",", "String", "pReplace", ")", "{", "if", "(", "pPattern", ".", "length", "(", ")", "==", "0", ")", "{", "return", "pSource", ";", "// Special case: No pattern to ...
Replaces a substring of a string with another string. All matches are replaced. @param pSource The source String @param pPattern The pattern to replace @param pReplace The new String to be inserted instead of the replace String @return The new String with the pattern replaced
[ "Replaces", "a", "substring", "of", "a", "string", "with", "another", "string", ".", "All", "matches", "are", "replaced", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L624-L646
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.replaceIgnoreCase
public static String replaceIgnoreCase(String pSource, String pPattern, String pReplace) { if (pPattern.length() == 0) { return pSource;// Special case: No pattern to replace } int match; int offset = 0; StringBuilder result = new StringBuilder(); while ((match = indexOfIgnoreCase(pSource, pPattern, offset)) != -1) { result.append(pSource.substring(offset, match)); result.append(pReplace); offset = match + pPattern.length(); } result.append(pSource.substring(offset)); return result.toString(); }
java
public static String replaceIgnoreCase(String pSource, String pPattern, String pReplace) { if (pPattern.length() == 0) { return pSource;// Special case: No pattern to replace } int match; int offset = 0; StringBuilder result = new StringBuilder(); while ((match = indexOfIgnoreCase(pSource, pPattern, offset)) != -1) { result.append(pSource.substring(offset, match)); result.append(pReplace); offset = match + pPattern.length(); } result.append(pSource.substring(offset)); return result.toString(); }
[ "public", "static", "String", "replaceIgnoreCase", "(", "String", "pSource", ",", "String", "pPattern", ",", "String", "pReplace", ")", "{", "if", "(", "pPattern", ".", "length", "(", ")", "==", "0", ")", "{", "return", "pSource", ";", "// Special case: No p...
Replaces a substring of a string with another string, ignoring case. All matches are replaced. @param pSource The source String @param pPattern The pattern to replace @param pReplace The new String to be inserted instead of the replace String @return The new String with the pattern replaced @see #replace(String,String,String)
[ "Replaces", "a", "substring", "of", "a", "string", "with", "another", "string", "ignoring", "case", ".", "All", "matches", "are", "replaced", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L659-L674
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.capitalize
public static String capitalize(String pString, int pIndex) { if (pIndex < 0) { throw new IndexOutOfBoundsException("Negative index not allowed: " + pIndex); } if (pString == null || pString.length() <= pIndex) { return pString; } // This is the fastest method, according to my tests // Skip array duplication if allready capitalized if (Character.isUpperCase(pString.charAt(pIndex))) { return pString; } // Convert to char array, capitalize and create new String char[] charArray = pString.toCharArray(); charArray[pIndex] = Character.toUpperCase(charArray[pIndex]); return new String(charArray); /** StringBuilder buf = new StringBuilder(pString); buf.setCharAt(pIndex, Character.toUpperCase(buf.charAt(pIndex))); return buf.toString(); //*/ /** return pString.substring(0, pIndex) + Character.toUpperCase(pString.charAt(pIndex)) + pString.substring(pIndex + 1); //*/ }
java
public static String capitalize(String pString, int pIndex) { if (pIndex < 0) { throw new IndexOutOfBoundsException("Negative index not allowed: " + pIndex); } if (pString == null || pString.length() <= pIndex) { return pString; } // This is the fastest method, according to my tests // Skip array duplication if allready capitalized if (Character.isUpperCase(pString.charAt(pIndex))) { return pString; } // Convert to char array, capitalize and create new String char[] charArray = pString.toCharArray(); charArray[pIndex] = Character.toUpperCase(charArray[pIndex]); return new String(charArray); /** StringBuilder buf = new StringBuilder(pString); buf.setCharAt(pIndex, Character.toUpperCase(buf.charAt(pIndex))); return buf.toString(); //*/ /** return pString.substring(0, pIndex) + Character.toUpperCase(pString.charAt(pIndex)) + pString.substring(pIndex + 1); //*/ }
[ "public", "static", "String", "capitalize", "(", "String", "pString", ",", "int", "pIndex", ")", "{", "if", "(", "pIndex", "<", "0", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"Negative index not allowed: \"", "+", "pIndex", ")", ";", "}", ...
Makes the Nth letter of a String uppercase. If the index is outside the the length of the argument string, the argument is simply returned. @param pString The string to capitalize @param pIndex The base-0 index of the char to capitalize. @return The capitalized string, or null, if a null argument was given.
[ "Makes", "the", "Nth", "letter", "of", "a", "String", "uppercase", ".", "If", "the", "index", "is", "outside", "the", "the", "length", "of", "the", "argument", "string", "the", "argument", "is", "simply", "returned", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L717-L748
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.pad
public static String pad(String pSource, int pRequiredLength, String pPadString, boolean pPrepend) { if (pPadString == null || pPadString.length() == 0) { throw new IllegalArgumentException("Pad string: \"" + pPadString + "\""); } if (pSource.length() >= pRequiredLength) { return pSource; } // TODO: Benchmark the new version against the old one, to see if it's really faster // Rewrite to first create pad // - pad += pad; - until length is >= gap // then append the pad and cut if too long int gap = pRequiredLength - pSource.length(); StringBuilder result = new StringBuilder(pPadString); while (result.length() < gap) { result.append(result); } if (result.length() > gap) { result.delete(gap, result.length()); } return pPrepend ? result.append(pSource).toString() : result.insert(0, pSource).toString(); /* StringBuilder result = new StringBuilder(pSource); // Concatenation until proper string length while (result.length() < pRequiredLength) { // Prepend or append if (pPrepend) { // Front result.insert(0, pPadString); } else { // Back result.append(pPadString); } } // Truncate if (result.length() > pRequiredLength) { if (pPrepend) { result.delete(0, result.length() - pRequiredLength); } else { result.delete(pRequiredLength, result.length()); } } return result.toString(); */ }
java
public static String pad(String pSource, int pRequiredLength, String pPadString, boolean pPrepend) { if (pPadString == null || pPadString.length() == 0) { throw new IllegalArgumentException("Pad string: \"" + pPadString + "\""); } if (pSource.length() >= pRequiredLength) { return pSource; } // TODO: Benchmark the new version against the old one, to see if it's really faster // Rewrite to first create pad // - pad += pad; - until length is >= gap // then append the pad and cut if too long int gap = pRequiredLength - pSource.length(); StringBuilder result = new StringBuilder(pPadString); while (result.length() < gap) { result.append(result); } if (result.length() > gap) { result.delete(gap, result.length()); } return pPrepend ? result.append(pSource).toString() : result.insert(0, pSource).toString(); /* StringBuilder result = new StringBuilder(pSource); // Concatenation until proper string length while (result.length() < pRequiredLength) { // Prepend or append if (pPrepend) { // Front result.insert(0, pPadString); } else { // Back result.append(pPadString); } } // Truncate if (result.length() > pRequiredLength) { if (pPrepend) { result.delete(0, result.length() - pRequiredLength); } else { result.delete(pRequiredLength, result.length()); } } return result.toString(); */ }
[ "public", "static", "String", "pad", "(", "String", "pSource", ",", "int", "pRequiredLength", ",", "String", "pPadString", ",", "boolean", "pPrepend", ")", "{", "if", "(", "pPadString", "==", "null", "||", "pPadString", ".", "length", "(", ")", "==", "0", ...
String length check with simple concatenation of selected pad-string. E.g. a zip number from 123 to the correct 0123. @param pSource The source string. @param pRequiredLength The accurate length of the resulting string. @param pPadString The string for concatenation. @param pPrepend The location of fill-ins, prepend (true), or append (false) @return a concatenated string. @todo What if source is allready longer than required length? @todo Consistency with cut @see #cut(String,int,String)
[ "String", "length", "check", "with", "simple", "concatenation", "of", "selected", "pad", "-", "string", ".", "E", ".", "g", ".", "a", "zip", "number", "from", "123", "to", "the", "correct", "0123", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L805-L855
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.toStringArray
public static String[] toStringArray(String pString, String pDelimiters) { if (isEmpty(pString)) { return new String[0]; } StringTokenIterator st = new StringTokenIterator(pString, pDelimiters); List<String> v = new ArrayList<String>(); while (st.hasMoreElements()) { v.add(st.nextToken()); } return v.toArray(new String[v.size()]); }
java
public static String[] toStringArray(String pString, String pDelimiters) { if (isEmpty(pString)) { return new String[0]; } StringTokenIterator st = new StringTokenIterator(pString, pDelimiters); List<String> v = new ArrayList<String>(); while (st.hasMoreElements()) { v.add(st.nextToken()); } return v.toArray(new String[v.size()]); }
[ "public", "static", "String", "[", "]", "toStringArray", "(", "String", "pString", ",", "String", "pDelimiters", ")", "{", "if", "(", "isEmpty", "(", "pString", ")", ")", "{", "return", "new", "String", "[", "0", "]", ";", "}", "StringTokenIterator", "st...
Converts a delimiter separated String to an array of Strings. @param pString The comma-separated string @param pDelimiters The delimiter string @return a {@code String} array containing the delimiter separated elements
[ "Converts", "a", "delimiter", "separated", "String", "to", "an", "array", "of", "Strings", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L930-L943
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.toIntArray
public static int[] toIntArray(String pString, String pDelimiters, int pBase) { if (isEmpty(pString)) { return new int[0]; } // Some room for improvement here... String[] temp = toStringArray(pString, pDelimiters); int[] array = new int[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Integer.parseInt(temp[i], pBase); } return array; }
java
public static int[] toIntArray(String pString, String pDelimiters, int pBase) { if (isEmpty(pString)) { return new int[0]; } // Some room for improvement here... String[] temp = toStringArray(pString, pDelimiters); int[] array = new int[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Integer.parseInt(temp[i], pBase); } return array; }
[ "public", "static", "int", "[", "]", "toIntArray", "(", "String", "pString", ",", "String", "pDelimiters", ",", "int", "pBase", ")", "{", "if", "(", "isEmpty", "(", "pString", ")", ")", "{", "return", "new", "int", "[", "0", "]", ";", "}", "// Some r...
Converts a comma-separated String to an array of ints. @param pString The comma-separated string @param pDelimiters The delimiter string @param pBase The radix @return an {@code int} array @throws NumberFormatException if any of the elements are not parseable as an int
[ "Converts", "a", "comma", "-", "separated", "String", "to", "an", "array", "of", "ints", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L966-L979
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.toLongArray
public static long[] toLongArray(String pString, String pDelimiters) { if (isEmpty(pString)) { return new long[0]; } // Some room for improvement here... String[] temp = toStringArray(pString, pDelimiters); long[] array = new long[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Long.parseLong(temp[i]); } return array; }
java
public static long[] toLongArray(String pString, String pDelimiters) { if (isEmpty(pString)) { return new long[0]; } // Some room for improvement here... String[] temp = toStringArray(pString, pDelimiters); long[] array = new long[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Long.parseLong(temp[i]); } return array; }
[ "public", "static", "long", "[", "]", "toLongArray", "(", "String", "pString", ",", "String", "pDelimiters", ")", "{", "if", "(", "isEmpty", "(", "pString", ")", ")", "{", "return", "new", "long", "[", "0", "]", ";", "}", "// Some room for improvement here...
Converts a comma-separated String to an array of longs. @param pString The comma-separated string @param pDelimiters The delimiter string @return a {@code long} array @throws NumberFormatException if any of the elements are not parseable as a long
[ "Converts", "a", "comma", "-", "separated", "String", "to", "an", "array", "of", "longs", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L1018-L1031
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.toDoubleArray
public static double[] toDoubleArray(String pString, String pDelimiters) { if (isEmpty(pString)) { return new double[0]; } // Some room for improvement here... String[] temp = toStringArray(pString, pDelimiters); double[] array = new double[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Double.valueOf(temp[i]); // Double.parseDouble() is 1.2... } return array; }
java
public static double[] toDoubleArray(String pString, String pDelimiters) { if (isEmpty(pString)) { return new double[0]; } // Some room for improvement here... String[] temp = toStringArray(pString, pDelimiters); double[] array = new double[temp.length]; for (int i = 0; i < array.length; i++) { array[i] = Double.valueOf(temp[i]); // Double.parseDouble() is 1.2... } return array; }
[ "public", "static", "double", "[", "]", "toDoubleArray", "(", "String", "pString", ",", "String", "pDelimiters", ")", "{", "if", "(", "isEmpty", "(", "pString", ")", ")", "{", "return", "new", "double", "[", "0", "]", ";", "}", "// Some room for improvemen...
Converts a comma-separated String to an array of doubles. @param pString The comma-separated string @param pDelimiters The delimiter string @return a {@code double} array @throws NumberFormatException if any of the elements are not parseable as a double
[ "Converts", "a", "comma", "-", "separated", "String", "to", "an", "array", "of", "doubles", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L1056-L1071
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java
StringUtil.toCSVString
public static String toCSVString(Object[] pStringArray, String pDelimiterString) { if (pStringArray == null) { return ""; } if (pDelimiterString == null) { throw new IllegalArgumentException("delimiter == null"); } StringBuilder buffer = new StringBuilder(); for (int i = 0; i < pStringArray.length; i++) { if (i > 0) { buffer.append(pDelimiterString); } buffer.append(pStringArray[i]); } return buffer.toString(); }
java
public static String toCSVString(Object[] pStringArray, String pDelimiterString) { if (pStringArray == null) { return ""; } if (pDelimiterString == null) { throw new IllegalArgumentException("delimiter == null"); } StringBuilder buffer = new StringBuilder(); for (int i = 0; i < pStringArray.length; i++) { if (i > 0) { buffer.append(pDelimiterString); } buffer.append(pStringArray[i]); } return buffer.toString(); }
[ "public", "static", "String", "toCSVString", "(", "Object", "[", "]", "pStringArray", ",", "String", "pDelimiterString", ")", "{", "if", "(", "pStringArray", "==", "null", ")", "{", "return", "\"\"", ";", "}", "if", "(", "pDelimiterString", "==", "null", "...
Converts a string array to a string separated by the given delimiter. @param pStringArray the string array @param pDelimiterString the delimiter string @return string of delimiter separated values @throws IllegalArgumentException if {@code pDelimiterString == null}
[ "Converts", "a", "string", "array", "to", "a", "string", "separated", "by", "the", "given", "delimiter", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/StringUtil.java#L1589-L1607
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/lang/NativeLoader.java
NativeLoader.loadLibrary0
static void loadLibrary0(String pLibrary, String pResource, ClassLoader pLoader) { if (pLibrary == null) { throw new IllegalArgumentException("library == null"); } // Try loading normal way UnsatisfiedLinkError unsatisfied; try { System.loadLibrary(pLibrary); return; } catch (UnsatisfiedLinkError err) { // Ignore unsatisfied = err; } final ClassLoader loader = pLoader != null ? pLoader : Thread.currentThread().getContextClassLoader(); final String resource = pResource != null ? pResource : getResourceFor(pLibrary); // TODO: resource may be null, and that MIGHT be okay, IFF the resource // is allready unpacked to the user dir... However, we then need another // way to resolve the library extension... // Right now we just fail in a predictable way (no NPE)! if (resource == null) { throw unsatisfied; } // Default to load/store from user.home File dir = new File(System.getProperty("user.home") + "/.twelvemonkeys/lib"); dir.mkdirs(); //File libraryFile = new File(dir.getAbsolutePath(), pLibrary + LIBRARY_EXTENSION); File libraryFile = new File(dir.getAbsolutePath(), pLibrary + "." + FileUtil.getExtension(resource)); if (!libraryFile.exists()) { try { extractToUserDir(resource, libraryFile, loader); } catch (IOException ioe) { UnsatisfiedLinkError err = new UnsatisfiedLinkError("Unable to extract resource to dir: " + libraryFile.getAbsolutePath()); err.initCause(ioe); throw err; } } // Try to load the library from the file we just wrote System.load(libraryFile.getAbsolutePath()); }
java
static void loadLibrary0(String pLibrary, String pResource, ClassLoader pLoader) { if (pLibrary == null) { throw new IllegalArgumentException("library == null"); } // Try loading normal way UnsatisfiedLinkError unsatisfied; try { System.loadLibrary(pLibrary); return; } catch (UnsatisfiedLinkError err) { // Ignore unsatisfied = err; } final ClassLoader loader = pLoader != null ? pLoader : Thread.currentThread().getContextClassLoader(); final String resource = pResource != null ? pResource : getResourceFor(pLibrary); // TODO: resource may be null, and that MIGHT be okay, IFF the resource // is allready unpacked to the user dir... However, we then need another // way to resolve the library extension... // Right now we just fail in a predictable way (no NPE)! if (resource == null) { throw unsatisfied; } // Default to load/store from user.home File dir = new File(System.getProperty("user.home") + "/.twelvemonkeys/lib"); dir.mkdirs(); //File libraryFile = new File(dir.getAbsolutePath(), pLibrary + LIBRARY_EXTENSION); File libraryFile = new File(dir.getAbsolutePath(), pLibrary + "." + FileUtil.getExtension(resource)); if (!libraryFile.exists()) { try { extractToUserDir(resource, libraryFile, loader); } catch (IOException ioe) { UnsatisfiedLinkError err = new UnsatisfiedLinkError("Unable to extract resource to dir: " + libraryFile.getAbsolutePath()); err.initCause(ioe); throw err; } } // Try to load the library from the file we just wrote System.load(libraryFile.getAbsolutePath()); }
[ "static", "void", "loadLibrary0", "(", "String", "pLibrary", ",", "String", "pResource", ",", "ClassLoader", "pLoader", ")", "{", "if", "(", "pLibrary", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"library == null\"", ")", ";", "...
Loads a native library. @param pLibrary name of the library @param pResource name of the resource @param pLoader the class loader to use @throws UnsatisfiedLinkError
[ "Loads", "a", "native", "library", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/lang/NativeLoader.java#L230-L276
train
haraldk/TwelveMonkeys
imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/tiff/Rational.java
Rational.plus
public Rational plus(final Rational pOther) { // special cases if (equals(ZERO)) { return pOther; } if (pOther.equals(ZERO)) { return this; } // Find gcd of numerators and denominators long f = gcd(numerator, pOther.numerator); long g = gcd(denominator, pOther.denominator); // add cross-product terms for numerator // multiply back in return new Rational( ((numerator / f) * (pOther.denominator / g) + (pOther.numerator / f) * (denominator / g)) * f, lcm(denominator, pOther.denominator) ); }
java
public Rational plus(final Rational pOther) { // special cases if (equals(ZERO)) { return pOther; } if (pOther.equals(ZERO)) { return this; } // Find gcd of numerators and denominators long f = gcd(numerator, pOther.numerator); long g = gcd(denominator, pOther.denominator); // add cross-product terms for numerator // multiply back in return new Rational( ((numerator / f) * (pOther.denominator / g) + (pOther.numerator / f) * (denominator / g)) * f, lcm(denominator, pOther.denominator) ); }
[ "public", "Rational", "plus", "(", "final", "Rational", "pOther", ")", "{", "// special cases", "if", "(", "equals", "(", "ZERO", ")", ")", "{", "return", "pOther", ";", "}", "if", "(", "pOther", ".", "equals", "(", "ZERO", ")", ")", "{", "return", "...
return a + b, staving off overflow
[ "return", "a", "+", "b", "staving", "off", "overflow" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/tiff/Rational.java#L187-L206
train
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/droplet/Param.java
Param.service
public void service(PageContext pContext) throws ServletException, IOException { JspWriter writer = pContext.getOut(); writer.print(value); }
java
public void service(PageContext pContext) throws ServletException, IOException { JspWriter writer = pContext.getOut(); writer.print(value); }
[ "public", "void", "service", "(", "PageContext", "pContext", ")", "throws", "ServletException", ",", "IOException", "{", "JspWriter", "writer", "=", "pContext", ".", "getOut", "(", ")", ";", "writer", ".", "print", "(", "value", ")", ";", "}" ]
Services the page fragment. This version simply prints the value of this parameter to teh PageContext's out.
[ "Services", "the", "page", "fragment", ".", "This", "version", "simply", "prints", "the", "value", "of", "this", "parameter", "to", "teh", "PageContext", "s", "out", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/droplet/Param.java#L36-L40
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java
TimeFormat.main
static void main(String[] argv) { Time time = null; TimeFormat in = null; TimeFormat out = null; if (argv.length >= 3) { System.out.println("Creating out TimeFormat: \"" + argv[2] + "\""); out = new TimeFormat(argv[2]); } if (argv.length >= 2) { System.out.println("Creating in TimeFormat: \"" + argv[1] + "\""); in = new TimeFormat(argv[1]); } else { System.out.println("Using default format for in"); in = DEFAULT_FORMAT; } if (out == null) out = in; if (argv.length >= 1) { System.out.println("Parsing: \"" + argv[0] + "\" with format \"" + in.formatString + "\""); time = in.parse(argv[0]); } else time = new Time(); System.out.println("Time is \"" + out.format(time) + "\" according to format \"" + out.formatString + "\""); }
java
static void main(String[] argv) { Time time = null; TimeFormat in = null; TimeFormat out = null; if (argv.length >= 3) { System.out.println("Creating out TimeFormat: \"" + argv[2] + "\""); out = new TimeFormat(argv[2]); } if (argv.length >= 2) { System.out.println("Creating in TimeFormat: \"" + argv[1] + "\""); in = new TimeFormat(argv[1]); } else { System.out.println("Using default format for in"); in = DEFAULT_FORMAT; } if (out == null) out = in; if (argv.length >= 1) { System.out.println("Parsing: \"" + argv[0] + "\" with format \"" + in.formatString + "\""); time = in.parse(argv[0]); } else time = new Time(); System.out.println("Time is \"" + out.format(time) + "\" according to format \"" + out.formatString + "\""); }
[ "static", "void", "main", "(", "String", "[", "]", "argv", ")", "{", "Time", "time", "=", "null", ";", "TimeFormat", "in", "=", "null", ";", "TimeFormat", "out", "=", "null", ";", "if", "(", "argv", ".", "length", ">=", "3", ")", "{", "System", "...
Main method for testing ONLY
[ "Main", "method", "for", "testing", "ONLY" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java#L96-L128
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java
TimeFormat.format
public String format(Time pTime) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < formatter.length; i++) { buf.append(formatter[i].format(pTime)); } return buf.toString(); }
java
public String format(Time pTime) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < formatter.length; i++) { buf.append(formatter[i].format(pTime)); } return buf.toString(); }
[ "public", "String", "format", "(", "Time", "pTime", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "formatter", ".", "length", ";", "i", "++", ")", "{", "buf", ".", "...
Formats the the given time, using this format.
[ "Formats", "the", "the", "given", "time", "using", "this", "format", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/TimeFormat.java#L251-L257
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/cache/HTTPCache.java
HTTPCache.registerContent
void registerContent( final String pCacheURI, final CacheRequest pRequest, final CachedResponse pCachedResponse ) throws IOException { // System.out.println(" ## HTTPCache ## Registering content for " + pCacheURI); // pRequest.removeAttribute(ATTRIB_IS_STALE); // pRequest.setAttribute(ATTRIB_CACHED_RESPONSE, pCachedResponse); if ("HEAD".equals(pRequest.getMethod())) { // System.out.println(" ## HTTPCache ## Was HEAD request, will NOT store content."); return; } // TODO: Several resources may have same extension... String extension = MIMEUtil.getExtension(pCachedResponse.getHeaderValue(HEADER_CONTENT_TYPE)); if (extension == null) { extension = "[NULL]"; } synchronized (contentCache) { contentCache.put(pCacheURI + '.' + extension, pCachedResponse); // This will be the default version if (!contentCache.containsKey(pCacheURI)) { contentCache.put(pCacheURI, pCachedResponse); } } // Write the cached content to disk File content = new File(tempDir, "./" + pCacheURI + '.' + extension); if (deleteCacheOnExit && !content.exists()) { content.deleteOnExit(); } File parent = content.getParentFile(); if (!(parent.exists() || parent.mkdirs())) { log("Could not create directory " + parent.getAbsolutePath()); // TODO: Make sure vary-info is still created in memory return; } OutputStream mContentStream = new BufferedOutputStream(new FileOutputStream(content)); try { pCachedResponse.writeContentsTo(mContentStream); } finally { try { mContentStream.close(); } catch (IOException e) { log("Error closing content stream: " + e.getMessage(), e); } } // Write the cached headers to disk (in pseudo-properties-format) File headers = new File(content.getAbsolutePath() + FILE_EXT_HEADERS); if (deleteCacheOnExit && !headers.exists()) { headers.deleteOnExit(); } FileWriter writer = new FileWriter(headers); PrintWriter headerWriter = new PrintWriter(writer); try { String[] names = pCachedResponse.getHeaderNames(); for (String name : names) { String[] values = pCachedResponse.getHeaderValues(name); headerWriter.print(name); headerWriter.print(": "); headerWriter.println(StringUtil.toCSVString(values, "\\")); } } finally { headerWriter.flush(); try { writer.close(); } catch (IOException e) { log("Error closing header stream: " + e.getMessage(), e); } } // TODO: Make this more robust, if some weird entity is not // consistent in it's vary-headers.. // (sometimes Vary, sometimes not, or somtimes different Vary headers). // Write extra Vary info to disk String[] varyHeaders = pCachedResponse.getHeaderValues(HEADER_VARY); // If no variations, then don't store vary info if (varyHeaders != null && varyHeaders.length > 0) { Properties variations = getVaryProperties(pCacheURI); String vary = StringUtil.toCSVString(varyHeaders); variations.setProperty(HEADER_VARY, vary); // Create Vary-key and map to file extension... String varyKey = createVaryKey(varyHeaders, pRequest); // System.out.println("varyKey: " + varyKey); // System.out.println("extension: " + extension); variations.setProperty(varyKey, extension); storeVaryProperties(pCacheURI, variations); } }
java
void registerContent( final String pCacheURI, final CacheRequest pRequest, final CachedResponse pCachedResponse ) throws IOException { // System.out.println(" ## HTTPCache ## Registering content for " + pCacheURI); // pRequest.removeAttribute(ATTRIB_IS_STALE); // pRequest.setAttribute(ATTRIB_CACHED_RESPONSE, pCachedResponse); if ("HEAD".equals(pRequest.getMethod())) { // System.out.println(" ## HTTPCache ## Was HEAD request, will NOT store content."); return; } // TODO: Several resources may have same extension... String extension = MIMEUtil.getExtension(pCachedResponse.getHeaderValue(HEADER_CONTENT_TYPE)); if (extension == null) { extension = "[NULL]"; } synchronized (contentCache) { contentCache.put(pCacheURI + '.' + extension, pCachedResponse); // This will be the default version if (!contentCache.containsKey(pCacheURI)) { contentCache.put(pCacheURI, pCachedResponse); } } // Write the cached content to disk File content = new File(tempDir, "./" + pCacheURI + '.' + extension); if (deleteCacheOnExit && !content.exists()) { content.deleteOnExit(); } File parent = content.getParentFile(); if (!(parent.exists() || parent.mkdirs())) { log("Could not create directory " + parent.getAbsolutePath()); // TODO: Make sure vary-info is still created in memory return; } OutputStream mContentStream = new BufferedOutputStream(new FileOutputStream(content)); try { pCachedResponse.writeContentsTo(mContentStream); } finally { try { mContentStream.close(); } catch (IOException e) { log("Error closing content stream: " + e.getMessage(), e); } } // Write the cached headers to disk (in pseudo-properties-format) File headers = new File(content.getAbsolutePath() + FILE_EXT_HEADERS); if (deleteCacheOnExit && !headers.exists()) { headers.deleteOnExit(); } FileWriter writer = new FileWriter(headers); PrintWriter headerWriter = new PrintWriter(writer); try { String[] names = pCachedResponse.getHeaderNames(); for (String name : names) { String[] values = pCachedResponse.getHeaderValues(name); headerWriter.print(name); headerWriter.print(": "); headerWriter.println(StringUtil.toCSVString(values, "\\")); } } finally { headerWriter.flush(); try { writer.close(); } catch (IOException e) { log("Error closing header stream: " + e.getMessage(), e); } } // TODO: Make this more robust, if some weird entity is not // consistent in it's vary-headers.. // (sometimes Vary, sometimes not, or somtimes different Vary headers). // Write extra Vary info to disk String[] varyHeaders = pCachedResponse.getHeaderValues(HEADER_VARY); // If no variations, then don't store vary info if (varyHeaders != null && varyHeaders.length > 0) { Properties variations = getVaryProperties(pCacheURI); String vary = StringUtil.toCSVString(varyHeaders); variations.setProperty(HEADER_VARY, vary); // Create Vary-key and map to file extension... String varyKey = createVaryKey(varyHeaders, pRequest); // System.out.println("varyKey: " + varyKey); // System.out.println("extension: " + extension); variations.setProperty(varyKey, extension); storeVaryProperties(pCacheURI, variations); } }
[ "void", "registerContent", "(", "final", "String", "pCacheURI", ",", "final", "CacheRequest", "pRequest", ",", "final", "CachedResponse", "pCachedResponse", ")", "throws", "IOException", "{", "// System.out.println(\" ## HTTPCache ## Registering content for \" + pCacheURI);\r", ...
Registers content for the given URI in the cache. @param pCacheURI the cache URI @param pRequest the request @param pCachedResponse the cached response @throws IOException if the content could not be cached
[ "Registers", "content", "for", "the", "given", "URI", "in", "the", "cache", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/cache/HTTPCache.java#L736-L846
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/cache/HTTPCache.java
HTTPCache.getDateHeader
static long getDateHeader(final String pHeaderValue) { long date = -1L; if (pHeaderValue != null) { date = HTTPUtil.parseHTTPDate(pHeaderValue); } return date; }
java
static long getDateHeader(final String pHeaderValue) { long date = -1L; if (pHeaderValue != null) { date = HTTPUtil.parseHTTPDate(pHeaderValue); } return date; }
[ "static", "long", "getDateHeader", "(", "final", "String", "pHeaderValue", ")", "{", "long", "date", "=", "-", "1L", ";", "if", "(", "pHeaderValue", "!=", "null", ")", "{", "date", "=", "HTTPUtil", ".", "parseHTTPDate", "(", "pHeaderValue", ")", ";", "}"...
Utility to read a date header from a cached response. @param pHeaderValue the header value @return the parsed date as a long, or {@code -1L} if not found @see javax.servlet.http.HttpServletRequest#getDateHeader(String)
[ "Utility", "to", "read", "a", "date", "header", "from", "a", "cached", "response", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/cache/HTTPCache.java#L1084-L1090
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/image/ColorServlet.java
ColorServlet.service
public void service(ServletRequest pRequest, ServletResponse pResponse) throws IOException, ServletException { int red = 0; int green = 0; int blue = 0; // Get color parameter and parse color String rgb = pRequest.getParameter(RGB_PARAME); if (rgb != null && rgb.length() >= 6 && rgb.length() <= 7) { int index = 0; // If the hash ('#') character is included, skip it. if (rgb.length() == 7) { index++; } try { // Two digit hex for each color String r = rgb.substring(index, index += 2); red = Integer.parseInt(r, 0x10); String g = rgb.substring(index, index += 2); green = Integer.parseInt(g, 0x10); String b = rgb.substring(index, index += 2); blue = Integer.parseInt(b, 0x10); } catch (NumberFormatException nfe) { log("Wrong color format for ColorDroplet: " + rgb + ". Must be RRGGBB."); } } // Set MIME type for PNG pResponse.setContentType("image/png"); ServletOutputStream out = pResponse.getOutputStream(); try { // Write header (and palette chunk length) out.write(PNG_IMG, 0, PLTE_CHUNK_START); // Create palette chunk, excl lenght, and write byte[] palette = makePalette(red, green, blue); out.write(palette); // Write image data until end int pos = PLTE_CHUNK_START + PLTE_CHUNK_LENGTH + 4; out.write(PNG_IMG, pos, PNG_IMG.length - pos); } finally { out.flush(); } }
java
public void service(ServletRequest pRequest, ServletResponse pResponse) throws IOException, ServletException { int red = 0; int green = 0; int blue = 0; // Get color parameter and parse color String rgb = pRequest.getParameter(RGB_PARAME); if (rgb != null && rgb.length() >= 6 && rgb.length() <= 7) { int index = 0; // If the hash ('#') character is included, skip it. if (rgb.length() == 7) { index++; } try { // Two digit hex for each color String r = rgb.substring(index, index += 2); red = Integer.parseInt(r, 0x10); String g = rgb.substring(index, index += 2); green = Integer.parseInt(g, 0x10); String b = rgb.substring(index, index += 2); blue = Integer.parseInt(b, 0x10); } catch (NumberFormatException nfe) { log("Wrong color format for ColorDroplet: " + rgb + ". Must be RRGGBB."); } } // Set MIME type for PNG pResponse.setContentType("image/png"); ServletOutputStream out = pResponse.getOutputStream(); try { // Write header (and palette chunk length) out.write(PNG_IMG, 0, PLTE_CHUNK_START); // Create palette chunk, excl lenght, and write byte[] palette = makePalette(red, green, blue); out.write(palette); // Write image data until end int pos = PLTE_CHUNK_START + PLTE_CHUNK_LENGTH + 4; out.write(PNG_IMG, pos, PNG_IMG.length - pos); } finally { out.flush(); } }
[ "public", "void", "service", "(", "ServletRequest", "pRequest", ",", "ServletResponse", "pResponse", ")", "throws", "IOException", ",", "ServletException", "{", "int", "red", "=", "0", ";", "int", "green", "=", "0", ";", "int", "blue", "=", "0", ";", "// G...
Renders the 1 x 1 single color PNG to the response. @see ColorServlet class description @param pRequest the request @param pResponse the response @throws IOException @throws ServletException
[ "Renders", "the", "1", "x", "1", "single", "color", "PNG", "to", "the", "response", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/image/ColorServlet.java#L112-L162
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java
ServletUtil.getParameter
public static String getParameter(final ServletRequest pReq, final String pName, final String pDefault) { String str = pReq.getParameter(pName); return str != null ? str : pDefault; }
java
public static String getParameter(final ServletRequest pReq, final String pName, final String pDefault) { String str = pReq.getParameter(pName); return str != null ? str : pDefault; }
[ "public", "static", "String", "getParameter", "(", "final", "ServletRequest", "pReq", ",", "final", "String", "pName", ",", "final", "String", "pDefault", ")", "{", "String", "str", "=", "pReq", ".", "getParameter", "(", "pName", ")", ";", "return", "str", ...
Gets the value of the given parameter from the request, or if the parameter is not set, the default value. @param pReq the servlet request @param pName the parameter name @param pDefault the default value @return the value of the parameter, or the default value, if the parameter is not set.
[ "Gets", "the", "value", "of", "the", "given", "parameter", "from", "the", "request", "or", "if", "the", "parameter", "is", "not", "set", "the", "default", "value", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java#L128-L132
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java
ServletUtil.getParameter
static <T> T getParameter(final ServletRequest pReq, final String pName, final Class<T> pType, final String pFormat, final T pDefault) { // Test if pDefault is either null or instance of pType if (pDefault != null && !pType.isInstance(pDefault)) { throw new IllegalArgumentException("default value not instance of " + pType + ": " + pDefault.getClass()); } String str = pReq.getParameter(pName); if (str == null) { return pDefault; } try { return pType.cast(Converter.getInstance().toObject(str, pType, pFormat)); } catch (ConversionException ce) { return pDefault; } }
java
static <T> T getParameter(final ServletRequest pReq, final String pName, final Class<T> pType, final String pFormat, final T pDefault) { // Test if pDefault is either null or instance of pType if (pDefault != null && !pType.isInstance(pDefault)) { throw new IllegalArgumentException("default value not instance of " + pType + ": " + pDefault.getClass()); } String str = pReq.getParameter(pName); if (str == null) { return pDefault; } try { return pType.cast(Converter.getInstance().toObject(str, pType, pFormat)); } catch (ConversionException ce) { return pDefault; } }
[ "static", "<", "T", ">", "T", "getParameter", "(", "final", "ServletRequest", "pReq", ",", "final", "String", "pName", ",", "final", "Class", "<", "T", ">", "pType", ",", "final", "String", "pFormat", ",", "final", "T", "pDefault", ")", "{", "// Test if ...
Gets the value of the given parameter from the request converted to an Object. If the parameter is not set or not parseable, the default value is returned. @param pReq the servlet request @param pName the parameter name @param pType the type of object (class) to return @param pFormat the format to use (might be {@code null} in many cases) @param pDefault the default value @return the value of the parameter converted to a boolean, or the default value, if the parameter is not set. @throws IllegalArgumentException if {@code pDefault} is non-{@code null} and not an instance of {@code pType} @throws NullPointerException if {@code pReq}, {@code pName} or {@code pType} is {@code null}. @todo Well, it's done. Need some thinking... We probably don't want default if conversion fails... @see Converter#toObject
[ "Gets", "the", "value", "of", "the", "given", "parameter", "from", "the", "request", "converted", "to", "an", "Object", ".", "If", "the", "parameter", "is", "not", "set", "or", "not", "parseable", "the", "default", "value", "is", "returned", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java#L153-L171
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java
ServletUtil.getScriptName
static String getScriptName(final HttpServletRequest pRequest) { String requestURI = pRequest.getRequestURI(); return StringUtil.getLastElement(requestURI, "/"); }
java
static String getScriptName(final HttpServletRequest pRequest) { String requestURI = pRequest.getRequestURI(); return StringUtil.getLastElement(requestURI, "/"); }
[ "static", "String", "getScriptName", "(", "final", "HttpServletRequest", "pRequest", ")", "{", "String", "requestURI", "=", "pRequest", ".", "getRequestURI", "(", ")", ";", "return", "StringUtil", ".", "getLastElement", "(", "requestURI", ",", "\"/\"", ")", ";",...
Gets the name of the servlet or the script that generated the servlet. @param pRequest The HTTP servlet request object. @return the script name. @todo Read the spec, seems to be a mismatch with the Servlet API... @see javax.servlet.http.HttpServletRequest#getServletPath()
[ "Gets", "the", "name", "of", "the", "servlet", "or", "the", "script", "that", "generated", "the", "servlet", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java#L519-L522
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java
ServletUtil.getSessionId
public static String getSessionId(final HttpServletRequest pRequest) { HttpSession session = pRequest.getSession(); return (session != null) ? session.getId() : null; }
java
public static String getSessionId(final HttpServletRequest pRequest) { HttpSession session = pRequest.getSession(); return (session != null) ? session.getId() : null; }
[ "public", "static", "String", "getSessionId", "(", "final", "HttpServletRequest", "pRequest", ")", "{", "HttpSession", "session", "=", "pRequest", ".", "getSession", "(", ")", ";", "return", "(", "session", "!=", "null", ")", "?", "session", ".", "getId", "(...
Gets the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent. @param pRequest The HTTP servlet request object. @return the session Id
[ "Gets", "the", "unique", "identifier", "assigned", "to", "this", "session", ".", "The", "identifier", "is", "assigned", "by", "the", "servlet", "container", "and", "is", "implementation", "dependent", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ServletUtil.java#L588-L592
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/IgnoreCaseMap.java
IgnoreCaseMap.toUpper
protected static Object toUpper(final Object pObject) { if (pObject instanceof String) { return ((String) pObject).toUpperCase(); } return pObject; }
java
protected static Object toUpper(final Object pObject) { if (pObject instanceof String) { return ((String) pObject).toUpperCase(); } return pObject; }
[ "protected", "static", "Object", "toUpper", "(", "final", "Object", "pObject", ")", "{", "if", "(", "pObject", "instanceof", "String", ")", "{", "return", "(", "(", "String", ")", "pObject", ")", ".", "toUpperCase", "(", ")", ";", "}", "return", "pObject...
Converts the parameter to uppercase, if it's a String.
[ "Converts", "the", "parameter", "to", "uppercase", "if", "it", "s", "a", "String", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/IgnoreCaseMap.java#L160-L165
train
haraldk/TwelveMonkeys
imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPScanner.java
XMPScanner.scanForSequence
private static long scanForSequence(final ImageInputStream pStream, final byte[] pSequence) throws IOException { long start = -1l; int index = 0; int nullBytes = 0; for (int read; (read = pStream.read()) >= 0;) { if (pSequence[index] == (byte) read) { // If this is the first byte in the sequence, store position if (start == -1) { start = pStream.getStreamPosition() - 1; } // Inside the sequence, there might be 1 or 3 null bytes, depending on 16/32 byte encoding if (nullBytes == 1 || nullBytes == 3) { pStream.skipBytes(nullBytes); } index++; // If we found the entire sequence, we're done, return start position if (index == pSequence.length) { return start; } } else if (index == 1 && read == 0 && nullBytes < 3) { // Skip 1 or 3 null bytes for 16/32 bit encoding nullBytes++; } else if (index != 0) { // Start over index = 0; start = -1; nullBytes = 0; } } return -1l; }
java
private static long scanForSequence(final ImageInputStream pStream, final byte[] pSequence) throws IOException { long start = -1l; int index = 0; int nullBytes = 0; for (int read; (read = pStream.read()) >= 0;) { if (pSequence[index] == (byte) read) { // If this is the first byte in the sequence, store position if (start == -1) { start = pStream.getStreamPosition() - 1; } // Inside the sequence, there might be 1 or 3 null bytes, depending on 16/32 byte encoding if (nullBytes == 1 || nullBytes == 3) { pStream.skipBytes(nullBytes); } index++; // If we found the entire sequence, we're done, return start position if (index == pSequence.length) { return start; } } else if (index == 1 && read == 0 && nullBytes < 3) { // Skip 1 or 3 null bytes for 16/32 bit encoding nullBytes++; } else if (index != 0) { // Start over index = 0; start = -1; nullBytes = 0; } } return -1l; }
[ "private", "static", "long", "scanForSequence", "(", "final", "ImageInputStream", "pStream", ",", "final", "byte", "[", "]", "pSequence", ")", "throws", "IOException", "{", "long", "start", "=", "-", "1l", ";", "int", "index", "=", "0", ";", "int", "nullBy...
Scans for a given ASCII sequence. @param pStream the stream to scan @param pSequence the byte sequence to search for @return the start position of the given sequence. @throws IOException if an I/O exception occurs during scanning
[ "Scans", "for", "a", "given", "ASCII", "sequence", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/xmp/XMPScanner.java#L185-L223
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/SystemUtil.java
SystemUtil.getResourceAsStream
private static InputStream getResourceAsStream(ClassLoader pClassLoader, String pName, boolean pGuessSuffix) { InputStream is; if (!pGuessSuffix) { is = pClassLoader.getResourceAsStream(pName); // If XML, wrap stream if (is != null && pName.endsWith(XML_PROPERTIES)) { is = new XMLPropertiesInputStream(is); } } else { // Try normal properties is = pClassLoader.getResourceAsStream(pName + STD_PROPERTIES); // Try XML if (is == null) { is = pClassLoader.getResourceAsStream(pName + XML_PROPERTIES); // Wrap stream if (is != null) { is = new XMLPropertiesInputStream(is); } } } // Return stream return is; }
java
private static InputStream getResourceAsStream(ClassLoader pClassLoader, String pName, boolean pGuessSuffix) { InputStream is; if (!pGuessSuffix) { is = pClassLoader.getResourceAsStream(pName); // If XML, wrap stream if (is != null && pName.endsWith(XML_PROPERTIES)) { is = new XMLPropertiesInputStream(is); } } else { // Try normal properties is = pClassLoader.getResourceAsStream(pName + STD_PROPERTIES); // Try XML if (is == null) { is = pClassLoader.getResourceAsStream(pName + XML_PROPERTIES); // Wrap stream if (is != null) { is = new XMLPropertiesInputStream(is); } } } // Return stream return is; }
[ "private", "static", "InputStream", "getResourceAsStream", "(", "ClassLoader", "pClassLoader", ",", "String", "pName", ",", "boolean", "pGuessSuffix", ")", "{", "InputStream", "is", ";", "if", "(", "!", "pGuessSuffix", ")", "{", "is", "=", "pClassLoader", ".", ...
Gets the named resource as a stream from the given Class' Classoader. If the pGuessSuffix parameter is true, the method will try to append typical properties file suffixes, such as ".properties" or ".xml". @param pClassLoader the class loader to use @param pName name of the resource @param pGuessSuffix guess suffix @return an input stream reading from the resource
[ "Gets", "the", "named", "resource", "as", "a", "stream", "from", "the", "given", "Class", "Classoader", ".", "If", "the", "pGuessSuffix", "parameter", "is", "true", "the", "method", "will", "try", "to", "append", "typical", "properties", "file", "suffixes", ...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/SystemUtil.java#L84-L112
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/SystemUtil.java
SystemUtil.getFileAsStream
private static InputStream getFileAsStream(String pName, boolean pGuessSuffix) { InputStream is = null; File propertiesFile; try { if (!pGuessSuffix) { // Get file propertiesFile = new File(pName); if (propertiesFile.exists()) { is = new FileInputStream(propertiesFile); // If XML, wrap stream if (pName.endsWith(XML_PROPERTIES)) { is = new XMLPropertiesInputStream(is); } } } else { // Try normal properties propertiesFile = new File(pName + STD_PROPERTIES); if (propertiesFile.exists()) { is = new FileInputStream(propertiesFile); } else { // Try XML propertiesFile = new File(pName + XML_PROPERTIES); if (propertiesFile.exists()) { // Wrap stream is = new XMLPropertiesInputStream(new FileInputStream(propertiesFile)); } } } } catch (FileNotFoundException fnf) { // Should not happen, as we always test that the file .exists() // before creating InputStream // assert false; } return is; }
java
private static InputStream getFileAsStream(String pName, boolean pGuessSuffix) { InputStream is = null; File propertiesFile; try { if (!pGuessSuffix) { // Get file propertiesFile = new File(pName); if (propertiesFile.exists()) { is = new FileInputStream(propertiesFile); // If XML, wrap stream if (pName.endsWith(XML_PROPERTIES)) { is = new XMLPropertiesInputStream(is); } } } else { // Try normal properties propertiesFile = new File(pName + STD_PROPERTIES); if (propertiesFile.exists()) { is = new FileInputStream(propertiesFile); } else { // Try XML propertiesFile = new File(pName + XML_PROPERTIES); if (propertiesFile.exists()) { // Wrap stream is = new XMLPropertiesInputStream(new FileInputStream(propertiesFile)); } } } } catch (FileNotFoundException fnf) { // Should not happen, as we always test that the file .exists() // before creating InputStream // assert false; } return is; }
[ "private", "static", "InputStream", "getFileAsStream", "(", "String", "pName", ",", "boolean", "pGuessSuffix", ")", "{", "InputStream", "is", "=", "null", ";", "File", "propertiesFile", ";", "try", "{", "if", "(", "!", "pGuessSuffix", ")", "{", "// Get file \r...
Gets the named file as a stream from the current directory. If the pGuessSuffix parameter is true, the method will try to append typical properties file suffixes, such as ".properties" or ".xml". @param pName name of the resource @param pGuessSuffix guess suffix @return an input stream reading from the resource
[ "Gets", "the", "named", "file", "as", "a", "stream", "from", "the", "current", "directory", ".", "If", "the", "pGuessSuffix", "parameter", "is", "true", "the", "method", "will", "try", "to", "append", "typical", "properties", "file", "suffixes", "such", "as"...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/SystemUtil.java#L124-L167
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/lang/SystemUtil.java
SystemUtil.loadProperties
private static Properties loadProperties(InputStream pInput) throws IOException { if (pInput == null) { throw new IllegalArgumentException("InputStream == null!"); } Properties mapping = new Properties(); /*if (pInput instanceof XMLPropertiesInputStream) { mapping = new XMLProperties(); } else { mapping = new Properties(); }*/ // Load the properties mapping.load(pInput); return mapping; }
java
private static Properties loadProperties(InputStream pInput) throws IOException { if (pInput == null) { throw new IllegalArgumentException("InputStream == null!"); } Properties mapping = new Properties(); /*if (pInput instanceof XMLPropertiesInputStream) { mapping = new XMLProperties(); } else { mapping = new Properties(); }*/ // Load the properties mapping.load(pInput); return mapping; }
[ "private", "static", "Properties", "loadProperties", "(", "InputStream", "pInput", ")", "throws", "IOException", "{", "if", "(", "pInput", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"InputStream == null!\"", ")", ";", "}", "Properti...
Returns a Properties, loaded from the given inputstream. If the given inputstream is null, then an empty Properties object is returned. @param pInput the inputstream to read from @return a Properties object read from the given stream, or an empty Properties mapping, if the stream is null. @throws IOException if an error occurred when reading from the input stream.
[ "Returns", "a", "Properties", "loaded", "from", "the", "given", "inputstream", ".", "If", "the", "given", "inputstream", "is", "null", "then", "an", "empty", "Properties", "object", "is", "returned", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/lang/SystemUtil.java#L405-L424
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/StringTokenIterator.java
StringTokenIterator.initMaxDelimiter
private static char initMaxDelimiter(char[] pDelimiters) { if (pDelimiters == null) { return 0; } char max = 0; for (char c : pDelimiters) { if (max < c) { max = c; } } return max; }
java
private static char initMaxDelimiter(char[] pDelimiters) { if (pDelimiters == null) { return 0; } char max = 0; for (char c : pDelimiters) { if (max < c) { max = c; } } return max; }
[ "private", "static", "char", "initMaxDelimiter", "(", "char", "[", "]", "pDelimiters", ")", "{", "if", "(", "pDelimiters", "==", "null", ")", "{", "return", "0", ";", "}", "char", "max", "=", "0", ";", "for", "(", "char", "c", ":", "pDelimiters", ")"...
Returns the highest char in the delimiter set. @param pDelimiters the delimiter set @return the highest char
[ "Returns", "the", "highest", "char", "in", "the", "delimiter", "set", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/StringTokenIterator.java#L169-L182
train
haraldk/TwelveMonkeys
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
PICTImageReader.getPICTFrame
private Rectangle getPICTFrame() throws IOException { if (frame == null) { // Read in header information readPICTHeader(imageInput); if (DEBUG) { System.out.println("Done reading PICT header!"); } } return frame; }
java
private Rectangle getPICTFrame() throws IOException { if (frame == null) { // Read in header information readPICTHeader(imageInput); if (DEBUG) { System.out.println("Done reading PICT header!"); } } return frame; }
[ "private", "Rectangle", "getPICTFrame", "(", ")", "throws", "IOException", "{", "if", "(", "frame", "==", "null", ")", "{", "// Read in header information", "readPICTHeader", "(", "imageInput", ")", ";", "if", "(", "DEBUG", ")", "{", "System", ".", "out", "....
Open and read the frame size of the PICT file. @return return the PICT frame @throws IOException if an I/O error occurs while reading the image.
[ "Open", "and", "read", "the", "frame", "size", "of", "the", "PICT", "file", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java#L150-L161
train
haraldk/TwelveMonkeys
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
PICTImageReader.readPICTHeader
private void readPICTHeader(final ImageInputStream pStream) throws IOException { pStream.seek(0l); try { readPICTHeader0(pStream); } catch (IIOException e) { // Rest and try again pStream.seek(0l); // Skip first 512 bytes PICTImageReaderSpi.skipNullHeader(pStream); readPICTHeader0(pStream); } }
java
private void readPICTHeader(final ImageInputStream pStream) throws IOException { pStream.seek(0l); try { readPICTHeader0(pStream); } catch (IIOException e) { // Rest and try again pStream.seek(0l); // Skip first 512 bytes PICTImageReaderSpi.skipNullHeader(pStream); readPICTHeader0(pStream); } }
[ "private", "void", "readPICTHeader", "(", "final", "ImageInputStream", "pStream", ")", "throws", "IOException", "{", "pStream", ".", "seek", "(", "0l", ")", ";", "try", "{", "readPICTHeader0", "(", "pStream", ")", ";", "}", "catch", "(", "IIOException", "e",...
Read the PICT header. The information read is shown on stdout if "DEBUG" is true. @param pStream the stream to read from @throws IOException if an I/O error occurs while reading the image.
[ "Read", "the", "PICT", "header", ".", "The", "information", "read", "is", "shown", "on", "stdout", "if", "DEBUG", "is", "true", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java#L170-L184
train
haraldk/TwelveMonkeys
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
PICTImageReader.readRectangle
private void readRectangle(DataInput pStream, Rectangle pDestRect) throws IOException { int y = pStream.readUnsignedShort(); int x = pStream.readUnsignedShort(); int h = pStream.readUnsignedShort(); int w = pStream.readUnsignedShort(); pDestRect.setLocation(getXPtCoord(x), getYPtCoord(y)); pDestRect.setSize(getXPtCoord(w - x), getYPtCoord(h - y)); }
java
private void readRectangle(DataInput pStream, Rectangle pDestRect) throws IOException { int y = pStream.readUnsignedShort(); int x = pStream.readUnsignedShort(); int h = pStream.readUnsignedShort(); int w = pStream.readUnsignedShort(); pDestRect.setLocation(getXPtCoord(x), getYPtCoord(y)); pDestRect.setSize(getXPtCoord(w - x), getYPtCoord(h - y)); }
[ "private", "void", "readRectangle", "(", "DataInput", "pStream", ",", "Rectangle", "pDestRect", ")", "throws", "IOException", "{", "int", "y", "=", "pStream", ".", "readUnsignedShort", "(", ")", ";", "int", "x", "=", "pStream", ".", "readUnsignedShort", "(", ...
Reads the rectangle location and size from an 8-byte rectangle stream. @param pStream the stream to read from @param pDestRect the rectangle to read into @throws NullPointerException if {@code pDestRect} is {@code null} @throws IOException if an I/O error occurs while reading the image.
[ "Reads", "the", "rectangle", "location", "and", "size", "from", "an", "8", "-", "byte", "rectangle", "stream", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java#L2366-L2374
train
haraldk/TwelveMonkeys
imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java
PICTImageReader.readPoly
private Polygon readPoly(DataInput pStream, Rectangle pBounds) throws IOException { // Get polygon data size int size = pStream.readUnsignedShort(); // Get poly bounds readRectangle(pStream, pBounds); // Initialize the point array to the right size int points = (size - 10) / 4; // Get the rest of the polygon points Polygon polygon = new Polygon(); for (int i = 0; i < points; i++) { int y = getYPtCoord(pStream.readShort()); int x = getXPtCoord(pStream.readShort()); polygon.addPoint(x, y); } if (!pBounds.contains(polygon.getBounds())) { processWarningOccurred("Bad poly, contains point(s) out of bounds " + pBounds + ": " + polygon); } return polygon; }
java
private Polygon readPoly(DataInput pStream, Rectangle pBounds) throws IOException { // Get polygon data size int size = pStream.readUnsignedShort(); // Get poly bounds readRectangle(pStream, pBounds); // Initialize the point array to the right size int points = (size - 10) / 4; // Get the rest of the polygon points Polygon polygon = new Polygon(); for (int i = 0; i < points; i++) { int y = getYPtCoord(pStream.readShort()); int x = getXPtCoord(pStream.readShort()); polygon.addPoint(x, y); } if (!pBounds.contains(polygon.getBounds())) { processWarningOccurred("Bad poly, contains point(s) out of bounds " + pBounds + ": " + polygon); } return polygon; }
[ "private", "Polygon", "readPoly", "(", "DataInput", "pStream", ",", "Rectangle", "pBounds", ")", "throws", "IOException", "{", "// Get polygon data size", "int", "size", "=", "pStream", ".", "readUnsignedShort", "(", ")", ";", "// Get poly bounds", "readRectangle", ...
Read in a polygon. The input stream should be positioned at the first byte of the polygon. @param pStream the stream to read from @param pBounds the bounds rectangle to read into @return the polygon @throws IOException if an I/O error occurs while reading the image.
[ "Read", "in", "a", "polygon", ".", "The", "input", "stream", "should", "be", "positioned", "at", "the", "first", "byte", "of", "the", "polygon", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTImageReader.java#L2452-L2476
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java
ThrottleFilter.setMaxConcurrentThreadCount
public void setMaxConcurrentThreadCount(String pMaxConcurrentThreadCount) { if (!StringUtil.isEmpty(pMaxConcurrentThreadCount)) { try { maxConcurrentThreadCount = Integer.parseInt(pMaxConcurrentThreadCount); } catch (NumberFormatException nfe) { // Use default } } }
java
public void setMaxConcurrentThreadCount(String pMaxConcurrentThreadCount) { if (!StringUtil.isEmpty(pMaxConcurrentThreadCount)) { try { maxConcurrentThreadCount = Integer.parseInt(pMaxConcurrentThreadCount); } catch (NumberFormatException nfe) { // Use default } } }
[ "public", "void", "setMaxConcurrentThreadCount", "(", "String", "pMaxConcurrentThreadCount", ")", "{", "if", "(", "!", "StringUtil", ".", "isEmpty", "(", "pMaxConcurrentThreadCount", ")", ")", "{", "try", "{", "maxConcurrentThreadCount", "=", "Integer", ".", "parseI...
Sets the minimum free thread count. @param pMaxConcurrentThreadCount
[ "Sets", "the", "minimum", "free", "thread", "count", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java#L109-L118
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java
ThrottleFilter.getContentType
private String getContentType(HttpServletRequest pRequest) { if (responseMessageTypes != null) { String accept = pRequest.getHeader("Accept"); for (String type : responseMessageTypes) { // Note: This is not 100% correct way of doing content negotiation // But we just want a compatible result, quick, so this is okay if (StringUtil.contains(accept, type)) { return type; } } } // If none found, return default return DEFAULT_TYPE; }
java
private String getContentType(HttpServletRequest pRequest) { if (responseMessageTypes != null) { String accept = pRequest.getHeader("Accept"); for (String type : responseMessageTypes) { // Note: This is not 100% correct way of doing content negotiation // But we just want a compatible result, quick, so this is okay if (StringUtil.contains(accept, type)) { return type; } } } // If none found, return default return DEFAULT_TYPE; }
[ "private", "String", "getContentType", "(", "HttpServletRequest", "pRequest", ")", "{", "if", "(", "responseMessageTypes", "!=", "null", ")", "{", "String", "accept", "=", "pRequest", ".", "getHeader", "(", "\"Accept\"", ")", ";", "for", "(", "String", "type",...
Gets the content type for the response, suitable for the requesting user agent. @param pRequest @return the content type
[ "Gets", "the", "content", "type", "for", "the", "response", "suitable", "for", "the", "requesting", "user", "agent", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java#L222-L237
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java
ThrottleFilter.getMessage
private String getMessage(String pContentType) { String fileName = responseMessageNames.get(pContentType); // Get cached value CacheEntry entry = responseCache.get(fileName); if ((entry == null) || entry.isExpired()) { // Create and add or replace cached value entry = new CacheEntry(readMessage(fileName)); responseCache.put(fileName, entry); } // Return value return (entry.getValue() != null) ? (String) entry.getValue() : DEFUALT_RESPONSE_MESSAGE; }
java
private String getMessage(String pContentType) { String fileName = responseMessageNames.get(pContentType); // Get cached value CacheEntry entry = responseCache.get(fileName); if ((entry == null) || entry.isExpired()) { // Create and add or replace cached value entry = new CacheEntry(readMessage(fileName)); responseCache.put(fileName, entry); } // Return value return (entry.getValue() != null) ? (String) entry.getValue() : DEFUALT_RESPONSE_MESSAGE; }
[ "private", "String", "getMessage", "(", "String", "pContentType", ")", "{", "String", "fileName", "=", "responseMessageNames", ".", "get", "(", "pContentType", ")", ";", "// Get cached value\r", "CacheEntry", "entry", "=", "responseCache", ".", "get", "(", "fileNa...
Gets the response message for the given content type. @param pContentType @return the message
[ "Gets", "the", "response", "message", "for", "the", "given", "content", "type", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java#L245-L262
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java
ThrottleFilter.readMessage
private String readMessage(String pFileName) { try { // Read resource from web app InputStream is = getServletContext().getResourceAsStream(pFileName); if (is != null) { return new String(FileUtil.read(is)); } else { log("File not found: " + pFileName); } } catch (IOException ioe) { log("Error reading file: " + pFileName + " (" + ioe.getMessage() + ")"); } return null; }
java
private String readMessage(String pFileName) { try { // Read resource from web app InputStream is = getServletContext().getResourceAsStream(pFileName); if (is != null) { return new String(FileUtil.read(is)); } else { log("File not found: " + pFileName); } } catch (IOException ioe) { log("Error reading file: " + pFileName + " (" + ioe.getMessage() + ")"); } return null; }
[ "private", "String", "readMessage", "(", "String", "pFileName", ")", "{", "try", "{", "// Read resource from web app\r", "InputStream", "is", "=", "getServletContext", "(", ")", ".", "getResourceAsStream", "(", "pFileName", ")", ";", "if", "(", "is", "!=", "null...
Reads the response message from a file in the current web app. @param pFileName @return the message
[ "Reads", "the", "response", "message", "from", "a", "file", "in", "the", "current", "web", "app", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/ThrottleFilter.java#L270-L286
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/cache/CacheFilter.java
CacheFilter.init
public void init() throws ServletException { FilterConfig config = getFilterConfig(); // Default don't delete cache files on exit (persistent cache) boolean deleteCacheOnExit = "TRUE".equalsIgnoreCase(config.getInitParameter("deleteCacheOnExit")); // Default expiry time 10 minutes int expiryTime = 10 * 60 * 1000; String expiryTimeStr = config.getInitParameter("expiryTime"); if (!StringUtil.isEmpty(expiryTimeStr)) { try { // TODO: This is insane.. :-P Let the expiry time be in minutes or seconds.. expiryTime = Integer.parseInt(expiryTimeStr); } catch (NumberFormatException e) { throw new ServletConfigException("Could not parse expiryTime: " + e.toString(), e); } } // Default max mem cache size 10 MB int memCacheSize = 10; String memCacheSizeStr = config.getInitParameter("memCacheSize"); if (!StringUtil.isEmpty(memCacheSizeStr)) { try { memCacheSize = Integer.parseInt(memCacheSizeStr); } catch (NumberFormatException e) { throw new ServletConfigException("Could not parse memCacheSize: " + e.toString(), e); } } int maxCachedEntites = 10000; try { cache = new HTTPCache( getTempFolder(), expiryTime, memCacheSize * 1024 * 1024, maxCachedEntites, deleteCacheOnExit, new ServletContextLoggerAdapter(getFilterName(), getServletContext()) ) { @Override protected File getRealFile(CacheRequest pRequest) { String contextRelativeURI = ServletUtil.getContextRelativeURI(((ServletCacheRequest) pRequest).getRequest()); String path = getServletContext().getRealPath(contextRelativeURI); if (path != null) { return new File(path); } return null; } }; log("Created cache: " + cache); } catch (IllegalArgumentException e) { throw new ServletConfigException("Could not create cache: " + e.toString(), e); } }
java
public void init() throws ServletException { FilterConfig config = getFilterConfig(); // Default don't delete cache files on exit (persistent cache) boolean deleteCacheOnExit = "TRUE".equalsIgnoreCase(config.getInitParameter("deleteCacheOnExit")); // Default expiry time 10 minutes int expiryTime = 10 * 60 * 1000; String expiryTimeStr = config.getInitParameter("expiryTime"); if (!StringUtil.isEmpty(expiryTimeStr)) { try { // TODO: This is insane.. :-P Let the expiry time be in minutes or seconds.. expiryTime = Integer.parseInt(expiryTimeStr); } catch (NumberFormatException e) { throw new ServletConfigException("Could not parse expiryTime: " + e.toString(), e); } } // Default max mem cache size 10 MB int memCacheSize = 10; String memCacheSizeStr = config.getInitParameter("memCacheSize"); if (!StringUtil.isEmpty(memCacheSizeStr)) { try { memCacheSize = Integer.parseInt(memCacheSizeStr); } catch (NumberFormatException e) { throw new ServletConfigException("Could not parse memCacheSize: " + e.toString(), e); } } int maxCachedEntites = 10000; try { cache = new HTTPCache( getTempFolder(), expiryTime, memCacheSize * 1024 * 1024, maxCachedEntites, deleteCacheOnExit, new ServletContextLoggerAdapter(getFilterName(), getServletContext()) ) { @Override protected File getRealFile(CacheRequest pRequest) { String contextRelativeURI = ServletUtil.getContextRelativeURI(((ServletCacheRequest) pRequest).getRequest()); String path = getServletContext().getRealPath(contextRelativeURI); if (path != null) { return new File(path); } return null; } }; log("Created cache: " + cache); } catch (IllegalArgumentException e) { throw new ServletConfigException("Could not create cache: " + e.toString(), e); } }
[ "public", "void", "init", "(", ")", "throws", "ServletException", "{", "FilterConfig", "config", "=", "getFilterConfig", "(", ")", ";", "// Default don't delete cache files on exit (persistent cache)\r", "boolean", "deleteCacheOnExit", "=", "\"TRUE\"", ".", "equalsIgnoreCas...
Initializes the filter @throws javax.servlet.ServletException
[ "Initializes", "the", "filter" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/cache/CacheFilter.java#L69-L131
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/AbstractDecoratedMap.java
AbstractDecoratedMap.removeEntry
protected Entry<K, V> removeEntry(Entry<K, V> pEntry) { if (pEntry == null) { return null; } // Find candidate entry for this key Entry<K, V> candidate = getEntry(pEntry.getKey()); if (candidate == pEntry || (candidate != null && candidate.equals(pEntry))) { // Remove remove(pEntry.getKey()); return pEntry; } return null; }
java
protected Entry<K, V> removeEntry(Entry<K, V> pEntry) { if (pEntry == null) { return null; } // Find candidate entry for this key Entry<K, V> candidate = getEntry(pEntry.getKey()); if (candidate == pEntry || (candidate != null && candidate.equals(pEntry))) { // Remove remove(pEntry.getKey()); return pEntry; } return null; }
[ "protected", "Entry", "<", "K", ",", "V", ">", "removeEntry", "(", "Entry", "<", "K", ",", "V", ">", "pEntry", ")", "{", "if", "(", "pEntry", "==", "null", ")", "{", "return", "null", ";", "}", "// Find candidate entry for this key\r", "Entry", "<", "K...
Removes the given entry from the Map. @param pEntry the entry to be removed @return the removed entry, or {@code null} if nothing was removed.
[ "Removes", "the", "given", "entry", "from", "the", "Map", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/AbstractDecoratedMap.java#L232-L245
train
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java
ExTagSupport.writeHtml
public void writeHtml(JspWriter pOut, String pHtml) throws IOException { StringTokenizer parser = new StringTokenizer(pHtml, "<>&", true); while (parser.hasMoreTokens()) { String token = parser.nextToken(); if (token.equals("<")) { pOut.print("&lt;"); } else if (token.equals(">")) { pOut.print("&gt;"); } else if (token.equals("&")) { pOut.print("&amp;"); } else { pOut.print(token); } } }
java
public void writeHtml(JspWriter pOut, String pHtml) throws IOException { StringTokenizer parser = new StringTokenizer(pHtml, "<>&", true); while (parser.hasMoreTokens()) { String token = parser.nextToken(); if (token.equals("<")) { pOut.print("&lt;"); } else if (token.equals(">")) { pOut.print("&gt;"); } else if (token.equals("&")) { pOut.print("&amp;"); } else { pOut.print(token); } } }
[ "public", "void", "writeHtml", "(", "JspWriter", "pOut", ",", "String", "pHtml", ")", "throws", "IOException", "{", "StringTokenizer", "parser", "=", "new", "StringTokenizer", "(", "pHtml", ",", "\"<>&\"", ",", "true", ")", ";", "while", "(", "parser", ".", ...
writeHtml ensures that the text being outputted appears as it was entered. This prevents users from hacking the system by entering html or jsp code into an entry form where that value will be displayed later in the site. @param pOut The JspWriter to write the output to. @param pHtml The original html to filter and output to the user. @throws IOException If the user clicks Stop in the browser, or their browser crashes, then the JspWriter will throw an IOException when the jsp tries to write to it.
[ "writeHtml", "ensures", "that", "the", "text", "being", "outputted", "appears", "as", "it", "was", "entered", ".", "This", "prevents", "users", "from", "hacking", "the", "system", "by", "entering", "html", "or", "jsp", "code", "into", "an", "entry", "form", ...
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java#L56-L75
train
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java
ExTagSupport.getInitParameter
public String getInitParameter(String pName, int pScope) { switch (pScope) { case PageContext.PAGE_SCOPE: return getServletConfig().getInitParameter(pName); case PageContext.APPLICATION_SCOPE: return getServletContext().getInitParameter(pName); default: throw new IllegalArgumentException("Illegal scope."); } }
java
public String getInitParameter(String pName, int pScope) { switch (pScope) { case PageContext.PAGE_SCOPE: return getServletConfig().getInitParameter(pName); case PageContext.APPLICATION_SCOPE: return getServletContext().getInitParameter(pName); default: throw new IllegalArgumentException("Illegal scope."); } }
[ "public", "String", "getInitParameter", "(", "String", "pName", ",", "int", "pScope", ")", "{", "switch", "(", "pScope", ")", "{", "case", "PageContext", ".", "PAGE_SCOPE", ":", "return", "getServletConfig", "(", ")", ".", "getInitParameter", "(", "pName", "...
Returns the initialisation parameter from the scope specified with the name specified. @param pName The name of the initialisation parameter to return the value for. @param pScope The scope to search for the initialisation parameter within. @return The value of the parameter found. If no parameter with the name specified is found in the scope specified, then {@code null } is returned.
[ "Returns", "the", "initialisation", "parameter", "from", "the", "scope", "specified", "with", "the", "name", "specified", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java#L211-L220
train
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java
ExTagSupport.getInitParameterNames
public Enumeration getInitParameterNames(int pScope) { switch (pScope) { case PageContext.PAGE_SCOPE: return getServletConfig().getInitParameterNames(); case PageContext.APPLICATION_SCOPE: return getServletContext().getInitParameterNames(); default: throw new IllegalArgumentException("Illegal scope"); } }
java
public Enumeration getInitParameterNames(int pScope) { switch (pScope) { case PageContext.PAGE_SCOPE: return getServletConfig().getInitParameterNames(); case PageContext.APPLICATION_SCOPE: return getServletContext().getInitParameterNames(); default: throw new IllegalArgumentException("Illegal scope"); } }
[ "public", "Enumeration", "getInitParameterNames", "(", "int", "pScope", ")", "{", "switch", "(", "pScope", ")", "{", "case", "PageContext", ".", "PAGE_SCOPE", ":", "return", "getServletConfig", "(", ")", ".", "getInitParameterNames", "(", ")", ";", "case", "Pa...
Returns an enumeration containing all the parameters defined in the scope specified by the parameter. @param pScope The scope to return the names of all the parameters defined within. @return An {@code Enumeration} containing all the names for all the parameters defined in the scope passed in as a parameter.
[ "Returns", "an", "enumeration", "containing", "all", "the", "parameters", "defined", "in", "the", "scope", "specified", "by", "the", "parameter", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java#L232-L241
train
haraldk/TwelveMonkeys
sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java
ExTagSupport.getResourceAsStream
public InputStream getResourceAsStream(String pPath) { //throws MalformedURLException { String path = pPath; if (pPath != null && !pPath.startsWith("/")) { path = getContextPath() + pPath; } return pageContext.getServletContext().getResourceAsStream(path); }
java
public InputStream getResourceAsStream(String pPath) { //throws MalformedURLException { String path = pPath; if (pPath != null && !pPath.startsWith("/")) { path = getContextPath() + pPath; } return pageContext.getServletContext().getResourceAsStream(path); }
[ "public", "InputStream", "getResourceAsStream", "(", "String", "pPath", ")", "{", "//throws MalformedURLException {\r", "String", "path", "=", "pPath", ";", "if", "(", "pPath", "!=", "null", "&&", "!", "pPath", ".", "startsWith", "(", "\"/\"", ")", ")", "{", ...
Gets the resource associated with the given relative path for the current JSP page request. The path may be absolute, or relative to the current context root. @param pPath the path @return a path relative to the current context root
[ "Gets", "the", "resource", "associated", "with", "the", "given", "relative", "path", "for", "the", "current", "JSP", "page", "request", ".", "The", "path", "may", "be", "absolute", "or", "relative", "to", "the", "current", "context", "root", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-servlet/src/main/java/com/twelvemonkeys/servlet/jsp/taglib/ExTagSupport.java#L281-L290
train
haraldk/TwelveMonkeys
imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java
ColorSpaces.isCS_sRGB
public static boolean isCS_sRGB(final ICC_Profile profile) { Validate.notNull(profile, "profile"); return profile.getColorSpaceType() == ColorSpace.TYPE_RGB && Arrays.equals(getProfileHeaderWithProfileId(profile), sRGB.header); }
java
public static boolean isCS_sRGB(final ICC_Profile profile) { Validate.notNull(profile, "profile"); return profile.getColorSpaceType() == ColorSpace.TYPE_RGB && Arrays.equals(getProfileHeaderWithProfileId(profile), sRGB.header); }
[ "public", "static", "boolean", "isCS_sRGB", "(", "final", "ICC_Profile", "profile", ")", "{", "Validate", ".", "notNull", "(", "profile", ",", "\"profile\"", ")", ";", "return", "profile", ".", "getColorSpaceType", "(", ")", "==", "ColorSpace", ".", "TYPE_RGB"...
Tests whether an ICC color profile is equal to the default sRGB profile. @param profile the ICC profile to test. May not be {@code null}. @return {@code true} if {@code profile} is equal to the default sRGB profile. @throws IllegalArgumentException if {@code profile} is {@code null} @see java.awt.color.ColorSpace#isCS_sRGB()
[ "Tests", "whether", "an", "ICC", "color", "profile", "is", "equal", "to", "the", "default", "sRGB", "profile", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-core/src/main/java/com/twelvemonkeys/imageio/color/ColorSpaces.java#L236-L240
train
haraldk/TwelveMonkeys
common/common-lang/src/main/java/com/twelvemonkeys/util/convert/DateConverter.java
DateConverter.toObject
public Object toObject(String pString, Class pType, String pFormat) throws ConversionException { if (StringUtil.isEmpty(pString)) return null; try { DateFormat format; if (pFormat == null) { // Use system default format, using default locale format = DateFormat.getDateTimeInstance(); } else { // Get format from cache format = getDateFormat(pFormat); } Date date = StringUtil.toDate(pString, format); // Allow for conversion to Date subclasses (ie. java.sql.*) if (pType != Date.class) { try { date = (Date) BeanUtil.createInstance(pType, new Long(date.getTime())); } catch (ClassCastException e) { throw new TypeMismathException(pType); } catch (InvocationTargetException e) { throw new ConversionException(e); } } return date; } catch (RuntimeException rte) { throw new ConversionException(rte); } }
java
public Object toObject(String pString, Class pType, String pFormat) throws ConversionException { if (StringUtil.isEmpty(pString)) return null; try { DateFormat format; if (pFormat == null) { // Use system default format, using default locale format = DateFormat.getDateTimeInstance(); } else { // Get format from cache format = getDateFormat(pFormat); } Date date = StringUtil.toDate(pString, format); // Allow for conversion to Date subclasses (ie. java.sql.*) if (pType != Date.class) { try { date = (Date) BeanUtil.createInstance(pType, new Long(date.getTime())); } catch (ClassCastException e) { throw new TypeMismathException(pType); } catch (InvocationTargetException e) { throw new ConversionException(e); } } return date; } catch (RuntimeException rte) { throw new ConversionException(rte); } }
[ "public", "Object", "toObject", "(", "String", "pString", ",", "Class", "pType", ",", "String", "pFormat", ")", "throws", "ConversionException", "{", "if", "(", "StringUtil", ".", "isEmpty", "(", "pString", ")", ")", "return", "null", ";", "try", "{", "Dat...
Converts the string to a date, using the given format for parsing. @param pString the string to convert. @param pType the type to convert to. {@code java.util.Date} and subclasses allowed. @param pFormat the format used for parsing. Must be a legal {@code SimpleDateFormat} format, or {@code null} which will use the default format. @return the object created from the given string. May safely be typecast to {@code java.util.Date} @see Date @see java.text.DateFormat @throws ConversionException
[ "Converts", "the", "string", "to", "a", "date", "using", "the", "given", "format", "for", "parsing", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-lang/src/main/java/com/twelvemonkeys/util/convert/DateConverter.java#L76-L112
train
haraldk/TwelveMonkeys
common/common-image/src/main/java/com/twelvemonkeys/image/DiffusionDither.java
DiffusionDither.toRGBArray
private static int[] toRGBArray(int pARGB, int[] pBuffer) { pBuffer[0] = ((pARGB & 0x00ff0000) >> 16); pBuffer[1] = ((pARGB & 0x0000ff00) >> 8); pBuffer[2] = ((pARGB & 0x000000ff)); //pBuffer[3] = ((pARGB & 0xff000000) >> 24); // alpha return pBuffer; }
java
private static int[] toRGBArray(int pARGB, int[] pBuffer) { pBuffer[0] = ((pARGB & 0x00ff0000) >> 16); pBuffer[1] = ((pARGB & 0x0000ff00) >> 8); pBuffer[2] = ((pARGB & 0x000000ff)); //pBuffer[3] = ((pARGB & 0xff000000) >> 24); // alpha return pBuffer; }
[ "private", "static", "int", "[", "]", "toRGBArray", "(", "int", "pARGB", ",", "int", "[", "]", "pBuffer", ")", "{", "pBuffer", "[", "0", "]", "=", "(", "(", "pARGB", "&", "0x00ff0000", ")", ">>", "16", ")", ";", "pBuffer", "[", "1", "]", "=", "...
Converts an int ARGB to int triplet.
[ "Converts", "an", "int", "ARGB", "to", "int", "triplet", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/DiffusionDither.java#L215-L222
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/image/ScaleFilter.java
ScaleFilter.doFilter
protected RenderedImage doFilter(BufferedImage pImage, ServletRequest pRequest, ImageServletResponse pResponse) { // Get quality setting // SMOOTH | FAST | REPLICATE | DEFAULT | AREA_AVERAGING // See Image (mHints) int quality = getQuality(pRequest.getParameter(PARAM_SCALE_QUALITY)); // Get units, default is pixels // PIXELS | PERCENT | METRIC | INCHES int units = getUnits(pRequest.getParameter(PARAM_SCALE_UNITS)); if (units == UNITS_UNKNOWN) { log("Unknown units for scale, returning original."); return pImage; } // Use uniform scaling? Default is true boolean uniformScale = ServletUtil.getBooleanParameter(pRequest, PARAM_SCALE_UNIFORM, true); // Get dimensions int width = ServletUtil.getIntParameter(pRequest, PARAM_SCALE_X, -1); int height = ServletUtil.getIntParameter(pRequest, PARAM_SCALE_Y, -1); // Get dimensions for scaled image Dimension dim = getDimensions(pImage, width, height, units, uniformScale); width = (int) dim.getWidth(); height = (int) dim.getHeight(); // Return scaled instance directly return ImageUtil.createScaled(pImage, width, height, quality); }
java
protected RenderedImage doFilter(BufferedImage pImage, ServletRequest pRequest, ImageServletResponse pResponse) { // Get quality setting // SMOOTH | FAST | REPLICATE | DEFAULT | AREA_AVERAGING // See Image (mHints) int quality = getQuality(pRequest.getParameter(PARAM_SCALE_QUALITY)); // Get units, default is pixels // PIXELS | PERCENT | METRIC | INCHES int units = getUnits(pRequest.getParameter(PARAM_SCALE_UNITS)); if (units == UNITS_UNKNOWN) { log("Unknown units for scale, returning original."); return pImage; } // Use uniform scaling? Default is true boolean uniformScale = ServletUtil.getBooleanParameter(pRequest, PARAM_SCALE_UNIFORM, true); // Get dimensions int width = ServletUtil.getIntParameter(pRequest, PARAM_SCALE_X, -1); int height = ServletUtil.getIntParameter(pRequest, PARAM_SCALE_Y, -1); // Get dimensions for scaled image Dimension dim = getDimensions(pImage, width, height, units, uniformScale); width = (int) dim.getWidth(); height = (int) dim.getHeight(); // Return scaled instance directly return ImageUtil.createScaled(pImage, width, height, quality); }
[ "protected", "RenderedImage", "doFilter", "(", "BufferedImage", "pImage", ",", "ServletRequest", "pRequest", ",", "ImageServletResponse", "pResponse", ")", "{", "// Get quality setting\r", "// SMOOTH | FAST | REPLICATE | DEFAULT | AREA_AVERAGING\r", "// See Image (mHints)\r", "int"...
Reads the image from the requested URL, scales it, and returns it in the Servlet stream. See above for details on parameters.
[ "Reads", "the", "image", "from", "the", "requested", "URL", "scales", "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/ScaleFilter.java#L134-L164
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/image/ScaleFilter.java
ScaleFilter.getQuality
protected int getQuality(String pQualityStr) { if (!StringUtil.isEmpty(pQualityStr)) { try { // Get quality constant from Image using reflection Class cl = Image.class; Field field = cl.getField(pQualityStr.toUpperCase()); return field.getInt(null); } catch (IllegalAccessException ia) { log("Unable to get quality.", ia); } catch (NoSuchFieldException nsf) { log("Unable to get quality.", nsf); } } return defaultScaleQuality; }
java
protected int getQuality(String pQualityStr) { if (!StringUtil.isEmpty(pQualityStr)) { try { // Get quality constant from Image using reflection Class cl = Image.class; Field field = cl.getField(pQualityStr.toUpperCase()); return field.getInt(null); } catch (IllegalAccessException ia) { log("Unable to get quality.", ia); } catch (NoSuchFieldException nsf) { log("Unable to get quality.", nsf); } } return defaultScaleQuality; }
[ "protected", "int", "getQuality", "(", "String", "pQualityStr", ")", "{", "if", "(", "!", "StringUtil", ".", "isEmpty", "(", "pQualityStr", ")", ")", "{", "try", "{", "// Get quality constant from Image using reflection\r", "Class", "cl", "=", "Image", ".", "cla...
Gets the quality constant for the scaling, from the string argument. @param pQualityStr The string representation of the scale quality constant. @return The matching quality constant, or the default quality if none was found. @see java.awt.Image @see java.awt.Image#getScaledInstance(int,int,int)
[ "Gets", "the", "quality", "constant", "for", "the", "scaling", "from", "the", "string", "argument", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/image/ScaleFilter.java#L176-L194
train
haraldk/TwelveMonkeys
servlet/src/main/java/com/twelvemonkeys/servlet/image/ScaleFilter.java
ScaleFilter.getUnits
protected int getUnits(String pUnitStr) { if (StringUtil.isEmpty(pUnitStr) || pUnitStr.equalsIgnoreCase("PIXELS")) { return UNITS_PIXELS; } else if (pUnitStr.equalsIgnoreCase("PERCENT")) { return UNITS_PERCENT; } else { return UNITS_UNKNOWN; } }
java
protected int getUnits(String pUnitStr) { if (StringUtil.isEmpty(pUnitStr) || pUnitStr.equalsIgnoreCase("PIXELS")) { return UNITS_PIXELS; } else if (pUnitStr.equalsIgnoreCase("PERCENT")) { return UNITS_PERCENT; } else { return UNITS_UNKNOWN; } }
[ "protected", "int", "getUnits", "(", "String", "pUnitStr", ")", "{", "if", "(", "StringUtil", ".", "isEmpty", "(", "pUnitStr", ")", "||", "pUnitStr", ".", "equalsIgnoreCase", "(", "\"PIXELS\"", ")", ")", "{", "return", "UNITS_PIXELS", ";", "}", "else", "if...
Gets the units constant for the width and height arguments, from the given string argument. @param pUnitStr The string representation of the units constant, can be one of "PIXELS" or "PERCENT". @return The mathcing units constant, or UNITS_UNKNOWN if none was found.
[ "Gets", "the", "units", "constant", "for", "the", "width", "and", "height", "arguments", "from", "the", "given", "string", "argument", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/servlet/src/main/java/com/twelvemonkeys/servlet/image/ScaleFilter.java#L208-L219
train
haraldk/TwelveMonkeys
imageio/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGLosslessDecoder.java
JPEGLosslessDecoder.getHuffmanValue
private int getHuffmanValue(final int table[], final int temp[], final int index[]) throws IOException { int code, input; final int mask = 0xFFFF; if (index[0] < 8) { temp[0] <<= 8; input = this.input.readUnsignedByte(); if (input == 0xFF) { marker = this.input.readUnsignedByte(); if (marker != 0) { markerIndex = 9; } } temp[0] |= input; } else { index[0] -= 8; } code = table[temp[0] >> index[0]]; if ((code & MSB) != 0) { if (markerIndex != 0) { markerIndex = 0; return 0xFF00 | marker; } temp[0] &= (mask >> (16 - index[0])); temp[0] <<= 8; input = this.input.readUnsignedByte(); if (input == 0xFF) { marker = this.input.readUnsignedByte(); if (marker != 0) { markerIndex = 9; } } temp[0] |= input; code = table[((code & 0xFF) * 256) + (temp[0] >> index[0])]; index[0] += 8; } index[0] += 8 - (code >> 8); if (index[0] < 0) { throw new IIOException("index=" + index[0] + " temp=" + temp[0] + " code=" + code + " in HuffmanValue()"); } if (index[0] < markerIndex) { markerIndex = 0; return 0xFF00 | marker; } temp[0] &= (mask >> (16 - index[0])); return code & 0xFF; }
java
private int getHuffmanValue(final int table[], final int temp[], final int index[]) throws IOException { int code, input; final int mask = 0xFFFF; if (index[0] < 8) { temp[0] <<= 8; input = this.input.readUnsignedByte(); if (input == 0xFF) { marker = this.input.readUnsignedByte(); if (marker != 0) { markerIndex = 9; } } temp[0] |= input; } else { index[0] -= 8; } code = table[temp[0] >> index[0]]; if ((code & MSB) != 0) { if (markerIndex != 0) { markerIndex = 0; return 0xFF00 | marker; } temp[0] &= (mask >> (16 - index[0])); temp[0] <<= 8; input = this.input.readUnsignedByte(); if (input == 0xFF) { marker = this.input.readUnsignedByte(); if (marker != 0) { markerIndex = 9; } } temp[0] |= input; code = table[((code & 0xFF) * 256) + (temp[0] >> index[0])]; index[0] += 8; } index[0] += 8 - (code >> 8); if (index[0] < 0) { throw new IIOException("index=" + index[0] + " temp=" + temp[0] + " code=" + code + " in HuffmanValue()"); } if (index[0] < markerIndex) { markerIndex = 0; return 0xFF00 | marker; } temp[0] &= (mask >> (16 - index[0])); return code & 0xFF; }
[ "private", "int", "getHuffmanValue", "(", "final", "int", "table", "[", "]", ",", "final", "int", "temp", "[", "]", ",", "final", "int", "index", "[", "]", ")", "throws", "IOException", "{", "int", "code", ",", "input", ";", "final", "int", "mask", "...
will not be called
[ "will", "not", "be", "called" ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGLosslessDecoder.java#L548-L604
train
haraldk/TwelveMonkeys
common/common-io/src/main/java/com/twelvemonkeys/io/enc/EncoderStream.java
EncoderStream.write
public void write(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { if (!flushOnWrite && pLength < buffer.remaining()) { // Buffer data buffer.put(pBytes, pOffset, pLength); } else { // Encode data already in the buffer encodeBuffer(); // Encode rest without buffering encoder.encode(out, ByteBuffer.wrap(pBytes, pOffset, pLength)); } }
java
public void write(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { if (!flushOnWrite && pLength < buffer.remaining()) { // Buffer data buffer.put(pBytes, pOffset, pLength); } else { // Encode data already in the buffer encodeBuffer(); // Encode rest without buffering encoder.encode(out, ByteBuffer.wrap(pBytes, pOffset, pLength)); } }
[ "public", "void", "write", "(", "final", "byte", "[", "]", "pBytes", ",", "final", "int", "pOffset", ",", "final", "int", "pLength", ")", "throws", "IOException", "{", "if", "(", "!", "flushOnWrite", "&&", "pLength", "<", "buffer", ".", "remaining", "(",...
tell the EncoderStream how large buffer it prefers...
[ "tell", "the", "EncoderStream", "how", "large", "buffer", "it", "prefers", "..." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-io/src/main/java/com/twelvemonkeys/io/enc/EncoderStream.java#L116-L128
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/NetUtil.java
NetUtil.getURLAndSetAuthorization
private static URL getURLAndSetAuthorization(final String pURL, final Properties pProperties) throws MalformedURLException { String url = pURL; // Split user/password away from url String userPass = null; String protocolPrefix = HTTP; int httpIdx = url.indexOf(HTTPS); if (httpIdx >= 0) { protocolPrefix = HTTPS; url = url.substring(httpIdx + HTTPS.length()); } else { httpIdx = url.indexOf(HTTP); if (httpIdx >= 0) { url = url.substring(httpIdx + HTTP.length()); } } // Get authorization part int atIdx = url.indexOf("@"); if (atIdx >= 0) { userPass = url.substring(0, atIdx); url = url.substring(atIdx + 1); } // Set authorization if user/password is present if (userPass != null) { // System.out.println("Setting password ("+ userPass + ")!"); pProperties.setProperty("Authorization", "Basic " + BASE64.encode(userPass.getBytes())); } // Return URL return new URL(protocolPrefix + url); }
java
private static URL getURLAndSetAuthorization(final String pURL, final Properties pProperties) throws MalformedURLException { String url = pURL; // Split user/password away from url String userPass = null; String protocolPrefix = HTTP; int httpIdx = url.indexOf(HTTPS); if (httpIdx >= 0) { protocolPrefix = HTTPS; url = url.substring(httpIdx + HTTPS.length()); } else { httpIdx = url.indexOf(HTTP); if (httpIdx >= 0) { url = url.substring(httpIdx + HTTP.length()); } } // Get authorization part int atIdx = url.indexOf("@"); if (atIdx >= 0) { userPass = url.substring(0, atIdx); url = url.substring(atIdx + 1); } // Set authorization if user/password is present if (userPass != null) { // System.out.println("Setting password ("+ userPass + ")!"); pProperties.setProperty("Authorization", "Basic " + BASE64.encode(userPass.getBytes())); } // Return URL return new URL(protocolPrefix + url); }
[ "private", "static", "URL", "getURLAndSetAuthorization", "(", "final", "String", "pURL", ",", "final", "Properties", "pProperties", ")", "throws", "MalformedURLException", "{", "String", "url", "=", "pURL", ";", "// Split user/password away from url", "String", "userPas...
Registers the password from the URL string, and returns the URL object. @param pURL the string representation of the URL, possibly including authorization part @param pProperties the @return the URL created from {@code pURL}. @throws java.net.MalformedURLException if there's a syntax error in {@code pURL}
[ "Registers", "the", "password", "from", "the", "URL", "string", "and", "returns", "the", "URL", "object", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/NetUtil.java#L597-L631
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/NetUtil.java
NetUtil.createHttpURLConnection
public static HttpURLConnection createHttpURLConnection(URL pURL, Properties pProperties, boolean pFollowRedirects, int pTimeout) throws IOException { // Open the connection, and get the stream HttpURLConnection conn; if (pTimeout > 0) { // Supports timeout conn = new com.twelvemonkeys.net.HttpURLConnection(pURL, pTimeout); } else { // Faster, more compatible conn = (HttpURLConnection) pURL.openConnection(); } // Set user agent if ((pProperties == null) || !pProperties.containsKey("User-Agent")) { conn.setRequestProperty("User-Agent", VERSION_ID + " (" + System.getProperty("os.name") + "/" + System.getProperty("os.version") + "; " + System.getProperty("os.arch") + "; " + System.getProperty("java.vm.name") + "/" + System.getProperty("java.vm.version") + ")"); } // Set request properties if (pProperties != null) { for (Map.Entry<Object, Object> entry : pProperties.entrySet()) { // Properties key/values can be safely cast to strings conn.setRequestProperty((String) entry.getKey(), entry.getValue().toString()); } } try { // Breaks with JRE1.2? conn.setInstanceFollowRedirects(pFollowRedirects); } catch (LinkageError le) { // This is the best we can do... HttpURLConnection.setFollowRedirects(pFollowRedirects); System.err.println("You are using an old Java Spec, consider upgrading."); System.err.println("java.net.HttpURLConnection.setInstanceFollowRedirects(" + pFollowRedirects + ") failed."); //le.printStackTrace(System.err); } conn.setDoInput(true); conn.setDoOutput(true); //conn.setUseCaches(true); return conn; }
java
public static HttpURLConnection createHttpURLConnection(URL pURL, Properties pProperties, boolean pFollowRedirects, int pTimeout) throws IOException { // Open the connection, and get the stream HttpURLConnection conn; if (pTimeout > 0) { // Supports timeout conn = new com.twelvemonkeys.net.HttpURLConnection(pURL, pTimeout); } else { // Faster, more compatible conn = (HttpURLConnection) pURL.openConnection(); } // Set user agent if ((pProperties == null) || !pProperties.containsKey("User-Agent")) { conn.setRequestProperty("User-Agent", VERSION_ID + " (" + System.getProperty("os.name") + "/" + System.getProperty("os.version") + "; " + System.getProperty("os.arch") + "; " + System.getProperty("java.vm.name") + "/" + System.getProperty("java.vm.version") + ")"); } // Set request properties if (pProperties != null) { for (Map.Entry<Object, Object> entry : pProperties.entrySet()) { // Properties key/values can be safely cast to strings conn.setRequestProperty((String) entry.getKey(), entry.getValue().toString()); } } try { // Breaks with JRE1.2? conn.setInstanceFollowRedirects(pFollowRedirects); } catch (LinkageError le) { // This is the best we can do... HttpURLConnection.setFollowRedirects(pFollowRedirects); System.err.println("You are using an old Java Spec, consider upgrading."); System.err.println("java.net.HttpURLConnection.setInstanceFollowRedirects(" + pFollowRedirects + ") failed."); //le.printStackTrace(System.err); } conn.setDoInput(true); conn.setDoOutput(true); //conn.setUseCaches(true); return conn; }
[ "public", "static", "HttpURLConnection", "createHttpURLConnection", "(", "URL", "pURL", ",", "Properties", "pProperties", ",", "boolean", "pFollowRedirects", ",", "int", "pTimeout", ")", "throws", "IOException", "{", "// Open the connection, and get the stream", "HttpURLCon...
Creates a HTTP connection to the given URL. @param pURL the URL to get. @param pProperties connection properties. @param pFollowRedirects specifies whether we should follow redirects. @param pTimeout the specified timeout, in milliseconds. @return a HttpURLConnection @throws UnknownHostException if the hostname in the URL cannot be found. @throws IOException if an I/O exception occurs.
[ "Creates", "a", "HTTP", "connection", "to", "the", "given", "URL", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/NetUtil.java#L869-L919
train
haraldk/TwelveMonkeys
sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/BASE64.java
BASE64.encode
public static String encode(byte[] pData) { int offset = 0; int len; StringBuilder buf = new StringBuilder(); while ((pData.length - offset) > 0) { byte a, b, c; if ((pData.length - offset) > 2) { len = 3; } else { len = pData.length - offset; } switch (len) { case 1: a = pData[offset]; b = 0; buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]); buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); buf.append('='); buf.append('='); offset++; break; case 2: a = pData[offset]; b = pData[offset + 1]; c = 0; buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]); buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); buf.append(PEM_ARRAY[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); buf.append('='); offset += offset + 2; // ??? break; default: a = pData[offset]; b = pData[offset + 1]; c = pData[offset + 2]; buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]); buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); buf.append(PEM_ARRAY[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); buf.append(PEM_ARRAY[c & 0x3F]); offset = offset + 3; break; } } return buf.toString(); }
java
public static String encode(byte[] pData) { int offset = 0; int len; StringBuilder buf = new StringBuilder(); while ((pData.length - offset) > 0) { byte a, b, c; if ((pData.length - offset) > 2) { len = 3; } else { len = pData.length - offset; } switch (len) { case 1: a = pData[offset]; b = 0; buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]); buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); buf.append('='); buf.append('='); offset++; break; case 2: a = pData[offset]; b = pData[offset + 1]; c = 0; buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]); buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); buf.append(PEM_ARRAY[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); buf.append('='); offset += offset + 2; // ??? break; default: a = pData[offset]; b = pData[offset + 1]; c = pData[offset + 2]; buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]); buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]); buf.append(PEM_ARRAY[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]); buf.append(PEM_ARRAY[c & 0x3F]); offset = offset + 3; break; } } return buf.toString(); }
[ "public", "static", "String", "encode", "(", "byte", "[", "]", "pData", ")", "{", "int", "offset", "=", "0", ";", "int", "len", ";", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "(", "pData", ".", "length", "-", ...
Encodes the input data using the standard base64 encoding scheme. @param pData the bytes to encode to base64 @return a string with base64 encoded data
[ "Encodes", "the", "input", "data", "using", "the", "standard", "base64", "encoding", "scheme", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/net/BASE64.java#L68-L116
train
haraldk/TwelveMonkeys
common/common-image/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java
BufferedImageFactory.setSourceSubsampling
public void setSourceSubsampling(int pXSub, int pYSub) { // Re-fetch everything, if subsampling changed if (xSub != pXSub || ySub != pYSub) { dispose(); } if (pXSub > 1) { xSub = pXSub; } if (pYSub > 1) { ySub = pYSub; } }
java
public void setSourceSubsampling(int pXSub, int pYSub) { // Re-fetch everything, if subsampling changed if (xSub != pXSub || ySub != pYSub) { dispose(); } if (pXSub > 1) { xSub = pXSub; } if (pYSub > 1) { ySub = pYSub; } }
[ "public", "void", "setSourceSubsampling", "(", "int", "pXSub", ",", "int", "pYSub", ")", "{", "// Re-fetch everything, if subsampling changed", "if", "(", "xSub", "!=", "pXSub", "||", "ySub", "!=", "pYSub", ")", "{", "dispose", "(", ")", ";", "}", "if", "(",...
Sets the source subsampling for the new image. @param pXSub horizontal subsampling factor @param pYSub vertical subsampling factor
[ "Sets", "the", "source", "subsampling", "for", "the", "new", "image", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java#L176-L188
train
haraldk/TwelveMonkeys
common/common-image/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java
BufferedImageFactory.addProgressListener
public void addProgressListener(ProgressListener pListener) { if (pListener == null) { return; } if (listeners == null) { listeners = new CopyOnWriteArrayList<ProgressListener>(); } listeners.add(pListener); }
java
public void addProgressListener(ProgressListener pListener) { if (pListener == null) { return; } if (listeners == null) { listeners = new CopyOnWriteArrayList<ProgressListener>(); } listeners.add(pListener); }
[ "public", "void", "addProgressListener", "(", "ProgressListener", "pListener", ")", "{", "if", "(", "pListener", "==", "null", ")", "{", "return", ";", "}", "if", "(", "listeners", "==", "null", ")", "{", "listeners", "=", "new", "CopyOnWriteArrayList", "<",...
Adds a progress listener to this factory. @param pListener the progress listener
[ "Adds", "a", "progress", "listener", "to", "this", "factory", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java#L283-L293
train
haraldk/TwelveMonkeys
common/common-image/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java
BufferedImageFactory.removeProgressListener
public void removeProgressListener(ProgressListener pListener) { if (pListener == null) { return; } if (listeners == null) { return; } listeners.remove(pListener); }
java
public void removeProgressListener(ProgressListener pListener) { if (pListener == null) { return; } if (listeners == null) { return; } listeners.remove(pListener); }
[ "public", "void", "removeProgressListener", "(", "ProgressListener", "pListener", ")", "{", "if", "(", "pListener", "==", "null", ")", "{", "return", ";", "}", "if", "(", "listeners", "==", "null", ")", "{", "return", ";", "}", "listeners", ".", "remove", ...
Removes a progress listener from this factory. @param pListener the progress listener
[ "Removes", "a", "progress", "listener", "from", "this", "factory", "." ]
7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d
https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/BufferedImageFactory.java#L300-L310
train