private String computeHash(String line) { String reducedLine = StringUtils.replaceChars(line, "\t ", ""); if (reducedLine.isEmpty()) { return ""; } return Hex.encodeHexString(md5Digest.digest(reducedLine.getBytes(UTF_8))); } }
private static String computeUniqueInstanceId(Configuration config) { final String suffix = getSuffix(config); final String uid = getUid(config); String instanceId = uid + suffix; for (char c : ConfigElement.ILLEGAL_CHARS) { instanceId = StringUtils.replaceChars(instanceId,c,'-'); } return instanceId; }
public String getHdfsWorkingDirectory() { if (cachedHdfsWorkingDirectory != null) return cachedHdfsWorkingDirectory; String root = getOptional("kylin.env.hdfs-working-dir", "/kylin"); Path path = new Path(root); if (!path.isAbsolute()) throw new IllegalArgumentException("kylin.env.hdfs-working-dir must be absolute, but got " + root); try { FileSystem fs = path.getFileSystem(HadoopUtil.getCurrentConfiguration()); path = fs.makeQualified(path); } catch (IOException e) { throw new RuntimeException(e); } // append metadata-url prefix root = new Path(path, StringUtils.replaceChars(getMetadataUrlPrefix(), ':', '-')).toString(); if (!root.endsWith("/")) root += "/"; cachedHdfsWorkingDirectory = root; if (cachedHdfsWorkingDirectory.startsWith(FILE_SCHEME)) { cachedHdfsWorkingDirectory = cachedHdfsWorkingDirectory.replace(FILE_SCHEME, "file://"); } else if (cachedHdfsWorkingDirectory.startsWith(MAPRFS_SCHEME)) { cachedHdfsWorkingDirectory = cachedHdfsWorkingDirectory.replace(MAPRFS_SCHEME, "maprfs://"); } return cachedHdfsWorkingDirectory; }
private static String computeUniqueInstanceId(Configuration config) { final String suffix; if (config.has(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX)) { suffix = LongEncoding.encode(config.get( GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX)); } else { suffix = ManagementFactory.getRuntimeMXBean().getName() + LongEncoding.encode(INSTANCE_COUNTER.incrementAndGet()); } byte[] addrBytes; try { addrBytes = Inet4Address.getLocalHost().getAddress(); } catch (UnknownHostException e) { throw new TitanConfigurationException("Cannot determine local host", e); } String uid = new String(Hex.encodeHex(addrBytes)) + suffix; for (char c : ConfigElement.ILLEGAL_CHARS) { uid = StringUtils.replaceChars(uid,c,'-'); } return uid; }
public static CoreDbTester createForSchema(Class testClass, String filename) { String path = StringUtils.replaceChars(testClass.getCanonicalName(), '.', '/'); String schemaPath = path + "/" + filename; return new CoreDbTester(schemaPath); }
public static CoreDbTester createEmpty() { String path = StringUtils.replaceChars(CoreDbTester.class.getCanonicalName(), '.', '/'); String schemaPath = path + "/empty.sql"; return new CoreDbTester(schemaPath); }
public String getMetastoreBigCellHdfsDirectory() { if (cachedBigCellDirectory != null) return cachedBigCellDirectory; String root = getOptional("kylin.env.hdfs-metastore-bigcell-dir"); if (root == null) { return getJdbcHdfsWorkingDirectory(); } Path path = new Path(root); if (!path.isAbsolute()) throw new IllegalArgumentException( "kylin.env.hdfs-metastore-bigcell-dir must be absolute, but got " + root); // make sure path is qualified try { FileSystem fs = HadoopUtil.getReadFileSystem(); path = fs.makeQualified(path); } catch (IOException e) { throw new RuntimeException(e); } root = new Path(path, StringUtils.replaceChars(getMetadataUrlPrefix(), ':', '-')).toString(); if (!root.endsWith("/")) root += "/"; cachedBigCellDirectory = root; if (cachedBigCellDirectory.startsWith(FILE_SCHEME)) { cachedBigCellDirectory = cachedBigCellDirectory.replace(FILE_SCHEME, "file://"); } else if (cachedBigCellDirectory.startsWith(MAPRFS_SCHEME)) { cachedBigCellDirectory = cachedBigCellDirectory.replace(MAPRFS_SCHEME, "maprfs://"); } return cachedBigCellDirectory; }
/** * Search for a resource in the classpath. For example calling the method getResource(getClass(), "myTestName/foo.txt") from * the class org.sonar.Foo loads the file $basedir/src/test/resources/org/sonar/Foo/myTestName/foo.txt * * @return the resource. Null if resource not found */ public static File getResource(Class baseClass, String path) { String resourcePath = StringUtils.replaceChars(baseClass.getCanonicalName(), '.', '/'); if (!path.startsWith("/")) { resourcePath += "/"; } resourcePath += path; return getResource(resourcePath); }
public static DbTester createForSchema(System2 system2, Class testClass, String filename) { String path = StringUtils.replaceChars(testClass.getCanonicalName(), '.', '/'); String schemaPath = path + "/" + filename; return new DbTester(system2, schemaPath).setDisableDefaultOrganization(true); }
private String computeHash(String line) { String reducedLine = StringUtils.replaceChars(line, "\t ", ""); if (reducedLine.isEmpty()) { return ""; } return Hex.encodeHexString(md5Digest.digest(reducedLine.getBytes(UTF_8))); } }
protected static String getPath(File file) { String path = file.getPath(); path = StringUtils.replaceChars(path, "\\", "/"); path = path.startsWith("/") ? path.substring(1, path.length()) : path; path = path.endsWith("/") ? path.substring(0, path.length() - 1) : path; return path; }
static String checkOtherLetters(String letter) { letter = StringUtils.replaceChars(letter, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"); if (letter.equals("_") || letter.equals("$") || StringUtils.isAlphanumeric(letter)){ return letter; } else { return "_"; } } }
/** * This is a poor man's way of "copying" the view HTML, so we can paste it in to the editor. * @return the HTML for the page's content */ private String copyViewHtmlContent() { String content; content = client.getEval("$('.wiki-content').html()"); content = StringUtils.replaceChars(content, "\t\n\r", "").trim(); return content; } }
static String checkFirstLetter(String letter) { letter = StringUtils.replaceChars(letter, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"); if (letter.equals("_") || letter.equals("$") || StringUtils.isAlpha(letter)){ return letter; } else if (StringUtils.isNumeric(letter)) { return "_"+letter; } else { return "_"; } }
public String asLinuxSystemPropertyKey(String javaProperty) { return StringUtils.upperCase(StringUtils.replaceChars(javaProperty, ".", "_")); } }
static String checkFirstLetter(String letter) { letter = StringUtils.replaceChars(letter, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"); if (letter.equals("_") || letter.equals("$") || StringUtils.isAlpha(letter)){ return letter; } else if (StringUtils.isNumeric(letter)) { return "_"+letter; } else { return "_"; } }
public String toString() { return new ToStringBuilder(this) .append(StringUtils.abbreviate(StringUtils.replaceChars(getBody(),"\r\n", ""), 50)) .toString(); } }
public DefaultCharacteristic setName(String s, boolean asKey) { this.name = StringUtils.trimToNull(s); if (asKey) { this.key = StringUtils.upperCase(this.name); this.key = StringUtils.replaceChars(this.key, ' ', '_'); } return this; }
/** * Returns the current content specified by the selector from the Editor as HTML. */ public String getContent(String selector, boolean removeNewLines) { String result = getExpressionValue("$('" + GeneralUtil.escapeForJavascript(selector) + "',doc).html()"); if(removeNewLines) result = StringUtils.replaceChars(result, "\n\r", ""); return result; }
public void testHeadingCopy() { editor.setHtmlContent("<h1>Heading 1</h1><p>Para 1</p><p>Para 2</p>"); tinyMce.putCursorAtStartOfFirstElementWithSelector("p"); tinyMce.pasteContent("<h1>Heading 2</h1><p>Para 3</p>"); String content = tinyMce.getContent(); content = StringUtils.replaceChars(content, "\t\n\r", ""); assertEquals("<h1>Heading 1</h1><h1>Heading 2</h1><p>Para 3</p><p>Para 1</p><p>Para 2</p>", content); } }