List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .
From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java
private List<Actor> createOrGetActorList(Document doc) { List<Actor> actorList = Lists.newArrayList(); Elements keyElements = doc.select(".fm-minfo dt"); Elements valueElements = doc.select(".fm-minfo dd"); if (CollectionUtils.isNotEmpty(keyElements) && CollectionUtils.isNotEmpty(valueElements)) { int keyI = 0; for (; keyI < keyElements.size(); keyI++) { Element keyElement = keyElements.get(keyI); Element valueElement = valueElements.get(keyI); if (null != keyElement && null != valueElement) { String key = StringUtils.trimToEmpty(keyElement.text().toString()); if (StringUtils.isNotBlank(key)) { String value = StringUtils.trimToEmpty(valueElement.text().toString()); if (StringUtils.equalsIgnoreCase(key, "")) { Elements actorNameElements = valueElement.select("a"); if (CollectionUtils.isNotEmpty(actorNameElements)) { actorNameElements.forEach(actorNameElement -> { String actorName = StringUtils.trimToEmpty(actorNameElement.text().toString()); if (StringUtils.isNotBlank(actorName)) { Actor actor = createOrQueryActor(actorName); if (null != actor) { actorList.add(actor); }//w w w. ja v a2 s . c o m } }); } break; } } } } } return actorList; }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the healthSummaryText */ public String getHealthSummaryText() { return StringUtils.trimToEmpty(healthSummaryText); }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the hispUnableToDetReasonCode */ public String getHispUnableToDetReasonCode() { return StringUtils.trimToEmpty(hispUnableToDetReasonCode); }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the hispanicOriginCode */ public String getHispanicOriginCode() { return StringUtils.trimToEmpty(hispanicOriginCode); }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the id */ public String getId() { return StringUtils.trimToEmpty(id); }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the incapacitatedParentCode */ public String getIncapacitatedParentCode() { return StringUtils.trimToEmpty(incapacitatedParentCode); }
From source file:com.mirth.connect.connectors.http.HttpListener.java
private String getBaseContextPath() { String contextPath = StringUtils.trimToEmpty(contextPathField.getText()); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; }/*from w ww . ja v a 2s . c om*/ while (contextPath.endsWith("/")) { contextPath = contextPath.substring(0, contextPath.length() - 1).trim(); } return contextPath; }
From source file:com.streamsets.pipeline.stage.origin.jdbc.cdc.oracle.OracleCDCSource.java
@Override public String produce(String lastSourceOffset, int maxBatchSize, final BatchMaker batchMaker) throws StageException { if (dummyRecord == null) { dummyRecord = getContext().createRecord("DUMMY"); }/*from w w w . j a v a 2s . c o m*/ final int batchSize = Math.min(configBean.baseConfigBean.maxBatchSize, maxBatchSize); int recordGenerationAttempts = 0; boolean recordsProduced = false; String nextOffset = StringUtils.trimToEmpty(lastSourceOffset); pollForStageExceptions(); while (!getContext().isStopped() && !recordsProduced && recordGenerationAttempts++ < MAX_RECORD_GENERATION_ATTEMPTS) { if (!sentInitialSchemaEvent) { for (SchemaAndTable schemaAndTable : tableSchemas.keySet()) { getContext() .toEvent(createEventRecord(DDL_EVENT.STARTUP, null, schemaAndTable, ZERO, true, null)); } sentInitialSchemaEvent = true; } try { if (!generationStarted) { startGeneratorThread(lastSourceOffset); } } catch (StageException ex) { LOG.error("Error while attempting to produce records", ex); throw ex; } catch (Exception ex) { // In preview, destroy gets called after timeout which can cause a SQLException if (getContext().isPreview() && ex instanceof SQLException) { LOG.warn("Exception while previewing", ex); return NULL; } LOG.error("Error while attempting to produce records", ex); errorRecordHandler.onError(JDBC_44, Throwables.getStackTraceAsString(ex)); } int batchCount = 0; while (batchCount < batchSize) { try { RecordOffset recordOffset = recordQueue.poll(1, TimeUnit.SECONDS); if (recordOffset != null) { if (recordOffset.record instanceof EventRecord) { getContext().toEvent((EventRecord) recordOffset.record); } else { // Make sure we move the offset forward even if no real data was produced, so that we don't end up // pointing to a start time which is very old. if (recordOffset.record != dummyRecord) { batchMaker.addRecord(recordOffset.record); recordsProduced = true; batchCount++; } } nextOffset = recordOffset.offset.toString(); } else { break; } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new StageException(JDBC_87, ex); } } } sendErrors(); pollForStageExceptions(); return nextOffset; }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the individualHealthCarePlanIndicator */ public String getIndividualHealthCarePlanIndicator() { return StringUtils.trimToEmpty(individualHealthCarePlanIndicator); }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the limitationOnScpHealthIndicator */ public String getLimitationOnScpHealthIndicator() { return StringUtils.trimToEmpty(limitationOnScpHealthIndicator); }