List of usage examples for org.apache.commons.lang StringUtils abbreviate
public static String abbreviate(String str, int maxWidth)
Abbreviates a String using ellipses.
From source file:org.ejbca.ui.web.CertificateView.java
public String getPublicKeyModulus() { String mod = null;/* w w w . j ava 2 s .com*/ if (certificate.getPublicKey() instanceof RSAPublicKey) { mod = "" + ((RSAPublicKey) certificate.getPublicKey()).getModulus().toString(16); mod = mod.toUpperCase(); mod = StringUtils.abbreviate(mod, 50); } else if (certificate.getPublicKey() instanceof DSAPublicKey) { mod = "" + ((DSAPublicKey) certificate.getPublicKey()).getY().toString(16); mod = mod.toUpperCase(); mod = StringUtils.abbreviate(mod, 50); } else if (certificate.getPublicKey() instanceof ECPublicKey) { mod = "" + ((ECPublicKey) certificate.getPublicKey()).getW().getAffineX().toString(16); mod = mod + ((ECPublicKey) certificate.getPublicKey()).getW().getAffineY().toString(16); mod = mod.toUpperCase(); mod = StringUtils.abbreviate(mod, 50); } return mod; }
From source file:org.gitools.ui.app.actions.data.analysis.ViewEnrichmentModuleDataAction.java
@Override public void onConfigure(HeatmapDimension dimension, HeatmapPosition position) { boolean enable = getHeatmap().getMetadata(EnrichmentAnalysis.CACHE_KEY_ENHRICHMENT) != null && dimension.getId().equals(MatrixDimensionKey.ROWS); setEnabled(enable);//from ww w. j a va 2 s. com if (enable) { this.analysis = getHeatmap().getMetadata(EnrichmentAnalysis.CACHE_KEY_ENHRICHMENT); this.moduleId = dimension.getLabel(position.getRow()); } this.setName("<html><i>View</i> data for '" + StringUtils.abbreviate(moduleId, 25) + "' module</html>"); }
From source file:org.gitools.ui.app.actions.data.analysis.ViewGroupComparisonResultDataAction.java
@Override public void onConfigure(HeatmapDimension dimension, HeatmapPosition position) { boolean enable = getHeatmap().getMetadata(GroupComparisonAnalysis.CACHE_KEY_GC_ANALYSIS) != null && dimension.getId().equals(MatrixDimensionKey.ROWS); setEnabled(enable);/* w w w.j a va 2s. c o m*/ if (enable) { this.analysis = getHeatmap().getMetadata(GroupComparisonAnalysis.CACHE_KEY_GC_ANALYSIS); this.rowId = dimension.getLabel(position.getRow()); } this.setName("<html><i>View</i> data for '" + StringUtils.abbreviate(rowId, 25) + "' results</html>"); }
From source file:org.gitools.ui.core.components.boxes.DetailsBox.java
private Component createValueLabel(DetailsDecoration property, int maxLength) { String value = property.getFormatedValue(); boolean abbreviate = (value.length() > maxLength); String abbreviatedValue;// www .j av a 2 s .co m if (value.matches("[0-9\\.]+e-?[0-9]+")) { value = "<html><body>" + value.replaceAll("e(-?[0-9]+)", "10<sup>$1</sup>") + "</body></html>"; } if (abbreviate) { abbreviatedValue = StringUtils.abbreviate(value, maxLength); } else { abbreviatedValue = value; } WebLabel label; if (StringUtils.isEmpty(property.getValueLink())) { label = new WebLabel(abbreviatedValue); } else { DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel(abbreviatedValue); webLabel.setLink(property.getValueLink(), false); label = webLabel; } SwingUtils.changeFontSize(label, -1); if (abbreviate) { TooltipManager.setTooltip(label, value, TooltipWay.down, 0); } label.setCursor(new Cursor(Cursor.HAND_CURSOR)); label.addMouseListener(new PropertyMouseListener(property)); if (property.isSelected()) { SwingUtils.setBoldFont(label); } if (property.getBgColor() != null) { WebPanel colorBox = new WebPanel(); colorBox.setPreferredSize(new Dimension(15, 15)); colorBox.setBackground(property.getBgColor()); return new GroupPanel(4, colorBox, label); } return label; }
From source file:org.gitools.ui.core.components.editor.EditorTabComponent.java
private void updateLabel() { if (editor.isDirty()) { label.setFont(label.getFont().deriveFont(Font.BOLD)); } else {/* w w w . java 2 s . c om*/ label.setFont(label.getFont().deriveFont(Font.PLAIN)); } String name = editor.getName(); if (name == null) { name = "unnamed"; } String extension = ""; String filename = name; String newname; int i = name.lastIndexOf('.'); if (i > 0) { extension = "." + name.substring(i + 1); filename = name.substring(0, name.lastIndexOf('.')); } newname = StringUtils.abbreviate(filename, DEFAULT_EDITOR_TAB_LENGTH) + extension; label.setText(newname); label.setIcon(editor.getIcon()); label.setIconTextGap(3); label.setHorizontalTextPosition(SwingConstants.RIGHT); String toolTip = null; if (editor.getFile() != null) { toolTip = editor.getFile().getAbsolutePath(); } label.setToolTipText(toolTip); }
From source file:org.gradle.util.DeprecationLogger.java
public static void nagUserAboutDynamicProperty(String propertyName, Object target, Object value) { if (!isEnabled()) { return;// ww w . j a v a 2 s .com } nagUserOfDeprecated("Creating properties on demand (a.k.a. dynamic properties)", "Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties"); String propertyWithClass = target.getClass().getName() + "." + propertyName; if (DYNAMIC_PROPERTIES.add(propertyWithClass)) { String propertyWithTarget = String.format("\"%s\" on \"%s\"", propertyName, target); String theValue = (value == null) ? "null" : StringUtils.abbreviate(value.toString(), 25); nagUserWith( String.format("Deprecated dynamic property: %s, value: \"%s\".", propertyWithTarget, theValue)); } else { nagUserWith(String.format("Deprecated dynamic property \"%s\" created in multiple locations.", propertyName)); } }
From source file:org.grycap.gpf4med.graph.base.BaseDocumentCreator.java
public Node getOrCreateLocation(final Transaction tx, final GraphDatabaseService graphDb, final Num num, final Node parent, final Template template) { checkArgument(num != null && num.getCONCEPTNAME() != null, "Uninitialized or invalid numeric field"); final ConceptName conceptName = num.getCONCEPTNAME(); final String id = Id.getId(conceptName); checkState(StringUtils.isNotBlank(id), "Tumour location id is invalid"); final UniqueFactory<Node> uniqueFactory = new UniqueFactory.UniqueNodeFactory(graphDb, TUMOUR_LOCATION_NODE) {/*from w w w.j a v a 2s.c o m*/ @Override protected void initialize(final Node created, final Map<String, Object> properties) { created.setProperty(ID_PROPERTY, properties.get(ID_PROPERTY)); } }; final Node node = uniqueFactory.getOrCreate(ID_PROPERTY, id); if (!node.hasLabel(LabelTypes.TUMOUR_LOCATION)) { node.addLabel(LabelTypes.TUMOUR_LOCATION); } if (!node.hasProperty(DESCRIPTION_PROPERTY)) { ConceptNameTemplate conceptNameTemplate = new ConceptNameTemplate() .withCODEVALUE(conceptName.getCODEVALUE()).withCODESCHEMA(conceptName.getCODESCHEMA()) .withCODEMEANING(conceptName.getCODEMEANING()).withCODEMEANING2(conceptName.getCODEMEANING2()); final String meaning = TemplateUtils.getMeaning(conceptNameTemplate, template, null); if (StringUtils.isNotBlank(meaning)) { node.setProperty(DESCRIPTION_PROPERTY, StringUtils.abbreviate(meaning, 20)); } } parent.createRelationshipTo(node, RelTypes.LOCATED_IN); return node; }
From source file:org.grycap.gpf4med.graph.base.BaseDocumentCreator.java
public Node getOrCreateFinding(final Transaction tx, final GraphDatabaseService graphDb, final Num num, final Node parent, final Template template) { checkArgument(num != null && num.getCONCEPTNAME() != null, "Uninitialized or invalid numeric field"); final ConceptName conceptName = num.getCONCEPTNAME(); final String id = Id.getId(conceptName); checkState(StringUtils.isNotBlank(id), "Finding id is invalid"); final UniqueFactory<Node> uniqueFactory = new UniqueFactory.UniqueNodeFactory(graphDb, FINDING_NODE) { @Override// w w w. j av a 2 s . c o m protected void initialize(final Node created, final Map<String, Object> properties) { created.setProperty(ID_PROPERTY, properties.get(ID_PROPERTY)); } }; final Node node = uniqueFactory.getOrCreate(ID_PROPERTY, id); if (!node.hasLabel(LabelTypes.FINDING)) { node.addLabel(LabelTypes.FINDING); } if (!node.hasProperty(DESCRIPTION_PROPERTY)) { ConceptNameTemplate conceptNameTemplate = new ConceptNameTemplate() .withCODEVALUE(conceptName.getCODEVALUE()).withCODESCHEMA(conceptName.getCODESCHEMA()) .withCODEMEANING(conceptName.getCODEMEANING()).withCODEMEANING2(conceptName.getCODEMEANING2()); final String meaning = TemplateUtils.getMeaning(conceptNameTemplate, template, null); if (StringUtils.isNotBlank(meaning)) { node.setProperty(DESCRIPTION_PROPERTY, StringUtils.abbreviate(meaning, 20)); } } parent.createRelationshipTo(node, RelTypes.PRESENTS); return node; }
From source file:org.haiku.haikudepotserver.job.controller.JobController.java
/** * <p>This is helper-code that can be used to check to see if the data is stale and * will then enqueue the job, run it and then redirect the user to the data * download.</p>/*www . ja v a 2 s . com*/ * @param response is the HTTP response to send the redirect to. * @param ifModifiedSinceHeader is the inbound header from the client. * @param lastModifyTimestamp is the actual last modified date for the data. * @param jobSpecification is the job that would be run if the data is newer than in the * inbound header. */ public static void handleRedirectToJobData(HttpServletResponse response, JobService jobService, String ifModifiedSinceHeader, Date lastModifyTimestamp, JobSpecification jobSpecification) throws IOException { if (!Strings.isNullOrEmpty(ifModifiedSinceHeader)) { try { Date requestModifyTimestamp = new Date(Instant .from(DateTimeFormatter.RFC_1123_DATE_TIME.parse(ifModifiedSinceHeader)).toEpochMilli()); if (requestModifyTimestamp.getTime() >= lastModifyTimestamp.getTime()) { response.setStatus(HttpStatus.NOT_MODIFIED.value()); return; } } catch (DateTimeParseException dtpe) { LOGGER.warn("bad [{}] header on request; [{}] -- will ignore", HttpHeaders.IF_MODIFIED_SINCE, StringUtils.abbreviate(ifModifiedSinceHeader, 128)); } } // what happens here is that we get the report and if it is too old, delete it and try again. JobSnapshot jobSnapshot = getJobSnapshotStartedAfter(jobService, lastModifyTimestamp, jobSpecification); Set<String> jobDataGuids = jobSnapshot.getDataGuids(); if (1 != jobDataGuids.size()) { throw new IllegalStateException("found [" + jobDataGuids.size() + "] job data guids related to the job [" + jobSnapshot.getGuid() + "] - was expecting 1"); } String lastModifiedValue = DateTimeFormatter.RFC_1123_DATE_TIME .format(ZonedDateTime.ofInstant(lastModifyTimestamp.toInstant(), ZoneOffset.UTC)); String destinationLocationUrl = UriComponentsBuilder.newInstance() .pathSegment(AuthenticationFilter.SEGMENT_SECURED).pathSegment(JobController.SEGMENT_JOBDATA) .pathSegment(jobDataGuids.iterator().next()).pathSegment(JobController.SEGMENT_DOWNLOAD) .toUriString(); response.addHeader(HttpHeaders.LAST_MODIFIED, lastModifiedValue); response.sendRedirect(destinationLocationUrl); }
From source file:org.hyperic.hq.management.shared.PolicyStatus.java
public void setConfigStatusBuf(String configStatusBuf) { this.configStatusBuf = StringUtils.abbreviate(configStatusBuf, MAX_STATUS_BUF_WIDTH); }