List of usage examples for java.lang Character isUpperCase
public static boolean isUpperCase(int codePoint)
From source file:nl.strohalm.cyclos.utils.StringHelper.java
/** * Transforms the given string into upper case, adding underscores between words. Examples: * <ul>/*from w ww.j a v a 2 s . c o m*/ * <li>upcase(null) == null</li> * <li>upcase("") == ""</li> * <li>upcase("myName") == "MY_NAME"</li> * <li>upcase("MyName") == "MY_NAME"</li> * <li>upcase("MyNAME") == "MY_N_A_M_E"</li> * </ul> */ public static String upcase(final String string) { if (string == null) { return null; } final StringBuilder sb = new StringBuilder(string.length()); for (int i = 0; i < string.length(); i++) { final char c = string.charAt(i); if (i > 0 && Character.isUpperCase(c)) { sb.append('_'); sb.append(c); } else { sb.append(Character.toUpperCase(c)); } } return sb.toString(); }
From source file:org.psjava.site.PsjavaSiteController.java
public static String getCamelResolved(String name) { String r = ""; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (i > 0 && Character.isUpperCase(c)) r += " "; r += c;// ww w.ja v a2 s .c o m } return r; }
From source file:com.ai.api.util.UnixFTPEntryParser.java
/** * Parses a line of a unix (standard) FTP server file listing and converts * it into a usable format in the form of an <code> FTPFile </code> * instance. If the file listing line doesn't describe a file, * <code> null </code> is returned, otherwise a <code> FTPFile </code> * instance representing the files in the directory is returned. * <p>/* ww w . ja v a 2 s.c o m*/ * @param entry A line of text from the file listing * @return An FTPFile instance corresponding to the supplied entry */ public FTPFile parseFTPEntry(String entry) { FTPFile file = new FTPFile(); file.setRawListing(entry); int type; boolean isDevice = false; if (matches(entry)) { String typeStr = group(1); String hardLinkCount = group(15); String usr = group(16); String grp = group(17); String filesize = group(18); String datestr = group(19) + " " + group(20); String name = group(21); String endtoken = group(22); try { //file.setTimestamp(super.parseTimestamp(datestr)); FTPTimestampParserImplExZH Zh2En = new FTPTimestampParserImplExZH(); file.setTimestamp(Zh2En.parseTimestamp(datestr)); } catch (ParseException e) { //logger.error(e, e); //return null; // this is a parsing failure too. //logger.info(entry+":??"); file.setTimestamp(Calendar.getInstance()); } // bcdlfmpSs- switch (typeStr.charAt(0)) { case 'd': type = FTPFile.DIRECTORY_TYPE; break; case 'l': type = FTPFile.SYMBOLIC_LINK_TYPE; break; case 'b': case 'c': isDevice = true; // break; - fall through case 'f': case '-': type = FTPFile.FILE_TYPE; break; default: type = FTPFile.UNKNOWN_TYPE; } file.setType(type); int g = 4; for (int access = 0; access < 3; access++, g += 4) { // Use != '-' to avoid having to check for suid and sticky bits file.setPermission(access, FTPFile.READ_PERMISSION, (!group(g).equals("-"))); file.setPermission(access, FTPFile.WRITE_PERMISSION, (!group(g + 1).equals("-"))); String execPerm = group(g + 2); if (!execPerm.equals("-") && !Character.isUpperCase(execPerm.charAt(0))) { file.setPermission(access, FTPFile.EXECUTE_PERMISSION, true); } else { file.setPermission(access, FTPFile.EXECUTE_PERMISSION, false); } } if (!isDevice) { try { file.setHardLinkCount(Integer.parseInt(hardLinkCount)); } catch (NumberFormatException e) { // intentionally do nothing } } file.setUser(usr); file.setGroup(grp); try { file.setSize(Long.parseLong(filesize)); } catch (NumberFormatException e) { // intentionally do nothing } if (null == endtoken) { file.setName(name); } else { // oddball cases like symbolic links, file names // with spaces in them. name += endtoken; if (type == FTPFile.SYMBOLIC_LINK_TYPE) { int end = name.indexOf(" -> "); // Give up if no link indicator is present if (end == -1) { file.setName(name); } else { file.setName(name.substring(0, end)); file.setLink(name.substring(end + 4)); } } else { file.setName(name); } } return file; } else { logger.info("matches(entry) failure:" + entry); } return null; }
From source file:org.romaframework.core.schema.SchemaClass.java
protected String lastCapitalWords(String name) { char[] chars = name.toCharArray(); for (int i = name.length() - 1; i > 0; i--) { if (Character.isUpperCase(chars[i])) { return name.substring(i); }/* w w w . j ava 2s. c o m*/ } return name; }
From source file:org.focusns.common.event.support.EventInterceptor.java
private Event getEvent(Method method, Event.Point point) { ///*from w w w . j ava 2 s .co m*/ String eventKey = eventKeyCache.get(method); if (eventKey == null) { StringBuilder eventKeyBuilder = new StringBuilder(); String methodName = method.getName(); for (int i = 0; i < methodName.length(); i++) { char c = methodName.charAt(i); if (Character.isUpperCase(c)) { eventKeyBuilder.append("_"); } eventKeyBuilder.append(Character.toUpperCase(c)); } // eventKey = eventKeyBuilder.append("|").append(point.name()).toString(); } // return eventMapping.get(eventKey); }
From source file:org.apache.nutch.tools.proxy.SegmentHandler.java
@Override public void handle(Request req, HttpServletResponse res, String target, int dispatch) throws IOException, ServletException { try {/* w w w.j a va 2s.co m*/ String uri = req.getUri().toString(); LOG.info("URI: " + uri); addMyHeader(res, "URI", uri); Text url = new Text(uri.toString()); CrawlDatum cd = seg.getCrawlDatum(url); if (cd != null) { addMyHeader(res, "Res", "found"); LOG.info("-got " + cd.toString()); ProtocolStatus ps = (ProtocolStatus) cd.getMetaData().get(Nutch.WRITABLE_PROTO_STATUS_KEY); if (ps != null) { Integer TrCode = protoCodes.get(ps.getCode()); if (TrCode != null) { res.setStatus(TrCode.intValue()); } else { res.setStatus(HttpServletResponse.SC_OK); } addMyHeader(res, "ProtocolStatus", ps.toString()); } else { res.setStatus(HttpServletResponse.SC_OK); } Content c = seg.getContent(url); if (c == null) { // missing content req.setHandled(true); res.addHeader("X-Handled-By", getClass().getSimpleName()); return; } byte[] data = c.getContent(); LOG.debug("-data len=" + data.length); Metadata meta = c.getMetadata(); String[] names = meta.names(); LOG.debug("- " + names.length + " meta"); for (int i = 0; i < names.length; i++) { boolean my = true; char ch = names[i].charAt(0); if (Character.isLetter(ch) && Character.isUpperCase(ch)) { // pretty good chance it's a standard header my = false; } String[] values = meta.getValues(names[i]); for (int k = 0; k < values.length; k++) { if (my) { addMyHeader(res, names[i], values[k]); } else { res.addHeader(names[i], values[k]); } } } req.setHandled(true); res.addHeader("X-Handled-By", getClass().getSimpleName()); res.setContentType(meta.get(Metadata.CONTENT_TYPE)); res.setContentLength(data.length); OutputStream os = res.getOutputStream(); os.write(data, 0, data.length); res.flushBuffer(); } else { addMyHeader(res, "Res", "not found"); LOG.info(" -not found " + url); } } catch (Exception e) { e.printStackTrace(); LOG.warn(StringUtils.stringifyException(e)); addMyHeader(res, "Res", "Exception: " + StringUtils.stringifyException(e)); } }
From source file:org.geotools.data.shapefile.ShpFiles.java
/** * @patch/*from w ww.ja v a 2 s .c o m*/ * * Checks if it is a compressed file which contains * the shapefiles * * @param url */ private void init(URL url) { String base = baseName(url); compressed = es.juntadeandalucia.panelGestion.negocio.utiles.Utils.isCompressedFile(url, user, password); if (base == null) { // checks if it is a compressed file if (compressed) { base = url.toExternalForm(); } if (base == null) { throw new IllegalArgumentException(url.getPath() + " is not one of the files types that is known to be associated with a shapefile"); } } String urlString = url.toExternalForm(); char lastChar = urlString.charAt(urlString.length() - 1); boolean upperCase = Character.isUpperCase(lastChar); for (ShpFileType type : ShpFileType.values()) { URL newURL; if (compressed) { newURL = url; } else { String extensionWithPeriod = type.extensionWithPeriod; if (upperCase) { extensionWithPeriod = extensionWithPeriod.toUpperCase(); } else { extensionWithPeriod = extensionWithPeriod.toLowerCase(); } String string = base + extensionWithPeriod; try { newURL = new URL(url, string); } catch (MalformedURLException e) { // shouldn't happen because the starting url was constructable throw new RuntimeException(e); } } urls.put(type, newURL); } // if the files are local check each file to see if it exists // if not then search for a file of the same name but try all combinations of the // different cases that the extension can be made up of. // IE Shp, SHP, Shp, ShP etc... if (isLocal()) { Set<Entry<ShpFileType, URL>> entries = urls.entrySet(); Map<ShpFileType, URL> toUpdate = new HashMap<ShpFileType, URL>(); for (Entry<ShpFileType, URL> entry : entries) { if (!exists(entry.getKey())) { url = findExistingFile(entry.getKey(), entry.getValue()); if (url != null) { toUpdate.put(entry.getKey(), url); } } } urls.putAll(toUpdate); } }
From source file:org.eclipse.plugin.kpax.beaninspector.introspector.BeanIntrospector.java
private String uncapitalize(String value) { if (value.length() < 2) { return value.toLowerCase(); } else if (Character.isUpperCase(value.charAt(0)) && Character.isUpperCase(value.charAt(1))) { return value; } else {//from w w w .j a v a 2 s.com return Character.toLowerCase(value.charAt(0)) + value.substring(1); } }
From source file:org.eclipse.wb.internal.core.model.variable.NamesManager.java
/** * @return the default base variable name for given component class. *///w ww.j a v a 2 s. co m public static String getDefaultName(String qualifiedClassName) { String name = CodeUtils.getShortClass(qualifiedClassName); // check if class name has only upper case characters { boolean onlyUpper = true; for (int i = 0; i < name.length(); i++) { onlyUpper &= Character.isUpperCase(name.charAt(i)); } if (onlyUpper) { return name.toLowerCase(); } } // check if class name starts from lower case character if (Character.isLowerCase(name.charAt(0))) { return name + '_'; } // remove all upper case characters from beginning except last one (most right from beginning) { int index = 0; { int maxIndex = name.length() - 1; while (index < maxIndex && Character.isUpperCase(name.charAt(index + 1))) { index++; } } name = name.substring(index); } // return StringUtils.uncapitalize(name); }
From source file:mSearch.tool.Log.java
private static void fehlermeldung_(int fehlerNummer, Exception ex, String[] texte) { final Throwable t = new Throwable(); final StackTraceElement methodCaller = t.getStackTrace()[2]; final String klasse = methodCaller.getClassName() + "." + methodCaller.getMethodName(); String kl;// w ww . j a va2 s . co m try { kl = klasse; while (kl.contains(".")) { if (Character.isUpperCase(kl.charAt(0))) { break; } else { kl = kl.substring(kl.indexOf(".") + 1); } } } catch (Exception ignored) { kl = klasse; } addFehlerNummer(fehlerNummer, kl, ex != null); if (ex != null || Config.debug) { // Exceptions immer ausgeben resetProgress(); String x, z; if (ex != null) { x = "!"; } else { x = "="; } z = "*"; logList.add(x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x); try { // Stacktrace try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) { if (ex != null) { ex.printStackTrace(pw); } pw.flush(); sw.flush(); logList.add(sw.toString()); } } catch (Exception ignored) { } logList.add(z + " Fehlernr: " + fehlerNummer); if (ex != null) { logList.add(z + " Exception: " + ex.getMessage()); } logList.add(z + " " + FEHLER + kl); for (String aTexte : texte) { logList.add(z + " " + aTexte); } logList.add(""); printLog(); } }