public static Short toShort(Object o,Short defaultValue){
  if (o instanceof Short)   return (Short)o;
  if (defaultValue != null)   return Short.valueOf(toShortValue(o,defaultValue.shortValue()));
  short res=toShortValue(o,Short.MIN_VALUE);
  if (res == Short.MIN_VALUE)   return defaultValue;
  return Short.valueOf(res);
}

public static Short toShort ( Object o , Short defaultValue ) { if ( o instanceof Short ) return ( Short ) o ; if ( defaultValue != null ) return Short . valueOf ( toShortValue ( o , defaultValue . shortValue ( ) ) ) ; short res = toShortValue ( o , Short . MIN_VALUE ) ; if ( res == Short . MIN_VALUE ) return defaultValue ; return Short . valueOf ( res ) ; }
cast a object to a byte object ( reference type )
