Example usage for org.apache.commons.lang StringUtils trimToEmpty

List of usage examples for org.apache.commons.lang StringUtils trimToEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils trimToEmpty.

Prototype

public static String trimToEmpty(String str) 

Source Link

Document

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.

Usage

From source file:nc.noumea.mairie.appock.core.utility.AppockUtil.java

public static String creerReprLigne(String... listeElement) {
    List<String> listeElementRetenu = new ArrayList<>();
    for (String element : listeElement) {
        if (!StringUtils.isBlank(element)) {
            listeElementRetenu.add(StringUtils.trimToEmpty(element));
        }/*from   w w w.j  a  va  2  s .  c  om*/
    }
    return StringUtils.join(listeElementRetenu, " ");
}

From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MongoDBLoginComposite.java

@Override
public void crateComposite() {
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 3;/*from  www. j  a va  2 s .  co m*/
    gridLayout.horizontalSpacing = 3;
    gridLayout.marginHeight = 3;
    gridLayout.marginWidth = 3;
    setLayout(gridLayout);
    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Composite compositeBody = new Composite(this, SWT.NONE);
    compositeBody.setLayout(new GridLayout(2, false));
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    Label lblOperationType = new Label(compositeBody, SWT.NONE);
    lblOperationType.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    lblOperationType.setText(Messages.MySQLLoginComposite_lblOperationType_text);

    comboOperationType = new Combo(compositeBody, SWT.READ_ONLY);
    comboOperationType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    for (DBOperationType opType : DBOperationType.values()) {
        comboOperationType.add(opType.getTypeName());
    }
    comboOperationType.select(1);

    Label lblGroupName = new Label(compositeBody, SWT.NONE);
    lblGroupName.setText(Messages.MySQLLoginComposite_lblGroupName_text);
    comboGroup = new Combo(compositeBody, SWT.NONE);
    comboGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    for (String strGroup : listGroupName)
        comboGroup.add(strGroup);

    Label lblNewLabel_1 = new Label(compositeBody, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel_1.setText(Messages.DBLoginDialog_lblNewLabel_1_text);

    textDisplayName = new Text(compositeBody, SWT.BORDER);
    textDisplayName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    new Label(compositeBody, SWT.NONE);
    new Label(compositeBody, SWT.NONE);

    Label lblHost = new Label(compositeBody, SWT.NONE);
    lblHost.setText(Messages.DBLoginDialog_1);

    textHost = new Text(compositeBody, SWT.BORDER);
    textHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblNewLabelPort = new Label(compositeBody, SWT.NONE);
    lblNewLabelPort.setText(Messages.DBLoginDialog_5);

    textPort = new Text(compositeBody, SWT.BORDER);
    textPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblReplicaSet = new Label(compositeBody, SWT.NONE);
    lblReplicaSet.setText(Messages.MongoDBLoginComposite_lblReplicaSet_text);

    textReplicaSet = new Text(compositeBody, SWT.BORDER);
    textReplicaSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(compositeBody, SWT.NONE);

    Label lblExLocalhostlocalhost = new Label(compositeBody, SWT.NONE);
    lblExLocalhostlocalhost.setText(Messages.MongoDBLoginComposite_lblExLocalhostlocalhost_text);

    Label lblNewLabelDatabase = new Label(compositeBody, SWT.NONE);
    lblNewLabelDatabase.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false, 1, 1));
    lblNewLabelDatabase.setText(Messages.DBLoginDialog_4);

    textDatabase = new Text(compositeBody, SWT.BORDER);
    textDatabase.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblUser = new Label(compositeBody, SWT.NONE);
    lblUser.setText(Messages.DBLoginDialog_2);

    textUser = new Text(compositeBody, SWT.BORDER);
    textUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblPassword = new Label(compositeBody, SWT.NONE);
    lblPassword.setText(Messages.DBLoginDialog_3);

    textPassword = new Text(compositeBody, SWT.BORDER | SWT.PASSWORD);
    textPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblLocale = new Label(compositeBody, SWT.NONE);
    lblLocale.setText(Messages.MySQLLoginComposite_lblLocale_text);

    comboLocale = new Combo(compositeBody, SWT.READ_ONLY);
    comboLocale.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    for (String val : DBLocaleUtils.getMySQLList())
        comboLocale.add(val);
    comboLocale.setVisibleItemCount(12);
    comboLocale.select(0);

    Button btnPing = new Button(compositeBody, SWT.NONE);
    btnPing.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String host = StringUtils.trimToEmpty(textHost.getText());
            String port = StringUtils.trimToEmpty(textPort.getText());

            if ("".equals(host) || "".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openError(null, Messages.DBLoginDialog_10, Messages.DBLoginDialog_11);
                return;
            }

            try {
                if (isPing(host, port)) {
                    MessageDialog.openInformation(null, Messages.DBLoginDialog_12, Messages.DBLoginDialog_13);
                } else {
                    MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.DBLoginDialog_15);
                }
            } catch (NumberFormatException nfe) {
                MessageDialog.openError(null, Messages.MySQLLoginComposite_3, Messages.MySQLLoginComposite_4);
            }
        }
    });
    btnPing.setText(Messages.DBLoginDialog_btnPing_text);

    init();
}

From source file:com.prowidesoftware.swift.model.field.Field35F.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//* w ww  .  jav  a  2  s.  com*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    appendInLines(result, 2, 36);
    return result.toString();
}

From source file:com.vangent.hieos.services.xds.bridge.mapper.CDAToXDSMapper.java

/**
 * Method description//from   w ww .j  a v  a 2  s. c o  m
 *
 *
 *
 * @param document
 *
 * @return
 *
 *
 * @throws XMLParserException
 * @throws XPathHelperException
 */
protected Map<String, String> createReplaceVariables(Document document)
        throws XMLParserException, XPathHelperException {

    ContentParser parser = getContentParser();
    ContentParserConfig cfg = getContentParserConfig();

    Map<String, String> result = parser.parse(cfg, document.getContent());

    // ////
    // apply business rules

    CodedValue documentType = document.getType();

    // ///
    // ExtrinsicObject

    // authorInstitution
    remapForXON(result, ContentVariableName.AuthorInstitutionRoot,
            ContentVariableName.AuthorInstitutionExtension);

    // authorPerson
    remapForXON(result, ContentVariableName.AuthorPersonRoot, ContentVariableName.AuthorPersonExtension);

    // symbolic Document01
    String symbolicId = createExtrinsicObjectId(1);

    result.put(ContentVariableName.DocumentSymbolicId.toString(), symbolicId);
    document.setSymbolicId(symbolicId);

    // document type, pull from SDR
    result.put(ContentVariableName.DocumentTypeCode.toString(), documentType.getCode());
    result.put(ContentVariableName.DocumentTypeCodeSystem.toString(), documentType.getCodeSystem());
    result.put(ContentVariableName.DocumentTypeDisplayName.toString(), documentType.getDisplayName());

    // formatCode
    CodedValue format = document.getFormat();

    result.put(ContentVariableName.DocumentFormatCode.toString(), format.getCode());
    result.put(ContentVariableName.DocumentFormatCodeSystem.toString(), format.getCodeSystem());
    result.put(ContentVariableName.DocumentFormatDisplayName.toString(), format.getDisplayName());

    // mime type
    result.put(ContentVariableName.DocumentMimeType.toString(), document.getMimeType());

    // legal Authenticator
    remapForXON(result, ContentVariableName.LegalAuthenticatorRoot,
            ContentVariableName.LegalAuthenticatorExtension);

    // patientId, create an identifier and store in document
    String patIdExt = result.get(ContentVariableName.PatientIdExtension.toString());

    String patIdRoot = result.get(ContentVariableName.PatientIdRoot.toString());

    SubjectIdentifier patId = SubjectIdentifierUtils.createSubjectIdentifier(patIdRoot, patIdExt);

    document.setPatientId(patId);

    // patientId
    remapForCX(result, ContentVariableName.PatientIdRoot, ContentVariableName.PatientIdExtension,
            ContentVariableName.PatientIdCX);

    // sourcePatientId
    remapForCX(result, ContentVariableName.SourcePatientIdRoot, ContentVariableName.SourcePatientIdExtension,
            ContentVariableName.SourcePatientIdCX);

    // title
    String title = result.get(ContentVariableName.DocumentTitle.toString());

    if (StringUtils.isBlank(title)) {

        // default to displayName
        result.put(ContentVariableName.DocumentTitle.toString(),
                result.get(ContentVariableName.DocumentDisplayName.toString()));
    }

    // confidentialityCode, rules:
    // use SDR
    // if null, use CDA (do nothing, already pulled/parsed using expressions)
    // if null, let static content handle it (below)
    CodedValue confidentialityCode = document.getConfidentialityCode();

    if (confidentialityCode != null) {

        // the SDR trumps all other values, use it
        result.put(ContentVariableName.DocumentConfidentialityCode.toString(), confidentialityCode.getCode());
        result.put(ContentVariableName.DocumentConfidentialityCodeSystem.toString(),
                confidentialityCode.getCodeSystem());

        String displayName = StringUtils.trimToEmpty(confidentialityCode.getDisplayName());

        result.put(ContentVariableName.DocumentConfidentialityDisplayName.toString(), displayName);
    }

    // uniqueId, rules:
    // use SDR id
    // if null, use CDA id
    // if null, generate one
    String uuidField = ContentVariableName.DocumentUniqueId.toString();

    if (StringUtils.isNotBlank(document.getId())) {

        // document id from SDR is preferred
        String docIdAsOID = document.getId();

        if (UUIDUtils.isUUID(docIdAsOID)) {

            // if UUID then we need to convert to OID
            docIdAsOID = convertUUIDToOID(docIdAsOID);
        }

        result.put(uuidField, docIdAsOID);
        document.setDocumentIdAsOID(docIdAsOID);

    } else {

        // if document content had internal id use that
        // else generate one

        String docId = result.get(uuidField);

        if (StringUtils.isBlank(docId)) {

            // uses 2.25 prefix
            docId = UUIDUtils.toOID(UUID.randomUUID());

            result.put(uuidField, docId);

            // sync up with the document object
            document.setId(docId);
            document.setDocumentIdAsOID(docId);
            document.setGeneratedDocumentId(true);

        } else {

            String docIdAsOID = docId;

            // if inner document id is a UUID then we need to convert
            if (UUIDUtils.isUUID(docId)) {

                // uses 2.25 prefix
                docIdAsOID = convertUUIDToOID(docIdAsOID);
                result.put(uuidField, docIdAsOID);
            }

            // sync up with the document object
            document.setDocumentIdAsOID(docIdAsOID);
        }
    }

    // convert the replace id to an OID from UUID (as necessary)
    String replIdAsOID = document.getReplaceId();

    if (StringUtils.isNotBlank(replIdAsOID) && UUIDUtils.isUUID(replIdAsOID)) {

        replIdAsOID = convertUUIDToOID(replIdAsOID);
    }

    logger.debug(String.format("Setting replaceIdAsOID: [%s].", replIdAsOID));
    document.setReplaceIdAsOID(replIdAsOID);

    // ///
    // Submission Set

    // content type, pull from SDR
    result.put(ContentVariableName.ContentTypeCode.toString(), documentType.getCode());
    result.put(ContentVariableName.ContentTypeCodeSystem.toString(), documentType.getCodeSystem());
    result.put(ContentVariableName.ContentTypeDisplayName.toString(), documentType.getDisplayName());

    String sourceIdRoot = result.get(ContentVariableName.SourceIdRoot.toString());
    String sourceIdExt = result.get(ContentVariableName.SourceIdExtension.toString());

    if (StringUtils.isBlank(sourceIdExt)) {

        result.put(ContentVariableName.SourceId.toString(), sourceIdRoot);

    } else {

        result.put(ContentVariableName.SourceId.toString(), String.format("%s^%s", sourceIdRoot, sourceIdExt));
    }

    // Convert Submission Time to DTM_UTC format (if required).
    //String submissionTime;
    //Map<String, String> contentConversions = cfg.getContentConversions();
    //if (contentConversions != null) {
    // See if a converter exists for the submission time.
    //    String contentConversion = contentConversions.get(ContentVariableName.SubmissionTime.toString());
    //    if (contentConversion != null)
    //    {
    //        System.out.println("SubmissionTime CONVERSION would go here!!!");
    //    }
    //}
    result.put(ContentVariableName.SubmissionTime.toString(), Hl7Date.nowUTC());

    // uses 2.25 prefix
    result.put(ContentVariableName.SubmissionSetUniqueId.toString(), UUIDUtils.toOID(UUID.randomUUID()));

    // ///
    // Static Values
    // set all the static values (or overrides)
    applyStaticValues(cfg, result);

    return result;
}

From source file:com.hangum.tadpole.sql.util.SQLUtil.java

/**
 *  jdbc?    .//  ww  w .jav a 2s  .c  om
 * 
 * @param exeSQL
 * @return
 */
public static String sqlExecutable(String exeSQL) {

    //      tmpStrSelText = UnicodeUtils.getUnicode(tmpStrSelText);
    try {
        //         
        //         https://github.com/hangum/TadpoleForDBTools/issues/140  .
        //         TO DO  ? ??  ??..DB?    ?   . 

        //  ? // ? ? ?? ? .
        /*
         *  mysql?  ?? , --  ? ? --   ? ??   ?. --comment ? ? ?? .( (mssql, oralce, pgsql)? ? ??)
         *   ,  ?? ??   ?? ??   . - 2013.11.11- (hangum)
         */
        //         exeSQL = delComment(exeSQL, "--");

        //    
        //         exeSQL = StringUtils.replace(exeSQL, "\r", " ");
        //         exeSQL = StringUtils.replace(exeSQL, "\n", " ");
        //         exeSQL = StringUtils.replace(exeSQL, Define.LINE_SEPARATOR, " ");
        //         exeSQL = exeSQL.replaceAll("(\r\n|\n|\r)", " ");

        //  ?  ? 
        exeSQL = removeComment(exeSQL);
        exeSQL = StringUtils.trimToEmpty(exeSQL);
        exeSQL = StringUtils.removeEnd(exeSQL, PublicTadpoleDefine.SQL_DELIMITER);

    } catch (Exception e) {
        logger.error("query execute", e);
    }

    return exeSQL.trim();
}

From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.dialog.ExtensionBrowserURLDialog.java

/**
 * table data ./*from   w w w .  j  a v  a2s. co m*/
 */
private void deleteExtensionBrowserData() {
    String strName = StringUtils.trimToEmpty(textName.getText());
    String strUrl = StringUtils.trimToEmpty(textURL.getText());

    // url?? ?  .
    List<ExternalBrowserInfoDAO> listCheckExterBroswer = (List) tableViewer.getInput();
    for (ExternalBrowserInfoDAO externalBrowserInfoDAO : listCheckExterBroswer) {
        if (strName.equals(externalBrowserInfoDAO.getName())
                && strUrl.equals(externalBrowserInfoDAO.getUrl())) {

            listExterBroswer.remove(externalBrowserInfoDAO);
            tableViewer.refresh();
            return;
        }
    }
}

From source file:com.prowidesoftware.swift.model.field.Field98D.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*from  ww w  . j a  va  2  s.  co m*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append(StringUtils.trimToEmpty(getComponent2()));
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())) {
        result.append(",");
        result.append(StringUtils.trimToEmpty(getComponent3()));
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent4())
            || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent5())) {
        result.append("/");
        if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent4())) {
            result.append(StringUtils.trimToEmpty(getComponent4()));
        }
        result.append(StringUtils.trimToEmpty(getComponent5()));
    }
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field77D.java

/**
 * Get the Narrative as a concatenation of component1 to component6.
 * @return the Narrative from components
 *//*w ww . j  av a 2s  .c o  m*/
public String getNarrative() {
    StringBuilder result = new StringBuilder();
    for (int i = 1; i < 7; i++) {
        if (StringUtils.isNotBlank(getComponent(i))) {
            if (result.length() > 0) {
                result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
            }
            result.append(StringUtils.trimToEmpty(getComponent(i)));
        }
    }
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field26D.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 */// w  ww .j  ava2  s.  co m
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    appendInLines(result, 2, 31);
    return result.toString();
}

From source file:com.edgenius.wiki.render.impl.LinkRenderHelperImpl.java

public boolean exists(String extSpaceUname, String title) {
    extSpaceUname = StringUtils.trimToEmpty(extSpaceUname);
    title = StringUtils.trimToEmpty(title);
    if (StringUtils.isBlank(title)) {
        //only check if space exist, and this link will redir to home page of space
        return spaceDAO.getByUname(extSpaceUname) == null ? false : true;
    } else {/*from   w w w  . j ava 2 s  . co  m*/
        return pageDAO.getCurrentPageByTitle(extSpaceUname, title) == null ? false : true;
    }
}