Replace StringBuffer with StringBuilder

avoid unnecessary synchronization
This commit is contained in:
Yanming Zhou 2020-09-03 15:35:50 +08:00 committed by Christian Beikov
parent 7f6ead80cc
commit 4499abd9a9
18 changed files with 21 additions and 26 deletions

View File

@ -61,8 +61,7 @@ public String logicalCollectionTableName(
return tableName; return tableName;
} }
else { else {
//use of a stringbuffer to workaround a JDK bug return new StringBuilder( ownerEntityTable ).append( "_" )
return new StringBuffer( ownerEntityTable ).append( "_" )
.append( .append(
associatedEntityTable != null ? associatedEntityTable != null ?
associatedEntityTable : associatedEntityTable :

View File

@ -96,8 +96,7 @@ public String logicalCollectionTableName(String tableName,
return tableName; return tableName;
} }
else { else {
//use of a stringbuffer to workaround a JDK bug return new StringBuilder(ownerEntityTable).append("_")
return new StringBuffer(ownerEntityTable).append("_")
.append( .append(
associatedEntityTable != null ? associatedEntityTable != null ?
associatedEntityTable : associatedEntityTable :

View File

@ -72,8 +72,7 @@ public String logicalCollectionTableName(
return tableName; return tableName;
} }
else { else {
//use of a stringbuffer to workaround a JDK bug return new StringBuilder( ownerEntityTable ).append( "_" )
return new StringBuffer( ownerEntityTable ).append( "_" )
.append( .append(
associatedEntityTable != null ? associatedEntityTable != null ?
associatedEntityTable : associatedEntityTable :

View File

@ -110,8 +110,7 @@ public String logicalCollectionTableName(String tableName,
return tableName; return tableName;
} }
else { else {
//use of a stringbuffer to workaround a JDK bug return new StringBuilder(ownerEntityTable).append("_")
return new StringBuffer(ownerEntityTable).append("_")
.append( .append(
associatedEntityTable != null ? associatedEntityTable != null ?
associatedEntityTable : associatedEntityTable :

View File

@ -771,7 +771,7 @@ private void renderIdentifierSelect(QuerySelect sql) {
} }
/*private String renderOrderByPropertiesSelect() { /*private String renderOrderByPropertiesSelect() {
StringBuffer buf = new StringBuffer(10); StringBuilder buf = new StringBuilder(10);
//add the columns we are ordering by to the select ID select clause //add the columns we are ordering by to the select ID select clause
Iterator iter = orderByTokens.iterator(); Iterator iter = orderByTokens.iterator();

View File

@ -49,7 +49,7 @@ public int hashCode( ) {
@Override @Override
public String toString( ) { public String toString( ) {
StringBuffer buf = new StringBuffer( "[id:" ); StringBuilder buf = new StringBuilder( "[id:" );
buf.append( ( this.getCode( ) == null ) ? "null" : this.getCode( ).toString( ) ); buf.append( ( this.getCode( ) == null ) ? "null" : this.getCode( ).toString( ) );
buf.append( ";code:" ); buf.append( ";code:" );
buf.append( ( this.getDivision( ) == null ) ? "null" : this.getDivision( ) ); buf.append( ( this.getDivision( ) == null ) ? "null" : this.getDivision( ) );

View File

@ -44,6 +44,6 @@ public void setMicro(int micro) {
} }
public String toString() { public String toString() {
return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); return new StringBuilder( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString();
} }
} }

View File

@ -44,6 +44,6 @@ public void setMicro(int micro) {
} }
public String toString() { public String toString() {
return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); return new StringBuilder( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString();
} }
} }

View File

@ -44,6 +44,6 @@ public void setMicro(int micro) {
} }
public String toString() { public String toString() {
return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); return new StringBuilder( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString();
} }
} }

View File

@ -63,8 +63,7 @@ public String logicalCollectionTablelName(
return tableName; return tableName;
} }
else { else {
//use of a stringbuffer to workaround a JDK bug return new StringBuilder( ownerEntityTable ).append( "_" )
return new StringBuffer( ownerEntityTable ).append( "_" )
.append( .append(
associatedEntityTable != null ? associatedEntityTable != null ?
associatedEntityTable : associatedEntityTable :

View File

@ -23,7 +23,7 @@ class GetDimensionFunction extends SDOObjectMethod {
} }
public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) { public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) {
final StringBuffer buf = new StringBuffer(); final StringBuilder buf = new StringBuilder();
if ( args.isEmpty() ) { if ( args.isEmpty() ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"First Argument in arglist must be object to " "First Argument in arglist must be object to "

View File

@ -23,7 +23,7 @@ class GetGeometryTypeFunction extends SDOObjectMethod {
} }
public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) { public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) {
final StringBuffer buf = new StringBuffer(); final StringBuilder buf = new StringBuilder();
if ( args.isEmpty() ) { if ( args.isEmpty() ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"First Argument in arglist must be object to which" "First Argument in arglist must be object to which"

View File

@ -106,7 +106,7 @@ public String getSpatialRelateSQL(String columnName, int spatialRelation) {
} }
public String getOGCSpatialRelateSQL(String arg1, String arg2, int spatialRelation) { public String getOGCSpatialRelateSQL(String arg1, String arg2, int spatialRelation) {
final StringBuffer ogcFunction = new StringBuffer( "MDSYS." ); final StringBuilder ogcFunction = new StringBuilder( "MDSYS." );
switch ( spatialRelation ) { switch ( spatialRelation ) {
case SpatialRelation.INTERSECTS: case SpatialRelation.INTERSECTS:
ogcFunction.append( "OGC_INTERSECTS" ); ogcFunction.append( "OGC_INTERSECTS" );
@ -229,7 +229,7 @@ String getNativeSpatialRelateSQL(String arg1, String arg2, int spatialRelation)
*/ */
@Override @Override
public String getSpatialFilterExpression(String columnName) { public String getSpatialFilterExpression(String columnName) {
final StringBuffer buffer = new StringBuffer( "SDO_FILTER(" ); final StringBuilder buffer = new StringBuilder( "SDO_FILTER(" );
buffer.append( columnName ); buffer.append( columnName );
buffer.append( ",?) = 'TRUE' " ); buffer.append( ",?) = 'TRUE' " );
return buffer.toString(); return buffer.toString();
@ -245,7 +245,7 @@ public String getSpatialFilterExpression(String columnName) {
*/ */
@Override @Override
public String getSpatialAggregateSQL(String columnName, int aggregation) { public String getSpatialAggregateSQL(String columnName, int aggregation) {
final StringBuffer aggregateFunction = new StringBuffer(); final StringBuilder aggregateFunction = new StringBuilder();
final SpatialAggregate sa = new SpatialAggregate( aggregation ); final SpatialAggregate sa = new SpatialAggregate( aggregation );
if ( sa.getAggregateSyntax() == null ) { if ( sa.getAggregateSyntax() == null ) {

View File

@ -175,7 +175,7 @@ class OracleSpatialFunctions extends SpatialFunctionsRegistry {
static String getOGCSpatialAnalysisSQL(List args, int spatialAnalysisFunction) { static String getOGCSpatialAnalysisSQL(List args, int spatialAnalysisFunction) {
boolean[] geomArgs; boolean[] geomArgs;
final StringBuffer ogcFunction = new StringBuffer( "MDSYS." ); final StringBuilder ogcFunction = new StringBuilder( "MDSYS." );
boolean isGeomReturn = true; boolean isGeomReturn = true;
switch ( spatialAnalysisFunction ) { switch ( spatialAnalysisFunction ) {
case SpatialAnalysis.BUFFER: case SpatialAnalysis.BUFFER:
@ -240,7 +240,7 @@ static String getOGCSpatialAnalysisSQL(List args, int spatialAnalysisFunction) {
return ogcFunction.toString(); return ogcFunction.toString();
} }
private static StringBuffer wrapInSTGeometry(String geomColumn, StringBuffer toAdd) { private static StringBuilder wrapInSTGeometry(String geomColumn, StringBuilder toAdd) {
return toAdd.append( "MDSYS.ST_GEOMETRY(" ).append( geomColumn ) return toAdd.append( "MDSYS.ST_GEOMETRY(" ).append( geomColumn )
.append( ")" ); .append( ")" );
} }

View File

@ -67,7 +67,7 @@ public String getName() {
*/ */
public String render(Type firstArgumentType, List args, SessionFactoryImplementor factory) throws QueryException { public String render(Type firstArgumentType, List args, SessionFactoryImplementor factory) throws QueryException {
final StringBuffer buf = new StringBuffer(); final StringBuilder buf = new StringBuilder();
if ( args.isEmpty() ) { if ( args.isEmpty() ) {
throw new QueryException( throw new QueryException(
"First Argument in arglist must be object to which method is applied" "First Argument in arglist must be object to which method is applied"

View File

@ -68,7 +68,7 @@ public String getName() {
public String render(Type firstArgtype, List args, SessionFactoryImplementor factory) public String render(Type firstArgtype, List args, SessionFactoryImplementor factory)
throws QueryException { throws QueryException {
final StringBuffer buf = new StringBuffer(); final StringBuilder buf = new StringBuilder();
if ( args.isEmpty() ) { if ( args.isEmpty() ) {
throw new QueryException( throw new QueryException(
"First Argument in arglist must be object of which property is queried" "First Argument in arglist must be object of which property is queried"

View File

@ -49,7 +49,7 @@ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteri
if ( dialect instanceof SpatialDialect ) { if ( dialect instanceof SpatialDialect ) {
final SpatialDialect seDialect = (SpatialDialect) dialect; final SpatialDialect seDialect = (SpatialDialect) dialect;
return new StringBuffer( return new StringBuilder(
seDialect.getSpatialAggregateSQL( seDialect.getSpatialAggregateSQL(
columns[0], this.aggregate columns[0], this.aggregate
) )

View File

@ -24,7 +24,7 @@ public SqlServerMethod(String name) {
@Override @Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) { public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) {
final StringBuffer buf = new StringBuffer(); final StringBuilder buf = new StringBuilder();
if ( arguments.size() < 1 ) { if ( arguments.size() < 1 ) {
buf.append( getName() ).append( "()" ); buf.append( getName() ).append( "()" );
} }