Permalink
Browse files

simple change, mostly are removing those unnesserary unboxing code.

  • Loading branch information...
1 parent 7811331 commit 9f4f817a73763c2418076ddb550a7b8399d53cc0 @stliu stliu committed Dec 31, 2012
Showing with 80 additions and 100 deletions.
  1. +4 −15 hibernate-core/src/main/java/org/hibernate/CacheMode.java
  2. +4 −15 hibernate-core/src/main/java/org/hibernate/FlushMode.java
  3. +1 −2 ...src/main/java/org/hibernate/bytecode/instrumentation/internal/javassist/FieldInterceptorImpl.java
  4. +2 −2 hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentArrayHolder.java
  5. +1 −1 hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentList.java
  6. +1 −1 hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentListElementHolder.java
  7. +1 −1 hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java
  8. +1 −1 hibernate-core/src/main/java/org/hibernate/dialect/function/TemplateRenderer.java
  9. +1 −1 hibernate-core/src/main/java/org/hibernate/engine/jdbc/ColumnNameCache.java
  10. +1 −1 hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java
  11. +1 −1 hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java
  12. +1 −1 hibernate-core/src/main/java/org/hibernate/engine/query/spi/NativeSQLQueryPlan.java
  13. +1 −1 hibernate-core/src/main/java/org/hibernate/engine/spi/RowSelection.java
  14. +4 −4 hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java
  15. +3 −5 hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java
  16. +1 −1 hibernate-core/src/main/java/org/hibernate/hql/internal/ast/exec/BasicExecutor.java
  17. +6 −7 hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/ASTUtil.java
  18. +1 −3 hibernate-core/src/main/java/org/hibernate/hql/internal/classic/QueryTranslatorImpl.java
  19. +2 −2 hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java
  20. +7 −7 hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java
  21. +24 −16 hibernate-core/src/main/java/org/hibernate/internal/util/collections/ArrayHelper.java
  22. +1 −1 hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java
  23. +2 −2 hibernate-core/src/main/java/org/hibernate/loader/JoinWalker.java
  24. +1 −1 hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
  25. +2 −2 hibernate-core/src/main/java/org/hibernate/persister/entity/SingleTableEntityPersister.java
  26. +1 −1 hibernate-core/src/main/java/org/hibernate/tuple/component/ComponentMetamodel.java
  27. +2 −2 hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java
  28. +1 −1 hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java
  29. +1 −1 hibernate-core/src/main/java/org/hibernate/type/IntegerType.java
  30. +1 −1 hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/JdbcTypeJavaClassMappings.java
@@ -84,22 +84,11 @@ public static CacheMode interpretExternalSetting(String setting) {
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 );
}
}
@@ -89,22 +89,11 @@ public static FlushMode interpretExternalSetting(String setting) {
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 );
}
}
@@ -81,8 +81,7 @@ public float readFloat(Object target, String name, float oldValue) {
}
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) {
@@ -134,7 +134,7 @@ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAl
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 Object getValue() {
}
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);
@@ -397,7 +397,7 @@ public String toString() {
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++) {
@@ -79,7 +79,7 @@ public Serializable disassemble(CollectionPersister persister) throws HibernateE
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;
}
@@ -354,7 +354,7 @@ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
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());
@@ -84,7 +84,7 @@ public TemplateRenderer(String template) {
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 );
}
}
@@ -45,7 +45,7 @@ public ColumnNameCache(int columnCount) {
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 );
@@ -192,7 +192,7 @@ private int refCursorTypeCode() {
throw new HibernateException( "Unexpected error trying to determine REF_CURSOR field value : " + e.getMessage() );
}
}
- return refCursorTypeCode.intValue();
+ return refCursorTypeCode;
}
@@ -336,7 +336,7 @@ private void closeParen() {
parensSinceSelect--;
if ( parensSinceSelect < 0 ) {
indent--;
- parensSinceSelect = parenCounts.removeLast().intValue();
+ parensSinceSelect = parenCounts.removeLast();
afterByOrSetOrFromOrSelect = afterByOrFromOrSelects.removeLast().booleanValue();
}
if ( inFunction > 0 ) {
@@ -87,7 +87,7 @@ public SQLCustomQuery getCustomQuery() {
customQuery.getSQL() );
}
if ( loc instanceof Integer ) {
- return new int[] { ((Integer) loc ).intValue() };
+ return new int[] { (Integer) loc };
}
else {
return ArrayHelper.toIntArray( (List) loc );
@@ -68,6 +68,6 @@ public void setFetchSize(Integer fetchSize) {
public boolean definesLimits() {
return maxRows != null ||
- ( firstRow != null && firstRow.intValue() <= 0 );
+ ( firstRow != null && firstRow <= 0 );
}
}
@@ -137,7 +137,7 @@
* 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 @@ else if ( node instanceof ParameterContainer ) {
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 @@ protected void handleResultVariableRef(AST resultVariableRef) throws SemanticExc
throw qe;
}
if ( o instanceof Integer ) {
- return new int[]{( ( Integer ) o ).intValue()};
+ return new int[]{ (Integer) o };
}
else {
return ArrayHelper.toIntArray( (ArrayList) o );
@@ -359,15 +359,13 @@ public List list(SessionImplementor session, QueryParameters queryParameters)
// 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;
}
@@ -96,7 +96,7 @@ public int execute(QueryParameters parameters, SessionImplementor session) throw
}
if ( selection != null ) {
if ( selection.getTimeout() != null ) {
- st.setQueryTimeout( selection.getTimeout().intValue() );
+ st.setQueryTimeout( selection.getTimeout() );
}
}
@@ -384,8 +384,7 @@ public List collect(AST root) {
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 static String getTokenTypeName(Class tokenTypeInterface, int tokenType) {
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 @@ else if ( value instanceof Short ) {
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();
}
}
@@ -550,9 +550,7 @@ else if ( o instanceof Integer ) {
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 );
}
@@ -192,10 +192,10 @@ private void initQuery(Query query, NamedQueryDefinition nqd) {
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() );
@@ -67,9 +67,9 @@ public FetchingScrollableResultsImpl(
* @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 boolean previous() throws HibernateException {
getSession(),
getQueryParameters(),
false,
- ( maxPosition != null && currentPosition > maxPosition.intValue() )
+ ( maxPosition != null && currentPosition > maxPosition )
);
currentRow = new Object[] { loadResult };
@@ -186,10 +186,10 @@ else if ( positions < 0 ) {
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 boolean isLast() throws HibernateException {
return false;
}
else {
- return currentPosition == maxPosition.intValue();
+ return currentPosition == maxPosition;
}
}
@@ -312,7 +312,7 @@ public boolean setRowNumber(int rowNumber) throws HibernateException {
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 );
Oops, something went wrong.

0 comments on commit 9f4f817

Please sign in to comment.