List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:cn.leancloud.diamond.server.service.NotifyService.java
String generateNotifyConfigInfoPath(String dataId, String group, String address) { String specialUrl = this.nodeProperties.getProperty(address); String urlString = PROTOCOL + address + URL_PREFIX; // urlurl//from w w w . j a v a2s . c o m if (specialUrl != null && StringUtils.hasLength(specialUrl.trim())) { urlString = specialUrl; } urlString += "?method=notifyConfigInfo&dataId=" + dataId + "&group=" + group; return urlString; }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.java
/** * {@inheritDoc}//from w w w . j a v a2s .c om * @see org.springframework.security.ui.AbstractProcessingFilter#determineFailureUrl( * javax.servlet.http.HttpServletRequest, org.springframework.security.AuthenticationException) */ @Override protected String determineFailureUrl(final HttpServletRequest request, final AuthenticationException failed) { String url = super.determineFailureUrl(request, failed); if (getAuthenticationFailureUrl().equals(url) && AuthorizeTools.isAjax(request)) { url = StringUtils.hasLength(_ajaxAuthenticationFailureUrl) ? _ajaxAuthenticationFailureUrl : getAuthenticationFailureUrl(); } return url; }
From source file:jails.http.converter.feed.AbstractWireFeedHttpMessageConverter.java
@Override protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { String wireFeedEncoding = wireFeed.getEncoding(); if (!StringUtils.hasLength(wireFeedEncoding)) { wireFeedEncoding = DEFAULT_CHARSET.name(); }// w w w. j a v a2 s . c o m MediaType contentType = outputMessage.getHeaders().getContentType(); if (contentType != null) { Charset wireFeedCharset = Charset.forName(wireFeedEncoding); contentType = new MediaType(contentType.getType(), contentType.getSubtype(), wireFeedCharset); outputMessage.getHeaders().setContentType(contentType); } WireFeedOutput feedOutput = new WireFeedOutput(); try { Writer writer = new OutputStreamWriter(outputMessage.getBody(), wireFeedEncoding); feedOutput.output(wireFeed, writer); } catch (FeedException ex) { throw new HttpMessageNotWritableException("Could not write WiredFeed: " + ex.getMessage(), ex); } }
From source file:org.mifos.androidclient.main.LoanInstallmentDetailsActivity.java
private void runLoanInstallmentDetailsTask() { if (StringUtils.hasLength(mAccountNumber)) { if (mLoanInstallmentDetailsTask == null || mLoanInstallmentDetailsTask.getStatus() != AsyncTask.Status.RUNNING) { mLoanInstallmentDetailsTask = new LoanInstallmentDetailsTask(this, getString(R.string.dialog_getting_installment_details), getString(R.string.dialog_loading_message)); mLoanInstallmentDetailsTask.execute(mAccountNumber); }/* www . java 2s .co m*/ } }
From source file:uk.ac.gda.dls.client.views.ReadonlyScannableComposite.java
public ReadonlyScannableComposite(Composite parent, int style, final Scannable scannable, String label, final String units, Integer decimalPlaces) { super(parent, style); this.display = parent.getDisplay(); this.scannable = scannable; this.decimalPlaces = decimalPlaces; if (StringUtils.hasLength(units)) { suffix = " " + units; }/*w ww. ja va2 s . c om*/ formats = scannable.getOutputFormat(); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(this); GridDataFactory.fillDefaults().applyTo(this); Label lbl = new Label(this, SWT.NONE | SWT.CENTER); lbl.setText(StringUtils.hasLength(label) ? label : scannable.getName()); int textStyle = SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY | SWT.CENTER; text = new Text(this, textStyle); text.setEditable(false); setTextRunnable = new Runnable() { @Override public void run() { beforeUpdateText(text, val); int currentLength = text.getText().length(); String valPlusUnits = val + suffix; text.setText(valPlusUnits); int diff = valPlusUnits.length() - currentLength; if (diff > 0 || diff < -3) EclipseWidgetUtils.forceLayoutOfTopParent(ReadonlyScannableComposite.this); if (colourMap != null) { Integer colorId = colourMap.get(val); if (colorId != null) { text.setForeground(Display.getCurrent().getSystemColor(colorId)); } } textUpdateScheduled = false; afterUpdateText(text, val); } }; observer = new IObserver() { @Override public void update(Object source, Object arg) { if (arg instanceof ScannablePositionChangeEvent) { final ScannablePositionChangeEvent event = (ScannablePositionChangeEvent) arg; setVal(new ScannableGetPositionWrapper(event.newPosition, formats) .getStringFormattedValues()[0]); } else if (arg instanceof ScannableStatus && ((ScannableStatus) arg).status == ScannableStatus.IDLE) { try { ScannableGetPositionWrapper wrapper = new ScannableGetPositionWrapper( scannable.getPosition(), formats); val = wrapper.getStringFormattedValues()[0]; } catch (DeviceException e1) { val = "Error"; logger.error("Error getting position for " + scannable.getName(), e1); } setVal(val); } else if (arg instanceof String) { setVal((String) arg); } else { ScannableGetPositionWrapper wrapper = new ScannableGetPositionWrapper(arg, formats); setVal(wrapper.getStringFormattedValues()[0]); } } }; try { ScannableGetPositionWrapper wrapper = new ScannableGetPositionWrapper(scannable.getPosition(), formats); val = wrapper.getStringFormattedValues()[0]; } catch (DeviceException e1) { val = "Error"; logger.error("Error getting position for " + scannable.getName(), e1); } setVal(val); scannable.addIObserver(observer); }
From source file:org.openmrs.module.sync.ingest.SyncImportRecord.java
public SyncImportRecord(SyncRecord record) { if (record != null) { // the uuid should be set to original uuid - this way all subsequent attempts to execute this change are matched to this import this.uuid = record.getOriginalUuid(); this.creator = record.getCreator(); this.databaseVersion = record.getDatabaseVersion(); this.timestamp = record.getTimestamp(); this.retryCount = record.getRetryCount(); this.state = record.getState(); if (StringUtils.hasLength(record.getContainedClasses())) { this.description = record.getContainedClasses().split(",")[0]; }//from w ww . j av a 2s .c o m } }
From source file:fr.xebia.management.config.ProfileAspectDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ProfileAspect.class); // see http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/aop.html#aop-aj-configure builder.setFactoryMethod("aspectOf"); // Mark as infrastructure bean and attach source location. builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE); if (StringUtils.hasText(serverBeanName)) { builder.addPropertyReference("server", serverBeanName); } else {/*from ww w . j a v a 2s .c o m*/ AbstractBeanDefinition specialServer = findServerForSpecialEnvironment(); if (specialServer != null) { builder.addPropertyValue("server", specialServer); } } String jmxDomain = element.getAttribute(JMX_DOMAIN_ATTRIBUTE); if (StringUtils.hasLength(jmxDomain)) { builder.addPropertyValue("jmxDomain", jmxDomain); } return builder.getBeanDefinition(); }
From source file:com.qpark.eip.core.failure.FailureAssert.java
/** * Assert that the given String is not empty; that is, it must not be * <code>null</code> and not the empty String. * * <pre class="code">//from w w w . j a v a 2 s . com * Assert.hasLength(name, "Name must not be empty"); * </pre> * * @param text * the String to check * @param errorCode * the error code to use if the assertion fails * @param data * additional information to the error code. * @see StringUtils#hasLength */ public static void hasLength(final String text, final String errorCode, final Object... data) { if (!StringUtils.hasLength(text)) { BaseFailureHandler.throwFailureException(errorCode, text, data); } }
From source file:org.zilverline.core.TestFileSystemCollection.java
public void testNoCacheURL() { FileSystemCollection col = new FileSystemCollection(); assertNotNull(col.getCacheDirWithManagerDefaults()); assertNotNull(col.getCacheUrlWithManagerDefaults()); col.setCacheDir(new File(System.getProperty("java.io.tmpdir"))); col.setCacheUrl(null);//from w w w. jav a 2s . c om assertTrue(new File(System.getProperty("java.io.tmpdir")).exists()); assertTrue("need a URL", StringUtils.hasLength(col.getCacheUrlWithManagerDefaults())); assertTrue(col.getCacheUrlWithManagerDefaults().endsWith("/")); }
From source file:org.jasypt.spring31.xml.encryption.UtilDigesterBeanDefinitionParser.java
@Override protected void doParse(final Element element, final BeanDefinitionBuilder builder) { processStringAttribute(element, builder, PARAM_ALGORITHM, "algorithm"); processBeanAttribute(element, builder, PARAM_CONFIG_BEAN, "config"); processBeanAttribute(element, builder, PARAM_PROVIDER_BEAN, "provider"); processStringAttribute(element, builder, PARAM_PROVIDER_NAME, "providerName"); processStringAttribute(element, builder, PARAM_STRING_OUTPUT_TYPE, "stringOutputType"); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope);//from ww w. j a va 2 s . c om } }