List of usage examples for org.apache.commons.lang ArrayUtils isNotEmpty
public static boolean isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not null
.
From source file:de.pawlidi.openaletheia.Aletheia.java
/** * Use following arguments./*from w ww .j av a 2s .c o m*/ * <ol> * <li>Create private and public key -> <code> 1 C:\temp</code></li> * <li>Encrypt password -> <code> 2 C:\temp LfhPCfmr6AHP</code></li> * <li>Decrypt password -> <code> 3 C:\temp wqefasdv234q4512tsdg</code></li> * </ol> * * @param args * @throws IOException */ public static void main(String[] args) throws IOException { if (ArrayUtils.isNotEmpty(args)) { final String command = args[0]; if ("1".equalsIgnoreCase(command)) { if (args.length > 1) { generateKeyFiles(args[1]); } } else if ("2".equalsIgnoreCase(command)) { if (args.length >= 3) { System.out.println(encryptPassword(args[1], args[2])); } } else if ("3".equalsIgnoreCase(command)) { if (args.length >= 3) { System.out.println(decryptPassword(args[1], args[2])); } } } }
From source file:cn.loveapple.client.android.util.ComponentUtil.java
/** * {@linkplain Activity}??/??{@linkplain View}? * //w w w . j a v a 2 s .com * @param target{@linkplain Activity} * @param visibleList * @param invisibleList * @param gonList */ public static void setVisibilityList(Activity target, View[] visibleList, View[] invisibleList, View[] goneList) { if (ArrayUtils.isNotEmpty(visibleList)) { for (View v : visibleList) { if (v == null) { continue; } v.setVisibility(View.VISIBLE); } } if (ArrayUtils.isNotEmpty(invisibleList)) { for (View v : invisibleList) { if (v == null) { continue; } v.setVisibility(View.INVISIBLE); } } if (ArrayUtils.isNotEmpty(goneList)) { for (View v : goneList) { if (v == null) { continue; } v.setVisibility(View.GONE); } } }
From source file:net.shopxx.util.CompressUtils.java
public static void archive(File[] srcFiles, File destFile, String archiverName) { Assert.notNull(destFile);//from w ww. j av a 2 s. co m Assert.state(!destFile.exists() || destFile.isFile()); Assert.hasText(archiverName); File parentFile = destFile.getParentFile(); if (parentFile != null) { parentFile.mkdirs(); } ArchiveOutputStream archiveOutputStream = null; try { archiveOutputStream = new ArchiveStreamFactory().createArchiveOutputStream(archiverName, new BufferedOutputStream(new FileOutputStream(destFile))); if (ArrayUtils.isNotEmpty(srcFiles)) { for (File srcFile : srcFiles) { if (srcFile == null || !srcFile.exists()) { continue; } Set<File> files = new HashSet<File>(); if (srcFile.isFile()) { files.add(srcFile); } if (srcFile.isDirectory()) { files.addAll(FileUtils.listFilesAndDirs(srcFile, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)); } String basePath = FilenameUtils.getFullPath(srcFile.getCanonicalPath()); for (File file : files) { try { String entryName = FilenameUtils.separatorsToUnix( StringUtils.substring(file.getCanonicalPath(), basePath.length())); ArchiveEntry archiveEntry = archiveOutputStream.createArchiveEntry(file, entryName); archiveOutputStream.putArchiveEntry(archiveEntry); if (file.isFile()) { InputStream inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(file)); IOUtils.copy(inputStream, archiveOutputStream); } catch (FileNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(inputStream); } } } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { archiveOutputStream.closeArchiveEntry(); } } } } } catch (ArchiveException e) { throw new RuntimeException(e.getMessage(), e); } catch (FileNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(archiveOutputStream); } }
From source file:com.tacitknowledge.noexcuses.EnumTypeHandler.java
@Override @SuppressWarnings("unchecked") public <T> T createInstance(Class<T> type) { T instance = null;/*from w ww . j a v a2s . c o m*/ if (type.isEnum()) { Object[] enums = type.getEnumConstants(); if (ArrayUtils.isNotEmpty(enums)) { instance = (T) enums[0]; } } return instance; }
From source file:com.vmware.bdd.service.resmgmt.sync.filter.VcResourceNameFilter.java
public VcResourceNameFilter(String[] names) { AuAssert.check(ArrayUtils.isNotEmpty(names), "can't build an empty name regx filter."); for (String name : names) { nameSet.add(name);// ww w. j a va 2 s. co m } }
From source file:com.mirth.connect.server.util.javascript.MirthContextFactory.java
public MirthContextFactory(URL[] urls, Set<String> resourceIds) { this.id = UUID.randomUUID().toString(); this.urls = urls; this.resourceIds = resourceIds; ClassLoader classLoader = null; if (ArrayUtils.isNotEmpty(urls)) { classLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader()); } else {/*from w w w . jav a 2 s . c om*/ classLoader = Thread.currentThread().getContextClassLoader(); } initApplicationClassLoader(classLoader); sealedSharedScope = JavaScriptScopeUtil.createSealedSharedScope(this); serializer = new ObjectXMLSerializer(classLoader); try { serializer.init(ControllerFactory.getFactory().createConfigurationController().getServerVersion()); } catch (Exception e) { } }
From source file:info.archinnov.achilles.internal.statement.wrapper.AbstractStatementWrapper.java
protected AbstractStatementWrapper(Object[] values) { if (ArrayUtils.isNotEmpty(values)) this.values = values; }
From source file:com.vmware.bdd.service.resmgmt.sync.filter.HostFilterByNetwork.java
public HostFilterByNetwork(String[] vcNetworkNames) { AuAssert.check(ArrayUtils.isNotEmpty(vcNetworkNames), "can't build an empty name regx filter."); for (String name : vcNetworkNames) { requiredNetworkNameSet.add(name); }// w ww . j ava 2s.com }
From source file:com.vmware.bdd.service.resmgmt.sync.filter.VcResourceNameRegxFilter.java
public VcResourceNameRegxFilter(String[] nameRegs) { AuAssert.check(ArrayUtils.isNotEmpty(nameRegs), "can't build an empty name regx filter."); HashSet<String> nameRegSet = new HashSet<>(); for (String name : nameRegs) { nameRegSet.add(name);//from www.j ava 2 s .com } for (String nameReg : nameRegSet) { Pattern pattern = Pattern.compile(nameReg); regxList.add(pattern); } }
From source file:com.vmware.bdd.service.resmgmt.sync.filter.HostFilterByDsNameRegx.java
public HostFilterByDsNameRegx(String[] vcDsNameRegxs) { AuAssert.check(ArrayUtils.isNotEmpty(vcDsNameRegxs), "can't build an empty name regx filter."); HashSet<String> nameRegSet = new HashSet<>(); for (String name : vcDsNameRegxs) { nameRegSet.add(name);//from w ww.ja v a2s. c om } for (String nameReg : nameRegSet) { Pattern pattern = Pattern.compile(nameReg); dsNameRegxSet.add(pattern); } }