Java Code Examples for org.apache.commons.lang.StringUtils.EMPTY

The following are Jave code examples for showing how to use EMPTY of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: otter-G   File: LogInterceptor.java   View Source Code Vote up 7 votes
/**
 * 取得结果字符串
 * 
 * @param result
 * @return
 */
protected String getResultString(Object result) {
    if (result == null) {
        return StringUtils.EMPTY;
    }

    if (result instanceof Map) { // 处理map
        return getMapResultString((Map) result);
    } else if (result instanceof List) {// 处理list
        return getListResultString((List) result);
    } else if (result.getClass().isArray()) {// 处理array
        return getArrayResultString((Object[]) result);
    } else {
        // 直接处理string
        return ObjectUtils.toString(result, StringUtils.EMPTY).toString();
        // return ToStringBuilder.reflectionToString(result, ToStringStyle.SIMPLE_STYLE);
    }
}
 
Example 2
Project: SugarOnRest   File: SugarRestClient.java   View Source Code Vote up 7 votes
/**
 * Sets response if an error occurs.
 *
 * @param request The request object.
 * @param response The response object.
 */
private void setErrorResponse(SugarRestRequest request, SugarRestResponse response) {
    ObjectMapper mapper = JsonObjectMapper.getMapper();
    String jsonRequest = StringUtils.EMPTY;
    String jsonResponse = StringUtils.EMPTY;

    try {
        jsonRequest = mapper.writeValueAsString(request);
        jsonResponse = mapper.writeValueAsString(response);
    } catch (JsonProcessingException exception) {
        ErrorResponse errorResponse = ErrorResponse.format(exception, exception.getMessage());
        errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        response.setError(errorResponse);
    }

    response.setData(null);
    response.setJData(StringUtils.EMPTY);
    response.setJsonRawRequest(jsonRequest);
    response.setJsonRawResponse(jsonResponse);
}
 
Example 3
Project: DBus   File: GlobalControlKafkaConsumerEvent.java   View Source Code Vote up 7 votes
public String getEmail(String dsSchemaName) {
    String email = StringUtils.EMPTY;

    HeartBeatVo hbConf = HeartBeatConfigContainer.getInstance().getHbConf();
    String adminUseEmail = hbConf.getAdminUseEmail();
    if (StringUtils.equals(adminUseEmail.toUpperCase(), "Y")) {
        email = hbConf.getAdminEmail();
    }

    if (StringUtils.isNotBlank(dsSchemaName)) {
        Map<String, Map<String, String>> additionalNotify = hbConf.getAdditionalNotify();
        Map<String, String> map = additionalNotify.get(dsSchemaName);
        if (map != null && StringUtils.equals(map.get("UseEmail").toUpperCase(), "Y")) {
            if (StringUtils.isNotBlank(email)) {
                email = StringUtils.join(new String[]{email, map.get("Email")}, ",");
            } else {
                email = map.get("Email");
            }
        }
    }

    return email;
}
 
Example 4
Project: formatter   File: FormatUtil.java   View Source Code Vote up 7 votes
/**
* 
* @Title: contents 
* @Description: get file contents
* @param @return
* @return String 
* @throws
 */
public static String contents(String filename)
{
    String content = StringUtils.EMPTY;
    try
    {
        InputStream is = FormatUtil.getInputStream(filename);
        content = IOUtils.toString(is, Charsets.UTF_8.getCname());
        FormatUtil.close(is);
    }
    catch(IOException e)
    {
        FormatView.getView().getStat().setText("Failed to read file: " + e.getMessage());
    }
    return content;
}
 
Example 5
Project: jspare-vertx-ms-blueprint   File: GatewayDatabaseOptions.java   View Source Code Vote up 7 votes
private void init() {

		databaseClass = DEFAULT_DATABASE_CLASS;
		url = DETAULT_URL;
		driverClass = DEFAULT_H2_DRIVER;
		username = StringUtils.EMPTY;
		password = StringUtils.EMPTY;
		embeddedPort = DEFAULT_EMBEDDED_PORT;
		maxPool = DEFAULT_MAX_POOL;
		minPool = DEFAULT_MIN_POOL;
		initialPool = DEFAULT_INITIAL_POOL;
		maxIdleTime = DEFAULT_MAX_IDLE_TIME;
		maxStatementsPerConnection = DEFAULT_MAX_STATEMENTS_PER_CONNECTION;
		showCommands = false;
		testConnection = true;
	}
 
Example 6
Project: otter-G   File: ProcessTimeoutRuleMonitor.java   View Source Code Vote up 6 votes
@Override
public void explore(List<AlarmRule> rules) {
    if (CollectionUtils.isEmpty(rules)) {
        return;
    }
    Long pipelineId = rules.get(0).getPipelineId();

    List<ProcessStat> processStats = processStatService.listRealtimeProcessStat(pipelineId);
    if (CollectionUtils.isEmpty(processStats)) {
        return;
    }

    long now = System.currentTimeMillis();
    Map<Long, Long> processTime = new HashMap<Long, Long>();
    for (ProcessStat processStat : processStats) {
        Long timeout = 0L;
        if (!CollectionUtils.isEmpty(processStat.getStageStats())) {
            timeout = now - processStat.getStageStats().get(0).getStartTime();
        }
        processTime.put(processStat.getProcessId(), timeout);
    }

    String message = StringUtils.EMPTY;
    for (AlarmRule rule : rules) {
        if (message.isEmpty()) {
            message = checkTimeout(rule, processTime);
        } else {
            checkTimeout(rule, processTime);
        }
    }

    if (!message.isEmpty()) {
        logRecordAlarm(pipelineId, MonitorName.PROCESSTIMEOUT, message);
    }

}
 
Example 7
Project: oneops   File: AbstractOrderExecutor.java   View Source Code Vote up 6 votes
protected String getDebugFlag(CmsWorkOrderSimpleBase ao) {
  String debugFlag = StringUtils.EMPTY;
  if (isDebugEnabled(ao)) {
    debugFlag = "-d";
  }
  return debugFlag;
}
 
Example 8
Project: otter-G   File: RegexUtils.java   View Source Code Vote up 6 votes
public static String findFirst(String originalStr, String regex) {
    if (StringUtils.isBlank(originalStr) || StringUtils.isBlank(regex)) {
        return StringUtils.EMPTY;
    }

    PatternMatcher matcher = new Perl5Matcher();
    if (matcher.contains(originalStr, patterns.get(regex))) {
        return StringUtils.trimToEmpty(matcher.getMatch().group(0));
    }
    return StringUtils.EMPTY;
}
 
Example 9
Project: formatter   File: FormatUtil.java   View Source Code Vote up 6 votes
/**
* 
* @Title: format 
* @Description: Format text 
* @param @param txt
* @param @return 
* @return String
* @throws
 */
public static String format(String txt)
{
    if (StringUtils.isBlank(txt))
    {
        return StringUtils.EMPTY;
    }

    try
    {
        if (isJson(txt))
        {
            return prettyJson(txt);
        }

        if (isHtml(txt))
        {
            return prettyHtml(txt);
        }

        if (isXml(txt))
        {
            return prettyXml(txt);
        }
    }
    catch(Throwable e)
    {
        FormatView.getView().getStat().setText("Failed to format text: " + e.getMessage());
    }

    return txt;
}
 
Example 10
Project: SugarOnRest   File: AccountsModuleTests.java   View Source Code Vote up 6 votes
@Test
public void deleteGroupAccountTest() {

    SugarRestRequest request = new SugarRestRequest("Accounts", RequestType.BulkRead);
    request.setUrl(TestAccount.Url);
    request.setUsername(TestAccount.Username);
    request.setPassword(TestAccount.Password);

    List<QueryPredicate> queryPredicates = new ArrayList<QueryPredicate>();

    // Since query is set, the query predicates will be ignored.
    queryPredicates.add(new QueryPredicate("name", Contains, "SugarOnRest"));
    request.getOptions().setQueryPredicates(queryPredicates);

    SugarRestClient client = new SugarRestClient();
    SugarRestResponse response = client.execute(request);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    List<Accounts> accounts = (List<Accounts>)response.getData();
    if (accounts != null){
        for (Accounts account : accounts) {

            // -------------------Delete Account-------------------
            response = AccountsModule.deleteAccount(client, account.getId());

            assertNotNull(response);
            assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

            String deleteId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

            assertNotNull(deleteId);
            assertNotSame(deleteId, StringUtils.EMPTY );
            assertEquals(account.getId(), deleteId);

            // -------------------End Delete Account-------------------
        }
    }
}
 
Example 11
Project: SugarOnRest   File: SugarRestRequest.java   View Source Code Vote up 6 votes
/**
 * Initializes a new instance of the SugarRestRequest class.
 *
 *  @param moduleType The SugarCRM module name.
 *  @param requestType The request type.
 */
public SugarRestRequest(Type moduleType, RequestType requestType) {
    this.setModuleType(moduleType);
    this.setRequestType(requestType);
    this.setOptions(new Options());
    this.validationMessage = StringUtils.EMPTY;
}
 
Example 12
Project: SugarOnRest   File: AccountsModule.java   View Source Code Vote up 6 votes
public static List<String> bulkDeleteAccount(SugarRestClient client, List<String> accountIds) {
    SugarRestRequest request = new SugarRestRequest("Accounts", RequestType.Delete);

    List<String> listId = new ArrayList<String>();
    for (String id : accountIds)
    {
        request.setParameter(id);
        SugarRestResponse response = client.execute(request);
        String identifier = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();
        listId.add(identifier);
    }

    return listId;
}
 
Example 13
Project: tcp-gateway   File: NetUtils.java   View Source Code Vote up 6 votes
/**
 * InetSocketAddress转 host:port 字符串
 *
 * @param address InetSocketAddress转
 * @return host:port 字符串
 */
public static String toAddressString(InetSocketAddress address) {
    if (address == null) {
        return StringUtils.EMPTY;
    } else {
        return toIpString(address) + ":" + address.getPort();
    }
}
 
Example 14
Project: logistimo-web-service   File: OrderUtils.java   View Source Code Vote up 6 votes
/**
 * Returns the string constants for the order types
 *
 * @param type 0-TRANSFER, 1- PURCHASE, 2-SALES
 * @return try-TRANSFER, prc- PURCHASE,sle- SALES
 */
public static String getOrderType(Integer type) {
  if (type == 0) {
    return IOrder.TYPE_TRANSFER;
  } else if (type == 1) {
    return IOrder.TYPE_PURCHASE;
  } else if (type == 2) {
    return IOrder.TYPE_SALE;
  }
  return StringUtils.EMPTY;
}
 
Example 15
Project: SugarOnRest   File: SugarRestRequest.java   View Source Code Vote up 5 votes
/**
 * Initializes a new instance of the SugarRestRequest class.
 *
 *  @param moduleType The SugarCRM module Java type.
 */
public SugarRestRequest(Type moduleType) {
    this.setModuleType(moduleType);
    this.setOptions(new Options());
    this.validationMessage = StringUtils.EMPTY;
}
 
Example 16
Project: morf   File: DefaultAdditionalSchemaDataImpl.java   View Source Code Vote up 5 votes
/**
 * @see org.alfasoftware.morf.excel.AdditionalSchemaData#columnDocumentation(Table, java.lang.String)
 */
@Override
public String columnDocumentation(Table table, String columnName) {
  return StringUtils.EMPTY;
}
 
Example 17
Project: SugarOnRest   File: ContactsModuleTests.java   View Source Code Vote up 3 votes
@Test
public void crudByTypeTest() {
    SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password);

    Contacts insertContact = ContactsModule.getTestContact();

    // -------------------Create Contact-------------------
    SugarRestResponse response = ContactsModule.createContactByType(client, insertContact);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String insertId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(insertId);
    assertNotSame(insertId, StringUtils.EMPTY );
    // -------------------End Create Contact-------------------


    // -------------------Read Contact-------------------
    response = ContactsModule.readContactByType(client, insertId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Contacts readOnCreateContact = (Contacts) response.getData();

    assertNotNull(readOnCreateContact);
    assertEquals(insertContact.getFirstName(), readOnCreateContact.getFirstName());
    assertEquals(insertContact.getLastName(), readOnCreateContact.getLastName());
    assertEquals(insertContact.getTitle(), readOnCreateContact.getTitle());
    assertEquals(insertContact.getPrimaryAddressPostalcode(), readOnCreateContact.getPrimaryAddressPostalcode());
    // -------------------End Read Contact-------------------


    // -------------------Update Contact-------------------
    response = ContactsModule.updateContact(client, readOnCreateContact.getId());

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String updateId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(updateId);
    assertNotSame(updateId, StringUtils.EMPTY );
    // -------------------End Update Contact-------------------


    // -------------------Read Contact-------------------
    response = ContactsModule.readContact(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Contacts readOnUpdateContact = (Contacts) response.getData();

    assertNotNull(readOnUpdateContact.getTitle());
    assertNotSame(readOnUpdateContact.getTitle(), StringUtils.EMPTY );
    assertEquals(updateId, updateId);
    assertNotSame(readOnCreateContact.getTitle(), readOnUpdateContact.getTitle());
    // -------------------End Read Contact-------------------


    // -------------------Delete Contact-------------------
    response = ContactsModule.deleteContactByType(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);;

    String deleteId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(deleteId);
    assertNotSame(deleteId, StringUtils.EMPTY );
    assertEquals(insertId, deleteId);
    // -------------------End Delete Contact-------------------
}
 
Example 18
Project: morf   File: SqlServerDialect.java   View Source Code Vote up 3 votes
/**
 * SQL server places a shared lock on a record when it is selected without doing anything else (no MVCC)
 * so no need to specify a lock mode.
 *
 * @see org.alfasoftware.morf.jdbc.SqlDialect#getForUpdateSql()
 * @see http://stackoverflow.com/questions/10935850/when-to-use-select-for-update
 */
@Override
protected String getForUpdateSql() {
  return StringUtils.EMPTY;
}
 
Example 19
Project: SugarOnRest   File: ContactsModuleTests.java   View Source Code Vote up 3 votes
public static void crudTest() {
    SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password);

    Contacts insertContact = ContactsModule.getTestContact();

    // -------------------Create Contact-------------------
    SugarRestResponse response = ContactsModule.createContact(client, insertContact);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String insertId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(insertId);
    assertNotSame(insertId, StringUtils.EMPTY );
    // -------------------End Create Contact-------------------


    // -------------------Read Contact-------------------
    response = ContactsModule.readContact(client, insertId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Contacts readOnCreateContact = (Contacts) response.getData();

    assertNotNull(readOnCreateContact);
    assertEquals(insertContact.getFirstName(), readOnCreateContact.getFirstName());
    assertEquals(insertContact.getLastName(), readOnCreateContact.getLastName());
    assertEquals(insertContact.getTitle(), readOnCreateContact.getTitle());
    assertEquals(insertContact.getPrimaryAddressPostalcode(), readOnCreateContact.getPrimaryAddressPostalcode());
    // -------------------End Read Contact-------------------


    // -------------------Update Contact-------------------
    response = ContactsModule.updateContact(client, readOnCreateContact.getId());

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    String updateId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(updateId);
    assertNotSame(updateId, StringUtils.EMPTY );
    // -------------------End Update Contact-------------------


    // -------------------Read Contact-------------------
    response = ContactsModule.readContact(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

    Contacts readOnUpdateContact = (Contacts) response.getData();

    assertNotNull(readOnUpdateContact.getTitle());
    assertNotSame(readOnUpdateContact.getTitle(), StringUtils.EMPTY );
    assertEquals(updateId, updateId);
    assertNotSame(readOnCreateContact.getTitle(), readOnUpdateContact.getTitle());
    // -------------------End Read Contact-------------------


    // -------------------Delete Contact-------------------
    response = ContactsModule.deleteContact(client, updateId);

    assertNotNull(response);
    assertEquals(response.getStatusCode(), HttpStatus.SC_OK);;

    String deleteId = (response.getData() == null) ? StringUtils.EMPTY : response.getData().toString();

    assertNotNull(deleteId);
    assertNotSame(deleteId, StringUtils.EMPTY );
    assertEquals(insertId, deleteId);
    // -------------------End Delete Contact-------------------
}
 
Example 20
Project: morf   File: SqlDialect.java   View Source Code Vote up 3 votes
/**
 * Returns any SQL code which should be added at the end of a statement for dialect-specific reasons.
 *
 * @param selectStatement The select statement
 * @return Any hint code required.
 */
protected String selectStatementPostStatementDirectives(@SuppressWarnings("unused") SelectStatement selectStatement) {
  return StringUtils.EMPTY;
}