List of usage examples for org.apache.commons.lang3 StringUtils isNoneBlank
public static boolean isNoneBlank(final CharSequence... css)
Checks if none of the CharSequences are blank ("") or null and whitespace only..
StringUtils.isNoneBlank(null) = false StringUtils.isNoneBlank(null, "foo") = false StringUtils.isNoneBlank(null, null) = false StringUtils.isNoneBlank("", "bar") = false StringUtils.isNoneBlank("bob", "") = false StringUtils.isNoneBlank(" bob ", null) = false StringUtils.isNoneBlank(" ", "bar") = false StringUtils.isNoneBlank("foo", "bar") = true
From source file:cn.afterturn.easypoi.excel.imports.ExcelImportService.java
/** * ??// w w w .j a v a 2 s .com */ public boolean verifyingDataValidity(Object object, Row row, ImportParams params, boolean isMap, StringBuilder fieldErrorMsg) { boolean isAdd = true; Cell cell = null; if (params.isNeedVerify()) { String errorMsg = PoiValidationUtil.validation(object, params.getVerifyGroup()); if (StringUtils.isNotEmpty(errorMsg)) { cell = row.createCell(row.getLastCellNum()); cell.setCellValue(errorMsg); if (object instanceof IExcelModel) { IExcelModel model = (IExcelModel) object; model.setErrorMsg(errorMsg); } isAdd = false; verifyFail = true; } } if (params.getVerifyHandler() != null) { ExcelVerifyHandlerResult result = params.getVerifyHandler().verifyHandler(object); if (!result.isSuccess()) { if (cell == null) { cell = row.createCell(row.getLastCellNum()); } cell.setCellValue( (StringUtils.isNoneBlank(cell.getStringCellValue()) ? cell.getStringCellValue() + "," : "") + result.getMsg()); if (object instanceof IExcelModel) { IExcelModel model = (IExcelModel) object; model.setErrorMsg( (StringUtils.isNoneBlank(model.getErrorMsg()) ? model.getErrorMsg() + "," : "") + result.getMsg()); } isAdd = false; verifyFail = true; } } if ((params.isNeedVerify() || params.getVerifyHandler() != null) && fieldErrorMsg.length() > 0) { if (object instanceof IExcelModel) { IExcelModel model = (IExcelModel) object; model.setErrorMsg((StringUtils.isNoneBlank(model.getErrorMsg()) ? model.getErrorMsg() + "," : "") + fieldErrorMsg.toString()); } if (cell == null) { cell = row.createCell(row.getLastCellNum()); } cell.setCellValue( (StringUtils.isNoneBlank(cell.getStringCellValue()) ? cell.getStringCellValue() + "," : "") + fieldErrorMsg.toString()); isAdd = false; verifyFail = true; } if (cell != null) { cell.setCellStyle(errorCellStyle); failRow.add(row); if (isMap) { ((Map) object).put("excelErrorMsg", cell.getStringCellValue()); } } else { successRow.add(row); } return isAdd; }
From source file:com.pantuo.service.impl.AttachmentServiceImpl.java
public void updateAttachments(HttpServletRequest request, String user_id, int main_id, JpaAttachment.Type file_type, String description) throws BusinessException { try {/*from w w w. j av a2 s .c om*/ CustomMultipartResolver multipartResolver = new CustomMultipartResolver( request.getSession().getServletContext()); if (multipartResolver.isMultipart(request)) { String path = request.getSession().getServletContext() .getRealPath(com.pantuo.util.Constants.FILE_UPLOAD_DIR).replaceAll("WEB-INF", ""); MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request; Iterator<String> iter = multiRequest.getFileNames(); while (iter.hasNext()) { MultipartFile file = multiRequest.getFile(iter.next()); if (file != null && !file.isEmpty()) { String oriFileName = file.getOriginalFilename(); String fn = file.getName(); if (StringUtils.isNoneBlank(oriFileName)) { String storeName = GlobalMethods .md5Encrypted((System.currentTimeMillis() + oriFileName).getBytes()); Pair<String, String> p = FileHelper.getUploadFileName(path, storeName += FileHelper.getFileExtension(oriFileName, true)); File localFile = new File(p.getLeft()); file.transferTo(localFile); AttachmentExample example = new AttachmentExample(); AttachmentExample.Criteria criteria = example.createCriteria(); criteria.andMainIdEqualTo(main_id); criteria.andUserIdEqualTo(user_id); List<Attachment> attachments = attachmentMapper.selectByExample(example); for (Attachment t : attachments) { if (StringUtils.equals(fn, "licensefile") && t.getType() == JpaAttachment.Type.license.ordinal()) { t.setUpdated(new Date()); t.setName(oriFileName); t.setUrl(p.getRight()); attachmentMapper.updateByPrimaryKey(t); } if (StringUtils.equals(fn, "taxfile") && t.getType() == JpaAttachment.Type.tax.ordinal()) { t.setUpdated(new Date()); t.setName(oriFileName); t.setUrl(p.getRight()); attachmentMapper.updateByPrimaryKey(t); } if (StringUtils.equals(fn, "taxpayerfile") && t.getType() == JpaAttachment.Type.taxpayer.ordinal()) { t.setUpdated(new Date()); t.setName(oriFileName); t.setUrl(p.getRight()); attachmentMapper.updateByPrimaryKey(t); } if (StringUtils.equals(fn, "user_license") && t.getType() == JpaAttachment.Type.user_license.ordinal()) { t.setUpdated(new Date()); t.setName(oriFileName); t.setUrl(p.getRight()); attachmentMapper.updateByPrimaryKey(t); } if (StringUtils.equals(fn, "user_tax") && t.getType() == JpaAttachment.Type.user_tax.ordinal()) { t.setUpdated(new Date()); t.setName(oriFileName); t.setUrl(p.getRight()); attachmentMapper.updateByPrimaryKey(t); } if (StringUtils.equals(fn, "user_code") && t.getType() == JpaAttachment.Type.user_code.ordinal()) { t.setUpdated(new Date()); t.setName(oriFileName); t.setUrl(p.getRight()); attachmentMapper.updateByPrimaryKey(t); } } } } } } } catch (Exception e) { log.error("saveAttachment", e); throw new BusinessException("saveAttachment-error", e); } }
From source file:gob.dp.simco.registro.controller.CasoController.java
public void cargarNiveles() { if (StringUtils.isNoneBlank(caso.getSubTipo())) { cargarPrimerNivel(); cargarSegundoNivel(); cargarTercerNivel(); } }
From source file:com.taobao.android.builder.dependency.parser.ResolvedDependencyInfo.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(group).append(":").append(name); if (StringUtils.isNoneBlank(classifier)) { sb.append(":").append(classifier); }//w ww . j a va 2 s. com sb.append(":").append(version); sb.append("@").append(type); return sb.toString(); }
From source file:com.pantuo.service.impl.AttachmentServiceImpl.java
public Pair<Boolean, String> removeAttachment(HttpServletRequest request, String user_id, int att_id) { Attachment t = attachmentMapper.selectByPrimaryKey(att_id); if (t != null && StringUtils.equals(user_id, t.getUserId())) { if (StringUtils.isNoneBlank(t.getUrl())) { String path = request.getSession().getServletContext() .getRealPath(com.pantuo.util.Constants.FILE_UPLOAD_DIR); File f = new File(path + "/" + t.getUrl()); f.delete();/*w w w . ja v a2 s . c o m*/ } attachmentMapper.deleteByPrimaryKey(att_id); return new Pair<Boolean, String>(true, "???"); } else { return new Pair<Boolean, String>(false, "??????!"); } }
From source file:gob.dp.simco.registro.controller.ActaAcuerdoController.java
private String uploadArchive(Part fil) { String nameArchive = getFilename(fil); String extencion = getFileExtension(getFilename(fil)); if (StringUtils.isNoneBlank(nameArchive)) { String formato = RandomStringUtils.random(32, 0, 20, true, true, "qw32rfHIJk9iQ8Ud7h0X".toCharArray()); String ruta = formato + extencion; File file = new File(ConstantesUtil.FILE_SYSTEM + ruta); try (InputStream input = fil.getInputStream()) { Files.copy(input, file.toPath()); } catch (IOException ex) { log.error(ex);/*from w w w.jav a 2 s.co m*/ } return ruta; } return null; }
From source file:cn.afterturn.easypoi.excel.imports.ExcelImportService.java
private void getSingleCellValueForRow(ExcelImportResult result, Row row, ImportParams params) { for (int j = row.getFirstCellNum(), le = row.getLastCellNum(); j < le; j++) { String text = PoiCellUtil.getCellValue(row.getCell(j)); if (StringUtils.isNoneBlank(text) && text.endsWith(params.getKeyMark())) { if (result.getMap().containsKey(text)) { if (result.getMap().get(text) instanceof String) { List<String> list = new ArrayList<String>(); list.add((String) result.getMap().get(text)); result.getMap().put(text, list); }/* w w w .j a va 2s . c o m*/ ((List) result.getMap().get(text)).add(PoiCellUtil.getCellValue(row.getCell(++j))); } else { result.getMap().put(text, PoiCellUtil.getCellValue(row.getCell(++j))); } } } }
From source file:com.taobao.android.utils.SmaliCodeUtils.java
/** * ?smali?//from w w w.ja va 2 s.c om * * @param dexBackedMethodImplementation * @param withLineNo ??? * @return */ public static String methodImplementionToCode(DexBackedMethodImplementation dexBackedMethodImplementation, boolean withLineNo) { if (null == dexBackedMethodImplementation) { return null; } StringWriter stringWriter = new StringWriter(); IndentingWriter writer = new IndentingWriter(stringWriter); MethodDefinition methodDefinition = new MethodDefinition(toClassDefinition(dexBackedMethodImplementation), dexBackedMethodImplementation.method, dexBackedMethodImplementation); try { methodDefinition.writeTo(writer); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } if (withLineNo) { return stringWriter.toString(); } else { List<String> codes = Lists.newArrayList(); String[] lines = StringUtils.split(stringWriter.toString(), "\n"); for (String line : lines) { if (StringUtils.isNoneBlank(line) && !line.matches("\\s+\\.line\\s+[0-9]+$")) { codes.add(line); } } return StringUtils.join(codes, "\n"); } }
From source file:gob.dp.simco.registro.controller.RegistroController.java
public String registrarActividad() { String ruta = uploadArchiveImage(); if (StringUtils.isNoneBlank(ruta)) { actividad.setRuta(ruta);//from www . j a v a 2s . c o m } try { String accionHistorial; if (actividad.getId() != null) { actividad.setFechaModificacion(new Date()); actividad.setUsuarioModificacion(usuarioSession.getCodigo()); actividadService.actividadModificar(actividad); if (caso.getId() != null) { insertaUpdateActividadCaso(setearActividadCaso(actividad, caso)); } accionHistorial = HistorialType.HISTORIAL_ACTUALIZACION.getKey(); } else { actividad.setFechaRegistro(new Date()); actividad.setUsuarioRegistro(usuarioSession.getCodigo()); actividad.setCodigoActividad(generarCodigoAD()); actividadService.actividadNuevo(actividad); accionHistorial = HistorialType.HISTORIAL_CREACION.getKey(); if (caso != null) { if (caso.getId() != null) { insertaUpdateActividadCaso(setearActividadCaso(actividad, caso)); } } verDetalleRegistro = true; } historialActividad(accionHistorial, actividad.getId()); msg.messageInfo("Se guardaron los cambios", null); setearEsUsuarioRegistro(); if (caso.getId() != null) { return "registroEdit"; } else { return "registroNuevo"; } } catch (Exception e) { log.error("ERROR - registrarActividad()" + e); } return null; }
From source file:gob.dp.simco.registro.controller.RegistroController.java
private String uploadArchiveImage() { String nameArchive = getFilename(file1); String extencion = ""; if (StringUtils.isNoneBlank(nameArchive)) { switch (file1.getContentType()) { case "image/png": extencion = ".png"; break; case "image/jpeg": extencion = ".jpg"; break; case "image/gif": extencion = ".gif"; break; }/*from ww w . j a v a 2 s . com*/ DateFormat fechaHora = new SimpleDateFormat("yyyyMMddHHmmss"); String formato = fechaHora.format(new Date()); String ruta = formato + extencion; File file = new File(ConstantesUtil.FILE_SYSTEM + ruta); try (InputStream input = file1.getInputStream()) { Files.copy(input, file.toPath()); } catch (IOException ex) { log.error("ERROR - uploadArchiveImage()" + ex); } return ruta; } return null; }