List of usage examples for org.apache.commons.lang3 StringUtils defaultIfBlank
public static <T extends CharSequence> T defaultIfBlank(final T str, final T defaultStr)
Returns either the passed in CharSequence, or if the CharSequence is whitespace, empty ("") or null , the value of defaultStr .
StringUtils.defaultIfBlank(null, "NULL") = "NULL" StringUtils.defaultIfBlank("", "NULL") = "NULL" StringUtils.defaultIfBlank(" ", "NULL") = "NULL" StringUtils.defaultIfBlank("bat", "NULL") = "bat" StringUtils.defaultIfBlank("", null) = null
From source file:org.sleuthkit.autopsy.datamodel.accounts.BINRange.java
/** * Constructor//w ww . j a v a2s. com * * @param BIN_start the first BIN in the range, must be 8 digits * @param BIN_end the last(inclusive) BIN in the range, must be 8 * digits * @param number_length the length of account numbers in this BIN range * @param scheme amex/visa/mastercard/etc * @param brand the brand of this BIN range * @param type credit vs debit * @param country the country of the issuer * @param bank_name the name of the issuer * @param bank_url the url of the issuer * @param bank_phone the phone number of the issuer * @param bank_city the city of the issuer */ public BINRange(int BIN_start, int BIN_end, Integer number_length, String scheme, String brand, String type, String country, String bank_name, String bank_url, String bank_phone, String bank_city) { this.BINStart = BIN_start; this.BINEnd = BIN_end; this.numberLength = number_length; this.scheme = StringUtils.defaultIfBlank(scheme, null); this.brand = StringUtils.defaultIfBlank(brand, null); this.cardType = StringUtils.defaultIfBlank(type, null); this.country = StringUtils.defaultIfBlank(country, null); this.bankName = StringUtils.defaultIfBlank(bank_name, null); this.bankURL = StringUtils.defaultIfBlank(bank_url, null); this.bankPhoneNumber = StringUtils.defaultIfBlank(bank_phone, null); this.bankCity = StringUtils.defaultIfBlank(bank_city, null); }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
/** * @return the text to display as part of the header *//* www . ja v a 2 s.c o m*/ public String getHeaderString() { int size = grouping.get().getSize(); int hashHitCount = grouping.get().getFilesWithHashSetHitsCount(); String groupName; if (grouping.get().groupKey.getAttribute() == DrawableAttribute.TAGS) { groupName = ((TagName) grouping.get().groupKey.getValue()).getDisplayName(); } else { groupName = grouping.get().groupKey.getValue().toString(); } return StringUtils.defaultIfBlank(groupName, DrawableGroup.UNKNOWN) + " -- " + hashHitCount + " hash set hits / " + size + " files"; }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
/** * reset the text and icons to represent the currently filtered files *///w w w . ja v a 2s. co m protected void resetHeaderString() { if (grouping.get() == null) { Platform.runLater(() -> { groupLabel.setText(""); }); } else { int size = grouping.get().getSize(); int hashHitCount = grouping.get().getFilesWithHashSetHitsCount(); String groupName; if (grouping.get().groupKey.getAttribute() == DrawableAttribute.TAGS) { groupName = ((TagName) grouping.get().groupKey.getValue()).getDisplayName(); } else { groupName = grouping.get().groupKey.getValue().toString(); } final String headerString = StringUtils.defaultIfBlank(groupName, DrawableGroup.UNKNOWN) + " -- " + hashHitCount + " hash set hits / " + size + " files"; Platform.runLater(() -> { groupLabel.setText(headerString); }); } }
From source file:org.sleuthkit.autopsy.imagegallery.gui.drawableviews.GroupPane.java
/** * create the string to display in the group header *///from w w w . ja va 2 s .c o m @NbBundle.Messages({ "# {0} - default group name", "# {1} - hashset hits count", "# {2} - group size", "GroupPane.headerString={0} -- {1} hash set hits / {2} files" }) protected String getHeaderString() { return isNull(getGroup()) ? "" : Bundle.GroupPane_headerString( StringUtils.defaultIfBlank(getGroup().getGroupByValueDislpayName(), DrawableGroup.getBlankGroupName()), getGroup().getHashSetHitsCount(), getGroup().getSize()); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.GroupPane.java
/** create the string to display in the group header */ protected String getHeaderString() { return isNull(getGrouping()) ? "" : StringUtils.defaultIfBlank(getGrouping().getGroupByValueDislpayName(), DrawableGroup.getBlankGroupName()) + " -- " + getGrouping().getHashSetHitsCount() + " hash set hits / " + getGrouping().getSize() + " files"; }
From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupTreeCell.java
private String getGroupName() { return Optional.ofNullable(getItem()) .map((TreeNode t) -> StringUtils.defaultIfBlank(t.getPath(), DrawableGroup.getBlankGroupName())) .orElse(""); }
From source file:org.sleuthkit.autopsy.timeline.actions.SaveSnapshotAsReport.java
/** * Constructor/*from www .j a va2s .c om*/ * * @param controller The controller for this timeline action * @param nodeSupplier The Supplier of the node to snapshot. */ @NbBundle.Messages({ "Timeline.ModuleName=Timeline", "SaveSnapShotAsReport.action.dialogs.title=Timeline", "SaveSnapShotAsReport.action.name.text=Snapshot Report", "SaveSnapShotAsReport.action.longText=Save a screen capture of the current view of the timeline as a report.", "# {0} - report file path", "SaveSnapShotAsReport.ReportSavedAt=Report saved at [{0}]", "SaveSnapShotAsReport.Success=Success", "SaveSnapShotAsReport.FailedToAddReport=Failed to add snaphot to case as a report.", "# {0} - report path", "SaveSnapShotAsReport.ErrorWritingReport=Error writing report to disk at {0}.", "# {0} - generated default report name", "SaveSnapShotAsReport.reportName.prompt=leave empty for default report name: {0}.", "SaveSnapShotAsReport.reportName.header=Enter a report name for the Timeline Snapshot Report.", "SaveSnapShotAsReport.duplicateReportNameError.text=A report with that name already exists." }) public SaveSnapshotAsReport(TimeLineController controller, Supplier<Node> nodeSupplier) { super(Bundle.SaveSnapShotAsReport_action_name_text()); setLongText(Bundle.SaveSnapShotAsReport_action_longText()); setGraphic(new ImageView(SNAP_SHOT)); this.controller = controller; this.currentCase = controller.getAutopsyCase(); setEventHandler(actionEvent -> { //capture generation date and use to make default report name Date generationDate = new Date(); final String defaultReportName = FileUtil.escapeFileName(currentCase.getName() + " " + new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss").format(generationDate)); //NON_NLS BufferedImage snapshot = SwingFXUtils.fromFXImage(nodeSupplier.get().snapshot(null, null), null); //prompt user to pick report name TextInputDialog textInputDialog = new TextInputDialog(); PromptDialogManager.setDialogIcons(textInputDialog); textInputDialog.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title()); textInputDialog.getEditor() .setPromptText(Bundle.SaveSnapShotAsReport_reportName_prompt(defaultReportName)); textInputDialog.setHeaderText(Bundle.SaveSnapShotAsReport_reportName_header()); //keep prompt even if text field has focus, until user starts typing. textInputDialog.getEditor() .setStyle("-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);");//NON_NLS /* * Create a ValidationSupport to validate that a report with the * entered name doesn't exist on disk already. Disable ok button if * report name is not validated. */ ValidationSupport validationSupport = new ValidationSupport(); validationSupport.registerValidator(textInputDialog.getEditor(), false, new Validator<String>() { @Override public ValidationResult apply(Control textField, String enteredReportName) { String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName); boolean exists = Files.exists(Paths.get(currentCase.getReportDirectory(), reportName)); return ValidationResult.fromErrorIf(textField, Bundle.SaveSnapShotAsReport_duplicateReportNameError_text(), exists); } }); textInputDialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty() .bind(validationSupport.invalidProperty()); //show dialog and handle result textInputDialog.showAndWait().ifPresent(enteredReportName -> { //reportName defaults to case name + timestamp if left blank String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName); Path reportFolderPath = Paths.get(currentCase.getReportDirectory(), reportName, "Timeline Snapshot"); //NON_NLS Path reportMainFilePath; try { //generate and write report reportMainFilePath = new SnapShotReportWriter(currentCase, reportFolderPath, reportName, controller.getEventsModel().getZoomParamaters(), generationDate, snapshot) .writeReport(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Error writing report to disk at " + reportFolderPath, ex); //NON_NLS new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_ErrorWritingReport(reportFolderPath)).show(); return; } try { //add main file as report to case Case.getCurrentCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(), reportName); } catch (TskCoreException ex) { LOGGER.log(Level.WARNING, "Failed to add " + reportMainFilePath.toString() + " to case as a report", ex); //NON_NLS new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_FailedToAddReport()).show(); return; } //notify user of report location final Alert alert = new Alert(Alert.AlertType.INFORMATION, null, OPEN, OK); alert.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title()); alert.setHeaderText(Bundle.SaveSnapShotAsReport_Success()); //make action to open report, and hyperlinklable to invoke action final OpenReportAction openReportAction = new OpenReportAction(reportMainFilePath); HyperlinkLabel hyperlinkLabel = new HyperlinkLabel( Bundle.SaveSnapShotAsReport_ReportSavedAt(reportMainFilePath.toString())); hyperlinkLabel.setOnAction(openReportAction); alert.getDialogPane().setContent(hyperlinkLabel); alert.showAndWait().filter(OPEN::equals).ifPresent(buttonType -> openReportAction.handle(null)); }); }); }
From source file:org.sleuthkit.autopsy.timeline.db.SQLHelper.java
/** * get the SQL where clause corresponding to an intersection filter ie * (sub-clause1 and sub-clause2 and ... and sub-clauseN) * * @param filter the filter get the where clause for * * @return an SQL where clause (without the "where") corresponding to the * filter// w w w . j ava 2 s . c o m */ private static String getSQLWhere(IntersectionFilter<?> filter) { String join = String.join(" and ", filter.getSubFilters().stream().filter(Filter::isActive) .map(SQLHelper::getSQLWhere).collect(Collectors.toList())); return "(" + StringUtils.defaultIfBlank(join, "1") + ")"; }
From source file:org.sleuthkit.autopsy.timeline.db.SQLHelper.java
/** * get the SQL where clause corresponding to a union filter ie (sub-clause1 * or sub-clause2 or ... or sub-clauseN) * * @param filter the filter get the where clause for * * @return an SQL where clause (without the "where") corresponding to the * filter/* w w w . j a va2 s . c o m*/ */ private static String getSQLWhere(UnionFilter<?> filter) { String join = String.join(" or ", filter.getSubFilters().stream().filter(Filter::isActive) .map(SQLHelper::getSQLWhere).collect(Collectors.toList())); return "(" + StringUtils.defaultIfBlank(join, "1") + ")"; }
From source file:org.sleuthkit.autopsy.timeline.filters.TextFilter.java
@Override public String getHTMLReportString() { return "text like \"" + StringUtils.defaultIfBlank(text.getValue(), "") + "\"" + getStringCheckBox(); // NON-NLS }