List of usage examples for org.apache.commons.lang ArrayUtils isEmpty
public static boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null
.
From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java
/** * <p>Finds the last index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the * array length will search from the end of the array.</p> * /* ww w . jav a 2 s . c o m*/ * @param array the array to traverse for looking for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the start index to travers backwards from * @return the last index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(double[] array, double valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { return INDEX_NOT_FOUND; } else if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; i--) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java
/** * <p>Finds the last index of the given value in the array starting at the given index. * This method will return the index of the last value which falls between the region * defined by valueToFind - tolerance and valueToFind + tolerance.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the * array length will search from the end of the array.</p> * //from w ww . j a v a2s .c o m * @param array the array to traverse for looking for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the start index to travers backwards from * @param tolerance search for value within plus/minus this amount * @return the last index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(double[] array, double valueToFind, int startIndex, double tolerance) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { return INDEX_NOT_FOUND; } else if (startIndex >= array.length) { startIndex = array.length - 1; } double min = valueToFind - tolerance; double max = valueToFind + tolerance; for (int i = startIndex; i >= 0; i--) { if (array[i] >= min && array[i] <= max) { return i; } } return INDEX_NOT_FOUND; }
From source file:com.photon.phresco.framework.rest.api.QualityService.java
/** * Gets the test suite names./*from ww w .ja va 2 s .c o m*/ * * @param appDirName the app dir name * @param testType the test type * @param moduleName the module name * @param techReport the tech report * @param testResultPath the test result path * @param testSuitePath the test suite path * @return the test suite names * @throws PhrescoException the phresco exception * @throws PhrescoPomException * */ private List<String> getTestSuiteNames(String appDirName, String testType, String moduleName, String techReport, String testResultPath, String testSuitePath, String rootModulePath, String subModule, String deviceid) throws PhrescoException { File[] resultFiles = null; String name = ""; String mapKey = constructMapKey(appDirName, moduleName); String testSuitesMapKey = mapKey + testType + moduleName + techReport; Map<String, List<NodeList>> testResultNameMap = testSuiteMap.get(testSuitesMapKey); List<String> resultTestSuiteNames = null; if (StringUtils.isNotEmpty(deviceid)) { name = "TEST-" + deviceid; } resultFiles = getTestResultFiles(testResultPath, name); if (!ArrayUtils.isEmpty(resultFiles)) { QualityUtil.sortResultFile(resultFiles); updateCache(appDirName, testType, moduleName, techReport, resultFiles, testSuitePath); } testResultNameMap = testSuiteMap.get(testSuitesMapKey); //} if (testResultNameMap != null) { resultTestSuiteNames = new ArrayList<String>(testResultNameMap.keySet()); } return resultTestSuiteNames; }
From source file:com.photon.phresco.framework.rest.api.ConfigurationService.java
@GET @Path("/removeFile") @Produces(MediaType.APPLICATION_JSON)/*from ww w. j a v a 2s.c o m*/ public Response removeConfigFile(@QueryParam(REST_QUERY_APPDIR_NAME) String appDirName, @QueryParam("configType") String configType, @QueryParam("propName") String propName, @QueryParam(REST_QUERY_MODULE_NAME) String moduleName, @QueryParam("fileName") String fileName, @QueryParam("envName") String envName, @QueryParam("configName") String configName) { String rootModulePath = ""; String subModuleName = ""; if (StringUtils.isNotEmpty(moduleName)) { rootModulePath = Utility.getProjectHome() + appDirName; subModuleName = moduleName; } else { rootModulePath = Utility.getProjectHome() + appDirName; } ResponseInfo<String> responseData = new ResponseInfo<String>(); try { if (StringUtils.isNotEmpty(appDirName) && getTargetDir(configType, rootModulePath, subModuleName) != null) { StringBuilder sb = getTargetDir(configType, rootModulePath, subModuleName).append(File.separator) .append(fileName); FileUtil.delete(new File(sb.toString())); } else { if (StringUtils.isNotEmpty(appDirName)) { File pomFile = Utility.getPomFileLocation(rootModulePath, subModuleName); StringBuilder sb = new StringBuilder(pomFile.getParent()).append(File.separator) .append(DO_NOT_CHECKIN_DIR).append(File.separator).append(envName); File envNameDir = new File(sb.toString()); sb.append(File.separator).append(configName); File configNameDir = new File(sb.toString()); sb.append(File.separator).append(propName); File propNameDir = new File(sb.toString()); sb.append(File.separator).append(fileName); File file = new File(sb.toString()); FileUtil.delete(file); if (ArrayUtils.isEmpty(propNameDir.listFiles())) { FileUtil.delete(propNameDir); } if (ArrayUtils.isEmpty(configNameDir.listFiles())) { FileUtil.delete(configNameDir); } if (ArrayUtils.isEmpty(envNameDir.listFiles())) { FileUtil.delete(envNameDir); } } } ResponseInfo finalOuptut = responseDataEvaluation(responseData, null, false, RESPONSE_STATUS_SUCCESS, PHR600027); return Response.ok(finalOuptut).header("Access-Control-Allow-Origin", "*").build(); } catch (PhrescoException e) { ResponseInfo<String> finalOuptut = responseDataEvaluation(responseData, null, null, RESPONSE_STATUS_ERROR, PHR610041); return Response.status(Status.OK).entity(finalOuptut).header("Access-Control-Allow-Origin", "*") .build(); } }
From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java
/** * <p>Finds the index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex is treated as zero. A startIndex larger than the array * length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p> * //from w ww.ja v a2s .c o m * @param array the array to search through for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the index to start searching at * @return the index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int indexOf(float[] array, float valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { startIndex = 0; } for (int i = startIndex; i < array.length; i++) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java
/** * <p>Finds the last index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the * array length will search from the end of the array.</p> * /*from ww w. ja va 2s . c o m*/ * @param array the array to traverse for looking for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the start index to travers backwards from * @return the last index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(float[] array, float valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { return INDEX_NOT_FOUND; } else if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; i--) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
From source file:com.photon.phresco.framework.rest.api.util.FrameworkServiceUtil.java
public boolean loadTestResultAvail(ApplicationInfo appInfo) throws PhrescoException { boolean isResultFileAvailable = false; try {/*from w w w . j a v a2s . com*/ String baseDir = Utility.getProjectHome() + appInfo.getAppDirName(); FrameworkUtil frameworkUtil = FrameworkUtil.getInstance(); List<String> testResultsTypes = new ArrayList<String>(); testResultsTypes.add("server"); testResultsTypes.add("webservice"); for (String testResultsType : testResultsTypes) { StringBuilder sb = new StringBuilder(baseDir.toString()); String loadReportDir = frameworkUtil.getLoadTestReportDir(appInfo); if (StringUtils.isNotEmpty(loadReportDir) && StringUtils.isNotEmpty(testResultsType)) { Pattern p = Pattern.compile("dir_type"); Matcher matcher = p.matcher(loadReportDir); loadReportDir = matcher.replaceAll(testResultsType); sb.append(loadReportDir); } File file = new File(sb.toString()); File[] children = file.listFiles(new XmlNameFileFilter(FILE_EXTENSION_XML)); if (!ArrayUtils.isEmpty(children)) { isResultFileAvailable = true; break; } } } catch (Exception e) { throw new PhrescoException(e); } return isResultFileAvailable; }
From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java
/** * <p>Finds the index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex is treated as zero. A startIndex larger than the array * length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p> * //from w w w. ja v a 2s . c o m * @param array the array to search through for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the index to start searching at * @return the index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> * array input */ public static int indexOf(boolean[] array, boolean valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { startIndex = 0; } for (int i = startIndex; i < array.length; i++) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }
From source file:com.photon.phresco.framework.rest.api.util.FrameworkServiceUtil.java
public boolean performanceTestResultAvail(ApplicationInfo appInfo) throws PhrescoException { boolean isResultFileAvailable = false; try {/*from w w w .jav a 2 s. com*/ String baseDir = Utility.getProjectHome() + appInfo.getAppDirName(); FrameworkUtil frameworkUtil = FrameworkUtil.getInstance(); List<String> testResultsTypes = new ArrayList<String>(); testResultsTypes.add("server"); testResultsTypes.add("database"); testResultsTypes.add("webservice"); for (String testResultsType : testResultsTypes) { StringBuilder sb = new StringBuilder(baseDir.toString()); String performanceReportDir = frameworkUtil.getPerformanceTestReportDir(appInfo); if (StringUtils.isNotEmpty(performanceReportDir) && StringUtils.isNotEmpty(testResultsType)) { Pattern p = Pattern.compile("dir_type"); Matcher matcher = p.matcher(performanceReportDir); performanceReportDir = matcher.replaceAll(testResultsType); sb.append(performanceReportDir); } File file = new File(sb.toString()); String resultExtension = FrameworkServiceUtil .getPerformanceResultFileExtension(appInfo.getAppDirName(), ""); if (StringUtils.isNotEmpty(resultExtension)) { File[] children = file.listFiles(new XmlNameFileFilter(resultExtension)); if (!ArrayUtils.isEmpty(children)) { isResultFileAvailable = true; break; } } } } catch (Exception e) { throw new PhrescoException(e); } return isResultFileAvailable; }
From source file:com.yucheng.cmis.pub.util.NewArrayUtils.java
/** * <p>Finds the last index of the given value in the array starting at the given index.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than * the array length will search from the end of the array.</p> * // w w w. j a v a 2 s .c o m * @param array the array to traverse for looking for the object, may be <code>null</code> * @param valueToFind the value to find * @param startIndex the start index to travers backwards from * @return the last index of the value within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(boolean[] array, boolean valueToFind, int startIndex) { if (ArrayUtils.isEmpty(array)) { return INDEX_NOT_FOUND; } if (startIndex < 0) { return INDEX_NOT_FOUND; } else if (startIndex >= array.length) { startIndex = array.length - 1; } for (int i = startIndex; i >= 0; i--) { if (valueToFind == array[i]) { return i; } } return INDEX_NOT_FOUND; }