Replace many StringBuffer occurrences with StringBuilder

This commit is contained in:
Sanne Grinovero 2012-02-12 00:58:22 +00:00
parent a8dee131e4
commit 37dafa2a5a
138 changed files with 230 additions and 230 deletions

View File

@ -69,7 +69,7 @@ public class PropertyValueException extends HibernateException {
* @return parent-child path
*/
public static String buildPropertyPath(String parent, String child) {
return new StringBuffer(parent).append('.').append(child).toString();
return new StringBuilder(parent).append('.').append(child).toString();
}
}

View File

@ -85,7 +85,7 @@ public abstract class CollectionSecondPass implements SecondPass {
throws MappingException;
private static String columns(Value val) {
StringBuffer columns = new StringBuffer();
StringBuilder columns = new StringBuilder();
Iterator iter = val.getColumnIterator();
while ( iter.hasNext() ) {
columns.append( ( (Selectable) iter.next() ).getText() );

View File

@ -1332,7 +1332,7 @@ public final class HbmBinder {
}
private static String columns(Value val) {
StringBuffer columns = new StringBuffer();
StringBuilder columns = new StringBuilder();
Iterator iter = val.getColumnIterator();
while ( iter.hasNext() ) {
columns.append( ( (Selectable) iter.next() ).getText() );

View File

@ -69,7 +69,7 @@ public class ImprovedNamingStrategy implements NamingStrategy, Serializable {
}
protected static String addUnderscores(String name) {
StringBuffer buf = new StringBuffer( name.replace('.', '_') );
StringBuilder buf = new StringBuilder( name.replace('.', '_') );
for (int i=1; i<buf.length()-1; i++) {
if (
Character.isLowerCase( buf.charAt(i-1) ) &&

View File

@ -199,7 +199,7 @@ public class Example implements Criterion {
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer().append('(');
StringBuilder buf = new StringBuilder().append('(');
EntityPersister meta = criteriaQuery.getFactory().getEntityPersister( criteriaQuery.getEntityName(criteria) );
String[] propertyNames = meta.getPropertyNames();
Type[] propertyTypes = meta.getPropertyTypes();
@ -325,7 +325,7 @@ public class Example implements Criterion {
Object propertyValue,
Criteria criteria,
CriteriaQuery cq,
StringBuffer buf)
StringBuilder buf)
throws HibernateException {
Criterion crit;
if ( propertyValue!=null ) {
@ -357,7 +357,7 @@ public class Example implements Criterion {
CompositeType type,
Criteria criteria,
CriteriaQuery criteriaQuery,
StringBuffer buf)
StringBuilder buf)
throws HibernateException {
if (component!=null) {

View File

@ -55,7 +55,7 @@ public class IdentifierProjection extends SimpleProjection {
public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
String[] cols = criteriaQuery.getIdentifierColumns(criteria);
for ( int i=0; i<cols.length; i++ ) {
buf.append( cols[i] )

View File

@ -66,7 +66,7 @@ public class Order implements Serializable {
throws HibernateException {
String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
StringBuffer fragment = new StringBuffer();
StringBuilder fragment = new StringBuilder();
for ( int i=0; i<columns.length; i++ ) {
SessionFactoryImplementor factory = criteriaQuery.getFactory();
boolean lower = ignoreCase && type.sqlTypes( factory )[i]==Types.VARCHAR;

View File

@ -65,7 +65,7 @@ public class ProjectionList implements EnhancedProjection {
public String toSqlString(Criteria criteria, int loc, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for ( int i=0; i<getLength(); i++ ) {
Projection proj = getProjection(i);
buf.append( proj.toSqlString(criteria, loc, criteriaQuery) );
@ -77,7 +77,7 @@ public class ProjectionList implements EnhancedProjection {
public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for ( int i=0; i<getLength(); i++ ) {
Projection proj = getProjection(i);
if ( proj.isGrouped() ) {

View File

@ -61,7 +61,7 @@ public class PropertyProjection extends SimpleProjection {
public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
String[] cols = criteriaQuery.getColumns( propertyName, criteria );
for ( int i=0; i<cols.length; i++ ) {
buf.append( cols[i] )

View File

@ -65,7 +65,7 @@ public class SimpleExpression implements Criterion {
String[] columns = criteriaQuery.findColumns( propertyName, criteria );
Type type = criteriaQuery.getTypeUsingProjection( criteria, propertyName );
StringBuffer fragment = new StringBuffer();
StringBuilder fragment = new StringBuilder();
if ( columns.length > 1 ) {
fragment.append( '(' );
}

View File

@ -80,7 +80,7 @@ public abstract class SubqueryExpression implements Criterion {
String sql = walker.getSQLString();
final StringBuffer buf = new StringBuffer( toLeftSqlString(criteria, criteriaQuery) );
final StringBuilder buf = new StringBuilder( toLeftSqlString(criteria, criteriaQuery) );
if ( op != null ) {
buf.append( ' ' ).append( op ).append( ' ' );
}

View File

@ -169,7 +169,7 @@ abstract class AbstractTransactSQLDialect extends Dialect {
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map keyColumnNames) {
// TODO: merge additional lockoptions support in Dialect.applyLocksToSql
Iterator itr = aliasedLockOptions.getAliasLockIterator();
StringBuffer buffer = new StringBuffer( sql );
StringBuilder buffer = new StringBuilder( sql );
int correction = 0;
while ( itr.hasNext() ) {
final Map.Entry entry = ( Map.Entry ) itr.next();

View File

@ -161,7 +161,7 @@ public class CUBRIDDialect extends Dialect {
public String getLimitString(String sql, boolean hasOffset) {
// CUBRID 8.3.0 support limit
return new StringBuffer( sql.length() + 20 ).append( sql )
return new StringBuilder( sql.length() + 20 ).append( sql )
.append( hasOffset ? " limit ?, ?" : " limit ?" ).toString();
}

View File

@ -418,7 +418,7 @@ public class Cache71Dialect extends Dialect {
String[] primaryKey,
boolean referencesPrimaryKey) {
// The syntax used to add a foreign key constraint to a table.
return new StringBuffer( 300 )
return new StringBuilder( 300 )
.append( " ADD CONSTRAINT " )
.append( constraintName )
.append( " FOREIGN KEY " )
@ -622,7 +622,7 @@ public class Cache71Dialect extends Dialect {
// but this extension is not supported through Hibernate anyway.
int insertionPoint = sql.startsWith( "select distinct" ) ? 15 : 6;
return new StringBuffer( sql.length() + 8 )
return new StringBuilder( sql.length() + 8 )
.append( sql )
.insert( insertionPoint, " TOP ? " )
.toString();

View File

@ -63,7 +63,7 @@ public class DB2390Dialect extends DB2Dialect {
if ( limit == 0 ) {
return sql;
}
return new StringBuffer( sql.length() + 40 )
return new StringBuilder( sql.length() + 40 )
.append( sql )
.append( " fetch first " )
.append( limit )

View File

@ -63,7 +63,7 @@ public class DB2400Dialect extends DB2Dialect {
if ( limit == 0 ) {
return sql;
}
return new StringBuffer( sql.length() + 40 )
return new StringBuilder( sql.length() + 40 )
.append( sql )
.append( " fetch first " )
.append( limit )

View File

@ -178,7 +178,7 @@ public String getForUpdateString() {
*/
@Override
public String getLimitString(String query, final int offset, final int limit) {
StringBuffer sb = new StringBuffer(query.length() + 50);
StringBuilder sb = new StringBuilder(query.length() + 50);
final String normalizedSelect = query.toLowerCase().trim();
final int forUpdateIndex = normalizedSelect.lastIndexOf( "for update") ;

View File

@ -221,7 +221,7 @@ public class H2Dialect extends Dialect {
}
public String getLimitString(String sql, boolean hasOffset) {
return new StringBuffer( sql.length() + 20 )
return new StringBuilder( sql.length() + 20 )
.append( sql )
.append( hasOffset ? " limit ? offset ?" : " limit ?" )
.toString();

View File

@ -257,7 +257,7 @@ public class HSQLDialect extends Dialect {
public String getLimitString(String sql, boolean hasOffset) {
if ( hsqldbVersion < 20 ) {
return new StringBuffer( sql.length() + 10 )
return new StringBuilder( sql.length() + 10 )
.append( sql )
.insert(
sql.toLowerCase().indexOf( "select" ) + 6,
@ -266,7 +266,7 @@ public class HSQLDialect extends Dialect {
.toString();
}
else {
return new StringBuffer( sql.length() + 20 )
return new StringBuilder( sql.length() + 20 )
.append( sql )
.append( hasOffset ? " offset ? limit ?" : " limit ?" )
.toString();

View File

@ -110,7 +110,7 @@ public class InformixDialect extends Dialect {
String referencedTable,
String[] primaryKey,
boolean referencesPrimaryKey) {
StringBuffer result = new StringBuffer( 30 )
StringBuilder result = new StringBuilder( 30 )
.append( " add constraint " )
.append( " foreign key (" )
.append( StringHelper.join( ", ", foreignKey ) )
@ -180,7 +180,7 @@ public class InformixDialect extends Dialect {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuffer( querySelect.length() + 8 )
return new StringBuilder( querySelect.length() + 8 )
.append( querySelect )
.insert( querySelect.toLowerCase().indexOf( "select" ) + 6, " first " + limit )
.toString();

View File

@ -237,9 +237,9 @@ public class Ingres9Dialect extends IngresDialect {
* @return the modified SQL
*/
public String getLimitString(String querySelect, int offset, int limit) {
StringBuffer soff = new StringBuffer(" offset " + offset);
StringBuffer slim = new StringBuffer(" fetch first " + limit + " rows only");
StringBuffer sb = new StringBuffer(querySelect.length() +
StringBuilder soff = new StringBuilder(" offset " + offset);
StringBuilder slim = new StringBuilder(" fetch first " + limit + " rows only");
StringBuilder sb = new StringBuilder(querySelect.length() +
soff.length() + slim.length()).append(querySelect);
if (offset > 0) {
sb.append(soff);

View File

@ -288,7 +288,7 @@ public class IngresDialect extends Dialect {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuffer( querySelect.length() + 16 )
return new StringBuilder( querySelect.length() + 16 )
.append( querySelect )
.insert( 6, " first " + limit )
.toString();

View File

@ -211,7 +211,7 @@ public class MySQLDialect extends Dialect {
String[] primaryKey, boolean referencesPrimaryKey
) {
String cols = StringHelper.join(", ", foreignKey);
return new StringBuffer(30)
return new StringBuilder(30)
.append(" add index ")
.append(constraintName)
.append(" (")
@ -237,7 +237,7 @@ public class MySQLDialect extends Dialect {
}
public String getLimitString(String sql, boolean hasOffset) {
return new StringBuffer( sql.length() + 20 )
return new StringBuilder( sql.length() + 20 )
.append( sql )
.append( hasOffset ? " limit ?, ?" : " limit ?" )
.toString();

View File

@ -245,7 +245,7 @@ public class Oracle8iDialect extends Dialect {
isForUpdate = true;
}
StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
StringBuilder pagingSelect = new StringBuilder( sql.length()+100 );
if (hasOffset) {
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
}

View File

@ -219,7 +219,7 @@ public class Oracle9Dialect extends Dialect {
isForUpdate = true;
}
StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
StringBuilder pagingSelect = new StringBuilder( sql.length()+100 );
if (hasOffset) {
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
}

View File

@ -72,7 +72,7 @@ public class OracleDialect extends Oracle9Dialect {
isForUpdate = true;
}
StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
StringBuilder pagingSelect = new StringBuilder( sql.length()+100 );
if (hasOffset) {
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
}

View File

@ -321,7 +321,7 @@ public class RDMSOS2200Dialect extends Dialect {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuffer( sql.length() + 40 )
return new StringBuilder( sql.length() + 40 )
.append( sql )
.append( " fetch first " )
.append( limit )

View File

@ -151,7 +151,7 @@ public class SAPDBDialect extends Dialect {
String referencedTable,
String[] primaryKey, boolean referencesPrimaryKey
) {
StringBuffer res = new StringBuffer(30)
StringBuilder res = new StringBuilder(30)
.append(" foreign key ")
.append(constraintName)
.append(" (")

View File

@ -75,7 +75,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuffer( querySelect.length() + 8 )
return new StringBuilder( querySelect.length() + 8 )
.append( querySelect )
.insert( getAfterSelectInsertPoint( querySelect ), " top " + limit )
.toString();

View File

@ -184,7 +184,7 @@ public class TimesTenDialect extends Dialect {
if ( offset > 0 ) {
throw new UnsupportedOperationException( "query result offset is not supported" );
}
return new StringBuffer( querySelect.length() + 8 )
return new StringBuilder( querySelect.length() + 8 )
.append( querySelect )
.insert( 6, " first " + limit )
.toString();

View File

@ -31,7 +31,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
*/
public class AnsiTrimFunction extends TrimFunctionTemplate {
protected String render(Options options, String trimSource, SessionFactoryImplementor factory) {
return new StringBuffer()
return new StringBuilder()
.append( "trim(" )
.append( options.getTrimSpecification().getName() )
.append( ' ' )

View File

@ -53,7 +53,7 @@ public class CharIndexFunction implements SQLFunction {
Object string = args.get(1);
Object start = threeArgs ? args.get(2) : null;
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("charindex(").append( pattern ).append(", ");
if (threeArgs) buf.append( "right(");
buf.append( string );

View File

@ -49,7 +49,7 @@ public class ConditionalParenthesisFunction extends StandardSQLFunction {
public String render(List args, SessionFactoryImplementor factory) {
final boolean hasArgs = !args.isEmpty();
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append( getName() );
if ( hasArgs ) {
buf.append( "(" );

View File

@ -165,7 +165,7 @@ public class DerbyConcatFunction implements SQLFunction {
private static String join(Iterator/*<String>*/ elements, StringTransformer elementTransformer, StringJoinTemplate template) {
// todo : make this available via StringHelper?
StringBuffer buffer = new StringBuffer( template.getBeginning() );
StringBuilder buffer = new StringBuilder( template.getBeginning() );
while ( elements.hasNext() ) {
final String element = ( String ) elements.next();
buffer.append( elementTransformer.transform( element ) );

View File

@ -53,7 +53,7 @@ public class PositionSubstringFunction implements SQLFunction {
Object string = args.get(1);
Object start = threeArgs ? args.get(2) : null;
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (threeArgs) buf.append('(');
buf.append("position(").append( pattern ).append(" in ");
if (threeArgs) buf.append( "substring(");

View File

@ -62,7 +62,7 @@ public class StandardAnsiSqlAggregationFunctions {
}
private String renderCountDistinct(List arguments) {
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
buffer.append( "count(distinct " );
String sep = "";
Iterator itr = arguments.iterator();

View File

@ -49,8 +49,8 @@ public class TemplateRenderer {
List<String> chunkList = new ArrayList<String>();
List<Integer> paramList = new ArrayList<Integer>();
StringBuffer chunk = new StringBuffer( 10 );
StringBuffer index = new StringBuffer( 2 );
StringBuilder chunk = new StringBuilder( 10 );
StringBuilder index = new StringBuilder( 2 );
for ( int i = 0; i < template.length(); ++i ) {
char c = template.charAt( i );

View File

@ -99,7 +99,7 @@ public class VarArgsSQLFunction implements SQLFunction {
}
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) {
StringBuffer buf = new StringBuffer().append( begin );
StringBuilder buf = new StringBuilder().append( begin );
for ( int i = 0; i < arguments.size(); i++ ) {
buf.append( transformArgument( ( String ) arguments.get( i ) ) );
if ( i < arguments.size() - 1 ) {

View File

@ -46,7 +46,7 @@ public class JoinSequence {
private final SessionFactoryImplementor factory;
private final List<Join> joins = new ArrayList<Join>();
private boolean useThetaStyle = false;
private final StringBuffer conditions = new StringBuffer();
private final StringBuilder conditions = new StringBuilder();
private String rootAlias;
private Joinable rootJoinable;
private Selector selector;

View File

@ -1134,7 +1134,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
*/
@Override
public String toString() {
return new StringBuffer()
return new StringBuilder()
.append("PersistenceContext[entityKeys=")
.append(entitiesByKey.keySet())
.append(",collectionKeys=")

View File

@ -100,7 +100,7 @@ public class ResultSetWrapperProxy implements InvocationHandler {
);
}
catch ( SQLException ex ) {
StringBuffer buf = new StringBuffer()
StringBuilder buf = new StringBuilder()
.append( "Exception getting column index for column: [" )
.append( args[0] )
.append( "].\nReverting to using: [" )

View File

@ -106,7 +106,7 @@ public class BasicFormatterImpl implements Formatter {
int indent = 1;
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
StringTokenizer tokens;
String lastToken;
String token;

View File

@ -61,7 +61,7 @@ public class DDLFormatterImpl implements Formatter {
}
private String formatCommentOn(String sql) {
StringBuffer result = new StringBuffer( 60 ).append( "\n " );
StringBuilder result = new StringBuilder( 60 ).append( "\n " );
StringTokenizer tokens = new StringTokenizer( sql, " '[]\"", true );
boolean quoted = false;
@ -82,7 +82,7 @@ public class DDLFormatterImpl implements Formatter {
}
private String formatAlterTable(String sql) {
StringBuffer result = new StringBuffer( 60 ).append( "\n " );
StringBuilder result = new StringBuilder( 60 ).append( "\n " );
StringTokenizer tokens = new StringTokenizer( sql, " (,)'[]\"", true );
boolean quoted = false;
@ -103,7 +103,7 @@ public class DDLFormatterImpl implements Formatter {
}
private String formatCreateTable(String sql) {
StringBuffer result = new StringBuffer( 60 ).append( "\n " );
StringBuilder result = new StringBuilder( 60 ).append( "\n " );
StringTokenizer tokens = new StringTokenizer( sql, "(,)'[]\"", true );
int depth = 0;

View File

@ -182,7 +182,7 @@ public class SqlExceptionHelper {
*/
public static abstract class WarningHandlerLoggingSupport implements WarningHandler {
public final void handleWarning( SQLWarning warning ) {
StringBuffer buf = new StringBuffer(30).append("SQL Warning Code: ").append(warning.getErrorCode()).append(", SQLState: ").append(warning.getSQLState());
StringBuilder buf = new StringBuilder(30).append("SQL Warning Code: ").append(warning.getErrorCode()).append(", SQLState: ").append(warning.getSQLState());
logWarning(buf.toString(), warning.getMessage());
}

View File

@ -472,7 +472,7 @@ public final class QueryParameters {
}
else {
final Dialect dialect = factory.getDialect();
String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
String symbols = new StringBuilder().append( ParserHelper.HQL_SEPARATORS )
.append( dialect.openQuote() )
.append( dialect.closeQuote() )
.toString();

View File

@ -82,7 +82,7 @@ public class SubselectFetch {
StringHelper.qualify( alias, loadable.getIdentifierColumnNames() ) :
( (PropertyMapping) loadable ).toColumns(alias, ukname);
return new StringBuffer()
return new StringBuilder()
.append("select ")
.append( StringHelper.join(", ", joinColumns) )
.append(queryString)

View File

@ -52,7 +52,7 @@ public final class CollectionSubqueryFactory {
String[] columns) {
try {
JoinFragment join = joinSequence.toJoinFragment( enabledFilters, true );
return new StringBuffer( "select " )
return new StringBuilder( "select " )
.append( StringHelper.join( ", ", columns ) )
.append( " from " )
.append( join.toFromFragmentString().substring( 2 ) )// remove initial ", "

View File

@ -52,7 +52,7 @@ public final class NameGenerator {
}
public static String scalarName(int x, int y) {
return new StringBuffer()
return new StringBuilder()
.append( "col_" )
.append( x )
.append( '_' )

View File

@ -85,7 +85,7 @@ public final class QuerySplitter {
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 );
StringBuilder templateQuery = new StringBuilder( 40 );
int start = getStartingPositionFor(tokens, templateQuery);
int count = 0;
@ -137,7 +137,7 @@ public final class QuerySplitter {
return tokens[tokens.length - 1];
}
private static int getStartingPositionFor(String[] tokens, StringBuffer templateQuery) {
private static int getStartingPositionFor(String[] tokens, StringBuilder templateQuery) {
templateQuery.append( tokens[0] );
if ( !"select".equals( tokens[0].toLowerCase() ) ) return 1;

View File

@ -65,7 +65,7 @@ public class ErrorCounter implements ParseErrorHandler {
}
private String getErrorString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) {
buf.append( ( String ) iterator.next() );
if ( iterator.hasNext() ) buf.append( "\n" );

View File

@ -38,7 +38,7 @@ public abstract class AbstractStatement extends HqlSqlWalkerNode implements Disp
* @return String - The additional display text.
*/
public String getDisplayText() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if ( getWalker().getQuerySpaces().size() > 0 ) {
buf.append( " querySpaces (" );
for ( Iterator iterator = getWalker().getQuerySpaces().iterator(); iterator.hasNext(); ) {

View File

@ -57,7 +57,7 @@ public class ComponentJoin extends FromElement {
initializeComponentJoin( new ComponentFromElementType( this ) );
final String[] cols = origin.getPropertyMapping( "" ).toColumns( getTableAlias(), componentProperty );
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for ( int j = 0; j < cols.length; j++ ) {
final String column = cols[j];
if ( j > 0 ) {
@ -147,7 +147,7 @@ public class ComponentJoin extends FromElement {
@Override
public String renderScalarIdentifierSelect(int i) {
String[] cols = getBasePropertyMapping().toColumns( getTableAlias(), getComponentProperty() );
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
// For property references generate <tablealias>.<columnname> as <projectionalias>
for ( int j = 0; j < cols.length; j++ ) {
final String column = cols[j];

View File

@ -139,7 +139,7 @@ class FromElementType {
String renderScalarIdentifierSelect(int i) {
checkInitialized();
String[] cols = getPropertyMapping( EntityPersister.ENTITY_ID ).toColumns( getTableAlias(), EntityPersister.ENTITY_ID );
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
// For property references generate <tablealias>.<columnname> as <projectionalias>
for ( int j = 0; j < cols.length; j++ ) {
String column = cols[j];
@ -165,7 +165,7 @@ class FromElementType {
// TODO: Replace this with a more elegant solution.
String[] idColumnNames = ( persister != null ) ?
( ( Queryable ) persister ).getIdentifierColumnNames() : new String[0];
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for ( int i = 0; i < idColumnNames.length; i++ ) {
buf.append( fromElement.getTableAlias() ).append( '.' ).append( idColumnNames[i] );
if ( i != idColumnNames.length - 1 ) buf.append( ", " );

View File

@ -76,7 +76,7 @@ public abstract class FromReferenceNode extends AbstractSelectExpression
}
public String getDisplayText() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append( "{" ).append( ( fromElement == null ) ? "no fromElement" : fromElement.getDisplayText() );
buf.append( "}" );
return buf.toString();

View File

@ -318,7 +318,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
@Override
public String getDisplayText() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (getType() == SqlTokenTypes.ALIAS_REF) {
buf.append("{alias=").append(getOriginalText());

View File

@ -205,7 +205,7 @@ public class IndexNode extends FromReferenceNode {
}
private String collectDisplayInfo() {
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
Iterator itr = paramSpecs.iterator();
while ( itr.hasNext() ) {
buffer.append( ( ( ParameterSpecification ) itr.next() ).renderDisplayInfo() );

View File

@ -138,7 +138,7 @@ public class IntoClause extends HqlSqlWalkerNode implements DisplayableNode {
* @return String - The additional display text.
*/
public String getDisplayText() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append( "IntoClause{" );
buf.append( "entityName=" ).append( getEntityName() );
buf.append( ",tableName=" ).append( getTableName() );

View File

@ -59,7 +59,7 @@ public class ParameterNode extends HqlSqlWalkerNode implements DisplayableNode,
public String getRenderText(SessionFactoryImplementor sessionFactory) {
int count = 0;
if ( getExpectedType() != null && ( count = getExpectedType().getColumnSpan( sessionFactory ) ) > 1 ) {
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
buffer.append( "(?" );
for ( int i = 1; i < count; i++ ) {
buffer.append( ", ?" );

View File

@ -77,7 +77,7 @@ public class ResultVariableRefNode extends HqlSqlWalkerNode {
private String getColumnPositionsString(int scalarColumnIndex ) {
int startPosition = getWalker().getSelectClause().getColumnNamesStartPosition( scalarColumnIndex );
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
int nColumns = getWalker().getSelectClause().getColumnNames()[ scalarColumnIndex ].length;
for ( int i = startPosition; i < startPosition + nColumns; i++ ) {
if ( i > startPosition ) {

View File

@ -187,7 +187,7 @@ public class ASTPrinter {
if ( ast == null ) {
return "{node:null}";
}
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append( "[" ).append( getTokenTypeName( ast.getType() ) ).append( "] " );
if ( showClassName ) {
buf.append( StringHelper.unqualify( ast.getClass().getName() ) ).append( ": " );
@ -208,7 +208,7 @@ public class ASTPrinter {
return buf.toString();
}
public static void appendEscapedMultibyteChars(String text, StringBuffer buf) {
public static void appendEscapedMultibyteChars(String text, StringBuilder buf) {
char[] chars = text.toCharArray();
for (int i = 0; i < chars.length; i++) {
char aChar = chars[i];
@ -222,7 +222,7 @@ public class ASTPrinter {
}
public static String escapeMultibyteChars(String text) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
appendEscapedMultibyteChars(text,buf);
return buf.toString();
}

View File

@ -220,7 +220,7 @@ public final class ASTUtil {
* @return The list representation of the tree.
*/
public static String getDebugString(AST n) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append( "[ " );
buf.append( ( n == null ) ? "{null}" : n.toStringTree() );
buf.append( " ]" );
@ -267,12 +267,12 @@ public final class ASTUtil {
}
public static String getPathText(AST n) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
getPathText( buf, n );
return buf.toString();
}
private static void getPathText(StringBuffer buf, AST n) {
private static void getPathText(StringBuilder buf, AST n) {
AST firstChild = n.getFirstChild();
// If the node has a first child, recurse into the first child.
if ( firstChild != null ) {

View File

@ -209,12 +209,12 @@ public class JoinProcessor implements SqlTokenTypes {
}
Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
String symbols = new StringBuilder().append( ParserHelper.HQL_SEPARATORS )
.append( dialect.openQuote() )
.append( dialect.closeQuote() )
.toString();
StringTokenizer tokens = new StringTokenizer( sqlFragment, symbols, true );
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
while ( tokens.hasMoreTokens() ) {
final String token = tokens.nextToken();

View File

@ -65,9 +65,9 @@ public class PathExpressionParser implements Parser {
private String collectionName;
private String collectionOwnerName;
private String collectionRole;
private final StringBuffer componentPath = new StringBuffer();
private final StringBuilder componentPath = new StringBuilder();
private Type type;
private final StringBuffer path = new StringBuffer();
private final StringBuilder path = new StringBuilder();
private boolean ignoreInitialJoin;
private boolean continuation;
private JoinType joinType = JoinType.INNER_JOIN; //default mode
@ -261,7 +261,7 @@ public class PathExpressionParser implements Parser {
}
else {
if ( componentPath.length() > 0 ) {
return new StringBuffer()
return new StringBuilder()
.append( currentProperty )
.append( '.' )
.append( componentPath.toString() )
@ -384,7 +384,7 @@ public class PathExpressionParser implements Parser {
String alias;
String[] elementColumns;
JoinSequence joinSequence;
StringBuffer indexValue = new StringBuffer();
StringBuilder indexValue = new StringBuilder();
}
public CollectionElement lastCollectionElement() {

View File

@ -60,7 +60,7 @@ public class PreprocessingParser implements Parser {
private Map replacements;
private boolean quoted;
private StringBuffer quotedString;
private StringBuilder quotedString;
private ClauseParser parser = new ClauseParser();
private String lastToken;
private String currentCollectionProp;
@ -80,7 +80,7 @@ public class PreprocessingParser implements Parser {
token = quotedString.toString();
}
else {
quotedString = new StringBuffer( 20 ).append( token );
quotedString = new StringBuilder( 20 ).append( token );
}
quoted = !quoted;
}

View File

@ -712,7 +712,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator
boolean isSubselect = superQuery != null;
StringBuffer buf = new StringBuffer( 20 );
StringBuilder buf = new StringBuilder( 20 );
if ( scalarTypes.size() == 0 ) {
//ie. no select clause

View File

@ -178,7 +178,7 @@ public class WhereParser implements Parser {
private boolean inSubselect = false;
private int bracketsSinceSelect = 0;
private StringBuffer subselect;
private StringBuilder subselect;
private boolean expectingPathContinuation = false;
private int expectingIndex = 0;
@ -233,7 +233,7 @@ public class WhereParser implements Parser {
//Cope with a subselect
if ( !inSubselect && ( lcToken.equals( "select" ) || lcToken.equals( "from" ) ) ) {
inSubselect = true;
subselect = new StringBuffer( 20 );
subselect = new StringBuilder( 20 );
}
if ( inSubselect && token.equals( ")" ) ) {
bracketsSinceSelect--;
@ -323,8 +323,8 @@ public class WhereParser implements Parser {
}
else {
StringBuffer join = ( StringBuffer ) joins.removeLast();
( ( StringBuffer ) joins.getLast() ).append( join.toString() );
StringBuilder join = ( StringBuilder ) joins.removeLast();
( ( StringBuilder ) joins.getLast() ).append( join.toString() );
}
if ( nots.removeLast() ) negated = !negated;
@ -335,7 +335,7 @@ public class WhereParser implements Parser {
private void openExpression(QueryTranslatorImpl q, String lcToken) {
nots.addLast( Boolean.FALSE );
booleanTests.addLast( Boolean.FALSE );
joins.addLast( new StringBuffer() );
joins.addLast( new StringBuilder() );
if ( !"(".equals( lcToken ) ) appendToken( q, "(" );
}
@ -454,7 +454,7 @@ public class WhereParser implements Parser {
}
private void addToCurrentJoin(String sql) {
( ( StringBuffer ) joins.getLast() ).append( sql );
( ( StringBuilder ) joins.getLast() ).append( sql );
}
private void addToCurrentJoin(PathExpressionParser.CollectionElement ce)

View File

@ -99,7 +99,7 @@ public class IncrementGenerator implements IdentifierGenerator, Configurable {
)
);
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for ( int i=0; i < tables.length; i++ ) {
final String tableName = dialect.quote( normalizer.normalizeIdentifierQuoting( tables[i] ) );
if ( tables.length > 1 ) {

View File

@ -134,7 +134,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
}
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
StringBuffer sqlDropString = new StringBuffer( "drop table " );
StringBuilder sqlDropString = new StringBuilder( "drop table " );
if ( dialect.supportsIfExistsBeforeTableName() ) {
sqlDropString.append( "if exists " );
}

View File

@ -207,7 +207,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
}
public String[] sqlDropStrings(Dialect dialect) {
StringBuffer sqlDropString = new StringBuffer( "drop table " );
StringBuilder sqlDropString = new StringBuilder( "drop table " );
if ( dialect.supportsIfExistsBeforeTableName() ) {
sqlDropString.append( "if exists " );
}

View File

@ -71,7 +71,7 @@ public class UUIDHexGenerator extends AbstractUUIDGenerator implements Configura
* {@inheritDoc}
*/
public Serializable generate(SessionImplementor session, Object obj) {
return new StringBuffer( 36 )
return new StringBuilder( 36 )
.append( format( getIP() ) ).append( sep )
.append( format( getJVM() ) ).append( sep )
.append( format( getHiTime() ) ).append( sep )
@ -82,14 +82,14 @@ public class UUIDHexGenerator extends AbstractUUIDGenerator implements Configura
protected String format(int intValue) {
String formatted = Integer.toHexString( intValue );
StringBuffer buf = new StringBuffer( "00000000" );
StringBuilder buf = new StringBuilder( "00000000" );
buf.replace( 8 - formatted.length(), 8, formatted );
return buf.toString();
}
protected String format(short shortValue) {
String formatted = Integer.toHexString( shortValue );
StringBuffer buf = new StringBuffer( "0000" );
StringBuilder buf = new StringBuilder( "0000" );
buf.replace( 4 - formatted.length(), 4, formatted );
return buf.toString();
}

View File

@ -549,7 +549,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
@Override
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
return new String[] {
new StringBuffer()
new StringBuilder()
.append( dialect.getCreateTableString() )
.append( ' ' )
.append( tableName )

View File

@ -187,7 +187,7 @@ public class TableStructure implements DatabaseStructure {
@Override
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
StringBuffer sqlDropString = new StringBuffer().append( "drop table " );
StringBuilder sqlDropString = new StringBuilder().append( "drop table " );
if ( dialect.supportsIfExistsBeforeTableName() ) {
sqlDropString.append( "if exists " );
}

View File

@ -118,14 +118,14 @@ public class Helper {
public static String format(int value) {
final String formatted = Integer.toHexString( value );
StringBuffer buf = new StringBuffer( "00000000".intern() );
StringBuilder buf = new StringBuilder( "00000000" );
buf.replace( 8 - formatted.length(), 8, formatted );
return buf.toString();
}
public static String format(short value) {
String formatted = Integer.toHexString( value );
StringBuffer buf = new StringBuffer( "0000" );
StringBuilder buf = new StringBuilder( "0000" );
buf.replace( 4 - formatted.length(), 4, formatted );
return buf.toString();
}
@ -139,7 +139,7 @@ public class Helper {
System.out.println( "ip address int : " + addressInt );
String formatted = Integer.toHexString( addressInt );
StringBuffer buf = new StringBuffer( "00000000" );
StringBuilder buf = new StringBuilder( "00000000" );
buf.replace( 8 - formatted.length(), 8, formatted );
String addressHex = buf.toString();
System.out.println( "ip address hex : " + addressHex );

View File

@ -754,7 +754,7 @@ public abstract class AbstractQueryImpl implements Query {
boolean isJpaPositionalParam = parameterMetadata.getNamedParameterDescriptor( name ).isJpaStyle();
String paramPrefix = isJpaPositionalParam ? "?" : ParserHelper.HQL_VARIABLE_PREFIX;
String placeholder =
new StringBuffer( paramPrefix.length() + name.length() )
new StringBuilder( paramPrefix.length() + name.length() )
.append( paramPrefix ).append( name )
.toString();
@ -783,7 +783,7 @@ public abstract class AbstractQueryImpl implements Query {
return query;
}
StringBuffer list = new StringBuffer( 16 );
StringBuilder list = new StringBuilder( 16 );
Iterator iter = vals.iterator();
int i = 0;
while ( iter.hasNext() ) {

View File

@ -1782,7 +1782,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
}
public String toString() {
StringBuffer buf = new StringBuffer(500)
StringBuilder buf = new StringBuilder(500)
.append( "SessionImpl(" );
if ( !isClosed() ) {
buf.append(persistenceContext)

View File

@ -122,21 +122,21 @@ public final class BytesHelper {
if ( formatted.length() > 8 ) {
formatted = formatted.substring( formatted.length() - 8 );
}
StringBuffer buf = new StringBuffer( "00000000" );
StringBuilder buf = new StringBuilder( "00000000" );
buf.replace( 8 - formatted.length(), 8, formatted );
return buf.toString();
}
public static String toBinaryString(int value) {
String formatted = Long.toBinaryString( value );
StringBuffer buf = new StringBuffer( StringHelper.repeat( '0', 32 ) );
StringBuilder buf = new StringBuilder( StringHelper.repeat( '0', 32 ) );
buf.replace( 64 - formatted.length(), 64, formatted );
return buf.toString();
}
public static String toBinaryString(long value) {
String formatted = Long.toBinaryString( value );
StringBuffer buf = new StringBuffer( StringHelper.repeat( '0', 64 ) );
StringBuilder buf = new StringBuilder( StringHelper.repeat( '0', 64 ) );
buf.replace( 64 - formatted.length(), 64, formatted );
return buf.toString();
}

View File

@ -201,7 +201,7 @@ public final class ArrayHelper {
private ArrayHelper() {}
public static String toString( Object[] array ) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < array.length; i++) {
sb.append( array[i] );

View File

@ -334,7 +334,7 @@ public final class ConfigurationHelper {
if ( property.indexOf( PLACEHOLDER_START ) < 0 ) {
return property;
}
StringBuffer buff = new StringBuffer();
StringBuilder buff = new StringBuilder();
char[] chars = property.toCharArray();
for ( int pos = 0; pos < chars.length; pos++ ) {
if ( chars[pos] == '$' ) {

View File

@ -898,7 +898,7 @@ public class JoinWalker {
*/
protected static final String orderBy(List associations)
throws MappingException {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
Iterator iter = associations.iterator();
OuterJoinableAssociation last = null;
while ( iter.hasNext() ) {
@ -934,13 +934,13 @@ public class JoinWalker {
/**
* Render the where condition for a (batch) load by identifier / collection key
*/
protected StringBuffer whereString(String alias, String[] columnNames, int batchSize) {
protected StringBuilder whereString(String alias, String[] columnNames, int batchSize) {
if ( columnNames.length==1 ) {
// if not a composite key, use "foo in (?, ?, ?)" for batching
// if no batch, and not a composite key, use "foo = ?"
InFragment in = new InFragment().setColumn( alias, columnNames[0] );
for ( int i=0; i<batchSize; i++ ) in.addValue("?");
return new StringBuffer( in.toFragmentString() );
return new StringBuilder( in.toFragmentString() );
}
else {
//a composite key
@ -948,7 +948,7 @@ public class JoinWalker {
.setTableAlias(alias)
.setCondition( columnNames, "?" );
StringBuffer whereString = new StringBuffer();
StringBuilder whereString = new StringBuilder();
if ( batchSize==1 ) {
// if no batch, use "foo = ? and bar = ?"
whereString.append( byId.toFragmentString() );
@ -1053,7 +1053,7 @@ public class JoinWalker {
return "";
}
else {
StringBuffer buf = new StringBuffer( associations.size() * 100 );
StringBuilder buf = new StringBuilder( associations.size() * 100 );
int entityAliasCount=0;
int collectionAliasCount=0;
for ( int i=0; i<associations.size(); i++ ) {

View File

@ -87,7 +87,7 @@ public class BasicCollectionJoinWalker extends CollectionJoinWalker {
suffixes = BasicLoader.generateSuffixes( joins );
collectionSuffixes = BasicLoader.generateSuffixes( joins, collectionJoins );
StringBuffer whereString = whereString(
StringBuilder whereString = whereString(
alias,
collectionPersister.getKeyColumnNames(),
subquery,

View File

@ -42,12 +42,12 @@ public abstract class CollectionJoinWalker extends JoinWalker {
super( factory, loadQueryInfluencers );
}
protected StringBuffer whereString(String alias, String[] columnNames, String subselect, int batchSize) {
protected StringBuilder whereString(String alias, String[] columnNames, String subselect, int batchSize) {
if (subselect==null) {
return super.whereString(alias, columnNames, batchSize);
}
else {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (columnNames.length>1) buf.append('(');
buf.append( StringHelper.join(", ", StringHelper.qualify(alias, columnNames) ) );
if (columnNames.length>1) buf.append(')');

View File

@ -97,7 +97,7 @@ public class OneToManyJoinWalker extends CollectionJoinWalker {
final int collectionJoins = countCollectionPersisters( associations ) + 1;
collectionSuffixes = BasicLoader.generateSuffixes( joins + 1, collectionJoins );
StringBuffer whereString = whereString(
StringBuilder whereString = whereString(
alias,
oneToManyPersister.getKeyColumnNames(),
subquery,

View File

@ -412,7 +412,7 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
}
public String getWhereCondition() {
StringBuffer condition = new StringBuffer( 30 );
StringBuilder condition = new StringBuilder( 30 );
Iterator criterionIterator = rootCriteria.iterateExpressionEntries();
while ( criterionIterator.hasNext() ) {
CriteriaImpl.CriterionEntry entry = ( CriteriaImpl.CriterionEntry ) criterionIterator.next();
@ -426,7 +426,7 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
}
public String getOrderBy() {
StringBuffer orderBy = new StringBuffer( 30 );
StringBuilder orderBy = new StringBuilder( 30 );
Iterator criterionIterator = rootCriteria.iterateOrderings();
while ( criterionIterator.hasNext() ) {
CriteriaImpl.OrderEntry oe = ( CriteriaImpl.OrderEntry ) criterionIterator.next();

View File

@ -43,7 +43,7 @@ public class CascadeEntityJoinWalker extends AbstractEntityJoinWalker {
throws MappingException {
super( persister, factory, LoadQueryInfluencers.NONE );
this.cascadeAction = action;
StringBuffer whereCondition = whereString( getAlias(), persister.getIdentifierColumnNames(), 1 )
StringBuilder whereCondition = whereString( getAlias(), persister.getIdentifierColumnNames(), 1 )
//include the discriminator and class-level where, but not filters
.append( persister.filterFragment( getAlias(), CollectionHelper.EMPTY_MAP ) );

View File

@ -67,7 +67,7 @@ public class EntityJoinWalker extends AbstractEntityJoinWalker {
this.lockOptions.setLockMode(lockMode);
StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
StringBuilder whereCondition = whereString( getAlias(), uniqueKey, batchSize )
//include the discriminator and class-level where, but not filters
.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
@ -86,7 +86,7 @@ public class EntityJoinWalker extends AbstractEntityJoinWalker {
super( persister, factory, loadQueryInfluencers );
LockOptions.copy(lockOptions, this.lockOptions);
StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
StringBuilder whereCondition = whereString( getAlias(), uniqueKey, batchSize )
//include the discriminator and class-level where, but not filters
.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );

View File

@ -98,7 +98,7 @@ public abstract class Constraint implements RelationalModel, Serializable {
public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) {
if ( isGenerated( dialect ) ) {
return new StringBuffer()
return new StringBuilder()
.append( "alter table " )
.append( getTable().getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
.append( " drop constraint " )
@ -113,7 +113,7 @@ public abstract class Constraint implements RelationalModel, Serializable {
public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog, String defaultSchema) {
if ( isGenerated( dialect ) ) {
String constraintString = sqlConstraintString( dialect, getName(), defaultCatalog, defaultSchema );
StringBuffer buf = new StringBuffer( "alter table " )
StringBuilder buf = new StringBuilder( "alter table " )
.append( getTable().getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
.append( constraintString );
return buf.toString();

View File

@ -70,7 +70,7 @@ public class ForeignKey extends Constraint {
return referencedTable;
}
private void appendColumns(StringBuffer buf, Iterator columns) {
private void appendColumns(StringBuilder buf, Iterator columns) {
while( columns.hasNext() ) {
Column column = (Column) columns.next();
buf.append( column.getName() );
@ -95,7 +95,7 @@ public class ForeignKey extends Constraint {
private void alignColumns(Table referencedTable) {
if ( referencedTable.getPrimaryKey().getColumnSpan()!=getColumnSpan() ) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("Foreign key (")
.append( getName() + ":")
.append( getTable().getName() )
@ -170,7 +170,7 @@ public class ForeignKey extends Constraint {
public String toString() {
if(!isReferenceToPrimaryKey() ) {
StringBuffer result = new StringBuffer(getClass().getName() + '(' + getTable().getName() + getColumns() );
StringBuilder result = new StringBuilder(getClass().getName() + '(' + getTable().getName() + getColumns() );
result.append( " ref-columns:" + '(' + getReferencedColumns() );
result.append( ") as " + getName() );
return result.toString();

View File

@ -80,7 +80,7 @@ public class Index implements RelationalModel, Serializable {
String defaultSchema
) {
//TODO handle supportsNotNullUnique=false, but such a case does not exist in the wild so far
StringBuffer buf = new StringBuffer( "create" )
StringBuilder buf = new StringBuilder( "create" )
.append( unique ?
" unique" :
"" )
@ -103,7 +103,7 @@ public class Index implements RelationalModel, Serializable {
// Used only in Table for sqlCreateString (but commented out at the moment)
public String sqlConstraintString(Dialect dialect) {
StringBuffer buf = new StringBuffer( " index (" );
StringBuilder buf = new StringBuilder( " index (" );
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
buf.append( ( (Column) iter.next() ).getQuotedName( dialect ) );

View File

@ -33,7 +33,7 @@ import org.hibernate.dialect.Dialect;
public class PrimaryKey extends Constraint {
public String sqlConstraintString(Dialect dialect) {
StringBuffer buf = new StringBuffer("primary key (");
StringBuilder buf = new StringBuilder("primary key (");
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
buf.append( ( (Column) iter.next() ).getQuotedName(dialect) );
@ -43,7 +43,7 @@ public class PrimaryKey extends Constraint {
}
public String sqlConstraintString(Dialect dialect, String constraintName, String defaultCatalog, String defaultSchema) {
StringBuffer buf = new StringBuffer(
StringBuilder buf = new StringBuilder(
dialect.getAddPrimaryKeyConstraintString(constraintName)
).append('(');
Iterator iter = getColumnIterator();

View File

@ -164,7 +164,7 @@ public class SimpleValue implements KeyValue {
params.setProperty( PersistentIdentifierGenerator.PK, columnName );
if (rootClass!=null) {
StringBuffer tables = new StringBuffer();
StringBuilder tables = new StringBuilder();
Iterator iter = rootClass.getIdentityTables().iterator();
while ( iter.hasNext() ) {
Table table= (Table) iter.next();

View File

@ -122,7 +122,7 @@ public class Table implements RelationalModel, Serializable {
}
public static String qualify(String catalog, String schema, String table) {
StringBuffer qualifiedName = new StringBuffer();
StringBuilder qualifiedName = new StringBuilder();
if ( catalog != null ) {
qualifiedName.append( catalog ).append( '.' );
}
@ -296,7 +296,7 @@ public class Table implements RelationalModel, Serializable {
String defaultSchema)
throws HibernateException {
StringBuffer root = new StringBuffer( "alter table " )
StringBuilder root = new StringBuilder( "alter table " )
.append( getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
.append( ' ' )
.append( dialect.getAddColumnString() );
@ -310,7 +310,7 @@ public class Table implements RelationalModel, Serializable {
if ( columnInfo == null ) {
// the column doesnt exist at all.
StringBuffer alter = new StringBuffer( root.toString() )
StringBuilder alter = new StringBuilder( root.toString() )
.append( ' ' )
.append( column.getQuotedName( dialect ) )
.append( ' ' )
@ -359,7 +359,7 @@ public class Table implements RelationalModel, Serializable {
}
public String sqlTemporaryTableCreateString(Dialect dialect, Mapping mapping) throws HibernateException {
StringBuffer buffer = new StringBuffer( dialect.getCreateTemporaryTableString() )
StringBuilder buffer = new StringBuilder( dialect.getCreateTemporaryTableString() )
.append( ' ' )
.append( name )
.append( " (" );
@ -498,7 +498,7 @@ public class Table implements RelationalModel, Serializable {
}
public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) {
StringBuffer buf = new StringBuffer( "drop table " );
StringBuilder buf = new StringBuilder( "drop table " );
if ( dialect.supportsIfExistsBeforeTableName() ) {
buf.append( "if exists " );
}
@ -695,7 +695,7 @@ public class Table implements RelationalModel, Serializable {
}
public String toString() {
StringBuffer buf = new StringBuffer().append( getClass().getName() )
StringBuilder buf = new StringBuilder().append( getClass().getName() )
.append( '(' );
if ( getCatalog() != null ) {
buf.append( getCatalog() + "." );
@ -760,7 +760,7 @@ public class Table implements RelationalModel, Serializable {
if ( dialect.supportsCommentOn() ) {
String tableName = getQualifiedName( dialect, defaultCatalog, defaultSchema );
if ( comment != null ) {
StringBuffer buf = new StringBuffer()
StringBuilder buf = new StringBuilder()
.append( "comment on table " )
.append( tableName )
.append( " is '" )
@ -773,7 +773,7 @@ public class Table implements RelationalModel, Serializable {
Column column = (Column) iter.next();
String columnComment = column.getComment();
if ( columnComment != null ) {
StringBuffer buf = new StringBuffer()
StringBuilder buf = new StringBuilder()
.append( "comment on column " )
.append( tableName )
.append( '.' )

View File

@ -35,7 +35,7 @@ import org.hibernate.engine.spi.Mapping;
public class UniqueKey extends Constraint {
public String sqlConstraintString(Dialect dialect) {
StringBuffer buf = new StringBuffer( "unique (" );
StringBuilder buf = new StringBuilder( "unique (" );
boolean hadNullableColumn = false;
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
@ -60,7 +60,7 @@ public class UniqueKey extends Constraint {
String constraintName,
String defaultCatalog,
String defaultSchema) {
StringBuffer buf = new StringBuffer(
StringBuilder buf = new StringBuilder(
dialect.getAddUniqueConstraintString( constraintName )
).append( '(' );
Iterator iter = getColumnIterator();

View File

@ -96,7 +96,7 @@ public abstract class AbstractConstraint implements Constraint {
}
else {
return new String[] {
new StringBuffer()
new StringBuilder()
.append( "alter table " )
.append( getTable().getQualifiedName( dialect ) )
.append( " drop constraint " )

View File

@ -106,7 +106,7 @@ public class Index extends AbstractConstraint implements Constraint {
public String[] sqlDropStrings(Dialect dialect) {
return new String[] {
new StringBuffer( "drop index " )
new StringBuilder( "drop index " )
.append(
StringHelper.qualify(
getTable().getQualifiedName( dialect ),

View File

@ -77,7 +77,7 @@ public class PrimaryKey extends AbstractConstraint implements Constraint, Export
}
public String sqlConstraintStringInAlterTable(Dialect dialect) {
StringBuffer buf = new StringBuffer(
StringBuilder buf = new StringBuilder(
dialect.getAddPrimaryKeyConstraintString( getName() )
).append('(');
boolean first = true;

View File

@ -61,7 +61,7 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
}
public String sqlConstraintStringInCreateTable(Dialect dialect) {
StringBuffer buf = new StringBuffer( "unique (" );
StringBuilder buf = new StringBuilder( "unique (" );
boolean hadNullableColumn = false;
boolean first = true;
for ( Column column : getColumns() ) {
@ -84,7 +84,7 @@ public class UniqueKey extends AbstractConstraint implements Constraint {
@Override
public String sqlConstraintStringInAlterTable(Dialect dialect) {
StringBuffer buf = new StringBuffer(
StringBuilder buf = new StringBuilder(
dialect.getAddUniqueConstraintString( getName() )
).append( '(' );
boolean nullable = false;

View File

@ -339,7 +339,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
String entitySuffix,
String collectionSuffix,
boolean includeCollectionColumns) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if ( includeCollectionColumns ) {
// buf.append( selectFragment( lhsAlias, "" ) )//ignore suffix for collection columns!
buf.append( selectFragment( lhsAlias, collectionSuffix ) )

View File

@ -1548,7 +1548,7 @@ public abstract class AbstractEntityPersister
String fromClause = fromTableFragment( getRootAlias() ) +
fromJoinFragment( getRootAlias(), true, false );
String whereClause = new StringBuffer()
String whereClause = new StringBuilder()
.append( StringHelper.join( "=? and ", aliasedIdColumns ) )
.append( "=?" )
.append( whereJoinFragment( getRootAlias(), true, false ) )
@ -1629,7 +1629,7 @@ public abstract class AbstractEntityPersister
String fromClause = fromTableFragment( getRootAlias() ) +
fromJoinFragment( getRootAlias(), true, false );
String whereClause = new StringBuffer()
String whereClause = new StringBuilder()
.append( StringHelper.join( "=? and ",
aliasedIdColumns ) )
.append( "=?" )
@ -1891,7 +1891,7 @@ public abstract class AbstractEntityPersister
if ( tableNumber == 0 ) {
return rootAlias;
}
StringBuffer buf = new StringBuffer().append( rootAlias );
StringBuilder buf = new StringBuilder().append( rootAlias );
if ( !rootAlias.endsWith( "_" ) ) {
buf.append( '_' );
}
@ -4460,7 +4460,7 @@ public abstract class AbstractEntityPersister
select.setFromClause( fromTableFragment( getRootAlias() ) + fromJoinFragment( getRootAlias(), true, false ) );
String[] aliasedIdColumns = StringHelper.qualify( getRootAlias(), getIdentifierColumnNames() );
String whereClause = new StringBuffer()
String whereClause = new StringBuilder()
.append( StringHelper.join( "=? and ",
aliasedIdColumns ) )
.append( "=?" )

View File

@ -852,7 +852,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
if ( !queryable.isAbstract() ) frag.addValue( queryable.getDiscriminatorSQLValue() );
}
StringBuffer buf = new StringBuffer(50)
StringBuilder buf = new StringBuilder(50)
.append(" and ")
.append( frag.toFragmentString() );

View File

@ -54,7 +54,7 @@ public final class MessageHelper {
* @return An info string, in the form [FooBar#1].
*/
public static String infoString(String entityName, Serializable id) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if( entityName == null ) {
s.append( "<null entity name>" );
@ -87,7 +87,7 @@ public final class MessageHelper {
EntityPersister persister,
Object id,
SessionFactoryImplementor factory) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
Type idType;
if( persister == null ) {
@ -131,7 +131,7 @@ public final class MessageHelper {
Object id,
Type identifierType,
SessionFactoryImplementor factory) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if( persister == null ) {
s.append( "<null EntityPersister>" );
@ -164,7 +164,7 @@ public final class MessageHelper {
EntityPersister persister,
Serializable[] ids,
SessionFactoryImplementor factory) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if( persister == null ) {
s.append( "<null EntityPersister>" );
@ -193,7 +193,7 @@ public final class MessageHelper {
* @return An info string, in the form [FooBar]
*/
public static String infoString(EntityPersister persister) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if ( persister == null ) {
s.append( "<null EntityPersister>" );
@ -215,7 +215,7 @@ public final class MessageHelper {
* @return An info string, in the form [Foo.bars#1]
*/
public static String infoString(String entityName, String propertyName, Object key) {
StringBuffer s = new StringBuffer()
StringBuilder s = new StringBuilder()
.append( '[' )
.append( entityName )
.append( '.' )
@ -249,7 +249,7 @@ public final class MessageHelper {
CollectionPersister persister,
Serializable[] ids,
SessionFactoryImplementor factory) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if ( persister == null ) {
s.append( "<unreferenced>" );
@ -286,7 +286,7 @@ public final class MessageHelper {
CollectionPersister persister,
Serializable id,
SessionFactoryImplementor factory) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if ( persister == null ) {
s.append( "<unreferenced>" );
@ -320,7 +320,7 @@ public final class MessageHelper {
* @return An info string, in the form [Foo.bars#1]
*/
public static String collectionInfoString(String role, Serializable id) {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
s.append( '[' );
if( role == null ) {
s.append( "<unreferenced>" );

Some files were not shown because too many files have changed in this diff Show More