List of usage examples for java.lang String toUpperCase
public String toUpperCase()
From source file:com.digitalgeneralists.assurance.Application.java
static void installDb(InputStream propertiesFileStream, InputStream dbScriptStream) throws IOException, SQLException { Logger logger = Logger.getLogger(Application.class); Connection dbConnection = null; ResultSet rs = null;// w w w . j ava 2 s . c o m try { Properties properties = new Properties(); if (propertiesFileStream != null) { properties.load(propertiesFileStream); } else { throw new FileNotFoundException("The database properties file could not be loaded."); } String dbUrl = (String) properties.get("jdbc.url"); String dbUser = (String) properties.get("jdbc.username"); String dbPassword = (String) properties.get("jdbc.password"); dbConnection = DriverManager.getConnection(dbUrl, dbUser, dbPassword); ArrayList<String> listOfDatabases = new ArrayList<String>(); DatabaseMetaData meta = dbConnection.getMetaData(); String[] tableTypes = { "TABLE" }; rs = meta.getTables(null, null, Application.verificationTableName, tableTypes); while (rs.next()) { String databaseName = rs.getString("TABLE_NAME"); listOfDatabases.add(databaseName.toUpperCase()); } if (listOfDatabases.contains(Application.verificationTableName)) { logger.info("Database already exists"); } else { ScriptRunner runner = new ScriptRunner(dbConnection, true, true); Reader dbScript = new InputStreamReader(dbScriptStream); runner.runScript(dbScript); logger.info("Database is created"); } } finally { if (rs != null) { try { rs.close(); rs = null; } catch (SQLException e) { // The ship is going down. Not much we can do. logger.fatal(e); } } if (dbConnection != null) { dbConnection.close(); dbConnection = null; } } logger = null; }
From source file:com.jaspersoft.jasperserver.search.model.SearchActionModelSupport.java
/** * Singleton getter method/*from w w w . j a v a 2 s. com*/ * @return singleton object */ public static synchronized SearchActionModelSupport getInstance(String searchMode) { SearchActionModelSupport.instance.setSearchMode(SearchMode.valueOf(searchMode.toUpperCase())); return SearchActionModelSupport.instance; }
From source file:Main.java
/** * Converts a database name (table or column) to a java name (first letter capitalised). * employee_name -> EmployeeName.// ww w . j av a 2s .c om * * Derived from middlegen's dbnameconverter. * @param s The database name to convert. * * @return The converted database name. */ public static String toUpperCamelCase(String s) { if ("".equals(s)) { return s; } StringBuffer result = new StringBuffer(); boolean capitalize = true; boolean lastCapital = false; boolean lastDecapitalized = false; String p = null; for (int i = 0; i < s.length(); i++) { String c = s.substring(i, i + 1); if ("_".equals(c) || " ".equals(c) || "-".equals(c)) { capitalize = true; continue; } if (c.toUpperCase().equals(c)) { if (lastDecapitalized && !lastCapital) { capitalize = true; } lastCapital = true; } else { lastCapital = false; } //if(forceFirstLetter && result.length()==0) capitalize = false; if (capitalize) { if (p == null || !p.equals("_")) { result.append(c.toUpperCase()); capitalize = false; p = c; } else { result.append(c.toLowerCase()); capitalize = false; p = c; } } else { result.append(c.toLowerCase()); lastDecapitalized = true; p = c; } } String r = result.toString(); return r; }
From source file:th.co.geniustree.intenship.advisor.spec.FacultySpec.java
public static Specification<Faculty> nameLike(final String keyword) { return new Specification<Faculty>() { @Override/*from w ww . j ava 2 s. co m*/ public Predicate toPredicate(Root<Faculty> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.like(cb.upper(root.get(Faculty_.name)), keyword.toUpperCase()); } }; }
From source file:jp.terasoluna.fw.util.HashUtil.java
/** * ??????//from ww w.j a v a 2s . com * * @param algorithm ? * @param str ???? * @return ? * @throws NoSuchAlgorithmException ??????? * */ public static byte[] hash(String algorithm, String str) throws NoSuchAlgorithmException { if (algorithm == null || str == null) { return null; } MessageDigest md = MessageDigest.getInstance(algorithm.toUpperCase()); return md.digest(str.getBytes()); }
From source file:br.gov.frameworkdemoiselle.util.contrib.Strings.java
public static String firstToUpper(String string) { String result = string;/* w ww .j a v a 2 s . c om*/ if (!Strings.isEmpty(string)) { result = string.toUpperCase().charAt(0) + (string.length() > 1 ? string.substring(1) : ""); } return result; }
From source file:com.aliyun.openservices.odps.console.utils.QueryUtil.java
/** * sql?insert?partition//from www.ja v a 2 s .c o m * */ public static boolean isOperatorDisabled(String sql) { String upSql = sql.toUpperCase(); if (upSql.matches("^INSERT\\s+INTO.*")) { return true; } //dy patition if (upSql.indexOf("INSERT ") >= 0 && upSql.indexOf(" PARTITION") >= 0) { //split partition String[] partitions = upSql.split(" PARTITION"); for (int i = 0; i < partitions.length; i++) { String temp = partitions[i].trim(); if (temp.startsWith("(") && temp.indexOf(")") > 0) { //get partition spec String partitionStr = temp.substring(0, temp.indexOf(")")); String[] partitionSpcs = partitionStr.split(","); String lastPartitionSpc = partitionSpcs[partitionSpcs.length - 1]; if (lastPartitionSpc.indexOf("=") == -1) { //????? return true; } } } } return false; }
From source file:gobblin.hive.HiveSerDeManager.java
/** * Get an instance of {@link HiveSerDeManager}. * * @param type The {@link HiveSerDeManager} type. It should be either AVRO, or the name of a class that implements * {@link HiveSerDeManager}. The specified {@link HiveSerDeManager} type must have a constructor that takes a * {@link State} object.//from www. ja v a2 s .co m * @param props A {@link State} object. To get a specific implementation of {@link HiveSerDeManager}, specify either * one of the values in {@link Implementation} (e.g., AVRO) or the name of a class that implements * {@link HiveSerDeManager} in property {@link #HIVE_ROW_FORMAT}. The {@link State} object is also used to * instantiate the {@link HiveSerDeManager}. */ public static HiveSerDeManager get(State props) { String type = props.getProp(HIVE_ROW_FORMAT, Implementation.AVRO.name()); Optional<Implementation> implementation = Enums.getIfPresent(Implementation.class, type.toUpperCase()); try { if (implementation.isPresent()) { return (HiveSerDeManager) ConstructorUtils .invokeConstructor(Class.forName(implementation.get().toString()), props); } return (HiveSerDeManager) ConstructorUtils.invokeConstructor(Class.forName(type), props); } catch (ReflectiveOperationException e) { throw new RuntimeException( "Unable to instantiate " + HiveSerDeManager.class.getSimpleName() + " with type " + type, e); } }
From source file:com.twosigma.cook.jobclient.StragglerHandling.java
public static StragglerHandling parseFromJSON(JSONObject shJson, InstanceDecorator decorator) throws JSONException { Builder shBuilder = new Builder(); String type = shJson.getString("type"); shBuilder.setType(Type.fromString(type.toUpperCase())); if (shJson.has("parameters")) { JSONObject paramJson = shJson.getJSONObject("parameters"); Iterator names = paramJson.keys(); while (names.hasNext()) { String name = (String) names.next(); shBuilder.setParameter(name, paramJson.get(name)); }//from w w w. jav a 2s.c o m } return shBuilder.build(); }
From source file:cc.sion.core.web.Servlets.java
/** * ??Header.// w w w. j av a 2 s.c om * * @param fileName ???. */ public static void setFileDownloadHeader(HttpServletRequest request, HttpServletResponse response, String fileName) { // ??? String encodedfileName = null; // ??firefox??,???+? encodedfileName = fileName.trim().replaceAll(" ", "_"); String agent = request.getHeader("User-Agent"); boolean isMSIE = (agent != null && agent.toUpperCase().indexOf("MSIE") != -1); if (isMSIE) { encodedfileName = Encodes.urlEncode(fileName); } else { encodedfileName = new String(fileName.getBytes(), Charsets.ISO_8859_1); } response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedfileName + "\""); }