simple change, mostly are removing those unnesserary unboxing code.

This commit is contained in:
Strong Liu 2012-12-31 23:20:05 +08:00
parent 781133164b
commit 9f4f817a73
30 changed files with 80 additions and 100 deletions

View File

@ -84,22 +84,11 @@ public enum CacheMode {
return null;
}
if ( GET.name().equalsIgnoreCase( setting ) ) {
return CacheMode.GET;
try {
return CacheMode.valueOf( setting.toUpperCase() );
}
if ( IGNORE.name().equalsIgnoreCase( setting ) ) {
return CacheMode.IGNORE;
catch ( IllegalArgumentException e ) {
throw new MappingException( "Unknown Cache Mode: " + setting );
}
if ( NORMAL.name().equalsIgnoreCase( setting ) ) {
return CacheMode.NORMAL;
}
if ( PUT.name().equalsIgnoreCase( setting ) ) {
return CacheMode.PUT;
}
if ( REFRESH.name().equalsIgnoreCase( setting ) ) {
return CacheMode.REFRESH;
}
throw new MappingException( "Unknown Cache Mode: " + setting );
}
}

View File

@ -89,22 +89,11 @@ public enum FlushMode {
return null;
}
if ( AUTO.name().equalsIgnoreCase( setting ) ) {
return FlushMode.AUTO;
try {
return FlushMode.valueOf( setting.toUpperCase() );
}
if ( COMMIT.name().equalsIgnoreCase( setting ) ) {
return FlushMode.COMMIT;
catch ( IllegalArgumentException e ) {
throw new MappingException( "unknown FlushMode : " + setting );
}
if ( NEVER.name().equalsIgnoreCase( setting ) ) {
return FlushMode.NEVER;
}
if ( MANUAL.name().equalsIgnoreCase( setting ) ) {
return FlushMode.MANUAL;
}
if ( ALWAYS.name().equalsIgnoreCase( setting ) ) {
return FlushMode.ALWAYS;
}
throw new MappingException( "unknown FlushMode : " + setting );
}
}

View File

@ -81,8 +81,7 @@ public final class FieldInterceptorImpl extends AbstractFieldInterceptor impleme
}
public int readInt(Object target, String name, int oldValue) {
return ( ( Integer ) intercept( target, name, Integer.valueOf( oldValue ) ) )
.intValue();
return ( ( Integer ) intercept( target, name, Integer.valueOf( oldValue ) ) );
}
public long readLong(Object target, String name, long oldValue) {

View File

@ -134,7 +134,7 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
throws HibernateException, SQLException {
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
int index = (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
for ( int i = tempList.size(); i<=index; i++) {
tempList.add(i, null);
}
@ -205,7 +205,7 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
}
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
java.util.List deletes = new ArrayList();
java.util.List<Integer> deletes = new ArrayList<Integer>();
Serializable sn = getSnapshot();
int snSize = Array.getLength(sn);
int arraySize = Array.getLength(array);

View File

@ -397,7 +397,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
int index = (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
//pad with nulls from the current last element up to the new index
for ( int i = list.size(); i<=index; i++) {

View File

@ -79,7 +79,7 @@ public class PersistentListElementHolder extends PersistentIndexedElementHolder
Element elem = (Element) elements.get(i);
Object object = elementType.fromXMLNode( elem, persister.getFactory() );
Integer index = IntegerType.INSTANCE.fromString( getIndex(elem, indexNodeName, i) );
result[ index.intValue() ] = elementType.disassemble( object, getSession(), null );
result[index] = elementType.disassemble( object, getSession(), null );
}
return result;
}

View File

@ -354,7 +354,7 @@ public class PostgreSQL81Dialect extends Dialect {
private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
public String extractConstraintName(SQLException sqle) {
try {
int sqlState = Integer.valueOf( JdbcExceptionHelper.extractSqlState( sqle )).intValue();
int sqlState = Integer.valueOf( JdbcExceptionHelper.extractSqlState( sqle ) );
switch (sqlState) {
// CHECK VIOLATION
case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage());

View File

@ -84,7 +84,7 @@ public class TemplateRenderer {
chunks = chunkList.toArray( new String[chunkList.size()] );
paramIndexes = new int[paramList.size()];
for ( int i = 0; i < paramIndexes.length; ++i ) {
paramIndexes[i] = paramList.get( i ).intValue();
paramIndexes[i] = paramList.get( i );
}
}

View File

@ -45,7 +45,7 @@ public class ColumnNameCache {
public int getIndexForColumnName(String columnName, ResultSet rs) throws SQLException {
Integer cached = columnNameToIndexCache.get( columnName );
if ( cached != null ) {
return cached.intValue();
return cached;
}
else {
int index = rs.findColumn( columnName );

View File

@ -192,7 +192,7 @@ public class StandardRefCursorSupport implements RefCursorSupport {
throw new HibernateException( "Unexpected error trying to determine REF_CURSOR field value : " + e.getMessage() );
}
}
return refCursorTypeCode.intValue();
return refCursorTypeCode;
}

View File

@ -336,7 +336,7 @@ public class BasicFormatterImpl implements Formatter {
parensSinceSelect--;
if ( parensSinceSelect < 0 ) {
indent--;
parensSinceSelect = parenCounts.removeLast().intValue();
parensSinceSelect = parenCounts.removeLast();
afterByOrSetOrFromOrSelect = afterByOrFromOrSelects.removeLast().booleanValue();
}
if ( inFunction > 0 ) {

View File

@ -87,7 +87,7 @@ public class NativeSQLQueryPlan implements Serializable {
customQuery.getSQL() );
}
if ( loc instanceof Integer ) {
return new int[] { ((Integer) loc ).intValue() };
return new int[] { (Integer) loc };
}
else {
return ArrayHelper.toIntArray( (List) loc );

View File

@ -68,6 +68,6 @@ public final class RowSelection {
public boolean definesLimits() {
return maxRows != null ||
( firstRow != null && firstRow.intValue() <= 0 );
( firstRow != null && firstRow <= 0 );
}
}

View File

@ -137,7 +137,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
* Maps each top-level result variable to its SelectExpression;
* (excludes result variables defined in subqueries)
**/
private Map<String, SelectExpression> selectExpressionsByResultVariable = new HashMap();
private Map<String, SelectExpression> selectExpressionsByResultVariable = new HashMap<String, SelectExpression>();
private Set querySpaces = new HashSet();
@ -492,8 +492,8 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
private void applyParameterSpecifications(ParameterContainer parameterContainer) {
if ( parameterContainer.hasEmbeddedParameters() ) {
ParameterSpecification[] specs = parameterContainer.getEmbeddedParameters();
for ( int i = 0; i < specs.length; i++ ) {
applyParameterSpecification( specs[i] );
for ( ParameterSpecification spec : specs ) {
applyParameterSpecification( spec );
}
}
}
@ -1064,7 +1064,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
throw qe;
}
if ( o instanceof Integer ) {
return new int[]{( ( Integer ) o ).intValue()};
return new int[]{ (Integer) o };
}
else {
return ArrayHelper.toIntArray( (ArrayList) o );

View File

@ -359,15 +359,13 @@ public class QueryTranslatorImpl implements FilterTranslator {
// NOTE : firstRow is zero-based
int first = !hasLimit || queryParameters.getRowSelection().getFirstRow() == null
? 0
: queryParameters.getRowSelection().getFirstRow().intValue();
: queryParameters.getRowSelection().getFirstRow();
int max = !hasLimit || queryParameters.getRowSelection().getMaxRows() == null
? -1
: queryParameters.getRowSelection().getMaxRows().intValue();
int size = results.size();
: queryParameters.getRowSelection().getMaxRows();
List tmp = new ArrayList();
IdentitySet distinction = new IdentitySet();
for ( int i = 0; i < size; i++ ) {
final Object result = results.get( i );
for ( final Object result : results ) {
if ( !distinction.add( result ) ) {
continue;
}

View File

@ -96,7 +96,7 @@ public class BasicExecutor implements StatementExecutor {
}
if ( selection != null ) {
if ( selection.getTimeout() != null ) {
st.setQueryTimeout( selection.getTimeout().intValue() );
st.setQueryTimeout( selection.getTimeout() );
}
}

View File

@ -384,8 +384,7 @@ public final class ASTUtil {
public static Map generateTokenNameCache(Class tokenTypeInterface) {
final Field[] fields = tokenTypeInterface.getFields();
Map cache = new HashMap( (int)( fields.length * .75 ) + 1 );
for ( int i = 0; i < fields.length; i++ ) {
final Field field = fields[i];
for ( final Field field : fields ) {
if ( Modifier.isStatic( field.getModifiers() ) ) {
try {
cache.put( field.get( null ), field.getName() );
@ -429,10 +428,10 @@ public final class ASTUtil {
String tokenTypeName = Integer.toString( tokenType );
if ( tokenTypeInterface != null ) {
Field[] fields = tokenTypeInterface.getFields();
for ( int i = 0; i < fields.length; i++ ) {
final Integer fieldValue = extractIntegerValue( fields[i] );
if ( fieldValue != null && fieldValue.intValue() == tokenType ) {
tokenTypeName = fields[i].getName();
for ( Field field : fields ) {
final Integer fieldValue = extractIntegerValue( field );
if ( fieldValue != null && fieldValue == tokenType ) {
tokenTypeName = field.getName();
break;
}
}
@ -451,7 +450,7 @@ public final class ASTUtil {
rtn = ( ( Short ) value ).intValue();
}
else if ( value instanceof Long ) {
if ( ( ( Long ) value ).longValue() <= Integer.MAX_VALUE ) {
if ( ( Long ) value <= Integer.MAX_VALUE ) {
rtn = ( ( Long ) value ).intValue();
}
}

View File

@ -550,9 +550,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator
qe.setQueryString( queryString );
throw qe;
}
if ( o instanceof Integer ) {
return new int[]{ ( ( Integer ) o ).intValue() };
}
if ( o instanceof Integer ) return new int[] { (Integer) o };
else {
return ArrayHelper.toIntArray( ( ArrayList ) o );
}

View File

@ -192,10 +192,10 @@ public abstract class AbstractSessionImpl implements Serializable, SharedSession
query.setReadOnly( nqd.isReadOnly() );
if ( nqd.getTimeout() != null ) {
query.setTimeout( nqd.getTimeout().intValue() );
query.setTimeout( nqd.getTimeout() );
}
if ( nqd.getFetchSize() != null ) {
query.setFetchSize( nqd.getFetchSize().intValue() );
query.setFetchSize( nqd.getFetchSize() );
}
if ( nqd.getCacheMode() != null ) {
query.setCacheMode( nqd.getCacheMode() );

View File

@ -67,9 +67,9 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
* @return <tt>true</tt> if there is another result
*/
public boolean next() throws HibernateException {
if ( maxPosition != null && maxPosition.intValue() <= currentPosition ) {
if ( maxPosition != null && maxPosition <= currentPosition ) {
currentRow = null;
currentPosition = maxPosition.intValue() + 1;
currentPosition = maxPosition + 1;
return false;
}
@ -130,7 +130,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
getSession(),
getQueryParameters(),
false,
( maxPosition != null && currentPosition > maxPosition.intValue() )
( maxPosition != null && currentPosition > maxPosition )
);
currentRow = new Object[] { loadResult };
@ -186,10 +186,10 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
public boolean last() throws HibernateException {
boolean more = false;
if ( maxPosition != null ) {
if ( currentPosition > maxPosition.intValue() ) {
if ( currentPosition > maxPosition ) {
more = previous();
}
for ( int i = currentPosition; i < maxPosition.intValue(); i++ ) {
for ( int i = currentPosition; i < maxPosition; i++ ) {
more = next();
}
}
@ -284,7 +284,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
return false;
}
else {
return currentPosition == maxPosition.intValue();
return currentPosition == maxPosition;
}
}
@ -312,7 +312,7 @@ public class FetchingScrollableResultsImpl extends AbstractScrollableResults {
else if ( rowNumber == -1 ) {
return last();
}
else if ( maxPosition != null && rowNumber == maxPosition.intValue() ) {
else if ( maxPosition != null && rowNumber == maxPosition ) {
return last();
}
return scroll( rowNumber - currentPosition );

View File

@ -113,7 +113,7 @@ public final class ArrayHelper {
int[] arr = new int[ coll.size() ];
int i=0;
while( iter.hasNext() ) {
arr[i++] = ( (Integer) iter.next() ).intValue();
arr[i++] = (Integer) iter.next();
}
return arr;
}
@ -123,7 +123,7 @@ public final class ArrayHelper {
boolean[] arr = new boolean[ coll.size() ];
int i=0;
while( iter.hasNext() ) {
arr[i++] = ( (Boolean) iter.next() ).booleanValue();
arr[i++] = (Boolean) iter.next();
}
return arr;
}
@ -214,23 +214,29 @@ public final class ArrayHelper {
}
public static boolean isAllNegative(int[] array) {
for ( int i=0; i<array.length; i++ ) {
if ( array[i] >=0 ) return false;
for ( int anArray : array ) {
if ( anArray >= 0 ) {
return false;
}
}
return true;
}
public static boolean isAllTrue(boolean[] array) {
for ( int i=0; i<array.length; i++ ) {
if ( !array[i] ) return false;
for ( boolean anArray : array ) {
if ( !anArray ) {
return false;
}
}
return true;
}
public static int countTrue(boolean[] array) {
int result=0;
for ( int i=0; i<array.length; i++ ) {
if ( array[i] ) result++;
for ( boolean anArray : array ) {
if ( anArray ) {
result++;
}
}
return result;
}
@ -244,8 +250,10 @@ public final class ArrayHelper {
}*/
public static boolean isAllFalse(boolean[] array) {
for ( int i=0; i<array.length; i++ ) {
if ( array[i] ) return false;
for ( boolean anArray : array ) {
if ( anArray ) {
return false;
}
}
return true;
}
@ -299,8 +307,8 @@ public final class ArrayHelper {
public static int hash(Object[] array) {
int length = array.length;
int seed = SEED;
for (int index = 0 ; index < length ; index++) {
seed = hash( seed, array[index] == null ? 0 : array[index].hashCode() );
for ( Object anArray : array ) {
seed = hash( seed, anArray == null ? 0 : anArray.hashCode() );
}
return seed;
}
@ -311,8 +319,8 @@ public final class ArrayHelper {
public static int hash(char[] array) {
int length = array.length;
int seed = SEED;
for (int index = 0 ; index < length ; index++) {
seed = hash( seed, array[index] ) ;
for ( char anArray : array ) {
seed = hash( seed, anArray );
}
return seed;
}
@ -323,8 +331,8 @@ public final class ArrayHelper {
public static int hash(byte[] bytes) {
int length = bytes.length;
int seed = SEED;
for (int index = 0 ; index < length ; index++) {
seed = hash( seed, bytes[index] ) ;
for ( byte aByte : bytes ) {
seed = hash( seed, aByte );
}
return seed;
}

View File

@ -133,7 +133,7 @@ public final class ConfigurationHelper {
return defaultValue;
}
if ( Integer.class.isInstance( value ) ) {
return ( (Integer) value ).intValue();
return (Integer) value;
}
if ( String.class.isInstance( value ) ) {
return Integer.parseInt( (String) value );

View File

@ -724,7 +724,7 @@ public class JoinWalker {
protected boolean isTooDeep(int currentDepth) {
Integer maxFetchDepth = getFactory().getSettings().getMaximumFetchDepth();
return maxFetchDepth!=null && currentDepth >= maxFetchDepth.intValue();
return maxFetchDepth!=null && currentDepth >= maxFetchDepth;
}
protected boolean isTooManyCollections() {
@ -841,7 +841,7 @@ public class JoinWalker {
}
Integer maxFetchDepth = getFactory().getSettings().getMaximumFetchDepth();
final boolean tooDeep = maxFetchDepth!=null && depth >= maxFetchDepth.intValue();
final boolean tooDeep = maxFetchDepth!=null && depth >= maxFetchDepth;
return !tooDeep && !isDuplicateAssociation(lhsTable, lhsColumnNames, type);
}

View File

@ -807,7 +807,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
if ( index == null ) {
return null;
}
return tableNames[propertyTableNumbers[index.intValue()]];
return tableNames[propertyTableNumbers[index]];
}
public String[] getConstraintOrderedTableNameClosure() {

View File

@ -927,7 +927,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
Type type = propertyMapping.toType(propertyName);
if ( type.isAssociationType() && ( (AssociationType) type ).useLHSPrimaryKey() ) return 0;
final Integer tabnum = (Integer) propertyTableNumbersByNameAndSubclass.get(entityName + '.' + propertyName);
return tabnum==null ? 0 : tabnum.intValue();
return tabnum==null ? 0 : tabnum;
}
protected String getSequentialSelect(String entityName) {
@ -1011,7 +1011,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
public String getPropertyTableName(String propertyName) {
Integer index = getEntityMetamodel().getPropertyIndexOrNull(propertyName);
if (index==null) return null;
return qualifiedTableNames[ propertyTableNumbers[ index.intValue() ] ];
return qualifiedTableNames[ propertyTableNumbers[index] ];
}
public void postInstantiate() {

View File

@ -107,7 +107,7 @@ public class ComponentMetamodel implements Serializable {
if ( index == null ) {
throw new HibernateException( "component does not contain such a property [" + propertyName + "]" );
}
return index.intValue();
return index;
}
public StandardProperty getProperty(String propertyName) {

View File

@ -645,13 +645,13 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
: propertyPath;
}
index = entityMetamodel.getPropertyIndexOrNull( basePropertyName );
final Object baseValue = getPropertyValue( entity, index.intValue() );
final Object baseValue = getPropertyValue( entity, index );
if ( loc > 0 ) {
if ( baseValue == null ) {
return null;
}
return getComponentValue(
(ComponentType) entityMetamodel.getPropertyTypes()[index.intValue()],
(ComponentType) entityMetamodel.getPropertyTypes()[index],
baseValue,
propertyPath.substring(loc+1)
);

View File

@ -791,7 +791,7 @@ public class EntityMetamodel implements Serializable {
if ( index == null ) {
throw new HibernateException("Unable to resolve property: " + propertyName);
}
return index.intValue();
return index;
}
public Integer getPropertyIndexOrNull(String propertyName) {

View File

@ -79,7 +79,7 @@ public class IntegerType extends AbstractSingleColumnStandardBasicType<Integer>
@SuppressWarnings({ "UnnecessaryBoxing", "UnnecessaryUnboxing" })
public Integer next(Integer current, SessionImplementor session) {
return Integer.valueOf( current.intValue() + 1 );
return current+1;
}
public Comparator<Integer> getComparator() {

View File

@ -62,7 +62,7 @@ public class JdbcTypeJavaClassMappings {
public int determineJdbcTypeCodeForJavaClass(Class cls) {
Integer typeCode = JdbcTypeJavaClassMappings.javaClassToJdbcTypeCodeMap.get( cls );
if ( typeCode != null ) {
return typeCode.intValue();
return typeCode;
}
int specialCode = cls.hashCode();