List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.vmware.thinapp.common.util.AfUtil.java
/** * Convert into lowercase with uppercase initial. * * @param string Word like "hello"./*from w w w .jav a2 s. co m*/ * @return Word like "Hello" */ public static String toInitialCase(String string) { if (string.isEmpty()) { return string; } StringBuffer lower = new StringBuffer(string.toLowerCase()); lower.setCharAt(0, Character.toUpperCase(lower.charAt(0))); return lower.toString(); }
From source file:Currently.java
/** * Parses one of the ISO 8601 that it produces. Note, it will not * parse the full range of ISO timestamps. * * @param stamp is the textual timestamp representation. * @return a time or <code>null</code>, if unparsable. *//*from w w w .j ava 2s.c om*/ public static Date parse(String stamp) { // initialize the compiled expressions once if (c_pattern == null) { c_pattern = new Pattern[c_expression.length]; for (int i = 0; i < c_expression.length; ++i) { c_pattern[i] = Pattern.compile(c_expression[i]); } } // match against pattern for (int i = 0; i < c_expression.length; ++i) { Matcher m = c_pattern[i].matcher(stamp); if (m.matches()) { Calendar c = Calendar.getInstance(); TimeZone z = TimeZone.getDefault(); if (m.group(9) != null && m.group(9).length() > 0) { boolean utc = (Character.toUpperCase(m.group(9).charAt(0)) == 'Z'); if (utc) { z = TimeZone.getTimeZone("GMT+0"); } else { z = TimeZone.getTimeZone("GMT" + m.group(9)); } } c.setTimeZone(z); c.set(Calendar.YEAR, Integer.parseInt(m.group(1))); c.set(Calendar.MONTH, Integer.parseInt(m.group(2)) + (Calendar.JANUARY - 1)); c.set(Calendar.DAY_OF_MONTH, Integer.parseInt(m.group(3))); if (m.group(4).length() > 0) { c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(m.group(5))); c.set(Calendar.MINUTE, Integer.parseInt(m.group(6))); if (m.group(7) != null && m.group(7).length() > 0) { c.set(Calendar.SECOND, Integer.parseInt(m.group(7))); } if (m.group(8) != null && m.group(8).length() > 1) { String millis = m.group(8).substring(1); while (millis.length() < 3) { millis += "0"; } millis = millis.substring(0, 3); c.set(Calendar.MILLISECOND, Integer.parseInt(millis)); } } return c.getTime(); } } // not found return null; }
From source file:com.github.kumaraman21.intellijbehave.parser.ScenarioStep.java
public String getAnnotatedStoryLine() { StepType stepType = getStepType();/*from www .j a va 2s .c om*/ String lowerCase = stepType.toString().toLowerCase(); JBehaveStepLine storyStepLine = getStoryStepLine(); if (storyStepLine != null) { lowerCase = Character.toUpperCase(lowerCase.charAt(0)) + lowerCase.substring(1); final String format = hasStoryStepPostParameters() ? "%s %s $" : "%s %s"; return String.format(format, lowerCase, storyStepLine.getText()); } return lowerCase; }
From source file:com.edgenius.wiki.render.handler.PageIndexHandler.java
public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) throws RenderHandlerException { if (indexer == null) { log.warn("Unable to find valid page for index"); throw new RenderHandlerException("Unable to find valid page for index"); }//from w w w . j ava 2 s.c om List<String> filters = getFilterList(values != null ? StringUtils.trimToNull(values.get("filter")) : null); List<String> filtersOut = getFilterList( values != null ? StringUtils.trimToNull(values.get("filterout")) : null); //temporary cache for indexer after filter out TreeMap<Character, Integer> indexerFiltered = new TreeMap<Character, Integer>(); List<RenderPiece> listPieces = new ArrayList<RenderPiece>(); //render each character list Character indexKey = null; boolean requireEndOfMacroPageIndexList = false; for (Entry<String, LinkModel> entry : indexMap.entrySet()) { String title = entry.getKey(); if (filters.size() > 0) { boolean out = false; for (String filter : filters) { if (!FilenameUtils.wildcardMatch(title.toLowerCase(), filter.toLowerCase())) { out = true; break; } } if (out) continue; } if (filtersOut.size() > 0) { boolean out = false; for (String filterOut : filtersOut) { if (FilenameUtils.wildcardMatch(title.toLowerCase(), filterOut.toLowerCase())) { out = true; break; } } if (out) continue; } Character first = Character.toUpperCase(title.charAt(0)); if (!first.equals(indexKey)) { if (requireEndOfMacroPageIndexList) { listPieces.add(new TextModel("</div>")); //macroPageIndexList } Integer anchorIdx = indexer.get(first); indexKey = first; if (anchorIdx != null) { indexerFiltered.put(first, anchorIdx); listPieces.add(new TextModel(new StringBuilder().append( "<div class=\"macroPageIndexList\"><div class=\"macroPageIndexKey\" id=\"pageindexanchor-") .append(anchorIdx).append("\">").append(first).toString())); requireEndOfMacroPageIndexList = true; //up image line to return top if (RenderContext.RENDER_TARGET_PAGE.equals(renderContext.getRenderTarget())) { LinkModel back = new LinkModel(); back.setAnchor("pageindexanchor-0"); back.setAid("Go back index character list"); back.setView(renderContext.buildSkinImageTag("render/link/up.png", NameConstants.AID, SharedConstants.NO_RENDER_TAG)); listPieces.add(back); } listPieces.add(new TextModel("</div>"));//macroPageIndexKey } else { log.error("Unable to page indexer for {}", indexKey); } } listPieces.add(new TextModel("<div class=\"macroPageIndexLink\">")); LinkModel link = entry.getValue(); link.setLinkTagStr(renderContext.buildURL(link)); listPieces.add(link); listPieces.add(new TextModel("</div>"));//macroPageIndexLink } if (requireEndOfMacroPageIndexList) { listPieces.add(new TextModel("</div>")); //macroPageIndexList } //render sum of characters - although it display before page list, however, as filter may hide some characters, so display later than //other List<RenderPiece> pieces = new ArrayList<RenderPiece>(); StringBuffer sbuf = new StringBuffer("<div aid=\"pageindex\" class=\"macroPageIndex ") .append(WikiConstants.mceNonEditable).append("\""); if (values != null && values.size() > 0) { sbuf.append(" wajax=\"") .append(RichTagUtil.buildWajaxAttributeString(this.getClass().getName(), values)).append("\" "); } sbuf.append("><div id=\"pageindexanchor-0\" class=\"macroPageIndexKeys\">"); pieces.add(new TextModel(sbuf.toString())); for (Entry<Character, Integer> entry : indexerFiltered.entrySet()) { LinkModel anchor = new LinkModel(); anchor.setView(entry.getKey().toString()); anchor.setAnchor("pageindexanchor-" + entry.getValue()); anchor.setLinkTagStr(renderContext.buildURL(anchor)); pieces.add(anchor); } pieces.add(new TextModel("</div>")); //macroPageIndexKeys pieces.addAll(listPieces); pieces.add(new TextModel("</div>")); //macroPageIndex return pieces; }
From source file:io.github.jeddict.jcode.util.StringHelper.java
/** * * @param input/*ww w . j a v a 2s. c o m*/ * @return * @example * * BankAccount => Bank Account Bank_Account => Bank_Account */ public static String toNatural(String input) { String natural = EMPTY; Character lastChar = null; for (Character curChar : input.toCharArray()) { if (lastChar == null) { // First character lastChar = Character.toUpperCase(curChar); natural = natural + lastChar; } else { if (Character.isLowerCase(lastChar) && (Character.isUpperCase(curChar)) || Character.isDigit(curChar)) { natural = natural + " " + curChar; } else { natural = natural + curChar; } lastChar = curChar; } } return natural; }
From source file:com.sun.faces.generate.AbstractGenerator.java
/** * <p>Return the capitalized version of the specified property name.</p> * * @param name Uncapitalized property name *///from w w w . j a v a 2s. c om protected static String capitalize(String name) { return (Character.toUpperCase(name.charAt(0)) + name.substring(1)); }
From source file:com.mifos.mifosxdroid.formwidgets.FormWidget.java
/** * takes a property name and modifies//from w w w. ja v a 2s . c o m * * @param s * @return */ public String toTitleCase(String s) { char[] chars = s.trim().toLowerCase().toCharArray(); boolean found = false; for (int i = 0; i < chars.length; i++) { if (!found && Character.isLetter(chars[i])) { chars[i] = Character.toUpperCase(chars[i]); found = true; } else if (Character.isWhitespace(chars[i])) { found = false; } } return String.valueOf(chars); }
From source file:net.solarnetwork.node.runtime.JobSettingSpecifierProvider.java
/** * Construct a display title based on a setting UID. * /*from w w w . j a v a 2 s. co m*/ * <p> * The display title is generated from the setting UID itself, by first * removing the {@link #SN_NODE_PREFIX} prefix and {@link #JOBS_PID_SUFFIX} * suffix, capitalizing the remaining value, and appending * {@link #TITLE_SUFFIX}. For example, the UID * <code>net.solarnetwork.node.power.JOBS</code> will result in * <code>Power Jobs</code>. * </p> * * * @param settingUID * the setting UID value * @return the generated title value */ private static String titleValue(String settingUID) { if (settingUID.startsWith(SN_NODE_PREFIX) && settingUID.length() > SN_NODE_PREFIX.length()) { String subPackage = settingUID.substring(SN_NODE_PREFIX.length()); if (subPackage.endsWith(JOBS_PID_SUFFIX) && subPackage.length() > JOBS_PID_SUFFIX.length()) { subPackage = subPackage.substring(0, subPackage.length() - JOBS_PID_SUFFIX.length()); } if (subPackage.indexOf('.') < 0) { // capitalize first letter subPackage = Character.toUpperCase(subPackage.charAt(0)) + subPackage.substring(1) + TITLE_SUFFIX; return subPackage; } return subPackage; } return settingUID; }
From source file:modmanager.backend.ModificationOption.java
/** * Renames folders to be compatible to unix file systems *//*from w w w . j a v a 2s .c o m*/ private void makeUnixCompatible(File path) { logger.log(Level.FINER, "Making modification compatible to UNIX filesystems (Mac, Linux, ...)"); /** * Check if the data folder is named wrong */ if (FileUtils.getFile(path, "data").exists()) { FileUtils.getFile(path, "data").renameTo(FileUtils.getFile(path, "Data")); /** * Go to data directory */ path = FileUtils.getFile(path, "Data"); logger.log(Level.FINEST, "unix: Renamed data to Data"); } else if (FileUtils.getFile(directory, "Data").exists()) { /** * Go to data directory */ path = FileUtils.getFile(path, "Data"); } /** * All top folders should be renamed to uppercase letter first */ for (File dir : path.listFiles()) { if (dir.isDirectory()) { if (Character.isLowerCase(dir.getName().charAt(0))) { /** * Silently assuming that a folder has more than one letter */ String new_name = Character.toUpperCase(dir.getName().charAt(0)) + dir.getName().substring(1); dir.renameTo(FileUtils.getFile(dir.getParentFile(), new_name)); logger.log(Level.FINEST, "unix: Renamed {0} to {1}", new Object[] { dir.getAbsolutePath(), new_name }); } } } }