类org.hibernate.annotations.common.util.StringHelper源码实例Demo

下面列出了怎么用org.hibernate.annotations.common.util.StringHelper的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: youkefu   文件: UKTableMetaData.java
/**
 * 
 * @param meta
 * @throws SQLException
 */
private void initColumns(DatabaseMetaData meta , boolean upcase) throws SQLException {
	ResultSet rs = null;

	try {
		if (meta.storesUpperCaseIdentifiers()) {
			rs = meta.getColumns(StringHelper.toUpperCase(catalog),
					StringHelper.toUpperCase(schema), StringHelper
							.toUpperCase(name), "%");
		} else if (meta.storesLowerCaseIdentifiers()) {
			rs = meta.getColumns(StringHelper.toLowerCase(catalog),
					StringHelper.toLowerCase(schema), StringHelper
							.toLowerCase(name), "%");
		} else {
			rs = meta.getColumns(catalog, schema, name, "%");
		}
		while (rs.next())
			addColumn(rs , upcase);
	}catch(Exception ex){
		ex.printStackTrace();
	}finally {
		if (rs != null)
			rs.close();
	}
}
 
源代码2 项目: lams   文件: InFlightMetadataCollectorImpl.java
@Override
public void addTypeDefinition(TypeDefinition typeDefinition) {
	if ( typeDefinition == null ) {
		throw new IllegalArgumentException( "Type definition is null" );
	}

	// Need to register both by name and registration keys.
	if ( !StringHelper.isEmpty( typeDefinition.getName() ) ) {
		addTypeDefinition( typeDefinition.getName(), typeDefinition );
	}

	if ( typeDefinition.getRegistrationKeys() != null ) {
		for ( String registrationKey : typeDefinition.getRegistrationKeys() ) {
			addTypeDefinition( registrationKey, typeDefinition );
		}
	}
}
 
源代码3 项目: lams   文件: Constraint.java
public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog, String defaultSchema) {
	if ( isGenerated( dialect ) ) {
		// Certain dialects (ex: HANA) don't support FKs as expected, but other constraints can still be created.
		// If that's the case, hasAlterTable() will be true, but getAddForeignKeyConstraintString will return
		// empty string.  Prevent blank "alter table" statements.
		String constraintString = sqlConstraintString( dialect, getName(), defaultCatalog, defaultSchema );
		if ( !StringHelper.isEmpty( constraintString ) ) {
			final String tableName = getTable().getQualifiedName( dialect, defaultCatalog, defaultSchema );
			return dialect.getAlterTableString( tableName ) + " " + constraintString;
		}
	}
	return null;
}
 
源代码4 项目: lams   文件: DialectFactoryImpl.java
@SuppressWarnings("SimplifiableIfStatement")
private boolean isEmpty(Object dialectReference) {
	if ( dialectReference != null ) {
		// the referenced value is not null
		if ( dialectReference instanceof String ) {
			// if it is a String, it might still be empty though...
			return StringHelper.isEmpty( (String) dialectReference );
		}
		return false;
	}
	return true;
}
 
源代码5 项目: lams   文件: SessionFactoryRegistry.java
public SessionFactory findSessionFactory(String uuid, String name) {
	SessionFactory sessionFactory = getSessionFactory( uuid );
	if ( sessionFactory == null && StringHelper.isNotEmpty( name ) ) {
		sessionFactory = getNamedSessionFactory( name );
	}
	return sessionFactory;
}
 
源代码6 项目: webdsl   文件: WebDSLDateBridge.java
public Object stringToObject(String stringValue) {
    if ( StringHelper.isEmpty( stringValue ) ) return null;
    try {
        return DateTools.stringToDate( stringValue );
    }
    catch (ParseException e) {
        throw new SearchException( "Unable to parse into date: " + stringValue, e );
    }
}
 
源代码7 项目: youkefu   文件: UKDatabaseMetadata.java
/**
 * 
 * @param name
 * @param schema
 * @param catalog
 * @param isQuoted
 * @return
 * @throws Exception
 */
public List<UKTableMetaData> loadTables(String name, String schema, String catalog,
		boolean isQuoted) throws Exception {
	boolean upcase = false ;
	try {
		if(properties!=null && properties.get("schema")!=null && schema==null){
			schema = properties.get("upcase")!=null?((String)properties.get("schema")).toUpperCase():(String)properties.get("schema") ;
		}
		if(properties!=null && properties.get("upcase")!=null){
			upcase = properties.get("upcase")!=null &&  properties.get("upcase").toString().toLowerCase().equals("true");
		}
		UKTableMetaData table = null;
		Statement statement = null;
		ResultSet rs = null ;
		try {
			if ((isQuoted && meta.storesMixedCaseQuotedIdentifiers())) {
				rs = meta.getTables(catalog, schema, name, TYPES);
			} else if ((isQuoted && meta.storesUpperCaseIdentifiers() && meta.storesUpperCaseQuotedIdentifiers())
					|| (!isQuoted && meta.storesUpperCaseIdentifiers())) {
				rs = meta.getTables(StringHelper.toUpperCase(catalog),
						StringHelper.toUpperCase(schema), StringHelper
								.toUpperCase(name), TYPES);
			} else if ((isQuoted && meta.storesLowerCaseQuotedIdentifiers())
					|| (!isQuoted && meta.storesLowerCaseIdentifiers())) {
				rs = meta.getTables(StringHelper.toLowerCase(catalog),
						StringHelper.toLowerCase(schema), StringHelper
								.toLowerCase(name), TYPES);
			}else if(schema!=null && schema.equals("hive")){
				statement = this.connection.createStatement() ;
				if(properties.get("database")!=null){
					statement.execute("USE "+properties.get("database")) ;
				}
				rs = statement.executeQuery("SHOW TABLES") ;
			} else {
				rs = meta.getTables(catalog, schema, name, TYPES);
			}

			while (rs.next()) {
				String tableName = null ;
				if(schema!=null && schema.equals("hive")){
					tableName = rs.getString("tab_name") ;
				}else{
					tableName = rs.getString("TABLE_NAME");
				}
				
				if(tableName.matches("[\\da-zA-Z_-\u4e00-\u9fa5]+")){
					table = new UKTableMetaData(rs, meta, true , upcase , false , schema);
					tables.add(table);
				}
			}

		}catch(Exception ex){
			ex.printStackTrace();
		} finally {
			if (rs != null){
				rs.close();
			}
			if(statement!=null){
				statement.close();
			}
		}
	} catch (SQLException sqle) {
		throw sqle;
	}
	return tables ;
}
 
源代码8 项目: youkefu   文件: UKDatabaseMetadata.java
/**
 * 
 * @param name
 * @param schema
 * @param catalog
 * @param isQuoted
 * @return
 * @throws Exception
 */
public UKTableMetaData loadTable(String name, String schema, String catalog,
		boolean isQuoted) throws Exception {
	UKTableMetaData table = null;
	boolean upcase = false ;
	try {
		if(properties!=null && properties.get("schema")!=null && schema==null){
			schema = (String)properties.get("schema") ;
		}
		if(properties!=null && properties.get("upcase")!=null){
			upcase = properties.get("upcase")!=null &&  properties.get("upcase").toString().toLowerCase().equals("true");
		}
		ResultSet rs = null;
		try {
			if ((isQuoted && meta.storesMixedCaseQuotedIdentifiers())) {
				rs = meta.getTables(catalog, schema, name, TYPES);
			} else if ((isQuoted && meta.storesUpperCaseQuotedIdentifiers())
					|| (!isQuoted && meta.storesUpperCaseIdentifiers())) {
				rs = meta.getTables(StringHelper.toUpperCase(catalog),
						StringHelper.toUpperCase(schema), StringHelper
								.toUpperCase(name), TYPES);
			} else if ((isQuoted && meta.storesLowerCaseQuotedIdentifiers())
					|| (!isQuoted && meta.storesLowerCaseIdentifiers())) {
				rs = meta.getTables(StringHelper.toLowerCase(catalog),
						StringHelper.toLowerCase(schema), StringHelper
								.toLowerCase(name), TYPES);
			} else {
				rs = meta.getTables(catalog, schema, name, TYPES);
			}

			while (rs.next()) {
				table = new UKTableMetaData(rs, meta, true , upcase , true , schema);
				break ;
			}

		} finally {
			if (rs != null)
				rs.close();
		}
	} catch (SQLException sqle) {
		sqle.printStackTrace() ;
		throw sqle;
	}
	return table ;
}
 
源代码9 项目: mojito   文件: VarGenerator.java
public static String gen(String description) {
    return StringHelper.generateAlias(description.replaceAll("\\(|\\)", ""), nextValue());
}
 
 类所在包
 类方法
 同包方法