List of usage examples for com.liferay.portal.kernel.util StringUtil upperCaseFirstLetter
public static String upperCaseFirstLetter(String s)
From source file:com.liferay.alloy.mvc.jsonwebservice.AlloyControllerInvokerManager.java
License:Open Source License
protected String getAlloyControllerInvokerClassName(Class<? extends AlloyController> controllerClass) { Package pkg = controllerClass.getPackage(); String simpleName = StringPool.BLANK; Class<?> enclosingClass = controllerClass.getEnclosingClass(); if (enclosingClass != null) { String name = StringUtil.replace(enclosingClass.getSimpleName(), "005f", StringPool.BLANK); int trimIndex = name.indexOf("_controller"); String[] wordElements = StringUtil.split(name.substring(0, trimIndex), CharPool.UNDERLINE); for (String wordElement : wordElements) { simpleName = simpleName.concat(StringUtil.upperCaseFirstLetter(wordElement)); }//ww w . j a v a 2s. com simpleName = simpleName.concat(_BASE_CLASS_NAME); } else { simpleName = _BASE_CLASS_NAME + _counter.getAndIncrement(); } return pkg.getName() + StringPool.PERIOD + simpleName; }
From source file:com.liferay.announcements.uad.entity.AnnouncementsEntryUADEntity.java
License:Open Source License
private String _getMethodName(String fieldName) { return "get" + StringUtil.upperCaseFirstLetter(fieldName); }
From source file:com.liferay.tools.sourceformatter.JavaSourceProcessor.java
License:Open Source License
protected void checkLogLevel(String content, String fileName, String logLevel) { if (fileName.contains("Log")) { return;//ww w .j ava 2s. co m } Pattern pattern = Pattern.compile("\n(\t+)_log." + logLevel + "\\("); Matcher matcher = pattern.matcher(content); while (matcher.find()) { int pos = matcher.start(); while (true) { pos = content.lastIndexOf(StringPool.NEW_LINE + StringPool.TAB, pos - 1); char c = content.charAt(pos + 2); if (c != CharPool.TAB) { break; } } String codeBlock = content.substring(pos, matcher.start()); String s = "_log.is" + StringUtil.upperCaseFirstLetter(logLevel) + "Enabled()"; if (!codeBlock.contains(s)) { int lineCount = StringUtil.count(content.substring(0, matcher.start(1)), StringPool.NEW_LINE); lineCount += 1; processErrorMessage(fileName, "Use " + s + ": " + fileName + " " + lineCount); } } return; }
From source file:com.liferay.users.admin.demo.data.creator.internal.BaseUserDemoDataCreator.java
License:Open Source License
protected String[] getFullNameArray(String emailAddress) { String emailAccountName = emailAddress.substring(0, emailAddress.indexOf(StringPool.AT)); String[] fullNameArray = StringUtil.split(emailAccountName, StringPool.PERIOD); String firstName = StringUtil.randomString(); String lastName = StringUtil.randomString(); if (fullNameArray.length > 0) { firstName = StringUtil.upperCaseFirstLetter(fullNameArray[0]); }// w ww. ja va 2s . com if (fullNameArray.length > 1) { lastName = StringUtil.upperCaseFirstLetter(fullNameArray[1]); } return new String[] { firstName, lastName }; }
From source file:gr.open.loglevelsmanager.loglevel.LogLevelUpload.java
License:Open Source License
private void callSetMethod(String formField, LogLevel logLevel, Long value) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String strMethod = "set" + StringUtil.upperCaseFirstLetter(formField); Method methodSet = logLevel.getClass().getMethod(strMethod, long.class); methodSet.invoke(logLevel, value);/*from w w w .j av a 2 s. co m*/ }
From source file:io.gatling.generation.service.SourceCodeIdentifierServices.java
License:Apache License
/** * create variable name for gatling scenario * Example: "my variable_name" becomes "PrefixMyVariableName" * @param prefix The prefix to insert in the begining of the returned scenario name * @param name The initial name//from www .j a v a 2s . c o m * @return The modified name */ public static String createVariableName(String prefix, String name) { if (!name.isEmpty() && name.charAt(0) == '_') { //Hack if the name starts with '_' which causes an Error if not processed name = name.substring(1); } // Create variable name String[] tab = name.trim().split("[_\\s]"); StringBuffer sb = new StringBuffer(prefix); for (String string : tab) { /* * TODO: It would be really good to remove all liferay dependencies * inside the io.gatling.generation Package. * * This would permit to seperate generation functionalities and permit * to use maven multi-modules : * Code generation could then be used in other dirived projects. */ sb.append(StringUtil.upperCaseFirstLetter(string)); } return sb.toString(); }
From source file:jorgediazest.missingrefchecker.ref.ReferenceUtil.java
License:Open Source License
protected static String replaceVars(String varPrefix, Model model, String text) { String primaryKeyAttribute = model.getPrimaryKeyAttribute(); String primaryKeyAttributeFirstUpper = StringPool.BLANK; if (primaryKeyAttribute.length() > 0) { primaryKeyAttributeFirstUpper = StringUtil.upperCaseFirstLetter(primaryKeyAttribute); }//from w w w . j a va 2s . c om return StringUtil.replace(text, new String[] { "${" + varPrefix + ".classNameId}", "${" + varPrefix + ".primaryKey}", "${" + varPrefix + ".PrimaryKey}" }, new String[] { Long.toString(model.getClassNameId()), primaryKeyAttribute, primaryKeyAttributeFirstUpper }); }
From source file:org.liferayhub.pc.service.impl.PowerConsoleServiceImpl.java
License:Open Source License
public String runCommand(long userId, long companyId, String mode, String command) { String response = ""; Date startDate = new Date(); if ("server".equalsIgnoreCase(mode)) { if ("help".equalsIgnoreCase(command)) { response = "Commands:\n" + "help\t\t\tShow this help message\n" + "version\t\t Display the version of the Liferay Portal\n" + "date\t\t\tDisplay the date and time of the database server\n" + "uptime\t\t Display the uptime of the portal\n" + "adduser\t\t Add a new user"; } else if ("version".equalsIgnoreCase(command)) { response = ReleaseInfo.getReleaseInfo() + " running on " + StringUtil.upperCaseFirstLetter(ServerDetector.getServerId()); } else if ("date".equalsIgnoreCase(command)) { response = new Date().toString(); } else if ("uptime".equalsIgnoreCase(command)) { response = getUptime(PortalUtil.getUptime().getTime()); } else if (command.toLowerCase().startsWith("adduser")) { response = handleAddUser(userId, companyId, command); }/*ww w . j a v a2 s .co m*/ } else if ("db".equalsIgnoreCase(mode)) { if ("help".equalsIgnoreCase(command)) { response = "Commands:\n" + "help\t\t\tShow this help message\n" + "version\t\t Display the version of the database\n" + "date\t\t\tDisplay the date and time of the database server\n" + "<sql query>\t Display result of any SQL query"; } else if ("date".equalsIgnoreCase(command)) { response = runSQLQuery("select now() \"\""); } else if ("version".equalsIgnoreCase(command)) { response = runSQLQuery( "select '" + DBFactoryUtil.getDBFactory().getDB().getType() + "' as '', version() ''"); } else response = runSQLQuery(command); } else if ("jvm".equalsIgnoreCase(mode)) { if ("help".equalsIgnoreCase(command)) { response = "Commands:\n" + "help\t\tShow this help message\n" + "mem\t\t Display memory usage of the JVM\n" + "osinfo\t Display operating system info of the running JVM\n" + "vminfo\t Display VM info"; } else if ("mem".equalsIgnoreCase(command)) { MemoryMXBean mem = ManagementFactory.getMemoryMXBean(); response = "Heap : " + mem.getHeapMemoryUsage().toString(); response += "\nNon Heap : " + mem.getNonHeapMemoryUsage().toString(); response += "\nFinalization: " + mem.getObjectPendingFinalizationCount() + " objects pending"; } else if ("osinfo".equalsIgnoreCase(command)) { OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); response = os.getName() + "[" + os.getArch() + "] " + os.getVersion() + " (" + os.getAvailableProcessors() + " processors)"; response += "\nLoad Average: " + os.getSystemLoadAverage(); } else if ("vminfo".equalsIgnoreCase(command)) { RuntimeMXBean vm = ManagementFactory.getRuntimeMXBean(); response = vm.getVmName() + " " + vm.getVmVersion() + " by " + vm.getVmVendor(); response += "\n" + vm.getSpecName() + " " + vm.getSpecVersion() + " by " + vm.getSpecVendor(); response += "\nStarted at: " + DateFormat.getInstance().format(new Date(vm.getStartTime())); response += "\nUptime : " + getUptime(vm.getStartTime()); } else { response = UNRECOGNIZED_COMMAND; } } // save command to database if it is not 'help' if (!command.startsWith("help")) { try { // add to history Date endDate = new Date(); long id = CounterLocalServiceUtil.increment(CommandHistory.class.getName()); CommandHistory history = CommandHistoryLocalServiceUtil.createCommandHistory(id); history.setCommand(command); history.setExecutionDate(startDate); history.setExecutionTime(endDate.getTime() - startDate.getTime()); history.setMode(mode); history.setUserId(userId); CommandHistoryLocalServiceUtil.updateCommandHistory(history); // TODO: delete the oldest entry > MAX_HISTORY_SIZE // get the history size long historySize = 100; List<CommandHistory> historyList = CommandHistoryLocalServiceUtil .findCommandHistoryByUserId(userId); if (historyList.size() >= historySize) { CommandHistoryLocalServiceUtil.deleteCommandHistory(historyList.get(0)); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } } return response; }
From source file:org.xmlportletfactory.olafk.customer.CustomerUpload.java
License:Open Source License
private void callSetMethod(String formField, Customer customer, Long value) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String strMethod = "set" + StringUtil.upperCaseFirstLetter(formField); Method methodSet = customer.getClass().getMethod(strMethod, long.class); methodSet.invoke(customer, value);/* ww w. jav a 2 s .c o m*/ }
From source file:org.xmlportletfactory.olafk.customer.InvoicesUpload.java
License:Open Source License
private void callSetMethod(String formField, Invoices invoices, Long value) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String strMethod = "set" + StringUtil.upperCaseFirstLetter(formField); Method methodSet = invoices.getClass().getMethod(strMethod, long.class); methodSet.invoke(invoices, value);//from www. ja va 2s .c o m }