List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:com.alkacon.opencms.geomap.CmsGoogleMapWidget.java
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */// w w w . ja v a 2s . c om public String getDialogWidget(final CmsObject cms, final I_CmsWidgetDialog widgetDialog, final I_CmsWidgetParameter param) { final String id = param.getId(); final CmsGoogleMapWidgetValue value = new CmsGoogleMapWidgetValue(param.getStringValue(cms)); final CmsXmlMessages templates = new CmsXmlMessages(cms, CmsGoogleMapWidget.TEMPLATE_FILE); // create macro resolver with macros for form field value replacement final CmsMacroResolver resolver = new CmsXmlMessages(cms, CmsGoogleMapWidget.MESSAGES_FILE) .getMacroResolver(); // set cms object and localized messages in resolver resolver.setCmsObject(cms); resolver.addMacro("id", id); resolver.addMacro("value", value.toString()); resolver.addMacro("options", getWidgetOption().getEditString()); resolver.addMacro("button", resolver.resolveMacros(templates.key("Button"))); resolver.addMacro("node", param.getName()); resolver.addMacro("width", "" + value.getWidth()); resolver.addMacro("height", "" + value.getHeight()); final StringBuffer sbInline = new StringBuffer(); final Iterator<CmsGoogleMapOption> itInline = getWidgetOption().getInline().iterator(); while (itInline.hasNext()) { final CmsGoogleMapOption prop = itInline.next(); final StringBuffer xpath = new StringBuffer(prop.toString()); xpath.setCharAt(0, Character.toUpperCase(xpath.charAt(0))); sbInline.append(resolver.resolveMacros(templates.key(xpath.toString()))); } resolver.addMacro("inline.properties", sbInline.toString()); final StringBuffer sbPopup = new StringBuffer(); final Iterator<CmsGoogleMapOption> itPopup = getWidgetOption().getPopup().iterator(); while (itPopup.hasNext()) { final CmsGoogleMapOption prop = itPopup.next(); final StringBuffer xpath = new StringBuffer(prop.toString()); xpath.setCharAt(0, Character.toUpperCase(xpath.charAt(0))); sbPopup.append(resolver.resolveMacros(templates.key(xpath.toString()))); } resolver.addMacro("popup.properties", sbPopup.toString()); final StringBuffer result = new StringBuffer(4096); result.append("<td class=\"xmlTd\">"); result.append(resolver.resolveMacros(templates.key("Main"))); result.append("</td>"); return result.toString(); }
From source file:ISMAGS.CommandLineInterface.java
public static Motif getMotif(String motifspec, HashMap<Character, LinkType> typeTranslation) { int l = motifspec.length(); int nrNodes = (int) Math.ceil(Math.sqrt(2 * l)); int l2 = nrNodes * (nrNodes - 1) / 2; if (l != l2) { Die("Error: motif \"" + motifspec + "\" has invalid length"); }// w w w .j a v a2 s . co m int counter = 0; Motif m = new Motif(nrNodes); for (int i = 1; i < nrNodes; i++) { for (int j = 0; j < i; j++) { // System.out.println("("+(1+i)+","+(1+j)+")"); char c = motifspec.charAt(counter); counter++; if (c == '0') { continue; } LinkType lt = typeTranslation.get(Character.toUpperCase(c)); if (Character.isUpperCase(c)) { m.addMotifLink(j, i, lt); } else { m.addMotifLink(i, j, lt); } } } m.finaliseMotif(); return m; }
From source file:com.yahoo.sql4d.sql4ddriver.Util.java
public static String capitalize(String word) { StringBuilder buff = new StringBuilder(word); if (word.charAt(0) != '_') { buff.setCharAt(0, Character.toUpperCase(word.charAt(0))); }/*from ww w.ja v a 2 s . c o m*/ for (int i = 1; i < buff.length(); i++) { if (buff.charAt(i - 1) == '_') { buff.setCharAt(i, Character.toUpperCase(word.charAt(i))); } } return buff.toString().replace("_", ""); }
From source file:org.neo4j.ontology.server.unmanaged.AnnotationResource.java
private String capitalize(final String string) { return Character.toUpperCase(string.charAt(0)) + string.substring(1); }
From source file:com.manydesigns.elements.util.Util.java
public static int compare(String one, String two) { if (one == null && two == null) { return 0; }//from w ww.j a va 2 s.co m if (two == null) return -1; if (one == null) return 1; int lenone = one.length(); int lentwo = two.length(); StringBuilder numberOne = new StringBuilder(); StringBuilder numberTwo = new StringBuilder(); int i = 0, j = 0; for (; i < lenone && j < lentwo; i++, j++) { if (Character.isDigit(one.charAt(i))) { if (Character.isDigit(two.charAt(j))) { numberOne.setLength(0); numberTwo.setLength(0); while ((i < lenone) && Character.isDigit(one.charAt(i))) { numberOne.append(one.charAt(i)); i++; } while ((j < lentwo) && Character.isDigit(two.charAt(j))) { numberTwo.append(two.charAt(j)); j++; } long diff = Long.parseLong(numberOne.toString()) - Long.parseLong(numberTwo.toString()); if (diff > 0) { return 1; } else if (diff < 0) { return -1; } } else { return -1; } } else if (Character.isDigit(two.charAt(j))) { return 1; } else { int diff = Character.toUpperCase(one.charAt(i)) - Character.toUpperCase(two.charAt(j)); if (diff != 0) return diff; } } return lenone - lentwo; }
From source file:com.softmotions.commons.bean.BeanUtils.java
/** * Sets a property at the given bean.//from w w w . j a v a 2 s .c o m * * @param bean The bean to set a property at. * @param propertyName The name of the property to set. * @param value The value to set for the property. * @throws BeanException In case the bean access failed. */ public static void setProperty(Object bean, String propertyName, Object value) throws BeanException { Class valueClass = null; try { // getting property object from bean using "setNnnn", where nnnn is parameter name Method setterMethod = null; // first trying form getPropertyNaae for regular value String setterName = "set" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); Class paramClass = bean.getClass(); if (value != null) { valueClass = value.getClass(); Class[] setterArgTypes = new Class[] { valueClass }; setterMethod = paramClass.getMethod(setterName, setterArgTypes); } else { Method[] methods = paramClass.getMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (m.getName().equals(setterName) && (m.getParameterTypes().length == 1)) { setterMethod = m; break; } } } if (setterMethod == null) { throw new NoSuchMethodException(setterName); } Object[] setterArgs = new Object[] { value }; setterMethod.invoke(bean, setterArgs); } catch (NoSuchMethodError | NoSuchMethodException ex) { throw new BeanException("No setter method found for property '" + propertyName + "' and type " + valueClass + " at given bean from class " + bean.getClass().getName() + ".", ex); } catch (InvocationTargetException ex) { throw new BeanException("Property '" + propertyName + "' could not be set for given bean from class " + bean.getClass().getName() + ".", ex); } catch (IllegalAccessException ex) { throw new BeanException("Property '" + propertyName + "' could not be accessed for given bean from class " + bean.getClass().getName() + ".", ex); } }
From source file:com.rabbitframework.commons.utils.StringUtils.java
/** * Returns the input argument, but ensures the first character is * capitalized (if possible)./*from www .jav a2 s . co m*/ * * @param in * the string to uppercase the first character. * @return the input argument, but with the first character capitalized (if * possible). * @since 1.2 */ public static String uppercaseFirstChar(String in) { if (in == null || in.length() == 0) { return in; } int length = in.length(); StringBuilder sb = new StringBuilder(length); sb.append(Character.toUpperCase(in.charAt(0))); if (length > 1) { String remaining = in.substring(1); sb.append(remaining); } return sb.toString(); }
From source file:de.fau.cs.osr.utils.StringUtils.java
/** * Converts a name that's given in camel-case into upper-case, inserting * underscores before upper-case letters. * //www . j a v a2 s .c om * @param camelCase * Name in camel-case notation. * @return Name in upper-case notation. */ public static String camelcaseToUppercase(String camelCase) { int n = camelCase.length(); StringBuilder upperCase = new StringBuilder(n * 4 / 3); for (int i = 0; i < n; ++i) { char ch = camelCase.charAt(i); if (Character.isUpperCase(ch)) { upperCase.append('_'); upperCase.append(ch); } else { upperCase.append(Character.toUpperCase(ch)); } } return upperCase.toString(); }
From source file:com.laxser.blitz.web.impl.view.ViewDispatcherImpl.java
protected ViewResolver getVelocityViewResolver(Invocation inv, String viewPath) throws IOException { ////w ww .j av a2s .co m VelocityViewResolver viewResolver = velocityViewResolvers.get(viewPath); if (viewResolver != null) { return viewResolver; } // String viewDirectory = getDirectory(viewPath); viewResolver = velocityViewResolvers.get(viewDirectory); if (viewResolver != null) { velocityViewResolvers.put(viewPath, viewResolver); return viewResolver; } StringBuilder sb = new StringBuilder(); boolean beUpperCase = false; for (int i = 0; i < viewDirectory.length(); i++) { if (viewDirectory.charAt(i) != '/') { if (beUpperCase) { sb.append(Character.toUpperCase(viewDirectory.charAt(i))); beUpperCase = false; } else { sb.append(viewDirectory.charAt(i)); } } else { beUpperCase = true; } } String beanName = sb.toString() + "VelocityViewResolver"; viewResolver = (VelocityViewResolver) SpringUtils.getBean(getApplicationContext(), beanName); if (viewResolver == null) { String temp = viewDirectory; String layoutUrl = null; while (temp.length() > 0) { String _layoutUrl = temp + "/layout.vm"; if (logger.isDebugEnabled()) { logger.debug("is default layout file exist? " + _layoutUrl); } File layout = new File(inv.getServletContext().getRealPath(_layoutUrl)); if (layout.exists()) { layoutUrl = _layoutUrl; if (logger.isDebugEnabled()) { logger.debug("found default layout file " + _layoutUrl); } break; } else { int i = temp.lastIndexOf('/'); if (i <= 0) { break; } temp = temp.substring(0, i); } } // if (layoutUrl == null) { if (logger.isDebugEnabled()) { logger.debug("not found layout file for " + viewDirectory); } beanName = "velocityViewResolver"; viewResolver = (VelocityViewResolver) SpringUtils.getBean(getApplicationContext(), beanName); } if (viewResolver == null) { viewResolver = createVelocityViewResolver(inv, beanName, layoutUrl); } } velocityViewResolvers.put(viewDirectory, viewResolver); velocityViewResolvers.put(viewPath, viewResolver); return viewResolver; }
From source file:com.baidubce.AbstractBceClient.java
/** * Returns the service ID based on the actual class name. * * <p>//from ww w . j a va 2 s . c o m * The class name should be in the form of "com.baidubce.services.xxx.XxxClient", * while "xxx" is the service ID and * "Xxx" is the capitalized service ID. * * @return the computed service ID. * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients. */ private String computeServiceId() { String packageName = this.getClass().getPackage().getName(); String prefix = AbstractBceClient.class.getPackage().getName() + ".services."; if (!packageName.startsWith(prefix)) { throw new IllegalStateException("Unrecognized prefix for the client package : " + packageName + ", " + "'" + prefix + "' expected"); } String serviceId = packageName.substring(prefix.length()); if (serviceId.indexOf('.') != -1) { throw new IllegalStateException("The client class should be put in package like " + prefix + "XXX"); } String className = this.getClass().getName(); String expectedClassName = packageName + '.' + Character.toUpperCase(serviceId.charAt(0)) + serviceId.substring(1) + "Client"; /** * Comment out this verification for media services, since media service is a suit of * services, the media package contains multiple Client classes. * */ // if (!className.equals(expectedClassName)) { // throw new IllegalStateException("Invalid class name " // + className + ", " + expectedClassName + " expected"); // } return serviceId; }