| | |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.constant.Regular; |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import java.lang.reflect.Method; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | public class ConvertUtil { |
| | | static final Logger LOGGER = LoggerFactory.getLogger(ConvertUtil.class); |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LOGGER.error("fieldName : " + fieldName, e); |
| | | if (LOGGER.isWarnEnabled()) { |
| | | LOGGER.warn("fieldName : " + fieldName, e); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | |
| | | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| | | return mapper; |
| | | } |
| | | |
| | | public static String[] ToArray(List<String> list) { |
| | | return list.toArray(new String[list.size()]); |
| | | } |
| | | |
| | | /** |
| | | * ip주소 long으로 변환 |
| | | * @param ipAddress String |
| | | * @return long |
| | | */ |
| | | public static long ipToLong(String ipAddress) { |
| | | long result = 0; |
| | | |
| | | if (!StringUtils.isEmpty(ipAddress) && !Pattern.matches(Regular.IP, ipAddress)) { |
| | | return result; |
| | | } else { |
| | | String[] ipAddressArr = ipAddress.split("\\."); |
| | | |
| | | for (int i=0; i<ipAddressArr.length; i++) { |
| | | result += Integer.parseInt(ipAddressArr[i]) * Math.pow(256, 3-i); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 콤마로 구분된 문자열을 IP 배열로 변환 |
| | | * @param ipAddressList 콤마로 구분된 IP 문자열 |
| | | * @return 정수로 변환한 배열 |
| | | */ |
| | | public static List<Long> ipToLongs(String ipAddressList) { |
| | | if (!StringUtils.isEmpty(ipAddressList)) { |
| | | String[] split = ipAddressList.split(CommonUtil.COMMA); |
| | | List<Long> longs = Lists.newArrayList(); |
| | | for (String str : split) { |
| | | longs.add(ipToLong(str)); |
| | | } |
| | | return longs; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | } |