List of usage examples for java.lang String subSequence
public CharSequence subSequence(int beginIndex, int endIndex)
From source file:org.gradle.util.GUtil.java
public static String toLowerCamelCase(CharSequence string) { String camelCase = toCamelCase(string); if (camelCase == null) { return null; }//ww w. j a va 2s . c o m if (camelCase.length() == 0) { return ""; } return ((Character) camelCase.charAt(0)).toString().toLowerCase() + camelCase.subSequence(1, camelCase.length()); }
From source file:Main.java
/** * Devuelve el fully qualified name de un Group a partir * del path de una pagina (preferentemente el absoluto) *//*from w w w . jav a2 s.c om*/ public static String getImportGroup(String path) { File arch = new File(path); path = arch.getParent(); String packAux = ""; String CADENA_CORTE = "\\"; String CADENA_CORTE2 = "/"; String SOURCE = "src"; String USE_CASES = "useCases"; String PAGES = "pages"; try { packAux = path.substring((path.indexOf(CADENA_CORTE))); } catch (StringIndexOutOfBoundsException e) { packAux = path.substring((path.indexOf(CADENA_CORTE2))); } packAux = packAux.replace("/", "."); packAux = packAux.replace("\\", "."); if (packAux.endsWith(".")) { packAux = (String) packAux.subSequence(0, packAux.lastIndexOf(".")); } packAux = packAux.substring(CADENA_CORTE.length()); String packageF = packAux; String groupImport = packageF.substring(packageF.lastIndexOf(SOURCE)); groupImport = groupImport.replace(SOURCE + ".", ""); groupImport = groupImport.replace(PAGES, ""); String caseName = groupImport.substring(groupImport.lastIndexOf(USE_CASES)); caseName = caseName.replace(".", ""); caseName = caseName.replace(USE_CASES, ""); caseName = capitalize(caseName); return groupImport + caseName + "Group"; }
From source file:org.archive.crawler.util.BdbUriUniqFilter.java
protected static long calcSchemeAuthorityKeyBytes(String url) { int index = url.indexOf(COLON_SLASH_SLASH); if (index > 0) { index = url.indexOf('/', index + COLON_SLASH_SLASH.length()); }//www. j av a 2 s. c o m CharSequence schemeAuthority = (index == -1) ? url : url.subSequence(0, index); return FPGenerator.std24.fp(schemeAuthority); }
From source file:de.micromata.genome.gwiki.page.search.expr.SearchUtils.java
private static String enrichFoundWord(String text, String w) { StringBuilder sb = new StringBuilder(); int i;//w w w. ja v a 2 s . c o m for (i = 0; i < text.length(); ++i) { if (StringUtils.startsWithIgnoreCase(text.substring(i), w) == true) { String bt = text.substring(i, i + w.length()); sb.append(text.subSequence(0, i)); if (text.length() > i + w.length()) { text = text.substring(i + w.length()); } else { text = ""; } i = 0; sb.append("<b><strong><big>").append(bt).append("</big></strong></b>"); } } sb.append(text); return sb.toString(); }
From source file:org.apache.airavata.common.utils.StringUtil.java
private static boolean isQuoted(String s, String delimiter) { //Check if we need quotes if (s.contains(delimiter)) { //Check if its already quoted s = s.replaceAll("\"\"", ""); return (s.substring(0, 1).equals(QUOTE) && s.subSequence(s.length() - 1, s.length()).equals(QUOTE)); }//from w ww .j a va2 s.c o m //no delimiters present, so already in proper form return true; }
From source file:org.openmrs.module.webservices.docs.ResourceDocCreator.java
/** * Fills a map of resource names and their documentation objects with resource operations. * // ww w. ja va 2 s . c o m * @param resouceDocMap a map of each resource name and its corresponding documentation object. */ private static void fillOperations(Map<String, ResourceDoc> resouceDocMap) throws IOException { File directory = new File( new File("").getAbsolutePath() + "/src/main/java/org/openmrs/module/webservices/rest/web/resource"); //Look for all resource files in the resource folder. String[] files = directory.list(); if (files == null) return; for (int i = 0; i < files.length; i++) { String file = files[i]; //We are only interested in ......Resource.java files if (file.endsWith("Resource.java")) { //Resource name is class name without the .java extension String name = file.subSequence(0, file.length() - "Resource.java".length()).toString(); ResourceDoc resourceDoc = resouceDocMap.get(name); //Get the complete path and name of the java source file. String fullPathName = directory.getAbsolutePath() + File.separator + file; String source = OpenmrsUtil.getFileAsString(new File(fullPathName)); //Parse the file's JavaDoc annotations to get the supported web service operations. resourceDoc.setOperations(JavadocParser.parse(source)); } } }
From source file:com.qubit.terra.docs.util.helpers.OpenofficeInProcessConverter.java
public static synchronized byte[] convert(final byte[] odtContent, final String tempDirFullPath, final String mimeTypeAbbreviation) { try {//from w ww .ja v a 2 s .c om long currentTimeMillis = System.currentTimeMillis(); if (System.getProperty("os.name").startsWith("Windows")) { final String odtFilename = tempDirFullPath + "openofficeConversion-" + currentTimeMillis + ".odt"; FileUtils.writeByteArrayToFile(new File(odtFilename), odtContent); final Process process = Runtime.getRuntime() .exec(String.format("soffice --headless --convert-to %s --outdir %s %s", mimeTypeAbbreviation, tempDirFullPath.subSequence(0, tempDirFullPath.length() - 1), odtFilename)); try { process.waitFor(); } catch (InterruptedException e) { } process.destroy(); final String outputFilename = tempDirFullPath + "openofficeConversion-" + currentTimeMillis + "." + mimeTypeAbbreviation; final byte[] output = FileUtils.readFileToByteArray(new File(outputFilename)); FileUtils.deleteQuietly(new File(odtFilename)); FileUtils.deleteQuietly(new File(outputFilename)); return output; } else { final String odtFilename = tempDirFullPath + "/openofficeConversion-" + currentTimeMillis + ".odt"; FileUtils.writeByteArrayToFile(new File(odtFilename), odtContent); final Process process = Runtime.getRuntime() .exec(String.format( "soffice --headless --convert-to %s -env:UserInstallation=file://%s --outdir %s %s", mimeTypeAbbreviation, tempDirFullPath, tempDirFullPath, odtFilename)); try { process.waitFor(); } catch (InterruptedException e) { } process.destroy(); final String outputFilename = tempDirFullPath + "/openofficeConversion-" + currentTimeMillis + "." + mimeTypeAbbreviation; final byte[] output = FileUtils.readFileToByteArray(new File(outputFilename)); FileUtils.deleteQuietly(new File(odtFilename)); FileUtils.deleteQuietly(new File(outputFilename)); return output; } } catch (final Throwable e) { throw new OpenofficeInProcessConversionException(e); } }
From source file:cascading.util.Util.java
/** * This method truncates the given String value to the given size, but appends an ellipse ("...") if the * String is larger than maxSize./*from www .j a v a2s .c om*/ * * @param string * @param maxSize * @return a String */ public static String truncate(String string, int maxSize) { string = toNull(string); if (string.length() <= maxSize) return string; return String.format("%s...", string.subSequence(0, maxSize - 3)); }
From source file:gridool.util.GridUtils.java
public static String alterFileName(String fileName, GridNode node) { final String addr = node.getPhysicalAdress().getHostAddress(); final int lastIdx = fileName.length() - 1; final int dotpos = fileName.lastIndexOf('.'); if (dotpos > 0 && dotpos < lastIdx) { final StringBuilder buf = new StringBuilder(64); buf.append(fileName.subSequence(0, dotpos)); buf.append('_'); buf.append(addr);/*from w w w . j ava2s . c o m*/ buf.append(fileName.substring(dotpos)); return buf.toString(); } else { return fileName + '_' + addr; } }
From source file:org.tsm.concharto.util.TimeRangeFormat.java
/** * @see TimeRangeFormat#adjustADBC/* w w w . ja v a 2 s . c o m*/ * * @param era 'AD' or 'BC' * @param text text to convert * @return converted text if necessary */ private static String padEra(String era, String text) { //get the character just before the ERA text (e.g. AD or BC) String before = StringUtils.substringBefore(text, era); if (' ' != before.charAt(before.length() - 1)) { //ok we need to insert a space right here text = before + " " + text.subSequence(before.length(), text.length()); } return text; }