当前位置: 首页>>代码示例>>Java>>正文


Java StringHelper.split方法代码示例

本文整理汇总了Java中org.hibernate.util.StringHelper.split方法的典型用法代码示例。如果您正苦于以下问题:Java StringHelper.split方法的具体用法?Java StringHelper.split怎么用?Java StringHelper.split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.util.StringHelper的用法示例。


在下文中一共展示了StringHelper.split方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isTable

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public boolean isTable(Object key) throws HibernateException {
	if(key instanceof String) {
	Table tbl = new Table((String)key);
	if ( getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null ) {
			return true;
		} else {
			String[] strings = StringHelper.split(".", (String) key);
			if(strings.length==3) {
			tbl = new Table(strings[2]);
			tbl.setCatalog(strings[0]);
			tbl.setSchema(strings[1]);
			return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
			} else if (strings.length==2) {
			tbl = new Table(strings[1]);
			tbl.setSchema(strings[0]);
			return getTableMetadata( tbl.getName(), tbl.getSchema(), tbl.getCatalog(), tbl.isQuoted() ) != null;
			}
		}
	}
	return false;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:DatabaseMetadata.java

示例2: parsePath

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
/**
 * Turns a path into an AST.
 *
 * @param path    The path.
 * @param factory The AST factory to use.
 * @return An HQL AST representing the path.
 */
public static AST parsePath(String path, ASTFactory factory) {
	String[] identifiers = StringHelper.split( ".", path );
	AST lhs = null;
	for ( int i = 0; i < identifiers.length; i++ ) {
		String identifier = identifiers[i];
		AST child = ASTUtil.create( factory, HqlSqlTokenTypes.IDENT, identifier );
		if ( i == 0 ) {
			lhs = child;
		}
		else {
			lhs = ASTUtil.createBinarySubtree( factory, HqlSqlTokenTypes.DOT, ".", lhs, child );
		}
	}
	if ( log.isDebugEnabled() ) {
		log.debug( "parsePath() : " + path + " -> " + ASTUtil.getDebugString( lhs ) );
	}
	return lhs;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:26,代码来源:PathHelper.java

示例3: preprocess

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
private void preprocess(String token, QueryTranslatorImpl q) throws QueryException {
	// ugly hack for cases like "elements(foo.bar.collection)"
	// (multi-part path expression ending in elements or indices)
	String[] tokens = StringHelper.split( ".", token, true );
	if (
			tokens.length > 5 &&
			( CollectionPropertyNames.COLLECTION_ELEMENTS.equals( tokens[tokens.length - 1] )
			|| CollectionPropertyNames.COLLECTION_INDICES.equals( tokens[tokens.length - 1] ) )
	) {
		pathExpressionParser.start( q );
		for ( int i = 0; i < tokens.length - 3; i++ ) {
			pathExpressionParser.token( tokens[i], q );
		}
		pathExpressionParser.token( null, q );
		pathExpressionParser.end( q );
		addJoin( pathExpressionParser.getWhereJoin(), q );
		pathExpressionParser.ignoreInitialJoin();
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:WhereParser.java

示例4: isSequence

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public boolean isSequence(Object key) {
	if (key instanceof String){
		String[] strings = StringHelper.split(".", (String) key);
		return sequences.contains( strings[strings.length-1].toLowerCase());
	}
	return false;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:DatabaseMetadata.java

示例5: configure

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public void configure(Type type, Properties params, Dialect dialect)
throws MappingException {

	String tableList = params.getProperty("tables");
	if (tableList==null) tableList = params.getProperty(PersistentIdentifierGenerator.TABLES);
	String[] tables = StringHelper.split(", ", tableList);
	String column = params.getProperty("column");
	if (column==null) column = params.getProperty(PersistentIdentifierGenerator.PK);
	String schema = params.getProperty(PersistentIdentifierGenerator.SCHEMA);
	String catalog = params.getProperty(PersistentIdentifierGenerator.CATALOG);
	returnClass = type.getReturnedClass();
	

	StringBuffer buf = new StringBuffer();
	for ( int i=0; i<tables.length; i++ ) {
		if (tables.length>1) {
			buf.append("select ").append(column).append(" from ");
		}
		buf.append( Table.qualify( catalog, schema, tables[i] ) );
		if ( i<tables.length-1) buf.append(" union ");
	}
	if (tables.length>1) {
		buf.insert(0, "( ").append(" ) ids_");
		column = "ids_." + column;
	}
	
	sql = "select max(" + column + ") from " + buf.toString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:29,代码来源:IncrementGenerator.java

示例6: testStr

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
public void testStr() {
	Session session = openSession();
	Transaction txn = session.beginTransaction();
	Animal an = new Animal();
	an.setBodyWeight(123.45f);
	session.persist(an);
	String str = (String) session.createQuery("select str(an.bodyWeight) from Animal an where str(an.bodyWeight) like '123%' or str(an.bodyWeight) like '1.23%'").uniqueResult();
	if ( getDialect() instanceof DB2Dialect ) {
		assertTrue( str.startsWith("1.234") );
	}
	else if ( getDialect() instanceof SQLServerDialect ) {
		// no assertion as SQLServer always returns nulls here; even trying directly against the
		// database, it seems to have problems with str() in the where clause...
	}
	else {
		assertTrue( str.startsWith("123.4") );
	}
	if ( ! ( getDialect() instanceof SybaseDialect ) ) {
		// In TransactSQL (the variant spoken by Sybase and SQLServer), the str() function
		// is explicitly intended for numeric values only...
		String dateStr1 = (String) session.createQuery("select str(current_date) from Animal").uniqueResult();
		String dateStr2 = (String) session.createQuery("select str(year(current_date))||'-'||str(month(current_date))||'-'||str(day(current_date)) from Animal").uniqueResult();
		System.out.println(dateStr1 + '=' + dateStr2);
		if ( ! ( getDialect() instanceof Oracle9Dialect || getDialect() instanceof Oracle8iDialect ) ) { //Oracle renders the name of the month :(
			String[] dp1 = StringHelper.split("-", dateStr1);
			String[] dp2 = StringHelper.split("-", dateStr2);
			for (int i=0; i<3; i++) {
				if ( dp1[i].startsWith( "0" ) ) {
					dp1[i] = dp1[i].substring( 1 );
				}
				assertEquals( dp1[i], dp2[i] );
			}
		}
	}
	session.delete(an);
	txn.commit();
	session.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:39,代码来源:ASTParserLoadingTest.java

示例7: concreteQueries

import org.hibernate.util.StringHelper; //导入方法依赖的package包/类
/**
 * Handle Hibernate "implicit" polymorphism, by translating the query string into
 * several "concrete" queries against mapped classes.
 */
public static String[] concreteQueries(String query, SessionFactoryImplementor factory) throws MappingException {

	//scan the query string for class names appearing in the from clause and replace
	//with all persistent implementors of the class/interface, returning multiple
	//query strings (make sure we don't pick up a class in the select clause!)

	//TODO: this is one of the ugliest and most fragile pieces of code in Hibernate....

	String[] tokens = StringHelper.split( StringHelper.WHITESPACE + "(),", query, true );
	if ( tokens.length == 0 ) return new String[]{query}; // just especially for the trivial collection filter
	ArrayList placeholders = new ArrayList();
	ArrayList replacements = new ArrayList();
	StringBuffer templateQuery = new StringBuffer( 40 );
	int count = 0;
	String last = null;
	int nextIndex = 0;
	String next = null;
	boolean isSelectClause = false;

	templateQuery.append( tokens[0] );
	if ( "select".equals( tokens[0].toLowerCase() ) ) isSelectClause = true;
       
	for ( int i = 1; i < tokens.length; i++ ) {

		//update last non-whitespace token, if necessary
		if ( !ParserHelper.isWhitespace( tokens[i - 1] ) ) last = tokens[i - 1].toLowerCase();

		// select-range is terminated by declaration of "from"
		if ( "from".equals( tokens[i].toLowerCase() ) ) isSelectClause = false;

		String token = tokens[i];
		if ( !ParserHelper.isWhitespace( token ) || last == null ) {

			//scan for next non-whitespace token
			if ( nextIndex <= i ) {
				for ( nextIndex = i + 1; nextIndex < tokens.length; nextIndex++ ) {
					next = tokens[nextIndex].toLowerCase();
					if ( !ParserHelper.isWhitespace( next ) ) break;
				}
			}

			boolean process = !isSelectClause && 
					isJavaIdentifier( token ) && 
					isPossiblyClassName( last, next );
					
			if (process) {
				String importedClassName = getImportedClass( token, factory );
				if ( importedClassName != null ) {
					String[] implementors = factory.getImplementors( importedClassName );
					String placeholder = "$clazz" + count++ + "$";
					if ( implementors != null ) {
						placeholders.add( placeholder );
						replacements.add( implementors );
					}
					token = placeholder; // Note this!!
				}
			}

		}

		templateQuery.append( token );

	}
	String[] results = StringHelper.multiply( templateQuery.toString(), placeholders.iterator(), replacements.iterator() );
	if ( results.length == 0 ) log.warn( "no persistent classes found for query class: " + query );
	return results;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:72,代码来源:QuerySplitter.java


注:本文中的org.hibernate.util.StringHelper.split方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。