id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
7,400
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.initializeInitParams
protected void initializeInitParams(Node initParamNode, Map<String, Object> initParameters) { String paramName = null; String paramValue = null; NodeList childNodes = initParamNode.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); String nodeName = childNode.getNodeName(); if (nodeName.equals(PARAM_NAME_TAG_NAME)) { paramName = getTextValue(childNode); } else if (nodeName.equals(PARAM_VALUE_TAG_NAME)) { paramValue = getTextValue(childNode); } } initParameters.put(paramName, paramValue); }
java
protected void initializeInitParams(Node initParamNode, Map<String, Object> initParameters) { String paramName = null; String paramValue = null; NodeList childNodes = initParamNode.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); String nodeName = childNode.getNodeName(); if (nodeName.equals(PARAM_NAME_TAG_NAME)) { paramName = getTextValue(childNode); } else if (nodeName.equals(PARAM_VALUE_TAG_NAME)) { paramValue = getTextValue(childNode); } } initParameters.put(paramName, paramValue); }
[ "protected", "void", "initializeInitParams", "(", "Node", "initParamNode", ",", "Map", "<", "String", ",", "Object", ">", "initParameters", ")", "{", "String", "paramName", "=", "null", ";", "String", "paramValue", "=", "null", ";", "NodeList", "childNodes", "=", "initParamNode", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "childNodes", ".", "getLength", "(", ")", ";", "j", "++", ")", "{", "Node", "childNode", "=", "childNodes", ".", "item", "(", "j", ")", ";", "String", "nodeName", "=", "childNode", ".", "getNodeName", "(", ")", ";", "if", "(", "nodeName", ".", "equals", "(", "PARAM_NAME_TAG_NAME", ")", ")", "{", "paramName", "=", "getTextValue", "(", "childNode", ")", ";", "}", "else", "if", "(", "nodeName", ".", "equals", "(", "PARAM_VALUE_TAG_NAME", ")", ")", "{", "paramValue", "=", "getTextValue", "(", "childNode", ")", ";", "}", "}", "initParameters", ".", "put", "(", "paramName", ",", "paramValue", ")", ";", "}" ]
Initialize the init parameters define in the servlet config @param initParameters the map of initialization parameters
[ "Initialize", "the", "init", "parameters", "define", "in", "the", "servlet", "config" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L528-L546
7,401
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.processJawrServlets
protected void processJawrServlets(String destDirPath, List<ServletDefinition> jawrServletDefinitions, boolean keepUrlMapping) throws Exception { String appRootDir = ""; String jsServletMapping = ""; String cssServletMapping = ""; String binaryServletMapping = ""; for (Iterator<ServletDefinition> iterator = jawrServletDefinitions .iterator(); iterator.hasNext();) { ServletDefinition servletDef = (ServletDefinition) iterator.next(); ServletConfig servletConfig = servletDef.getServletConfig(); // Force the production mode, and remove config listener parameters Map<?, ?> initParameters = ((MockServletConfig) servletConfig) .getInitParameters(); initParameters.remove("jawr.config.reload.interval"); String jawrServletMapping = servletConfig .getInitParameter(JawrConstant.SERVLET_MAPPING_PROPERTY_NAME); String servletMapping = servletConfig .getInitParameter(JawrConstant.SPRING_SERVLET_MAPPING_PROPERTY_NAME); if (servletMapping == null) { servletMapping = jawrServletMapping; } ResourceBundlesHandler bundleHandler = null; BinaryResourcesHandler binaryRsHandler = null; // Retrieve the bundle Handler ServletContext servletContext = servletConfig.getServletContext(); String type = servletConfig.getInitParameter(TYPE_INIT_PARAMETER); if (type == null || type.equals(JawrConstant.JS_TYPE)) { bundleHandler = (ResourceBundlesHandler) servletContext .getAttribute(JawrConstant.JS_CONTEXT_ATTRIBUTE); String contextPathOverride = bundleHandler.getConfig() .getContextPathOverride(); if (StringUtils.isNotEmpty(contextPathOverride)) { int idx = contextPathOverride.indexOf("//"); if (idx != -1) { idx = contextPathOverride.indexOf("/", idx + 2); if (idx != -1) { appRootDir = PathNormalizer .asPath(contextPathOverride.substring(idx)); } } } if (jawrServletMapping != null) { jsServletMapping = PathNormalizer .asPath(jawrServletMapping); } } else if (type.equals(JawrConstant.CSS_TYPE)) { bundleHandler = (ResourceBundlesHandler) servletContext .getAttribute(JawrConstant.CSS_CONTEXT_ATTRIBUTE); if (jawrServletMapping != null) { cssServletMapping = PathNormalizer .asPath(jawrServletMapping); } } else if (type.equals(JawrConstant.BINARY_TYPE)) { binaryRsHandler = (BinaryResourcesHandler) servletContext .getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE); if (jawrServletMapping != null) { binaryServletMapping = PathNormalizer .asPath(jawrServletMapping); } } if (bundleHandler != null) { createBundles(servletDef.getServlet(), bundleHandler, destDirPath, servletMapping, keepUrlMapping); } else if (binaryRsHandler != null) { createBinaryBundle(servletDef.getServlet(), binaryRsHandler, destDirPath, servletConfig, keepUrlMapping); } } // Create the apache rewrite config file. createApacheRewriteConfigFile(destDirPath, appRootDir, jsServletMapping, cssServletMapping, binaryServletMapping); }
java
protected void processJawrServlets(String destDirPath, List<ServletDefinition> jawrServletDefinitions, boolean keepUrlMapping) throws Exception { String appRootDir = ""; String jsServletMapping = ""; String cssServletMapping = ""; String binaryServletMapping = ""; for (Iterator<ServletDefinition> iterator = jawrServletDefinitions .iterator(); iterator.hasNext();) { ServletDefinition servletDef = (ServletDefinition) iterator.next(); ServletConfig servletConfig = servletDef.getServletConfig(); // Force the production mode, and remove config listener parameters Map<?, ?> initParameters = ((MockServletConfig) servletConfig) .getInitParameters(); initParameters.remove("jawr.config.reload.interval"); String jawrServletMapping = servletConfig .getInitParameter(JawrConstant.SERVLET_MAPPING_PROPERTY_NAME); String servletMapping = servletConfig .getInitParameter(JawrConstant.SPRING_SERVLET_MAPPING_PROPERTY_NAME); if (servletMapping == null) { servletMapping = jawrServletMapping; } ResourceBundlesHandler bundleHandler = null; BinaryResourcesHandler binaryRsHandler = null; // Retrieve the bundle Handler ServletContext servletContext = servletConfig.getServletContext(); String type = servletConfig.getInitParameter(TYPE_INIT_PARAMETER); if (type == null || type.equals(JawrConstant.JS_TYPE)) { bundleHandler = (ResourceBundlesHandler) servletContext .getAttribute(JawrConstant.JS_CONTEXT_ATTRIBUTE); String contextPathOverride = bundleHandler.getConfig() .getContextPathOverride(); if (StringUtils.isNotEmpty(contextPathOverride)) { int idx = contextPathOverride.indexOf("//"); if (idx != -1) { idx = contextPathOverride.indexOf("/", idx + 2); if (idx != -1) { appRootDir = PathNormalizer .asPath(contextPathOverride.substring(idx)); } } } if (jawrServletMapping != null) { jsServletMapping = PathNormalizer .asPath(jawrServletMapping); } } else if (type.equals(JawrConstant.CSS_TYPE)) { bundleHandler = (ResourceBundlesHandler) servletContext .getAttribute(JawrConstant.CSS_CONTEXT_ATTRIBUTE); if (jawrServletMapping != null) { cssServletMapping = PathNormalizer .asPath(jawrServletMapping); } } else if (type.equals(JawrConstant.BINARY_TYPE)) { binaryRsHandler = (BinaryResourcesHandler) servletContext .getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE); if (jawrServletMapping != null) { binaryServletMapping = PathNormalizer .asPath(jawrServletMapping); } } if (bundleHandler != null) { createBundles(servletDef.getServlet(), bundleHandler, destDirPath, servletMapping, keepUrlMapping); } else if (binaryRsHandler != null) { createBinaryBundle(servletDef.getServlet(), binaryRsHandler, destDirPath, servletConfig, keepUrlMapping); } } // Create the apache rewrite config file. createApacheRewriteConfigFile(destDirPath, appRootDir, jsServletMapping, cssServletMapping, binaryServletMapping); }
[ "protected", "void", "processJawrServlets", "(", "String", "destDirPath", ",", "List", "<", "ServletDefinition", ">", "jawrServletDefinitions", ",", "boolean", "keepUrlMapping", ")", "throws", "Exception", "{", "String", "appRootDir", "=", "\"\"", ";", "String", "jsServletMapping", "=", "\"\"", ";", "String", "cssServletMapping", "=", "\"\"", ";", "String", "binaryServletMapping", "=", "\"\"", ";", "for", "(", "Iterator", "<", "ServletDefinition", ">", "iterator", "=", "jawrServletDefinitions", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "ServletDefinition", "servletDef", "=", "(", "ServletDefinition", ")", "iterator", ".", "next", "(", ")", ";", "ServletConfig", "servletConfig", "=", "servletDef", ".", "getServletConfig", "(", ")", ";", "// Force the production mode, and remove config listener parameters", "Map", "<", "?", ",", "?", ">", "initParameters", "=", "(", "(", "MockServletConfig", ")", "servletConfig", ")", ".", "getInitParameters", "(", ")", ";", "initParameters", ".", "remove", "(", "\"jawr.config.reload.interval\"", ")", ";", "String", "jawrServletMapping", "=", "servletConfig", ".", "getInitParameter", "(", "JawrConstant", ".", "SERVLET_MAPPING_PROPERTY_NAME", ")", ";", "String", "servletMapping", "=", "servletConfig", ".", "getInitParameter", "(", "JawrConstant", ".", "SPRING_SERVLET_MAPPING_PROPERTY_NAME", ")", ";", "if", "(", "servletMapping", "==", "null", ")", "{", "servletMapping", "=", "jawrServletMapping", ";", "}", "ResourceBundlesHandler", "bundleHandler", "=", "null", ";", "BinaryResourcesHandler", "binaryRsHandler", "=", "null", ";", "// Retrieve the bundle Handler", "ServletContext", "servletContext", "=", "servletConfig", ".", "getServletContext", "(", ")", ";", "String", "type", "=", "servletConfig", ".", "getInitParameter", "(", "TYPE_INIT_PARAMETER", ")", ";", "if", "(", "type", "==", "null", "||", "type", ".", "equals", "(", "JawrConstant", ".", "JS_TYPE", ")", ")", "{", "bundleHandler", "=", "(", "ResourceBundlesHandler", ")", "servletContext", ".", "getAttribute", "(", "JawrConstant", ".", "JS_CONTEXT_ATTRIBUTE", ")", ";", "String", "contextPathOverride", "=", "bundleHandler", ".", "getConfig", "(", ")", ".", "getContextPathOverride", "(", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "contextPathOverride", ")", ")", "{", "int", "idx", "=", "contextPathOverride", ".", "indexOf", "(", "\"//\"", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "idx", "=", "contextPathOverride", ".", "indexOf", "(", "\"/\"", ",", "idx", "+", "2", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "appRootDir", "=", "PathNormalizer", ".", "asPath", "(", "contextPathOverride", ".", "substring", "(", "idx", ")", ")", ";", "}", "}", "}", "if", "(", "jawrServletMapping", "!=", "null", ")", "{", "jsServletMapping", "=", "PathNormalizer", ".", "asPath", "(", "jawrServletMapping", ")", ";", "}", "}", "else", "if", "(", "type", ".", "equals", "(", "JawrConstant", ".", "CSS_TYPE", ")", ")", "{", "bundleHandler", "=", "(", "ResourceBundlesHandler", ")", "servletContext", ".", "getAttribute", "(", "JawrConstant", ".", "CSS_CONTEXT_ATTRIBUTE", ")", ";", "if", "(", "jawrServletMapping", "!=", "null", ")", "{", "cssServletMapping", "=", "PathNormalizer", ".", "asPath", "(", "jawrServletMapping", ")", ";", "}", "}", "else", "if", "(", "type", ".", "equals", "(", "JawrConstant", ".", "BINARY_TYPE", ")", ")", "{", "binaryRsHandler", "=", "(", "BinaryResourcesHandler", ")", "servletContext", ".", "getAttribute", "(", "JawrConstant", ".", "BINARY_CONTEXT_ATTRIBUTE", ")", ";", "if", "(", "jawrServletMapping", "!=", "null", ")", "{", "binaryServletMapping", "=", "PathNormalizer", ".", "asPath", "(", "jawrServletMapping", ")", ";", "}", "}", "if", "(", "bundleHandler", "!=", "null", ")", "{", "createBundles", "(", "servletDef", ".", "getServlet", "(", ")", ",", "bundleHandler", ",", "destDirPath", ",", "servletMapping", ",", "keepUrlMapping", ")", ";", "}", "else", "if", "(", "binaryRsHandler", "!=", "null", ")", "{", "createBinaryBundle", "(", "servletDef", ".", "getServlet", "(", ")", ",", "binaryRsHandler", ",", "destDirPath", ",", "servletConfig", ",", "keepUrlMapping", ")", ";", "}", "}", "// Create the apache rewrite config file.", "createApacheRewriteConfigFile", "(", "destDirPath", ",", "appRootDir", ",", "jsServletMapping", ",", "cssServletMapping", ",", "binaryServletMapping", ")", ";", "}" ]
Process the Jawr Servlets @param destDirPath the destination directory path @param jawrServletDefinitions the destination directory @throws Exception if an exception occurs.
[ "Process", "the", "Jawr", "Servlets" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L569-L653
7,402
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.createApacheRewriteConfigFile
protected void createApacheRewriteConfigFile(String cdnDestDirPath, String appRootDir, String jsServletMapping, String cssServletMapping, String imgServletMapping) throws IOException { BufferedReader templateFileReader = null; FileWriter fileWriter = null; try { templateFileReader = new BufferedReader(new InputStreamReader(this .getClass().getResourceAsStream( TEMPLATE_JAWR_APACHE_HTTPD_CONF_PATH))); fileWriter = new FileWriter(cdnDestDirPath + File.separator + JAWR_APACHE_HTTPD_CONF_FILE); String line = null; boolean processNextString = true; while ((line = templateFileReader.readLine()) != null) { // If the line starts with the condition to check the existence // of the JS servlet mapping, // sets the processNextString flag accordingly if (line.startsWith(CHECKS_JAWR_JS_SERVLET_MAPPING_EXISTS)) { if (StringUtils.isEmpty(jsServletMapping)) { processNextString = false; } // If the line starts with the condition to check the // existence of the servlet mapping, // sets the processNextString flag accordingly } else if (line .startsWith(CHECK_JAWR_CSS_SERVLET_MAPPING_EXISTS)) { if (StringUtils.isEmpty(cssServletMapping)) { processNextString = false; } // If the processNextString flag is set to false, skip the // current line, and process the next one } else if (processNextString == false) { processNextString = true; } else { // Make the replacement line = line.replaceAll(APP_ROOT_DIR_PATTERN, appRootDir); line = line.replaceAll(JAWR_JS_SERVLET_MAPPING_PATTERN, jsServletMapping); line = line.replaceAll(JAWR_CSS_SERVLET_MAPPING_PATTERN, cssServletMapping); line = line.replaceAll(JAWR_IMG_SERVLET_MAPPING_PATTERN, imgServletMapping); fileWriter.write(line + "\n"); } } } finally { IOUtils.close(templateFileReader); IOUtils.close(fileWriter); } }
java
protected void createApacheRewriteConfigFile(String cdnDestDirPath, String appRootDir, String jsServletMapping, String cssServletMapping, String imgServletMapping) throws IOException { BufferedReader templateFileReader = null; FileWriter fileWriter = null; try { templateFileReader = new BufferedReader(new InputStreamReader(this .getClass().getResourceAsStream( TEMPLATE_JAWR_APACHE_HTTPD_CONF_PATH))); fileWriter = new FileWriter(cdnDestDirPath + File.separator + JAWR_APACHE_HTTPD_CONF_FILE); String line = null; boolean processNextString = true; while ((line = templateFileReader.readLine()) != null) { // If the line starts with the condition to check the existence // of the JS servlet mapping, // sets the processNextString flag accordingly if (line.startsWith(CHECKS_JAWR_JS_SERVLET_MAPPING_EXISTS)) { if (StringUtils.isEmpty(jsServletMapping)) { processNextString = false; } // If the line starts with the condition to check the // existence of the servlet mapping, // sets the processNextString flag accordingly } else if (line .startsWith(CHECK_JAWR_CSS_SERVLET_MAPPING_EXISTS)) { if (StringUtils.isEmpty(cssServletMapping)) { processNextString = false; } // If the processNextString flag is set to false, skip the // current line, and process the next one } else if (processNextString == false) { processNextString = true; } else { // Make the replacement line = line.replaceAll(APP_ROOT_DIR_PATTERN, appRootDir); line = line.replaceAll(JAWR_JS_SERVLET_MAPPING_PATTERN, jsServletMapping); line = line.replaceAll(JAWR_CSS_SERVLET_MAPPING_PATTERN, cssServletMapping); line = line.replaceAll(JAWR_IMG_SERVLET_MAPPING_PATTERN, imgServletMapping); fileWriter.write(line + "\n"); } } } finally { IOUtils.close(templateFileReader); IOUtils.close(fileWriter); } }
[ "protected", "void", "createApacheRewriteConfigFile", "(", "String", "cdnDestDirPath", ",", "String", "appRootDir", ",", "String", "jsServletMapping", ",", "String", "cssServletMapping", ",", "String", "imgServletMapping", ")", "throws", "IOException", "{", "BufferedReader", "templateFileReader", "=", "null", ";", "FileWriter", "fileWriter", "=", "null", ";", "try", "{", "templateFileReader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "this", ".", "getClass", "(", ")", ".", "getResourceAsStream", "(", "TEMPLATE_JAWR_APACHE_HTTPD_CONF_PATH", ")", ")", ")", ";", "fileWriter", "=", "new", "FileWriter", "(", "cdnDestDirPath", "+", "File", ".", "separator", "+", "JAWR_APACHE_HTTPD_CONF_FILE", ")", ";", "String", "line", "=", "null", ";", "boolean", "processNextString", "=", "true", ";", "while", "(", "(", "line", "=", "templateFileReader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "// If the line starts with the condition to check the existence", "// of the JS servlet mapping,", "// sets the processNextString flag accordingly", "if", "(", "line", ".", "startsWith", "(", "CHECKS_JAWR_JS_SERVLET_MAPPING_EXISTS", ")", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "jsServletMapping", ")", ")", "{", "processNextString", "=", "false", ";", "}", "// If the line starts with the condition to check the", "// existence of the servlet mapping,", "// sets the processNextString flag accordingly", "}", "else", "if", "(", "line", ".", "startsWith", "(", "CHECK_JAWR_CSS_SERVLET_MAPPING_EXISTS", ")", ")", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "cssServletMapping", ")", ")", "{", "processNextString", "=", "false", ";", "}", "// If the processNextString flag is set to false, skip the", "// current line, and process the next one", "}", "else", "if", "(", "processNextString", "==", "false", ")", "{", "processNextString", "=", "true", ";", "}", "else", "{", "// Make the replacement", "line", "=", "line", ".", "replaceAll", "(", "APP_ROOT_DIR_PATTERN", ",", "appRootDir", ")", ";", "line", "=", "line", ".", "replaceAll", "(", "JAWR_JS_SERVLET_MAPPING_PATTERN", ",", "jsServletMapping", ")", ";", "line", "=", "line", ".", "replaceAll", "(", "JAWR_CSS_SERVLET_MAPPING_PATTERN", ",", "cssServletMapping", ")", ";", "line", "=", "line", ".", "replaceAll", "(", "JAWR_IMG_SERVLET_MAPPING_PATTERN", ",", "imgServletMapping", ")", ";", "fileWriter", ".", "write", "(", "line", "+", "\"\\n\"", ")", ";", "}", "}", "}", "finally", "{", "IOUtils", ".", "close", "(", "templateFileReader", ")", ";", "IOUtils", ".", "close", "(", "fileWriter", ")", ";", "}", "}" ]
Create the apache rewrite configuration file @param cdnDestDirPath the CDN destination directory @param appRootDir the application root dir path in the CDN @param jsServletMapping the JS servlet mapping @param cssServletMapping the CSS servlet mapping @param imgServletMapping the image servlet mapping @throws IOException if an IOException occurs.
[ "Create", "the", "apache", "rewrite", "configuration", "file" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L671-L728
7,403
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.createBundles
protected void createBundles(HttpServlet servlet, ResourceBundlesHandler bundleHandler, String destDirPath, String servletMapping, boolean keepUrlMapping) throws IOException, ServletException { List<JoinableResourceBundle> bundles = bundleHandler .getContextBundles(); Iterator<JoinableResourceBundle> bundleIterator = bundles.iterator(); MockServletResponse response = new MockServletResponse(); MockServletRequest request = new MockServletRequest( JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH); MockServletSession session = new MockServletSession( servlet.getServletContext()); request.setSession(session); String resourceType = servlet.getServletConfig().getInitParameter( TYPE_INIT_PARAMETER); if (resourceType == null) { resourceType = JawrConstant.JS_TYPE; } // For the list of bundle defines, create the file associated while (bundleIterator.hasNext()) { JoinableResourceBundle bundle = (JoinableResourceBundle) bundleIterator .next(); // Check if there is a resource file, which could be in conflict // with the bundle name URL url = servlet.getServletContext().getResource(bundle.getId()); if (url != null) { logger.error("It is not recommended to use a bundle name which could be in conflict with a resource.\n" + "Please rename your bundle '" + bundle.getId() + "' to avoid any issue"); } List<Map<String, String>> allVariants = VariantUtils .getAllVariants(bundle.getVariants()); if (allVariants == null) { allVariants = new ArrayList<Map<String, String>>(); } if (allVariants.isEmpty()) { allVariants.add(new HashMap<String, String>()); } // Creates the bundle file for each local variant for (Iterator<Map<String, String>> it = allVariants.iterator(); it .hasNext();) { Map<String, String> variantMap = (Map<String, String>) it .next(); List<RenderedLink> linksToBundle = createLinkToBundle( bundleHandler, bundle.getId(), resourceType, variantMap); for (Iterator<RenderedLink> iteratorLinks = linksToBundle .iterator(); iteratorLinks.hasNext();) { RenderedLink renderedLink = iteratorLinks.next(); String path = renderedLink.getLink(); // Force the debug mode of the config to match what was used // in the generated link JawrConfig config = bundleHandler.getConfig(); config.setDebugModeOn(renderedLink.isDebugMode()); String finalBundlePath = null; if (keepUrlMapping) { finalBundlePath = path; } else { finalBundlePath = getFinalBundlePath(path, config, variantMap); } // Sets the request URL setRequestUrl(request, variantMap, path, config); // We can't use path for generated resources because it's // not a valid file path ( /jawr_generator.js?xxx.... ) if (!(path.indexOf("?") != -1) || !keepUrlMapping) { File bundleFile = new File(destDirPath, finalBundlePath); createBundleFile(servlet, response, request, path, bundleFile, servletMapping); } } } } }
java
protected void createBundles(HttpServlet servlet, ResourceBundlesHandler bundleHandler, String destDirPath, String servletMapping, boolean keepUrlMapping) throws IOException, ServletException { List<JoinableResourceBundle> bundles = bundleHandler .getContextBundles(); Iterator<JoinableResourceBundle> bundleIterator = bundles.iterator(); MockServletResponse response = new MockServletResponse(); MockServletRequest request = new MockServletRequest( JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH); MockServletSession session = new MockServletSession( servlet.getServletContext()); request.setSession(session); String resourceType = servlet.getServletConfig().getInitParameter( TYPE_INIT_PARAMETER); if (resourceType == null) { resourceType = JawrConstant.JS_TYPE; } // For the list of bundle defines, create the file associated while (bundleIterator.hasNext()) { JoinableResourceBundle bundle = (JoinableResourceBundle) bundleIterator .next(); // Check if there is a resource file, which could be in conflict // with the bundle name URL url = servlet.getServletContext().getResource(bundle.getId()); if (url != null) { logger.error("It is not recommended to use a bundle name which could be in conflict with a resource.\n" + "Please rename your bundle '" + bundle.getId() + "' to avoid any issue"); } List<Map<String, String>> allVariants = VariantUtils .getAllVariants(bundle.getVariants()); if (allVariants == null) { allVariants = new ArrayList<Map<String, String>>(); } if (allVariants.isEmpty()) { allVariants.add(new HashMap<String, String>()); } // Creates the bundle file for each local variant for (Iterator<Map<String, String>> it = allVariants.iterator(); it .hasNext();) { Map<String, String> variantMap = (Map<String, String>) it .next(); List<RenderedLink> linksToBundle = createLinkToBundle( bundleHandler, bundle.getId(), resourceType, variantMap); for (Iterator<RenderedLink> iteratorLinks = linksToBundle .iterator(); iteratorLinks.hasNext();) { RenderedLink renderedLink = iteratorLinks.next(); String path = renderedLink.getLink(); // Force the debug mode of the config to match what was used // in the generated link JawrConfig config = bundleHandler.getConfig(); config.setDebugModeOn(renderedLink.isDebugMode()); String finalBundlePath = null; if (keepUrlMapping) { finalBundlePath = path; } else { finalBundlePath = getFinalBundlePath(path, config, variantMap); } // Sets the request URL setRequestUrl(request, variantMap, path, config); // We can't use path for generated resources because it's // not a valid file path ( /jawr_generator.js?xxx.... ) if (!(path.indexOf("?") != -1) || !keepUrlMapping) { File bundleFile = new File(destDirPath, finalBundlePath); createBundleFile(servlet, response, request, path, bundleFile, servletMapping); } } } } }
[ "protected", "void", "createBundles", "(", "HttpServlet", "servlet", ",", "ResourceBundlesHandler", "bundleHandler", ",", "String", "destDirPath", ",", "String", "servletMapping", ",", "boolean", "keepUrlMapping", ")", "throws", "IOException", ",", "ServletException", "{", "List", "<", "JoinableResourceBundle", ">", "bundles", "=", "bundleHandler", ".", "getContextBundles", "(", ")", ";", "Iterator", "<", "JoinableResourceBundle", ">", "bundleIterator", "=", "bundles", ".", "iterator", "(", ")", ";", "MockServletResponse", "response", "=", "new", "MockServletResponse", "(", ")", ";", "MockServletRequest", "request", "=", "new", "MockServletRequest", "(", "JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH", ")", ";", "MockServletSession", "session", "=", "new", "MockServletSession", "(", "servlet", ".", "getServletContext", "(", ")", ")", ";", "request", ".", "setSession", "(", "session", ")", ";", "String", "resourceType", "=", "servlet", ".", "getServletConfig", "(", ")", ".", "getInitParameter", "(", "TYPE_INIT_PARAMETER", ")", ";", "if", "(", "resourceType", "==", "null", ")", "{", "resourceType", "=", "JawrConstant", ".", "JS_TYPE", ";", "}", "// For the list of bundle defines, create the file associated", "while", "(", "bundleIterator", ".", "hasNext", "(", ")", ")", "{", "JoinableResourceBundle", "bundle", "=", "(", "JoinableResourceBundle", ")", "bundleIterator", ".", "next", "(", ")", ";", "// Check if there is a resource file, which could be in conflict", "// with the bundle name", "URL", "url", "=", "servlet", ".", "getServletContext", "(", ")", ".", "getResource", "(", "bundle", ".", "getId", "(", ")", ")", ";", "if", "(", "url", "!=", "null", ")", "{", "logger", ".", "error", "(", "\"It is not recommended to use a bundle name which could be in conflict with a resource.\\n\"", "+", "\"Please rename your bundle '\"", "+", "bundle", ".", "getId", "(", ")", "+", "\"' to avoid any issue\"", ")", ";", "}", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "allVariants", "=", "VariantUtils", ".", "getAllVariants", "(", "bundle", ".", "getVariants", "(", ")", ")", ";", "if", "(", "allVariants", "==", "null", ")", "{", "allVariants", "=", "new", "ArrayList", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", ";", "}", "if", "(", "allVariants", ".", "isEmpty", "(", ")", ")", "{", "allVariants", ".", "add", "(", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ")", ";", "}", "// Creates the bundle file for each local variant", "for", "(", "Iterator", "<", "Map", "<", "String", ",", "String", ">", ">", "it", "=", "allVariants", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Map", "<", "String", ",", "String", ">", "variantMap", "=", "(", "Map", "<", "String", ",", "String", ">", ")", "it", ".", "next", "(", ")", ";", "List", "<", "RenderedLink", ">", "linksToBundle", "=", "createLinkToBundle", "(", "bundleHandler", ",", "bundle", ".", "getId", "(", ")", ",", "resourceType", ",", "variantMap", ")", ";", "for", "(", "Iterator", "<", "RenderedLink", ">", "iteratorLinks", "=", "linksToBundle", ".", "iterator", "(", ")", ";", "iteratorLinks", ".", "hasNext", "(", ")", ";", ")", "{", "RenderedLink", "renderedLink", "=", "iteratorLinks", ".", "next", "(", ")", ";", "String", "path", "=", "renderedLink", ".", "getLink", "(", ")", ";", "// Force the debug mode of the config to match what was used", "// in the generated link", "JawrConfig", "config", "=", "bundleHandler", ".", "getConfig", "(", ")", ";", "config", ".", "setDebugModeOn", "(", "renderedLink", ".", "isDebugMode", "(", ")", ")", ";", "String", "finalBundlePath", "=", "null", ";", "if", "(", "keepUrlMapping", ")", "{", "finalBundlePath", "=", "path", ";", "}", "else", "{", "finalBundlePath", "=", "getFinalBundlePath", "(", "path", ",", "config", ",", "variantMap", ")", ";", "}", "// Sets the request URL", "setRequestUrl", "(", "request", ",", "variantMap", ",", "path", ",", "config", ")", ";", "// We can't use path for generated resources because it's", "// not a valid file path ( /jawr_generator.js?xxx.... )", "if", "(", "!", "(", "path", ".", "indexOf", "(", "\"?\"", ")", "!=", "-", "1", ")", "||", "!", "keepUrlMapping", ")", "{", "File", "bundleFile", "=", "new", "File", "(", "destDirPath", ",", "finalBundlePath", ")", ";", "createBundleFile", "(", "servlet", ",", "response", ",", "request", ",", "path", ",", "bundleFile", ",", "servletMapping", ")", ";", "}", "}", "}", "}", "}" ]
Creates the bundles in the destination directory @param servlet the servlet @param bundleHandler the bundles handler @param destDirPath the destination directory path @param servletMapping the mapping of the servlet @param keepUrlMapping the flag indicating if we must keep the URL mapping @throws IOException if an IO exception occurs @throws ServletException if a servlet exception occurs
[ "Creates", "the", "bundles", "in", "the", "destination", "directory" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L748-L835
7,404
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.setRequestUrl
protected void setRequestUrl(MockServletRequest request, Map<String, String> variantMap, String path, JawrConfig config) { String domainURL = JawrConstant.HTTP_URL_PREFIX + DEFAULT_WEBAPP_URL; if (JawrConstant.SSL.equals(variantMap .get(JawrConstant.CONNECTION_TYPE_VARIANT_TYPE))) { // Use the contextPathSslOverride property if it's an absolute URL if (StringUtils.isNotEmpty(config.getContextPathSslOverride()) && config.getContextPathSslOverride().startsWith( JawrConstant.HTTPS_URL_PREFIX)) { domainURL = config.getContextPathSslOverride(); } else { domainURL = JawrConstant.HTTPS_URL_PREFIX + DEFAULT_WEBAPP_URL; } } else { // Use the contextPathOverride property if it's an absolute URL if (StringUtils.isNotEmpty(config.getContextPathOverride()) && config.getContextPathOverride().startsWith( JawrConstant.HTTP_URL_PREFIX)) { domainURL = config.getContextPathOverride(); } else { domainURL = JawrConstant.HTTP_URL_PREFIX + DEFAULT_WEBAPP_URL; } } request.setRequestUrl(PathNormalizer.joinDomainToPath(domainURL, path)); }
java
protected void setRequestUrl(MockServletRequest request, Map<String, String> variantMap, String path, JawrConfig config) { String domainURL = JawrConstant.HTTP_URL_PREFIX + DEFAULT_WEBAPP_URL; if (JawrConstant.SSL.equals(variantMap .get(JawrConstant.CONNECTION_TYPE_VARIANT_TYPE))) { // Use the contextPathSslOverride property if it's an absolute URL if (StringUtils.isNotEmpty(config.getContextPathSslOverride()) && config.getContextPathSslOverride().startsWith( JawrConstant.HTTPS_URL_PREFIX)) { domainURL = config.getContextPathSslOverride(); } else { domainURL = JawrConstant.HTTPS_URL_PREFIX + DEFAULT_WEBAPP_URL; } } else { // Use the contextPathOverride property if it's an absolute URL if (StringUtils.isNotEmpty(config.getContextPathOverride()) && config.getContextPathOverride().startsWith( JawrConstant.HTTP_URL_PREFIX)) { domainURL = config.getContextPathOverride(); } else { domainURL = JawrConstant.HTTP_URL_PREFIX + DEFAULT_WEBAPP_URL; } } request.setRequestUrl(PathNormalizer.joinDomainToPath(domainURL, path)); }
[ "protected", "void", "setRequestUrl", "(", "MockServletRequest", "request", ",", "Map", "<", "String", ",", "String", ">", "variantMap", ",", "String", "path", ",", "JawrConfig", "config", ")", "{", "String", "domainURL", "=", "JawrConstant", ".", "HTTP_URL_PREFIX", "+", "DEFAULT_WEBAPP_URL", ";", "if", "(", "JawrConstant", ".", "SSL", ".", "equals", "(", "variantMap", ".", "get", "(", "JawrConstant", ".", "CONNECTION_TYPE_VARIANT_TYPE", ")", ")", ")", "{", "// Use the contextPathSslOverride property if it's an absolute URL", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "config", ".", "getContextPathSslOverride", "(", ")", ")", "&&", "config", ".", "getContextPathSslOverride", "(", ")", ".", "startsWith", "(", "JawrConstant", ".", "HTTPS_URL_PREFIX", ")", ")", "{", "domainURL", "=", "config", ".", "getContextPathSslOverride", "(", ")", ";", "}", "else", "{", "domainURL", "=", "JawrConstant", ".", "HTTPS_URL_PREFIX", "+", "DEFAULT_WEBAPP_URL", ";", "}", "}", "else", "{", "// Use the contextPathOverride property if it's an absolute URL", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "config", ".", "getContextPathOverride", "(", ")", ")", "&&", "config", ".", "getContextPathOverride", "(", ")", ".", "startsWith", "(", "JawrConstant", ".", "HTTP_URL_PREFIX", ")", ")", "{", "domainURL", "=", "config", ".", "getContextPathOverride", "(", ")", ";", "}", "else", "{", "domainURL", "=", "JawrConstant", ".", "HTTP_URL_PREFIX", "+", "DEFAULT_WEBAPP_URL", ";", "}", "}", "request", ".", "setRequestUrl", "(", "PathNormalizer", ".", "joinDomainToPath", "(", "domainURL", ",", "path", ")", ")", ";", "}" ]
Set the request URL @param request the request @param variantMap the variantMap @param path the path @param config the Jawr config
[ "Set", "the", "request", "URL" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L849-L876
7,405
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.getFinalBundlePath
public String getFinalBundlePath(String path, JawrConfig jawrConfig, Map<String, String> variantMap) { String finalPath = path; int jawrGenerationParamIdx = finalPath .indexOf(JawrRequestHandler.GENERATION_PARAM); if (jawrGenerationParamIdx != -1) { try { finalPath = URLDecoder.decode(path, "UTF-8"); } catch (UnsupportedEncodingException neverHappens) { /* URLEncoder:how not to use checked exceptions... */ throw new RuntimeException( "Something went unexpectedly wrong while decoding a URL for a generator. ", neverHappens); } // Remove servlet mapping if it exists. finalPath = removeServletMappingFromPath(finalPath, jawrConfig.getServletMapping()); finalPath = jawrConfig.getGeneratorRegistry() .getDebugModeBuildTimeGenerationPath(finalPath); } else { // Remove servlet mapping if it exists. finalPath = removeServletMappingFromPath(finalPath, jawrConfig.getServletMapping()); if (finalPath.startsWith("/")) { finalPath = finalPath.substring(1); } // remove cache prefix, when not in debug mode if (!jawrConfig.isDebugModeOn()) { int idx = finalPath.indexOf("/"); finalPath = finalPath.substring(idx + 1); } // For localized bundle add the local info in the file name // For example, with local variant = 'en' // /bundle/myBundle.js -> /bundle/myBundle_en.js finalPath = VariantUtils .getVariantBundleName(finalPath, variantMap, false); } return finalPath; }
java
public String getFinalBundlePath(String path, JawrConfig jawrConfig, Map<String, String> variantMap) { String finalPath = path; int jawrGenerationParamIdx = finalPath .indexOf(JawrRequestHandler.GENERATION_PARAM); if (jawrGenerationParamIdx != -1) { try { finalPath = URLDecoder.decode(path, "UTF-8"); } catch (UnsupportedEncodingException neverHappens) { /* URLEncoder:how not to use checked exceptions... */ throw new RuntimeException( "Something went unexpectedly wrong while decoding a URL for a generator. ", neverHappens); } // Remove servlet mapping if it exists. finalPath = removeServletMappingFromPath(finalPath, jawrConfig.getServletMapping()); finalPath = jawrConfig.getGeneratorRegistry() .getDebugModeBuildTimeGenerationPath(finalPath); } else { // Remove servlet mapping if it exists. finalPath = removeServletMappingFromPath(finalPath, jawrConfig.getServletMapping()); if (finalPath.startsWith("/")) { finalPath = finalPath.substring(1); } // remove cache prefix, when not in debug mode if (!jawrConfig.isDebugModeOn()) { int idx = finalPath.indexOf("/"); finalPath = finalPath.substring(idx + 1); } // For localized bundle add the local info in the file name // For example, with local variant = 'en' // /bundle/myBundle.js -> /bundle/myBundle_en.js finalPath = VariantUtils .getVariantBundleName(finalPath, variantMap, false); } return finalPath; }
[ "public", "String", "getFinalBundlePath", "(", "String", "path", ",", "JawrConfig", "jawrConfig", ",", "Map", "<", "String", ",", "String", ">", "variantMap", ")", "{", "String", "finalPath", "=", "path", ";", "int", "jawrGenerationParamIdx", "=", "finalPath", ".", "indexOf", "(", "JawrRequestHandler", ".", "GENERATION_PARAM", ")", ";", "if", "(", "jawrGenerationParamIdx", "!=", "-", "1", ")", "{", "try", "{", "finalPath", "=", "URLDecoder", ".", "decode", "(", "path", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "neverHappens", ")", "{", "/* URLEncoder:how not to use checked exceptions... */", "throw", "new", "RuntimeException", "(", "\"Something went unexpectedly wrong while decoding a URL for a generator. \"", ",", "neverHappens", ")", ";", "}", "// Remove servlet mapping if it exists.", "finalPath", "=", "removeServletMappingFromPath", "(", "finalPath", ",", "jawrConfig", ".", "getServletMapping", "(", ")", ")", ";", "finalPath", "=", "jawrConfig", ".", "getGeneratorRegistry", "(", ")", ".", "getDebugModeBuildTimeGenerationPath", "(", "finalPath", ")", ";", "}", "else", "{", "// Remove servlet mapping if it exists.", "finalPath", "=", "removeServletMappingFromPath", "(", "finalPath", ",", "jawrConfig", ".", "getServletMapping", "(", ")", ")", ";", "if", "(", "finalPath", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "finalPath", "=", "finalPath", ".", "substring", "(", "1", ")", ";", "}", "// remove cache prefix, when not in debug mode", "if", "(", "!", "jawrConfig", ".", "isDebugModeOn", "(", ")", ")", "{", "int", "idx", "=", "finalPath", ".", "indexOf", "(", "\"/\"", ")", ";", "finalPath", "=", "finalPath", ".", "substring", "(", "idx", "+", "1", ")", ";", "}", "// For localized bundle add the local info in the file name", "// For example, with local variant = 'en'", "// /bundle/myBundle.js -> /bundle/myBundle_en.js", "finalPath", "=", "VariantUtils", ".", "getVariantBundleName", "(", "finalPath", ",", "variantMap", ",", "false", ")", ";", "}", "return", "finalPath", ";", "}" ]
Retrieves the final path, where the servlet mapping and the cache prefix have been removed, and take also in account the jawr generator URLs. <pre> "/N1785986402/js/bundle/msg.js" -> "/js/bundle/msg.js" "/jawr_generator.js?generationConfigParam=messages%3Amessages%40fr" -> "/jawr_generator/js/messages/messages_fr.js" "/cssJawrPath/1414653084/folder/core/component.css" -> "folder/core/component.css" </pre> @param path the path @param jawrConfig the jawr config @param localVariantKey The local variant key @return the final path
[ "Retrieves", "the", "final", "path", "where", "the", "servlet", "mapping", "and", "the", "cache", "prefix", "have", "been", "removed", "and", "take", "also", "in", "account", "the", "jawr", "generator", "URLs", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L896-L944
7,406
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.getImageFinalPath
public String getImageFinalPath(String path, JawrConfig jawrConfig) { String finalPath = path; // Remove servlet mapping if it exists. finalPath = removeServletMappingFromPath(finalPath, jawrConfig.getServletMapping()); if (finalPath.startsWith("/")) { finalPath = finalPath.substring(1); } // remove cache prefix int idx = finalPath.indexOf("/"); finalPath = finalPath.substring(idx + 1); return finalPath; }
java
public String getImageFinalPath(String path, JawrConfig jawrConfig) { String finalPath = path; // Remove servlet mapping if it exists. finalPath = removeServletMappingFromPath(finalPath, jawrConfig.getServletMapping()); if (finalPath.startsWith("/")) { finalPath = finalPath.substring(1); } // remove cache prefix int idx = finalPath.indexOf("/"); finalPath = finalPath.substring(idx + 1); return finalPath; }
[ "public", "String", "getImageFinalPath", "(", "String", "path", ",", "JawrConfig", "jawrConfig", ")", "{", "String", "finalPath", "=", "path", ";", "// Remove servlet mapping if it exists.", "finalPath", "=", "removeServletMappingFromPath", "(", "finalPath", ",", "jawrConfig", ".", "getServletMapping", "(", ")", ")", ";", "if", "(", "finalPath", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "finalPath", "=", "finalPath", ".", "substring", "(", "1", ")", ";", "}", "// remove cache prefix", "int", "idx", "=", "finalPath", ".", "indexOf", "(", "\"/\"", ")", ";", "finalPath", "=", "finalPath", ".", "substring", "(", "idx", "+", "1", ")", ";", "return", "finalPath", ";", "}" ]
Retrieves the image final path, where the servlet mapping and the cache prefix have been removed @param path the path @param jawrConfig the jawr config @return the final path
[ "Retrieves", "the", "image", "final", "path", "where", "the", "servlet", "mapping", "and", "the", "cache", "prefix", "have", "been", "removed" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L956-L972
7,407
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.removeServletMappingFromPath
protected String removeServletMappingFromPath(String path, String mapping) { if (mapping != null && mapping.length() > 0) { int idx = path.indexOf(mapping); if (idx > -1) { path = path.substring(idx + mapping.length()); } path = PathNormalizer.asPath(path); } return path; }
java
protected String removeServletMappingFromPath(String path, String mapping) { if (mapping != null && mapping.length() > 0) { int idx = path.indexOf(mapping); if (idx > -1) { path = path.substring(idx + mapping.length()); } path = PathNormalizer.asPath(path); } return path; }
[ "protected", "String", "removeServletMappingFromPath", "(", "String", "path", ",", "String", "mapping", ")", "{", "if", "(", "mapping", "!=", "null", "&&", "mapping", ".", "length", "(", ")", ">", "0", ")", "{", "int", "idx", "=", "path", ".", "indexOf", "(", "mapping", ")", ";", "if", "(", "idx", ">", "-", "1", ")", "{", "path", "=", "path", ".", "substring", "(", "idx", "+", "mapping", ".", "length", "(", ")", ")", ";", "}", "path", "=", "PathNormalizer", ".", "asPath", "(", "path", ")", ";", "}", "return", "path", ";", "}" ]
Remove the servlet mapping from the path @param path the path @param mapping the servlet mapping @return the path without the servlet mapping
[ "Remove", "the", "servlet", "mapping", "from", "the", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L983-L993
7,408
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.createBinaryBundle
protected void createBinaryBundle(HttpServlet servlet, BinaryResourcesHandler binaryRsHandler, String destDirPath, ServletConfig servletConfig, boolean keepUrlMapping) throws IOException, ServletException { Map<String, String> bundleImgMap = binaryRsHandler.getBinaryPathMap(); Iterator<String> bundleIterator = bundleImgMap.values().iterator(); MockServletResponse response = new MockServletResponse(); MockServletRequest request = new MockServletRequest( JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH); String jawrServletMapping = servletConfig .getInitParameter(JawrConstant.SERVLET_MAPPING_PROPERTY_NAME); if (jawrServletMapping == null) { jawrServletMapping = ""; } String servletMapping = servletConfig .getInitParameter(JawrConstant.SPRING_SERVLET_MAPPING_PROPERTY_NAME); if (servletMapping == null) { servletMapping = jawrServletMapping; } // For the list of bundle defines, create the file associated while (bundleIterator.hasNext()) { String path = (String) bundleIterator.next(); String binaryFinalPath = null; if (keepUrlMapping) { binaryFinalPath = path; } else { binaryFinalPath = getImageFinalPath(path, binaryRsHandler.getConfig()); } File destFile = new File(destDirPath, binaryFinalPath); Map<String, String> variantMap = new HashMap<String, String>(); setRequestUrl(request, variantMap , path, binaryRsHandler.getConfig()); // Update the bundle mapping path = PathNormalizer.concatWebPath( PathNormalizer.asDirPath(jawrServletMapping), path); createBundleFile(servlet, response, request, path, destFile, servletMapping); } }
java
protected void createBinaryBundle(HttpServlet servlet, BinaryResourcesHandler binaryRsHandler, String destDirPath, ServletConfig servletConfig, boolean keepUrlMapping) throws IOException, ServletException { Map<String, String> bundleImgMap = binaryRsHandler.getBinaryPathMap(); Iterator<String> bundleIterator = bundleImgMap.values().iterator(); MockServletResponse response = new MockServletResponse(); MockServletRequest request = new MockServletRequest( JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH); String jawrServletMapping = servletConfig .getInitParameter(JawrConstant.SERVLET_MAPPING_PROPERTY_NAME); if (jawrServletMapping == null) { jawrServletMapping = ""; } String servletMapping = servletConfig .getInitParameter(JawrConstant.SPRING_SERVLET_MAPPING_PROPERTY_NAME); if (servletMapping == null) { servletMapping = jawrServletMapping; } // For the list of bundle defines, create the file associated while (bundleIterator.hasNext()) { String path = (String) bundleIterator.next(); String binaryFinalPath = null; if (keepUrlMapping) { binaryFinalPath = path; } else { binaryFinalPath = getImageFinalPath(path, binaryRsHandler.getConfig()); } File destFile = new File(destDirPath, binaryFinalPath); Map<String, String> variantMap = new HashMap<String, String>(); setRequestUrl(request, variantMap , path, binaryRsHandler.getConfig()); // Update the bundle mapping path = PathNormalizer.concatWebPath( PathNormalizer.asDirPath(jawrServletMapping), path); createBundleFile(servlet, response, request, path, destFile, servletMapping); } }
[ "protected", "void", "createBinaryBundle", "(", "HttpServlet", "servlet", ",", "BinaryResourcesHandler", "binaryRsHandler", ",", "String", "destDirPath", ",", "ServletConfig", "servletConfig", ",", "boolean", "keepUrlMapping", ")", "throws", "IOException", ",", "ServletException", "{", "Map", "<", "String", ",", "String", ">", "bundleImgMap", "=", "binaryRsHandler", ".", "getBinaryPathMap", "(", ")", ";", "Iterator", "<", "String", ">", "bundleIterator", "=", "bundleImgMap", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "MockServletResponse", "response", "=", "new", "MockServletResponse", "(", ")", ";", "MockServletRequest", "request", "=", "new", "MockServletRequest", "(", "JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH", ")", ";", "String", "jawrServletMapping", "=", "servletConfig", ".", "getInitParameter", "(", "JawrConstant", ".", "SERVLET_MAPPING_PROPERTY_NAME", ")", ";", "if", "(", "jawrServletMapping", "==", "null", ")", "{", "jawrServletMapping", "=", "\"\"", ";", "}", "String", "servletMapping", "=", "servletConfig", ".", "getInitParameter", "(", "JawrConstant", ".", "SPRING_SERVLET_MAPPING_PROPERTY_NAME", ")", ";", "if", "(", "servletMapping", "==", "null", ")", "{", "servletMapping", "=", "jawrServletMapping", ";", "}", "// For the list of bundle defines, create the file associated", "while", "(", "bundleIterator", ".", "hasNext", "(", ")", ")", "{", "String", "path", "=", "(", "String", ")", "bundleIterator", ".", "next", "(", ")", ";", "String", "binaryFinalPath", "=", "null", ";", "if", "(", "keepUrlMapping", ")", "{", "binaryFinalPath", "=", "path", ";", "}", "else", "{", "binaryFinalPath", "=", "getImageFinalPath", "(", "path", ",", "binaryRsHandler", ".", "getConfig", "(", ")", ")", ";", "}", "File", "destFile", "=", "new", "File", "(", "destDirPath", ",", "binaryFinalPath", ")", ";", "Map", "<", "String", ",", "String", ">", "variantMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "setRequestUrl", "(", "request", ",", "variantMap", ",", "path", ",", "binaryRsHandler", ".", "getConfig", "(", ")", ")", ";", "// Update the bundle mapping", "path", "=", "PathNormalizer", ".", "concatWebPath", "(", "PathNormalizer", ".", "asDirPath", "(", "jawrServletMapping", ")", ",", "path", ")", ";", "createBundleFile", "(", "servlet", ",", "response", ",", "request", ",", "path", ",", "destFile", ",", "servletMapping", ")", ";", "}", "}" ]
Create the image bundle @param servlet the servlet @param binaryRsHandler the binary resource handler @param destDirPath the destination directory path @param servletMapping the mapping @param keepUrlMapping = the flag indicating if we must keep the url mapping @throws IOException if an IOExceptin occurs @throws ServletException if an exception occurs
[ "Create", "the", "image", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L1013-L1060
7,409
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.createBundleFile
protected void createBundleFile(HttpServlet servlet, MockServletResponse response, MockServletRequest request, String path, File destFile, String mapping) throws IOException, ServletException { request.setRequestPath(mapping, path); // Create the parent directory of the destination file if (!destFile.getParentFile().exists()) { boolean dirsCreated = destFile.getParentFile().mkdirs(); if (!dirsCreated) { throw new IOException("The directory '" + destFile.getParentFile().getCanonicalPath() + "' can't be created."); } } // Set the response mock to write in the destination file try { response.setOutputStream(new FileOutputStream(destFile)); servlet.service(request, response); } finally { response.close(); } if (destFile.length() == 0) { logger.warn("No content retrieved for file '" + destFile.getAbsolutePath() + "', which is associated to the path : " + path); System.out.println("No content retrieved for file '" + destFile.getAbsolutePath() + "', which is associated to the path : " + path); } }
java
protected void createBundleFile(HttpServlet servlet, MockServletResponse response, MockServletRequest request, String path, File destFile, String mapping) throws IOException, ServletException { request.setRequestPath(mapping, path); // Create the parent directory of the destination file if (!destFile.getParentFile().exists()) { boolean dirsCreated = destFile.getParentFile().mkdirs(); if (!dirsCreated) { throw new IOException("The directory '" + destFile.getParentFile().getCanonicalPath() + "' can't be created."); } } // Set the response mock to write in the destination file try { response.setOutputStream(new FileOutputStream(destFile)); servlet.service(request, response); } finally { response.close(); } if (destFile.length() == 0) { logger.warn("No content retrieved for file '" + destFile.getAbsolutePath() + "', which is associated to the path : " + path); System.out.println("No content retrieved for file '" + destFile.getAbsolutePath() + "', which is associated to the path : " + path); } }
[ "protected", "void", "createBundleFile", "(", "HttpServlet", "servlet", ",", "MockServletResponse", "response", ",", "MockServletRequest", "request", ",", "String", "path", ",", "File", "destFile", ",", "String", "mapping", ")", "throws", "IOException", ",", "ServletException", "{", "request", ".", "setRequestPath", "(", "mapping", ",", "path", ")", ";", "// Create the parent directory of the destination file", "if", "(", "!", "destFile", ".", "getParentFile", "(", ")", ".", "exists", "(", ")", ")", "{", "boolean", "dirsCreated", "=", "destFile", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "if", "(", "!", "dirsCreated", ")", "{", "throw", "new", "IOException", "(", "\"The directory '\"", "+", "destFile", ".", "getParentFile", "(", ")", ".", "getCanonicalPath", "(", ")", "+", "\"' can't be created.\"", ")", ";", "}", "}", "// Set the response mock to write in the destination file", "try", "{", "response", ".", "setOutputStream", "(", "new", "FileOutputStream", "(", "destFile", ")", ")", ";", "servlet", ".", "service", "(", "request", ",", "response", ")", ";", "}", "finally", "{", "response", ".", "close", "(", ")", ";", "}", "if", "(", "destFile", ".", "length", "(", ")", "==", "0", ")", "{", "logger", ".", "warn", "(", "\"No content retrieved for file '\"", "+", "destFile", ".", "getAbsolutePath", "(", ")", "+", "\"', which is associated to the path : \"", "+", "path", ")", ";", "System", ".", "out", ".", "println", "(", "\"No content retrieved for file '\"", "+", "destFile", ".", "getAbsolutePath", "(", ")", "+", "\"', which is associated to the path : \"", "+", "path", ")", ";", "}", "}" ]
Create the bundle file @param servlet the servlet @param response the response @param request the request @param path the path @param destFile the destination file @param mapping the mapping @throws IOException if an IO exception occurs @throws ServletException if an exception occurs
[ "Create", "the", "bundle", "file" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L1082-L1115
7,410
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.createLinkToBundle
protected List<RenderedLink> createLinkToBundle( ResourceBundlesHandler handler, String path, String resourceType, Map<String, String> variantMap) throws IOException { ArrayList<RenderedLink> linksToBundle = new ArrayList<RenderedLink>(); BasicBundleRenderer bundleRenderer = new BasicBundleRenderer(handler, resourceType); StringWriter sw = new StringWriter(); // The gzip compression will be made by the CDN server // So we force it to false. boolean useGzip = false; // The generation of bundle is the same in SSL and non SSL mode boolean isSslRequest = false; // First deals with the production mode handler.getConfig().setDebugModeOn(false); handler.getConfig().setGzipResourcesModeOn(useGzip); BundleRendererContext ctx = new BundleRendererContext("", variantMap, useGzip, isSslRequest); bundleRenderer.renderBundleLinks(path, ctx, sw); // Then take in account the debug mode handler.getConfig().setDebugModeOn(true); ctx = new BundleRendererContext("", variantMap, useGzip, isSslRequest); bundleRenderer.renderBundleLinks(path, ctx, sw); List<RenderedLink> renderedLinks = bundleRenderer.getRenderedLinks(); // Remove context override path if it's defined. String contextPathOverride = handler.getConfig() .getContextPathOverride(); for (Iterator<RenderedLink> iterator = renderedLinks.iterator(); iterator .hasNext();) { RenderedLink renderedLink = iterator.next(); String renderedLinkPath = renderedLink.getLink(); // Remove the context path override if (StringUtils.isNotEmpty(contextPathOverride) && renderedLinkPath.startsWith(contextPathOverride)) { renderedLinkPath = renderedLinkPath .substring(contextPathOverride.length()); } renderedLink.setLink(PathNormalizer.asPath(renderedLinkPath)); linksToBundle.add(renderedLink); } return linksToBundle; }
java
protected List<RenderedLink> createLinkToBundle( ResourceBundlesHandler handler, String path, String resourceType, Map<String, String> variantMap) throws IOException { ArrayList<RenderedLink> linksToBundle = new ArrayList<RenderedLink>(); BasicBundleRenderer bundleRenderer = new BasicBundleRenderer(handler, resourceType); StringWriter sw = new StringWriter(); // The gzip compression will be made by the CDN server // So we force it to false. boolean useGzip = false; // The generation of bundle is the same in SSL and non SSL mode boolean isSslRequest = false; // First deals with the production mode handler.getConfig().setDebugModeOn(false); handler.getConfig().setGzipResourcesModeOn(useGzip); BundleRendererContext ctx = new BundleRendererContext("", variantMap, useGzip, isSslRequest); bundleRenderer.renderBundleLinks(path, ctx, sw); // Then take in account the debug mode handler.getConfig().setDebugModeOn(true); ctx = new BundleRendererContext("", variantMap, useGzip, isSslRequest); bundleRenderer.renderBundleLinks(path, ctx, sw); List<RenderedLink> renderedLinks = bundleRenderer.getRenderedLinks(); // Remove context override path if it's defined. String contextPathOverride = handler.getConfig() .getContextPathOverride(); for (Iterator<RenderedLink> iterator = renderedLinks.iterator(); iterator .hasNext();) { RenderedLink renderedLink = iterator.next(); String renderedLinkPath = renderedLink.getLink(); // Remove the context path override if (StringUtils.isNotEmpty(contextPathOverride) && renderedLinkPath.startsWith(contextPathOverride)) { renderedLinkPath = renderedLinkPath .substring(contextPathOverride.length()); } renderedLink.setLink(PathNormalizer.asPath(renderedLinkPath)); linksToBundle.add(renderedLink); } return linksToBundle; }
[ "protected", "List", "<", "RenderedLink", ">", "createLinkToBundle", "(", "ResourceBundlesHandler", "handler", ",", "String", "path", ",", "String", "resourceType", ",", "Map", "<", "String", ",", "String", ">", "variantMap", ")", "throws", "IOException", "{", "ArrayList", "<", "RenderedLink", ">", "linksToBundle", "=", "new", "ArrayList", "<", "RenderedLink", ">", "(", ")", ";", "BasicBundleRenderer", "bundleRenderer", "=", "new", "BasicBundleRenderer", "(", "handler", ",", "resourceType", ")", ";", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "// The gzip compression will be made by the CDN server", "// So we force it to false.", "boolean", "useGzip", "=", "false", ";", "// The generation of bundle is the same in SSL and non SSL mode", "boolean", "isSslRequest", "=", "false", ";", "// First deals with the production mode", "handler", ".", "getConfig", "(", ")", ".", "setDebugModeOn", "(", "false", ")", ";", "handler", ".", "getConfig", "(", ")", ".", "setGzipResourcesModeOn", "(", "useGzip", ")", ";", "BundleRendererContext", "ctx", "=", "new", "BundleRendererContext", "(", "\"\"", ",", "variantMap", ",", "useGzip", ",", "isSslRequest", ")", ";", "bundleRenderer", ".", "renderBundleLinks", "(", "path", ",", "ctx", ",", "sw", ")", ";", "// Then take in account the debug mode", "handler", ".", "getConfig", "(", ")", ".", "setDebugModeOn", "(", "true", ")", ";", "ctx", "=", "new", "BundleRendererContext", "(", "\"\"", ",", "variantMap", ",", "useGzip", ",", "isSslRequest", ")", ";", "bundleRenderer", ".", "renderBundleLinks", "(", "path", ",", "ctx", ",", "sw", ")", ";", "List", "<", "RenderedLink", ">", "renderedLinks", "=", "bundleRenderer", ".", "getRenderedLinks", "(", ")", ";", "// Remove context override path if it's defined.", "String", "contextPathOverride", "=", "handler", ".", "getConfig", "(", ")", ".", "getContextPathOverride", "(", ")", ";", "for", "(", "Iterator", "<", "RenderedLink", ">", "iterator", "=", "renderedLinks", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "RenderedLink", "renderedLink", "=", "iterator", ".", "next", "(", ")", ";", "String", "renderedLinkPath", "=", "renderedLink", ".", "getLink", "(", ")", ";", "// Remove the context path override", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "contextPathOverride", ")", "&&", "renderedLinkPath", ".", "startsWith", "(", "contextPathOverride", ")", ")", "{", "renderedLinkPath", "=", "renderedLinkPath", ".", "substring", "(", "contextPathOverride", ".", "length", "(", ")", ")", ";", "}", "renderedLink", ".", "setLink", "(", "PathNormalizer", ".", "asPath", "(", "renderedLinkPath", ")", ")", ";", "linksToBundle", ".", "add", "(", "renderedLink", ")", ";", "}", "return", "linksToBundle", ";", "}" ]
Returns the link to the bundle @param handler the resource bundles handler @param path the path @param variantKey the local variant key @return the link to the bundle @throws IOException if an IO exception occurs
[ "Returns", "the", "link", "to", "the", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L1130-L1179
7,411
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/FilePathMappingUtils.java
FilePathMappingUtils.buildFilePathMapping
public static FilePathMapping buildFilePathMapping(String path, ResourceReaderHandler rsHandler) { return buildFilePathMapping(null, path, rsHandler); }
java
public static FilePathMapping buildFilePathMapping(String path, ResourceReaderHandler rsHandler) { return buildFilePathMapping(null, path, rsHandler); }
[ "public", "static", "FilePathMapping", "buildFilePathMapping", "(", "String", "path", ",", "ResourceReaderHandler", "rsHandler", ")", "{", "return", "buildFilePathMapping", "(", "null", ",", "path", ",", "rsHandler", ")", ";", "}" ]
Builds the File path mapping @param path the resource path @param rsHandler the resource reader handler @return the file path mapping
[ "Builds", "the", "File", "path", "mapping" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/FilePathMappingUtils.java#L42-L46
7,412
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/FilePathMappingUtils.java
FilePathMappingUtils.buildFilePathMapping
public static FilePathMapping buildFilePathMapping(JoinableResourceBundle bundle, String path, ResourceReaderHandler rsHandler) { FilePathMapping fPathMapping = null; String filePath = rsHandler.getFilePath(path); if(filePath != null){ File f = new File(filePath); if(f.exists()){ fPathMapping = new FilePathMapping(bundle, filePath, f.lastModified()); if(bundle != null){ bundle.getLinkedFilePathMappings().add(fPathMapping); } }else{ if(LOGGER.isDebugEnabled()){ LOGGER.debug("The file path '"+filePath+"' associated to the URL '"+path+"' doesn't exixts."); } } } return fPathMapping; }
java
public static FilePathMapping buildFilePathMapping(JoinableResourceBundle bundle, String path, ResourceReaderHandler rsHandler) { FilePathMapping fPathMapping = null; String filePath = rsHandler.getFilePath(path); if(filePath != null){ File f = new File(filePath); if(f.exists()){ fPathMapping = new FilePathMapping(bundle, filePath, f.lastModified()); if(bundle != null){ bundle.getLinkedFilePathMappings().add(fPathMapping); } }else{ if(LOGGER.isDebugEnabled()){ LOGGER.debug("The file path '"+filePath+"' associated to the URL '"+path+"' doesn't exixts."); } } } return fPathMapping; }
[ "public", "static", "FilePathMapping", "buildFilePathMapping", "(", "JoinableResourceBundle", "bundle", ",", "String", "path", ",", "ResourceReaderHandler", "rsHandler", ")", "{", "FilePathMapping", "fPathMapping", "=", "null", ";", "String", "filePath", "=", "rsHandler", ".", "getFilePath", "(", "path", ")", ";", "if", "(", "filePath", "!=", "null", ")", "{", "File", "f", "=", "new", "File", "(", "filePath", ")", ";", "if", "(", "f", ".", "exists", "(", ")", ")", "{", "fPathMapping", "=", "new", "FilePathMapping", "(", "bundle", ",", "filePath", ",", "f", ".", "lastModified", "(", ")", ")", ";", "if", "(", "bundle", "!=", "null", ")", "{", "bundle", ".", "getLinkedFilePathMappings", "(", ")", ".", "add", "(", "fPathMapping", ")", ";", "}", "}", "else", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"The file path '\"", "+", "filePath", "+", "\"' associated to the URL '\"", "+", "path", "+", "\"' doesn't exixts.\"", ")", ";", "}", "}", "}", "return", "fPathMapping", ";", "}" ]
Builds the File path mapping and add it to the file mappings of the bundle @param bundle the bundle @param path the resource path @param rsHandler the resource reader handler @return the file path mapping
[ "Builds", "the", "File", "path", "mapping", "and", "add", "it", "to", "the", "file", "mappings", "of", "the", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/mappings/FilePathMappingUtils.java#L56-L77
7,413
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/JSMinPostProcessor.java
JSMinPostProcessor.minifyStringBuffer
public StringBuffer minifyStringBuffer(StringBuffer sb, Charset charset) throws IOException, JSMinException { byte[] bundleBytes = sb.toString().getBytes(charset.name()); ByteArrayInputStream bIs = new ByteArrayInputStream(bundleBytes); ByteArrayOutputStream bOs = new ByteArrayOutputStream(); // Compress data and recover it as a byte array. JSMin minifier = new JSMin(bIs, bOs); minifier.jsmin(); byte[] minified = bOs.toByteArray(); return byteArrayToString(charset, minified); }
java
public StringBuffer minifyStringBuffer(StringBuffer sb, Charset charset) throws IOException, JSMinException { byte[] bundleBytes = sb.toString().getBytes(charset.name()); ByteArrayInputStream bIs = new ByteArrayInputStream(bundleBytes); ByteArrayOutputStream bOs = new ByteArrayOutputStream(); // Compress data and recover it as a byte array. JSMin minifier = new JSMin(bIs, bOs); minifier.jsmin(); byte[] minified = bOs.toByteArray(); return byteArrayToString(charset, minified); }
[ "public", "StringBuffer", "minifyStringBuffer", "(", "StringBuffer", "sb", ",", "Charset", "charset", ")", "throws", "IOException", ",", "JSMinException", "{", "byte", "[", "]", "bundleBytes", "=", "sb", ".", "toString", "(", ")", ".", "getBytes", "(", "charset", ".", "name", "(", ")", ")", ";", "ByteArrayInputStream", "bIs", "=", "new", "ByteArrayInputStream", "(", "bundleBytes", ")", ";", "ByteArrayOutputStream", "bOs", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "// Compress data and recover it as a byte array.", "JSMin", "minifier", "=", "new", "JSMin", "(", "bIs", ",", "bOs", ")", ";", "minifier", ".", "jsmin", "(", ")", ";", "byte", "[", "]", "minified", "=", "bOs", ".", "toByteArray", "(", ")", ";", "return", "byteArrayToString", "(", "charset", ",", "minified", ")", ";", "}" ]
Utility method for components that need to use JSMin in a different context other than bundle postprocessing. @param sb the content to minify @param charset the charset @return the minified content @throws java.io.IOException if an IOException occurs @throws net.jawr.web.minification.JSMin.JSMinException if a JSMin exception occurs
[ "Utility", "method", "for", "components", "that", "need", "to", "use", "JSMin", "in", "a", "different", "context", "other", "than", "bundle", "postprocessing", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/JSMinPostProcessor.java#L100-L110
7,414
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/JSMinPostProcessor.java
JSMinPostProcessor.byteArrayToString
private StringBuffer byteArrayToString(Charset charset, byte[] minified) throws IOException { // Write the data into a string ReadableByteChannel chan = Channels.newChannel(new ByteArrayInputStream(minified)); Reader rd = Channels.newReader(chan, charset.newDecoder(), -1); StringWriter writer = new StringWriter(); IOUtils.copy(rd, writer, true); return writer.getBuffer(); }
java
private StringBuffer byteArrayToString(Charset charset, byte[] minified) throws IOException { // Write the data into a string ReadableByteChannel chan = Channels.newChannel(new ByteArrayInputStream(minified)); Reader rd = Channels.newReader(chan, charset.newDecoder(), -1); StringWriter writer = new StringWriter(); IOUtils.copy(rd, writer, true); return writer.getBuffer(); }
[ "private", "StringBuffer", "byteArrayToString", "(", "Charset", "charset", ",", "byte", "[", "]", "minified", ")", "throws", "IOException", "{", "// Write the data into a string", "ReadableByteChannel", "chan", "=", "Channels", ".", "newChannel", "(", "new", "ByteArrayInputStream", "(", "minified", ")", ")", ";", "Reader", "rd", "=", "Channels", ".", "newReader", "(", "chan", ",", "charset", ".", "newDecoder", "(", ")", ",", "-", "1", ")", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "IOUtils", ".", "copy", "(", "rd", ",", "writer", ",", "true", ")", ";", "return", "writer", ".", "getBuffer", "(", ")", ";", "}" ]
Convert a byte array to a String buffer taking into account the charset @param charset the charset @param minified the byte array @return the string buffer @throws IOException if an IO exception occurs
[ "Convert", "a", "byte", "array", "to", "a", "String", "buffer", "taking", "into", "account", "the", "charset" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/JSMinPostProcessor.java#L123-L130
7,415
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java
RendererFactory.getJsBundleRenderer
public final static JsBundleLinkRenderer getJsBundleRenderer( ResourceBundlesHandler bundler, String type, Boolean useRandomParam, Boolean async, Boolean defer, String crossorigin) { JsBundleLinkRenderer renderer = (JsBundleLinkRenderer) ClassLoaderResourceUtils .buildObjectInstance(bundler.getConfig() .getJsBundleLinkRenderClass()); renderer.init(bundler, type, useRandomParam, async, defer, crossorigin); return renderer; }
java
public final static JsBundleLinkRenderer getJsBundleRenderer( ResourceBundlesHandler bundler, String type, Boolean useRandomParam, Boolean async, Boolean defer, String crossorigin) { JsBundleLinkRenderer renderer = (JsBundleLinkRenderer) ClassLoaderResourceUtils .buildObjectInstance(bundler.getConfig() .getJsBundleLinkRenderClass()); renderer.init(bundler, type, useRandomParam, async, defer, crossorigin); return renderer; }
[ "public", "final", "static", "JsBundleLinkRenderer", "getJsBundleRenderer", "(", "ResourceBundlesHandler", "bundler", ",", "String", "type", ",", "Boolean", "useRandomParam", ",", "Boolean", "async", ",", "Boolean", "defer", ",", "String", "crossorigin", ")", "{", "JsBundleLinkRenderer", "renderer", "=", "(", "JsBundleLinkRenderer", ")", "ClassLoaderResourceUtils", ".", "buildObjectInstance", "(", "bundler", ".", "getConfig", "(", ")", ".", "getJsBundleLinkRenderClass", "(", ")", ")", ";", "renderer", ".", "init", "(", "bundler", ",", "type", ",", "useRandomParam", ",", "async", ",", "defer", ",", "crossorigin", ")", ";", "return", "renderer", ";", "}" ]
Returns the JS Bundle renderer @param bundler the ResourceBundlesHandler @param type the script type attribute @param useRandomParam the flag indicating if it should use the random param @param async the flag indicating the value of the async attribute @param defer the flag indicating the value of the deferred attribute @param crossorigin the value of the crossorigin attribute @return the JS Bundle renderer
[ "Returns", "the", "JS", "Bundle", "renderer" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java#L47-L56
7,416
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java
RendererFactory.getCssBundleRenderer
public final static CssBundleLinkRenderer getCssBundleRenderer( ResourceBundlesHandler bundler, Boolean useRandomParam, String media, boolean alternate, boolean displayAlternateStyles, String title) { CssBundleLinkRenderer renderer = (CssBundleLinkRenderer) ClassLoaderResourceUtils .buildObjectInstance(bundler.getConfig() .getCssBundleLinkRenderClass()); renderer.init(bundler, useRandomParam, media, alternate, displayAlternateStyles, title); return renderer; }
java
public final static CssBundleLinkRenderer getCssBundleRenderer( ResourceBundlesHandler bundler, Boolean useRandomParam, String media, boolean alternate, boolean displayAlternateStyles, String title) { CssBundleLinkRenderer renderer = (CssBundleLinkRenderer) ClassLoaderResourceUtils .buildObjectInstance(bundler.getConfig() .getCssBundleLinkRenderClass()); renderer.init(bundler, useRandomParam, media, alternate, displayAlternateStyles, title); return renderer; }
[ "public", "final", "static", "CssBundleLinkRenderer", "getCssBundleRenderer", "(", "ResourceBundlesHandler", "bundler", ",", "Boolean", "useRandomParam", ",", "String", "media", ",", "boolean", "alternate", ",", "boolean", "displayAlternateStyles", ",", "String", "title", ")", "{", "CssBundleLinkRenderer", "renderer", "=", "(", "CssBundleLinkRenderer", ")", "ClassLoaderResourceUtils", ".", "buildObjectInstance", "(", "bundler", ".", "getConfig", "(", ")", ".", "getCssBundleLinkRenderClass", "(", ")", ")", ";", "renderer", ".", "init", "(", "bundler", ",", "useRandomParam", ",", "media", ",", "alternate", ",", "displayAlternateStyles", ",", "title", ")", ";", "return", "renderer", ";", "}" ]
Returns the CSS Bundle renderer @param bundler the bundler @param useRandomParam the flag indicating if we use the random flag @param media the media @param alternate the alternate flag @param displayAlternateStyles the flag indicating if the alternate styles must be displayed @param title the title @return the Css Bundle renderer
[ "Returns", "the", "CSS", "Bundle", "renderer" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java#L75-L85
7,417
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java
RendererFactory.getImgRenderer
public final static ImgRenderer getImgRenderer(JawrConfig config, boolean isPlainImg) { ImgRenderer renderer = (ImgRenderer) ClassLoaderResourceUtils .buildObjectInstance(config.getImgRendererClass()); renderer.init(isPlainImg); return renderer; }
java
public final static ImgRenderer getImgRenderer(JawrConfig config, boolean isPlainImg) { ImgRenderer renderer = (ImgRenderer) ClassLoaderResourceUtils .buildObjectInstance(config.getImgRendererClass()); renderer.init(isPlainImg); return renderer; }
[ "public", "final", "static", "ImgRenderer", "getImgRenderer", "(", "JawrConfig", "config", ",", "boolean", "isPlainImg", ")", "{", "ImgRenderer", "renderer", "=", "(", "ImgRenderer", ")", "ClassLoaderResourceUtils", ".", "buildObjectInstance", "(", "config", ".", "getImgRendererClass", "(", ")", ")", ";", "renderer", ".", "init", "(", "isPlainImg", ")", ";", "return", "renderer", ";", "}" ]
Returns the image renderer @param config the Jawr config @param isPlainImg the flag indicating if it a plain image to render or not @return the image renderer
[ "Returns", "the", "image", "renderer" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java#L96-L102
7,418
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java
ClassPathGeneratorHelper.createResource
public Reader createResource(GeneratorContext context) { InputStream is = createStreamResource(context); ReadableByteChannel chan = Channels.newChannel(is); return Channels.newReader(chan, context.getCharset().newDecoder(), -1); }
java
public Reader createResource(GeneratorContext context) { InputStream is = createStreamResource(context); ReadableByteChannel chan = Channels.newChannel(is); return Channels.newReader(chan, context.getCharset().newDecoder(), -1); }
[ "public", "Reader", "createResource", "(", "GeneratorContext", "context", ")", "{", "InputStream", "is", "=", "createStreamResource", "(", "context", ")", ";", "ReadableByteChannel", "chan", "=", "Channels", ".", "newChannel", "(", "is", ")", ";", "return", "Channels", ".", "newReader", "(", "chan", ",", "context", ".", "getCharset", "(", ")", ".", "newDecoder", "(", ")", ",", "-", "1", ")", ";", "}" ]
Finds a resource from the classpath and returns a reader on it. @param context the generator context @return the reader
[ "Finds", "a", "resource", "from", "the", "classpath", "and", "returns", "a", "reader", "on", "it", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java#L91-L96
7,419
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java
ClassPathGeneratorHelper.createStreamResource
public InputStream createStreamResource(GeneratorContext context) { InputStream is = null; try { String resourcePath = context.getPath(); String path = getCompletePath(resourcePath); is = ClassLoaderResourceUtils.getResourceAsStream(path, this); } catch (FileNotFoundException e) { throw new BundlingProcessException(e); } return is; }
java
public InputStream createStreamResource(GeneratorContext context) { InputStream is = null; try { String resourcePath = context.getPath(); String path = getCompletePath(resourcePath); is = ClassLoaderResourceUtils.getResourceAsStream(path, this); } catch (FileNotFoundException e) { throw new BundlingProcessException(e); } return is; }
[ "public", "InputStream", "createStreamResource", "(", "GeneratorContext", "context", ")", "{", "InputStream", "is", "=", "null", ";", "try", "{", "String", "resourcePath", "=", "context", ".", "getPath", "(", ")", ";", "String", "path", "=", "getCompletePath", "(", "resourcePath", ")", ";", "is", "=", "ClassLoaderResourceUtils", ".", "getResourceAsStream", "(", "path", ",", "this", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "return", "is", ";", "}" ]
Finds a resource from the classpath and returns an input stream on it. @param context the generator context @return the input stream
[ "Finds", "a", "resource", "from", "the", "classpath", "and", "returns", "an", "input", "stream", "on", "it", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java#L105-L116
7,420
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java
ClassPathGeneratorHelper.getCompletePath
private String getCompletePath(String resourcePath) { String path = PathNormalizer.normalizePath(classpathPrefix + resourcePath); return path; }
java
private String getCompletePath(String resourcePath) { String path = PathNormalizer.normalizePath(classpathPrefix + resourcePath); return path; }
[ "private", "String", "getCompletePath", "(", "String", "resourcePath", ")", "{", "String", "path", "=", "PathNormalizer", ".", "normalizePath", "(", "classpathPrefix", "+", "resourcePath", ")", ";", "return", "path", ";", "}" ]
Returns the complete path with the classpath prefix @param resourcePath the resource path @return the complete path with the classpath prefix
[ "Returns", "the", "complete", "path", "with", "the", "classpath", "prefix" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java#L125-L128
7,421
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java
ClassPathGeneratorHelper.getResourceNamesFromJar
private Set<String> getResourceNamesFromJar(String path, URL resourceURL) { URLConnection con = null; try { if (resourceURL.toString().startsWith(JawrConstant.JAR_URL_PREFIX)) { con = resourceURL.openConnection(); } } catch (IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Unable to find resources name for path '" + path + "'", e); } return Collections.emptySet(); } JarFile jarFile; String jarFileUrl; String rootEntryPath; boolean newJarFile = false; try { if (con instanceof JarURLConnection) { // Should usually be the case for traditional JAR files. JarURLConnection jarCon = (JarURLConnection) con; jarCon.setUseCaches(true); jarFile = jarCon.getJarFile(); JarEntry jarEntry = jarCon.getJarEntry(); rootEntryPath = (jarEntry != null ? jarEntry.getName() : ""); } else { // No JarURLConnection -> need to resort to URL file parsing. // We'll assume URLs of the format "jar:path!/entry", with the // protocol // being arbitrary as long as following the entry format. // We'll also handle paths with and without leading "file:" // prefix. String urlFile = resourceURL.getFile(); int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR); if (separatorIndex != -1) { jarFileUrl = urlFile.substring(0, separatorIndex); rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length()); jarFile = getJarFile(jarFileUrl); } else { jarFile = new JarFile(urlFile); rootEntryPath = ""; } newJarFile = true; } } catch (IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Unable to find resources name for path '" + path + "'", e); } return Collections.emptySet(); } try { if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) { // Root entry path must end with slash to allow for proper // matching. // The Sun JRE does not return a slash here, but BEA JRockit // does. rootEntryPath = rootEntryPath + "/"; } Set<String> result = new LinkedHashSet<>(8); for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { JarEntry entry = entries.nextElement(); String entryPath = entry.getName(); if (isDirectChildPath(rootEntryPath, entryPath)) { String relativePath = entryPath.substring(rootEntryPath.length()); result.add(relativePath); } } return result; } finally { // Close jar file, but only if freshly obtained - // not from JarURLConnection, which might cache the file reference. if (newJarFile) { try { jarFile.close(); } catch (IOException e) { // Nothing to do } } } }
java
private Set<String> getResourceNamesFromJar(String path, URL resourceURL) { URLConnection con = null; try { if (resourceURL.toString().startsWith(JawrConstant.JAR_URL_PREFIX)) { con = resourceURL.openConnection(); } } catch (IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Unable to find resources name for path '" + path + "'", e); } return Collections.emptySet(); } JarFile jarFile; String jarFileUrl; String rootEntryPath; boolean newJarFile = false; try { if (con instanceof JarURLConnection) { // Should usually be the case for traditional JAR files. JarURLConnection jarCon = (JarURLConnection) con; jarCon.setUseCaches(true); jarFile = jarCon.getJarFile(); JarEntry jarEntry = jarCon.getJarEntry(); rootEntryPath = (jarEntry != null ? jarEntry.getName() : ""); } else { // No JarURLConnection -> need to resort to URL file parsing. // We'll assume URLs of the format "jar:path!/entry", with the // protocol // being arbitrary as long as following the entry format. // We'll also handle paths with and without leading "file:" // prefix. String urlFile = resourceURL.getFile(); int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR); if (separatorIndex != -1) { jarFileUrl = urlFile.substring(0, separatorIndex); rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length()); jarFile = getJarFile(jarFileUrl); } else { jarFile = new JarFile(urlFile); rootEntryPath = ""; } newJarFile = true; } } catch (IOException e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Unable to find resources name for path '" + path + "'", e); } return Collections.emptySet(); } try { if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) { // Root entry path must end with slash to allow for proper // matching. // The Sun JRE does not return a slash here, but BEA JRockit // does. rootEntryPath = rootEntryPath + "/"; } Set<String> result = new LinkedHashSet<>(8); for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { JarEntry entry = entries.nextElement(); String entryPath = entry.getName(); if (isDirectChildPath(rootEntryPath, entryPath)) { String relativePath = entryPath.substring(rootEntryPath.length()); result.add(relativePath); } } return result; } finally { // Close jar file, but only if freshly obtained - // not from JarURLConnection, which might cache the file reference. if (newJarFile) { try { jarFile.close(); } catch (IOException e) { // Nothing to do } } } }
[ "private", "Set", "<", "String", ">", "getResourceNamesFromJar", "(", "String", "path", ",", "URL", "resourceURL", ")", "{", "URLConnection", "con", "=", "null", ";", "try", "{", "if", "(", "resourceURL", ".", "toString", "(", ")", ".", "startsWith", "(", "JawrConstant", ".", "JAR_URL_PREFIX", ")", ")", "{", "con", "=", "resourceURL", ".", "openConnection", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to find resources name for path '\"", "+", "path", "+", "\"'\"", ",", "e", ")", ";", "}", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "JarFile", "jarFile", ";", "String", "jarFileUrl", ";", "String", "rootEntryPath", ";", "boolean", "newJarFile", "=", "false", ";", "try", "{", "if", "(", "con", "instanceof", "JarURLConnection", ")", "{", "// Should usually be the case for traditional JAR files.", "JarURLConnection", "jarCon", "=", "(", "JarURLConnection", ")", "con", ";", "jarCon", ".", "setUseCaches", "(", "true", ")", ";", "jarFile", "=", "jarCon", ".", "getJarFile", "(", ")", ";", "JarEntry", "jarEntry", "=", "jarCon", ".", "getJarEntry", "(", ")", ";", "rootEntryPath", "=", "(", "jarEntry", "!=", "null", "?", "jarEntry", ".", "getName", "(", ")", ":", "\"\"", ")", ";", "}", "else", "{", "// No JarURLConnection -> need to resort to URL file parsing.", "// We'll assume URLs of the format \"jar:path!/entry\", with the", "// protocol", "// being arbitrary as long as following the entry format.", "// We'll also handle paths with and without leading \"file:\"", "// prefix.", "String", "urlFile", "=", "resourceURL", ".", "getFile", "(", ")", ";", "int", "separatorIndex", "=", "urlFile", ".", "indexOf", "(", "JAR_URL_SEPARATOR", ")", ";", "if", "(", "separatorIndex", "!=", "-", "1", ")", "{", "jarFileUrl", "=", "urlFile", ".", "substring", "(", "0", ",", "separatorIndex", ")", ";", "rootEntryPath", "=", "urlFile", ".", "substring", "(", "separatorIndex", "+", "JAR_URL_SEPARATOR", ".", "length", "(", ")", ")", ";", "jarFile", "=", "getJarFile", "(", "jarFileUrl", ")", ";", "}", "else", "{", "jarFile", "=", "new", "JarFile", "(", "urlFile", ")", ";", "rootEntryPath", "=", "\"\"", ";", "}", "newJarFile", "=", "true", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Unable to find resources name for path '\"", "+", "path", "+", "\"'\"", ",", "e", ")", ";", "}", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "try", "{", "if", "(", "!", "\"\"", ".", "equals", "(", "rootEntryPath", ")", "&&", "!", "rootEntryPath", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "// Root entry path must end with slash to allow for proper", "// matching.", "// The Sun JRE does not return a slash here, but BEA JRockit", "// does.", "rootEntryPath", "=", "rootEntryPath", "+", "\"/\"", ";", "}", "Set", "<", "String", ">", "result", "=", "new", "LinkedHashSet", "<>", "(", "8", ")", ";", "for", "(", "Enumeration", "<", "JarEntry", ">", "entries", "=", "jarFile", ".", "entries", "(", ")", ";", "entries", ".", "hasMoreElements", "(", ")", ";", ")", "{", "JarEntry", "entry", "=", "entries", ".", "nextElement", "(", ")", ";", "String", "entryPath", "=", "entry", ".", "getName", "(", ")", ";", "if", "(", "isDirectChildPath", "(", "rootEntryPath", ",", "entryPath", ")", ")", "{", "String", "relativePath", "=", "entryPath", ".", "substring", "(", "rootEntryPath", ".", "length", "(", ")", ")", ";", "result", ".", "add", "(", "relativePath", ")", ";", "}", "}", "return", "result", ";", "}", "finally", "{", "// Close jar file, but only if freshly obtained -", "// not from JarURLConnection, which might cache the file reference.", "if", "(", "newJarFile", ")", "{", "try", "{", "jarFile", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// Nothing to do", "}", "}", "}", "}" ]
Returns the resources name from a Jar file. @param path the directory path @param resourceURL the jar file URL @return the resources name from a Jar file.
[ "Returns", "the", "resources", "name", "from", "a", "Jar", "file", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/classpath/ClassPathGeneratorHelper.java#L174-L257
7,422
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/iexplore/IENamedResourceFilter.java
IENamedResourceFilter.filterPathSet
public Map<String, List<String>> filterPathSet(Collection<String> paths) { Map<String, List<String>> expressions = new HashMap<>(); List<String> toRemove = new ArrayList<>(); for (Iterator<String> it = paths.iterator(); it.hasNext();) { String path = it.next(); if (COMMENTS_PATTERN.matcher(path).matches()) { Matcher matcher = OPERATORS_PATTERN.matcher(path); matcher.find(); String suffix = matcher.group(); suffix = suffix.substring(0, suffix.lastIndexOf(".")); String expressionKey = createExpressionKey(suffix); if (expressions.containsKey(expressionKey)) { List<String> fileNames = expressions.get(expressionKey); fileNames.add(path); } else { List<String> fileNames = new ArrayList<>(); fileNames.add(path); expressions.put(expressionKey, fileNames); } toRemove.add(path); } } // Remove extracted paths from the source collection for (Iterator<String> it = toRemove.iterator(); it.hasNext();) { paths.remove(it.next()); } return expressions; }
java
public Map<String, List<String>> filterPathSet(Collection<String> paths) { Map<String, List<String>> expressions = new HashMap<>(); List<String> toRemove = new ArrayList<>(); for (Iterator<String> it = paths.iterator(); it.hasNext();) { String path = it.next(); if (COMMENTS_PATTERN.matcher(path).matches()) { Matcher matcher = OPERATORS_PATTERN.matcher(path); matcher.find(); String suffix = matcher.group(); suffix = suffix.substring(0, suffix.lastIndexOf(".")); String expressionKey = createExpressionKey(suffix); if (expressions.containsKey(expressionKey)) { List<String> fileNames = expressions.get(expressionKey); fileNames.add(path); } else { List<String> fileNames = new ArrayList<>(); fileNames.add(path); expressions.put(expressionKey, fileNames); } toRemove.add(path); } } // Remove extracted paths from the source collection for (Iterator<String> it = toRemove.iterator(); it.hasNext();) { paths.remove(it.next()); } return expressions; }
[ "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "filterPathSet", "(", "Collection", "<", "String", ">", "paths", ")", "{", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "expressions", "=", "new", "HashMap", "<>", "(", ")", ";", "List", "<", "String", ">", "toRemove", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "it", "=", "paths", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "String", "path", "=", "it", ".", "next", "(", ")", ";", "if", "(", "COMMENTS_PATTERN", ".", "matcher", "(", "path", ")", ".", "matches", "(", ")", ")", "{", "Matcher", "matcher", "=", "OPERATORS_PATTERN", ".", "matcher", "(", "path", ")", ";", "matcher", ".", "find", "(", ")", ";", "String", "suffix", "=", "matcher", ".", "group", "(", ")", ";", "suffix", "=", "suffix", ".", "substring", "(", "0", ",", "suffix", ".", "lastIndexOf", "(", "\".\"", ")", ")", ";", "String", "expressionKey", "=", "createExpressionKey", "(", "suffix", ")", ";", "if", "(", "expressions", ".", "containsKey", "(", "expressionKey", ")", ")", "{", "List", "<", "String", ">", "fileNames", "=", "expressions", ".", "get", "(", "expressionKey", ")", ";", "fileNames", ".", "add", "(", "path", ")", ";", "}", "else", "{", "List", "<", "String", ">", "fileNames", "=", "new", "ArrayList", "<>", "(", ")", ";", "fileNames", ".", "add", "(", "path", ")", ";", "expressions", ".", "put", "(", "expressionKey", ",", "fileNames", ")", ";", "}", "toRemove", ".", "add", "(", "path", ")", ";", "}", "}", "// Remove extracted paths from the source collection", "for", "(", "Iterator", "<", "String", ">", "it", "=", "toRemove", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "paths", ".", "remove", "(", "it", ".", "next", "(", ")", ")", ";", "}", "return", "expressions", ";", "}" ]
Finds all the paths in a collection which contain IE conditional comment syntax, extracts all of them from the collection. @param paths @return A Map with all the extracted paths, in which the key is the corresponding IE expression and the value is a List instance containing all the paths that match that expression.
[ "Finds", "all", "the", "paths", "in", "a", "collection", "which", "contain", "IE", "conditional", "comment", "syntax", "extracts", "all", "of", "them", "from", "the", "collection", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/iexplore/IENamedResourceFilter.java#L49-L80
7,423
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/iexplore/IENamedResourceFilter.java
IENamedResourceFilter.createExpressionKey
private String createExpressionKey(String suffix) { String[] parts = suffix.split("_"); StringBuilder ret = new StringBuilder("[if "); boolean ieAdded = false; for (String part : parts) { if ("".equals(part)) { continue; } if ("ie".equals(part)) { break; } else if (Pattern.matches("(lt|lte|gt|gte)", part)) { ret.append(part).append(" "); } else { ret.append("IE ").append(part); ieAdded = true; } } if (!ieAdded) ret.append("IE"); ret.append("]"); return ret.toString(); }
java
private String createExpressionKey(String suffix) { String[] parts = suffix.split("_"); StringBuilder ret = new StringBuilder("[if "); boolean ieAdded = false; for (String part : parts) { if ("".equals(part)) { continue; } if ("ie".equals(part)) { break; } else if (Pattern.matches("(lt|lte|gt|gte)", part)) { ret.append(part).append(" "); } else { ret.append("IE ").append(part); ieAdded = true; } } if (!ieAdded) ret.append("IE"); ret.append("]"); return ret.toString(); }
[ "private", "String", "createExpressionKey", "(", "String", "suffix", ")", "{", "String", "[", "]", "parts", "=", "suffix", ".", "split", "(", "\"_\"", ")", ";", "StringBuilder", "ret", "=", "new", "StringBuilder", "(", "\"[if \"", ")", ";", "boolean", "ieAdded", "=", "false", ";", "for", "(", "String", "part", ":", "parts", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "part", ")", ")", "{", "continue", ";", "}", "if", "(", "\"ie\"", ".", "equals", "(", "part", ")", ")", "{", "break", ";", "}", "else", "if", "(", "Pattern", ".", "matches", "(", "\"(lt|lte|gt|gte)\"", ",", "part", ")", ")", "{", "ret", ".", "append", "(", "part", ")", ".", "append", "(", "\" \"", ")", ";", "}", "else", "{", "ret", ".", "append", "(", "\"IE \"", ")", ".", "append", "(", "part", ")", ";", "ieAdded", "=", "true", ";", "}", "}", "if", "(", "!", "ieAdded", ")", "ret", ".", "append", "(", "\"IE\"", ")", ";", "ret", ".", "append", "(", "\"]\"", ")", ";", "return", "ret", ".", "toString", "(", ")", ";", "}" ]
Creates an IE conditional expression by transforming the suffix of a filename. @param suffix @return
[ "Creates", "an", "IE", "conditional", "expression", "by", "transforming", "the", "suffix", "of", "a", "filename", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/iexplore/IENamedResourceFilter.java#L89-L110
7,424
j-a-w-r/jawr-main-repo
jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/AbstractJawrImageReference.java
AbstractJawrImageReference.getHttpServletResponseUrlEncoder
private HttpServletResponse getHttpServletResponseUrlEncoder( final Response response) { return new HttpServletResponse() { public void setLocale(Locale loc) { } public void setContentType(String type) { } public void setContentLength(int len) { } public void setBufferSize(int size) { } public void resetBuffer() { } public void reset() { } public boolean isCommitted() { return false; } public PrintWriter getWriter() throws IOException { return new PrintWriter(new RedirectWriter(getResponse())); } public ServletOutputStream getOutputStream() throws IOException { return null; } public Locale getLocale() { return null; } public int getBufferSize() { return 0; } public void flushBuffer() throws IOException { } public void setStatus(int sc, String sm) { } public void setStatus(int sc) { } public void setIntHeader(String name, int value) { } public void setHeader(String name, String value) { } public void setDateHeader(String name, long date) { } public void sendRedirect(String location) throws IOException { } public void sendError(int sc, String msg) throws IOException { } public void sendError(int sc) throws IOException { } public String encodeUrl(String url) { return response.encodeURL(url).toString(); } public String encodeURL(String url) { return response.encodeURL(url).toString(); } public String encodeRedirectUrl(String url) { return null; } public String encodeRedirectURL(String url) { return null; } public boolean containsHeader(String name) { return false; } public void addIntHeader(String name, int value) { } public void addHeader(String name, String value) { } public void addDateHeader(String name, long date) { } public void addCookie(Cookie cookie) { } public String getContentType() { return null; } public void setCharacterEncoding(String charset) { } @Override public String getCharacterEncoding() { return "UTF-8"; } }; }
java
private HttpServletResponse getHttpServletResponseUrlEncoder( final Response response) { return new HttpServletResponse() { public void setLocale(Locale loc) { } public void setContentType(String type) { } public void setContentLength(int len) { } public void setBufferSize(int size) { } public void resetBuffer() { } public void reset() { } public boolean isCommitted() { return false; } public PrintWriter getWriter() throws IOException { return new PrintWriter(new RedirectWriter(getResponse())); } public ServletOutputStream getOutputStream() throws IOException { return null; } public Locale getLocale() { return null; } public int getBufferSize() { return 0; } public void flushBuffer() throws IOException { } public void setStatus(int sc, String sm) { } public void setStatus(int sc) { } public void setIntHeader(String name, int value) { } public void setHeader(String name, String value) { } public void setDateHeader(String name, long date) { } public void sendRedirect(String location) throws IOException { } public void sendError(int sc, String msg) throws IOException { } public void sendError(int sc) throws IOException { } public String encodeUrl(String url) { return response.encodeURL(url).toString(); } public String encodeURL(String url) { return response.encodeURL(url).toString(); } public String encodeRedirectUrl(String url) { return null; } public String encodeRedirectURL(String url) { return null; } public boolean containsHeader(String name) { return false; } public void addIntHeader(String name, int value) { } public void addHeader(String name, String value) { } public void addDateHeader(String name, long date) { } public void addCookie(Cookie cookie) { } public String getContentType() { return null; } public void setCharacterEncoding(String charset) { } @Override public String getCharacterEncoding() { return "UTF-8"; } }; }
[ "private", "HttpServletResponse", "getHttpServletResponseUrlEncoder", "(", "final", "Response", "response", ")", "{", "return", "new", "HttpServletResponse", "(", ")", "{", "public", "void", "setLocale", "(", "Locale", "loc", ")", "{", "}", "public", "void", "setContentType", "(", "String", "type", ")", "{", "}", "public", "void", "setContentLength", "(", "int", "len", ")", "{", "}", "public", "void", "setBufferSize", "(", "int", "size", ")", "{", "}", "public", "void", "resetBuffer", "(", ")", "{", "}", "public", "void", "reset", "(", ")", "{", "}", "public", "boolean", "isCommitted", "(", ")", "{", "return", "false", ";", "}", "public", "PrintWriter", "getWriter", "(", ")", "throws", "IOException", "{", "return", "new", "PrintWriter", "(", "new", "RedirectWriter", "(", "getResponse", "(", ")", ")", ")", ";", "}", "public", "ServletOutputStream", "getOutputStream", "(", ")", "throws", "IOException", "{", "return", "null", ";", "}", "public", "Locale", "getLocale", "(", ")", "{", "return", "null", ";", "}", "public", "int", "getBufferSize", "(", ")", "{", "return", "0", ";", "}", "public", "void", "flushBuffer", "(", ")", "throws", "IOException", "{", "}", "public", "void", "setStatus", "(", "int", "sc", ",", "String", "sm", ")", "{", "}", "public", "void", "setStatus", "(", "int", "sc", ")", "{", "}", "public", "void", "setIntHeader", "(", "String", "name", ",", "int", "value", ")", "{", "}", "public", "void", "setHeader", "(", "String", "name", ",", "String", "value", ")", "{", "}", "public", "void", "setDateHeader", "(", "String", "name", ",", "long", "date", ")", "{", "}", "public", "void", "sendRedirect", "(", "String", "location", ")", "throws", "IOException", "{", "}", "public", "void", "sendError", "(", "int", "sc", ",", "String", "msg", ")", "throws", "IOException", "{", "}", "public", "void", "sendError", "(", "int", "sc", ")", "throws", "IOException", "{", "}", "public", "String", "encodeUrl", "(", "String", "url", ")", "{", "return", "response", ".", "encodeURL", "(", "url", ")", ".", "toString", "(", ")", ";", "}", "public", "String", "encodeURL", "(", "String", "url", ")", "{", "return", "response", ".", "encodeURL", "(", "url", ")", ".", "toString", "(", ")", ";", "}", "public", "String", "encodeRedirectUrl", "(", "String", "url", ")", "{", "return", "null", ";", "}", "public", "String", "encodeRedirectURL", "(", "String", "url", ")", "{", "return", "null", ";", "}", "public", "boolean", "containsHeader", "(", "String", "name", ")", "{", "return", "false", ";", "}", "public", "void", "addIntHeader", "(", "String", "name", ",", "int", "value", ")", "{", "}", "public", "void", "addHeader", "(", "String", "name", ",", "String", "value", ")", "{", "}", "public", "void", "addDateHeader", "(", "String", "name", ",", "long", "date", ")", "{", "}", "public", "void", "addCookie", "(", "Cookie", "cookie", ")", "{", "}", "public", "String", "getContentType", "(", ")", "{", "return", "null", ";", "}", "public", "void", "setCharacterEncoding", "(", "String", "charset", ")", "{", "}", "@", "Override", "public", "String", "getCharacterEncoding", "(", ")", "{", "return", "\"UTF-8\"", ";", "}", "}", ";", "}" ]
Returns the HttpServletResponse which will be used to encode the URL @param response the response @return the HttpServletResponse which will be used to encode the URL
[ "Returns", "the", "HttpServletResponse", "which", "will", "be", "used", "to", "encode", "the", "URL" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-wicket/jawr-wicket-extension/src/main/java/net/jawr/web/wicket/AbstractJawrImageReference.java#L142-L276
7,425
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/less/JawrLessSource.java
JawrLessSource.addLinkedResource
private void addLinkedResource(FilePathMapping linkedResource) { linkedResources.add(linkedResource); if (parent != null) { parent.addLinkedResource(linkedResource); } }
java
private void addLinkedResource(FilePathMapping linkedResource) { linkedResources.add(linkedResource); if (parent != null) { parent.addLinkedResource(linkedResource); } }
[ "private", "void", "addLinkedResource", "(", "FilePathMapping", "linkedResource", ")", "{", "linkedResources", ".", "add", "(", "linkedResource", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "parent", ".", "addLinkedResource", "(", "linkedResource", ")", ";", "}", "}" ]
Adds a linked resource to the less source @param linkedResource the linked resource to add
[ "Adds", "a", "linked", "resource", "to", "the", "less", "source" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/less/JawrLessSource.java#L134-L139
7,426
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/less/JawrLessSource.java
JawrLessSource.getResourceReader
private Reader getResourceReader(String resource) throws ResourceNotFoundException { List<Class<?>> excluded = new ArrayList<>(); excluded.add(ILessCssResourceGenerator.class); return rsReaderHandler.getResource(bundle, resource, false, excluded); }
java
private Reader getResourceReader(String resource) throws ResourceNotFoundException { List<Class<?>> excluded = new ArrayList<>(); excluded.add(ILessCssResourceGenerator.class); return rsReaderHandler.getResource(bundle, resource, false, excluded); }
[ "private", "Reader", "getResourceReader", "(", "String", "resource", ")", "throws", "ResourceNotFoundException", "{", "List", "<", "Class", "<", "?", ">", ">", "excluded", "=", "new", "ArrayList", "<>", "(", ")", ";", "excluded", ".", "add", "(", "ILessCssResourceGenerator", ".", "class", ")", ";", "return", "rsReaderHandler", ".", "getResource", "(", "bundle", ",", "resource", ",", "false", ",", "excluded", ")", ";", "}" ]
Returns the resource reader @param resource the resource @return the resource reader @throws ResourceNotFoundException if the resource is not found
[ "Returns", "the", "resource", "reader" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/css/less/JawrLessSource.java#L150-L154
7,427
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/CSSURLPathRewriterPostProcessor.java
CSSURLPathRewriterPostProcessor.getFinalFullBundlePath
public String getFinalFullBundlePath(BundleProcessingStatus status) { JawrConfig jawrConfig = status.getJawrConfig(); String bundleName = status.getCurrentBundle().getId(); String bundlePrefix = getBundlePrefix(status, jawrConfig, bundleName); // Concatenate the bundle prefix and the bundle name String fullBundlePath = PathNormalizer.concatWebPath(bundlePrefix, bundleName); return fullBundlePath; }
java
public String getFinalFullBundlePath(BundleProcessingStatus status) { JawrConfig jawrConfig = status.getJawrConfig(); String bundleName = status.getCurrentBundle().getId(); String bundlePrefix = getBundlePrefix(status, jawrConfig, bundleName); // Concatenate the bundle prefix and the bundle name String fullBundlePath = PathNormalizer.concatWebPath(bundlePrefix, bundleName); return fullBundlePath; }
[ "public", "String", "getFinalFullBundlePath", "(", "BundleProcessingStatus", "status", ")", "{", "JawrConfig", "jawrConfig", "=", "status", ".", "getJawrConfig", "(", ")", ";", "String", "bundleName", "=", "status", ".", "getCurrentBundle", "(", ")", ".", "getId", "(", ")", ";", "String", "bundlePrefix", "=", "getBundlePrefix", "(", "status", ",", "jawrConfig", ",", "bundleName", ")", ";", "// Concatenate the bundle prefix and the bundle name", "String", "fullBundlePath", "=", "PathNormalizer", ".", "concatWebPath", "(", "bundlePrefix", ",", "bundleName", ")", ";", "return", "fullBundlePath", ";", "}" ]
Returns the full path for the CSS bundle, taking in account the css servlet path if defined, the caching prefix, and the url context path overridden @param status the bundle processing status @return the full bundle path
[ "Returns", "the", "full", "path", "for", "the", "CSS", "bundle", "taking", "in", "account", "the", "css", "servlet", "path", "if", "defined", "the", "caching", "prefix", "and", "the", "url", "context", "path", "overridden" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/CSSURLPathRewriterPostProcessor.java#L100-L111
7,428
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/CSSURLPathRewriterPostProcessor.java
CSSURLPathRewriterPostProcessor.getBundlePrefix
protected String getBundlePrefix(BundleProcessingStatus status, JawrConfig jawrConfig, String bundleName) { // Generation the bundle prefix String bundlePrefix = status.getCurrentBundle().getBundlePrefix(); if (bundlePrefix == null) { bundlePrefix = ""; } else { bundlePrefix = PathNormalizer.asPath(bundlePrefix); } if (!bundleName.equals(ResourceGenerator.CSS_DEBUGPATH)) { bundlePrefix += FAKE_BUNDLE_PREFIX; } // Add path reference for the servlet mapping if it exists if (!"".equals(jawrConfig.getServletMapping())) { bundlePrefix = PathNormalizer.asPath(jawrConfig.getServletMapping() + bundlePrefix) + "/"; } return bundlePrefix; }
java
protected String getBundlePrefix(BundleProcessingStatus status, JawrConfig jawrConfig, String bundleName) { // Generation the bundle prefix String bundlePrefix = status.getCurrentBundle().getBundlePrefix(); if (bundlePrefix == null) { bundlePrefix = ""; } else { bundlePrefix = PathNormalizer.asPath(bundlePrefix); } if (!bundleName.equals(ResourceGenerator.CSS_DEBUGPATH)) { bundlePrefix += FAKE_BUNDLE_PREFIX; } // Add path reference for the servlet mapping if it exists if (!"".equals(jawrConfig.getServletMapping())) { bundlePrefix = PathNormalizer.asPath(jawrConfig.getServletMapping() + bundlePrefix) + "/"; } return bundlePrefix; }
[ "protected", "String", "getBundlePrefix", "(", "BundleProcessingStatus", "status", ",", "JawrConfig", "jawrConfig", ",", "String", "bundleName", ")", "{", "// Generation the bundle prefix", "String", "bundlePrefix", "=", "status", ".", "getCurrentBundle", "(", ")", ".", "getBundlePrefix", "(", ")", ";", "if", "(", "bundlePrefix", "==", "null", ")", "{", "bundlePrefix", "=", "\"\"", ";", "}", "else", "{", "bundlePrefix", "=", "PathNormalizer", ".", "asPath", "(", "bundlePrefix", ")", ";", "}", "if", "(", "!", "bundleName", ".", "equals", "(", "ResourceGenerator", ".", "CSS_DEBUGPATH", ")", ")", "{", "bundlePrefix", "+=", "FAKE_BUNDLE_PREFIX", ";", "}", "// Add path reference for the servlet mapping if it exists", "if", "(", "!", "\"\"", ".", "equals", "(", "jawrConfig", ".", "getServletMapping", "(", ")", ")", ")", "{", "bundlePrefix", "=", "PathNormalizer", ".", "asPath", "(", "jawrConfig", ".", "getServletMapping", "(", ")", "+", "bundlePrefix", ")", "+", "\"/\"", ";", "}", "return", "bundlePrefix", ";", "}" ]
Returns the bundle prefix @param status the bundle processing status @param jawrConfig the jawr config @param bundleName the bundle name @return the bundle prefix
[ "Returns", "the", "bundle", "prefix" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/CSSURLPathRewriterPostProcessor.java#L124-L142
7,429
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/ResourceBundleDirMapper.java
ResourceBundleDirMapper.initExcludedPathList
private Set<String> initExcludedPathList(Set<String> paths) { Set<String> toExclude = new HashSet<>(); if (null == paths) return toExclude; for (String path : paths) { path = PathNormalizer.asPath(path); toExclude.add(path); } return toExclude; }
java
private Set<String> initExcludedPathList(Set<String> paths) { Set<String> toExclude = new HashSet<>(); if (null == paths) return toExclude; for (String path : paths) { path = PathNormalizer.asPath(path); toExclude.add(path); } return toExclude; }
[ "private", "Set", "<", "String", ">", "initExcludedPathList", "(", "Set", "<", "String", ">", "paths", ")", "{", "Set", "<", "String", ">", "toExclude", "=", "new", "HashSet", "<>", "(", ")", ";", "if", "(", "null", "==", "paths", ")", "return", "toExclude", ";", "for", "(", "String", "path", ":", "paths", ")", "{", "path", "=", "PathNormalizer", ".", "asPath", "(", "path", ")", ";", "toExclude", ".", "add", "(", "path", ")", ";", "}", "return", "toExclude", ";", "}" ]
Determine which paths are to be excluded based on a set of path mappings from the configuration. @param paths the Set of path to exclude @return the Set of path to exclude
[ "Determine", "which", "paths", "are", "to", "be", "excluded", "based", "on", "a", "set", "of", "path", "mappings", "from", "the", "configuration", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/ResourceBundleDirMapper.java#L73-L83
7,430
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/ResourceBundleDirMapper.java
ResourceBundleDirMapper.addBundlesToMapping
@Override protected void addBundlesToMapping() throws DuplicateBundlePathException { Set<String> paths = rsHandler.getResourceNames(baseDir); for (String path : paths) { path = PathNormalizer.joinPaths(baseDir, path); if (!excludedPaths.contains(path) && rsHandler.isDirectory(path)) { String bundleKey = path + resourceExtension; addBundleToMap(bundleKey, path + "/**"); if (LOGGER.isDebugEnabled()) LOGGER.debug("Added [" + bundleKey + "] with value [" + path + "/**] to a generated path list"); } } }
java
@Override protected void addBundlesToMapping() throws DuplicateBundlePathException { Set<String> paths = rsHandler.getResourceNames(baseDir); for (String path : paths) { path = PathNormalizer.joinPaths(baseDir, path); if (!excludedPaths.contains(path) && rsHandler.isDirectory(path)) { String bundleKey = path + resourceExtension; addBundleToMap(bundleKey, path + "/**"); if (LOGGER.isDebugEnabled()) LOGGER.debug("Added [" + bundleKey + "] with value [" + path + "/**] to a generated path list"); } } }
[ "@", "Override", "protected", "void", "addBundlesToMapping", "(", ")", "throws", "DuplicateBundlePathException", "{", "Set", "<", "String", ">", "paths", "=", "rsHandler", ".", "getResourceNames", "(", "baseDir", ")", ";", "for", "(", "String", "path", ":", "paths", ")", "{", "path", "=", "PathNormalizer", ".", "joinPaths", "(", "baseDir", ",", "path", ")", ";", "if", "(", "!", "excludedPaths", ".", "contains", "(", "path", ")", "&&", "rsHandler", ".", "isDirectory", "(", "path", ")", ")", "{", "String", "bundleKey", "=", "path", "+", "resourceExtension", ";", "addBundleToMap", "(", "bundleKey", ",", "path", "+", "\"/**\"", ")", ";", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "LOGGER", ".", "debug", "(", "\"Added [\"", "+", "bundleKey", "+", "\"] with value [\"", "+", "path", "+", "\"/**] to a generated path list\"", ")", ";", "}", "}", "}" ]
Generates the resource bundles mapping expressions. @throws DuplicateBundlePathException if a duplicate path is found in the bundle
[ "Generates", "the", "resource", "bundles", "mapping", "expressions", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/mapper/ResourceBundleDirMapper.java#L91-L104
7,431
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/sorting/SortFileParser.java
SortFileParser.getSortedResources
public List<String> getSortedResources() { List<String> resources = new ArrayList<>(); try (BufferedReader bf = new BufferedReader(reader)) { String res; while ((res = bf.readLine()) != null) { String name = PathNormalizer.normalizePath(res.trim()); for (String available : availableResources) { if (PathNormalizer.normalizePath(available).equals(name)) { if (name.endsWith(".js") || name.endsWith(".css")) resources.add(PathNormalizer.joinPaths(dirName, name)); else resources.add(PathNormalizer.joinPaths(dirName, name + "/")); availableResources.remove(available); break; } } } } catch (IOException e) { throw new BundlingProcessException("Unexpected IOException reading sort file", e); } return resources; }
java
public List<String> getSortedResources() { List<String> resources = new ArrayList<>(); try (BufferedReader bf = new BufferedReader(reader)) { String res; while ((res = bf.readLine()) != null) { String name = PathNormalizer.normalizePath(res.trim()); for (String available : availableResources) { if (PathNormalizer.normalizePath(available).equals(name)) { if (name.endsWith(".js") || name.endsWith(".css")) resources.add(PathNormalizer.joinPaths(dirName, name)); else resources.add(PathNormalizer.joinPaths(dirName, name + "/")); availableResources.remove(available); break; } } } } catch (IOException e) { throw new BundlingProcessException("Unexpected IOException reading sort file", e); } return resources; }
[ "public", "List", "<", "String", ">", "getSortedResources", "(", ")", "{", "List", "<", "String", ">", "resources", "=", "new", "ArrayList", "<>", "(", ")", ";", "try", "(", "BufferedReader", "bf", "=", "new", "BufferedReader", "(", "reader", ")", ")", "{", "String", "res", ";", "while", "(", "(", "res", "=", "bf", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "String", "name", "=", "PathNormalizer", ".", "normalizePath", "(", "res", ".", "trim", "(", ")", ")", ";", "for", "(", "String", "available", ":", "availableResources", ")", "{", "if", "(", "PathNormalizer", ".", "normalizePath", "(", "available", ")", ".", "equals", "(", "name", ")", ")", "{", "if", "(", "name", ".", "endsWith", "(", "\".js\"", ")", "||", "name", ".", "endsWith", "(", "\".css\"", ")", ")", "resources", ".", "add", "(", "PathNormalizer", ".", "joinPaths", "(", "dirName", ",", "name", ")", ")", ";", "else", "resources", ".", "add", "(", "PathNormalizer", ".", "joinPaths", "(", "dirName", ",", "name", "+", "\"/\"", ")", ")", ";", "availableResources", ".", "remove", "(", "available", ")", ";", "break", ";", "}", "}", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Unexpected IOException reading sort file\"", ",", "e", ")", ";", "}", "return", "resources", ";", "}" ]
Creates a list with the ordered resource names and returns it. If a resource is not in the resources dir, it is ignored. @return the list of ordered resource names
[ "Creates", "a", "list", "with", "the", "ordered", "resource", "names", "and", "returns", "it", ".", "If", "a", "resource", "is", "not", "in", "the", "resources", "dir", "it", "is", "ignored", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/sorting/SortFileParser.java#L67-L89
7,432
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/el/EvalHelper.java
EvalHelper.evalString
public static String evalString(String propertyName, String propertyValue, Tag tag, PageContext pageContext) throws JspException{ return (String) ExpressionEvaluatorManager.evaluate(propertyName, propertyValue, String.class, tag, pageContext); }
java
public static String evalString(String propertyName, String propertyValue, Tag tag, PageContext pageContext) throws JspException{ return (String) ExpressionEvaluatorManager.evaluate(propertyName, propertyValue, String.class, tag, pageContext); }
[ "public", "static", "String", "evalString", "(", "String", "propertyName", ",", "String", "propertyValue", ",", "Tag", "tag", ",", "PageContext", "pageContext", ")", "throws", "JspException", "{", "return", "(", "String", ")", "ExpressionEvaluatorManager", ".", "evaluate", "(", "propertyName", ",", "propertyValue", ",", "String", ".", "class", ",", "tag", ",", "pageContext", ")", ";", "}" ]
Evaluate the string EL expression passed as parameter @param propertyName the property name @param propertyValue the property value @param tag the tag @param pageContext the page context @return the value corresponding to the EL expression passed as parameter @throws JspException if an exception occurs
[ "Evaluate", "the", "string", "EL", "expression", "passed", "as", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/el/EvalHelper.java#L39-L43
7,433
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/el/EvalHelper.java
EvalHelper.evalBoolean
public static Boolean evalBoolean(String propertyName, String propertyValue, Tag tag, PageContext pageContext) throws JspException{ return (Boolean) ExpressionEvaluatorManager.evaluate(propertyName, propertyValue, Boolean.class, tag, pageContext); }
java
public static Boolean evalBoolean(String propertyName, String propertyValue, Tag tag, PageContext pageContext) throws JspException{ return (Boolean) ExpressionEvaluatorManager.evaluate(propertyName, propertyValue, Boolean.class, tag, pageContext); }
[ "public", "static", "Boolean", "evalBoolean", "(", "String", "propertyName", ",", "String", "propertyValue", ",", "Tag", "tag", ",", "PageContext", "pageContext", ")", "throws", "JspException", "{", "return", "(", "Boolean", ")", "ExpressionEvaluatorManager", ".", "evaluate", "(", "propertyName", ",", "propertyValue", ",", "Boolean", ".", "class", ",", "tag", ",", "pageContext", ")", ";", "}" ]
Evaluate the boolean EL expression passed as parameter @param propertyName the property name @param propertyValue the property value @param tag the tag @param pageContext the page context @return the value corresponding to the EL expression passed as parameter @throws JspException if an exception occurs
[ "Evaluate", "the", "boolean", "EL", "expression", "passed", "as", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/el/EvalHelper.java#L54-L58
7,434
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java
FullMappingPropertiesBasedBundlesHandlerFactory.getResourceBundles
public List<JoinableResourceBundle> getResourceBundles(Properties properties) { PropertiesConfigHelper props = new PropertiesConfigHelper(properties, resourceType); String fileExtension = "." + resourceType; // Initialize custom bundles List<JoinableResourceBundle> customBundles = new ArrayList<>(); // Check if we should use the bundle names property or // find the bundle name using the bundle id declaration : // jawr.<type>.bundle.<name>.id if (null != props.getProperty(PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_NAMES)) { StringTokenizer tk = new StringTokenizer( props.getProperty(PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_NAMES), ","); while (tk.hasMoreTokens()) { customBundles .add(buildJoinableResourceBundle(props, tk.nextToken().trim(), fileExtension, rsReaderHandler)); } } else { Iterator<String> bundleNames = props.getPropertyBundleNameSet().iterator(); while (bundleNames.hasNext()) { customBundles .add(buildJoinableResourceBundle(props, bundleNames.next(), fileExtension, rsReaderHandler)); } } // Initialize the bundles dependencies Iterator<String> bundleNames = props.getPropertyBundleNameSet().iterator(); while (bundleNames.hasNext()) { String bundleName = (String) bundleNames.next(); List<String> bundleNameDependencies = props.getCustomBundlePropertyAsList(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_DEPENDENCIES); if (!bundleNameDependencies.isEmpty()) { JoinableResourceBundle bundle = getBundleFromName(bundleName, customBundles); List<JoinableResourceBundle> bundleDependencies = getBundlesFromName(bundleNameDependencies, customBundles); bundle.setDependencies(bundleDependencies); } } return customBundles; }
java
public List<JoinableResourceBundle> getResourceBundles(Properties properties) { PropertiesConfigHelper props = new PropertiesConfigHelper(properties, resourceType); String fileExtension = "." + resourceType; // Initialize custom bundles List<JoinableResourceBundle> customBundles = new ArrayList<>(); // Check if we should use the bundle names property or // find the bundle name using the bundle id declaration : // jawr.<type>.bundle.<name>.id if (null != props.getProperty(PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_NAMES)) { StringTokenizer tk = new StringTokenizer( props.getProperty(PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_NAMES), ","); while (tk.hasMoreTokens()) { customBundles .add(buildJoinableResourceBundle(props, tk.nextToken().trim(), fileExtension, rsReaderHandler)); } } else { Iterator<String> bundleNames = props.getPropertyBundleNameSet().iterator(); while (bundleNames.hasNext()) { customBundles .add(buildJoinableResourceBundle(props, bundleNames.next(), fileExtension, rsReaderHandler)); } } // Initialize the bundles dependencies Iterator<String> bundleNames = props.getPropertyBundleNameSet().iterator(); while (bundleNames.hasNext()) { String bundleName = (String) bundleNames.next(); List<String> bundleNameDependencies = props.getCustomBundlePropertyAsList(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_DEPENDENCIES); if (!bundleNameDependencies.isEmpty()) { JoinableResourceBundle bundle = getBundleFromName(bundleName, customBundles); List<JoinableResourceBundle> bundleDependencies = getBundlesFromName(bundleNameDependencies, customBundles); bundle.setDependencies(bundleDependencies); } } return customBundles; }
[ "public", "List", "<", "JoinableResourceBundle", ">", "getResourceBundles", "(", "Properties", "properties", ")", "{", "PropertiesConfigHelper", "props", "=", "new", "PropertiesConfigHelper", "(", "properties", ",", "resourceType", ")", ";", "String", "fileExtension", "=", "\".\"", "+", "resourceType", ";", "// Initialize custom bundles", "List", "<", "JoinableResourceBundle", ">", "customBundles", "=", "new", "ArrayList", "<>", "(", ")", ";", "// Check if we should use the bundle names property or", "// find the bundle name using the bundle id declaration :", "// jawr.<type>.bundle.<name>.id", "if", "(", "null", "!=", "props", ".", "getProperty", "(", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_NAMES", ")", ")", "{", "StringTokenizer", "tk", "=", "new", "StringTokenizer", "(", "props", ".", "getProperty", "(", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_NAMES", ")", ",", "\",\"", ")", ";", "while", "(", "tk", ".", "hasMoreTokens", "(", ")", ")", "{", "customBundles", ".", "add", "(", "buildJoinableResourceBundle", "(", "props", ",", "tk", ".", "nextToken", "(", ")", ".", "trim", "(", ")", ",", "fileExtension", ",", "rsReaderHandler", ")", ")", ";", "}", "}", "else", "{", "Iterator", "<", "String", ">", "bundleNames", "=", "props", ".", "getPropertyBundleNameSet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "bundleNames", ".", "hasNext", "(", ")", ")", "{", "customBundles", ".", "add", "(", "buildJoinableResourceBundle", "(", "props", ",", "bundleNames", ".", "next", "(", ")", ",", "fileExtension", ",", "rsReaderHandler", ")", ")", ";", "}", "}", "// Initialize the bundles dependencies", "Iterator", "<", "String", ">", "bundleNames", "=", "props", ".", "getPropertyBundleNameSet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "bundleNames", ".", "hasNext", "(", ")", ")", "{", "String", "bundleName", "=", "(", "String", ")", "bundleNames", ".", "next", "(", ")", ";", "List", "<", "String", ">", "bundleNameDependencies", "=", "props", ".", "getCustomBundlePropertyAsList", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_DEPENDENCIES", ")", ";", "if", "(", "!", "bundleNameDependencies", ".", "isEmpty", "(", ")", ")", "{", "JoinableResourceBundle", "bundle", "=", "getBundleFromName", "(", "bundleName", ",", "customBundles", ")", ";", "List", "<", "JoinableResourceBundle", ">", "bundleDependencies", "=", "getBundlesFromName", "(", "bundleNameDependencies", ",", "customBundles", ")", ";", "bundle", ".", "setDependencies", "(", "bundleDependencies", ")", ";", "}", "}", "return", "customBundles", ";", "}" ]
Returns the list of joinable resource bundle @param properties the properties @return the list of joinable resource bundle
[ "Returns", "the", "list", "of", "joinable", "resource", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java#L97-L137
7,435
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java
FullMappingPropertiesBasedBundlesHandlerFactory.getBundleFromName
private JoinableResourceBundle getBundleFromName(String bundleName, List<JoinableResourceBundle> bundles) { JoinableResourceBundle bundle = null; List<String> names = new ArrayList<>(); names.add(bundleName); List<JoinableResourceBundle> result = getBundlesFromName(names, bundles); if (!result.isEmpty()) { bundle = result.get(0); } return bundle; }
java
private JoinableResourceBundle getBundleFromName(String bundleName, List<JoinableResourceBundle> bundles) { JoinableResourceBundle bundle = null; List<String> names = new ArrayList<>(); names.add(bundleName); List<JoinableResourceBundle> result = getBundlesFromName(names, bundles); if (!result.isEmpty()) { bundle = result.get(0); } return bundle; }
[ "private", "JoinableResourceBundle", "getBundleFromName", "(", "String", "bundleName", ",", "List", "<", "JoinableResourceBundle", ">", "bundles", ")", "{", "JoinableResourceBundle", "bundle", "=", "null", ";", "List", "<", "String", ">", "names", "=", "new", "ArrayList", "<>", "(", ")", ";", "names", ".", "add", "(", "bundleName", ")", ";", "List", "<", "JoinableResourceBundle", ">", "result", "=", "getBundlesFromName", "(", "names", ",", "bundles", ")", ";", "if", "(", "!", "result", ".", "isEmpty", "(", ")", ")", "{", "bundle", "=", "result", ".", "get", "(", "0", ")", ";", "}", "return", "bundle", ";", "}" ]
Returns a bundle using the bundle name from a list of bundles @param bundleName the bundle name @param bundles the list of bundle @return a bundle
[ "Returns", "a", "bundle", "using", "the", "bundle", "name", "from", "a", "list", "of", "bundles" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java#L148-L158
7,436
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java
FullMappingPropertiesBasedBundlesHandlerFactory.getBundlesFromName
private List<JoinableResourceBundle> getBundlesFromName(List<String> names, List<JoinableResourceBundle> bundles) { List<JoinableResourceBundle> resultBundles = new ArrayList<>(); for (String name : names) { for (JoinableResourceBundle bundle : bundles) { if (bundle.getName().equals(name)) { resultBundles.add(bundle); } } } return resultBundles; }
java
private List<JoinableResourceBundle> getBundlesFromName(List<String> names, List<JoinableResourceBundle> bundles) { List<JoinableResourceBundle> resultBundles = new ArrayList<>(); for (String name : names) { for (JoinableResourceBundle bundle : bundles) { if (bundle.getName().equals(name)) { resultBundles.add(bundle); } } } return resultBundles; }
[ "private", "List", "<", "JoinableResourceBundle", ">", "getBundlesFromName", "(", "List", "<", "String", ">", "names", ",", "List", "<", "JoinableResourceBundle", ">", "bundles", ")", "{", "List", "<", "JoinableResourceBundle", ">", "resultBundles", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "name", ":", "names", ")", "{", "for", "(", "JoinableResourceBundle", "bundle", ":", "bundles", ")", "{", "if", "(", "bundle", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "resultBundles", ".", "add", "(", "bundle", ")", ";", "}", "}", "}", "return", "resultBundles", ";", "}" ]
Returns a list of bundles using the bundle names from a list of bundles @param names the list of bundle name @param bundles the list of bundle @return a list of bundles
[ "Returns", "a", "list", "of", "bundles", "using", "the", "bundle", "names", "from", "a", "list", "of", "bundles" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java#L169-L181
7,437
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java
FullMappingPropertiesBasedBundlesHandlerFactory.verifyIfBundleIsModified
private void verifyIfBundleIsModified(JoinableResourceBundleImpl bundle, List<String> mappings, PropertiesConfigHelper props) { // Retrieves current available variant Map<String, VariantSet> variants = new TreeMap<>(); for (String mapping : mappings) { variants = VariantUtils.concatVariants(variants, generatorRegistry.getAvailableVariants(mapping)); } // Checks if the current variant are the same as the stored one if (!variants.equals(bundle.getVariants())) { bundle.setVariants(variants); bundle.setDirty(true); } else { String bundleName = bundle.getName(); List<String> fileMappings = props.getCustomBundlePropertyAsList(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_FILEPATH_MAPPINGS); if (fileMappings != null) { List<FilePathMapping> bundleFileMappings = bundle.getFilePathMappings(); if (bundleFileMappings.size() != fileMappings.size()) { bundle.setDirty(true); } else { Set<FilePathMapping> storedFilePathMapping = new HashSet<>(); for (String filePathWithTimeStamp : fileMappings) { String[] tmp = filePathWithTimeStamp.split(LAST_MODIFIED_SEPARATOR); String filePath = tmp[0]; long storedLastModified = Long.parseLong(tmp[1]); storedFilePathMapping.add(new FilePathMapping(bundle, filePath, storedLastModified)); } Set<FilePathMapping> bundleFilePathMappingSet = new HashSet<>(bundleFileMappings); if (!bundleFilePathMappingSet.equals(storedFilePathMapping)) { bundle.setDirty(true); } } } // Checks if the linked resource has been modified fileMappings = props.getCustomBundlePropertyAsList(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_LINKED_FILEPATH_MAPPINGS); for (String filePathWithTimeStamp : fileMappings) { int idx = filePathWithTimeStamp.lastIndexOf(LAST_MODIFIED_SEPARATOR); if (idx != -1) { String filePath = filePathWithTimeStamp.substring(0, idx); long storedLastModified = Long.parseLong(filePathWithTimeStamp.substring(idx + 1)); long currentLastModified = rsReaderHandler.getLastModified(filePath); FilePathMapping fPathMapping = new FilePathMapping(bundle, filePath, currentLastModified); bundle.getLinkedFilePathMappings().add(fPathMapping); if (storedLastModified != currentLastModified) { bundle.setDirty(true); } } } } }
java
private void verifyIfBundleIsModified(JoinableResourceBundleImpl bundle, List<String> mappings, PropertiesConfigHelper props) { // Retrieves current available variant Map<String, VariantSet> variants = new TreeMap<>(); for (String mapping : mappings) { variants = VariantUtils.concatVariants(variants, generatorRegistry.getAvailableVariants(mapping)); } // Checks if the current variant are the same as the stored one if (!variants.equals(bundle.getVariants())) { bundle.setVariants(variants); bundle.setDirty(true); } else { String bundleName = bundle.getName(); List<String> fileMappings = props.getCustomBundlePropertyAsList(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_FILEPATH_MAPPINGS); if (fileMappings != null) { List<FilePathMapping> bundleFileMappings = bundle.getFilePathMappings(); if (bundleFileMappings.size() != fileMappings.size()) { bundle.setDirty(true); } else { Set<FilePathMapping> storedFilePathMapping = new HashSet<>(); for (String filePathWithTimeStamp : fileMappings) { String[] tmp = filePathWithTimeStamp.split(LAST_MODIFIED_SEPARATOR); String filePath = tmp[0]; long storedLastModified = Long.parseLong(tmp[1]); storedFilePathMapping.add(new FilePathMapping(bundle, filePath, storedLastModified)); } Set<FilePathMapping> bundleFilePathMappingSet = new HashSet<>(bundleFileMappings); if (!bundleFilePathMappingSet.equals(storedFilePathMapping)) { bundle.setDirty(true); } } } // Checks if the linked resource has been modified fileMappings = props.getCustomBundlePropertyAsList(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_LINKED_FILEPATH_MAPPINGS); for (String filePathWithTimeStamp : fileMappings) { int idx = filePathWithTimeStamp.lastIndexOf(LAST_MODIFIED_SEPARATOR); if (idx != -1) { String filePath = filePathWithTimeStamp.substring(0, idx); long storedLastModified = Long.parseLong(filePathWithTimeStamp.substring(idx + 1)); long currentLastModified = rsReaderHandler.getLastModified(filePath); FilePathMapping fPathMapping = new FilePathMapping(bundle, filePath, currentLastModified); bundle.getLinkedFilePathMappings().add(fPathMapping); if (storedLastModified != currentLastModified) { bundle.setDirty(true); } } } } }
[ "private", "void", "verifyIfBundleIsModified", "(", "JoinableResourceBundleImpl", "bundle", ",", "List", "<", "String", ">", "mappings", ",", "PropertiesConfigHelper", "props", ")", "{", "// Retrieves current available variant", "Map", "<", "String", ",", "VariantSet", ">", "variants", "=", "new", "TreeMap", "<>", "(", ")", ";", "for", "(", "String", "mapping", ":", "mappings", ")", "{", "variants", "=", "VariantUtils", ".", "concatVariants", "(", "variants", ",", "generatorRegistry", ".", "getAvailableVariants", "(", "mapping", ")", ")", ";", "}", "// Checks if the current variant are the same as the stored one", "if", "(", "!", "variants", ".", "equals", "(", "bundle", ".", "getVariants", "(", ")", ")", ")", "{", "bundle", ".", "setVariants", "(", "variants", ")", ";", "bundle", ".", "setDirty", "(", "true", ")", ";", "}", "else", "{", "String", "bundleName", "=", "bundle", ".", "getName", "(", ")", ";", "List", "<", "String", ">", "fileMappings", "=", "props", ".", "getCustomBundlePropertyAsList", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_FILEPATH_MAPPINGS", ")", ";", "if", "(", "fileMappings", "!=", "null", ")", "{", "List", "<", "FilePathMapping", ">", "bundleFileMappings", "=", "bundle", ".", "getFilePathMappings", "(", ")", ";", "if", "(", "bundleFileMappings", ".", "size", "(", ")", "!=", "fileMappings", ".", "size", "(", ")", ")", "{", "bundle", ".", "setDirty", "(", "true", ")", ";", "}", "else", "{", "Set", "<", "FilePathMapping", ">", "storedFilePathMapping", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "String", "filePathWithTimeStamp", ":", "fileMappings", ")", "{", "String", "[", "]", "tmp", "=", "filePathWithTimeStamp", ".", "split", "(", "LAST_MODIFIED_SEPARATOR", ")", ";", "String", "filePath", "=", "tmp", "[", "0", "]", ";", "long", "storedLastModified", "=", "Long", ".", "parseLong", "(", "tmp", "[", "1", "]", ")", ";", "storedFilePathMapping", ".", "add", "(", "new", "FilePathMapping", "(", "bundle", ",", "filePath", ",", "storedLastModified", ")", ")", ";", "}", "Set", "<", "FilePathMapping", ">", "bundleFilePathMappingSet", "=", "new", "HashSet", "<>", "(", "bundleFileMappings", ")", ";", "if", "(", "!", "bundleFilePathMappingSet", ".", "equals", "(", "storedFilePathMapping", ")", ")", "{", "bundle", ".", "setDirty", "(", "true", ")", ";", "}", "}", "}", "// Checks if the linked resource has been modified", "fileMappings", "=", "props", ".", "getCustomBundlePropertyAsList", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_LINKED_FILEPATH_MAPPINGS", ")", ";", "for", "(", "String", "filePathWithTimeStamp", ":", "fileMappings", ")", "{", "int", "idx", "=", "filePathWithTimeStamp", ".", "lastIndexOf", "(", "LAST_MODIFIED_SEPARATOR", ")", ";", "if", "(", "idx", "!=", "-", "1", ")", "{", "String", "filePath", "=", "filePathWithTimeStamp", ".", "substring", "(", "0", ",", "idx", ")", ";", "long", "storedLastModified", "=", "Long", ".", "parseLong", "(", "filePathWithTimeStamp", ".", "substring", "(", "idx", "+", "1", ")", ")", ";", "long", "currentLastModified", "=", "rsReaderHandler", ".", "getLastModified", "(", "filePath", ")", ";", "FilePathMapping", "fPathMapping", "=", "new", "FilePathMapping", "(", "bundle", ",", "filePath", ",", "currentLastModified", ")", ";", "bundle", ".", "getLinkedFilePathMappings", "(", ")", ".", "add", "(", "fPathMapping", ")", ";", "if", "(", "storedLastModified", "!=", "currentLastModified", ")", "{", "bundle", ".", "setDirty", "(", "true", ")", ";", "}", "}", "}", "}", "}" ]
Verify f the bundle has been modified @param bundle the bundle @param mappings the bundle mappings @param props the properties config helper
[ "Verify", "f", "the", "bundle", "has", "been", "modified" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java#L324-L383
7,438
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java
FullMappingPropertiesBasedBundlesHandlerFactory.getInclusionPattern
private InclusionPattern getInclusionPattern(PropertiesConfigHelper props, String bundleName) { // Whether it's global or not boolean isGlobal = Boolean.parseBoolean(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_GLOBAL_FLAG, "false")); // Set order if its a global bundle int order = 0; if (isGlobal) { order = Integer.parseInt(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_ORDER, "0")); } // Use only with debug mode on boolean isDebugOnly = Boolean.parseBoolean(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_DEBUGONLY, "false")); // Use only with debug mode off boolean isDebugNever = Boolean.parseBoolean(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_DEBUGNEVER, "false")); return new InclusionPattern(isGlobal, order, DebugInclusion.get(isDebugOnly, isDebugNever)); }
java
private InclusionPattern getInclusionPattern(PropertiesConfigHelper props, String bundleName) { // Whether it's global or not boolean isGlobal = Boolean.parseBoolean(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_GLOBAL_FLAG, "false")); // Set order if its a global bundle int order = 0; if (isGlobal) { order = Integer.parseInt(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_ORDER, "0")); } // Use only with debug mode on boolean isDebugOnly = Boolean.parseBoolean(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_DEBUGONLY, "false")); // Use only with debug mode off boolean isDebugNever = Boolean.parseBoolean(props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_DEBUGNEVER, "false")); return new InclusionPattern(isGlobal, order, DebugInclusion.get(isDebugOnly, isDebugNever)); }
[ "private", "InclusionPattern", "getInclusionPattern", "(", "PropertiesConfigHelper", "props", ",", "String", "bundleName", ")", "{", "// Whether it's global or not", "boolean", "isGlobal", "=", "Boolean", ".", "parseBoolean", "(", "props", ".", "getCustomBundleProperty", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_GLOBAL_FLAG", ",", "\"false\"", ")", ")", ";", "// Set order if its a global bundle", "int", "order", "=", "0", ";", "if", "(", "isGlobal", ")", "{", "order", "=", "Integer", ".", "parseInt", "(", "props", ".", "getCustomBundleProperty", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_ORDER", ",", "\"0\"", ")", ")", ";", "}", "// Use only with debug mode on", "boolean", "isDebugOnly", "=", "Boolean", ".", "parseBoolean", "(", "props", ".", "getCustomBundleProperty", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_DEBUGONLY", ",", "\"false\"", ")", ")", ";", "// Use only with debug mode off", "boolean", "isDebugNever", "=", "Boolean", ".", "parseBoolean", "(", "props", ".", "getCustomBundleProperty", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_DEBUGNEVER", ",", "\"false\"", ")", ")", ";", "return", "new", "InclusionPattern", "(", "isGlobal", ",", "order", ",", "DebugInclusion", ".", "get", "(", "isDebugOnly", ",", "isDebugNever", ")", ")", ";", "}" ]
Returns the inclusion pattern for a bundle @param props the properties helper @param bundleName the bundle name @return the inclusion pattern for a bundle
[ "Returns", "the", "inclusion", "pattern", "for", "a", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/FullMappingPropertiesBasedBundlesHandlerFactory.java#L394-L415
7,439
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/PostProcessorCssImageUrlRewriter.java
PostProcessorCssImageUrlRewriter.isBinaryResource
protected boolean isBinaryResource(String resourcePath) { String extension = FileNameUtils.getExtension(resourcePath); if (extension != null) { extension = extension.toLowerCase(); } return MIMETypesSupport.getSupportedProperties(this).containsKey(extension); }
java
protected boolean isBinaryResource(String resourcePath) { String extension = FileNameUtils.getExtension(resourcePath); if (extension != null) { extension = extension.toLowerCase(); } return MIMETypesSupport.getSupportedProperties(this).containsKey(extension); }
[ "protected", "boolean", "isBinaryResource", "(", "String", "resourcePath", ")", "{", "String", "extension", "=", "FileNameUtils", ".", "getExtension", "(", "resourcePath", ")", ";", "if", "(", "extension", "!=", "null", ")", "{", "extension", "=", "extension", ".", "toLowerCase", "(", ")", ";", "}", "return", "MIMETypesSupport", ".", "getSupportedProperties", "(", "this", ")", ".", "containsKey", "(", "extension", ")", ";", "}" ]
Checks if the resource is an binary resource @param resourcePath the resourcePath @return true if the resource is an binary resource
[ "Checks", "if", "the", "resource", "is", "an", "binary", "resource" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/PostProcessorCssImageUrlRewriter.java#L213-L219
7,440
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/PostProcessorCssImageUrlRewriter.java
PostProcessorCssImageUrlRewriter.addCacheBuster
private String addCacheBuster(String url, BinaryResourcesHandler binaryRsHandler) throws IOException { if (binaryRsHandler != null) { FilePathMappingUtils.buildFilePathMapping(bundle, url, binaryRsHandler.getRsReaderHandler()); } // Try to retrieve the cache busted URL from the bundle processing cache String newUrl = null; if (binaryMapping != null) { newUrl = binaryMapping.get(url); if (newUrl != null) { return newUrl; } } // Try to retrieve the from the image resource handler cache if (binaryRsHandler != null) { newUrl = binaryRsHandler.getCacheUrl(url); if (newUrl != null) { return newUrl; } // Retrieve the new URL with the cache prefix try { newUrl = CheckSumUtils.getCacheBustedUrl(url, binaryRsHandler.getRsReaderHandler(), binaryRsHandler.getConfig()); } catch (ResourceNotFoundException e) { LOGGER.info("Impossible to define the checksum for the resource '" + url + "'. "); return url; } catch (IOException e) { LOGGER.info("Impossible to define the checksum for the resource '" + url + "'."); return url; } binaryRsHandler.addMapping(url, newUrl); } else { newUrl = url; } binaryMapping.put(url, newUrl); return newUrl; }
java
private String addCacheBuster(String url, BinaryResourcesHandler binaryRsHandler) throws IOException { if (binaryRsHandler != null) { FilePathMappingUtils.buildFilePathMapping(bundle, url, binaryRsHandler.getRsReaderHandler()); } // Try to retrieve the cache busted URL from the bundle processing cache String newUrl = null; if (binaryMapping != null) { newUrl = binaryMapping.get(url); if (newUrl != null) { return newUrl; } } // Try to retrieve the from the image resource handler cache if (binaryRsHandler != null) { newUrl = binaryRsHandler.getCacheUrl(url); if (newUrl != null) { return newUrl; } // Retrieve the new URL with the cache prefix try { newUrl = CheckSumUtils.getCacheBustedUrl(url, binaryRsHandler.getRsReaderHandler(), binaryRsHandler.getConfig()); } catch (ResourceNotFoundException e) { LOGGER.info("Impossible to define the checksum for the resource '" + url + "'. "); return url; } catch (IOException e) { LOGGER.info("Impossible to define the checksum for the resource '" + url + "'."); return url; } binaryRsHandler.addMapping(url, newUrl); } else { newUrl = url; } binaryMapping.put(url, newUrl); return newUrl; }
[ "private", "String", "addCacheBuster", "(", "String", "url", ",", "BinaryResourcesHandler", "binaryRsHandler", ")", "throws", "IOException", "{", "if", "(", "binaryRsHandler", "!=", "null", ")", "{", "FilePathMappingUtils", ".", "buildFilePathMapping", "(", "bundle", ",", "url", ",", "binaryRsHandler", ".", "getRsReaderHandler", "(", ")", ")", ";", "}", "// Try to retrieve the cache busted URL from the bundle processing cache", "String", "newUrl", "=", "null", ";", "if", "(", "binaryMapping", "!=", "null", ")", "{", "newUrl", "=", "binaryMapping", ".", "get", "(", "url", ")", ";", "if", "(", "newUrl", "!=", "null", ")", "{", "return", "newUrl", ";", "}", "}", "// Try to retrieve the from the image resource handler cache", "if", "(", "binaryRsHandler", "!=", "null", ")", "{", "newUrl", "=", "binaryRsHandler", ".", "getCacheUrl", "(", "url", ")", ";", "if", "(", "newUrl", "!=", "null", ")", "{", "return", "newUrl", ";", "}", "// Retrieve the new URL with the cache prefix", "try", "{", "newUrl", "=", "CheckSumUtils", ".", "getCacheBustedUrl", "(", "url", ",", "binaryRsHandler", ".", "getRsReaderHandler", "(", ")", ",", "binaryRsHandler", ".", "getConfig", "(", ")", ")", ";", "}", "catch", "(", "ResourceNotFoundException", "e", ")", "{", "LOGGER", ".", "info", "(", "\"Impossible to define the checksum for the resource '\"", "+", "url", "+", "\"'. \"", ")", ";", "return", "url", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "info", "(", "\"Impossible to define the checksum for the resource '\"", "+", "url", "+", "\"'.\"", ")", ";", "return", "url", ";", "}", "binaryRsHandler", ".", "addMapping", "(", "url", ",", "newUrl", ")", ";", "}", "else", "{", "newUrl", "=", "url", ";", "}", "binaryMapping", ".", "put", "(", "url", ",", "newUrl", ")", ";", "return", "newUrl", ";", "}" ]
Adds the cache buster to the CSS image @param url the URL of the image @param binaryRsHandler the binary resource handler @return the url of the CSS image with a cache buster @throws IOException if an IO exception occurs
[ "Adds", "the", "cache", "buster", "to", "the", "CSS", "image" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/PostProcessorCssImageUrlRewriter.java#L232-L274
7,441
soulgalore/crawler
src/main/java/com/soulgalore/crawler/core/impl/HTTPClientResponseFetcher.java
HTTPClientResponseFetcher.getBody
protected String getBody(HttpEntity entity, String enc) throws IOException { final StringBuilder body = new StringBuilder(); String buffer = ""; if (entity != null) { final BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), enc)); while ((buffer = reader.readLine()) != null) { body.append(buffer); } reader.close(); } return body.toString(); }
java
protected String getBody(HttpEntity entity, String enc) throws IOException { final StringBuilder body = new StringBuilder(); String buffer = ""; if (entity != null) { final BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), enc)); while ((buffer = reader.readLine()) != null) { body.append(buffer); } reader.close(); } return body.toString(); }
[ "protected", "String", "getBody", "(", "HttpEntity", "entity", ",", "String", "enc", ")", "throws", "IOException", "{", "final", "StringBuilder", "body", "=", "new", "StringBuilder", "(", ")", ";", "String", "buffer", "=", "\"\"", ";", "if", "(", "entity", "!=", "null", ")", "{", "final", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "entity", ".", "getContent", "(", ")", ",", "enc", ")", ")", ";", "while", "(", "(", "buffer", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "body", ".", "append", "(", "buffer", ")", ";", "}", "reader", ".", "close", "(", ")", ";", "}", "return", "body", ".", "toString", "(", ")", ";", "}" ]
Get the body. @param entity the http entity from the response @param enc the encoding @return the body as a String @throws IOException if the body couldn't be fetched
[ "Get", "the", "body", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/core/impl/HTTPClientResponseFetcher.java#L178-L191
7,442
soulgalore/crawler
src/main/java/com/soulgalore/crawler/core/impl/HTTPClientResponseFetcher.java
HTTPClientResponseFetcher.getHeaders
protected Map<String, String> getHeaders(HttpResponse resp) { final Map<String, String> headersAndValues = new HashMap<String, String>(); final Header[] httpHeaders = resp.getAllHeaders(); for (Header header : httpHeaders) { headersAndValues.put(header.getName(), header.getValue()); } return headersAndValues; }
java
protected Map<String, String> getHeaders(HttpResponse resp) { final Map<String, String> headersAndValues = new HashMap<String, String>(); final Header[] httpHeaders = resp.getAllHeaders(); for (Header header : httpHeaders) { headersAndValues.put(header.getName(), header.getValue()); } return headersAndValues; }
[ "protected", "Map", "<", "String", ",", "String", ">", "getHeaders", "(", "HttpResponse", "resp", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "headersAndValues", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "final", "Header", "[", "]", "httpHeaders", "=", "resp", ".", "getAllHeaders", "(", ")", ";", "for", "(", "Header", "header", ":", "httpHeaders", ")", "{", "headersAndValues", ".", "put", "(", "header", ".", "getName", "(", ")", ",", "header", ".", "getValue", "(", ")", ")", ";", "}", "return", "headersAndValues", ";", "}" ]
Get the headers from the response. @param resp the response @return the headers as a key/value map.
[ "Get", "the", "headers", "from", "the", "response", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/core/impl/HTTPClientResponseFetcher.java#L199-L207
7,443
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/OracleSpatialUtils.java
OracleSpatialUtils.convertToClob
public static String convertToClob(final String varchar) { int startIndex = 0; int endIndex = Math.min(startIndex + 4000, varchar.length()); final StringBuilder clobs = new StringBuilder("TO_CLOB('").append( varchar.substring(startIndex, endIndex)).append("')"); while (endIndex < varchar.length()) { startIndex = endIndex; endIndex = Math.min(startIndex + 4000, varchar.length()); clobs.append(" || TO_CLOB('").append(varchar.substring(startIndex, endIndex)).append("')"); } return clobs.toString(); }
java
public static String convertToClob(final String varchar) { int startIndex = 0; int endIndex = Math.min(startIndex + 4000, varchar.length()); final StringBuilder clobs = new StringBuilder("TO_CLOB('").append( varchar.substring(startIndex, endIndex)).append("')"); while (endIndex < varchar.length()) { startIndex = endIndex; endIndex = Math.min(startIndex + 4000, varchar.length()); clobs.append(" || TO_CLOB('").append(varchar.substring(startIndex, endIndex)).append("')"); } return clobs.toString(); }
[ "public", "static", "String", "convertToClob", "(", "final", "String", "varchar", ")", "{", "int", "startIndex", "=", "0", ";", "int", "endIndex", "=", "Math", ".", "min", "(", "startIndex", "+", "4000", ",", "varchar", ".", "length", "(", ")", ")", ";", "final", "StringBuilder", "clobs", "=", "new", "StringBuilder", "(", "\"TO_CLOB('\"", ")", ".", "append", "(", "varchar", ".", "substring", "(", "startIndex", ",", "endIndex", ")", ")", ".", "append", "(", "\"')\"", ")", ";", "while", "(", "endIndex", "<", "varchar", ".", "length", "(", ")", ")", "{", "startIndex", "=", "endIndex", ";", "endIndex", "=", "Math", ".", "min", "(", "startIndex", "+", "4000", ",", "varchar", ".", "length", "(", ")", ")", ";", "clobs", ".", "append", "(", "\" || TO_CLOB('\"", ")", ".", "append", "(", "varchar", ".", "substring", "(", "startIndex", ",", "endIndex", ")", ")", ".", "append", "(", "\"')\"", ")", ";", "}", "return", "clobs", ".", "toString", "(", ")", ";", "}" ]
Generates the SQL to convert the given string to a CLOB. @param varchar the value to convert. @return the SQL to convert the string to a CLOB.
[ "Generates", "the", "SQL", "to", "convert", "the", "given", "string", "to", "a", "CLOB", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/OracleSpatialUtils.java#L60-L71
7,444
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/OracleSpatialUtils.java
OracleSpatialUtils.getOracleSrid
public static String getOracleSrid(final String srid, final Database database) { final String oracleSrid; if (StringUtils.trimToNull(srid) == null) { oracleSrid = null; } else if (EPSG_TO_ORACLE_MAP.containsKey(srid)) { oracleSrid = EPSG_TO_ORACLE_MAP.get(srid); } else { oracleSrid = loadOracleSrid(srid, database); EPSG_TO_ORACLE_MAP.put(srid, oracleSrid); } return oracleSrid; }
java
public static String getOracleSrid(final String srid, final Database database) { final String oracleSrid; if (StringUtils.trimToNull(srid) == null) { oracleSrid = null; } else if (EPSG_TO_ORACLE_MAP.containsKey(srid)) { oracleSrid = EPSG_TO_ORACLE_MAP.get(srid); } else { oracleSrid = loadOracleSrid(srid, database); EPSG_TO_ORACLE_MAP.put(srid, oracleSrid); } return oracleSrid; }
[ "public", "static", "String", "getOracleSrid", "(", "final", "String", "srid", ",", "final", "Database", "database", ")", "{", "final", "String", "oracleSrid", ";", "if", "(", "StringUtils", ".", "trimToNull", "(", "srid", ")", "==", "null", ")", "{", "oracleSrid", "=", "null", ";", "}", "else", "if", "(", "EPSG_TO_ORACLE_MAP", ".", "containsKey", "(", "srid", ")", ")", "{", "oracleSrid", "=", "EPSG_TO_ORACLE_MAP", ".", "get", "(", "srid", ")", ";", "}", "else", "{", "oracleSrid", "=", "loadOracleSrid", "(", "srid", ",", "database", ")", ";", "EPSG_TO_ORACLE_MAP", ".", "put", "(", "srid", ",", "oracleSrid", ")", ";", "}", "return", "oracleSrid", ";", "}" ]
Converts the given EPSG SRID to the corresponding Oracle SRID. @param srid the EPSG SRID. @param database the database instance. @return the corresponding Oracle SRID.
[ "Converts", "the", "given", "EPSG", "SRID", "to", "the", "corresponding", "Oracle", "SRID", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/OracleSpatialUtils.java#L82-L93
7,445
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/OracleSpatialUtils.java
OracleSpatialUtils.loadOracleSrid
public static String loadOracleSrid(final String srid, final Database database) { final String oracleSrid; final JdbcConnection jdbcConnection = (JdbcConnection) database.getConnection(); final Connection connection = jdbcConnection.getUnderlyingConnection(); Statement statement = null; try { statement = connection.createStatement(); final ResultSet resultSet = statement.executeQuery("SELECT " + EPSG_TO_ORACLE_FUNCTION + "(" + srid + ") FROM dual"); resultSet.next(); oracleSrid = resultSet.getString(1); } catch (final SQLException e) { throw new UnexpectedLiquibaseException("Failed to find the Oracle SRID for EPSG:" + srid, e); } finally { try { statement.close(); } catch (final SQLException ignore) { } } return oracleSrid; }
java
public static String loadOracleSrid(final String srid, final Database database) { final String oracleSrid; final JdbcConnection jdbcConnection = (JdbcConnection) database.getConnection(); final Connection connection = jdbcConnection.getUnderlyingConnection(); Statement statement = null; try { statement = connection.createStatement(); final ResultSet resultSet = statement.executeQuery("SELECT " + EPSG_TO_ORACLE_FUNCTION + "(" + srid + ") FROM dual"); resultSet.next(); oracleSrid = resultSet.getString(1); } catch (final SQLException e) { throw new UnexpectedLiquibaseException("Failed to find the Oracle SRID for EPSG:" + srid, e); } finally { try { statement.close(); } catch (final SQLException ignore) { } } return oracleSrid; }
[ "public", "static", "String", "loadOracleSrid", "(", "final", "String", "srid", ",", "final", "Database", "database", ")", "{", "final", "String", "oracleSrid", ";", "final", "JdbcConnection", "jdbcConnection", "=", "(", "JdbcConnection", ")", "database", ".", "getConnection", "(", ")", ";", "final", "Connection", "connection", "=", "jdbcConnection", ".", "getUnderlyingConnection", "(", ")", ";", "Statement", "statement", "=", "null", ";", "try", "{", "statement", "=", "connection", ".", "createStatement", "(", ")", ";", "final", "ResultSet", "resultSet", "=", "statement", ".", "executeQuery", "(", "\"SELECT \"", "+", "EPSG_TO_ORACLE_FUNCTION", "+", "\"(\"", "+", "srid", "+", "\") FROM dual\"", ")", ";", "resultSet", ".", "next", "(", ")", ";", "oracleSrid", "=", "resultSet", ".", "getString", "(", "1", ")", ";", "}", "catch", "(", "final", "SQLException", "e", ")", "{", "throw", "new", "UnexpectedLiquibaseException", "(", "\"Failed to find the Oracle SRID for EPSG:\"", "+", "srid", ",", "e", ")", ";", "}", "finally", "{", "try", "{", "statement", ".", "close", "(", ")", ";", "}", "catch", "(", "final", "SQLException", "ignore", ")", "{", "}", "}", "return", "oracleSrid", ";", "}" ]
Queries to the database to convert the given EPSG SRID to the corresponding Oracle SRID. @param srid the EPSG SRID. @param database the database instance. @return the corresponding Oracle SRID.
[ "Queries", "to", "the", "database", "to", "convert", "the", "given", "EPSG", "SRID", "to", "the", "corresponding", "Oracle", "SRID", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/OracleSpatialUtils.java#L104-L125
7,446
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/DropGeometryColumnGeneratorGeoDB.java
DropGeometryColumnGeneratorGeoDB.dropSpatialIndexIfExists
protected void dropSpatialIndexIfExists(final String catalogName, final String schemaName, final String tableName, final Database database, final List<Sql> list) { final DropSpatialIndexGeneratorGeoDB generator = new DropSpatialIndexGeneratorGeoDB(); final DropSpatialIndexStatement statement = new DropSpatialIndexStatement(null, catalogName, schemaName, tableName); list.addAll(Arrays.asList(generator.generateSqlIfExists(statement, database))); }
java
protected void dropSpatialIndexIfExists(final String catalogName, final String schemaName, final String tableName, final Database database, final List<Sql> list) { final DropSpatialIndexGeneratorGeoDB generator = new DropSpatialIndexGeneratorGeoDB(); final DropSpatialIndexStatement statement = new DropSpatialIndexStatement(null, catalogName, schemaName, tableName); list.addAll(Arrays.asList(generator.generateSqlIfExists(statement, database))); }
[ "protected", "void", "dropSpatialIndexIfExists", "(", "final", "String", "catalogName", ",", "final", "String", "schemaName", ",", "final", "String", "tableName", ",", "final", "Database", "database", ",", "final", "List", "<", "Sql", ">", "list", ")", "{", "final", "DropSpatialIndexGeneratorGeoDB", "generator", "=", "new", "DropSpatialIndexGeneratorGeoDB", "(", ")", ";", "final", "DropSpatialIndexStatement", "statement", "=", "new", "DropSpatialIndexStatement", "(", "null", ",", "catalogName", ",", "schemaName", ",", "tableName", ")", ";", "list", ".", "addAll", "(", "Arrays", ".", "asList", "(", "generator", ".", "generateSqlIfExists", "(", "statement", ",", "database", ")", ")", ")", ";", "}" ]
Adds the SQL statement to drop the spatial index if it is present. @param catalogName the catalog name. @param schemaName the schema name. @param tableName the table name. @param database the database. @param list the list of SQL statements to execute.
[ "Adds", "the", "SQL", "statement", "to", "drop", "the", "spatial", "index", "if", "it", "is", "present", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/DropGeometryColumnGeneratorGeoDB.java#L91-L97
7,447
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/DropSpatialIndexGeneratorGeoDB.java
DropSpatialIndexGeneratorGeoDB.validate
@Override public ValidationErrors validate(final DropSpatialIndexStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) { final ValidationErrors validationErrors = new ValidationErrors(); validationErrors.checkRequiredField("tableName", statement.getTableName()); return validationErrors; }
java
@Override public ValidationErrors validate(final DropSpatialIndexStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) { final ValidationErrors validationErrors = new ValidationErrors(); validationErrors.checkRequiredField("tableName", statement.getTableName()); return validationErrors; }
[ "@", "Override", "public", "ValidationErrors", "validate", "(", "final", "DropSpatialIndexStatement", "statement", ",", "final", "Database", "database", ",", "final", "SqlGeneratorChain", "sqlGeneratorChain", ")", "{", "final", "ValidationErrors", "validationErrors", "=", "new", "ValidationErrors", "(", ")", ";", "validationErrors", ".", "checkRequiredField", "(", "\"tableName\"", ",", "statement", ".", "getTableName", "(", ")", ")", ";", "return", "validationErrors", ";", "}" ]
Ensures that the table name is populated.
[ "Ensures", "that", "the", "table", "name", "is", "populated", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/DropSpatialIndexGeneratorGeoDB.java#L37-L43
7,448
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/DropSpatialIndexGeneratorGeoDB.java
DropSpatialIndexGeneratorGeoDB.generateSqlIfExists
public Sql[] generateSqlIfExists(final DropSpatialIndexStatement statement, final Database database) { final String catalogName = statement.getTableCatalogName(); final String schemaName = statement.getTableSchemaName(); final String tableName = statement.getTableName(); final SpatialIndexExistsPrecondition precondition = new SpatialIndexExistsPrecondition(); precondition.setCatalogName(catalogName); precondition.setSchemaName(schemaName); precondition.setTableName(tableName); final DatabaseObject example = precondition.getExample(database, tableName); try { // If a spatial index exists on the table, drop it. if (SnapshotGeneratorFactory.getInstance().has(example, database)) { return generateSql(statement, database, null); } } catch (final Exception e) { throw new UnexpectedLiquibaseException(e); } return new Sql[0]; }
java
public Sql[] generateSqlIfExists(final DropSpatialIndexStatement statement, final Database database) { final String catalogName = statement.getTableCatalogName(); final String schemaName = statement.getTableSchemaName(); final String tableName = statement.getTableName(); final SpatialIndexExistsPrecondition precondition = new SpatialIndexExistsPrecondition(); precondition.setCatalogName(catalogName); precondition.setSchemaName(schemaName); precondition.setTableName(tableName); final DatabaseObject example = precondition.getExample(database, tableName); try { // If a spatial index exists on the table, drop it. if (SnapshotGeneratorFactory.getInstance().has(example, database)) { return generateSql(statement, database, null); } } catch (final Exception e) { throw new UnexpectedLiquibaseException(e); } return new Sql[0]; }
[ "public", "Sql", "[", "]", "generateSqlIfExists", "(", "final", "DropSpatialIndexStatement", "statement", ",", "final", "Database", "database", ")", "{", "final", "String", "catalogName", "=", "statement", ".", "getTableCatalogName", "(", ")", ";", "final", "String", "schemaName", "=", "statement", ".", "getTableSchemaName", "(", ")", ";", "final", "String", "tableName", "=", "statement", ".", "getTableName", "(", ")", ";", "final", "SpatialIndexExistsPrecondition", "precondition", "=", "new", "SpatialIndexExistsPrecondition", "(", ")", ";", "precondition", ".", "setCatalogName", "(", "catalogName", ")", ";", "precondition", ".", "setSchemaName", "(", "schemaName", ")", ";", "precondition", ".", "setTableName", "(", "tableName", ")", ";", "final", "DatabaseObject", "example", "=", "precondition", ".", "getExample", "(", "database", ",", "tableName", ")", ";", "try", "{", "// If a spatial index exists on the table, drop it.", "if", "(", "SnapshotGeneratorFactory", ".", "getInstance", "(", ")", ".", "has", "(", "example", ",", "database", ")", ")", "{", "return", "generateSql", "(", "statement", ",", "database", ",", "null", ")", ";", "}", "}", "catch", "(", "final", "Exception", "e", ")", "{", "throw", "new", "UnexpectedLiquibaseException", "(", "e", ")", ";", "}", "return", "new", "Sql", "[", "0", "]", ";", "}" ]
Generates the SQL statement to drop the spatial index if it exists. @param statement the drop spatial index statement. @param database the database. @return the drop spatial index statement, if the index exists.
[ "Generates", "the", "SQL", "statement", "to", "drop", "the", "spatial", "index", "if", "it", "exists", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/DropSpatialIndexGeneratorGeoDB.java#L81-L100
7,449
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/CreateSpatialIndexGeneratorOracle.java
CreateSpatialIndexGeneratorOracle.generateCreateIndexSql
protected String generateCreateIndexSql(final CreateSpatialIndexStatement statement, final Database database) { final StringBuilder sql = new StringBuilder(); sql.append("CREATE INDEX "); final String schemaName = statement.getTableSchemaName(); final String catalogName = statement.getTableCatalogName(); final String indexName = statement.getIndexName(); sql.append(database.escapeIndexName(catalogName, schemaName, indexName)); sql.append(" ON "); final String tableName = statement.getTableName(); sql.append(database.escapeTableName(catalogName, schemaName, tableName)).append(" ("); final Iterator<String> iterator = Arrays.asList(statement.getColumns()).iterator(); final String column = iterator.next(); sql.append(database.escapeColumnName(catalogName, statement.getTableSchemaName(), tableName, column)); sql.append(") INDEXTYPE IS mdsys.spatial_index"); // Generate and add the optional parameters. final Collection<String> parameters = getParameters(statement); if (parameters != null && !parameters.isEmpty()) { sql.append(" PARAMETERS ('"); sql.append(StringUtils.join(parameters, " ")); sql.append("')"); } return sql.toString(); }
java
protected String generateCreateIndexSql(final CreateSpatialIndexStatement statement, final Database database) { final StringBuilder sql = new StringBuilder(); sql.append("CREATE INDEX "); final String schemaName = statement.getTableSchemaName(); final String catalogName = statement.getTableCatalogName(); final String indexName = statement.getIndexName(); sql.append(database.escapeIndexName(catalogName, schemaName, indexName)); sql.append(" ON "); final String tableName = statement.getTableName(); sql.append(database.escapeTableName(catalogName, schemaName, tableName)).append(" ("); final Iterator<String> iterator = Arrays.asList(statement.getColumns()).iterator(); final String column = iterator.next(); sql.append(database.escapeColumnName(catalogName, statement.getTableSchemaName(), tableName, column)); sql.append(") INDEXTYPE IS mdsys.spatial_index"); // Generate and add the optional parameters. final Collection<String> parameters = getParameters(statement); if (parameters != null && !parameters.isEmpty()) { sql.append(" PARAMETERS ('"); sql.append(StringUtils.join(parameters, " ")); sql.append("')"); } return sql.toString(); }
[ "protected", "String", "generateCreateIndexSql", "(", "final", "CreateSpatialIndexStatement", "statement", ",", "final", "Database", "database", ")", "{", "final", "StringBuilder", "sql", "=", "new", "StringBuilder", "(", ")", ";", "sql", ".", "append", "(", "\"CREATE INDEX \"", ")", ";", "final", "String", "schemaName", "=", "statement", ".", "getTableSchemaName", "(", ")", ";", "final", "String", "catalogName", "=", "statement", ".", "getTableCatalogName", "(", ")", ";", "final", "String", "indexName", "=", "statement", ".", "getIndexName", "(", ")", ";", "sql", ".", "append", "(", "database", ".", "escapeIndexName", "(", "catalogName", ",", "schemaName", ",", "indexName", ")", ")", ";", "sql", ".", "append", "(", "\" ON \"", ")", ";", "final", "String", "tableName", "=", "statement", ".", "getTableName", "(", ")", ";", "sql", ".", "append", "(", "database", ".", "escapeTableName", "(", "catalogName", ",", "schemaName", ",", "tableName", ")", ")", ".", "append", "(", "\" (\"", ")", ";", "final", "Iterator", "<", "String", ">", "iterator", "=", "Arrays", ".", "asList", "(", "statement", ".", "getColumns", "(", ")", ")", ".", "iterator", "(", ")", ";", "final", "String", "column", "=", "iterator", ".", "next", "(", ")", ";", "sql", ".", "append", "(", "database", ".", "escapeColumnName", "(", "catalogName", ",", "statement", ".", "getTableSchemaName", "(", ")", ",", "tableName", ",", "column", ")", ")", ";", "sql", ".", "append", "(", "\") INDEXTYPE IS mdsys.spatial_index\"", ")", ";", "// Generate and add the optional parameters.", "final", "Collection", "<", "String", ">", "parameters", "=", "getParameters", "(", "statement", ")", ";", "if", "(", "parameters", "!=", "null", "&&", "!", "parameters", ".", "isEmpty", "(", ")", ")", "{", "sql", ".", "append", "(", "\" PARAMETERS ('\"", ")", ";", "sql", ".", "append", "(", "StringUtils", ".", "join", "(", "parameters", ",", "\" \"", ")", ")", ";", "sql", ".", "append", "(", "\"')\"", ")", ";", "}", "return", "sql", ".", "toString", "(", ")", ";", "}" ]
Generates the SQL for creating the spatial index. @param statement the create spatial index statement. @param database the database instance. @return the SQL to create a spatial index.
[ "Generates", "the", "SQL", "for", "creating", "the", "spatial", "index", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/CreateSpatialIndexGeneratorOracle.java#L109-L134
7,450
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/CreateSpatialIndexGeneratorOracle.java
CreateSpatialIndexGeneratorOracle.getParameters
protected Collection<String> getParameters(final CreateSpatialIndexStatement statement) { final Collection<String> parameters = new ArrayList<String>(); if (StringUtils.trimToNull(statement.getGeometryType()) != null) { final String gType = getGtype(statement.getGeometryType().trim()); if (gType != null) { parameters.add("layer_gtype=" + gType); } } if (StringUtils.trimToNull(statement.getTablespace()) != null) { parameters.add("tablespace=" + statement.getTablespace().trim()); } return parameters; }
java
protected Collection<String> getParameters(final CreateSpatialIndexStatement statement) { final Collection<String> parameters = new ArrayList<String>(); if (StringUtils.trimToNull(statement.getGeometryType()) != null) { final String gType = getGtype(statement.getGeometryType().trim()); if (gType != null) { parameters.add("layer_gtype=" + gType); } } if (StringUtils.trimToNull(statement.getTablespace()) != null) { parameters.add("tablespace=" + statement.getTablespace().trim()); } return parameters; }
[ "protected", "Collection", "<", "String", ">", "getParameters", "(", "final", "CreateSpatialIndexStatement", "statement", ")", "{", "final", "Collection", "<", "String", ">", "parameters", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "StringUtils", ".", "trimToNull", "(", "statement", ".", "getGeometryType", "(", ")", ")", "!=", "null", ")", "{", "final", "String", "gType", "=", "getGtype", "(", "statement", ".", "getGeometryType", "(", ")", ".", "trim", "(", ")", ")", ";", "if", "(", "gType", "!=", "null", ")", "{", "parameters", ".", "add", "(", "\"layer_gtype=\"", "+", "gType", ")", ";", "}", "}", "if", "(", "StringUtils", ".", "trimToNull", "(", "statement", ".", "getTablespace", "(", ")", ")", "!=", "null", ")", "{", "parameters", ".", "add", "(", "\"tablespace=\"", "+", "statement", ".", "getTablespace", "(", ")", ".", "trim", "(", ")", ")", ";", "}", "return", "parameters", ";", "}" ]
Creates the parameters to the spatial index creation statement. @param statement the statement. @return the optional parameters for the <code>CREATE INDEX</code> statement.
[ "Creates", "the", "parameters", "to", "the", "spatial", "index", "creation", "statement", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/CreateSpatialIndexGeneratorOracle.java#L143-L155
7,451
soulgalore/crawler
src/main/java/com/soulgalore/crawler/util/HTTPSFaker.java
HTTPSFaker.getClientThatAllowAnyHTTPS
@SuppressWarnings("deprecation") public static DefaultHttpClient getClientThatAllowAnyHTTPS(ThreadSafeClientConnManager cm) { final TrustManager easyTrustManager = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {} public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {} public X509Certificate[] getAcceptedIssuers() { return null; } }; final X509HostnameVerifier easyVerifier = new X509HostnameVerifier() { public boolean verify(String string, SSLSession ssls) { return true; } public void verify(String string, SSLSocket ssls) throws IOException {} public void verify(String string, String[] strings, String[] strings1) throws SSLException {} public void verify(String string, X509Certificate xc) throws SSLException {} }; SSLContext ctx = null; try { ctx = SSLContext.getInstance("TLS"); ctx.init(null, new TrustManager[] {easyTrustManager}, null); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (KeyManagementException e) { throw new RuntimeException(e); } final SSLSocketFactory ssf = new SSLSocketFactory(ctx); ssf.setHostnameVerifier(easyVerifier); cm.getSchemeRegistry().register(new Scheme(HTTPS, ssf, HTTPS_PORT)); return new DefaultHttpClient(cm); }
java
@SuppressWarnings("deprecation") public static DefaultHttpClient getClientThatAllowAnyHTTPS(ThreadSafeClientConnManager cm) { final TrustManager easyTrustManager = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {} public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {} public X509Certificate[] getAcceptedIssuers() { return null; } }; final X509HostnameVerifier easyVerifier = new X509HostnameVerifier() { public boolean verify(String string, SSLSession ssls) { return true; } public void verify(String string, SSLSocket ssls) throws IOException {} public void verify(String string, String[] strings, String[] strings1) throws SSLException {} public void verify(String string, X509Certificate xc) throws SSLException {} }; SSLContext ctx = null; try { ctx = SSLContext.getInstance("TLS"); ctx.init(null, new TrustManager[] {easyTrustManager}, null); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (KeyManagementException e) { throw new RuntimeException(e); } final SSLSocketFactory ssf = new SSLSocketFactory(ctx); ssf.setHostnameVerifier(easyVerifier); cm.getSchemeRegistry().register(new Scheme(HTTPS, ssf, HTTPS_PORT)); return new DefaultHttpClient(cm); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "DefaultHttpClient", "getClientThatAllowAnyHTTPS", "(", "ThreadSafeClientConnManager", "cm", ")", "{", "final", "TrustManager", "easyTrustManager", "=", "new", "X509TrustManager", "(", ")", "{", "public", "void", "checkClientTrusted", "(", "X509Certificate", "[", "]", "xcs", ",", "String", "string", ")", "throws", "CertificateException", "{", "}", "public", "void", "checkServerTrusted", "(", "X509Certificate", "[", "]", "xcs", ",", "String", "string", ")", "throws", "CertificateException", "{", "}", "public", "X509Certificate", "[", "]", "getAcceptedIssuers", "(", ")", "{", "return", "null", ";", "}", "}", ";", "final", "X509HostnameVerifier", "easyVerifier", "=", "new", "X509HostnameVerifier", "(", ")", "{", "public", "boolean", "verify", "(", "String", "string", ",", "SSLSession", "ssls", ")", "{", "return", "true", ";", "}", "public", "void", "verify", "(", "String", "string", ",", "SSLSocket", "ssls", ")", "throws", "IOException", "{", "}", "public", "void", "verify", "(", "String", "string", ",", "String", "[", "]", "strings", ",", "String", "[", "]", "strings1", ")", "throws", "SSLException", "{", "}", "public", "void", "verify", "(", "String", "string", ",", "X509Certificate", "xc", ")", "throws", "SSLException", "{", "}", "}", ";", "SSLContext", "ctx", "=", "null", ";", "try", "{", "ctx", "=", "SSLContext", ".", "getInstance", "(", "\"TLS\"", ")", ";", "ctx", ".", "init", "(", "null", ",", "new", "TrustManager", "[", "]", "{", "easyTrustManager", "}", ",", "null", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "catch", "(", "KeyManagementException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "final", "SSLSocketFactory", "ssf", "=", "new", "SSLSocketFactory", "(", "ctx", ")", ";", "ssf", ".", "setHostnameVerifier", "(", "easyVerifier", ")", ";", "cm", ".", "getSchemeRegistry", "(", ")", ".", "register", "(", "new", "Scheme", "(", "HTTPS", ",", "ssf", ",", "HTTPS_PORT", ")", ")", ";", "return", "new", "DefaultHttpClient", "(", "cm", ")", ";", "}" ]
Get a HttpClient that accept any HTTP certificate. @param cm the connection manager to use when creating the new HttpClient @return a httpClient that accept any HTTP certificate
[ "Get", "a", "HttpClient", "that", "accept", "any", "HTTP", "certificate", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/util/HTTPSFaker.java#L61-L108
7,452
soulgalore/crawler
src/main/java/com/soulgalore/crawler/core/impl/AhrefPageURLParser.java
AhrefPageURLParser.get
public Set<CrawlerURL> get(HTMLPageResponse theResponse) { final String url = theResponse.getUrl(); Set<CrawlerURL> ahrefs = new HashSet<CrawlerURL>(); // only populate if we have a valid response, else return empty set if (theResponse.getResponseCode() == HttpStatus.SC_OK) { ahrefs = fetch(AHREF, ABS_HREF, theResponse.getBody(), url); } return ahrefs; }
java
public Set<CrawlerURL> get(HTMLPageResponse theResponse) { final String url = theResponse.getUrl(); Set<CrawlerURL> ahrefs = new HashSet<CrawlerURL>(); // only populate if we have a valid response, else return empty set if (theResponse.getResponseCode() == HttpStatus.SC_OK) { ahrefs = fetch(AHREF, ABS_HREF, theResponse.getBody(), url); } return ahrefs; }
[ "public", "Set", "<", "CrawlerURL", ">", "get", "(", "HTMLPageResponse", "theResponse", ")", "{", "final", "String", "url", "=", "theResponse", ".", "getUrl", "(", ")", ";", "Set", "<", "CrawlerURL", ">", "ahrefs", "=", "new", "HashSet", "<", "CrawlerURL", ">", "(", ")", ";", "// only populate if we have a valid response, else return empty set", "if", "(", "theResponse", ".", "getResponseCode", "(", ")", "==", "HttpStatus", ".", "SC_OK", ")", "{", "ahrefs", "=", "fetch", "(", "AHREF", ",", "ABS_HREF", ",", "theResponse", ".", "getBody", "(", ")", ",", "url", ")", ";", "}", "return", "ahrefs", ";", "}" ]
Get all ahref links within this page response. @param theResponse the response from the request to this page @return the urls.
[ "Get", "all", "ahref", "links", "within", "this", "page", "response", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/core/impl/AhrefPageURLParser.java#L62-L74
7,453
soulgalore/crawler
src/main/java/com/soulgalore/crawler/run/AbstractCrawl.java
AbstractCrawl.getOptions
@Override protected Options getOptions() { final Options options = super.getOptions(); final Option urlOption = new Option("u", "the page that is the startpoint of the crawl, examle http://mydomain.com/mypage"); urlOption.setLongOpt(URL); urlOption.setArgName("URL"); urlOption.setRequired(true); urlOption.setArgs(1); options.addOption(urlOption); final Option levelOption = new Option("l", "how deep the crawl should be done, default is " + CrawlerConfiguration.DEFAULT_CRAWL_LEVEL + " [optional]"); levelOption.setArgName("LEVEL"); levelOption.setLongOpt(LEVEL); levelOption.setRequired(false); levelOption.setArgs(1); options.addOption(levelOption); final Option followOption = new Option("p", "stay on this path when crawling [optional]"); followOption.setArgName("PATH"); followOption.setLongOpt(FOLLOW_PATH); followOption.setRequired(false); followOption.setArgs(1); options.addOption(followOption); final Option noFollowOption = new Option("np", "no url:s on this path will be crawled [optional]"); noFollowOption.setArgName("NOPATH"); noFollowOption.setLongOpt(NO_FOLLOW_PATH); noFollowOption.setRequired(false); noFollowOption.setArgs(1); options.addOption(noFollowOption); final Option verifyOption = new Option("v", "verify that all links are returning 200, default is set to " + CrawlerConfiguration.DEFAULT_SHOULD_VERIFY_URLS + " [optional]"); verifyOption.setArgName("VERIFY"); verifyOption.setLongOpt(VERIFY); verifyOption.setRequired(false); verifyOption.setArgs(1); options.addOption(verifyOption); final Option requestHeadersOption = new Option("rh", "the request headers by the form of header1:value1@header2:value2 [optional]"); requestHeadersOption.setArgName("REQUEST-HEADERS"); requestHeadersOption.setLongOpt(REQUEST_HEADERS); requestHeadersOption.setRequired(false); requestHeadersOption.setArgs(1); options.addOption(requestHeadersOption); return options; }
java
@Override protected Options getOptions() { final Options options = super.getOptions(); final Option urlOption = new Option("u", "the page that is the startpoint of the crawl, examle http://mydomain.com/mypage"); urlOption.setLongOpt(URL); urlOption.setArgName("URL"); urlOption.setRequired(true); urlOption.setArgs(1); options.addOption(urlOption); final Option levelOption = new Option("l", "how deep the crawl should be done, default is " + CrawlerConfiguration.DEFAULT_CRAWL_LEVEL + " [optional]"); levelOption.setArgName("LEVEL"); levelOption.setLongOpt(LEVEL); levelOption.setRequired(false); levelOption.setArgs(1); options.addOption(levelOption); final Option followOption = new Option("p", "stay on this path when crawling [optional]"); followOption.setArgName("PATH"); followOption.setLongOpt(FOLLOW_PATH); followOption.setRequired(false); followOption.setArgs(1); options.addOption(followOption); final Option noFollowOption = new Option("np", "no url:s on this path will be crawled [optional]"); noFollowOption.setArgName("NOPATH"); noFollowOption.setLongOpt(NO_FOLLOW_PATH); noFollowOption.setRequired(false); noFollowOption.setArgs(1); options.addOption(noFollowOption); final Option verifyOption = new Option("v", "verify that all links are returning 200, default is set to " + CrawlerConfiguration.DEFAULT_SHOULD_VERIFY_URLS + " [optional]"); verifyOption.setArgName("VERIFY"); verifyOption.setLongOpt(VERIFY); verifyOption.setRequired(false); verifyOption.setArgs(1); options.addOption(verifyOption); final Option requestHeadersOption = new Option("rh", "the request headers by the form of header1:value1@header2:value2 [optional]"); requestHeadersOption.setArgName("REQUEST-HEADERS"); requestHeadersOption.setLongOpt(REQUEST_HEADERS); requestHeadersOption.setRequired(false); requestHeadersOption.setArgs(1); options.addOption(requestHeadersOption); return options; }
[ "@", "Override", "protected", "Options", "getOptions", "(", ")", "{", "final", "Options", "options", "=", "super", ".", "getOptions", "(", ")", ";", "final", "Option", "urlOption", "=", "new", "Option", "(", "\"u\"", ",", "\"the page that is the startpoint of the crawl, examle http://mydomain.com/mypage\"", ")", ";", "urlOption", ".", "setLongOpt", "(", "URL", ")", ";", "urlOption", ".", "setArgName", "(", "\"URL\"", ")", ";", "urlOption", ".", "setRequired", "(", "true", ")", ";", "urlOption", ".", "setArgs", "(", "1", ")", ";", "options", ".", "addOption", "(", "urlOption", ")", ";", "final", "Option", "levelOption", "=", "new", "Option", "(", "\"l\"", ",", "\"how deep the crawl should be done, default is \"", "+", "CrawlerConfiguration", ".", "DEFAULT_CRAWL_LEVEL", "+", "\" [optional]\"", ")", ";", "levelOption", ".", "setArgName", "(", "\"LEVEL\"", ")", ";", "levelOption", ".", "setLongOpt", "(", "LEVEL", ")", ";", "levelOption", ".", "setRequired", "(", "false", ")", ";", "levelOption", ".", "setArgs", "(", "1", ")", ";", "options", ".", "addOption", "(", "levelOption", ")", ";", "final", "Option", "followOption", "=", "new", "Option", "(", "\"p\"", ",", "\"stay on this path when crawling [optional]\"", ")", ";", "followOption", ".", "setArgName", "(", "\"PATH\"", ")", ";", "followOption", ".", "setLongOpt", "(", "FOLLOW_PATH", ")", ";", "followOption", ".", "setRequired", "(", "false", ")", ";", "followOption", ".", "setArgs", "(", "1", ")", ";", "options", ".", "addOption", "(", "followOption", ")", ";", "final", "Option", "noFollowOption", "=", "new", "Option", "(", "\"np\"", ",", "\"no url:s on this path will be crawled [optional]\"", ")", ";", "noFollowOption", ".", "setArgName", "(", "\"NOPATH\"", ")", ";", "noFollowOption", ".", "setLongOpt", "(", "NO_FOLLOW_PATH", ")", ";", "noFollowOption", ".", "setRequired", "(", "false", ")", ";", "noFollowOption", ".", "setArgs", "(", "1", ")", ";", "options", ".", "addOption", "(", "noFollowOption", ")", ";", "final", "Option", "verifyOption", "=", "new", "Option", "(", "\"v\"", ",", "\"verify that all links are returning 200, default is set to \"", "+", "CrawlerConfiguration", ".", "DEFAULT_SHOULD_VERIFY_URLS", "+", "\" [optional]\"", ")", ";", "verifyOption", ".", "setArgName", "(", "\"VERIFY\"", ")", ";", "verifyOption", ".", "setLongOpt", "(", "VERIFY", ")", ";", "verifyOption", ".", "setRequired", "(", "false", ")", ";", "verifyOption", ".", "setArgs", "(", "1", ")", ";", "options", ".", "addOption", "(", "verifyOption", ")", ";", "final", "Option", "requestHeadersOption", "=", "new", "Option", "(", "\"rh\"", ",", "\"the request headers by the form of header1:value1@header2:value2 [optional]\"", ")", ";", "requestHeadersOption", ".", "setArgName", "(", "\"REQUEST-HEADERS\"", ")", ";", "requestHeadersOption", ".", "setLongOpt", "(", "REQUEST_HEADERS", ")", ";", "requestHeadersOption", ".", "setRequired", "(", "false", ")", ";", "requestHeadersOption", ".", "setArgs", "(", "1", ")", ";", "options", ".", "addOption", "(", "requestHeadersOption", ")", ";", "return", "options", ";", "}" ]
Get hold of the default options. @return the options that needs to run a crawl
[ "Get", "hold", "of", "the", "default", "options", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/run/AbstractCrawl.java#L77-L134
7,454
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/AbstractSpatialInsertGenerator.java
AbstractSpatialInsertGenerator.generateSql
@Override public Sql[] generateSql(final InsertStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) { for (final Entry<String, Object> entry : statement.getColumnValues().entrySet()) { entry.setValue(handleColumnValue(entry.getValue(), database)); } return super.generateSql(statement, database, sqlGeneratorChain); }
java
@Override public Sql[] generateSql(final InsertStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) { for (final Entry<String, Object> entry : statement.getColumnValues().entrySet()) { entry.setValue(handleColumnValue(entry.getValue(), database)); } return super.generateSql(statement, database, sqlGeneratorChain); }
[ "@", "Override", "public", "Sql", "[", "]", "generateSql", "(", "final", "InsertStatement", "statement", ",", "final", "Database", "database", ",", "final", "SqlGeneratorChain", "sqlGeneratorChain", ")", "{", "for", "(", "final", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "statement", ".", "getColumnValues", "(", ")", ".", "entrySet", "(", ")", ")", "{", "entry", ".", "setValue", "(", "handleColumnValue", "(", "entry", ".", "getValue", "(", ")", ",", "database", ")", ")", ";", "}", "return", "super", ".", "generateSql", "(", "statement", ",", "database", ",", "sqlGeneratorChain", ")", ";", "}" ]
Find any fields that look like WKT or EWKT and replace them with the database-specific value.
[ "Find", "any", "fields", "that", "look", "like", "WKT", "or", "EWKT", "and", "replace", "them", "with", "the", "database", "-", "specific", "value", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/AbstractSpatialInsertGenerator.java#L34-L41
7,455
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/AbstractCreateSpatialIndexGenerator.java
AbstractCreateSpatialIndexGenerator.validate
@Override public ValidationErrors validate(final CreateSpatialIndexStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) { final ValidationErrors validationErrors = new ValidationErrors(); validationErrors.checkRequiredField("tableName", statement.getTableName()); validationErrors.checkRequiredField("columns", statement.getColumns()); return validationErrors; }
java
@Override public ValidationErrors validate(final CreateSpatialIndexStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) { final ValidationErrors validationErrors = new ValidationErrors(); validationErrors.checkRequiredField("tableName", statement.getTableName()); validationErrors.checkRequiredField("columns", statement.getColumns()); return validationErrors; }
[ "@", "Override", "public", "ValidationErrors", "validate", "(", "final", "CreateSpatialIndexStatement", "statement", ",", "final", "Database", "database", ",", "final", "SqlGeneratorChain", "sqlGeneratorChain", ")", "{", "final", "ValidationErrors", "validationErrors", "=", "new", "ValidationErrors", "(", ")", ";", "validationErrors", ".", "checkRequiredField", "(", "\"tableName\"", ",", "statement", ".", "getTableName", "(", ")", ")", ";", "validationErrors", ".", "checkRequiredField", "(", "\"columns\"", ",", "statement", ".", "getColumns", "(", ")", ")", ";", "return", "validationErrors", ";", "}" ]
Ensures that the table name and columns are populated. @see SqlGenerator#validate(liquibase.statement.SqlStatement, Database, SqlGeneratorChain)
[ "Ensures", "that", "the", "table", "name", "and", "columns", "are", "populated", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/AbstractCreateSpatialIndexGenerator.java#L23-L30
7,456
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/WktConversionUtils.java
WktConversionUtils.convertToFunction
public static String convertToFunction(final String wkt, final String srid, final Database database, final WktInsertOrUpdateGenerator generator) { if (wkt == null || wkt.equals("")) { throw new IllegalArgumentException( "The Well-Known Text cannot be null or empty"); } if (generator == null) { throw new IllegalArgumentException("The generator cannot be null or empty"); } final String geomFromTextFunction = generator.getGeomFromWktFunction(); String function = geomFromTextFunction + "('" + wkt + "'"; if (srid != null && !srid.equals("")) { function += ", " + srid; } else if (generator.isSridRequiredInFunction(database)) { throw new IllegalArgumentException("An SRID was not provided with '" + wkt + "' but is required in call to '" + geomFromTextFunction + "'"); } function += ")"; return function; }
java
public static String convertToFunction(final String wkt, final String srid, final Database database, final WktInsertOrUpdateGenerator generator) { if (wkt == null || wkt.equals("")) { throw new IllegalArgumentException( "The Well-Known Text cannot be null or empty"); } if (generator == null) { throw new IllegalArgumentException("The generator cannot be null or empty"); } final String geomFromTextFunction = generator.getGeomFromWktFunction(); String function = geomFromTextFunction + "('" + wkt + "'"; if (srid != null && !srid.equals("")) { function += ", " + srid; } else if (generator.isSridRequiredInFunction(database)) { throw new IllegalArgumentException("An SRID was not provided with '" + wkt + "' but is required in call to '" + geomFromTextFunction + "'"); } function += ")"; return function; }
[ "public", "static", "String", "convertToFunction", "(", "final", "String", "wkt", ",", "final", "String", "srid", ",", "final", "Database", "database", ",", "final", "WktInsertOrUpdateGenerator", "generator", ")", "{", "if", "(", "wkt", "==", "null", "||", "wkt", ".", "equals", "(", "\"\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The Well-Known Text cannot be null or empty\"", ")", ";", "}", "if", "(", "generator", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The generator cannot be null or empty\"", ")", ";", "}", "final", "String", "geomFromTextFunction", "=", "generator", ".", "getGeomFromWktFunction", "(", ")", ";", "String", "function", "=", "geomFromTextFunction", "+", "\"('\"", "+", "wkt", "+", "\"'\"", ";", "if", "(", "srid", "!=", "null", "&&", "!", "srid", ".", "equals", "(", "\"\"", ")", ")", "{", "function", "+=", "\", \"", "+", "srid", ";", "}", "else", "if", "(", "generator", ".", "isSridRequiredInFunction", "(", "database", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"An SRID was not provided with '\"", "+", "wkt", "+", "\"' but is required in call to '\"", "+", "geomFromTextFunction", "+", "\"'\"", ")", ";", "}", "function", "+=", "\")\"", ";", "return", "function", ";", "}" ]
Converts the given Well-Known Text and SRID to the appropriate function call for the database. @param wkt the Well-Known Text string. @param srid the SRID string which may be an empty string. @param database the database instance. @param generator the SQL generator. @return the string that converts the WKT to a database-specific geometry.
[ "Converts", "the", "given", "Well", "-", "Known", "Text", "and", "SRID", "to", "the", "appropriate", "function", "call", "for", "the", "database", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/WktConversionUtils.java#L79-L98
7,457
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/datatype/GeometryType.java
GeometryType.getGeometryType
public String getGeometryType() { String geometryType = null; if (getParameters().length > 0 && getParameters()[0] != null) { geometryType = getParameters()[0].toString(); } return geometryType; }
java
public String getGeometryType() { String geometryType = null; if (getParameters().length > 0 && getParameters()[0] != null) { geometryType = getParameters()[0].toString(); } return geometryType; }
[ "public", "String", "getGeometryType", "(", ")", "{", "String", "geometryType", "=", "null", ";", "if", "(", "getParameters", "(", ")", ".", "length", ">", "0", "&&", "getParameters", "(", ")", "[", "0", "]", "!=", "null", ")", "{", "geometryType", "=", "getParameters", "(", ")", "[", "0", "]", ".", "toString", "(", ")", ";", "}", "return", "geometryType", ";", "}" ]
Returns the value geometry type parameter. @return the geometry type or <code>null</code> if not present.
[ "Returns", "the", "value", "geometry", "type", "parameter", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/datatype/GeometryType.java#L29-L35
7,458
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/datatype/GeometryType.java
GeometryType.getSRID
public Integer getSRID() { Integer srid = null; if (getParameters().length > 1 && getParameters()[1] != null) { srid = Integer.valueOf(getParameters()[1].toString()); } return srid; }
java
public Integer getSRID() { Integer srid = null; if (getParameters().length > 1 && getParameters()[1] != null) { srid = Integer.valueOf(getParameters()[1].toString()); } return srid; }
[ "public", "Integer", "getSRID", "(", ")", "{", "Integer", "srid", "=", "null", ";", "if", "(", "getParameters", "(", ")", ".", "length", ">", "1", "&&", "getParameters", "(", ")", "[", "1", "]", "!=", "null", ")", "{", "srid", "=", "Integer", ".", "valueOf", "(", "getParameters", "(", ")", "[", "1", "]", ".", "toString", "(", ")", ")", ";", "}", "return", "srid", ";", "}" ]
Returns the value SRID parameter. @return the SRID or <code>null</code> if not present.
[ "Returns", "the", "value", "SRID", "parameter", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/datatype/GeometryType.java#L42-L48
7,459
soulgalore/crawler
src/main/java/com/soulgalore/crawler/guice/HttpClientProvider.java
HttpClientProvider.get
public HttpClient get() { final ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(); cm.setMaxTotal(nrOfThreads); cm.setDefaultMaxPerRoute(maxToRoute); final DefaultHttpClient client = HTTPSFaker.getClientThatAllowAnyHTTPS(cm); client.getParams().setParameter("http.socket.timeout", socketTimeout); client.getParams().setParameter("http.connection.timeout", connectionTimeout); client.addRequestInterceptor(new RequestAcceptEncoding()); client.addResponseInterceptor(new ResponseContentEncoding()); CookieSpecFactory csf = new CookieSpecFactory() { public CookieSpec newInstance(HttpParams params) { return new BestMatchSpecWithURLErrorLog(); } }; client.getCookieSpecs().register("bestmatchwithurl", csf); client.getParams().setParameter(ClientPNames.COOKIE_POLICY, "bestmatchwithurl"); if (!"".equals(proxy)) { StringTokenizer token = new StringTokenizer(proxy, ":"); if (token.countTokens() == 3) { String proxyProtocol = token.nextToken(); String proxyHost = token.nextToken(); int proxyPort = Integer.parseInt(token.nextToken()); HttpHost proxy = new HttpHost(proxyHost, proxyPort, proxyProtocol); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else System.err.println("Invalid proxy configuration: " + proxy); } if (auths.size() > 0) { for (Auth authObject : auths) { client.getCredentialsProvider().setCredentials( new AuthScope(authObject.getScope(), authObject.getPort()), new UsernamePasswordCredentials(authObject.getUserName(), authObject.getPassword())); } } return client; }
java
public HttpClient get() { final ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(); cm.setMaxTotal(nrOfThreads); cm.setDefaultMaxPerRoute(maxToRoute); final DefaultHttpClient client = HTTPSFaker.getClientThatAllowAnyHTTPS(cm); client.getParams().setParameter("http.socket.timeout", socketTimeout); client.getParams().setParameter("http.connection.timeout", connectionTimeout); client.addRequestInterceptor(new RequestAcceptEncoding()); client.addResponseInterceptor(new ResponseContentEncoding()); CookieSpecFactory csf = new CookieSpecFactory() { public CookieSpec newInstance(HttpParams params) { return new BestMatchSpecWithURLErrorLog(); } }; client.getCookieSpecs().register("bestmatchwithurl", csf); client.getParams().setParameter(ClientPNames.COOKIE_POLICY, "bestmatchwithurl"); if (!"".equals(proxy)) { StringTokenizer token = new StringTokenizer(proxy, ":"); if (token.countTokens() == 3) { String proxyProtocol = token.nextToken(); String proxyHost = token.nextToken(); int proxyPort = Integer.parseInt(token.nextToken()); HttpHost proxy = new HttpHost(proxyHost, proxyPort, proxyProtocol); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else System.err.println("Invalid proxy configuration: " + proxy); } if (auths.size() > 0) { for (Auth authObject : auths) { client.getCredentialsProvider().setCredentials( new AuthScope(authObject.getScope(), authObject.getPort()), new UsernamePasswordCredentials(authObject.getUserName(), authObject.getPassword())); } } return client; }
[ "public", "HttpClient", "get", "(", ")", "{", "final", "ThreadSafeClientConnManager", "cm", "=", "new", "ThreadSafeClientConnManager", "(", ")", ";", "cm", ".", "setMaxTotal", "(", "nrOfThreads", ")", ";", "cm", ".", "setDefaultMaxPerRoute", "(", "maxToRoute", ")", ";", "final", "DefaultHttpClient", "client", "=", "HTTPSFaker", ".", "getClientThatAllowAnyHTTPS", "(", "cm", ")", ";", "client", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"http.socket.timeout\"", ",", "socketTimeout", ")", ";", "client", ".", "getParams", "(", ")", ".", "setParameter", "(", "\"http.connection.timeout\"", ",", "connectionTimeout", ")", ";", "client", ".", "addRequestInterceptor", "(", "new", "RequestAcceptEncoding", "(", ")", ")", ";", "client", ".", "addResponseInterceptor", "(", "new", "ResponseContentEncoding", "(", ")", ")", ";", "CookieSpecFactory", "csf", "=", "new", "CookieSpecFactory", "(", ")", "{", "public", "CookieSpec", "newInstance", "(", "HttpParams", "params", ")", "{", "return", "new", "BestMatchSpecWithURLErrorLog", "(", ")", ";", "}", "}", ";", "client", ".", "getCookieSpecs", "(", ")", ".", "register", "(", "\"bestmatchwithurl\"", ",", "csf", ")", ";", "client", ".", "getParams", "(", ")", ".", "setParameter", "(", "ClientPNames", ".", "COOKIE_POLICY", ",", "\"bestmatchwithurl\"", ")", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "proxy", ")", ")", "{", "StringTokenizer", "token", "=", "new", "StringTokenizer", "(", "proxy", ",", "\":\"", ")", ";", "if", "(", "token", ".", "countTokens", "(", ")", "==", "3", ")", "{", "String", "proxyProtocol", "=", "token", ".", "nextToken", "(", ")", ";", "String", "proxyHost", "=", "token", ".", "nextToken", "(", ")", ";", "int", "proxyPort", "=", "Integer", ".", "parseInt", "(", "token", ".", "nextToken", "(", ")", ")", ";", "HttpHost", "proxy", "=", "new", "HttpHost", "(", "proxyHost", ",", "proxyPort", ",", "proxyProtocol", ")", ";", "client", ".", "getParams", "(", ")", ".", "setParameter", "(", "ConnRoutePNames", ".", "DEFAULT_PROXY", ",", "proxy", ")", ";", "}", "else", "System", ".", "err", ".", "println", "(", "\"Invalid proxy configuration: \"", "+", "proxy", ")", ";", "}", "if", "(", "auths", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "Auth", "authObject", ":", "auths", ")", "{", "client", ".", "getCredentialsProvider", "(", ")", ".", "setCredentials", "(", "new", "AuthScope", "(", "authObject", ".", "getScope", "(", ")", ",", "authObject", ".", "getPort", "(", ")", ")", ",", "new", "UsernamePasswordCredentials", "(", "authObject", ".", "getUserName", "(", ")", ",", "authObject", ".", "getPassword", "(", ")", ")", ")", ";", "}", "}", "return", "client", ";", "}" ]
Get the client. @return the client
[ "Get", "the", "client", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/guice/HttpClientProvider.java#L122-L167
7,460
soulgalore/crawler
src/main/java/com/soulgalore/crawler/util/HeaderUtil.java
HeaderUtil.createHeadersFromString
public Map<String, String> createHeadersFromString(String headersAndValues) { if (headersAndValues == null || headersAndValues.isEmpty()) return Collections.emptyMap(); final StringTokenizer token = new StringTokenizer(headersAndValues, "@"); final Map<String, String> theHeaders = new HashMap<String, String>(token.countTokens()); while (token.hasMoreTokens()) { final String headerAndValue = token.nextToken(); if (!headerAndValue.contains(":")) throw new IllegalArgumentException( "Request headers wrongly configured, missing separator :" + headersAndValues); final String header = headerAndValue.substring(0, headerAndValue.indexOf(":")); final String value = headerAndValue.substring(headerAndValue.indexOf(":") + 1, headerAndValue.length()); theHeaders.put(header, value); } return theHeaders; }
java
public Map<String, String> createHeadersFromString(String headersAndValues) { if (headersAndValues == null || headersAndValues.isEmpty()) return Collections.emptyMap(); final StringTokenizer token = new StringTokenizer(headersAndValues, "@"); final Map<String, String> theHeaders = new HashMap<String, String>(token.countTokens()); while (token.hasMoreTokens()) { final String headerAndValue = token.nextToken(); if (!headerAndValue.contains(":")) throw new IllegalArgumentException( "Request headers wrongly configured, missing separator :" + headersAndValues); final String header = headerAndValue.substring(0, headerAndValue.indexOf(":")); final String value = headerAndValue.substring(headerAndValue.indexOf(":") + 1, headerAndValue.length()); theHeaders.put(header, value); } return theHeaders; }
[ "public", "Map", "<", "String", ",", "String", ">", "createHeadersFromString", "(", "String", "headersAndValues", ")", "{", "if", "(", "headersAndValues", "==", "null", "||", "headersAndValues", ".", "isEmpty", "(", ")", ")", "return", "Collections", ".", "emptyMap", "(", ")", ";", "final", "StringTokenizer", "token", "=", "new", "StringTokenizer", "(", "headersAndValues", ",", "\"@\"", ")", ";", "final", "Map", "<", "String", ",", "String", ">", "theHeaders", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", "token", ".", "countTokens", "(", ")", ")", ";", "while", "(", "token", ".", "hasMoreTokens", "(", ")", ")", "{", "final", "String", "headerAndValue", "=", "token", ".", "nextToken", "(", ")", ";", "if", "(", "!", "headerAndValue", ".", "contains", "(", "\":\"", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Request headers wrongly configured, missing separator :\"", "+", "headersAndValues", ")", ";", "final", "String", "header", "=", "headerAndValue", ".", "substring", "(", "0", ",", "headerAndValue", ".", "indexOf", "(", "\":\"", ")", ")", ";", "final", "String", "value", "=", "headerAndValue", ".", "substring", "(", "headerAndValue", ".", "indexOf", "(", "\":\"", ")", "+", "1", ",", "headerAndValue", ".", "length", "(", ")", ")", ";", "theHeaders", ".", "put", "(", "header", ",", "value", ")", ";", "}", "return", "theHeaders", ";", "}" ]
Create headers from a string. @param headersAndValues by the header1:value1,header2:value2... @return the Headers as a Set
[ "Create", "headers", "from", "a", "string", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/util/HeaderUtil.java#L63-L85
7,461
soulgalore/crawler
src/main/java/com/soulgalore/crawler/util/AuthUtil.java
AuthUtil.createAuthsFromString
public Set<Auth> createAuthsFromString(String authInfo) { if ("".equals(authInfo) || authInfo == null) return Collections.emptySet(); String[] parts = authInfo.split(","); final Set<Auth> auths = new HashSet<Auth>(); try { for (String auth : parts) { StringTokenizer tokenizer = new StringTokenizer(auth, ":"); while (tokenizer.hasMoreTokens()) { auths.add(new Auth(tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken())); } } return auths; } catch (NoSuchElementException e) { final StringBuilder b = new StringBuilder(); for (String auth : parts) { b.append(auth); } throw new IllegalArgumentException( "Auth configuration is configured wrongly:" + b.toString(), e); } }
java
public Set<Auth> createAuthsFromString(String authInfo) { if ("".equals(authInfo) || authInfo == null) return Collections.emptySet(); String[] parts = authInfo.split(","); final Set<Auth> auths = new HashSet<Auth>(); try { for (String auth : parts) { StringTokenizer tokenizer = new StringTokenizer(auth, ":"); while (tokenizer.hasMoreTokens()) { auths.add(new Auth(tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken(), tokenizer.nextToken())); } } return auths; } catch (NoSuchElementException e) { final StringBuilder b = new StringBuilder(); for (String auth : parts) { b.append(auth); } throw new IllegalArgumentException( "Auth configuration is configured wrongly:" + b.toString(), e); } }
[ "public", "Set", "<", "Auth", ">", "createAuthsFromString", "(", "String", "authInfo", ")", "{", "if", "(", "\"\"", ".", "equals", "(", "authInfo", ")", "||", "authInfo", "==", "null", ")", "return", "Collections", ".", "emptySet", "(", ")", ";", "String", "[", "]", "parts", "=", "authInfo", ".", "split", "(", "\",\"", ")", ";", "final", "Set", "<", "Auth", ">", "auths", "=", "new", "HashSet", "<", "Auth", ">", "(", ")", ";", "try", "{", "for", "(", "String", "auth", ":", "parts", ")", "{", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "auth", ",", "\":\"", ")", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "auths", ".", "add", "(", "new", "Auth", "(", "tokenizer", ".", "nextToken", "(", ")", ",", "tokenizer", ".", "nextToken", "(", ")", ",", "tokenizer", ".", "nextToken", "(", ")", ",", "tokenizer", ".", "nextToken", "(", ")", ")", ")", ";", "}", "}", "return", "auths", ";", "}", "catch", "(", "NoSuchElementException", "e", ")", "{", "final", "StringBuilder", "b", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "auth", ":", "parts", ")", "{", "b", ".", "append", "(", "auth", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"Auth configuration is configured wrongly:\"", "+", "b", ".", "toString", "(", ")", ",", "e", ")", ";", "}", "}" ]
Create a auth object from a String looking like. @param authInfo the authinfo in the form of @return a Set of auth
[ "Create", "a", "auth", "object", "from", "a", "String", "looking", "like", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/util/AuthUtil.java#L36-L65
7,462
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/preconditions/SpatialIndexExistsPrecondition.java
SpatialIndexExistsPrecondition.getHatboxTableName
protected String getHatboxTableName() { final String tableName; if (!StringUtils.hasUpperCase(getTableName())) { tableName = getTableName() + "_hatbox"; } else { tableName = getTableName() + "_HATBOX"; } return tableName; }
java
protected String getHatboxTableName() { final String tableName; if (!StringUtils.hasUpperCase(getTableName())) { tableName = getTableName() + "_hatbox"; } else { tableName = getTableName() + "_HATBOX"; } return tableName; }
[ "protected", "String", "getHatboxTableName", "(", ")", "{", "final", "String", "tableName", ";", "if", "(", "!", "StringUtils", ".", "hasUpperCase", "(", "getTableName", "(", ")", ")", ")", "{", "tableName", "=", "getTableName", "(", ")", "+", "\"_hatbox\"", ";", "}", "else", "{", "tableName", "=", "getTableName", "(", ")", "+", "\"_HATBOX\"", ";", "}", "return", "tableName", ";", "}" ]
Generates the table name containing the Hatbox index. @return the Hatbox table name.
[ "Generates", "the", "table", "name", "containing", "the", "Hatbox", "index", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/preconditions/SpatialIndexExistsPrecondition.java#L142-L150
7,463
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/preconditions/SpatialIndexExistsPrecondition.java
SpatialIndexExistsPrecondition.getExample
public DatabaseObject getExample(final Database database, final String tableName) { final Schema schema = new Schema(getCatalogName(), getSchemaName()); final DatabaseObject example; // For GeoDB, the index is another table. if (database instanceof DerbyDatabase || database instanceof H2Database) { final String correctedTableName = database.correctObjectName(getHatboxTableName(), Table.class); example = new Table().setName(correctedTableName).setSchema(schema); } else { example = getIndexExample(database, schema, tableName); } return example; }
java
public DatabaseObject getExample(final Database database, final String tableName) { final Schema schema = new Schema(getCatalogName(), getSchemaName()); final DatabaseObject example; // For GeoDB, the index is another table. if (database instanceof DerbyDatabase || database instanceof H2Database) { final String correctedTableName = database.correctObjectName(getHatboxTableName(), Table.class); example = new Table().setName(correctedTableName).setSchema(schema); } else { example = getIndexExample(database, schema, tableName); } return example; }
[ "public", "DatabaseObject", "getExample", "(", "final", "Database", "database", ",", "final", "String", "tableName", ")", "{", "final", "Schema", "schema", "=", "new", "Schema", "(", "getCatalogName", "(", ")", ",", "getSchemaName", "(", ")", ")", ";", "final", "DatabaseObject", "example", ";", "// For GeoDB, the index is another table.", "if", "(", "database", "instanceof", "DerbyDatabase", "||", "database", "instanceof", "H2Database", ")", "{", "final", "String", "correctedTableName", "=", "database", ".", "correctObjectName", "(", "getHatboxTableName", "(", ")", ",", "Table", ".", "class", ")", ";", "example", "=", "new", "Table", "(", ")", ".", "setName", "(", "correctedTableName", ")", ".", "setSchema", "(", "schema", ")", ";", "}", "else", "{", "example", "=", "getIndexExample", "(", "database", ",", "schema", ",", "tableName", ")", ";", "}", "return", "example", ";", "}" ]
Creates an example of the database object for which to check. @param database the database instance. @param tableName the table name of the index. @return the database object example.
[ "Creates", "an", "example", "of", "the", "database", "object", "for", "which", "to", "check", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/preconditions/SpatialIndexExistsPrecondition.java#L161-L174
7,464
Addicticks/httpsupload
src/main/java/com/addicticks/net/httpsupload/SSLUtils.java
SSLUtils.getNonValidatingTrustManagers
private static TrustManager[] getNonValidatingTrustManagers(String[] acceptedIssuers) { X509TrustManager x509TrustManager = new CustomX509TrustManager(acceptedIssuers); return new TrustManager[]{x509TrustManager}; }
java
private static TrustManager[] getNonValidatingTrustManagers(String[] acceptedIssuers) { X509TrustManager x509TrustManager = new CustomX509TrustManager(acceptedIssuers); return new TrustManager[]{x509TrustManager}; }
[ "private", "static", "TrustManager", "[", "]", "getNonValidatingTrustManagers", "(", "String", "[", "]", "acceptedIssuers", ")", "{", "X509TrustManager", "x509TrustManager", "=", "new", "CustomX509TrustManager", "(", "acceptedIssuers", ")", ";", "return", "new", "TrustManager", "[", "]", "{", "x509TrustManager", "}", ";", "}" ]
we want to allow self-signed certificates.
[ "we", "want", "to", "allow", "self", "-", "signed", "certificates", "." ]
261a8e63ec923482a74ffe1352024c1900c55a55
https://github.com/Addicticks/httpsupload/blob/261a8e63ec923482a74ffe1352024c1900c55a55/src/main/java/com/addicticks/net/httpsupload/SSLUtils.java#L62-L65
7,465
lonnyj/liquibase-spatial
src/main/java/liquibase/ext/spatial/sqlgenerator/SpatialUpdateGeneratorOracle.java
SpatialUpdateGeneratorOracle.convertToFunction
@Override public String convertToFunction(final String wkt, final String srid, final Database database) { final String oracleWkt = OracleSpatialUtils.getOracleWkt(wkt); final String oracleSrid = OracleSpatialUtils.getOracleSrid(srid, database); return super.convertToFunction(oracleWkt, oracleSrid, database); }
java
@Override public String convertToFunction(final String wkt, final String srid, final Database database) { final String oracleWkt = OracleSpatialUtils.getOracleWkt(wkt); final String oracleSrid = OracleSpatialUtils.getOracleSrid(srid, database); return super.convertToFunction(oracleWkt, oracleSrid, database); }
[ "@", "Override", "public", "String", "convertToFunction", "(", "final", "String", "wkt", ",", "final", "String", "srid", ",", "final", "Database", "database", ")", "{", "final", "String", "oracleWkt", "=", "OracleSpatialUtils", ".", "getOracleWkt", "(", "wkt", ")", ";", "final", "String", "oracleSrid", "=", "OracleSpatialUtils", ".", "getOracleSrid", "(", "srid", ",", "database", ")", ";", "return", "super", ".", "convertToFunction", "(", "oracleWkt", ",", "oracleSrid", ",", "database", ")", ";", "}" ]
Handles the Well-Known Text and SRID for Oracle.
[ "Handles", "the", "Well", "-", "Known", "Text", "and", "SRID", "for", "Oracle", "." ]
36ae41b0d3d08bb00a22c856e51ffeed08891c0e
https://github.com/lonnyj/liquibase-spatial/blob/36ae41b0d3d08bb00a22c856e51ffeed08891c0e/src/main/java/liquibase/ext/spatial/sqlgenerator/SpatialUpdateGeneratorOracle.java#L34-L39
7,466
soulgalore/crawler
src/main/java/com/soulgalore/crawler/core/impl/DefaultCrawler.java
DefaultCrawler.getUrls
public CrawlerResult getUrls(CrawlerConfiguration configuration) { final Map<String, String> requestHeaders = configuration.getRequestHeadersMap(); final HTMLPageResponse resp = verifyInput(configuration.getStartUrl(), configuration.getOnlyOnPath(), requestHeaders); int level = 0; final Set<CrawlerURL> allUrls = new LinkedHashSet<CrawlerURL>(); final Set<HTMLPageResponse> verifiedUrls = new LinkedHashSet<HTMLPageResponse>(); final Set<HTMLPageResponse> nonWorkingResponses = new LinkedHashSet<HTMLPageResponse>(); verifiedUrls.add(resp); final String host = resp.getPageUrl().getHost(); if (configuration.getMaxLevels() > 0) { // set the start url Set<CrawlerURL> nextToFetch = new LinkedHashSet<CrawlerURL>(); nextToFetch.add(resp.getPageUrl()); while (level < configuration.getMaxLevels()) { final Map<Future<HTMLPageResponse>, CrawlerURL> futures = new HashMap<Future<HTMLPageResponse>, CrawlerURL>(nextToFetch.size()); for (CrawlerURL testURL : nextToFetch) { futures.put(service.submit(new HTMLPageResponseCallable(testURL, responseFetcher, true, requestHeaders, false)), testURL); } nextToFetch = fetchNextLevelLinks(futures, allUrls, nonWorkingResponses, verifiedUrls, host, configuration.getOnlyOnPath(), configuration.getNotOnPath()); level++; } } else { allUrls.add(resp.getPageUrl()); } if (configuration.isVerifyUrls()) verifyUrls(allUrls, verifiedUrls, nonWorkingResponses, requestHeaders); LinkedHashSet<CrawlerURL> workingUrls = new LinkedHashSet<CrawlerURL>(); for (HTMLPageResponse workingResponses : verifiedUrls) { workingUrls.add(workingResponses.getPageUrl()); } // TODO find a better fix for this // wow, this is a hack to fix if the first URL is redirected, // then we want to keep that original start url if (workingUrls.size() >= 1) { List<CrawlerURL> list = new ArrayList<CrawlerURL>(workingUrls); list.add(0, new CrawlerURL(configuration.getStartUrl())); list.remove(1); workingUrls.clear(); workingUrls.addAll(list); } return new CrawlerResult(configuration.getStartUrl(), configuration.isVerifyUrls() ? workingUrls : allUrls, verifiedUrls, nonWorkingResponses); }
java
public CrawlerResult getUrls(CrawlerConfiguration configuration) { final Map<String, String> requestHeaders = configuration.getRequestHeadersMap(); final HTMLPageResponse resp = verifyInput(configuration.getStartUrl(), configuration.getOnlyOnPath(), requestHeaders); int level = 0; final Set<CrawlerURL> allUrls = new LinkedHashSet<CrawlerURL>(); final Set<HTMLPageResponse> verifiedUrls = new LinkedHashSet<HTMLPageResponse>(); final Set<HTMLPageResponse> nonWorkingResponses = new LinkedHashSet<HTMLPageResponse>(); verifiedUrls.add(resp); final String host = resp.getPageUrl().getHost(); if (configuration.getMaxLevels() > 0) { // set the start url Set<CrawlerURL> nextToFetch = new LinkedHashSet<CrawlerURL>(); nextToFetch.add(resp.getPageUrl()); while (level < configuration.getMaxLevels()) { final Map<Future<HTMLPageResponse>, CrawlerURL> futures = new HashMap<Future<HTMLPageResponse>, CrawlerURL>(nextToFetch.size()); for (CrawlerURL testURL : nextToFetch) { futures.put(service.submit(new HTMLPageResponseCallable(testURL, responseFetcher, true, requestHeaders, false)), testURL); } nextToFetch = fetchNextLevelLinks(futures, allUrls, nonWorkingResponses, verifiedUrls, host, configuration.getOnlyOnPath(), configuration.getNotOnPath()); level++; } } else { allUrls.add(resp.getPageUrl()); } if (configuration.isVerifyUrls()) verifyUrls(allUrls, verifiedUrls, nonWorkingResponses, requestHeaders); LinkedHashSet<CrawlerURL> workingUrls = new LinkedHashSet<CrawlerURL>(); for (HTMLPageResponse workingResponses : verifiedUrls) { workingUrls.add(workingResponses.getPageUrl()); } // TODO find a better fix for this // wow, this is a hack to fix if the first URL is redirected, // then we want to keep that original start url if (workingUrls.size() >= 1) { List<CrawlerURL> list = new ArrayList<CrawlerURL>(workingUrls); list.add(0, new CrawlerURL(configuration.getStartUrl())); list.remove(1); workingUrls.clear(); workingUrls.addAll(list); } return new CrawlerResult(configuration.getStartUrl(), configuration.isVerifyUrls() ? workingUrls : allUrls, verifiedUrls, nonWorkingResponses); }
[ "public", "CrawlerResult", "getUrls", "(", "CrawlerConfiguration", "configuration", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "requestHeaders", "=", "configuration", ".", "getRequestHeadersMap", "(", ")", ";", "final", "HTMLPageResponse", "resp", "=", "verifyInput", "(", "configuration", ".", "getStartUrl", "(", ")", ",", "configuration", ".", "getOnlyOnPath", "(", ")", ",", "requestHeaders", ")", ";", "int", "level", "=", "0", ";", "final", "Set", "<", "CrawlerURL", ">", "allUrls", "=", "new", "LinkedHashSet", "<", "CrawlerURL", ">", "(", ")", ";", "final", "Set", "<", "HTMLPageResponse", ">", "verifiedUrls", "=", "new", "LinkedHashSet", "<", "HTMLPageResponse", ">", "(", ")", ";", "final", "Set", "<", "HTMLPageResponse", ">", "nonWorkingResponses", "=", "new", "LinkedHashSet", "<", "HTMLPageResponse", ">", "(", ")", ";", "verifiedUrls", ".", "add", "(", "resp", ")", ";", "final", "String", "host", "=", "resp", ".", "getPageUrl", "(", ")", ".", "getHost", "(", ")", ";", "if", "(", "configuration", ".", "getMaxLevels", "(", ")", ">", "0", ")", "{", "// set the start url", "Set", "<", "CrawlerURL", ">", "nextToFetch", "=", "new", "LinkedHashSet", "<", "CrawlerURL", ">", "(", ")", ";", "nextToFetch", ".", "add", "(", "resp", ".", "getPageUrl", "(", ")", ")", ";", "while", "(", "level", "<", "configuration", ".", "getMaxLevels", "(", ")", ")", "{", "final", "Map", "<", "Future", "<", "HTMLPageResponse", ">", ",", "CrawlerURL", ">", "futures", "=", "new", "HashMap", "<", "Future", "<", "HTMLPageResponse", ">", ",", "CrawlerURL", ">", "(", "nextToFetch", ".", "size", "(", ")", ")", ";", "for", "(", "CrawlerURL", "testURL", ":", "nextToFetch", ")", "{", "futures", ".", "put", "(", "service", ".", "submit", "(", "new", "HTMLPageResponseCallable", "(", "testURL", ",", "responseFetcher", ",", "true", ",", "requestHeaders", ",", "false", ")", ")", ",", "testURL", ")", ";", "}", "nextToFetch", "=", "fetchNextLevelLinks", "(", "futures", ",", "allUrls", ",", "nonWorkingResponses", ",", "verifiedUrls", ",", "host", ",", "configuration", ".", "getOnlyOnPath", "(", ")", ",", "configuration", ".", "getNotOnPath", "(", ")", ")", ";", "level", "++", ";", "}", "}", "else", "{", "allUrls", ".", "add", "(", "resp", ".", "getPageUrl", "(", ")", ")", ";", "}", "if", "(", "configuration", ".", "isVerifyUrls", "(", ")", ")", "verifyUrls", "(", "allUrls", ",", "verifiedUrls", ",", "nonWorkingResponses", ",", "requestHeaders", ")", ";", "LinkedHashSet", "<", "CrawlerURL", ">", "workingUrls", "=", "new", "LinkedHashSet", "<", "CrawlerURL", ">", "(", ")", ";", "for", "(", "HTMLPageResponse", "workingResponses", ":", "verifiedUrls", ")", "{", "workingUrls", ".", "add", "(", "workingResponses", ".", "getPageUrl", "(", ")", ")", ";", "}", "// TODO find a better fix for this", "// wow, this is a hack to fix if the first URL is redirected,", "// then we want to keep that original start url", "if", "(", "workingUrls", ".", "size", "(", ")", ">=", "1", ")", "{", "List", "<", "CrawlerURL", ">", "list", "=", "new", "ArrayList", "<", "CrawlerURL", ">", "(", "workingUrls", ")", ";", "list", ".", "add", "(", "0", ",", "new", "CrawlerURL", "(", "configuration", ".", "getStartUrl", "(", ")", ")", ")", ";", "list", ".", "remove", "(", "1", ")", ";", "workingUrls", ".", "clear", "(", ")", ";", "workingUrls", ".", "addAll", "(", "list", ")", ";", "}", "return", "new", "CrawlerResult", "(", "configuration", ".", "getStartUrl", "(", ")", ",", "configuration", ".", "isVerifyUrls", "(", ")", "?", "workingUrls", ":", "allUrls", ",", "verifiedUrls", ",", "nonWorkingResponses", ")", ";", "}" ]
Get the urls. @param configuration how to perform the crawl @return the result of the crawl
[ "Get", "the", "urls", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/core/impl/DefaultCrawler.java#L92-L156
7,467
soulgalore/crawler
src/main/java/com/soulgalore/crawler/core/impl/DefaultCrawler.java
DefaultCrawler.fetchNextLevelLinks
protected Set<CrawlerURL> fetchNextLevelLinks(Map<Future<HTMLPageResponse>, CrawlerURL> responses, Set<CrawlerURL> allUrls, Set<HTMLPageResponse> nonWorkingUrls, Set<HTMLPageResponse> verifiedUrls, String host, String onlyOnPath, String notOnPath) { final Set<CrawlerURL> nextLevel = new LinkedHashSet<CrawlerURL>(); final Iterator<Entry<Future<HTMLPageResponse>, CrawlerURL>> it = responses.entrySet().iterator(); while (it.hasNext()) { final Entry<Future<HTMLPageResponse>, CrawlerURL> entry = it.next(); try { final HTMLPageResponse response = entry.getKey().get(); if (HttpStatus.SC_OK == response.getResponseCode() && response.getResponseType().indexOf("html") > 0) { // we know that this links work verifiedUrls.add(response); final Set<CrawlerURL> allLinks = parser.get(response); for (CrawlerURL link : allLinks) { // only add if it is the same host if (host.equals(link.getHost()) && link.getUrl().contains(onlyOnPath) && (notOnPath.equals("") ? true : (!link.getUrl().contains(notOnPath)))) { if (!allUrls.contains(link)) { nextLevel.add(link); allUrls.add(link); } } } } else if (HttpStatus.SC_OK != response.getResponseCode() || StatusCode.SC_SERVER_REDIRECT_TO_NEW_DOMAIN.getCode() == response.getResponseCode()) { allUrls.remove(entry.getValue()); nonWorkingUrls.add(response); } else { // it is of another content type than HTML or if it redirected to another domain allUrls.remove(entry.getValue()); } } catch (InterruptedException e) { nonWorkingUrls.add(new HTMLPageResponse(entry.getValue(), StatusCode.SC_SERVER_RESPONSE_UNKNOWN.getCode(), Collections.<String, String>emptyMap(), "", "", 0, "", -1)); } catch (ExecutionException e) { nonWorkingUrls.add(new HTMLPageResponse(entry.getValue(), StatusCode.SC_SERVER_RESPONSE_UNKNOWN.getCode(), Collections.<String, String>emptyMap(), "", "", 0, "", -1)); } } return nextLevel; }
java
protected Set<CrawlerURL> fetchNextLevelLinks(Map<Future<HTMLPageResponse>, CrawlerURL> responses, Set<CrawlerURL> allUrls, Set<HTMLPageResponse> nonWorkingUrls, Set<HTMLPageResponse> verifiedUrls, String host, String onlyOnPath, String notOnPath) { final Set<CrawlerURL> nextLevel = new LinkedHashSet<CrawlerURL>(); final Iterator<Entry<Future<HTMLPageResponse>, CrawlerURL>> it = responses.entrySet().iterator(); while (it.hasNext()) { final Entry<Future<HTMLPageResponse>, CrawlerURL> entry = it.next(); try { final HTMLPageResponse response = entry.getKey().get(); if (HttpStatus.SC_OK == response.getResponseCode() && response.getResponseType().indexOf("html") > 0) { // we know that this links work verifiedUrls.add(response); final Set<CrawlerURL> allLinks = parser.get(response); for (CrawlerURL link : allLinks) { // only add if it is the same host if (host.equals(link.getHost()) && link.getUrl().contains(onlyOnPath) && (notOnPath.equals("") ? true : (!link.getUrl().contains(notOnPath)))) { if (!allUrls.contains(link)) { nextLevel.add(link); allUrls.add(link); } } } } else if (HttpStatus.SC_OK != response.getResponseCode() || StatusCode.SC_SERVER_REDIRECT_TO_NEW_DOMAIN.getCode() == response.getResponseCode()) { allUrls.remove(entry.getValue()); nonWorkingUrls.add(response); } else { // it is of another content type than HTML or if it redirected to another domain allUrls.remove(entry.getValue()); } } catch (InterruptedException e) { nonWorkingUrls.add(new HTMLPageResponse(entry.getValue(), StatusCode.SC_SERVER_RESPONSE_UNKNOWN.getCode(), Collections.<String, String>emptyMap(), "", "", 0, "", -1)); } catch (ExecutionException e) { nonWorkingUrls.add(new HTMLPageResponse(entry.getValue(), StatusCode.SC_SERVER_RESPONSE_UNKNOWN.getCode(), Collections.<String, String>emptyMap(), "", "", 0, "", -1)); } } return nextLevel; }
[ "protected", "Set", "<", "CrawlerURL", ">", "fetchNextLevelLinks", "(", "Map", "<", "Future", "<", "HTMLPageResponse", ">", ",", "CrawlerURL", ">", "responses", ",", "Set", "<", "CrawlerURL", ">", "allUrls", ",", "Set", "<", "HTMLPageResponse", ">", "nonWorkingUrls", ",", "Set", "<", "HTMLPageResponse", ">", "verifiedUrls", ",", "String", "host", ",", "String", "onlyOnPath", ",", "String", "notOnPath", ")", "{", "final", "Set", "<", "CrawlerURL", ">", "nextLevel", "=", "new", "LinkedHashSet", "<", "CrawlerURL", ">", "(", ")", ";", "final", "Iterator", "<", "Entry", "<", "Future", "<", "HTMLPageResponse", ">", ",", "CrawlerURL", ">", ">", "it", "=", "responses", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "final", "Entry", "<", "Future", "<", "HTMLPageResponse", ">", ",", "CrawlerURL", ">", "entry", "=", "it", ".", "next", "(", ")", ";", "try", "{", "final", "HTMLPageResponse", "response", "=", "entry", ".", "getKey", "(", ")", ".", "get", "(", ")", ";", "if", "(", "HttpStatus", ".", "SC_OK", "==", "response", ".", "getResponseCode", "(", ")", "&&", "response", ".", "getResponseType", "(", ")", ".", "indexOf", "(", "\"html\"", ")", ">", "0", ")", "{", "// we know that this links work", "verifiedUrls", ".", "add", "(", "response", ")", ";", "final", "Set", "<", "CrawlerURL", ">", "allLinks", "=", "parser", ".", "get", "(", "response", ")", ";", "for", "(", "CrawlerURL", "link", ":", "allLinks", ")", "{", "// only add if it is the same host", "if", "(", "host", ".", "equals", "(", "link", ".", "getHost", "(", ")", ")", "&&", "link", ".", "getUrl", "(", ")", ".", "contains", "(", "onlyOnPath", ")", "&&", "(", "notOnPath", ".", "equals", "(", "\"\"", ")", "?", "true", ":", "(", "!", "link", ".", "getUrl", "(", ")", ".", "contains", "(", "notOnPath", ")", ")", ")", ")", "{", "if", "(", "!", "allUrls", ".", "contains", "(", "link", ")", ")", "{", "nextLevel", ".", "add", "(", "link", ")", ";", "allUrls", ".", "add", "(", "link", ")", ";", "}", "}", "}", "}", "else", "if", "(", "HttpStatus", ".", "SC_OK", "!=", "response", ".", "getResponseCode", "(", ")", "||", "StatusCode", ".", "SC_SERVER_REDIRECT_TO_NEW_DOMAIN", ".", "getCode", "(", ")", "==", "response", ".", "getResponseCode", "(", ")", ")", "{", "allUrls", ".", "remove", "(", "entry", ".", "getValue", "(", ")", ")", ";", "nonWorkingUrls", ".", "add", "(", "response", ")", ";", "}", "else", "{", "// it is of another content type than HTML or if it redirected to another domain", "allUrls", ".", "remove", "(", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "nonWorkingUrls", ".", "add", "(", "new", "HTMLPageResponse", "(", "entry", ".", "getValue", "(", ")", ",", "StatusCode", ".", "SC_SERVER_RESPONSE_UNKNOWN", ".", "getCode", "(", ")", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ",", "\"\"", ",", "\"\"", ",", "0", ",", "\"\"", ",", "-", "1", ")", ")", ";", "}", "catch", "(", "ExecutionException", "e", ")", "{", "nonWorkingUrls", ".", "add", "(", "new", "HTMLPageResponse", "(", "entry", ".", "getValue", "(", ")", ",", "StatusCode", ".", "SC_SERVER_RESPONSE_UNKNOWN", ".", "getCode", "(", ")", ",", "Collections", ".", "<", "String", ",", "String", ">", "emptyMap", "(", ")", ",", "\"\"", ",", "\"\"", ",", "0", ",", "\"\"", ",", "-", "1", ")", ")", ";", "}", "}", "return", "nextLevel", ";", "}" ]
Fetch links to the next level of the crawl. @param responses holding bodys where we should fetch the links. @param allUrls every url we have fetched so far @param nonWorkingUrls the urls that didn't work to fetch @param verifiedUrls responses that are already verified @param host the host we are working on @param onlyOnPath only fetch files that match the following path. If empty, all will match. @param notOnPath don't collect/follow urls that contains this text in the url @return the next level of links that we should fetch
[ "Fetch", "links", "to", "the", "next", "level", "of", "the", "crawl", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/core/impl/DefaultCrawler.java#L170-L220
7,468
soulgalore/crawler
src/main/java/com/soulgalore/crawler/core/impl/DefaultCrawler.java
DefaultCrawler.verifyUrls
private void verifyUrls(Set<CrawlerURL> allUrls, Set<HTMLPageResponse> verifiedUrls, Set<HTMLPageResponse> nonWorkingUrls, Map<String, String> requestHeaders) { Set<CrawlerURL> urlsThatNeedsVerification = new LinkedHashSet<CrawlerURL>(allUrls); urlsThatNeedsVerification.removeAll(verifiedUrls); final Set<Callable<HTMLPageResponse>> tasks = new HashSet<Callable<HTMLPageResponse>>(urlsThatNeedsVerification.size()); for (CrawlerURL testURL : urlsThatNeedsVerification) { tasks.add(new HTMLPageResponseCallable(testURL, responseFetcher, true, requestHeaders, false)); } try { // wait for all urls to verify List<Future<HTMLPageResponse>> responses = service.invokeAll(tasks); for (Future<HTMLPageResponse> future : responses) { if (!future.isCancelled()) { HTMLPageResponse response = future.get(); if (response.getResponseCode() == HttpStatus.SC_OK && response.getResponseType().indexOf("html") > 0) { // remove, way of catching interrupted / execution e urlsThatNeedsVerification.remove(response.getPageUrl()); verifiedUrls.add(response); } else if (response.getResponseCode() == HttpStatus.SC_OK) { // it is not HTML urlsThatNeedsVerification.remove(response.getPageUrl()); } else { nonWorkingUrls.add(response); } } } } catch (InterruptedException e1) { // TODO add some logging e1.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO: We can have a delta here if the exception occur }
java
private void verifyUrls(Set<CrawlerURL> allUrls, Set<HTMLPageResponse> verifiedUrls, Set<HTMLPageResponse> nonWorkingUrls, Map<String, String> requestHeaders) { Set<CrawlerURL> urlsThatNeedsVerification = new LinkedHashSet<CrawlerURL>(allUrls); urlsThatNeedsVerification.removeAll(verifiedUrls); final Set<Callable<HTMLPageResponse>> tasks = new HashSet<Callable<HTMLPageResponse>>(urlsThatNeedsVerification.size()); for (CrawlerURL testURL : urlsThatNeedsVerification) { tasks.add(new HTMLPageResponseCallable(testURL, responseFetcher, true, requestHeaders, false)); } try { // wait for all urls to verify List<Future<HTMLPageResponse>> responses = service.invokeAll(tasks); for (Future<HTMLPageResponse> future : responses) { if (!future.isCancelled()) { HTMLPageResponse response = future.get(); if (response.getResponseCode() == HttpStatus.SC_OK && response.getResponseType().indexOf("html") > 0) { // remove, way of catching interrupted / execution e urlsThatNeedsVerification.remove(response.getPageUrl()); verifiedUrls.add(response); } else if (response.getResponseCode() == HttpStatus.SC_OK) { // it is not HTML urlsThatNeedsVerification.remove(response.getPageUrl()); } else { nonWorkingUrls.add(response); } } } } catch (InterruptedException e1) { // TODO add some logging e1.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO: We can have a delta here if the exception occur }
[ "private", "void", "verifyUrls", "(", "Set", "<", "CrawlerURL", ">", "allUrls", ",", "Set", "<", "HTMLPageResponse", ">", "verifiedUrls", ",", "Set", "<", "HTMLPageResponse", ">", "nonWorkingUrls", ",", "Map", "<", "String", ",", "String", ">", "requestHeaders", ")", "{", "Set", "<", "CrawlerURL", ">", "urlsThatNeedsVerification", "=", "new", "LinkedHashSet", "<", "CrawlerURL", ">", "(", "allUrls", ")", ";", "urlsThatNeedsVerification", ".", "removeAll", "(", "verifiedUrls", ")", ";", "final", "Set", "<", "Callable", "<", "HTMLPageResponse", ">", ">", "tasks", "=", "new", "HashSet", "<", "Callable", "<", "HTMLPageResponse", ">", ">", "(", "urlsThatNeedsVerification", ".", "size", "(", ")", ")", ";", "for", "(", "CrawlerURL", "testURL", ":", "urlsThatNeedsVerification", ")", "{", "tasks", ".", "add", "(", "new", "HTMLPageResponseCallable", "(", "testURL", ",", "responseFetcher", ",", "true", ",", "requestHeaders", ",", "false", ")", ")", ";", "}", "try", "{", "// wait for all urls to verify", "List", "<", "Future", "<", "HTMLPageResponse", ">>", "responses", "=", "service", ".", "invokeAll", "(", "tasks", ")", ";", "for", "(", "Future", "<", "HTMLPageResponse", ">", "future", ":", "responses", ")", "{", "if", "(", "!", "future", ".", "isCancelled", "(", ")", ")", "{", "HTMLPageResponse", "response", "=", "future", ".", "get", "(", ")", ";", "if", "(", "response", ".", "getResponseCode", "(", ")", "==", "HttpStatus", ".", "SC_OK", "&&", "response", ".", "getResponseType", "(", ")", ".", "indexOf", "(", "\"html\"", ")", ">", "0", ")", "{", "// remove, way of catching interrupted / execution e", "urlsThatNeedsVerification", ".", "remove", "(", "response", ".", "getPageUrl", "(", ")", ")", ";", "verifiedUrls", ".", "add", "(", "response", ")", ";", "}", "else", "if", "(", "response", ".", "getResponseCode", "(", ")", "==", "HttpStatus", ".", "SC_OK", ")", "{", "// it is not HTML", "urlsThatNeedsVerification", ".", "remove", "(", "response", ".", "getPageUrl", "(", ")", ")", ";", "}", "else", "{", "nonWorkingUrls", ".", "add", "(", "response", ")", ";", "}", "}", "}", "}", "catch", "(", "InterruptedException", "e1", ")", "{", "// TODO add some logging", "e1", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "ExecutionException", "e", ")", "{", "// TODO Auto-generated catch block", "e", ".", "printStackTrace", "(", ")", ";", "}", "// TODO: We can have a delta here if the exception occur", "}" ]
Verify that all urls in allUrls returns 200. If not, they will be removed from that set and instead added to the nonworking list. @param allUrls all the links that has been fetched @param nonWorkingUrls links that are not working
[ "Verify", "that", "all", "urls", "in", "allUrls", "returns", "200", ".", "If", "not", "they", "will", "be", "removed", "from", "that", "set", "and", "instead", "added", "to", "the", "nonworking", "list", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/core/impl/DefaultCrawler.java#L229-L274
7,469
Addicticks/httpsupload
src/main/java/com/addicticks/net/httpsupload/HttpsFileUploaderConfig.java
HttpsFileUploaderConfig.setAdditionalHeaders
public void setAdditionalHeaders(Map<String,String> additionalHeaders) { Map<String, String> newMap = new HashMap<>(); for (Entry<String,String> e : additionalHeaders.entrySet()) { boolean found = false; for(String restrictedHeaderField : RESTRICTED_HTTP_HEADERS) { if (e.getKey().equalsIgnoreCase(restrictedHeaderField)) { found = true; break; } } if (!found) { newMap.put(e.getKey(), e.getValue()); } } this.additionalHeaders = newMap; }
java
public void setAdditionalHeaders(Map<String,String> additionalHeaders) { Map<String, String> newMap = new HashMap<>(); for (Entry<String,String> e : additionalHeaders.entrySet()) { boolean found = false; for(String restrictedHeaderField : RESTRICTED_HTTP_HEADERS) { if (e.getKey().equalsIgnoreCase(restrictedHeaderField)) { found = true; break; } } if (!found) { newMap.put(e.getKey(), e.getValue()); } } this.additionalHeaders = newMap; }
[ "public", "void", "setAdditionalHeaders", "(", "Map", "<", "String", ",", "String", ">", "additionalHeaders", ")", "{", "Map", "<", "String", ",", "String", ">", "newMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "String", ">", "e", ":", "additionalHeaders", ".", "entrySet", "(", ")", ")", "{", "boolean", "found", "=", "false", ";", "for", "(", "String", "restrictedHeaderField", ":", "RESTRICTED_HTTP_HEADERS", ")", "{", "if", "(", "e", ".", "getKey", "(", ")", ".", "equalsIgnoreCase", "(", "restrictedHeaderField", ")", ")", "{", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "newMap", ".", "put", "(", "e", ".", "getKey", "(", ")", ",", "e", ".", "getValue", "(", ")", ")", ";", "}", "}", "this", ".", "additionalHeaders", "=", "newMap", ";", "}" ]
Sets additional overall HTTP headers to add to the upload POST request. There's rarely a need to use this method. <p>The following header fields are automatically set: <pre> "Connection" "Cache-Control" "Content-Type" "Content-Length" "Authorization" </pre> and you must <i>never</i> set these here. (if you do they will be ignored) <p>However you might want to use this method to explicitly set e.g. {@code User-Agent} or non-standard header fields that are required for your particular endpoint. For example by overriding {@code User-Agent} you can make the upload operation look to the endpoint as if it comes from a browser. @param additionalHeaders Map of HTTP request headers. The key is the header field name and the value is the header field value.
[ "Sets", "additional", "overall", "HTTP", "headers", "to", "add", "to", "the", "upload", "POST", "request", ".", "There", "s", "rarely", "a", "need", "to", "use", "this", "method", "." ]
261a8e63ec923482a74ffe1352024c1900c55a55
https://github.com/Addicticks/httpsupload/blob/261a8e63ec923482a74ffe1352024c1900c55a55/src/main/java/com/addicticks/net/httpsupload/HttpsFileUploaderConfig.java#L327-L343
7,470
soulgalore/crawler
src/main/java/com/soulgalore/crawler/guice/CrawlModule.java
CrawlModule.configure
@Override protected void configure() { super.configure(); bind(Crawler.class).to(DefaultCrawler.class); bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class); bind(HTMLPageResponseFetcher.class).to(HTTPClientResponseFetcher.class); bind(HttpClient.class).toProvider(HttpClientProvider.class); bind(PageURLParser.class).to(AhrefPageURLParser.class); // For parsing assets bind(AssetsParser.class).to(DefaultAssetsParser.class); bind(AssetsVerifier.class).to(DefaultAssetsVerifier.class); bind(AssetFetcher.class).to(HTTPClientAssetFetcher.class); }
java
@Override protected void configure() { super.configure(); bind(Crawler.class).to(DefaultCrawler.class); bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class); bind(HTMLPageResponseFetcher.class).to(HTTPClientResponseFetcher.class); bind(HttpClient.class).toProvider(HttpClientProvider.class); bind(PageURLParser.class).to(AhrefPageURLParser.class); // For parsing assets bind(AssetsParser.class).to(DefaultAssetsParser.class); bind(AssetsVerifier.class).to(DefaultAssetsVerifier.class); bind(AssetFetcher.class).to(HTTPClientAssetFetcher.class); }
[ "@", "Override", "protected", "void", "configure", "(", ")", "{", "super", ".", "configure", "(", ")", ";", "bind", "(", "Crawler", ".", "class", ")", ".", "to", "(", "DefaultCrawler", ".", "class", ")", ";", "bind", "(", "ExecutorService", ".", "class", ")", ".", "toProvider", "(", "ExecutorServiceProvider", ".", "class", ")", ";", "bind", "(", "HTMLPageResponseFetcher", ".", "class", ")", ".", "to", "(", "HTTPClientResponseFetcher", ".", "class", ")", ";", "bind", "(", "HttpClient", ".", "class", ")", ".", "toProvider", "(", "HttpClientProvider", ".", "class", ")", ";", "bind", "(", "PageURLParser", ".", "class", ")", ".", "to", "(", "AhrefPageURLParser", ".", "class", ")", ";", "// For parsing assets", "bind", "(", "AssetsParser", ".", "class", ")", ".", "to", "(", "DefaultAssetsParser", ".", "class", ")", ";", "bind", "(", "AssetsVerifier", ".", "class", ")", ".", "to", "(", "DefaultAssetsVerifier", ".", "class", ")", ";", "bind", "(", "AssetFetcher", ".", "class", ")", ".", "to", "(", "HTTPClientAssetFetcher", ".", "class", ")", ";", "}" ]
Bind the classes.
[ "Bind", "the", "classes", "." ]
715ee7f1454eec14bebcb6d12563dfc32d9bbf48
https://github.com/soulgalore/crawler/blob/715ee7f1454eec14bebcb6d12563dfc32d9bbf48/src/main/java/com/soulgalore/crawler/guice/CrawlModule.java#L52-L66
7,471
Addicticks/httpsupload
src/main/java/com/addicticks/net/httpsupload/HttpsFileUploader.java
HttpsFileUploader.byteSizeIsKnown
private static boolean byteSizeIsKnown(Collection<? extends UploadItem> uploadItems) { for (UploadItem uploadItem : uploadItems) { if (uploadItem.getSizeInBytes() == -1) { return false; } } return true; }
java
private static boolean byteSizeIsKnown(Collection<? extends UploadItem> uploadItems) { for (UploadItem uploadItem : uploadItems) { if (uploadItem.getSizeInBytes() == -1) { return false; } } return true; }
[ "private", "static", "boolean", "byteSizeIsKnown", "(", "Collection", "<", "?", "extends", "UploadItem", ">", "uploadItems", ")", "{", "for", "(", "UploadItem", "uploadItem", ":", "uploadItems", ")", "{", "if", "(", "uploadItem", ".", "getSizeInBytes", "(", ")", "==", "-", "1", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Determines if there are upload items where the size is unknown in advance. This means we cannot predict the total upload size. @param uploadItems @return
[ "Determines", "if", "there", "are", "upload", "items", "where", "the", "size", "is", "unknown", "in", "advance", ".", "This", "means", "we", "cannot", "predict", "the", "total", "upload", "size", "." ]
261a8e63ec923482a74ffe1352024c1900c55a55
https://github.com/Addicticks/httpsupload/blob/261a8e63ec923482a74ffe1352024c1900c55a55/src/main/java/com/addicticks/net/httpsupload/HttpsFileUploader.java#L490-L497
7,472
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.isWatchConnected
public static boolean isWatchConnected(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return false; } return c.getInt(KIT_STATE_COLUMN_CONNECTED) == 1; } finally { if (c != null) { c.close(); } } }
java
public static boolean isWatchConnected(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return false; } return c.getInt(KIT_STATE_COLUMN_CONNECTED) == 1; } finally { if (c != null) { c.close(); } } }
[ "public", "static", "boolean", "isWatchConnected", "(", "final", "Context", "context", ")", "{", "Cursor", "c", "=", "null", ";", "try", "{", "c", "=", "queryProvider", "(", "context", ")", ";", "if", "(", "c", "==", "null", "||", "!", "c", ".", "moveToNext", "(", ")", ")", "{", "return", "false", ";", "}", "return", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_CONNECTED", ")", "==", "1", ";", "}", "finally", "{", "if", "(", "c", "!=", "null", ")", "{", "c", ".", "close", "(", ")", ";", "}", "}", "}" ]
Synchronously query the Pebble application to see if an active Bluetooth connection to a watch currently exists. @param context The Android context used to perform the query. <em>Protip:</em> You probably want to use your ApplicationContext here. @return true if an active connection to the watch currently exists, otherwise false. This method will also return false if the Pebble application is not installed on the user's handset.
[ "Synchronously", "query", "the", "Pebble", "application", "to", "see", "if", "an", "active", "Bluetooth", "connection", "to", "a", "watch", "currently", "exists", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L97-L110
7,473
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.areAppMessagesSupported
public static boolean areAppMessagesSupported(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return false; } return c.getInt(KIT_STATE_COLUMN_APPMSG_SUPPORT) == 1; } finally { if (c != null) { c.close(); } } }
java
public static boolean areAppMessagesSupported(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return false; } return c.getInt(KIT_STATE_COLUMN_APPMSG_SUPPORT) == 1; } finally { if (c != null) { c.close(); } } }
[ "public", "static", "boolean", "areAppMessagesSupported", "(", "final", "Context", "context", ")", "{", "Cursor", "c", "=", "null", ";", "try", "{", "c", "=", "queryProvider", "(", "context", ")", ";", "if", "(", "c", "==", "null", "||", "!", "c", ".", "moveToNext", "(", ")", ")", "{", "return", "false", ";", "}", "return", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_APPMSG_SUPPORT", ")", "==", "1", ";", "}", "finally", "{", "if", "(", "c", "!=", "null", ")", "{", "c", ".", "close", "(", ")", ";", "}", "}", "}" ]
Synchronously query the Pebble application to see if the connected watch is running a firmware version that supports PebbleKit messages. @param context The Android context used to perform the query. <em>Protip:</em> You probably want to use your ApplicationContext here. @return true if the watch supports PebbleKit messages, otherwise false. This method will always return false if no Pebble is currently connected to the handset.
[ "Synchronously", "query", "the", "Pebble", "application", "to", "see", "if", "the", "connected", "watch", "is", "running", "a", "firmware", "version", "that", "supports", "PebbleKit", "messages", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L124-L137
7,474
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.getWatchFWVersion
public static FirmwareVersionInfo getWatchFWVersion(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return null; } int majorVersion = c.getInt(KIT_STATE_COLUMN_VERSION_MAJOR); int minorVersion = c.getInt(KIT_STATE_COLUMN_VERSION_MINOR); int pointVersion = c.getInt(KIT_STATE_COLUMN_VERSION_POINT); String versionTag = c.getString(KIT_STATE_COLUMN_VERSION_TAG); return new FirmwareVersionInfo(majorVersion, minorVersion, pointVersion, versionTag); } finally { if (c != null) { c.close(); } } }
java
public static FirmwareVersionInfo getWatchFWVersion(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return null; } int majorVersion = c.getInt(KIT_STATE_COLUMN_VERSION_MAJOR); int minorVersion = c.getInt(KIT_STATE_COLUMN_VERSION_MINOR); int pointVersion = c.getInt(KIT_STATE_COLUMN_VERSION_POINT); String versionTag = c.getString(KIT_STATE_COLUMN_VERSION_TAG); return new FirmwareVersionInfo(majorVersion, minorVersion, pointVersion, versionTag); } finally { if (c != null) { c.close(); } } }
[ "public", "static", "FirmwareVersionInfo", "getWatchFWVersion", "(", "final", "Context", "context", ")", "{", "Cursor", "c", "=", "null", ";", "try", "{", "c", "=", "queryProvider", "(", "context", ")", ";", "if", "(", "c", "==", "null", "||", "!", "c", ".", "moveToNext", "(", ")", ")", "{", "return", "null", ";", "}", "int", "majorVersion", "=", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_VERSION_MAJOR", ")", ";", "int", "minorVersion", "=", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_VERSION_MINOR", ")", ";", "int", "pointVersion", "=", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_VERSION_POINT", ")", ";", "String", "versionTag", "=", "c", ".", "getString", "(", "KIT_STATE_COLUMN_VERSION_TAG", ")", ";", "return", "new", "FirmwareVersionInfo", "(", "majorVersion", ",", "minorVersion", ",", "pointVersion", ",", "versionTag", ")", ";", "}", "finally", "{", "if", "(", "c", "!=", "null", ")", "{", "c", ".", "close", "(", ")", ";", "}", "}", "}" ]
Get the version information of the firmware running on a connected watch. @param context The Android context used to perform the query. <em>Protip:</em> You probably want to use your ApplicationContext here. @return null if the watch is disconnected or we can't get the version. Otherwise, a FirmwareVersionObject containing info on the watch FW version
[ "Get", "the", "version", "information", "of", "the", "firmware", "running", "on", "a", "connected", "watch", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L151-L170
7,475
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.isDataLoggingSupported
public static boolean isDataLoggingSupported(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return false; } return c.getInt(KIT_STATE_COLUMN_DATALOGGING_SUPPORT) == 1; } finally { if (c != null) { c.close(); } } }
java
public static boolean isDataLoggingSupported(final Context context) { Cursor c = null; try { c = queryProvider(context); if (c == null || !c.moveToNext()) { return false; } return c.getInt(KIT_STATE_COLUMN_DATALOGGING_SUPPORT) == 1; } finally { if (c != null) { c.close(); } } }
[ "public", "static", "boolean", "isDataLoggingSupported", "(", "final", "Context", "context", ")", "{", "Cursor", "c", "=", "null", ";", "try", "{", "c", "=", "queryProvider", "(", "context", ")", ";", "if", "(", "c", "==", "null", "||", "!", "c", ".", "moveToNext", "(", ")", ")", "{", "return", "false", ";", "}", "return", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_DATALOGGING_SUPPORT", ")", "==", "1", ";", "}", "finally", "{", "if", "(", "c", "!=", "null", ")", "{", "c", ".", "close", "(", ")", ";", "}", "}", "}" ]
Synchronously query the Pebble application to see if the connected watch is running a firmware version that supports PebbleKit data logging. @param context The Android context used to perform the query. <em>Protip:</em> You probably want to use your ApplicationContext here. @return true if the watch supports PebbleKit messages, otherwise false. This method will always return false if no Pebble is currently connected to the handset.
[ "Synchronously", "query", "the", "Pebble", "application", "to", "see", "if", "the", "connected", "watch", "is", "running", "a", "firmware", "version", "that", "supports", "PebbleKit", "data", "logging", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L184-L197
7,476
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.startAppOnPebble
public static void startAppOnPebble(final Context context, final UUID watchappUuid) throws IllegalArgumentException { if (watchappUuid == null) { throw new IllegalArgumentException("uuid cannot be null"); } final Intent startAppIntent = new Intent(INTENT_APP_START); startAppIntent.putExtra(APP_UUID, watchappUuid); context.sendBroadcast(startAppIntent); }
java
public static void startAppOnPebble(final Context context, final UUID watchappUuid) throws IllegalArgumentException { if (watchappUuid == null) { throw new IllegalArgumentException("uuid cannot be null"); } final Intent startAppIntent = new Intent(INTENT_APP_START); startAppIntent.putExtra(APP_UUID, watchappUuid); context.sendBroadcast(startAppIntent); }
[ "public", "static", "void", "startAppOnPebble", "(", "final", "Context", "context", ",", "final", "UUID", "watchappUuid", ")", "throws", "IllegalArgumentException", "{", "if", "(", "watchappUuid", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"uuid cannot be null\"", ")", ";", "}", "final", "Intent", "startAppIntent", "=", "new", "Intent", "(", "INTENT_APP_START", ")", ";", "startAppIntent", ".", "putExtra", "(", "APP_UUID", ",", "watchappUuid", ")", ";", "context", ".", "sendBroadcast", "(", "startAppIntent", ")", ";", "}" ]
Send a message to the connected Pebble to launch an application identified by a UUID. If another application is currently running it will be terminated and the new application will be brought to the foreground. @param context The context used to send the broadcast. @param watchappUuid A UUID uniquely identifying the target application. UUIDs for the stock PebbleKit applications are available in {@link Constants}. @throws IllegalArgumentException Thrown if the specified UUID is invalid.
[ "Send", "a", "message", "to", "the", "connected", "Pebble", "to", "launch", "an", "application", "identified", "by", "a", "UUID", ".", "If", "another", "application", "is", "currently", "running", "it", "will", "be", "terminated", "and", "the", "new", "application", "will", "be", "brought", "to", "the", "foreground", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L212-L222
7,477
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.closeAppOnPebble
public static void closeAppOnPebble(final Context context, final UUID watchappUuid) throws IllegalArgumentException { if (watchappUuid == null) { throw new IllegalArgumentException("uuid cannot be null"); } final Intent stopAppIntent = new Intent(INTENT_APP_STOP); stopAppIntent.putExtra(APP_UUID, watchappUuid); context.sendBroadcast(stopAppIntent); }
java
public static void closeAppOnPebble(final Context context, final UUID watchappUuid) throws IllegalArgumentException { if (watchappUuid == null) { throw new IllegalArgumentException("uuid cannot be null"); } final Intent stopAppIntent = new Intent(INTENT_APP_STOP); stopAppIntent.putExtra(APP_UUID, watchappUuid); context.sendBroadcast(stopAppIntent); }
[ "public", "static", "void", "closeAppOnPebble", "(", "final", "Context", "context", ",", "final", "UUID", "watchappUuid", ")", "throws", "IllegalArgumentException", "{", "if", "(", "watchappUuid", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"uuid cannot be null\"", ")", ";", "}", "final", "Intent", "stopAppIntent", "=", "new", "Intent", "(", "INTENT_APP_STOP", ")", ";", "stopAppIntent", ".", "putExtra", "(", "APP_UUID", ",", "watchappUuid", ")", ";", "context", ".", "sendBroadcast", "(", "stopAppIntent", ")", ";", "}" ]
Send a message to the connected Pebble to close an application identified by a UUID. If this application is not currently running, the message is ignored. @param context The context used to send the broadcast. @param watchappUuid A UUID uniquely identifying the target application. UUIDs for the stock kit applications are available in {@link Constants}. @throws IllegalArgumentException Thrown if the specified UUID is invalid.
[ "Send", "a", "message", "to", "the", "connected", "Pebble", "to", "close", "an", "application", "identified", "by", "a", "UUID", ".", "If", "this", "application", "is", "not", "currently", "running", "the", "message", "is", "ignored", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L237-L247
7,478
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.sendDataToPebble
public static void sendDataToPebble(final Context context, final UUID watchappUuid, final PebbleDictionary data) throws IllegalArgumentException { sendDataToPebbleWithTransactionId(context, watchappUuid, data, -1); }
java
public static void sendDataToPebble(final Context context, final UUID watchappUuid, final PebbleDictionary data) throws IllegalArgumentException { sendDataToPebbleWithTransactionId(context, watchappUuid, data, -1); }
[ "public", "static", "void", "sendDataToPebble", "(", "final", "Context", "context", ",", "final", "UUID", "watchappUuid", ",", "final", "PebbleDictionary", "data", ")", "throws", "IllegalArgumentException", "{", "sendDataToPebbleWithTransactionId", "(", "context", ",", "watchappUuid", ",", "data", ",", "-", "1", ")", ";", "}" ]
Send one-or-more key-value pairs to the watch-app identified by the provided UUID. This is the primary method for sending data from the phone to a connected Pebble. The watch-app and phone-app must agree of the set and type of key-value pairs being exchanged. Type mismatches or missing keys will cause errors on the receiver's end. @param context The context used to send the broadcast. @param watchappUuid A UUID uniquely identifying the target application. UUIDs for the stock kit applications are available in {@link Constants}. @param data A dictionary containing one-or-more key-value pairs. For more information about the types of data that can be stored, see {@link PebbleDictionary}. @throws IllegalArgumentException Thrown in the specified PebbleDictionary or UUID is invalid.
[ "Send", "one", "-", "or", "-", "more", "key", "-", "value", "pairs", "to", "the", "watch", "-", "app", "identified", "by", "the", "provided", "UUID", ".", "This", "is", "the", "primary", "method", "for", "sending", "data", "from", "the", "phone", "to", "a", "connected", "Pebble", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L268-L272
7,479
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.sendDataToPebbleWithTransactionId
public static void sendDataToPebbleWithTransactionId(final Context context, final UUID watchappUuid, final PebbleDictionary data, final int transactionId) throws IllegalArgumentException { if (watchappUuid == null) { throw new IllegalArgumentException("uuid cannot be null"); } if (data == null) { throw new IllegalArgumentException("data cannot be null"); } if (data.size() == 0) { return; } final Intent sendDataIntent = new Intent(INTENT_APP_SEND); sendDataIntent.putExtra(APP_UUID, watchappUuid); sendDataIntent.putExtra(TRANSACTION_ID, transactionId); sendDataIntent.putExtra(MSG_DATA, data.toJsonString()); context.sendBroadcast(sendDataIntent); }
java
public static void sendDataToPebbleWithTransactionId(final Context context, final UUID watchappUuid, final PebbleDictionary data, final int transactionId) throws IllegalArgumentException { if (watchappUuid == null) { throw new IllegalArgumentException("uuid cannot be null"); } if (data == null) { throw new IllegalArgumentException("data cannot be null"); } if (data.size() == 0) { return; } final Intent sendDataIntent = new Intent(INTENT_APP_SEND); sendDataIntent.putExtra(APP_UUID, watchappUuid); sendDataIntent.putExtra(TRANSACTION_ID, transactionId); sendDataIntent.putExtra(MSG_DATA, data.toJsonString()); context.sendBroadcast(sendDataIntent); }
[ "public", "static", "void", "sendDataToPebbleWithTransactionId", "(", "final", "Context", "context", ",", "final", "UUID", "watchappUuid", ",", "final", "PebbleDictionary", "data", ",", "final", "int", "transactionId", ")", "throws", "IllegalArgumentException", "{", "if", "(", "watchappUuid", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"uuid cannot be null\"", ")", ";", "}", "if", "(", "data", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"data cannot be null\"", ")", ";", "}", "if", "(", "data", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "final", "Intent", "sendDataIntent", "=", "new", "Intent", "(", "INTENT_APP_SEND", ")", ";", "sendDataIntent", ".", "putExtra", "(", "APP_UUID", ",", "watchappUuid", ")", ";", "sendDataIntent", ".", "putExtra", "(", "TRANSACTION_ID", ",", "transactionId", ")", ";", "sendDataIntent", ".", "putExtra", "(", "MSG_DATA", ",", "data", ".", "toJsonString", "(", ")", ")", ";", "context", ".", "sendBroadcast", "(", "sendDataIntent", ")", ";", "}" ]
Send one-or-more key-value pairs to the watch-app identified by the provided UUID. The watch-app and phone-app must agree of the set and type of key-value pairs being exchanged. Type mismatches or missing keys will cause errors on the receiver's end. @param context The context used to send the broadcast. @param watchappUuid A UUID uniquely identifying the target application. UUIDs for the stock kit applications are available in {@link Constants}. @param data A dictionary containing one-or-more key-value pairs. For more information about the types of data that can be stored, see {@link PebbleDictionary}. @param transactionId An integer uniquely identifying the transaction. This can be used to correlate messages sent to the Pebble and ACK/NACKs received from the Pebble. @throws IllegalArgumentException Thrown in the specified PebbleDictionary or UUID is invalid.
[ "Send", "one", "-", "or", "-", "more", "key", "-", "value", "pairs", "to", "the", "watch", "-", "app", "identified", "by", "the", "provided", "UUID", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L295-L316
7,480
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerPebbleConnectedReceiver
public static BroadcastReceiver registerPebbleConnectedReceiver(final Context context, final BroadcastReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_PEBBLE_CONNECTED, receiver); }
java
public static BroadcastReceiver registerPebbleConnectedReceiver(final Context context, final BroadcastReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_PEBBLE_CONNECTED, receiver); }
[ "public", "static", "BroadcastReceiver", "registerPebbleConnectedReceiver", "(", "final", "Context", "context", ",", "final", "BroadcastReceiver", "receiver", ")", "{", "return", "registerBroadcastReceiverInternal", "(", "context", ",", "INTENT_PEBBLE_CONNECTED", ",", "receiver", ")", ";", "}" ]
A convenience function to assist in programatically registering a broadcast receiver for the 'CONNECTED' intent. To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param receiver The receiver to be registered. @return The registered receiver. @see Constants#INTENT_PEBBLE_CONNECTED
[ "A", "convenience", "function", "to", "assist", "in", "programatically", "registering", "a", "broadcast", "receiver", "for", "the", "CONNECTED", "intent", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L385-L388
7,481
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerPebbleDisconnectedReceiver
public static BroadcastReceiver registerPebbleDisconnectedReceiver(final Context context, final BroadcastReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_PEBBLE_DISCONNECTED, receiver); }
java
public static BroadcastReceiver registerPebbleDisconnectedReceiver(final Context context, final BroadcastReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_PEBBLE_DISCONNECTED, receiver); }
[ "public", "static", "BroadcastReceiver", "registerPebbleDisconnectedReceiver", "(", "final", "Context", "context", ",", "final", "BroadcastReceiver", "receiver", ")", "{", "return", "registerBroadcastReceiverInternal", "(", "context", ",", "INTENT_PEBBLE_DISCONNECTED", ",", "receiver", ")", ";", "}" ]
A convenience function to assist in programatically registering a broadcast receiver for the 'DISCONNECTED' intent. Go avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param receiver The receiver to be registered. @return The registered receiver. @see Constants#INTENT_PEBBLE_DISCONNECTED
[ "A", "convenience", "function", "to", "assist", "in", "programatically", "registering", "a", "broadcast", "receiver", "for", "the", "DISCONNECTED", "intent", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L406-L409
7,482
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerReceivedDataHandler
public static BroadcastReceiver registerReceivedDataHandler(final Context context, final PebbleDataReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE, receiver); }
java
public static BroadcastReceiver registerReceivedDataHandler(final Context context, final PebbleDataReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE, receiver); }
[ "public", "static", "BroadcastReceiver", "registerReceivedDataHandler", "(", "final", "Context", "context", ",", "final", "PebbleDataReceiver", "receiver", ")", "{", "return", "registerBroadcastReceiverInternal", "(", "context", ",", "INTENT_APP_RECEIVE", ",", "receiver", ")", ";", "}" ]
A convenience function to assist in programatically registering a broadcast receiver for the 'RECEIVE' intent. To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param receiver The receiver to be registered. @return The registered receiver. @see Constants#INTENT_APP_RECEIVE
[ "A", "convenience", "function", "to", "assist", "in", "programatically", "registering", "a", "broadcast", "receiver", "for", "the", "RECEIVE", "intent", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L426-L429
7,483
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerReceivedAckHandler
public static BroadcastReceiver registerReceivedAckHandler(final Context context, final PebbleAckReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE_ACK, receiver); }
java
public static BroadcastReceiver registerReceivedAckHandler(final Context context, final PebbleAckReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE_ACK, receiver); }
[ "public", "static", "BroadcastReceiver", "registerReceivedAckHandler", "(", "final", "Context", "context", ",", "final", "PebbleAckReceiver", "receiver", ")", "{", "return", "registerBroadcastReceiverInternal", "(", "context", ",", "INTENT_APP_RECEIVE_ACK", ",", "receiver", ")", ";", "}" ]
A convenience function to assist in programatically registering a broadcast receiver for the 'RECEIVE_ACK' intent. To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param receiver The receiver to be registered. @return The registered receiver. @see Constants#INTENT_APP_RECEIVE_ACK
[ "A", "convenience", "function", "to", "assist", "in", "programatically", "registering", "a", "broadcast", "receiver", "for", "the", "RECEIVE_ACK", "intent", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L448-L451
7,484
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerReceivedNackHandler
public static BroadcastReceiver registerReceivedNackHandler(final Context context, final PebbleNackReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE_NACK, receiver); }
java
public static BroadcastReceiver registerReceivedNackHandler(final Context context, final PebbleNackReceiver receiver) { return registerBroadcastReceiverInternal(context, INTENT_APP_RECEIVE_NACK, receiver); }
[ "public", "static", "BroadcastReceiver", "registerReceivedNackHandler", "(", "final", "Context", "context", ",", "final", "PebbleNackReceiver", "receiver", ")", "{", "return", "registerBroadcastReceiverInternal", "(", "context", ",", "INTENT_APP_RECEIVE_NACK", ",", "receiver", ")", ";", "}" ]
A convenience function to assist in programatically registering a broadcast receiver for the 'RECEIVE_NACK' intent. To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param receiver The receiver to be registered. @return The registered receiver. @see Constants#INTENT_APP_RECEIVE_NACK
[ "A", "convenience", "function", "to", "assist", "in", "programatically", "registering", "a", "broadcast", "receiver", "for", "the", "RECEIVE_NACK", "intent", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L469-L472
7,485
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerBroadcastReceiverInternal
private static BroadcastReceiver registerBroadcastReceiverInternal(final Context context, final String action, final BroadcastReceiver receiver) { if (receiver == null) { return null; } IntentFilter filter = new IntentFilter(action); context.registerReceiver(receiver, filter); return receiver; }
java
private static BroadcastReceiver registerBroadcastReceiverInternal(final Context context, final String action, final BroadcastReceiver receiver) { if (receiver == null) { return null; } IntentFilter filter = new IntentFilter(action); context.registerReceiver(receiver, filter); return receiver; }
[ "private", "static", "BroadcastReceiver", "registerBroadcastReceiverInternal", "(", "final", "Context", "context", ",", "final", "String", "action", ",", "final", "BroadcastReceiver", "receiver", ")", "{", "if", "(", "receiver", "==", "null", ")", "{", "return", "null", ";", "}", "IntentFilter", "filter", "=", "new", "IntentFilter", "(", "action", ")", ";", "context", ".", "registerReceiver", "(", "receiver", ",", "filter", ")", ";", "return", "receiver", ";", "}" ]
Register broadcast receiver internal. @param context the context @param action the action @param receiver the receiver @return the broadcast receiver
[ "Register", "broadcast", "receiver", "internal", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L486-L495
7,486
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.registerDataLogReceiver
public static BroadcastReceiver registerDataLogReceiver(final Context context, final PebbleDataLogReceiver receiver) { IntentFilter filter = new IntentFilter(); filter.addAction(INTENT_DL_RECEIVE_DATA); filter.addAction(INTENT_DL_FINISH_SESSION); context.registerReceiver(receiver, filter); return receiver; }
java
public static BroadcastReceiver registerDataLogReceiver(final Context context, final PebbleDataLogReceiver receiver) { IntentFilter filter = new IntentFilter(); filter.addAction(INTENT_DL_RECEIVE_DATA); filter.addAction(INTENT_DL_FINISH_SESSION); context.registerReceiver(receiver, filter); return receiver; }
[ "public", "static", "BroadcastReceiver", "registerDataLogReceiver", "(", "final", "Context", "context", ",", "final", "PebbleDataLogReceiver", "receiver", ")", "{", "IntentFilter", "filter", "=", "new", "IntentFilter", "(", ")", ";", "filter", ".", "addAction", "(", "INTENT_DL_RECEIVE_DATA", ")", ";", "filter", ".", "addAction", "(", "INTENT_DL_FINISH_SESSION", ")", ";", "context", ".", "registerReceiver", "(", "receiver", ",", "filter", ")", ";", "return", "receiver", ";", "}" ]
A convenience function to assist in programatically registering a broadcast receiver for the 'DATA_AVAILABLE' intent. To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param receiver The receiver to be registered. @return The registered receiver. @see Constants#INTENT_DL_RECEIVE_DATA
[ "A", "convenience", "function", "to", "assist", "in", "programatically", "registering", "a", "broadcast", "receiver", "for", "the", "DATA_AVAILABLE", "intent", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L866-L874
7,487
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.requestDataLogsForApp
public static void requestDataLogsForApp(final Context context, final UUID appUuid) { final Intent requestIntent = new Intent(INTENT_DL_REQUEST_DATA); requestIntent.putExtra(APP_UUID, appUuid); context.sendBroadcast(requestIntent); }
java
public static void requestDataLogsForApp(final Context context, final UUID appUuid) { final Intent requestIntent = new Intent(INTENT_DL_REQUEST_DATA); requestIntent.putExtra(APP_UUID, appUuid); context.sendBroadcast(requestIntent); }
[ "public", "static", "void", "requestDataLogsForApp", "(", "final", "Context", "context", ",", "final", "UUID", "appUuid", ")", "{", "final", "Intent", "requestIntent", "=", "new", "Intent", "(", "INTENT_DL_REQUEST_DATA", ")", ";", "requestIntent", ".", "putExtra", "(", "APP_UUID", ",", "appUuid", ")", ";", "context", ".", "sendBroadcast", "(", "requestIntent", ")", ";", "}" ]
A convenience function to emit an intent to pebble.apk to request the data logs for a particular app. If data is available, pebble.apk will advertise the data via 'INTENT_DL_RECEIVE_DATA' intents. To avoid leaking memory, activities registering BroadcastReceivers <em>must</em> unregister them in the Activity's {@link android.app.Activity#onPause()} method. @param context The context in which to register the BroadcastReceiver. @param appUuid The app for which to request data logs. @see Constants#INTENT_DL_RECEIVE_DATA @see Constants#INTENT_DL_REQUEST_DATA
[ "A", "convenience", "function", "to", "emit", "an", "intent", "to", "pebble", ".", "apk", "to", "request", "the", "data", "logs", "for", "a", "particular", "app", ".", "If", "data", "is", "available", "pebble", ".", "apk", "will", "advertise", "the", "data", "via", "INTENT_DL_RECEIVE_DATA", "intents", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L891-L895
7,488
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java
PebbleKit.queryProvider
private static Cursor queryProvider(final Context context) { Cursor c = context.getContentResolver().query(Constants.URI_CONTENT_BASALT, null, null, null, null); if (c != null) { if (c.moveToFirst()) { // If Basalt app is connected, talk to that (return the open cursor) if (c.getInt(KIT_STATE_COLUMN_CONNECTED) == 1) { c.moveToPrevious(); return c; } } // Else close the cursor and try the primary authority c.close(); } c = context.getContentResolver().query(Constants.URI_CONTENT_PRIMARY, null, null, null, null); // Do nothing with this cursor - the calling method will check it for whatever it is looking for return c; }
java
private static Cursor queryProvider(final Context context) { Cursor c = context.getContentResolver().query(Constants.URI_CONTENT_BASALT, null, null, null, null); if (c != null) { if (c.moveToFirst()) { // If Basalt app is connected, talk to that (return the open cursor) if (c.getInt(KIT_STATE_COLUMN_CONNECTED) == 1) { c.moveToPrevious(); return c; } } // Else close the cursor and try the primary authority c.close(); } c = context.getContentResolver().query(Constants.URI_CONTENT_PRIMARY, null, null, null, null); // Do nothing with this cursor - the calling method will check it for whatever it is looking for return c; }
[ "private", "static", "Cursor", "queryProvider", "(", "final", "Context", "context", ")", "{", "Cursor", "c", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Constants", ".", "URI_CONTENT_BASALT", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "if", "(", "c", "!=", "null", ")", "{", "if", "(", "c", ".", "moveToFirst", "(", ")", ")", "{", "// If Basalt app is connected, talk to that (return the open cursor)", "if", "(", "c", ".", "getInt", "(", "KIT_STATE_COLUMN_CONNECTED", ")", "==", "1", ")", "{", "c", ".", "moveToPrevious", "(", ")", ";", "return", "c", ";", "}", "}", "// Else close the cursor and try the primary authority", "c", ".", "close", "(", ")", ";", "}", "c", "=", "context", ".", "getContentResolver", "(", ")", ".", "query", "(", "Constants", ".", "URI_CONTENT_PRIMARY", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "// Do nothing with this cursor - the calling method will check it for whatever it is looking for", "return", "c", ";", "}" ]
Query the Pebble ContentProvider - utility method for various PebbleKit helper methods This attempts first to query the Basalt app provider, then if that is non-existant or disconnected queries the primary (i.e. original) provider authority
[ "Query", "the", "Pebble", "ContentProvider", "-", "utility", "method", "for", "various", "PebbleKit", "helper", "methods" ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/PebbleKit.java#L933-L950
7,489
vinaysshenoy/mugen
sample/src/main/java/com/mugen/sample/ReposFragment.java
ReposFragment.getPerPage
private int getPerPage(Context context) { //fixed item size in recyclerview. Adding 3 enables recyclerview scrolling. return (context.getResources().getDisplayMetrics().heightPixels / context.getResources().getDimensionPixelSize(R.dimen.repo_item_height)) + 3; }
java
private int getPerPage(Context context) { //fixed item size in recyclerview. Adding 3 enables recyclerview scrolling. return (context.getResources().getDisplayMetrics().heightPixels / context.getResources().getDimensionPixelSize(R.dimen.repo_item_height)) + 3; }
[ "private", "int", "getPerPage", "(", "Context", "context", ")", "{", "//fixed item size in recyclerview. Adding 3 enables recyclerview scrolling.", "return", "(", "context", ".", "getResources", "(", ")", ".", "getDisplayMetrics", "(", ")", ".", "heightPixels", "/", "context", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "repo_item_height", ")", ")", "+", "3", ";", "}" ]
Get items to load per page onScroll. @param context {@link Context} @return int of num of items that can be loaded onto the screen with scroll enabled
[ "Get", "items", "to", "load", "per", "page", "onScroll", "." ]
2ace4312c940fed6b82d221a6a7fbd8681e91e9e
https://github.com/vinaysshenoy/mugen/blob/2ace4312c940fed6b82d221a6a7fbd8681e91e9e/sample/src/main/java/com/mugen/sample/ReposFragment.java#L93-L97
7,490
vinaysshenoy/mugen
sample/src/main/java/com/mugen/sample/GitHubClient.java
GitHubClient.getClient
public static GitHub getClient() { RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(API_URL) .setLogLevel(RestAdapter.LogLevel.BASIC) .build(); return restAdapter.create(GitHub.class); }
java
public static GitHub getClient() { RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(API_URL) .setLogLevel(RestAdapter.LogLevel.BASIC) .build(); return restAdapter.create(GitHub.class); }
[ "public", "static", "GitHub", "getClient", "(", ")", "{", "RestAdapter", "restAdapter", "=", "new", "RestAdapter", ".", "Builder", "(", ")", ".", "setEndpoint", "(", "API_URL", ")", ".", "setLogLevel", "(", "RestAdapter", ".", "LogLevel", ".", "BASIC", ")", ".", "build", "(", ")", ";", "return", "restAdapter", ".", "create", "(", "GitHub", ".", "class", ")", ";", "}" ]
Get github client. @return Github retrofit interface
[ "Get", "github", "client", "." ]
2ace4312c940fed6b82d221a6a7fbd8681e91e9e
https://github.com/vinaysshenoy/mugen/blob/2ace4312c940fed6b82d221a6a7fbd8681e91e9e/sample/src/main/java/com/mugen/sample/GitHubClient.java#L76-L83
7,491
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addBytes
public void addBytes(int key, byte[] bytes) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.BYTES, PebbleTuple.Width.NONE, bytes); addTuple(t); }
java
public void addBytes(int key, byte[] bytes) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.BYTES, PebbleTuple.Width.NONE, bytes); addTuple(t); }
[ "public", "void", "addBytes", "(", "int", "key", ",", "byte", "[", "]", "bytes", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "BYTES", ",", "PebbleTuple", ".", "Width", ".", "NONE", ",", "bytes", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified byte array with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param bytes value to be associated with the specified key
[ "Associate", "the", "specified", "byte", "array", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L78-L81
7,492
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addString
public void addString(int key, String value) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.STRING, PebbleTuple.Width.NONE, value); addTuple(t); }
java
public void addString(int key, String value) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.STRING, PebbleTuple.Width.NONE, value); addTuple(t); }
[ "public", "void", "addString", "(", "int", "key", ",", "String", "value", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "STRING", ",", "PebbleTuple", ".", "Width", ".", "NONE", ",", "value", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified String with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param value value to be associated with the specified key
[ "Associate", "the", "specified", "String", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L92-L96
7,493
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addInt8
public void addInt8(final int key, final byte b) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.BYTE, b); addTuple(t); }
java
public void addInt8(final int key, final byte b) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.BYTE, b); addTuple(t); }
[ "public", "void", "addInt8", "(", "final", "int", "key", ",", "final", "byte", "b", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "INT", ",", "PebbleTuple", ".", "Width", ".", "BYTE", ",", "b", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified signed byte with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param b value to be associated with the specified key
[ "Associate", "the", "specified", "signed", "byte", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L107-L110
7,494
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addUint8
public void addUint8(final int key, final byte b) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.UINT, PebbleTuple.Width.BYTE, b); addTuple(t); }
java
public void addUint8(final int key, final byte b) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.UINT, PebbleTuple.Width.BYTE, b); addTuple(t); }
[ "public", "void", "addUint8", "(", "final", "int", "key", ",", "final", "byte", "b", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "UINT", ",", "PebbleTuple", ".", "Width", ".", "BYTE", ",", "b", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified unsigned byte with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param b value to be associated with the specified key
[ "Associate", "the", "specified", "unsigned", "byte", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L121-L124
7,495
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addInt16
public void addInt16(final int key, final short s) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.SHORT, s); addTuple(t); }
java
public void addInt16(final int key, final short s) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.SHORT, s); addTuple(t); }
[ "public", "void", "addInt16", "(", "final", "int", "key", ",", "final", "short", "s", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "INT", ",", "PebbleTuple", ".", "Width", ".", "SHORT", ",", "s", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified signed short with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param s value to be associated with the specified key
[ "Associate", "the", "specified", "signed", "short", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L135-L138
7,496
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addUint16
public void addUint16(final int key, final short s) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.UINT, PebbleTuple.Width.SHORT, s); addTuple(t); }
java
public void addUint16(final int key, final short s) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.UINT, PebbleTuple.Width.SHORT, s); addTuple(t); }
[ "public", "void", "addUint16", "(", "final", "int", "key", ",", "final", "short", "s", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "UINT", ",", "PebbleTuple", ".", "Width", ".", "SHORT", ",", "s", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified unsigned short with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param s value to be associated with the specified key
[ "Associate", "the", "specified", "unsigned", "short", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L149-L152
7,497
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addInt32
public void addInt32(final int key, final int i) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.WORD, i); addTuple(t); }
java
public void addInt32(final int key, final int i) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.WORD, i); addTuple(t); }
[ "public", "void", "addInt32", "(", "final", "int", "key", ",", "final", "int", "i", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "INT", ",", "PebbleTuple", ".", "Width", ".", "WORD", ",", "i", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified signed int with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param i value to be associated with the specified key
[ "Associate", "the", "specified", "signed", "int", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L163-L166
7,498
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.addUint32
public void addUint32(final int key, final int i) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.UINT, PebbleTuple.Width.WORD, i); addTuple(t); }
java
public void addUint32(final int key, final int i) { PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.UINT, PebbleTuple.Width.WORD, i); addTuple(t); }
[ "public", "void", "addUint32", "(", "final", "int", "key", ",", "final", "int", "i", ")", "{", "PebbleTuple", "t", "=", "PebbleTuple", ".", "create", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "UINT", ",", "PebbleTuple", ".", "Width", ".", "WORD", ",", "i", ")", ";", "addTuple", "(", "t", ")", ";", "}" ]
Associate the specified unsigned int with the provided key in the dictionary. If another key-value pair with the same key is already present in the dictionary, it will be replaced. @param key key with which the specified value is associated @param i value to be associated with the specified key
[ "Associate", "the", "specified", "unsigned", "int", "with", "the", "provided", "key", "in", "the", "dictionary", ".", "If", "another", "key", "-", "value", "pair", "with", "the", "same", "key", "is", "already", "present", "in", "the", "dictionary", "it", "will", "be", "replaced", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L177-L180
7,499
pebble/pebble-android-sdk
PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java
PebbleDictionary.getInteger
public Long getInteger(int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.INT); if (tuple == null) { return null; } return (Long) tuple.value; }
java
public Long getInteger(int key) { PebbleTuple tuple = getTuple(key, PebbleTuple.TupleType.INT); if (tuple == null) { return null; } return (Long) tuple.value; }
[ "public", "Long", "getInteger", "(", "int", "key", ")", "{", "PebbleTuple", "tuple", "=", "getTuple", "(", "key", ",", "PebbleTuple", ".", "TupleType", ".", "INT", ")", ";", "if", "(", "tuple", "==", "null", ")", "{", "return", "null", ";", "}", "return", "(", "Long", ")", "tuple", ".", "value", ";", "}" ]
Returns the signed integer to which the specified key is mapped, or null if the key does not exist in this dictionary. @param key key whose associated value is to be returned @return value to which the specified key is mapped
[ "Returns", "the", "signed", "integer", "to", "which", "the", "specified", "key", "is", "mapped", "or", "null", "if", "the", "key", "does", "not", "exist", "in", "this", "dictionary", "." ]
ddfc53ecf3950deebb62a1f205aa21fbe9bce45d
https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L203-L209