List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:com.cinchapi.concourse.util.ConvertTest.java
/** * Randomly flip the case of all the characters in {@code string}. * //from w w w. j a v a 2 s .c om * @param string * @return the case scrambled string */ private String scrambleCase(String string) { char[] chars = string.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Random.getInt() % 2 == 0) { c = Character.toLowerCase(c); } else { c = Character.toUpperCase(c); } chars[i] = c; } return new String(chars); }
From source file:com.adito.boot.Util.java
/** * Turn a constant name into an english like phrase. E.g. <i>HTTP_ERROR</i> * would be turned into <i>Http Error</i>. * // w w w. j a va 2 s. c o m * @param constant constant name * @return readable name */ public static String makeConstantReadable(String constant) { StringBuffer buf = new StringBuffer(); char ch; boolean firstChar = true; for (int i = 0; i < constant.length(); i++) { ch = constant.charAt(i); if (ch == '_') { ch = ' '; firstChar = true; } else { if (firstChar) { ch = Character.toUpperCase(ch); firstChar = false; } else { ch = Character.toLowerCase(ch); } } buf.append(ch); } return buf.toString(); }
From source file:org.eclipse.jubula.rc.swt.driver.RobotSwtImpl.java
/** * {@inheritDoc}/* w w w . j a va 2 s . com*/ */ public void type(final Object graphicsComponent, final char character) throws RobotException { Validate.notNull(graphicsComponent, "The graphic component must not be null"); //$NON-NLS-1$ // Workaround for issue 342718 if (EnvironmentUtils.isMacOS() && Character.toLowerCase(character) == WorkaroundUtil.CHAR_B) { SwtApplicationTester impClass = new SwtApplicationTester(); impClass.rcNativeInputText(String.valueOf(character)); return; } if (m_keyboardHelper == null) { throw new StepExecutionException("No keyboard layout available.", //$NON-NLS-1$ EventFactory.createActionError(TestErrorEvent.UNSUPPORTED_KEYBOARD_LAYOUT)); } final KeyboardHelper.KeyStroke keyStroke = m_keyboardHelper.getKeyStroke(character); final Integer[] modifiers = keyStroke.getModifiers(); final char key = keyStroke.getChar(); final InterceptorOptions options = new InterceptorOptions(new long[] { SWT.KeyUp }); // add confirmer final IEventMatcher matcher = new DefaultSwtEventMatcher(SWT.KeyUp); final IRobotEventConfirmer confirmer = m_interceptor.intercept(options); final Boolean succeeded = (Boolean) m_queuer.invokeAndWait(this.getClass().getName() + ".type", //$NON-NLS-1$ new IRunnable() { public Object run() { Boolean success = Boolean.TRUE; try { // press the modifier keys for (int i = 0; i < modifiers.length; i++) { final int mod = modifiers[i].intValue(); if (!postKeyPress(graphicsComponent, mod, '\0')) { success = Boolean.FALSE; break; } } if (success.booleanValue()) { if (!postKeyPress(graphicsComponent, 0, key)) { success = Boolean.FALSE; } } } finally { if (!postKeyRelease(graphicsComponent, 0, key)) { success = Boolean.FALSE; } // release the modifier keys for (int i = 0; i < modifiers.length; i++) { final int mod = modifiers[i].intValue(); if (!postKeyRelease(graphicsComponent, mod, '\0')) { success = Boolean.FALSE; } } } return success; } }); if (!succeeded.booleanValue()) { final String msg = "Failed to type character '" //$NON-NLS-1$ + String.valueOf(character) + "' into component '" //$NON-NLS-1$ + SwtUtils.toString((Widget) graphicsComponent) + "'"; //$NON-NLS-1$ if (log.isWarnEnabled()) { log.warn(msg); } throw new RobotException(msg, EventFactory.createActionError(TestErrorEvent.INPUT_FAILED)); } // Workaround for bug 342718 if (!(key == WorkaroundUtil.CHAR_9 && EnvironmentUtils.isMacOS())) { confirmer.waitToConfirm(graphicsComponent, matcher); } else { TimeUtil.delay(50); } }
From source file:com.adito.util.Utils.java
/** * Converts camelCaseVersusC to camel_case_versus_c **///from ww w .ja v a 2 s.c o m public static String toUnderscore(String s) { StringBuffer buf = new StringBuffer(); char[] ch = s.toCharArray(); for (int i = 0; i < ch.length; ++i) { if (Character.isUpperCase(ch[i])) { buf.append('_'); buf.append(Character.toLowerCase(ch[i])); } else { buf.append(ch[i]); } } //System.err.println(s + " -> " + buf.toString()); return buf.toString(); }
From source file:com.zhumeng.dream.orm.hibernate.HibernateDao.java
public static String camelToUnderline(String param) { if (param == null || "".equals(param.trim())) { return ""; }/*from w ww. j a va2 s . c o m*/ int len = param.length(); StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { char c = param.charAt(i); if (Character.isUpperCase(c)) { sb.append('_'); sb.append(Character.toLowerCase(c)); } else { sb.append(c); } } return sb.toString(); }
From source file:com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.java
private ClassConfiguration processClass(final Class<? extends SimpleScriptable> klass, final BrowserVersion browser) { if (browser != null) { final JsxClass jsxClass = klass.getAnnotation(JsxClass.class); final String expectedBrowserName; if (browser.isIE()) { expectedBrowserName = "IE"; } else if (browser.isFirefox()) { expectedBrowserName = "FF"; } else {/*from w ww . j a v a2s. co m*/ expectedBrowserName = "CHROME"; } final float browserVersionNumeric = browser.getBrowserVersionNumeric(); if (jsxClass != null && isSupported(jsxClass.browsers(), expectedBrowserName, browserVersionNumeric)) { final String hostClassName = klass.getName(); final Class<?>[] domClasses = jsxClass.domClasses(); final boolean isJsObject = jsxClass.isJSObject(); final ClassConfiguration classConfiguration = new ClassConfiguration(klass, domClasses, isJsObject); final String simpleClassName = hostClassName.substring(hostClassName.lastIndexOf('.') + 1); ClassnameMap_.put(hostClassName, simpleClassName); final Map<String, Method> allGetters = new HashMap<String, Method>(); final Map<String, Method> allSetters = new HashMap<String, Method>(); for (final Method method : classConfiguration.getHostClass().getDeclaredMethods()) { for (final Annotation annotation : method.getAnnotations()) { if (annotation instanceof JsxGetter) { final JsxGetter jsxGetter = (JsxGetter) annotation; if (isSupported(jsxGetter.value(), expectedBrowserName, browserVersionNumeric)) { String property; if (jsxGetter.propertyName().isEmpty()) { property = method.getName().substring(3); property = Character.toLowerCase(property.charAt(0)) + property.substring(1); } else { property = jsxGetter.propertyName(); } allGetters.put(property, method); } } else if (annotation instanceof JsxSetter) { final JsxSetter jsxSetter = (JsxSetter) annotation; if (isSupported(jsxSetter.value(), expectedBrowserName, browserVersionNumeric)) { String property; if (jsxSetter.propertyName().isEmpty()) { property = method.getName().substring(3); property = Character.toLowerCase(property.charAt(0)) + property.substring(1); } else { property = jsxSetter.propertyName(); } allSetters.put(property, method); } } else if (annotation instanceof JsxFunction) { if (isSupported(((JsxFunction) annotation).value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.addFunction(method); } } else if (annotation instanceof JsxConstructor) { classConfiguration.setJSConstructor(method); } } } for (final Field field : classConfiguration.getHostClass().getDeclaredFields()) { final JsxConstant jsxConstant = field.getAnnotation(JsxConstant.class); if (jsxConstant != null && isSupported(jsxConstant.value(), expectedBrowserName, browserVersionNumeric)) { classConfiguration.addConstant(field.getName()); } } for (final Entry<String, Method> getterEntry : allGetters.entrySet()) { final String property = getterEntry.getKey(); classConfiguration.addProperty(property, getterEntry.getValue(), allSetters.get(property)); } return classConfiguration; } } return null; }
From source file:com.legstar.cob2xsd.XsdDataItem.java
/** * Turn a COBOL name to an XSD element name. * <p/>/*from w ww .ja va 2s .c o m*/ * COBOL names look ugly in XML schema. They are often uppercased and use * hyphens extensively. XML schema names they will have to be transformed * later to java identifiers so we try to get as close as possible to a * naming convention that suits XML Schema as well as Java. * <p> * So we remove hyphens. We lower case all characters which are not word * breakers. Word breakers are hyphens and numerics. This creates Camel * style names. Element names customarily start with a lowercase character. * <p/> * COBOL FILLERs are a particular case because there might be more than one * in the same parent group. So what we do is systematically append the * COBOL source line number so that these become unique names. * <p/> * COBOL names can start with a digit which is illegal for XML element * names. In this case we prepend a "C" character. * <p/> * Since Enterprise COBOL V4R1, underscores can be used (apart from first * character). We treat them as hyphens here, they are not propagated to the * XSD name but are used as word breakers. * <p/> * Once an element name is identified, we make sure it is unique among * siblings within the same parent. * * @param cobolDataItem the original COBOL data item * @param nonUniqueCobolNames a list of non unique COBOL names used to * detect name collisions * @param model the translator options * @param parent used to resolve potential name conflict * @param order order within parent to disambiguate siblings * @return an XML schema element name */ public static String formatElementName(final CobolDataItem cobolDataItem, final List<String> nonUniqueCobolNames, final Cob2XsdModel model, final XsdDataItem parent, final int order) { String cobolName = getXmlCompatibleCobolName(cobolDataItem.getCobolName()); if (cobolName.equalsIgnoreCase("FILLER")) { String filler = (model.elementNamesStartWithUppercase()) ? "Filler" : "filler"; return filler + cobolDataItem.getSrceLine(); } StringBuilder sb = new StringBuilder(); boolean wordBreaker = (model.elementNamesStartWithUppercase()) ? true : false; for (int i = 0; i < cobolName.length(); i++) { char c = cobolName.charAt(i); if (c != '-' && c != '_') { if (Character.isDigit(c)) { sb.append(c); wordBreaker = true; } else { if (wordBreaker) { sb.append(Character.toUpperCase(c)); } else { sb.append(Character.toLowerCase(c)); } wordBreaker = false; } } else { wordBreaker = true; } } String elementName = sb.toString(); if (parent != null) { int siblingsWithSameName = 0; for (CobolDataItem child : parent.getCobolChildren()) { if (child.getCobolName().equals(cobolDataItem.getCobolName())) { siblingsWithSameName++; } } if (siblingsWithSameName > 1) { elementName += order; } } return elementName; }
From source file:org.apache.click.util.ContainerUtils.java
/** * Extract and return the specified object property names. * <p/>// w w w . j a v a 2 s . c o m * If the object is a Map instance, this method returns the maps key set. * * @param object the object to extract property names from * @return the unique set of property names */ private static Set<String> getObjectPropertyNames(Object object) { if (object instanceof Map) { return ((Map) object).keySet(); } Set<String> hashSet = new TreeSet<String>(); Method[] methods = object.getClass().getMethods(); for (Method method : methods) { String methodName = method.getName(); if (methodName.startsWith("get") && methodName.length() > 3) { String propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } if (methodName.startsWith("is") && methodName.length() > 2) { String propertyName = Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3); hashSet.add(propertyName); } if (methodName.startsWith("set") && methodName.length() > 3) { String propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } } return hashSet; }
From source file:io.cloudsoft.marklogic.nodes.MarkLogicNodeSshDriver.java
private char claimDeviceSuffix() { Character suffix;/*from w w w . j a v a2 s . com*/ synchronized (freeDeviceNameSuffixes) { if (freeDeviceNameSuffixes.isEmpty()) { throw new IllegalStateException("No device-name suffixes available; all in use for " + getEntity()); } suffix = freeDeviceNameSuffixes.remove(0); } return Character.toLowerCase(suffix); }
From source file:CharUtils.java
/** * Make case of string match another string's case. * /*from ww w . j a v a 2s. co m*/ * @param s * String whose case should be changed. * @param sCaseToMatch * String whose case should be matched. * * @return "s" modified to match case of "sCaseToMatch". * */ public static String makeCaseMatch(String s, String sCaseToMatch) { String result = s; if (isAllCaps(sCaseToMatch)) { result = result.toUpperCase(); } else { boolean isCapitalized = false; if (sCaseToMatch.length() > 0) { if (CharUtils.isSingleQuote(sCaseToMatch.charAt(0))) { isCapitalized = (sCaseToMatch.length() > 1) && CharUtils.isCapitalLetter(sCaseToMatch.charAt(1)); } else { isCapitalized = CharUtils.isCapitalLetter(sCaseToMatch.charAt(0)); } } if (result.length() > 0) { if (CharUtils.isSingleQuote(result.charAt(0))) { String char0 = result.charAt(0) + ""; String rest = ""; if (result.length() > 1) { char char1 = result.charAt(1); if (result.length() > 2) { rest = result.substring(2); } if (isCapitalized) { result = char0 + Character.toUpperCase(char1) + rest; } else { result = char0 + Character.toLowerCase(char1) + rest; } } } else { String rest = ""; char char0 = result.charAt(0); if (result.length() > 1) { rest = result.substring(1); } if (isCapitalized) { result = Character.toUpperCase(char0) + rest; } else { result = Character.toLowerCase(char0) + rest; } } } } return result; }