target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void getFreeURLsPostRequest() { assertArrayEquals(autowiredSc.getFreeURLsPostRequest(), freeURLsPostRequestBind.split(SEPARATOR)); }
public String[] getFreeURLsPostRequest() { return freeURLsPostRequest.split(";"); }
SecurityConst { public String[] getFreeURLsPostRequest() { return freeURLsPostRequest.split(";"); } }
SecurityConst { public String[] getFreeURLsPostRequest() { return freeURLsPostRequest.split(";"); } }
SecurityConst { public String[] getFreeURLsPostRequest() { return freeURLsPostRequest.split(";"); } String[] getFreeURLsAnyRequest(); String[] getFreeURLsGetRequest(); String[] getFreeURLsPostRequest(); }
SecurityConst { public String[] getFreeURLsPostRequest() { return freeURLsPostRequest.split(";"); } String[] getFreeURLsAnyRequest(); String[] getFreeURLsGetRequest(); String[] getFreeURLsPostRequest(); static final String AUTHORITIES_SEPARATOR; static final String ACCESS_TOKEN_URL; static final String USERNAME_HOLDER; static final String USERNAME_REGEXP; }
@Test public void getBAuthorizationDAOOK() { daoProvider = new DAOProvider(queryService); ReflectionTestUtils.setField(daoProvider, URL, URL_VALUE); Assert.assertNotNull(daoProvider.getBAuthorizationDAO()); }
public BAuthorizationDAO getBAuthorizationDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBAuthorizationDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); }
DAOProvider { public BAuthorizationDAO getBAuthorizationDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBAuthorizationDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } }
DAOProvider { public BAuthorizationDAO getBAuthorizationDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBAuthorizationDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } @Autowired DAOProvider(final QueryService queryService); }
DAOProvider { public BAuthorizationDAO getBAuthorizationDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBAuthorizationDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } @Autowired DAOProvider(final QueryService queryService); BAuthorizationDAO getBAuthorizationDAO(); BPermissionDAO getBPermissionDAO(); }
DAOProvider { public BAuthorizationDAO getBAuthorizationDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBAuthorizationDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } @Autowired DAOProvider(final QueryService queryService); BAuthorizationDAO getBAuthorizationDAO(); BPermissionDAO getBPermissionDAO(); }
@Test public void getBPermissionDAOOK() { daoProvider = new DAOProvider(queryService); ReflectionTestUtils.setField(daoProvider, URL, URL_VALUE); Assert.assertNotNull(daoProvider.getBPermissionDAO()); }
public BPermissionDAO getBPermissionDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBPermissionDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); }
DAOProvider { public BPermissionDAO getBPermissionDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBPermissionDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } }
DAOProvider { public BPermissionDAO getBPermissionDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBPermissionDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } @Autowired DAOProvider(final QueryService queryService); }
DAOProvider { public BPermissionDAO getBPermissionDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBPermissionDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } @Autowired DAOProvider(final QueryService queryService); BAuthorizationDAO getBAuthorizationDAO(); BPermissionDAO getBPermissionDAO(); }
DAOProvider { public BPermissionDAO getBPermissionDAO() { if (DatabaseDriver.fromJdbcUrl(url) == DatabaseDriver.POSTGRESQL) { return new PostgreSQLBPermissionDAO(queryService); } throw new NullPointerException(NOT_IMPLEMENTED_YET); } @Autowired DAOProvider(final QueryService queryService); BAuthorizationDAO getBAuthorizationDAO(); BPermissionDAO getBPermissionDAO(); }
@Test public void shouldReturnExpectedRandomsFor5And9() { assertThat(rand.nextInt(5), equalTo(2)); assertThat(rand.nextInt(9), equalTo(3)); assertThat(rand.nextInt(5), equalTo(3)); assertThat(rand.nextInt(9), equalTo(3)); assertThat(rand.nextInt(5), equalTo(3)); assertThat(rand.nextInt(9), equalTo(8)); assertThat(rand.nextInt(5), equalTo(4)); assertThat(rand.nextInt(9), equalTo(2)); }
@Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } ReplayingRandom(String five, String nine); }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } ReplayingRandom(String five, String nine); @Override int nextInt(int n); }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } ReplayingRandom(String five, String nine); @Override int nextInt(int n); }
@Test(expected = UnsupportedOperationException.class) public void shouldFailForOthers() { rand.nextInt(3); }
@Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } ReplayingRandom(String five, String nine); }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } ReplayingRandom(String five, String nine); @Override int nextInt(int n); }
ReplayingRandom extends Random { @Override public int nextInt(int n) { if (n == 5) { return getNextValueOf(fives, indexInFives++); } else if (n == 9) { return getNextValueOf(nines, indexInNines++); } throw new UnsupportedOperationException("not expected invocation of nextInt(" + n + ")"); } ReplayingRandom(String five, String nine); @Override int nextInt(int n); }
@Test public void testWriteExcel() { HttpServletResponseExcelWrite.build(fileName, request, response) .deal(ExcelDataList.getTitle(), get(), ExcelDataList.getTenList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } private HttpServletResponseExcelWrite(HttpServletRequest request, HttpServletResponse response); }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } private HttpServletResponseExcelWrite(HttpServletRequest request, HttpServletResponse response); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response); static ExcelWrite build(String fileName, HttpServletRequest request, HttpServletResponse response); }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } private HttpServletResponseExcelWrite(HttpServletRequest request, HttpServletResponse response); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response); static ExcelWrite build(String fileName, HttpServletRequest request, HttpServletResponse response); }
@Test public void testCglibGetProxy() { ProxyFactory proxyFactory = new ProxyFactory(); Audi audi = new Audi(); TargetSource targetSource = new SingletonTargetSource(audi); proxyFactory.setTargetSource(targetSource); Advisor[] advisors = new Advisor[1]; advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory.addAdvisors(advisors); Audi proxy = (Audi) proxyFactory.getProxy(); Audi obj = SpringProxyUtils.getRealTarget(proxy); assertEquals(audi, obj); }
public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
@Test public void testIsMultipleProxy() { Bmw bmw = new Bmw(); ProxyFactory proxyFactory1 = new ProxyFactory(); TargetSource targetSource1 = new SingletonTargetSource(bmw); proxyFactory1.setTargetSource(targetSource1); Advisor[] advisors = new Advisor[1]; advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory1.addAdvisors(advisors); Object object = proxyFactory1.getProxy(); ProxyFactory proxyFactory = new ProxyFactory(); TargetSource targetSource = new SingletonTargetSource(object); proxyFactory.setTargetSource(targetSource); Class<?>[] targetInterfaces = ClassUtils.getAllInterfacesForClass(bmw.getClass()); for (Class<?> targetInterface : targetInterfaces) { proxyFactory.addInterface(targetInterface); } advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory.addAdvisors(advisors); Car proxy = (Car) proxyFactory.getProxy(); assertTrue(SpringProxyUtils.isMultipleProxy(proxy)); SpringProxyUtils.getRealTarget(proxy); }
public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } } }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } } }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
SpringProxyUtils { public static boolean isMultipleProxy(Object proxy) { try { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return false; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return false; } return AopUtils.isAopProxy(targetSource.getTarget()); } catch (Exception e) { throw new IllegalArgumentException("proxy args maybe not proxy " + "with cglib or jdk dynamic proxy. this method not support", e); } } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
@Test public void testGetRealTarget() { Bmw bmw = new Bmw(); ProxyFactory proxyFactory1 = new ProxyFactory(); TargetSource targetSource1 = new SingletonTargetSource(bmw); proxyFactory1.setTargetSource(targetSource1); Advisor[] advisors = new Advisor[1]; advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory1.addAdvisors(advisors); Object object = proxyFactory1.getProxy(); ProxyFactory proxyFactory = new ProxyFactory(); TargetSource targetSource = new SingletonTargetSource(object); proxyFactory.setTargetSource(targetSource); Class<?>[] targetInterfaces = ClassUtils.getAllInterfacesForClass(bmw.getClass()); for (Class<?> targetInterface : targetInterfaces) { proxyFactory.addInterface(targetInterface); } advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory.addAdvisors(advisors); Car proxy = (Car) proxyFactory.getProxy(); Object target = SpringProxyUtils.getRealTarget(proxy); assertEquals(bmw, target); assertEquals(bmw, SpringProxyUtils.getRealTarget(proxy)); }
public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
@Test public void testFindJdkDynamicProxyFactory() { ProxyFactory proxyFactory = new ProxyFactory(); Bmw bmw = new Bmw(); TargetSource targetSource = new SingletonTargetSource(bmw); proxyFactory.setTargetSource(targetSource); Class<?>[] targetInterfaces = ClassUtils.getAllInterfacesForClass(bmw.getClass()); for (Class<?> targetInterface : targetInterfaces) { proxyFactory.addInterface(targetInterface); } Advisor[] advisors = new Advisor[1]; advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory.addAdvisors(advisors); Car proxy = (Car) proxyFactory.getProxy(); SpringProxyUtils.findJdkDynamicProxyFactory(proxy); }
public static ProxyFactory findJdkDynamicProxyFactory(Object proxy) { InvocationHandler h = Proxy.getInvocationHandler(proxy); ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(h); return (ProxyFactory) accessor.getPropertyValue("advised"); }
SpringProxyUtils { public static ProxyFactory findJdkDynamicProxyFactory(Object proxy) { InvocationHandler h = Proxy.getInvocationHandler(proxy); ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(h); return (ProxyFactory) accessor.getPropertyValue("advised"); } }
SpringProxyUtils { public static ProxyFactory findJdkDynamicProxyFactory(Object proxy) { InvocationHandler h = Proxy.getInvocationHandler(proxy); ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(h); return (ProxyFactory) accessor.getPropertyValue("advised"); } }
SpringProxyUtils { public static ProxyFactory findJdkDynamicProxyFactory(Object proxy) { InvocationHandler h = Proxy.getInvocationHandler(proxy); ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(h); return (ProxyFactory) accessor.getPropertyValue("advised"); } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
SpringProxyUtils { public static ProxyFactory findJdkDynamicProxyFactory(Object proxy) { InvocationHandler h = Proxy.getInvocationHandler(proxy); ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(h); return (ProxyFactory) accessor.getPropertyValue("advised"); } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
@Test public void testGetRealTarget2() { Bmw bmw = new Bmw(); ProxyFactory proxyFactory1 = new ProxyFactory(); TargetSource targetSource1 = new SingletonTargetSource(bmw); proxyFactory1.setTargetSource(targetSource1); Advisor[] advisors = new Advisor[1]; advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory1.addAdvisors(advisors); Object object = proxyFactory1.getProxy(); ProxyFactory proxyFactory = new ProxyFactory(); TargetSource targetSource = new SingletonTargetSource(object); proxyFactory.setTargetSource(targetSource); Class<?>[] targetInterfaces = ClassUtils.getAllInterfacesForClass(bmw.getClass()); for (Class<?> targetInterface : targetInterfaces) { proxyFactory.addInterface(targetInterface); } advisors[0] = advisorAdapterRegistry.wrap(new TestMethodInterceptor()); proxyFactory.addAdvisors(advisors); Car proxy = (Car) proxyFactory.getProxy(); Object target = SpringProxyUtils.getRealTarget(proxy); assertEquals(bmw, target); assertEquals(bmw, SpringProxyUtils.getRealTarget(proxy)); }
public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
SpringProxyUtils { public static <T> T getRealTarget(Object proxy) { Assert.notNull(proxy, "proxy not null"); while (AopUtils.isAopProxy(proxy)) { ProxyFactory proxyFactory = getProxyFactory(proxy); if (proxyFactory == null) { return null; } ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(proxyFactory); TargetSource targetSource = (TargetSource) accessor.getPropertyValue("targetSource"); if (targetSource == null) { return null; } try { proxy = targetSource.getTarget(); } catch (Exception e) { e.printStackTrace(); } } return (T) proxy; } static T getRealTarget(Object proxy); static boolean isMultipleProxy(Object proxy); static ProxyFactory findJdkDynamicProxyFactory(Object proxy); static ProxyFactory findCglibProxyFactory(Object proxy); static boolean isTransactional(Object proxy); static void removeTransactional(Object proxy); static boolean isAsync(Object proxy); static void removeAsync(Object proxy); }
@Test public void testGetFactory() { try { ServiceLocator.getBean("test"); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "没有注入spring factory"); } }
public static ApplicationContext getFactory() { Assert.notNull(factory, "没有注入spring factory"); return factory; }
ServiceLocator implements ApplicationContextAware { public static ApplicationContext getFactory() { Assert.notNull(factory, "没有注入spring factory"); return factory; } }
ServiceLocator implements ApplicationContextAware { public static ApplicationContext getFactory() { Assert.notNull(factory, "没有注入spring factory"); return factory; } }
ServiceLocator implements ApplicationContextAware { public static ApplicationContext getFactory() { Assert.notNull(factory, "没有注入spring factory"); return factory; } static ApplicationContext getFactory(); static void setFactory(ApplicationContext context); @SuppressWarnings("unchecked") static T getBean(String beanName); static Map<String, T> getBeansOfType(Class<T> type); static Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit); static T getBean(Class<T> clazz); static boolean containsBean(String name); static boolean isSingleton(String name); static Class<?> getType(String name); static String[] getAliases(String name); void setApplicationContext(ApplicationContext applicationContext); }
ServiceLocator implements ApplicationContextAware { public static ApplicationContext getFactory() { Assert.notNull(factory, "没有注入spring factory"); return factory; } static ApplicationContext getFactory(); static void setFactory(ApplicationContext context); @SuppressWarnings("unchecked") static T getBean(String beanName); static Map<String, T> getBeansOfType(Class<T> type); static Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit); static T getBean(Class<T> clazz); static boolean containsBean(String name); static boolean isSingleton(String name); static Class<?> getType(String name); static String[] getAliases(String name); void setApplicationContext(ApplicationContext applicationContext); }
@Test public void testDoParse() { final Map<String, String> placeholderVals = new HashMap<>(5); placeholderVals.put("key1", "china"); placeholderVals.put("key2", "3"); placeholderVals.put("key3", "beijin"); String testStr = "hello ${key1}"; PlaceholderResolver resolver = new PlaceholderResolver(placeholderVals::get); resolver.setPlaceholderPrefix("${"); resolver.setPlaceholderSuffix("}"); assertEquals(resolver.doParse(testStr), "hello china"); testStr = "hello ${key${key2}}"; assertEquals(resolver.doParse(testStr), "hello beijin"); }
public String doParse(String strVal) { if (strVal == null) { return null; } return parseStringValue(strVal, visitedPlaceholders); }
PlaceholderResolver { public String doParse(String strVal) { if (strVal == null) { return null; } return parseStringValue(strVal, visitedPlaceholders); } }
PlaceholderResolver { public String doParse(String strVal) { if (strVal == null) { return null; } return parseStringValue(strVal, visitedPlaceholders); } PlaceholderResolver(PlaceholderResolved resolvedInterceptor); }
PlaceholderResolver { public String doParse(String strVal) { if (strVal == null) { return null; } return parseStringValue(strVal, visitedPlaceholders); } PlaceholderResolver(PlaceholderResolved resolvedInterceptor); String doParse(String strVal); boolean hasPlaceHolder(String strVal); static boolean substringMatch(CharSequence str, int index, CharSequence substring); void setPlaceholderPrefix(String placeholderPrefix); void setPlaceholderSuffix(String placeholderSuffix); }
PlaceholderResolver { public String doParse(String strVal) { if (strVal == null) { return null; } return parseStringValue(strVal, visitedPlaceholders); } PlaceholderResolver(PlaceholderResolved resolvedInterceptor); String doParse(String strVal); boolean hasPlaceHolder(String strVal); static boolean substringMatch(CharSequence str, int index, CharSequence substring); void setPlaceholderPrefix(String placeholderPrefix); void setPlaceholderSuffix(String placeholderSuffix); static final String DEFAULT_PLACEHOLDER_PREFIX; static final String DEFAULT_PLACEHOLDER_SUFFIX; }
@Test public void testInit() { Company company = new Company(); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(company); bw.setPropertyValue("name", "Some Company Inc."); PropertyValue value = new PropertyValue("name", "Some Company Inc1."); bw.setPropertyValue(value); Employee employee = new Employee(); BeanWrapper jim = PropertyAccessorFactory.forBeanPropertyAccess(employee); PropertyValue name = new PropertyValue("name", "Some Employee Inc1."); List<PropertyValue> list = new ArrayList<>(); list.add(name); PropertyValues propertyValues = new MutablePropertyValues(list); jim.setPropertyValues(propertyValues, true); jim.setPropertyValue("salary", 1L); bw.setPropertyValue("managingDirector", jim.getWrappedInstance()); Float salary = (Float) bw.getPropertyValue("managingDirector.salary"); assertEquals(salary, Float.parseFloat("1.0")); }
@Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } } }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } } }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } } @Override final void init(FilterConfig filterConfig); @Override void destroy(); }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } } @Override final void init(FilterConfig filterConfig); @Override void destroy(); static final String JNDI_PROPERTY_PREFIX; static final String NAME; }
@Test public void testFindModel() { List<EasyUITreeModel> json = service.findChildren(getList(), p -> { EasyUITreeModel m = new EasyUITreeModel(); m.setId(p.getParamId()); m.setText(p.getParamName()); m.setPid(p.getParamType()); return m; }); assertNotNull(json); }
private EasyUITreeModel findModel(List<T> list, Function<T, EasyUITreeModel> mc) { if (null == list) { throw new RuntimeException("没有EasyUI菜单"); } Map<Integer, EasyUITreeModel> p = new HashMap<>(list.size() + 1); EasyUITreeModel root = new EasyUITreeModel(); root.setId(0); p.put(root.getId(), root); findModel(list, p, mc); root.setId(null); return root; }
EasyUITreeServiceImpl implements EasyUITreeService<T> { private EasyUITreeModel findModel(List<T> list, Function<T, EasyUITreeModel> mc) { if (null == list) { throw new RuntimeException("没有EasyUI菜单"); } Map<Integer, EasyUITreeModel> p = new HashMap<>(list.size() + 1); EasyUITreeModel root = new EasyUITreeModel(); root.setId(0); p.put(root.getId(), root); findModel(list, p, mc); root.setId(null); return root; } }
EasyUITreeServiceImpl implements EasyUITreeService<T> { private EasyUITreeModel findModel(List<T> list, Function<T, EasyUITreeModel> mc) { if (null == list) { throw new RuntimeException("没有EasyUI菜单"); } Map<Integer, EasyUITreeModel> p = new HashMap<>(list.size() + 1); EasyUITreeModel root = new EasyUITreeModel(); root.setId(0); p.put(root.getId(), root); findModel(list, p, mc); root.setId(null); return root; } }
EasyUITreeServiceImpl implements EasyUITreeService<T> { private EasyUITreeModel findModel(List<T> list, Function<T, EasyUITreeModel> mc) { if (null == list) { throw new RuntimeException("没有EasyUI菜单"); } Map<Integer, EasyUITreeModel> p = new HashMap<>(list.size() + 1); EasyUITreeModel root = new EasyUITreeModel(); root.setId(0); p.put(root.getId(), root); findModel(list, p, mc); root.setId(null); return root; } @Override List<EasyUITreeModel> findChildren(List<T> list, Function<T, EasyUITreeModel> mc); void setCheck(List<EasyUITreeModel> easyUITreeModels); }
EasyUITreeServiceImpl implements EasyUITreeService<T> { private EasyUITreeModel findModel(List<T> list, Function<T, EasyUITreeModel> mc) { if (null == list) { throw new RuntimeException("没有EasyUI菜单"); } Map<Integer, EasyUITreeModel> p = new HashMap<>(list.size() + 1); EasyUITreeModel root = new EasyUITreeModel(); root.setId(0); p.put(root.getId(), root); findModel(list, p, mc); root.setId(null); return root; } @Override List<EasyUITreeModel> findChildren(List<T> list, Function<T, EasyUITreeModel> mc); void setCheck(List<EasyUITreeModel> easyUITreeModels); }
@Test public void testWriteSingleLtMaxSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle(), get(), ExcelDataList.getTenList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteSingleGtMaxSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle(), get(), ExcelDataList.getList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getTenList()) .deal(getTitle1(), get1(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetOverMaxCountExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle1(), get1(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetNullExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), null) .deal(getTitle1(), get1(), null) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetEmptyExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), new ArrayList<>()) .deal(getTitle1(), get1(), new ArrayList<>()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetOverMaxTwoCountExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle1(), get1(), ExcelDataList.getTenList1()) .deal(getTitle(), get(), ExcelDataList.getList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetOverMaxTwoDoubleCountExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle1(), get1(), ExcelDataList.getTenList1()) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle1(), get1(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameLtMaxExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteExcelByInputStream() { HttpServletResponseExcelWrite.build(this.getClass().getResourceAsStream("/c.xls"), fileName, request, response) .deal(new WriteDeal<ExcelDto>() { public String[] dealBean(ExcelDto obj) { String[] result = new String[3]; result[0] = obj.getId() + ""; result[1] = obj.getName(); result[2] = obj.getAge() + ""; return result; } public int skipLine() { return 4; } @Override public Map<String, Object> additional() { Map<String, Object> map = new HashMap<>(); map.put("quoteCurrency", "ETH"); map.put("symbol", "USDT_ETH"); map.put("startTime", "2019-01-09 00:00:00"); map.put("endTime", "2019-01-09 12:00:00"); return map; } }, ExcelDataList.getTenList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } private HttpServletResponseExcelWrite(HttpServletRequest request, HttpServletResponse response); }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } private HttpServletResponseExcelWrite(HttpServletRequest request, HttpServletResponse response); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response); static ExcelWrite build(String fileName, HttpServletRequest request, HttpServletResponse response); }
HttpServletResponseExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new CopyInputStreamExcelWrite(inputStream, fileName, new HttpServletResponseExcelWrite(request, response)); } private HttpServletResponseExcelWrite(HttpServletRequest request, HttpServletResponse response); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName, HttpServletRequest request, HttpServletResponse response); static ExcelWrite build(String fileName, HttpServletRequest request, HttpServletResponse response); }
@Test public void testWriteMultipleSheetAndNameLtMaxDisorderExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getTenList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameOverMaxCountExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameNullExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), null) .deal(getTitle1(), getTestName(), null) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameEmptyExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), new ArrayList<>()) .deal(getTitle1(), getTestName(), new ArrayList<>()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameOverMaxCountTwoExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameOverMaxCountTwoDisorderExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetAndNameOverMaxCountTwoTwoDisorderExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .deal(getTitle1(), getTestName(), ExcelDataList.getList1()) .deal(getTitle(), getExcelDtoName(), ExcelDataList.getList()) .deal(getTitle1(), getTestName(), ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteExcelByInputStream() { FileExcelWrite.build(this.getClass().getResourceAsStream("/c.xls"), fileName) .setLargeDataMode(false) .deal(new WriteDeal<ExcelDto>() { public String[] dealBean(ExcelDto obj) { String[] result = new String[3]; result[0] = obj.getId() + ""; result[1] = obj.getName(); result[2] = obj.getAge() + ""; return result; } public int skipLine() { return 4; } @Override public Map<String, Object> additional() { Map<String, Object> map = new HashMap<>(); map.put("quoteCurrency", "ETH"); map.put("symbol", "USDT_ETH"); map.put("startTime", "2019-01-09 00:00:00"); map.put("endTime", "2019-01-09 12:00:00"); return map; } }, ExcelDataList.getTenList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteMultipleSheetExcelByInputStream() { FileExcelWrite.build(this.getClass().getResourceAsStream("/d.xls"), fileName) .setLargeDataMode(true) .deal(new WriteDeal<ExcelDto>() { public String[] dealBean(ExcelDto obj) { String[] result = new String[3]; result[0] = obj.getId() + ""; result[1] = obj.getName(); result[2] = obj.getAge() + ""; return result; } public int skipLine() { return 4; } @Override public Map<String, Object> additional() { Map<String, Object> map = new HashMap<>(); map.put("quoteCurrency", "ETH"); map.put("symbol", "USDT_ETH"); map.put("startTime", "2019-01-09 00:00:00"); map.put("endTime", "2019-01-09 12:00:00"); return map; } }, ExcelDataList.getTenList()) .deal(new WriteDeal<ExcelDto1>() { public String[] dealBean(ExcelDto1 obj) { String[] result = new String[3]; result[0] = obj.getId() + ""; result[1] = obj.getType(); result[2] = obj.getDesc(); return result; } public int skipLine() { return 4; } @Override public Map<String, Object> additional() { Map<String, Object> map = new HashMap<>(); map.put("quoteCurrency", "BTC"); map.put("symbol", "BTC_USDT"); map.put("startTime", "2019-04-01 00:00:00"); map.put("endTime", "2019-04-01 12:00:00"); return map; } }, ExcelDataList.getTenList1()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWriteExcelOverMaxCountExceptionByInputStream() { FileExcelWrite.build(this.getClass().getResourceAsStream("/c.xls"), fileName) .setLargeDataMode(true) .deal(new WriteDeal<ExcelDto>() { public String[] dealBean(ExcelDto obj) { String[] result = new String[3]; result[0] = obj.getId() + ""; result[1] = obj.getName(); result[2] = obj.getAge() + ""; return result; } public int skipLine() { return 4; } @Override public Map<String, Object> additional() { Map<String, Object> map = new HashMap<>(); map.put("quoteCurrency", "ETH"); map.put("symbol", "USDT_ETH"); map.put("startTime", "2019-01-09 00:00:00"); map.put("endTime", "2019-01-09 12:00:00"); return map; } }, ExcelDataList.getList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteSingleOverMaxSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testWriteExcelMaxCountByInputStream() { List<ExcelDto> list = ExcelDataList.getList(); list.remove(65535); list.remove(65534); list.remove(65533); list.remove(65532); FileExcelWrite.build(this.getClass().getResourceAsStream("/c.xls"), fileName) .setLargeDataMode(true) .deal(new WriteDeal<ExcelDto>() { public String[] dealBean(ExcelDto obj) { String[] result = new String[3]; result[0] = obj.getIp(); result[1] = obj.getName(); result[2] = obj.getVersion(); return result; } public int skipLine() { return 4; } @Override public Map<String, Object> additional() { Map<String, Object> map = new HashMap<>(); map.put("quoteCurrency", "ETH"); map.put("symbol", "USDT_ETH"); map.put("startTime", "2019-01-09 00:00:00"); map.put("endTime", "2019-01-09 12:00:00"); return map; } }, list) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testRead() { ExcelRead.read(ExcelReadTest.class.getResourceAsStream("/a.xls"), new ExcelReadDeal<ExcelReadDto>() { @Override public ExcelReadDto dealBean(Row row) { ExcelReadDto dto = new ExcelReadDto(); dto.setId(new BigDecimal(row.getCell(0).toString()).longValue()); dto.setName(row.getCell(1).toString()); dto.setAge(Integer.valueOf(row.getCell(2).toString())); return dto; } @Override public void dealBatchBean(List<ExcelReadDto> list) { Assert.assertEquals("name1", list.get(0).getName()); Assert.assertEquals("name2", list.get(1).getName()); Assert.assertEquals("name3", list.get(2).getName()); } }); }
public static <E> void read(InputStream inputStream, ExcelReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (Workbook wb = WorkbookFactory.create(inputStream)) { for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); if (null == sheet) { continue; } int tmp = deal.getBatchCount(); int index = 0; List<E> l = new ArrayList<>(tmp); for (Row row : sheet) { ++index; if (index <= deal.skipLine()) { continue; } E o = deal.dealBean(row); if (null != o) { l.add(o); if (index % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } } catch (Exception e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } }
ExcelRead { public static <E> void read(InputStream inputStream, ExcelReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (Workbook wb = WorkbookFactory.create(inputStream)) { for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); if (null == sheet) { continue; } int tmp = deal.getBatchCount(); int index = 0; List<E> l = new ArrayList<>(tmp); for (Row row : sheet) { ++index; if (index <= deal.skipLine()) { continue; } E o = deal.dealBean(row); if (null != o) { l.add(o); if (index % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } } catch (Exception e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } }
ExcelRead { public static <E> void read(InputStream inputStream, ExcelReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (Workbook wb = WorkbookFactory.create(inputStream)) { for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); if (null == sheet) { continue; } int tmp = deal.getBatchCount(); int index = 0; List<E> l = new ArrayList<>(tmp); for (Row row : sheet) { ++index; if (index <= deal.skipLine()) { continue; } E o = deal.dealBean(row); if (null != o) { l.add(o); if (index % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } } catch (Exception e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } }
ExcelRead { public static <E> void read(InputStream inputStream, ExcelReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (Workbook wb = WorkbookFactory.create(inputStream)) { for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); if (null == sheet) { continue; } int tmp = deal.getBatchCount(); int index = 0; List<E> l = new ArrayList<>(tmp); for (Row row : sheet) { ++index; if (index <= deal.skipLine()) { continue; } E o = deal.dealBean(row); if (null != o) { l.add(o); if (index % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } } catch (Exception e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } static void read(InputStream inputStream, ExcelReadDeal<E> deal); }
ExcelRead { public static <E> void read(InputStream inputStream, ExcelReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (Workbook wb = WorkbookFactory.create(inputStream)) { for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); if (null == sheet) { continue; } int tmp = deal.getBatchCount(); int index = 0; List<E> l = new ArrayList<>(tmp); for (Row row : sheet) { ++index; if (index <= deal.skipLine()) { continue; } E o = deal.dealBean(row); if (null != o) { l.add(o); if (index % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } } catch (Exception e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } static void read(InputStream inputStream, ExcelReadDeal<E> deal); }
@Test public void testRead() { CSVRead.read(CSVReadTest.class.getResourceAsStream("/a.csv"), new CSVReadDeal<CsvReadDto>() { @Override public CsvReadDto dealBean(String[] arr) { CsvReadDto dto = new CsvReadDto(); dto.setId(Long.valueOf(arr[0])); dto.setName(arr[1]); dto.setAge(Integer.valueOf(arr[2])); return dto; } @Override public void dealBatchBean(List<CsvReadDto> list) { Assert.assertEquals("name1", list.get(0).getName()); Assert.assertEquals("name2", list.get(1).getName()); Assert.assertEquals("name3", list.get(2).getName()); } }); }
public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } static void read(InputStream inputStream, CSVReadDeal<E> deal); static void read(InputStream inputStream, CSVReadDeal<E> deal, CSVParser parser); static void read(InputStream inputStream, CSVReadDeal<E> deal, Function<Reader, CSVReader> function); }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } static void read(InputStream inputStream, CSVReadDeal<E> deal); static void read(InputStream inputStream, CSVReadDeal<E> deal, CSVParser parser); static void read(InputStream inputStream, CSVReadDeal<E> deal, Function<Reader, CSVReader> function); }
@Test public void testRead1() { CSVParser parser = new CSVParserBuilder().withSeparator('|').withIgnoreQuotations(true).build(); CSVRead.read(CSVReadTest.class.getResourceAsStream("/a1.csv"), new CSVReadDeal<CsvReadDto>() { @Override public CsvReadDto dealBean(String[] arr) { CsvReadDto dto = new CsvReadDto(); dto.setId(Long.valueOf(arr[0])); dto.setName(arr[1]); dto.setAge(Integer.valueOf(arr[2])); return dto; } @Override public void dealBatchBean(List<CsvReadDto> list) { Assert.assertEquals("name1", list.get(0).getName()); Assert.assertEquals("name2", list.get(1).getName()); Assert.assertEquals("name3", list.get(2).getName()); } }, parser); }
public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } static void read(InputStream inputStream, CSVReadDeal<E> deal); static void read(InputStream inputStream, CSVReadDeal<E> deal, CSVParser parser); static void read(InputStream inputStream, CSVReadDeal<E> deal, Function<Reader, CSVReader> function); }
CSVRead { public static <E> void read(InputStream inputStream, CSVReadDeal<E> deal) { Objects.requireNonNull(inputStream); Objects.requireNonNull(deal); try (CSVReader reader = new CSVReader(new InputStreamReader(new DataInputStream(inputStream)))) { int tmp = deal.getBatchCount(); List<E> l = new ArrayList<>(tmp); int i = 0; String [] arr; while ((arr = reader.readNext()) != null) { ++i; if (i <= deal.skipLine()) { continue; } E o = deal.dealBean(arr); if (o != null) { l.add(o); if (i % tmp == 0) { deal.dealBatchBean(l); l = new ArrayList<>(tmp); } } } if (!l.isEmpty()) { deal.dealBatchBean(l); } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { inputStream = null; } } } static void read(InputStream inputStream, CSVReadDeal<E> deal); static void read(InputStream inputStream, CSVReadDeal<E> deal, CSVParser parser); static void read(InputStream inputStream, CSVReadDeal<E> deal, Function<Reader, CSVReader> function); }
@Test public void testWrite() { String path = FilePdfWriteTest.class.getResource("/d.html").getPath(); FilePdfWrite.build(fileName) .addFontPath(fontPath) .deal(() -> { File file = new File(path); String html = null; try { html = FileUtils.readFileToString(file, Charset.forName("GBK")); } catch (IOException e) { e.printStackTrace(); } String[] h = html.split("\\$\\$\\{}"); List<String> htmls = Collections.unmodifiableList(Arrays.asList(h)); StringBuilder sb = new StringBuilder(); sb.append(htmls.get(0)); sb.append("20183732736"); sb.append(htmls.get(1)); sb.append("机械"); sb.append(htmls.get(2)); sb.append("物流"); sb.append(htmls.get(3)); sb.append("20180064"); sb.append(htmls.get(4)); sb.append("2,567"); sb.append(htmls.get(5)); sb.append("食品"); sb.append(htmls.get(6)); sb.append("箱"); sb.append(htmls.get(7)); sb.append("80"); sb.append(htmls.get(8)); sb.append("10"); sb.append(htmls.get(9)); sb.append("30"); sb.append(htmls.get(10)); sb.append("浙江杭州"); sb.append(htmls.get(11)); sb.append("陕西西安"); sb.append(htmls.get(12)); sb.append("开发"); sb.append(htmls.get(13)); sb.append("测试"); sb.append(htmls.get(14)); return sb.toString(); }) .write(); }
public static FilePdfWrite build(String fileName) { Objects.requireNonNull(fileName); return new FilePdfWrite(fileName); }
FilePdfWrite extends AbstractPdfWrite { public static FilePdfWrite build(String fileName) { Objects.requireNonNull(fileName); return new FilePdfWrite(fileName); } }
FilePdfWrite extends AbstractPdfWrite { public static FilePdfWrite build(String fileName) { Objects.requireNonNull(fileName); return new FilePdfWrite(fileName); } private FilePdfWrite(String fileName); }
FilePdfWrite extends AbstractPdfWrite { public static FilePdfWrite build(String fileName) { Objects.requireNonNull(fileName); return new FilePdfWrite(fileName); } private FilePdfWrite(String fileName); @Override PdfWrite createOutputStream(); static FilePdfWrite build(String fileName); }
FilePdfWrite extends AbstractPdfWrite { public static FilePdfWrite build(String fileName) { Objects.requireNonNull(fileName); return new FilePdfWrite(fileName); } private FilePdfWrite(String fileName); @Override PdfWrite createOutputStream(); static FilePdfWrite build(String fileName); }
@Test public void testWrite() { String path = FilePdfWriteTest.class.getResource("/d.html").getPath(); HttpServletResponsePdfWrite.build(fileName, request, response) .addFontPath(fontPath) .deal(() -> { File file = new File(path); String html = null; try { html = FileUtils.readFileToString(file, Charset.forName("GBK")); } catch (IOException e) { e.printStackTrace(); } String[] h = html.split("\\$\\$\\{}"); List<String> htmls = Collections.unmodifiableList(Arrays.asList(h)); StringBuilder sb = new StringBuilder(); sb.append(htmls.get(0)); sb.append("20183732736"); sb.append(htmls.get(1)); sb.append("机械"); sb.append(htmls.get(2)); sb.append("物流"); sb.append(htmls.get(3)); sb.append("20180064"); sb.append(htmls.get(4)); sb.append("2,567"); sb.append(htmls.get(5)); sb.append("食品"); sb.append(htmls.get(6)); sb.append("箱"); sb.append(htmls.get(7)); sb.append("80"); sb.append(htmls.get(8)); sb.append("10"); sb.append(htmls.get(9)); sb.append("30"); sb.append(htmls.get(10)); sb.append("浙江杭州"); sb.append(htmls.get(11)); sb.append("陕西西安"); sb.append(htmls.get(12)); sb.append("开发"); sb.append(htmls.get(13)); sb.append("测试"); sb.append(htmls.get(14)); return sb.toString(); }) .write(); }
public static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new HttpServletResponsePdfWrite(fileName, request, response); }
HttpServletResponsePdfWrite extends AbstractPdfWrite { public static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new HttpServletResponsePdfWrite(fileName, request, response); } }
HttpServletResponsePdfWrite extends AbstractPdfWrite { public static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new HttpServletResponsePdfWrite(fileName, request, response); } HttpServletResponsePdfWrite(String fileName, HttpServletRequest request, HttpServletResponse response); }
HttpServletResponsePdfWrite extends AbstractPdfWrite { public static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new HttpServletResponsePdfWrite(fileName, request, response); } HttpServletResponsePdfWrite(String fileName, HttpServletRequest request, HttpServletResponse response); @Override PdfWrite createOutputStream(); static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response); }
HttpServletResponsePdfWrite extends AbstractPdfWrite { public static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response) { Objects.requireNonNull(fileName); Objects.requireNonNull(request); Objects.requireNonNull(response); return new HttpServletResponsePdfWrite(fileName, request, response); } HttpServletResponsePdfWrite(String fileName, HttpServletRequest request, HttpServletResponse response); @Override PdfWrite createOutputStream(); static HttpServletResponsePdfWrite build(String fileName, HttpServletRequest request, HttpServletResponse response); }
@Test public void testGetMessageCustomExceptionAndCustomMessage() { try { try { String s = null; s.toString(); } catch (Exception e) { String[] str = {"a", "b"}; throw new SystemException("first={0}, second={1}", e, str); } } catch (Exception e) { assertEquals(e.getMessage(), "first=a, second=b"); } }
public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
@Test public void testGetMessageCustomMessage() { try { try { String s = null; s.toString(); } catch (Exception e) { throw new SystemException("自定义异常信息"); } } catch (Exception e) { assertEquals(e.getMessage(), "自定义异常信息"); } }
public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
@Test public void testGetMessageNullPointerException() { try { try { String s = null; s.toString(); } catch (Exception e) { throw new SystemException(e); } } catch (SystemException e) { assertEquals(e.getMessage(), "空指针异常"); } }
public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
@Test public void testGetMessageCustomExceptionAndMessage() { try { try { String s = null; s.toString(); } catch (Exception e) { throw new SystemException("自定义异常信息", e); } } catch (Exception e) { assertEquals(e.getMessage(), "空指针异常"); } }
public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
SystemException extends BaseSystemException { public String getMessage(Throwable t) { String oldMessage; if (t instanceof InvocationTargetException) { oldMessage = getMessage(((InvocationTargetException) t).getTargetException()); } else if (t instanceof SystemException) { oldMessage = t.getMessage(); } else if (t instanceof SQLException) { oldMessage = getSQLException(t); } else if (t instanceof RuntimeException) { if (t.getMessage() != null) { oldMessage = t.getMessage(); } else if (null != t.getCause() && null != t.getCause().getMessage()) { oldMessage = t.getCause().getMessage(); } else { oldMessage = getCommonMessage(t); } } else { oldMessage = getCommonMessage(t); } return oldMessage; } SystemException(String msg, Throwable t, String... args); SystemException(String msg); SystemException(Throwable t); SystemException(String msg, Throwable t); String getMessage(Throwable t); }
@Test public void testWriteSingleNullSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), null) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testMatch() { String s = "/time/;jsessionid=6E697A0D5DDDBC4F7206250E5E594305js/frame/menuModel.js"; assertTrue(PathPatternMatcher.match("*.js", s)); }
public static boolean match(String pattern, String str) { if (str.startsWith("/") != pattern.startsWith("/")) { return false; } List patDirs = tokenizePath(pattern); List strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; int strIdxStart = 0; int strIdxEnd = strDirs.size() - 1; while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxStart); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxStart))) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { return false; } } while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxEnd); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxEnd))) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (patDirs.get(i).equals("**")) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { patIdxStart++; continue; } int patLength = patIdxTmp - patIdxStart - 1; int strLength = strIdxEnd - strIdxStart + 1; int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = (String) patDirs.get(patIdxStart + j + 1); String subStr = (String) strDirs.get(strIdxStart + i + j); if (!matchStrings(subPat, subStr)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; }
PathPatternMatcher { public static boolean match(String pattern, String str) { if (str.startsWith("/") != pattern.startsWith("/")) { return false; } List patDirs = tokenizePath(pattern); List strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; int strIdxStart = 0; int strIdxEnd = strDirs.size() - 1; while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxStart); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxStart))) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { return false; } } while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxEnd); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxEnd))) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (patDirs.get(i).equals("**")) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { patIdxStart++; continue; } int patLength = patIdxTmp - patIdxStart - 1; int strLength = strIdxEnd - strIdxStart + 1; int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = (String) patDirs.get(patIdxStart + j + 1); String subStr = (String) strDirs.get(strIdxStart + i + j); if (!matchStrings(subPat, subStr)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } }
PathPatternMatcher { public static boolean match(String pattern, String str) { if (str.startsWith("/") != pattern.startsWith("/")) { return false; } List patDirs = tokenizePath(pattern); List strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; int strIdxStart = 0; int strIdxEnd = strDirs.size() - 1; while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxStart); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxStart))) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { return false; } } while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxEnd); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxEnd))) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (patDirs.get(i).equals("**")) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { patIdxStart++; continue; } int patLength = patIdxTmp - patIdxStart - 1; int strLength = strIdxEnd - strIdxStart + 1; int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = (String) patDirs.get(patIdxStart + j + 1); String subStr = (String) strDirs.get(strIdxStart + i + j); if (!matchStrings(subPat, subStr)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } }
PathPatternMatcher { public static boolean match(String pattern, String str) { if (str.startsWith("/") != pattern.startsWith("/")) { return false; } List patDirs = tokenizePath(pattern); List strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; int strIdxStart = 0; int strIdxEnd = strDirs.size() - 1; while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxStart); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxStart))) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { return false; } } while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxEnd); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxEnd))) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (patDirs.get(i).equals("**")) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { patIdxStart++; continue; } int patLength = patIdxTmp - patIdxStart - 1; int strLength = strIdxEnd - strIdxStart + 1; int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = (String) patDirs.get(patIdxStart + j + 1); String subStr = (String) strDirs.get(strIdxStart + i + j); if (!matchStrings(subPat, subStr)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } static boolean isPattern(String str); static boolean match(String pattern, String str); }
PathPatternMatcher { public static boolean match(String pattern, String str) { if (str.startsWith("/") != pattern.startsWith("/")) { return false; } List patDirs = tokenizePath(pattern); List strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; int strIdxStart = 0; int strIdxEnd = strDirs.size() - 1; while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxStart); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxStart))) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } else { if (patIdxStart > patIdxEnd) { return false; } } while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { String patDir = (String) patDirs.get(patIdxEnd); if ("**".equals(patDir)) { break; } if (!matchStrings(patDir, (String) strDirs.get(strIdxEnd))) { return false; } patIdxEnd--; strIdxEnd--; } if (strIdxStart > strIdxEnd) { for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { if (patDirs.get(i).equals("**")) { patIdxTmp = i; break; } } if (patIdxTmp == patIdxStart + 1) { patIdxStart++; continue; } int patLength = patIdxTmp - patIdxStart - 1; int strLength = strIdxEnd - strIdxStart + 1; int foundIdx = -1; strLoop: for (int i = 0; i <= strLength - patLength; i++) { for (int j = 0; j < patLength; j++) { String subPat = (String) patDirs.get(patIdxStart + j + 1); String subStr = (String) strDirs.get(strIdxStart + i + j); if (!matchStrings(subPat, subStr)) { continue strLoop; } } foundIdx = strIdxStart + i; break; } if (foundIdx == -1) { return false; } patIdxStart = patIdxTmp; strIdxStart = foundIdx + patLength; } for (int i = patIdxStart; i <= patIdxEnd; i++) { if (!patDirs.get(i).equals("**")) { return false; } } return true; } static boolean isPattern(String str); static boolean match(String pattern, String str); }
@Test public void testAdd() { assertEquals(BigDecimalUtil.add(123, 234), 357.0); }
public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testAdd1() { BigDecimal v1 = new BigDecimal(123); BigDecimal v2 = new BigDecimal(234); assertEquals(BigDecimalUtil.add(v1, v2), new BigDecimal("357.00")); }
public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double add(double v1, double v2) { return add(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testSub() { assertEquals(BigDecimalUtil.sub(123, 234), -111.0); }
public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testSub1() { BigDecimal v1 = new BigDecimal(123); BigDecimal v2 = new BigDecimal(234); assertEquals(BigDecimalUtil.sub(v1, v2), new BigDecimal("-111.00")); }
public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double sub(double v1, double v2) { return sub(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testMul() { assertEquals(BigDecimalUtil.mul(10, 23), 230.0); }
public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testMul1() { BigDecimal v1 = new BigDecimal(10); BigDecimal v2 = new BigDecimal(23); assertEquals(BigDecimalUtil.mul(v1, v2), new BigDecimal("230.00")); }
public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double mul(double v1, double v2) { return mul(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testDiv() { assertEquals(BigDecimalUtil.div(23, 10), 2.3); }
public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testDiv1() { BigDecimal v1 = new BigDecimal(23); BigDecimal v2 = new BigDecimal(10); assertEquals(BigDecimalUtil.div(v1, v2), new BigDecimal("2.30")); }
public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testDiv2() { BigDecimal v1 = new BigDecimal(23); BigDecimal v2 = new BigDecimal(0); assertEquals(BigDecimalUtil.div(v1, v2), BigDecimal.ZERO); }
public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
BigDecimalUtil { public static double div(double v1, double v2) { return div(v1, v2, Constant.DEFAULT_SCALE); } static double add(double v1, double v2); static double add(double v1, double v2, int scale); static BigDecimal add(BigDecimal v1, BigDecimal v2); static BigDecimal add(BigDecimal v1, BigDecimal v2, int scale); static double sub(double v1, double v2); static double sub(double v1, double v2, int scale); static BigDecimal sub(BigDecimal v1, BigDecimal v2); static BigDecimal sub(BigDecimal v1, BigDecimal v2, int scale); static double mul(double v1, double v2); static double mul(double v1, double v2, int scale); static BigDecimal mul(BigDecimal v1, BigDecimal v2); static BigDecimal mul(BigDecimal v1, BigDecimal v2, int scale); static double div(double v1, double v2); static double div(double v1, double v2, int scale); static BigDecimal div(BigDecimal v1, BigDecimal v2); static BigDecimal div(BigDecimal v1, BigDecimal v2, int scale); }
@Test public void testWriteSingleEmptySheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), new ArrayList<>()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testToJson() { User user = new User(); user.setName("名称"); user.setDesc("测试"); user.setAge(27); assertEquals("{\"name\":\"名称\",\"age\":27}", JsonUtil.toJson(user, "desc")); }
public static String toJson(Object obj, String... ignoreProperties) { return gson(ignoreProperties).toJson(obj); }
JsonUtil { public static String toJson(Object obj, String... ignoreProperties) { return gson(ignoreProperties).toJson(obj); } }
JsonUtil { public static String toJson(Object obj, String... ignoreProperties) { return gson(ignoreProperties).toJson(obj); } }
JsonUtil { public static String toJson(Object obj, String... ignoreProperties) { return gson(ignoreProperties).toJson(obj); } static T fromJson(String json, Class<T> clazz); static String toJson(Object obj, String... ignoreProperties); static Gson gson(String... ignoreProperties); static Gson gson1(String... ignoreProperties); static ExclusionStrategy getExclusionStrategy(String... ignoreProperties); }
JsonUtil { public static String toJson(Object obj, String... ignoreProperties) { return gson(ignoreProperties).toJson(obj); } static T fromJson(String json, Class<T> clazz); static String toJson(Object obj, String... ignoreProperties); static Gson gson(String... ignoreProperties); static Gson gson1(String... ignoreProperties); static ExclusionStrategy getExclusionStrategy(String... ignoreProperties); }
@Test public void testGetDistance() { assertEquals(MapDistance.getDistance(116.327396, 39.938416, 120.332685, 37.617222), 462.0); assertEquals(MapDistance.getDistance(120.332685, 37.617222, 116.327396, 39.938416), 462.0); }
public static double getDistance(double lng1, double lat1, double lng2, double lat2) { double radLat1 = rad(lng1); double radLat2 = rad(lng2); double difference = radLat1 - radLat2; double mdifference = rad(lat1) - rad(lat2); double distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(difference / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(mdifference / 2), 2))); distance = distance * EARTH_RADIUS; distance = Math.round(distance * 10000) / 10000; return distance; }
MapDistance { public static double getDistance(double lng1, double lat1, double lng2, double lat2) { double radLat1 = rad(lng1); double radLat2 = rad(lng2); double difference = radLat1 - radLat2; double mdifference = rad(lat1) - rad(lat2); double distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(difference / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(mdifference / 2), 2))); distance = distance * EARTH_RADIUS; distance = Math.round(distance * 10000) / 10000; return distance; } }
MapDistance { public static double getDistance(double lng1, double lat1, double lng2, double lat2) { double radLat1 = rad(lng1); double radLat2 = rad(lng2); double difference = radLat1 - radLat2; double mdifference = rad(lat1) - rad(lat2); double distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(difference / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(mdifference / 2), 2))); distance = distance * EARTH_RADIUS; distance = Math.round(distance * 10000) / 10000; return distance; } }
MapDistance { public static double getDistance(double lng1, double lat1, double lng2, double lat2) { double radLat1 = rad(lng1); double radLat2 = rad(lng2); double difference = radLat1 - radLat2; double mdifference = rad(lat1) - rad(lat2); double distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(difference / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(mdifference / 2), 2))); distance = distance * EARTH_RADIUS; distance = Math.round(distance * 10000) / 10000; return distance; } static double getDistance(double lng1, double lat1, double lng2, double lat2); static Map<String, Double> getAround(double lng, double lat, double raidusMile); }
MapDistance { public static double getDistance(double lng1, double lat1, double lng2, double lat2) { double radLat1 = rad(lng1); double radLat2 = rad(lng2); double difference = radLat1 - radLat2; double mdifference = rad(lat1) - rad(lat2); double distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(difference / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(mdifference / 2), 2))); distance = distance * EARTH_RADIUS; distance = Math.round(distance * 10000) / 10000; return distance; } static double getDistance(double lng1, double lat1, double lng2, double lat2); static Map<String, Double> getAround(double lng, double lat, double raidusMile); static final double EARTH_RADIUS; }
@Test public void testGetAround() { Map<String, Double> map = MapDistance.getAround(117.11811, 36.68484, 13000); assertEquals(map.get("maxLat"), Double.valueOf("36.941095784459634")); assertEquals(map.get("minLat"), Double.valueOf("36.42858421554037")); assertEquals(map.get("minLng"), Double.valueOf("117.001301883613")); assertEquals(map.get("maxLng"), Double.valueOf("117.234918116387")); }
public static Map<String, Double> getAround(double lng, double lat, double raidusMile) { Map<String, Double> map = new HashMap<>(); double degree = (24901 * 1609) / 360.0; double mpdLng = Double.parseDouble((degree * Math.cos(lng * (Math.PI / 180)) + "").replace("-", "")); double dpmLng = 1 / mpdLng; double radiusLng = dpmLng * raidusMile; double minLat = lat - radiusLng; double maxLat = lat + radiusLng; double dpmLat = 1 / degree; double radiusLat = dpmLat * raidusMile; double minLng = lng - radiusLat; double maxLng = lng + radiusLat; map.put("minLat", minLat); map.put("maxLat", maxLat); map.put("minLng", minLng); map.put("maxLng", maxLng); return map; }
MapDistance { public static Map<String, Double> getAround(double lng, double lat, double raidusMile) { Map<String, Double> map = new HashMap<>(); double degree = (24901 * 1609) / 360.0; double mpdLng = Double.parseDouble((degree * Math.cos(lng * (Math.PI / 180)) + "").replace("-", "")); double dpmLng = 1 / mpdLng; double radiusLng = dpmLng * raidusMile; double minLat = lat - radiusLng; double maxLat = lat + radiusLng; double dpmLat = 1 / degree; double radiusLat = dpmLat * raidusMile; double minLng = lng - radiusLat; double maxLng = lng + radiusLat; map.put("minLat", minLat); map.put("maxLat", maxLat); map.put("minLng", minLng); map.put("maxLng", maxLng); return map; } }
MapDistance { public static Map<String, Double> getAround(double lng, double lat, double raidusMile) { Map<String, Double> map = new HashMap<>(); double degree = (24901 * 1609) / 360.0; double mpdLng = Double.parseDouble((degree * Math.cos(lng * (Math.PI / 180)) + "").replace("-", "")); double dpmLng = 1 / mpdLng; double radiusLng = dpmLng * raidusMile; double minLat = lat - radiusLng; double maxLat = lat + radiusLng; double dpmLat = 1 / degree; double radiusLat = dpmLat * raidusMile; double minLng = lng - radiusLat; double maxLng = lng + radiusLat; map.put("minLat", minLat); map.put("maxLat", maxLat); map.put("minLng", minLng); map.put("maxLng", maxLng); return map; } }
MapDistance { public static Map<String, Double> getAround(double lng, double lat, double raidusMile) { Map<String, Double> map = new HashMap<>(); double degree = (24901 * 1609) / 360.0; double mpdLng = Double.parseDouble((degree * Math.cos(lng * (Math.PI / 180)) + "").replace("-", "")); double dpmLng = 1 / mpdLng; double radiusLng = dpmLng * raidusMile; double minLat = lat - radiusLng; double maxLat = lat + radiusLng; double dpmLat = 1 / degree; double radiusLat = dpmLat * raidusMile; double minLng = lng - radiusLat; double maxLng = lng + radiusLat; map.put("minLat", minLat); map.put("maxLat", maxLat); map.put("minLng", minLng); map.put("maxLng", maxLng); return map; } static double getDistance(double lng1, double lat1, double lng2, double lat2); static Map<String, Double> getAround(double lng, double lat, double raidusMile); }
MapDistance { public static Map<String, Double> getAround(double lng, double lat, double raidusMile) { Map<String, Double> map = new HashMap<>(); double degree = (24901 * 1609) / 360.0; double mpdLng = Double.parseDouble((degree * Math.cos(lng * (Math.PI / 180)) + "").replace("-", "")); double dpmLng = 1 / mpdLng; double radiusLng = dpmLng * raidusMile; double minLat = lat - radiusLng; double maxLat = lat + radiusLng; double dpmLat = 1 / degree; double radiusLat = dpmLat * raidusMile; double minLng = lng - radiusLat; double maxLng = lng + radiusLat; map.put("minLat", minLat); map.put("maxLat", maxLat); map.put("minLng", minLng); map.put("maxLng", maxLng); return map; } static double getDistance(double lng1, double lat1, double lng2, double lat2); static Map<String, Double> getAround(double lng, double lat, double raidusMile); static final double EARTH_RADIUS; }
@Test public void testLongToN62() throws Exception { assertEquals(Num62.longToN62(Long.MAX_VALUE), "AzL8n0Y58m7"); }
public static String longToN62(long l) { return longToNBuf(l, N62_CHARS).reverse().toString(); }
Num62 { public static String longToN62(long l) { return longToNBuf(l, N62_CHARS).reverse().toString(); } }
Num62 { public static String longToN62(long l) { return longToNBuf(l, N62_CHARS).reverse().toString(); } }
Num62 { public static String longToN62(long l) { return longToNBuf(l, N62_CHARS).reverse().toString(); } static String longToN62(long l); static String longToN36(long l); static String longToN62(long l, int length); static String longToN36(long l, int length); static long n62ToLong(String n62); static long n36ToLong(String n36); }
Num62 { public static String longToN62(long l) { return longToNBuf(l, N62_CHARS).reverse().toString(); } static String longToN62(long l); static String longToN36(long l); static String longToN62(long l, int length); static String longToN36(long l, int length); static long n62ToLong(String n62); static long n36ToLong(String n36); static final char[] N62_CHARS; static final char[] N36_CHARS; static final int LONG_N36_LEN; static final int LONG_N62_LEN; }
@Test public void testMapPlainPut() { Map<String, Object> map = MapUtil.<String, Object>build(1).put("name", "name").get(); assertEquals(map.get("name"), "name"); }
public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testMapPlainPutAll() { Map<String, Object> mapAll = new HashMap<>(); mapAll.put("name", "name"); mapAll.put("age", 25); Map<String, Object> map = MapUtil.<String, Object>build().putAll(mapAll).get(); assertEquals(map.get("name"), "name"); assertEquals(map.get("age"), 25); }
public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testMapPlainPutAllEmpty() { Map<String, Object> mapAll = new HashMap<>(); Map<String, Object> map = MapUtil.<String, Object>build().putAll(mapAll).get(); assertEquals(map.size(), 0); }
public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static <K, V> MapPlain<K, V> build() { return new MapPlain<>(); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testDefaultToMap() { A a = new A(); a.setName("name"); a.setAge(25); Map<String, Object> params = MapUtil.toMap(a); assertEquals(params.get("name"), "name"); assertEquals(params.get("age"), 25); }
public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testAliasMapToMap() { Map<String, String> alias = new HashMap<>(); alias.put("name", "testName"); A a = new A(); a.setName("name"); a.setAge(25); Map<String, Object> params = MapUtil.toMap(a, alias); assertEquals(params.get("testName"), "name"); assertEquals(params.get("age"), 25); }
public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(o); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; Map<String, Object> m = new HashMap<>(ts.length); for (PropertyDescriptor t : ts) { Method r = t.getReadMethod(); String name = t.getName(); if (r != null && (ignoreList == null || !ignoreList.contains(name))) { try { if (!Modifier.isPublic(r.getDeclaringClass().getModifiers())) { r.setAccessible(true); } String value; if (null != map && (value = map.get(name)) != null) { m.put(value, r.invoke(o)); } else { m.put(name, r.invoke(o)); } } catch (Throwable e) { throw new RuntimeException("Could not copy property '" + name + "' from source to target", e); } } } return m; } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testToObject() { Map<String, Object> params = new HashMap<>(); params.put("name", "name"); params.put("age", 25); A a = new A(); MapUtil.toObject(params, a); assertEquals(a.getName(), "name"); assertEquals(a.getAge(), 25); }
public static void toObject(Map<String, Object> source, Object target, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(target); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; for (PropertyDescriptor t : ts) { String name = t.getName(); if (ignoreList == null || !ignoreList.contains(name)) { Object value; if (null != source && (value = source.get(name)) != null) { ReflectUtil.setValueByField(target, name, value); } } } }
MapUtil { public static void toObject(Map<String, Object> source, Object target, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(target); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; for (PropertyDescriptor t : ts) { String name = t.getName(); if (ignoreList == null || !ignoreList.contains(name)) { Object value; if (null != source && (value = source.get(name)) != null) { ReflectUtil.setValueByField(target, name, value); } } } } }
MapUtil { public static void toObject(Map<String, Object> source, Object target, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(target); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; for (PropertyDescriptor t : ts) { String name = t.getName(); if (ignoreList == null || !ignoreList.contains(name)) { Object value; if (null != source && (value = source.get(name)) != null) { ReflectUtil.setValueByField(target, name, value); } } } } }
MapUtil { public static void toObject(Map<String, Object> source, Object target, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(target); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; for (PropertyDescriptor t : ts) { String name = t.getName(); if (ignoreList == null || !ignoreList.contains(name)) { Object value; if (null != source && (value = source.get(name)) != null) { ReflectUtil.setValueByField(target, name, value); } } } } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static void toObject(Map<String, Object> source, Object target, String... ignoreProperties) { PropertyDescriptor[] ts = ReflectUtil.getPropertyDescriptors(target); List<String> ignoreList = (ignoreProperties != null && ignoreProperties.length > 0) ? Arrays.asList(ignoreProperties) : null; for (PropertyDescriptor t : ts) { String name = t.getName(); if (ignoreList == null || !ignoreList.contains(name)) { Object value; if (null != source && (value = source.get(name)) != null) { ReflectUtil.setValueByField(target, name, value); } } } } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testWriteTwoOverMaxSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle(), get(), ExcelDataList.getList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testEmptyMapConvertToList() { Map<String, Object> map = new HashMap<>(); List<Map<String, Object>> list = MapUtil.mapConvertToList(map); assertEquals(list.size(), 0); }
public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testMapConvertToList() { Map<String, Object> map = new HashMap<>(); map.put("name", "name"); map.put("age", 25); List<Map<String, Object>> list = MapUtil.mapConvertToList(map); assertEquals(list.size(), 2); assertEquals(list.get(0).get("value"), "name"); assertEquals(list.get(1).get("value"), "age"); }
public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testMapConvertToListDefaultValue() { Map<String, Object> map = new HashMap<>(); map.put("name", "name"); map.put("age", 25); List<Map<String, Object>> list = MapUtil.mapConvertToList(map, "age"); assertTrue((Boolean) list.get(1).get("selected")); }
public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
MapUtil { public static <K, V> List<Map<String, Object>> mapConvertToList(Map<K, V> map) { return mapConvertToList(map, null); } static MapPlain<K, V> build(); static MapPlain<K, V> build(int cap); static Map<String, Object> toMap(Object o, Map<String, String> map, String... ignoreProperties); static Map<String, Object> toMap(Object o, String... ignoreProperties); static void toObject(Map<String, Object> source, Object target, String... ignoreProperties); static List<Map<String, Object>> mapConvertToList(Map<K, V> map); static List<Map<String, Object>> mapConvertToList(Map<K, V> map, Object defaultValue); }
@Test public void testGuessContentType() throws Exception { assertEquals(WebUtil.guessContentType("1.jpg"), "image/jpeg"); assertNull(WebUtil.guessContentType("2.xlsx")); assertEquals(WebUtil.guessContentType("3.png"), "image/png"); assertNull(WebUtil.guessContentType("4.csv")); assertEquals(WebUtil.guessContentType("5.zip"), "application/zip"); assertEquals(WebUtil.guessContentType("6.txt"), "text/plain"); assertNull(WebUtil.guessContentType("7.docx")); assertNull(WebUtil.guessContentType("8.doc")); assertNull(WebUtil.guessContentType("9.ppt")); assertEquals(WebUtil.guessContentType("10.pdf"), "application/pdf"); assertNull(WebUtil.guessContentType("11.xls")); }
public static String guessContentType(String fileName) { return URLConnection.getFileNameMap().getContentTypeFor(fileName); }
WebUtil { public static String guessContentType(String fileName) { return URLConnection.getFileNameMap().getContentTypeFor(fileName); } }
WebUtil { public static String guessContentType(String fileName) { return URLConnection.getFileNameMap().getContentTypeFor(fileName); } }
WebUtil { public static String guessContentType(String fileName) { return URLConnection.getFileNameMap().getContentTypeFor(fileName); } static String guessContentType(String fileName); static String encodeContentDisposition(String userAgent, String fileName); }
WebUtil { public static String guessContentType(String fileName) { return URLConnection.getFileNameMap().getContentTypeFor(fileName); } static String guessContentType(String fileName); static String encodeContentDisposition(String userAgent, String fileName); }
@Test public void testEncodeContentDisposition() throws Exception { assertEquals(MimeUtility.encodeWord("1.jpg"), "1.jpg"); }
public static String encodeContentDisposition(String userAgent, String fileName) { try { String lowUserAgent = userAgent.toLowerCase(); if (lowUserAgent.contains("msie") || lowUserAgent.contains("trident")) { return "attachment;filename=" + StringUtils.replace(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()), "+", "%20"); } else if (lowUserAgent.contains("opera")) { return "attachment;filename*=UTF-8''" + fileName; } else if (lowUserAgent.contains("safari") || lowUserAgent.contains("applewebkit") || lowUserAgent.contains("mozilla")) { return "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); } else { return "attachment;filename=" + MimeUtility.encodeWord(fileName); } } catch (UnsupportedEncodingException e) { String charset = MimeUtility.getDefaultJavaCharset(); throw new RuntimeException("default java charset [" + charset + "]", e); } }
WebUtil { public static String encodeContentDisposition(String userAgent, String fileName) { try { String lowUserAgent = userAgent.toLowerCase(); if (lowUserAgent.contains("msie") || lowUserAgent.contains("trident")) { return "attachment;filename=" + StringUtils.replace(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()), "+", "%20"); } else if (lowUserAgent.contains("opera")) { return "attachment;filename*=UTF-8''" + fileName; } else if (lowUserAgent.contains("safari") || lowUserAgent.contains("applewebkit") || lowUserAgent.contains("mozilla")) { return "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); } else { return "attachment;filename=" + MimeUtility.encodeWord(fileName); } } catch (UnsupportedEncodingException e) { String charset = MimeUtility.getDefaultJavaCharset(); throw new RuntimeException("default java charset [" + charset + "]", e); } } }
WebUtil { public static String encodeContentDisposition(String userAgent, String fileName) { try { String lowUserAgent = userAgent.toLowerCase(); if (lowUserAgent.contains("msie") || lowUserAgent.contains("trident")) { return "attachment;filename=" + StringUtils.replace(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()), "+", "%20"); } else if (lowUserAgent.contains("opera")) { return "attachment;filename*=UTF-8''" + fileName; } else if (lowUserAgent.contains("safari") || lowUserAgent.contains("applewebkit") || lowUserAgent.contains("mozilla")) { return "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); } else { return "attachment;filename=" + MimeUtility.encodeWord(fileName); } } catch (UnsupportedEncodingException e) { String charset = MimeUtility.getDefaultJavaCharset(); throw new RuntimeException("default java charset [" + charset + "]", e); } } }
WebUtil { public static String encodeContentDisposition(String userAgent, String fileName) { try { String lowUserAgent = userAgent.toLowerCase(); if (lowUserAgent.contains("msie") || lowUserAgent.contains("trident")) { return "attachment;filename=" + StringUtils.replace(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()), "+", "%20"); } else if (lowUserAgent.contains("opera")) { return "attachment;filename*=UTF-8''" + fileName; } else if (lowUserAgent.contains("safari") || lowUserAgent.contains("applewebkit") || lowUserAgent.contains("mozilla")) { return "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); } else { return "attachment;filename=" + MimeUtility.encodeWord(fileName); } } catch (UnsupportedEncodingException e) { String charset = MimeUtility.getDefaultJavaCharset(); throw new RuntimeException("default java charset [" + charset + "]", e); } } static String guessContentType(String fileName); static String encodeContentDisposition(String userAgent, String fileName); }
WebUtil { public static String encodeContentDisposition(String userAgent, String fileName) { try { String lowUserAgent = userAgent.toLowerCase(); if (lowUserAgent.contains("msie") || lowUserAgent.contains("trident")) { return "attachment;filename=" + StringUtils.replace(URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()), "+", "%20"); } else if (lowUserAgent.contains("opera")) { return "attachment;filename*=UTF-8''" + fileName; } else if (lowUserAgent.contains("safari") || lowUserAgent.contains("applewebkit") || lowUserAgent.contains("mozilla")) { return "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); } else { return "attachment;filename=" + MimeUtility.encodeWord(fileName); } } catch (UnsupportedEncodingException e) { String charset = MimeUtility.getDefaultJavaCharset(); throw new RuntimeException("default java charset [" + charset + "]", e); } } static String guessContentType(String fileName); static String encodeContentDisposition(String userAgent, String fileName); }
@Test public void testDateRedMonthBegin() { Date date = DateUtil.parse(DateUtil.YYYY_MM, "201603"); String startDate = DateUtil.dateRedMonthBegin(date, 0); assertEquals(startDate, "2016-03-01"); }
public static String dateRedMonthBegin(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-01"; }
DateUtil { public static String dateRedMonthBegin(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-01"; } }
DateUtil { public static String dateRedMonthBegin(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-01"; } }
DateUtil { public static String dateRedMonthBegin(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-01"; } static DateFormat getDateFormat(String format); static String format(String format, Date date); static Date parse(String format, String date); static String getDateStr(Date date, String format, int i, int j); static boolean isLeapYear(int year); static int maxDayOfMonth(int year, int month); static int year(Date date); static int month(Date date); static int day(Date date); static int getTimeNumber(Date date, int i); static int week(Date date); static int getQuarter(Date date); static int dayOfQuarter(Date date); static int days(Date date); static int dayOfYear(Date date); static String dateRedMonthBegin(Date date, int n); static String dateRedMonthEnd(Date date, int n); static Date getDateByCalendar(Date date, int i, int j); static long getBetweenDiff(Date startDate, Date endDate, long time); static boolean isDBDefaultDate(Date date); }
DateUtil { public static String dateRedMonthBegin(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-01"; } static DateFormat getDateFormat(String format); static String format(String format, Date date); static Date parse(String format, String date); static String getDateStr(Date date, String format, int i, int j); static boolean isLeapYear(int year); static int maxDayOfMonth(int year, int month); static int year(Date date); static int month(Date date); static int day(Date date); static int getTimeNumber(Date date, int i); static int week(Date date); static int getQuarter(Date date); static int dayOfQuarter(Date date); static int days(Date date); static int dayOfYear(Date date); static String dateRedMonthBegin(Date date, int n); static String dateRedMonthEnd(Date date, int n); static Date getDateByCalendar(Date date, int i, int j); static long getBetweenDiff(Date startDate, Date endDate, long time); static boolean isDBDefaultDate(Date date); static final String YYYYMMDD; static final String YYYY_MM_DD; static final String DDMMYY; static final String YYYY_MM; static final String YYYY_MM_DD_HH_MM_SS; static final String YYMMDDHHMMSS; static final String YYYYMMDDHH; static final String YYYYMMDDHHMMSS; static final String HH_MM_SS; static final String HHMMSS; static final String HH_MM; static final long SECOND_TIME; static final long MINUTE_TIME; static final long HOUR_TIME; static final long DAY_TIME; }
@Test public void testDateRedMonthEnd() { Date date = DateUtil.parse(DateUtil.YYYY_MM, "201603"); String endDate = DateUtil.dateRedMonthEnd(date, 0); assertEquals(endDate, "2016-03-31"); }
public static String dateRedMonthEnd(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-" + maxDayOfMonth(year, month); }
DateUtil { public static String dateRedMonthEnd(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-" + maxDayOfMonth(year, month); } }
DateUtil { public static String dateRedMonthEnd(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-" + maxDayOfMonth(year, month); } }
DateUtil { public static String dateRedMonthEnd(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-" + maxDayOfMonth(year, month); } static DateFormat getDateFormat(String format); static String format(String format, Date date); static Date parse(String format, String date); static String getDateStr(Date date, String format, int i, int j); static boolean isLeapYear(int year); static int maxDayOfMonth(int year, int month); static int year(Date date); static int month(Date date); static int day(Date date); static int getTimeNumber(Date date, int i); static int week(Date date); static int getQuarter(Date date); static int dayOfQuarter(Date date); static int days(Date date); static int dayOfYear(Date date); static String dateRedMonthBegin(Date date, int n); static String dateRedMonthEnd(Date date, int n); static Date getDateByCalendar(Date date, int i, int j); static long getBetweenDiff(Date startDate, Date endDate, long time); static boolean isDBDefaultDate(Date date); }
DateUtil { public static String dateRedMonthEnd(Date date, int n) { String str = ""; int year = year(date); int month = month(date); if (n >= 12) { int m = n % 12; int s = n / 12; month = 12 - m + month; year = year - s; } else { month = month - n; } if (month == 0) { year = year - 1; month = 12; } if (month < 10) { str = "0" + month; } else { str = month + ""; } return year + "-" + str + "-" + maxDayOfMonth(year, month); } static DateFormat getDateFormat(String format); static String format(String format, Date date); static Date parse(String format, String date); static String getDateStr(Date date, String format, int i, int j); static boolean isLeapYear(int year); static int maxDayOfMonth(int year, int month); static int year(Date date); static int month(Date date); static int day(Date date); static int getTimeNumber(Date date, int i); static int week(Date date); static int getQuarter(Date date); static int dayOfQuarter(Date date); static int days(Date date); static int dayOfYear(Date date); static String dateRedMonthBegin(Date date, int n); static String dateRedMonthEnd(Date date, int n); static Date getDateByCalendar(Date date, int i, int j); static long getBetweenDiff(Date startDate, Date endDate, long time); static boolean isDBDefaultDate(Date date); static final String YYYYMMDD; static final String YYYY_MM_DD; static final String DDMMYY; static final String YYYY_MM; static final String YYYY_MM_DD_HH_MM_SS; static final String YYMMDDHHMMSS; static final String YYYYMMDDHH; static final String YYYYMMDDHHMMSS; static final String HH_MM_SS; static final String HHMMSS; static final String HH_MM; static final long SECOND_TIME; static final long MINUTE_TIME; static final long HOUR_TIME; static final long DAY_TIME; }
@Test public void testFormat() { int count = 2; int j = 2; while (j > 0) { Thread[] threads = new Thread[count]; for (int i = 0; i < count; i++) { Thread thread = new Thread(() -> { String date = DateUtil.format(DateUtil.YYYY_MM_DD_HH_MM_SS, new Date()); assertNotNull(date); date = DateUtil.format(DateUtil.YYYY_MM_DD, new Date()); assertNotNull(date); }); threads[i] = thread; } for (int i = 0; i < count; i++) { threads[i].start(); } j--; } }
public static String format(String format, Date date) { return date != null ? getDateFormat(format).format(date) : null; }
DateUtil { public static String format(String format, Date date) { return date != null ? getDateFormat(format).format(date) : null; } }
DateUtil { public static String format(String format, Date date) { return date != null ? getDateFormat(format).format(date) : null; } }
DateUtil { public static String format(String format, Date date) { return date != null ? getDateFormat(format).format(date) : null; } static DateFormat getDateFormat(String format); static String format(String format, Date date); static Date parse(String format, String date); static String getDateStr(Date date, String format, int i, int j); static boolean isLeapYear(int year); static int maxDayOfMonth(int year, int month); static int year(Date date); static int month(Date date); static int day(Date date); static int getTimeNumber(Date date, int i); static int week(Date date); static int getQuarter(Date date); static int dayOfQuarter(Date date); static int days(Date date); static int dayOfYear(Date date); static String dateRedMonthBegin(Date date, int n); static String dateRedMonthEnd(Date date, int n); static Date getDateByCalendar(Date date, int i, int j); static long getBetweenDiff(Date startDate, Date endDate, long time); static boolean isDBDefaultDate(Date date); }
DateUtil { public static String format(String format, Date date) { return date != null ? getDateFormat(format).format(date) : null; } static DateFormat getDateFormat(String format); static String format(String format, Date date); static Date parse(String format, String date); static String getDateStr(Date date, String format, int i, int j); static boolean isLeapYear(int year); static int maxDayOfMonth(int year, int month); static int year(Date date); static int month(Date date); static int day(Date date); static int getTimeNumber(Date date, int i); static int week(Date date); static int getQuarter(Date date); static int dayOfQuarter(Date date); static int days(Date date); static int dayOfYear(Date date); static String dateRedMonthBegin(Date date, int n); static String dateRedMonthEnd(Date date, int n); static Date getDateByCalendar(Date date, int i, int j); static long getBetweenDiff(Date startDate, Date endDate, long time); static boolean isDBDefaultDate(Date date); static final String YYYYMMDD; static final String YYYY_MM_DD; static final String DDMMYY; static final String YYYY_MM; static final String YYYY_MM_DD_HH_MM_SS; static final String YYMMDDHHMMSS; static final String YYYYMMDDHH; static final String YYYYMMDDHHMMSS; static final String HH_MM_SS; static final String HHMMSS; static final String HH_MM; static final long SECOND_TIME; static final long MINUTE_TIME; static final long HOUR_TIME; static final long DAY_TIME; }
@Test public void testStringArrayWriteCsvFile() { String[] title = {"id" , "name"}; List<String[]> bodyList = new ArrayList<>(); String[] data = new String[2]; data[0] = "1"; data[1] = "张三"; bodyList.add(data); data = new String[2]; data[0] = "2"; data[1] = "李四"; bodyList.add(data); CsvUtil.writeCsvFile(fileName, title, bodyList); }
public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<T> objs, Function<T, String[]> function); static void writeCsvFile(String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(String filename, String[] title, List<T> objs, Function<T, String[]> function); }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<T> objs, Function<T, String[]> function); static void writeCsvFile(String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(String filename, String[] title, List<T> objs, Function<T, String[]> function); }
@Test public void testObjectWriteCsvFile() { String[] title = {"id" , "name"}; List<User> objs = new ArrayList<>(); User user = new User(); user.setId(1); user.setName("张三"); objs.add(user); user = new User(); user.setId(2); user.setName("李四"); objs.add(user); CsvUtil.writeCsvFile(fileName, title, objs, t -> { String[] bodyList = new String[2]; bodyList[0] = t.getId() + ""; bodyList[1] = t.getName(); return bodyList; }); }
public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<T> objs, Function<T, String[]> function); static void writeCsvFile(String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(String filename, String[] title, List<T> objs, Function<T, String[]> function); }
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } } static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<T> objs, Function<T, String[]> function); static void writeCsvFile(String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(String filename, String[] title, List<T> objs, Function<T, String[]> function); }
@Test public void testWriteThreeOverMaxSheetExcel() { FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle(), get(), ExcelDataList.getList()) .deal(getTitle(), get(), ExcelDataList.getList()) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test(expectedExceptions = NullPointerException.class) public void testGetWithKeyNull() { SystemPropertyUtil.get(null, null); }
public static String get(String key) { return get(key, null); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testGetWithKeyEmpty() { SystemPropertyUtil.get("", null); }
public static String get(String key) { return get(key, null); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test public void testGetDefaultValueWithPropertyNull() { assertEquals("default", SystemPropertyUtil.get("key", "default")); }
public static String get(String key) { return get(key, null); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test public void testGetPropertyValue() { System.setProperty("key", "value"); assertEquals("value", SystemPropertyUtil.get("key")); }
public static String get(String key) { return get(key, null); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static String get(String key) { return get(key, null); } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test public void getIntDefaultValueWithPropertyNull() { assertEquals(1, SystemPropertyUtil.getInt("key", 1)); }
public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test public void getIntWithPropertValueIsInt() { System.setProperty("key", "123"); assertEquals(123, SystemPropertyUtil.getInt("key", 1)); }
public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test public void getIntDefaultValueWithPropertValueIsNotInt() { System.setProperty("key", "NotInt"); assertEquals(1, SystemPropertyUtil.getInt("key", 1)); }
public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
SystemPropertyUtil { public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { } return def; } private SystemPropertyUtil(); static boolean contains(String key); static String get(String key); static String get(final String key, String def); static int getInt(String key, int def); }
@Test public void testUnicode2String() { assertEquals(unicode2String("\u674e"), "李"); }
public static String unicode2String(String str) { Matcher matcher = UNICODE_2_STRING_PATTERN.matcher(str); while (matcher.find()) { char ch = (char) Integer.parseInt(matcher.group(2), 16); str = str.replace(matcher.group(1), ch + ""); } return str; }
ISOUtil { public static String unicode2String(String str) { Matcher matcher = UNICODE_2_STRING_PATTERN.matcher(str); while (matcher.find()) { char ch = (char) Integer.parseInt(matcher.group(2), 16); str = str.replace(matcher.group(1), ch + ""); } return str; } }
ISOUtil { public static String unicode2String(String str) { Matcher matcher = UNICODE_2_STRING_PATTERN.matcher(str); while (matcher.find()) { char ch = (char) Integer.parseInt(matcher.group(2), 16); str = str.replace(matcher.group(1), ch + ""); } return str; } ISOUtil(); }
ISOUtil { public static String unicode2String(String str) { Matcher matcher = UNICODE_2_STRING_PATTERN.matcher(str); while (matcher.find()) { char ch = (char) Integer.parseInt(matcher.group(2), 16); str = str.replace(matcher.group(1), ch + ""); } return str; } ISOUtil(); static String ebcdicToAscii(byte[] e); static String ebcdicToAscii(byte[] e, int offset, int len); static byte[] ebcdicToAsciiBytes(byte[] e); static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len); static byte[] asciiToEbcdic(String s); static byte[] asciiToEbcdic(byte[] a); static void asciiToEbcdic(String s, byte[] e, int offset); static void asciiToEbcdic(byte[] s, byte[] e, int offset); static String padleft(String s, int len, char c); static String padright(String s, int len, char c); static String trim(String s); static String zeropad(String s, int len); static String zeropad(long l, int len); static String strpad(String s, int len); static String zeropadRight(String s, int len); static byte[] str2bcd(String s, boolean padLeft, byte[] d, int offset); static byte[] str2bcd(String s, boolean padLeft); static byte[] str2bcd(String s, boolean padLeft, byte fill); static String bcd2str(byte[] b, int offset, int len, boolean padLeft); static String hexString(byte[] b); static String dumpString(byte[] b); static String hexString(byte[] b, int offset, int len); static String bitSet2String(BitSet b); static byte[] bitSet2byte(BitSet b); static byte[] bitSet2byte(BitSet b, int bytes); static int bitSet2Int(BitSet bs); static BitSet int2BitSet(int value); static BitSet int2BitSet(int value, int offset); static BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet byte2BitSet(byte[] b, int offset, int maxBits); static BitSet byte2BitSet(BitSet bmap, byte[] b, int bitOffset); static BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet hex2BitSet(byte[] b, int offset, int maxBits); static BitSet hex2BitSet(BitSet bmap, byte[] b, int bitOffset); static byte[] hex2byte(byte[] b, int offset, int len); static byte[] hex2byte(String s); static String byte2hex(byte[] bs); static byte[] int2byte(int value); static int byte2int(byte[] bytes); static String byte2hex(byte[] bs, int off, int length); static String formatDouble(double d, int len); static String formatAmount(long l, int len); static String normalize(String s, boolean canonical); static String normalize(String s); static String protect(String s); static int[] toIntArray(String s); static String[] toStringArray(String s); static byte[] xor(byte[] op1, byte[] op2); static String hexor(String op1, String op2); static byte[] trim(byte[] array, int length); static byte[] concat(byte[] array1, byte[] array2); static byte[] concat(byte[] array1, int beginIndex1, int length1, byte[] array2, int beginIndex2, int length2); static void sleep(long millis); static String zeroUnPad(String s); static String blankUnPad(String s); static String unPadRight(String s, char c); static String unPadLeft(String s, char c); static boolean isZero(String s); static boolean isBlank(String s); static boolean isAlphaNumeric(String s); static boolean isNumeric(String s, int radix); static byte[] bitSet2extendedByte(BitSet b); static int parseInt(String s, int radix); static int parseInt(String s); static int parseInt(char[] cArray, int radix); static int parseInt(char[] cArray); static int parseInt(byte[] bArray, int radix); static int parseInt(byte[] bArray); static String hexdump(byte[] b); static String hexdump(byte[] b, int offset); static String hexdump(byte[] b, int offset, int len); static String strpadf(String s, int len); static String trimf(String s); static String takeLastN(String s, int n); static String takeFirstN(String s, int n); static String millisToString(long millis); static String formatAmountConversionRate(double convRate); static double parseAmountConversionRate(String convRate); static String commaEncode(String[] ss); static String[] commaDecode(String s); static String commaDecode(String s, int i); static char calcLUHN(String p); static String getRandomDigits(Random r, int l, int radix); static String unicode2String(String str); }
ISOUtil { public static String unicode2String(String str) { Matcher matcher = UNICODE_2_STRING_PATTERN.matcher(str); while (matcher.find()) { char ch = (char) Integer.parseInt(matcher.group(2), 16); str = str.replace(matcher.group(1), ch + ""); } return str; } ISOUtil(); static String ebcdicToAscii(byte[] e); static String ebcdicToAscii(byte[] e, int offset, int len); static byte[] ebcdicToAsciiBytes(byte[] e); static byte[] ebcdicToAsciiBytes(byte[] e, int offset, int len); static byte[] asciiToEbcdic(String s); static byte[] asciiToEbcdic(byte[] a); static void asciiToEbcdic(String s, byte[] e, int offset); static void asciiToEbcdic(byte[] s, byte[] e, int offset); static String padleft(String s, int len, char c); static String padright(String s, int len, char c); static String trim(String s); static String zeropad(String s, int len); static String zeropad(long l, int len); static String strpad(String s, int len); static String zeropadRight(String s, int len); static byte[] str2bcd(String s, boolean padLeft, byte[] d, int offset); static byte[] str2bcd(String s, boolean padLeft); static byte[] str2bcd(String s, boolean padLeft, byte fill); static String bcd2str(byte[] b, int offset, int len, boolean padLeft); static String hexString(byte[] b); static String dumpString(byte[] b); static String hexString(byte[] b, int offset, int len); static String bitSet2String(BitSet b); static byte[] bitSet2byte(BitSet b); static byte[] bitSet2byte(BitSet b, int bytes); static int bitSet2Int(BitSet bs); static BitSet int2BitSet(int value); static BitSet int2BitSet(int value, int offset); static BitSet byte2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet byte2BitSet(byte[] b, int offset, int maxBits); static BitSet byte2BitSet(BitSet bmap, byte[] b, int bitOffset); static BitSet hex2BitSet(byte[] b, int offset, boolean bitZeroMeansExtended); static BitSet hex2BitSet(byte[] b, int offset, int maxBits); static BitSet hex2BitSet(BitSet bmap, byte[] b, int bitOffset); static byte[] hex2byte(byte[] b, int offset, int len); static byte[] hex2byte(String s); static String byte2hex(byte[] bs); static byte[] int2byte(int value); static int byte2int(byte[] bytes); static String byte2hex(byte[] bs, int off, int length); static String formatDouble(double d, int len); static String formatAmount(long l, int len); static String normalize(String s, boolean canonical); static String normalize(String s); static String protect(String s); static int[] toIntArray(String s); static String[] toStringArray(String s); static byte[] xor(byte[] op1, byte[] op2); static String hexor(String op1, String op2); static byte[] trim(byte[] array, int length); static byte[] concat(byte[] array1, byte[] array2); static byte[] concat(byte[] array1, int beginIndex1, int length1, byte[] array2, int beginIndex2, int length2); static void sleep(long millis); static String zeroUnPad(String s); static String blankUnPad(String s); static String unPadRight(String s, char c); static String unPadLeft(String s, char c); static boolean isZero(String s); static boolean isBlank(String s); static boolean isAlphaNumeric(String s); static boolean isNumeric(String s, int radix); static byte[] bitSet2extendedByte(BitSet b); static int parseInt(String s, int radix); static int parseInt(String s); static int parseInt(char[] cArray, int radix); static int parseInt(char[] cArray); static int parseInt(byte[] bArray, int radix); static int parseInt(byte[] bArray); static String hexdump(byte[] b); static String hexdump(byte[] b, int offset); static String hexdump(byte[] b, int offset, int len); static String strpadf(String s, int len); static String trimf(String s); static String takeLastN(String s, int n); static String takeFirstN(String s, int n); static String millisToString(long millis); static String formatAmountConversionRate(double convRate); static double parseAmountConversionRate(String convRate); static String commaEncode(String[] ss); static String[] commaDecode(String s); static String commaDecode(String s, int i); static char calcLUHN(String p); static String getRandomDigits(Random r, int l, int radix); static String unicode2String(String str); static final String[] hexStrings; static final String ENCODING; static final Charset CHARSET; static final byte[] EBCDIC2ASCII; static final byte[] ASCII2EBCDIC; static final byte STX; static final byte FS; static final byte US; static final byte RS; static final byte GS; static final byte ETX; }
@Test public void testGetConnection() { Connection connection = dbManager.getConnection(); assertNotNull(connection); dbManager.close(connection); }
public Connection getConnection() { try { Class.forName(this.driveName); return DriverManager.getConnection(this.url, this.user, this.password); } catch (ClassNotFoundException e) { throw new RuntimeException("load database class exception : " + e.getMessage(), e); } catch (SQLException e) { throw new RuntimeException("get database connection : " + e.getMessage(), e); } }
DbManager { public Connection getConnection() { try { Class.forName(this.driveName); return DriverManager.getConnection(this.url, this.user, this.password); } catch (ClassNotFoundException e) { throw new RuntimeException("load database class exception : " + e.getMessage(), e); } catch (SQLException e) { throw new RuntimeException("get database connection : " + e.getMessage(), e); } } }
DbManager { public Connection getConnection() { try { Class.forName(this.driveName); return DriverManager.getConnection(this.url, this.user, this.password); } catch (ClassNotFoundException e) { throw new RuntimeException("load database class exception : " + e.getMessage(), e); } catch (SQLException e) { throw new RuntimeException("get database connection : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public Connection getConnection() { try { Class.forName(this.driveName); return DriverManager.getConnection(this.url, this.user, this.password); } catch (ClassNotFoundException e) { throw new RuntimeException("load database class exception : " + e.getMessage(), e); } catch (SQLException e) { throw new RuntimeException("get database connection : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public Connection getConnection() { try { Class.forName(this.driveName); return DriverManager.getConnection(this.url, this.user, this.password); } catch (ClassNotFoundException e) { throw new RuntimeException("load database class exception : " + e.getMessage(), e); } catch (SQLException e) { throw new RuntimeException("get database connection : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testGetPreparedStatement() { Connection connection = dbManager.getConnection(); PreparedStatement preparedStatement = dbManager.getPreparedStatement(connection, "select count(1) as count from tb_user"); assertNotNull(preparedStatement); dbManager.close(connection, preparedStatement, null); }
public PreparedStatement getPreparedStatement(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeException("get PrepareStatement exception : " + e.getMessage(), e); } }
DbManager { public PreparedStatement getPreparedStatement(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeException("get PrepareStatement exception : " + e.getMessage(), e); } } }
DbManager { public PreparedStatement getPreparedStatement(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeException("get PrepareStatement exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public PreparedStatement getPreparedStatement(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeException("get PrepareStatement exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public PreparedStatement getPreparedStatement(Connection connection, String sql) { try { return connection.prepareStatement(sql); } catch (SQLException e) { throw new RuntimeException("get PrepareStatement exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testWriteSingleEqualMaxSheetExcel() { List<ExcelDto> excelDtos = ExcelDataList.getList(); excelDtos.remove(65535); FileExcelWrite.build(fileName) .setLargeDataMode(false) .deal(getTitle(), get(), excelDtos) .write(); }
public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
FileExcelWrite implements OutputStreamDelegate { public static ExcelWrite build(InputStream inputStream, String fileName) { Objects.requireNonNull(inputStream); Objects.requireNonNull(fileName); return new CopyInputStreamExcelWrite(inputStream, fileName, new FileExcelWrite()); } private FileExcelWrite(); @Override OutputStream createOutputStream(String fileName); static ExcelWrite build(InputStream inputStream, String fileName); static ExcelWrite build(String fileName); }
@Test public void testGetResultSet() throws Exception { Connection connection = dbManager.getConnection(); PreparedStatement preparedStatement = dbManager.getPreparedStatement(connection, "select count(1) as count from tb_user"); ResultSet resultSet = dbManager.getResultSet(preparedStatement); assertNotNull(resultSet); resultSet.next(); long count = resultSet.getLong("count"); assertEquals(count, 0); dbManager.close(connection, preparedStatement, resultSet); }
public ResultSet getResultSet(PreparedStatement preparedStatement) { try { return preparedStatement.executeQuery(); } catch (SQLException e) { throw new RuntimeException("get ResultSet exception : " + e.getMessage(), e); } }
DbManager { public ResultSet getResultSet(PreparedStatement preparedStatement) { try { return preparedStatement.executeQuery(); } catch (SQLException e) { throw new RuntimeException("get ResultSet exception : " + e.getMessage(), e); } } }
DbManager { public ResultSet getResultSet(PreparedStatement preparedStatement) { try { return preparedStatement.executeQuery(); } catch (SQLException e) { throw new RuntimeException("get ResultSet exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public ResultSet getResultSet(PreparedStatement preparedStatement) { try { return preparedStatement.executeQuery(); } catch (SQLException e) { throw new RuntimeException("get ResultSet exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public ResultSet getResultSet(PreparedStatement preparedStatement) { try { return preparedStatement.executeQuery(); } catch (SQLException e) { throw new RuntimeException("get ResultSet exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testGetTables() throws Exception { Connection connection = dbManager.getConnection(); ResultSet resultSet = dbManager.getTables(connection, "", "test_tmp", ""); assertNotNull(resultSet); int size = 0; while (resultSet.next()) { size++; } assertEquals(size, 1); dbManager.close(connection, null, resultSet); }
public ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getTables(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get tables exception : " + e.getMessage(), e); } }
DbManager { public ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getTables(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get tables exception : " + e.getMessage(), e); } } }
DbManager { public ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getTables(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get tables exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getTables(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get tables exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getTables(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get tables exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testGetColumns() throws Exception { Connection connection = dbManager.getConnection(); ResultSet resultSet = dbManager.getColumns(connection, "", "test_tmp", "tb_user"); assertNotNull(resultSet); int size = 0; while (resultSet.next()) { size++; } assertEquals(size, 6); dbManager.close(connection, null, resultSet); }
public ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getColumns(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get columns exception : " + e.getMessage(), e); } }
DbManager { public ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getColumns(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get columns exception : " + e.getMessage(), e); } } }
DbManager { public ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getColumns(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get columns exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getColumns(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get columns exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getColumns(localCatalog, localSchema, localTableName, null); } catch (SQLException e) { throw new RuntimeException("get columns exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testGetPrimaryKeys() throws Exception { Connection connection = dbManager.getConnection(); ResultSet resultSet = dbManager.getPrimaryKeys(connection, "", "test_tmp", "tb_user"); assertNotNull(resultSet); int size = 0; while (resultSet.next()) { size++; } assertEquals(size, 1); dbManager.close(connection, null, resultSet); }
public ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getPrimaryKeys(localCatalog, localSchema, localTableName); } catch (SQLException e) { throw new RuntimeException("get primary key exception : " + e.getMessage(), e); } }
DbManager { public ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getPrimaryKeys(localCatalog, localSchema, localTableName); } catch (SQLException e) { throw new RuntimeException("get primary key exception : " + e.getMessage(), e); } } }
DbManager { public ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getPrimaryKeys(localCatalog, localSchema, localTableName); } catch (SQLException e) { throw new RuntimeException("get primary key exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getPrimaryKeys(localCatalog, localSchema, localTableName); } catch (SQLException e) { throw new RuntimeException("get primary key exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName) { try { return getDatabaseMetaData(connection).getPrimaryKeys(localCatalog, localSchema, localTableName); } catch (SQLException e) { throw new RuntimeException("get primary key exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testGetResultSetMetaData() throws Exception { Connection connection = dbManager.getConnection(); PreparedStatement preparedStatement = dbManager.getPreparedStatement(connection, "select count(1) as count from tb_user"); ResultSet resultSet = dbManager.getResultSet(preparedStatement); ResultSetMetaData resultSetMetaData = dbManager.getResultSetMetaData(resultSet); assertNotNull(resultSetMetaData); assertEquals(resultSetMetaData.getColumnCount(), 1); }
public ResultSetMetaData getResultSetMetaData(ResultSet resultSet) { try { return resultSet.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get ResultSetMetaData exception : " + e.getMessage(), e); } }
DbManager { public ResultSetMetaData getResultSetMetaData(ResultSet resultSet) { try { return resultSet.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get ResultSetMetaData exception : " + e.getMessage(), e); } } }
DbManager { public ResultSetMetaData getResultSetMetaData(ResultSet resultSet) { try { return resultSet.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get ResultSetMetaData exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public ResultSetMetaData getResultSetMetaData(ResultSet resultSet) { try { return resultSet.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get ResultSetMetaData exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public ResultSetMetaData getResultSetMetaData(ResultSet resultSet) { try { return resultSet.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get ResultSetMetaData exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testGetDatabaseMetaData() throws Exception { Connection connection = dbManager.getConnection(); DatabaseMetaData databaseMetaData = dbManager.getDatabaseMetaData(connection); assertNotNull(databaseMetaData); assertEquals(databaseMetaData.getDatabaseProductName().toLowerCase(), "mysql"); dbManager.close(connection); }
public DatabaseMetaData getDatabaseMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get DatabaseMetaData exception : " + e.getMessage(), e); } }
DbManager { public DatabaseMetaData getDatabaseMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get DatabaseMetaData exception : " + e.getMessage(), e); } } }
DbManager { public DatabaseMetaData getDatabaseMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get DatabaseMetaData exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); }
DbManager { public DatabaseMetaData getDatabaseMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get DatabaseMetaData exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
DbManager { public DatabaseMetaData getDatabaseMetaData(Connection connection) { try { return connection.getMetaData(); } catch (SQLException e) { throw new RuntimeException("get DatabaseMetaData exception : " + e.getMessage(), e); } } DbManager(); DbManager(String url, String user, String password); Connection getConnection(); PreparedStatement getPreparedStatement(Connection connection, String sql); ResultSet getResultSet(PreparedStatement preparedStatement); ResultSet getTables(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getColumns(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSet getPrimaryKeys(Connection connection, String localCatalog, String localSchema, String localTableName); ResultSetMetaData getResultSetMetaData(ResultSet resultSet); DatabaseMetaData getDatabaseMetaData(Connection connection); void close(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet); void close(Connection connection); void close(PreparedStatement preparedStatement); void close(ResultSet resultSet); String getDriveName(); void setDriveName(String driveName); String getUrl(); void setUrl(String url); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); }
@Test public void testASCIIToEBCDIC() { byte[]c = new byte[]{1,2,3,4}; byte[] a = Coder.ASCIIToEBCDIC(c); assertEquals(a[0], 1); assertEquals(a[1], 2); assertEquals(a[2], 3); assertEquals(a[3], 55); }
public static int ASCIIToEBCDIC(int ascii) { return ASCII.AToE[ascii & 0xff] & 0xff; }
Coder { public static int ASCIIToEBCDIC(int ascii) { return ASCII.AToE[ascii & 0xff] & 0xff; } }
Coder { public static int ASCIIToEBCDIC(int ascii) { return ASCII.AToE[ascii & 0xff] & 0xff; } }
Coder { public static int ASCIIToEBCDIC(int ascii) { return ASCII.AToE[ascii & 0xff] & 0xff; } static int ASCIIToEBCDIC(int ascii); static int EBCDICToASCII(int ebcdic); static byte[] ASCIIToEBCDIC(byte[] ascii); static byte[] EBCDICToASCII(byte[] ebcdic); static String ASCIIToEBCDIC(String ascii); static String EBCDICToASCII(String ebcdic); static void ASCIIToEBCDIC(String fromFile, String toFile); static void EBCDICToASCII(String fromFile, String toFile); }
Coder { public static int ASCIIToEBCDIC(int ascii) { return ASCII.AToE[ascii & 0xff] & 0xff; } static int ASCIIToEBCDIC(int ascii); static int EBCDICToASCII(int ebcdic); static byte[] ASCIIToEBCDIC(byte[] ascii); static byte[] EBCDICToASCII(byte[] ebcdic); static String ASCIIToEBCDIC(String ascii); static String EBCDICToASCII(String ebcdic); static void ASCIIToEBCDIC(String fromFile, String toFile); static void EBCDICToASCII(String fromFile, String toFile); }
@Test public void testValidate() { User user = new User(); user.setRealName("a"); try { ValidateUtils.validate(user); } catch (Exception e) { String str = e.getMessage(); assertEquals(str, "用户id不能为空"); } }
public static <T> void validate(T bean, Class<?>... groups) { validate(bean, true, groups); }
ValidateUtils { public static <T> void validate(T bean, Class<?>... groups) { validate(bean, true, groups); } }
ValidateUtils { public static <T> void validate(T bean, Class<?>... groups) { validate(bean, true, groups); } }
ValidateUtils { public static <T> void validate(T bean, Class<?>... groups) { validate(bean, true, groups); } static void validate(T bean, Class<?>... groups); static void validate(T bean, boolean flag, Class<?>... groups); }
ValidateUtils { public static <T> void validate(T bean, Class<?>... groups) { validate(bean, true, groups); } static void validate(T bean, Class<?>... groups); static void validate(T bean, boolean flag, Class<?>... groups); }