List of usage examples for org.springframework.util Assert notNull
@Deprecated public static void notNull(@Nullable Object object)
From source file:org.nebulaframework.util.io.IOSupport.java
/** * Reads from the given {@codeInputStream} until end of stream * and returns the data read as a {@code byte[]} * // w ww . ja v a 2 s.c o m * @param is InputStream * * @return bytes read as {@code byte[]} * * @throws IOException If IO error occurs during operation * @throws IllegalArgumentException if {@code InputStream} is {@code null} */ public static byte[] readBytes(InputStream is) throws IOException, IllegalArgumentException { Assert.notNull(is); int byteRead = -1; List<Byte> list = new ArrayList<Byte>(); // Read all bytes while ((byteRead = is.read()) != -1) { list.add((byte) byteRead); } // Convert to byte[] and return return tobyteArray(list); }
From source file:com.ewcms.publication.freemarker.directive.out.DefaultDirectiveOut.java
@SuppressWarnings("rawtypes") @Override//from ww w . j a va 2s .c o m public String constructOut(Object value, Environment env, Map params) throws TemplateModelException { Assert.notNull(value); return value.toString(); }
From source file:com.iterzp.momo.utils.WebUtils.java
/** * cookie/*from w w w.j ava2 s. c om*/ * * @param request * HttpServletRequest * @param response * HttpServletResponse * @param name * cookie?? * @param value * cookie * @param maxAge * (??: ) * @param path * * @param domain * * @param secure * ?? */ public static void addCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, Integer maxAge, String path, String domain, Boolean secure) { Assert.notNull(request); Assert.notNull(response); Assert.hasText(name); try { name = URLEncoder.encode(name, "UTF-8"); value = URLEncoder.encode(value, "UTF-8"); Cookie cookie = new Cookie(name, value); if (maxAge != null) { cookie.setMaxAge(maxAge); } if (StringUtils.isNotEmpty(path)) { cookie.setPath(path); } if (StringUtils.isNotEmpty(domain)) { cookie.setDomain(domain); } if (secure != null) { cookie.setSecure(secure); } response.addCookie(cookie); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:com.iterzp.momo.utils.RSAUtils.java
/** * /*from w ww . ja v a 2s .com*/ * * @param publicKey * * @param data * ? * @return ?? */ public static byte[] encrypt(PublicKey publicKey, byte[] data) { Assert.notNull(publicKey); Assert.notNull(data); try { Cipher cipher = Cipher.getInstance("RSA", PROVIDER); cipher.init(Cipher.ENCRYPT_MODE, publicKey); return cipher.doFinal(data); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.dianping.lion.util.BeanUtils.java
public static Field getDeclaredField(Class<?> clazz, String propertyName) throws NoSuchFieldException { Assert.notNull(clazz); Assert.hasText(propertyName);//from ww w . j a v a 2s . c o m for (Class<?> superClass = clazz; superClass != Object.class; superClass = superClass.getSuperclass()) { try { return superClass.getDeclaredField(propertyName); } catch (NoSuchFieldException e) { // Field??,? logger.debug("no such method !"); } } throw new NoSuchFieldException("No such field: " + clazz.getName() + '.' + propertyName); }
From source file:org.eclipse.swordfish.core.util.ServiceMixSupport.java
public static Exchange toNMRExchange(MessageExchange messageExchange) { Assert.notNull(messageExchange); Assert.isTrue(messageExchange instanceof MessageExchangeImpl); return ((MessageExchangeImpl) messageExchange).getInternalExchange(); }
From source file:spring.osgi.context.internal.classloader.ClassLoaderFactory.java
/** * Returns the wrapped class loader for the given bundle. * <p/>/*from ww w .jav a 2 s . c o m*/ * <p/> * <p/> Useful when creating importers/exporters programmatically. * * @param bundle OSGi bundle * @return associated wrapping class loader */ public static ClassLoader getBundleClassLoaderFor(Bundle bundle) { Assert.notNull(bundle); return bundleClassLoaderFactory.createClassLoader(bundle); }
From source file:com.github.woozoo73.test.dummy.User.java
public User(String id, String name) { Assert.notNull(id); Assert.notNull(name); setId(id); setName(name); }
From source file:net.groupbuy.dao.impl.AttributeDaoImpl.java
/** * propertyIndex?/*from w ww . j a v a 2s.co m*/ * * @param attribute * */ @Override public void persist(Attribute attribute) { Assert.notNull(attribute); String jpql = "select attribute.propertyIndex from Attribute attribute where attribute.productCategory = :productCategory"; List<Integer> propertyIndexs = entityManager.createQuery(jpql, Integer.class) .setFlushMode(FlushModeType.COMMIT).setParameter("productCategory", attribute.getProductCategory()) .getResultList(); for (int i = 0; i < Product.ATTRIBUTE_VALUE_PROPERTY_COUNT; i++) { if (!propertyIndexs.contains(i)) { attribute.setPropertyIndex(i); super.persist(attribute); break; } } }
From source file:com.nmote.xr.spring.XRSpringExporter.java
public void destroy() throws Exception { Assert.notNull(servletContext); servletContext.removeAttribute(endpointKey); }