List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:com.chiralbehaviors.CoRE.workspace.WorkspaceAuthorization.java
public static String getWorkspaceAuthorizationColumnName(Class<?> ruleform) { StringBuilder builder = new StringBuilder(); String simpleName = ruleform.getClass().getSimpleName(); builder.append(Character.toLowerCase(simpleName.charAt(0))); int i = 1;/*from ww w.j a v a2s . c o m*/ for (char c = simpleName.charAt(i); i < simpleName.length(); i++) { if (Character.isUpperCase(c)) { builder.append('_'); builder.append(Character.toLowerCase(c)); } } return builder.toString(); }
From source file:org.jspresso.framework.util.bean.PropertyHelper.java
/** * Whenever a property name starts with a single lowercase letter, the actual * java bean property starts with an upper case letter. * * @param prop/* ww w. j a va2s .c o m*/ * the property name. * @return the fixed java bean property name. */ public static String fromJavaBeanPropertyName(String prop) { if (prop != null && prop.length() >= 2) { if (Character.isUpperCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) { StringBuilder fixedProp = new StringBuilder(prop.substring(0, 1).toLowerCase()); fixedProp.append(prop.substring(1)); return fixedProp.toString(); } } return prop; }
From source file:org.hyperic.hq.plugin.netdevice.NetworkDevicePlatformDetector.java
public PlatformResource getPlatformResource(ConfigResponse config) throws PluginException { String platformIp = config.getValue(ProductPlugin.PROP_PLATFORM_IP); // For command-line -DsnmpIp=x.x.x.x usage... platformIp = getIpProp(SNMPClient.PROP_IP, platformIp, platformIp); String defaultVersion = getIpProp(SNMPClient.PROP_VERSION, platformIp, SNMPClient.VALID_VERSIONS[1]); // v2c String fallbackVersion = SNMPClient.VALID_VERSIONS[0]; // v1 PlatformResource platform = super.getPlatformResource(config); Log log = getLog();//from w ww .j a va2 s . com ConfigResponse metricConfig; boolean hasConfig = config.getValue(SNMPClient.PROP_IP) != null; if (hasConfig) { // We've already been here... metricConfig = config; if (log.isDebugEnabled()) { log.debug("Using approved snmp config=" + metricConfig); } } else if (this.autoDefaults) { // Platform was just created, attempt to auto-configure... metricConfig = new ConfigResponse(); metricConfig.setValue(SNMPClient.PROP_IP, platformIp); metricConfig.setValue(SNMPClient.PROP_VERSION, defaultVersion); metricConfig.setValue(SNMPClient.PROP_COMMUNITY, getIpProp(SNMPClient.PROP_COMMUNITY, platformIp, SNMPClient.DEFAULT_COMMUNITY)); metricConfig.setValue(SNMPClient.PROP_PORT, getIpProp(SNMPClient.PROP_PORT, platformIp, SNMPClient.DEFAULT_PORT_STRING)); metricConfig.setValue(NetworkDeviceDetector.PROP_IF_IX, getIpProp(NetworkDeviceDetector.PROP_IF_IX, platformIp, NetworkDeviceDetector.IF_DESCR)); if (log.isDebugEnabled()) { log.debug("Using default snmp config=" + metricConfig); } } else { if (log.isDebugEnabled()) { log.debug("Need user input for snmp config=" + config); } return platform; } ConfigResponse cprops = new ConfigResponse(); SNMPSession session; if ((session = getSession(metricConfig)) == null) { return platform; } try { session.getSingleValue("sysName"); } catch (SNMPException e) { getLog().debug("Unable to connect using " + defaultVersion + ", trying version " + fallbackVersion); metricConfig.setValue(SNMPClient.PROP_VERSION, fallbackVersion); if ((session = getSession(metricConfig)) == null) { return platform; } } String[] keys = getCustomPropertiesSchema().getOptionNames(); for (int i = 0; i < keys.length; i++) { String key = keys[i]; if (Character.isUpperCase(key.charAt(0))) { continue; // Not a MIB name } String val = getString(session, key); if (val == null) { log.debug("'" + key + "'==null"); continue; } cprops.setValue(key, val); } if (!hasConfig) { // Should only happen when the platform is created... config.merge(metricConfig, false); platform.setProductConfig(config); platform.setMeasurementConfig(new ConfigResponse()); log.debug("Setting measurement config=" + metricConfig); } String description = getString(session, "sysDescr"); if (description != null) { platform.setDescription(description); boolean hasVersionCprop = getCustomPropertiesSchema().getOption(PROP_VERSION) != null; if (hasVersionCprop) { // This works for Cisco IOS at least... StringTokenizer tok = new StringTokenizer(description, " ,"); while (tok.hasMoreTokens()) { String s = tok.nextToken(); if (s.equalsIgnoreCase(PROP_VERSION) && tok.hasMoreTokens()) { String version = tok.nextToken(); cprops.setValue(PROP_VERSION, version); break; } } } } platform.setCustomProperties(cprops); return platform; }
From source file:org.hippoecm.frontend.plugins.standards.perspective.Perspective.java
protected String toImageName(final String camelCaseString, final IconSize size, final String extension) { StringBuilder name = new StringBuilder(camelCaseString.length()); name.append(Character.toLowerCase(camelCaseString.charAt(0))); for (int i = 1; i < camelCaseString.length(); i++) { char c = camelCaseString.charAt(i); if (Character.isUpperCase(c)) { name.append('-').append(Character.toLowerCase(c)); } else {/*from w w w. jav a2 s .c o m*/ name.append(c); } } if (size != null) { name.append('-').append(size.getSize()); } name.append('.').append(extension); return name.toString(); }
From source file:com.quinsoft.zeidon.standardoe.WriteOisToJsonStream.java
private String camelCaseName(String name) { if (!options.isCamelCase()) return name; char[] nameChars = name.toCharArray(); for (int i = 0; i < nameChars.length; i++) { if (!Character.isUpperCase(nameChars[i])) break; nameChars[i] = Character.toLowerCase(nameChars[i]); }/*from ww w. j a v a 2 s .c o m*/ return String.valueOf(nameChars); }
From source file:org.openhab.binding.yamahareceiver.internal.protocol.xml.InputWithPresetControlXML.java
private int convertToPresetNumber(String presetValue) { if (StringUtils.isNotEmpty(presetValue)) { if (StringUtils.isNumeric(presetValue)) { return Integer.parseInt(presetValue); } else {/*from w ww . ja va 2 s .com*/ // special handling for RX-V3900, where 'A1' becomes 101 and 'B2' becomes 202 preset if (presetValue.length() >= 2) { Character presetAlpha = presetValue.charAt(0); if (Character.isLetter(presetAlpha) && Character.isUpperCase(presetAlpha)) { int presetNumber = Integer.parseInt(presetValue.substring(1)); return (ArrayUtils.indexOf(LETTERS, presetAlpha) + 1) * 100 + presetNumber; } } } } return -1; }
From source file:org.amplafi.flow.web.BaseFlowComponent.java
/** * add "-" before each letter that is uppercase and convert uppercase to lowercase. * for example, convert "FooBar" to "foo-bar" * @param baseName//from w w w .ja va2 s. co m * @param sb converted baseName added. */ private void tweak(String baseName, StringBuilder sb) { boolean separate = false; for (int i = 0; i < baseName.length(); i++) { char ch = baseName.charAt(i); if (Character.isUpperCase(ch)) { if (separate) { sb.append('-'); } sb.append(Character.toLowerCase(ch)); } else { sb.append(ch); } separate = true; } }
From source file:org.javaweb.utils.StringUtils.java
/** * ?/*from w ww . ja v a2 s. co m*/ * * @param str * @return */ public static String toUpperCaseFirstOne(String str) { if (isNotEmpty(str)) { char f = str.charAt(0); if (Character.isUpperCase(f)) { return str; } else { return str.replaceFirst(String.valueOf(f), String.valueOf(f).toUpperCase()); } } return str; }
From source file:com.github.nmorel.gwtjackson.rebind.property.PropertyParser.java
private static String extractFieldNameFromGetterSetterMethodName(String methodName) { String fieldName;/*from ww w. j a v a2 s . co m*/ if (methodName.startsWith("is") && methodName.length() > 2) { fieldName = methodName.substring(2); } else if ((methodName.startsWith("get") || methodName.startsWith("set")) && methodName.length() > 3) { fieldName = methodName.substring(3); } else { fieldName = methodName; } int index = 0; while (Character.isUpperCase(fieldName.charAt(index++)) && index < fieldName.length()) { } return fieldName.substring(0, index).toLowerCase() + fieldName.substring(index); }
From source file:org.intermine.metadata.StringUtil.java
/** * Returns a decapitalised version of the given String unless string is an acronym. * * Gene --> gene/*from ww w. j a v a2s. c o m*/ * Protein --> protein * MRNA --> MRNA * CDS --> CDS * * @param str the String to decapitalise * @return the decapitalised version of str */ public static String decapitalise(String str) { if (str == null) { return null; } if (str.length() <= 1) { return str.toLowerCase(); } // second character is uppercase, so we probably have an acronym. leave as upper if (Character.isUpperCase(str.charAt(1))) { return str; } return str.substring(0, 1).toLowerCase() + str.substring(1); }