List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(String str1, String str2)
Compares two Strings, returning true
if they are equal ignoring the case.
From source file:com.nridge.ds.solr.SolrParentChild.java
private DataField pcExpansionField(String aValue) { String fieldName;/*from w w w . j ava 2 s .c o m*/ if (StringUtils.startsWithIgnoreCase(aValue, Solr.PC_EXPANSION_BOTH)) fieldName = Solr.PC_EXPANSION_BOTH; else if (StringUtils.startsWithIgnoreCase(aValue, Solr.PC_EXPANSION_CHILD)) fieldName = Solr.PC_EXPANSION_CHILD; else if (StringUtils.equalsIgnoreCase(aValue, Solr.PC_EXPANSION_PARENT)) fieldName = Solr.PC_EXPANSION_PARENT; else fieldName = Solr.PC_EXPANSION_NONE; DataField expansionField = new DataIntegerField(fieldName, Field.nameToTitle(fieldName)); expansionField.setMultiValueFlag(true); expansionField.addValue(extractOffset(aValue)); expansionField.addValue(extractLimit(aValue)); return expansionField; }
From source file:fr.paris.lutece.plugins.extend.service.content.ExtendableContentPostProcessor.java
/** * {@inheritDoc}/*from w w w . ja v a 2 s .c o m*/ */ @Override public String process(HttpServletRequest request, String strContent) { String strHtmlContent = strContent; // Check if the process is carried out in client or server side boolean bClientSide = Boolean.valueOf(AppPropertiesService.getProperty(PROPERTY_CLIENT_SIDE, "false")); if (bClientSide) { // CLIENT SIDE int nPos = strHtmlContent.indexOf(END_BODY); if (nPos < 0) { AppLogService.error("ExtendableContentPostProcessor Service : no BODY end tag found"); return strHtmlContent; } Map<String, Object> model = new HashMap<String, Object>(); model.put(MARK_BASE_URL, AppPathService.getBaseUrl(request)); model.put(MARK_REGEX_PATTERN, _strRegexPattern); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_CONTENT_POST_PROCESSOR, request.getLocale(), model); StringBuilder sb = new StringBuilder(); sb.append(strHtmlContent.substring(0, nPos)); sb.append(template.getHtml()); sb.append(strHtmlContent.substring(nPos)); strHtmlContent = sb.toString(); } else { // SERVER SIDE /** * Replace all makers @Extender[<idResource>,<resourceType>,<extenderType>,<params>]@ to * the correct HTML content of the extender. * 1) First parse the content of the markers * 2) Get all information (idResource, resourceType, extenderType, params) * 3) Get the html content from the given information * 4) Replace the markers by the html content */ // 1) First parse the content of the markers Matcher match = _regexPattern.matcher(strHtmlContent); Matcher parameterMatch = null; StringBuffer strResultHTML = new StringBuffer(strHtmlContent.length()); while (match.find()) { String strMarker = match.group(); // 2) Get all information (idResource, resourceType, extenderType, params) ResourceExtenderDTO resourceExtender = _mapper.map(match.group(1)); boolean bParameteredId = StringUtils.equalsIgnoreCase(resourceExtender.getIdExtendableResource(), EXTEND_PARAMETERED_ID); if (bParameteredId) { if (parameterMatch == null) { parameterMatch = _extendedParameterRegexPattern.matcher(strHtmlContent); } else { parameterMatch.reset(); } while (parameterMatch.find()) { ResourceExtenderDTO realResourceExtender = _mapper.map(parameterMatch.group(1)); if (StringUtils.equals(realResourceExtender.getExtendableResourceType(), resourceExtender.getExtendableResourceType()) && StringUtils.equals(realResourceExtender.getExtenderType(), resourceExtender.getExtenderType())) { resourceExtender .setIdExtendableResource(realResourceExtender.getIdExtendableResource()); break; } } } String strHtml = StringUtils.EMPTY; if (!bParameteredId || !StringUtils.equalsIgnoreCase(resourceExtender.getIdExtendableResource(), EXTEND_PARAMETERED_ID)) { // 3) Get the html content from the given information if (!StringUtils.equals(resourceExtender.getExtendableResourceType(), Page.RESOURCE_TYPE) || (StringUtils.isBlank(request.getParameter(PARAM_PAGE)) && StringUtils.isBlank(request.getParameter(PARAM_PORTLET_ID)))) { strHtml = _extenderService.getContent(resourceExtender.getIdExtendableResource(), resourceExtender.getExtendableResourceType(), resourceExtender.getExtenderType(), resourceExtender.getParameters(), request); } } // 4) Replace the markers by the html content match.appendReplacement(strResultHTML, Matcher.quoteReplacement(strHtml)); } match.appendTail(strResultHTML); strHtmlContent = strResultHTML.toString(); } if (StringUtils.isNotBlank(_strExtenderParameterRegexPattern)) { strHtmlContent = _extendedParameterRegexPattern.matcher(strHtmlContent).replaceAll(""); } return strHtmlContent; }
From source file:hydrograph.ui.graph.editor.JobDeleteParticipant.java
private void setJobFileAndXmlFile(IFolder jobsFolder) { try {/* ww w .j ava 2 s . c o m*/ IResource[] members = jobsFolder.members(); if (members != null) { for (IResource jobFolderMember : members) { if ((IFolder.class).isAssignableFrom(jobFolderMember.getClass())) { setJobFileAndXmlFile((IFolder) jobFolderMember); } else if ((IFile.class).isAssignableFrom(jobFolderMember.getClass())) { String file = jobFolderMember.getFullPath().lastSegment(); if (StringUtils.equalsIgnoreCase(modifiedResource.getName() .replace(Constants.PROPERTIES_EXTENSION, Constants.JOB_EXTENSION), file)) { jobIFile = jobsFolder.getFile(modifiedResource.getName() .replace(Constants.PROPERTIES_EXTENSION, Constants.JOB_EXTENSION)); } else if (StringUtils.equalsIgnoreCase(modifiedResource.getName() .replace(Constants.PROPERTIES_EXTENSION, Constants.XML_EXTENSION), file)) { xmlIFile = jobsFolder.getFile(modifiedResource.getName() .replace(Constants.PROPERTIES_EXTENSION, Constants.XML_EXTENSION)); } } } } } catch (CoreException coreException) { LOGGER.error("Error while setting job file and xml file for dependent deletion", coreException); } }
From source file:com.xx_dev.apn.proxy.ApnProxyUserAgentTunnelHandler.java
private String constructConnectRequestForProxy(HttpRequest httpRequest, ApnProxyRemote apnProxyRemote) { String CRLF = "\r\n"; String url = httpRequest.getUri(); StringBuilder sb = new StringBuilder(); sb.append(httpRequest.getMethod().name()).append(" ").append(url).append(" ") .append(httpRequest.getProtocolVersion().text()).append(CRLF); Set<String> headerNames = httpRequest.headers().names(); for (String headerName : headerNames) { if (StringUtils.equalsIgnoreCase(headerName, "Proxy-Connection")) { continue; }//from w w w .ja v a 2 s.co m if (StringUtils.equalsIgnoreCase(headerName, HttpHeaders.Names.CONNECTION)) { continue; } for (String headerValue : httpRequest.headers().getAll(headerName)) { sb.append(headerName).append(": ").append(headerValue).append(CRLF); } } if (StringUtils.isNotBlank(apnProxyRemote.getProxyUserName()) && StringUtils.isNotBlank(apnProxyRemote.getProxyPassword())) { String proxyAuthorization = apnProxyRemote.getProxyUserName() + ":" + apnProxyRemote.getProxyPassword(); try { sb.append("Proxy-Authorization: Basic " + Base64.encodeBase64String(proxyAuthorization.getBytes("UTF-8"))).append(CRLF); } catch (UnsupportedEncodingException e) { } } sb.append(CRLF); return sb.toString(); }
From source file:com.evolveum.icf.dummy.resource.DummyObject.java
private void addAttributeValue(String attrName, Set<Object> currentValues, Object valueToAdd) throws SchemaViolationException, ConnectException, FileNotFoundException { checkModifyBreak();//ww w . j a va 2 s.com if (resource != null && !resource.isTolerateDuplicateValues()) { for (Object currentValue : currentValues) { if (currentValue.equals(valueToAdd)) { throw new IllegalArgumentException("The value '" + valueToAdd + "' of attribute '" + attrName + "' conflicts with existing value: Attempt to add value that already exists"); } if (resource.isCaseIgnoreValues() && (valueToAdd instanceof String)) { if (StringUtils.equalsIgnoreCase((String) currentValue, (String) valueToAdd)) { throw new IllegalArgumentException("The value '" + valueToAdd + "' of attribute '" + attrName + "' conflicts with existing value: Attempt to add value that already exists"); } } } } Set<Object> valuesToCheck = new HashSet<Object>(); valuesToCheck.addAll(currentValues); valuesToCheck.add(valueToAdd); checkSchema(attrName, valuesToCheck, "add"); currentValues.add(valueToAdd); }
From source file:com.bfd.harpc.config.ClientConfig.java
/** * client//from ww w . ja v a 2 s .c o m * <p> * * @param classLoader * @param ifaceClass * @throws ClassNotFoundException * @throws InstantiationException * @throws IllegalAccessException */ @SuppressWarnings("unchecked") protected GenericKeyedObjectPool<ServerNode, T> bulidClientPool(ClassLoader classLoader, Class<?> ifaceClass) throws ClassNotFoundException, InstantiationException, IllegalAccessException { // poolConfig GenericKeyedObjectPool.Config poolConfig = new GenericKeyedObjectPool.Config(); poolConfig.maxActive = maxActive; poolConfig.maxIdle = maxIdle; poolConfig.minIdle = minIdle; poolConfig.maxWait = maxWait; poolConfig.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; poolConfig.testWhileIdle = testWhileIdle; if (StringUtils.equalsIgnoreCase(protocol, "thrift")) { // Client.Factory Class<TServiceClientFactory<TServiceClient>> fi = (Class<TServiceClientFactory<TServiceClient>>) classLoader .loadClass(findOutClassName() + "$Client$Factory"); TServiceClientFactory<TServiceClient> clientFactory = fi.newInstance(); TServiceClientPoolFactory<T> clientPool = new TServiceClientPoolFactory<T>(clientFactory, timeout); return new GenericKeyedObjectPool<ServerNode, T>(clientPool, poolConfig); } else if (StringUtils.equalsIgnoreCase(protocol, "avro")) { AvroClientPoolFactory<T> clientPool = new AvroClientPoolFactory<T>(timeout, ifaceClass); return new GenericKeyedObjectPool<ServerNode, T>(clientPool, poolConfig); } else { throw new RpcException(RpcException.CONFIG_EXCEPTION, "Unsupport protocal,please check the params 'protocal'!"); } }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.ELTFilePathWidget.java
@Override public void attachToPropertySubGroup(AbstractELTContainerWidget container) { ELTDefaultSubgroupComposite eltSuDefaultSubgroupComposite = new ELTDefaultSubgroupComposite( container.getContainerControl()); eltSuDefaultSubgroupComposite.createContainerWidget(); AbstractELTWidget eltDefaultLable = new ELTDefaultLable(filepathConfig.getLabel()); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultLable); setPropertyHelpWidget((Control) eltDefaultLable.getSWTWidgetControl()); AbstractELTWidget eltDefaultTextBox = new ELTDefaultTextBox().grabExcessHorizontalSpace(true) .textBoxWidth(200);/*from w ww.jav a2s . co m*/ eltSuDefaultSubgroupComposite.attachWidget(eltDefaultTextBox); textBox = (Text) eltDefaultTextBox.getSWTWidgetControl(); decorator = WidgetUtility.addDecorator(textBox, Messages.EMPTYFIELDMESSAGE); textBox.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (textBox.getText().isEmpty() && filepathConfig.isMandatory()) { decorator.show(); textBox.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 255, 204)); } else { decorator.hide(); } } @Override public void focusGained(FocusEvent e) { decorator.hide(); textBox.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 255, 255)); } }); AbstractELTWidget eltDefaultButton = new ELTDefaultButton("...").buttonWidth(35); eltSuDefaultSubgroupComposite.attachWidget(eltDefaultButton); button = (Button) eltDefaultButton.getSWTWidgetControl(); button.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { decorator.hide(); textBox.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 255, 255)); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); txtDecorator = WidgetUtility.addDecorator(textBox, Messages.CHARACTERSET); txtDecorator.setMarginWidth(3); decorator.setMarginWidth(3); ListenerHelper helper = new ListenerHelper(); helper.put(HelperType.CONTROL_DECORATION, txtDecorator); helper.put(HelperType.CURRENT_COMPONENT, getComponent()); helper.put(HelperType.FILE_EXTENSION, filepathConfig.getfileExtension()); try { eltDefaultTextBox.attachListener(ListenerFactory.Listners.EVENT_CHANGE.getListener(), propertyDialogButtonBar, null, eltDefaultTextBox.getSWTWidgetControl()); if (filepathConfig.isMandatory()) eltDefaultTextBox.attachListener(ListenerFactory.Listners.MODIFY.getListener(), propertyDialogButtonBar, helper, eltDefaultTextBox.getSWTWidgetControl()); if (StringUtils.equalsIgnoreCase(Constants.OUTPUT, getComponent().getCategory())) { eltDefaultButton.attachListener(ListenerFactory.Listners.DIRECTORY_DIALOG_SELECTION.getListener(), propertyDialogButtonBar, helper, eltDefaultButton.getSWTWidgetControl(), eltDefaultTextBox.getSWTWidgetControl()); eltDefaultTextBox.attachListener(ListenerFactory.Listners.FILE_PATH_MODIFY.getListener(), propertyDialogButtonBar, helper, eltDefaultTextBox.getSWTWidgetControl()); } else { eltDefaultButton.attachListener(ListenerFactory.Listners.FILE_DIALOG_SELECTION.getListener(), propertyDialogButtonBar, helper, eltDefaultButton.getSWTWidgetControl(), eltDefaultTextBox.getSWTWidgetControl()); // eltDefaultTextBox.attachListener(listenerFactory.getListener("ELTFocusOutListener"),propertyDialogButtonBar, helper,eltDefaultTextBox.getSWTWidgetControl()); if (filepathConfig.getListeners() != null) { for (Listners listener : filepathConfig.getListeners()) { eltDefaultTextBox.attachListener(listener.getListener(), propertyDialogButtonBar, helper, eltDefaultTextBox.getSWTWidgetControl()); } } } } catch (Exception exception) { LOGGER.error("Exception occurred while attaching listeners to ELTFileWidget", exception); } /** *parameter resolution at dev phase */ Utils.INSTANCE.loadProperties(); cursor = container.getContainerControl().getDisplay().getSystemCursor(SWT.CURSOR_HAND); populateWidget(); }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.databasecomponents.InputAdditionalParametersWidget.java
/** * Propogates the schema from GridRow//from w ww . j a v a 2 s. c om */ protected List<String> getPropagatedSchema() { List<String> list = new ArrayList<String>(); Schema schema = (Schema) getComponent().getProperties().get(Constants.SCHEMA_PROPERTY_NAME); if (schema != null && schema.getGridRow() != null) { List<GridRow> gridRows = schema.getGridRow(); if (gridRows != null) { for (GridRow gridRow : gridRows) { if (StringUtils.equalsIgnoreCase(gridRow.getDataTypeValue(), "java.lang.Integer") || StringUtils.equalsIgnoreCase(gridRow.getDataTypeValue(), "java.lang.Long")) { list.add(gridRow.getFieldName()); } } } } return list; }
From source file:hydrograph.ui.propertywindow.ftp.FTPOperationConfigDialog.java
private void populateWidget() { for (Map.Entry<String, FTPAuthOperationDetails> map : authOperationSelectionMap.entrySet()) { authenticationModeCombo.setText(map.getKey()); FTPAuthOperationDetails authOperationDetails = map.getValue(); text1.setText(authOperationDetails.getField1()); text2.setText(authOperationDetails.getField2()); if (StringUtils.equalsIgnoreCase(protocol, Constants.AWS_S3)) { if (authOperationDetails.getField3() != null) { text3.setText(authOperationDetails.getField3()); }//from w w w. j a v a 2 s .c o m if (authOperationDetails.getField4() != null) { text4.setText(authOperationDetails.getField4()); } FTPWidgetUtility ftpWidgetUtility = new FTPWidgetUtility(); ftpWidgetUtility.removeModifyListener(text3, propertyDialogButtonBar, cursor, text3ControlDecoration); } if (map.getKey().contains(Constants.PUT_FILE)) { overwriteCombo.select(0); overWriteLabel.setEnabled(false); overwriteCombo.setEnabled(false); } if (StringUtils.equalsIgnoreCase(authOperationDetails.getField5(), Messages.OVERWRITE_IF_EXISTS)) { overwriteCombo.select(0); } else if (StringUtils.equalsIgnoreCase(authOperationDetails.getField5(), Messages.FAIL_IF_EXISTS)) { overwriteCombo.select(1); } } }
From source file:com.dgq.utils.Struts2Utils.java
private static HttpServletResponse initResponseHeaderServlet(final String contentType, HttpServletResponse response, final String... headers) { // ?headers?/*from w w w . j a v a2s. c om*/ String encoding = DEFAULT_ENCODING; boolean noCache = DEFAULT_NOCACHE; for (String header : headers) { String headerName = StringUtils.substringBefore(header, ":"); String headerValue = StringUtils.substringAfter(header, ":"); if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) { encoding = headerValue; } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) { noCache = Boolean.parseBoolean(headerValue); } else { throw new IllegalArgumentException(headerName + "??header"); } } // headers? String fullContentType = contentType + ";charset=" + encoding; response.setContentType(fullContentType); if (noCache) { ServletUtils.setNoCacheHeader(response); } return response; }