BuilderExceptionHandler.java revision 897832aa150cdf53ed7fa2f17dee132d2408e2f3
1package org.jf.dexlib2.builder; 2 3import org.jf.dexlib2.base.BaseExceptionHandler; 4import org.jf.dexlib2.iface.ExceptionHandler; 5import org.jf.dexlib2.iface.reference.TypeReference; 6 7import javax.annotation.Nonnull; 8import javax.annotation.Nullable; 9 10class BuilderExceptionHandler { 11 static ExceptionHandler newExceptionHandler(@Nullable final TypeReference exceptionType, 12 @Nonnull final LabelMethodItem handler) { 13 if (exceptionType == null) { 14 return newExceptionHandler(handler); 15 } 16 return new BaseExceptionHandler() { 17 @Nullable @Override public String getExceptionType() { 18 return exceptionType.getType(); 19 } 20 21 @Override public int getHandlerCodeAddress() { 22 return handler.getCodeAddress(); 23 } 24 25 @Nullable @Override public TypeReference getExceptionTypeReference() { 26 return exceptionType; 27 } 28 }; 29 } 30 31 static ExceptionHandler newExceptionHandler(@Nonnull final LabelMethodItem handler) { 32 return new BaseExceptionHandler() { 33 @Nullable @Override public String getExceptionType() { 34 return null; 35 } 36 37 @Override public int getHandlerCodeAddress() { 38 return handler.getCodeAddress(); 39 } 40 }; 41 } 42 43 static ExceptionHandler newExceptionHandler(@Nullable final String exceptionType, 44 @Nonnull final LabelMethodItem handler) { 45 if (exceptionType == null) { 46 return newExceptionHandler(handler); 47 } 48 return new BaseExceptionHandler() { 49 @Nullable @Override public String getExceptionType() { 50 return exceptionType; 51 } 52 53 @Override public int getHandlerCodeAddress() { 54 return handler.getCodeAddress(); 55 } 56 }; 57 } 58} 59