HHH-9722 cleanup, removed StringHelper methods

This commit is contained in:
Brett Meyer 2015-04-17 14:35:09 -04:00
parent 1361925bc7
commit 7ca12c7d80
5 changed files with 39 additions and 52 deletions

View File

@ -23,22 +23,6 @@
*/
package org.hibernate.cfg.annotations;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.persistence.Access;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
@ -103,9 +87,24 @@ import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner;
import org.hibernate.mapping.Value;
import org.jboss.logging.Logger;
import javax.persistence.Access;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
@ -342,7 +341,7 @@ public class EntityBinder {
if ( sqlUpdate != null ) {
persistentClass.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable(),
ExecuteUpdateResultCheckStyle.fromExternalName( sqlUpdate.check().toString().toLowerCase(Locale.ROOT) )
);Locale.ROOT
);
}
if ( sqlDelete != null ) {
persistentClass.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable(),

View File

@ -24,6 +24,9 @@
*/
package org.hibernate.internal.util;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.ArrayHelper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@ -32,9 +35,6 @@ import java.util.Iterator;
import java.util.Locale;
import java.util.StringTokenizer;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.ArrayHelper;
public final class StringHelper {
private static final int ALIAS_TRUNCATE_LENGTH = 10;
@ -556,8 +556,6 @@ public final class StringHelper {
*/
private static String generateAliasRoot(String description) {
String result = truncate( unqualifyEntityName(description), ALIAS_TRUNCATE_LENGTH )
// Important to use Locale.ENGLISH. See HHH-8579. #toLowerCase() uses the default Locale. Certain DBs
// do not like non-ascii characters in aliases, etc., so ensure consistency/portability here.
.toLowerCase(Locale.ROOT)
.replace( '/', '_' ) // entityNames may now include slashes for the representations
.replace( '$', '_' ); //classname may be an inner class
@ -601,16 +599,6 @@ public final class StringHelper {
return result;
}
public static String toUpperCase(String str) {
return str==null ? null : str.toUpperCase(Locale.ROOT);
}
public static String toLowerCase(String str) {
// Important to use Locale.ENGLISH. See HHH-8579. #toLowerCase() uses the default Locale. Certain DBs do not
// like non-ascii characters in aliases, etc., so ensure consistency/portability here.
return str == null ? null : str.toLowerCase(Locale.ROOT);
}
public static String moveAndToBeginning(String filter) {
if ( filter.trim().length()>0 ){
filter += " and ";

View File

@ -22,16 +22,16 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.tool.hbm2ddl;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
/**
* JDBC foreign key metadata
*
@ -56,11 +56,11 @@ public class ForeignKeyMetadata {
}
void addReference(ResultSet rs) throws SQLException {
references.put( StringHelper.toLowerCase(rs.getString("FKCOLUMN_NAME")), rs.getString("PKCOLUMN_NAME") );
references.put( rs.getString("FKCOLUMN_NAME").toLowerCase(Locale.ROOT), rs.getString("PKCOLUMN_NAME") );
}
private boolean hasReference(Column column, Column ref) {
String refName = (String) references.get(StringHelper.toLowerCase(column.getName()));
String refName = (String) references.get(column.getName().toLowerCase(Locale.ROOT));
return ref.getName().equalsIgnoreCase(refName);
}

View File

@ -23,19 +23,18 @@
*/
package org.hibernate.tool.hbm2ddl;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.mapping.ForeignKey;
import org.jboss.logging.Logger;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.ForeignKey;
import org.jboss.logging.Logger;
/**
* JDBC table metadata
*
@ -90,11 +89,11 @@ public class TableMetadata {
}
public ColumnMetadata getColumnMetadata(String columnName) {
return (ColumnMetadata) columns.get( StringHelper.toLowerCase(columnName) );
return (ColumnMetadata) columns.get( columnName.toLowerCase(Locale.ROOT) );
}
public ForeignKeyMetadata getForeignKeyMetadata(String keyName) {
return (ForeignKeyMetadata) foreignKeys.get( StringHelper.toLowerCase(keyName) );
return (ForeignKeyMetadata) foreignKeys.get( keyName.toLowerCase(Locale.ROOT) );
}
public ForeignKeyMetadata getForeignKeyMetadata(ForeignKey fk) {
@ -109,7 +108,7 @@ public class TableMetadata {
}
public IndexMetadata getIndexMetadata(String indexName) {
return (IndexMetadata) indexes.get( StringHelper.toLowerCase(indexName) );
return (IndexMetadata) indexes.get( indexName.toLowerCase(Locale.ROOT) );
}
private void addForeignKey(ResultSet rs) throws SQLException {
@ -122,7 +121,7 @@ public class TableMetadata {
ForeignKeyMetadata info = getForeignKeyMetadata(fk);
if (info == null) {
info = new ForeignKeyMetadata(rs);
foreignKeys.put( StringHelper.toLowerCase(info.getName()), info );
foreignKeys.put( info.getName().toLowerCase(Locale.ROOT), info );
}
info.addReference( rs );
@ -138,7 +137,7 @@ public class TableMetadata {
IndexMetadata info = getIndexMetadata(index);
if (info == null) {
info = new IndexMetadata(rs);
indexes.put( StringHelper.toLowerCase(info.getName()), info );
indexes.put( info.getName().toLowerCase(Locale.ROOT), info );
}
info.addColumn( getColumnMetadata( rs.getString("COLUMN_NAME") ) );
@ -153,7 +152,7 @@ public class TableMetadata {
if ( getColumnMetadata(column) == null ) {
ColumnMetadata info = new ColumnMetadata(rs);
columns.put( StringHelper.toLowerCase(info.getName()), info );
columns.put( info.getName().toLowerCase(Locale.ROOT), info );
}
}

View File

@ -24,6 +24,7 @@
package org.hibernate.envers.internal.tools;
import java.util.Iterator;
import java.util.Locale;
/**
* @author Adam Warski (adam at warski dot org)
@ -80,6 +81,6 @@ public abstract class StringTools {
* @return capitalized string
*/
public static String capitalizeFirst(String fieldName) {
return fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
return fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + fieldName.substring(1);
}
}