Example usage for java.util.regex Pattern matches

List of usage examples for java.util.regex Pattern matches

Introduction

In this page you can find the example usage for java.util.regex Pattern matches.

Prototype

public static boolean matches(String regex, CharSequence input) 

Source Link

Document

Compiles the given regular expression and attempts to match the given input against it.

Usage

From source file:cz.cuni.mff.ufal.curation.ItemMetadataQAChecker.java

private void validate_dc_type(Item item, DCValue[] dcs, StringBuilder results) throws CurateException {
    DCValue[] dcs_type = item.getMetadata("dc.type");
    // no metadata?
    if (dcs_type == null || dcs_type.length == 0) {
        throw new CurateException(String.format("Item [%s] does not dc.type metadata", get_handle(item)),
                Curator.CURATE_FAIL);// w ww  .  j av a 2  s  .c  om
    }

    // check array is not null or length > 0
    for (DCValue dcsEntry : dcs_type) {
        String typeVal = dcsEntry.value.trim();

        // check if original and trimmed versions match
        if (!typeVal.equals(dcsEntry.value)) {
            throw new CurateException("leading or trailing spaces", Curator.CURATE_FAIL);
        }

        // check if the dc.type field is empty
        if (Pattern.matches("^\\s*$", typeVal)) {
            throw new CurateException("empty value", Curator.CURATE_FAIL);
        }

        // check if the value is valid
        if (!DCTYPE_VALUES_SET.contains(typeVal)) {
            throw new CurateException("invalid type" + "(" + typeVal + ")", Curator.CURATE_FAIL);
        }
    }
}

From source file:com.smanempat.controller.ControllerClassification.java

public String[] processMining(JTextField textNumberOfK, JTable tablePreview, JLabel labelPesanError,
        JTable tableResult, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan,
        JYearChooser jYearChooser1, JYearChooser jYearChooser2, JTabbedPane jTabbedPane1) {

    String numberValidate = textNumberOfK.getText();
    ModelClassification modelClassification = new ModelClassification();
    int rowCountModel = modelClassification.getRowCount();
    int rowCountData = tablePreview.getRowCount();
    System.out.println("Row Count Data : " + rowCountData);
    System.out.println("Row Count Model : " + rowCountModel);
    String[] knnValue = null;//www.  j a v  a 2  s.  c  o  m

    /*Validasi Nilai Number of Nearest Neighbor*/
    if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) {
        labelPesanError.setText("Number of Nearest Neighbor tidak valid");
        JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        textNumberOfK.requestFocus();
    } else if (numberValidate.isEmpty()) {
        JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong");
        textNumberOfK.requestFocus();
    } else if (Integer.parseInt(numberValidate) >= rowCountModel) {
        labelPesanError.setText("Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + "");
        JOptionPane.showMessageDialog(null,
                "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error",
                JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
        textNumberOfK.requestFocus();
    } else {
        int confirm = 0;
        confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
        if (confirm == JOptionPane.OK_OPTION) {
            int kValue = Integer.parseInt(textNumberOfK.getText());
            String[][] modelValue = getModelValue(rowCountModel);
            double[][] dataValue = getDataValue(rowCountData, tablePreview);
            knnValue = getKNNValue(rowCountData, rowCountModel, modelValue, dataValue, kValue);
            showClassificationResult(tableResult, tablePreview, knnValue, rowCountData, labelSiswaIPA,
                    labelSiswaIPS, labelKeterangan, jYearChooser1, jYearChooser2, kValue);
            jTabbedPane1.setSelectedIndex(1);
        }

    }
    return knnValue;
}

From source file:com.ikon.module.db.DbDocumentModule.java

/**
 * Used when big files and FileUpload//from   w w w . j a  v  a2 s  .  com
 */
public Document create(String token, Document doc, InputStream is, long size, String userId,
        Ref<FileUploadResponse> fuResponse)
        throws UnsupportedMimeTypeException, FileSizeExceededException, UserQuotaExceededException,
        VirusDetectedException, ItemExistsException, PathNotFoundException, AccessDeniedException,
        RepositoryException, IOException, DatabaseException, ExtensionException, AutomationException {
    log.debug("create({}, {}, {}, {}, {}, {})", new Object[] { token, doc, is, size, userId, fuResponse });
    Document newDocument = null;
    Authentication auth = null, oldAuth = null;

    if (Config.SYSTEM_READONLY) {
        throw new AccessDeniedException("System is in read-only mode");
    }

    String parentPath = PathUtils.getParent(doc.getPath());
    String name = PathUtils.getName(doc.getPath());

    // Add to KEA - must have the same extension
    int idx = name.lastIndexOf('.');
    String fileExtension = idx > 0 ? name.substring(idx) : ".tmp";
    File tmp = File.createTempFile("okm", fileExtension);

    try {
        if (token == null) {
            auth = PrincipalUtils.getAuthentication();
        } else {
            oldAuth = PrincipalUtils.getAuthentication();
            auth = PrincipalUtils.getAuthenticationByToken(token);
        }

        if (Config.MAX_FILE_SIZE > 0 && size > Config.MAX_FILE_SIZE) {
            log.error("Uploaded file size: {} ({}), Max file size: {} ({})",
                    new Object[] { FormatUtil.formatSize(size), size,
                            FormatUtil.formatSize(Config.MAX_FILE_SIZE), Config.MAX_FILE_SIZE });
            String usr = userId == null ? auth.getName() : userId;
            UserActivity.log(usr, "ERROR_FILE_SIZE_EXCEEDED", null, doc.getPath(), Long.toString(size));
            throw new FileSizeExceededException(Long.toString(size));
        }

        // Escape dangerous chars in name
        name = PathUtils.escape(name);

        if (!name.isEmpty()) {
            doc.setPath(parentPath + "/" + name);

            // Check file restrictions
            String mimeType = MimeTypeConfig.mimeTypes.getContentType(name.toLowerCase());
            doc.setMimeType(mimeType);

            if (Config.RESTRICT_FILE_MIME && MimeTypeDAO.findByName(mimeType) == null) {
                String usr = userId == null ? auth.getName() : userId;
                UserActivity.log(usr, "ERROR_UNSUPPORTED_MIME_TYPE", null, doc.getPath(), mimeType);
                throw new UnsupportedMimeTypeException(mimeType);
            }

            // Restrict for extension
            if (!Config.RESTRICT_FILE_NAME.isEmpty()) {
                StringTokenizer st = new StringTokenizer(Config.RESTRICT_FILE_NAME, Config.LIST_SEPARATOR);

                while (st.hasMoreTokens()) {
                    String wc = st.nextToken().trim();
                    String re = ConfigUtils.wildcard2regexp(wc);

                    if (Pattern.matches(re, name)) {
                        String usr = userId == null ? auth.getName() : userId;
                        UserActivity.log(usr, "ERROR_UNSUPPORTED_MIME_TYPE", null, doc.getPath(), mimeType);
                        throw new UnsupportedMimeTypeException(mimeType);
                    }
                }
            }

            // Manage temporary files
            byte[] buff = new byte[4 * 1024];
            FileOutputStream fos = new FileOutputStream(tmp);
            int read;

            while ((read = is.read(buff)) != -1) {
                fos.write(buff, 0, read);
            }

            fos.flush();
            fos.close();
            is.close();
            is = new FileInputStream(tmp);

            if (!Config.SYSTEM_ANTIVIR.equals("")) {
                String info = VirusDetection.detect(tmp);

                if (info != null) {
                    String usr = userId == null ? auth.getName() : userId;
                    UserActivity.log(usr, "ERROR_VIRUS_DETECTED", null, doc.getPath(), info);
                    throw new VirusDetectedException(info);
                }
            }

            String parentUuid = NodeBaseDAO.getInstance().getUuidFromPath(parentPath);
            NodeBase parentNode = NodeBaseDAO.getInstance().findByPk(parentUuid);

            // AUTOMATION - PRE
            // INSIDE BaseDocumentModule.create

            // Create node
            Set<String> keywords = doc.getKeywords() != null ? doc.getKeywords() : new HashSet<String>();
            NodeDocument docNode = BaseDocumentModule.create(auth.getName(), parentPath, parentNode, name,
                    doc.getTitle(), doc.getCreated(), mimeType, is, size, keywords, new HashSet<String>(),
                    fuResponse);

            // AUTOMATION - POST
            // INSIDE BaseDocumentModule.create

            // Set returned folder properties
            newDocument = BaseDocumentModule.getProperties(auth.getName(), docNode);

            // Setting wizard properties
            // INSIDE BaseDocumentModule.create

            if (fuResponse.get() == null) {
                fuResponse.set(new FileUploadResponse());
            }

            fuResponse.get().setHasAutomation(AutomationManager.getInstance().hasAutomation());

            if (userId == null) {
                // Check subscriptions
                BaseNotificationModule.checkSubscriptions(docNode, auth.getName(), "CREATE_DOCUMENT", null);

                // Check scripting
                // BaseScriptingModule.checkScripts(session, parentNode, documentNode, "CREATE_DOCUMENT");

                // Activity log
                UserActivity.log(auth.getName(), "CREATE_DOCUMENT", docNode.getUuid(), doc.getPath(),
                        mimeType + ", " + size);
            } else {
                // Check subscriptions
                BaseNotificationModule.checkSubscriptions(docNode, userId, "CREATE_MAIL_ATTACHMENT", null);

                // Check scripting
                // BaseScriptingModule.checkScripts(session, parentNode, documentNode, "CREATE_MAIL_ATTACHMENT");

                // Activity log
                UserActivity.log(userId, "CREATE_MAIL_ATTACHMENT", docNode.getUuid(), doc.getPath(),
                        mimeType + ", " + size);
            }
        } else {
            throw new RepositoryException("Invalid document name");
        }
    } finally {
        IOUtils.closeQuietly(is);
        org.apache.commons.io.FileUtils.deleteQuietly(tmp);

        if (token != null) {
            PrincipalUtils.setAuthentication(oldAuth);
        }
    }

    log.debug("create: {}", newDocument);
    return newDocument;
}

From source file:org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper.java

/**
 * Scans the given stack for upgrade packages which can be applied to update the cluster to given repository version.
 *
 * @param stackName stack name//from   w ww  . ja  v a  2 s .c  o  m
 * @param stackVersion stack version
 * @param repositoryVersion target repository version
 * @return upgrade pack name
 * @throws AmbariException if no upgrade packs suit the requirements
 */
public String getUpgradePackageName(String stackName, String stackVersion, String repositoryVersion)
        throws AmbariException {
    final Map<String, UpgradePack> upgradePacks = ambariMetaInfo.getUpgradePacks(stackName, stackVersion);
    for (Entry<String, UpgradePack> upgradePackEntry : upgradePacks.entrySet()) {
        final UpgradePack upgradePack = upgradePackEntry.getValue();
        final String upgradePackName = upgradePackEntry.getKey();
        // check that upgrade pack has <target> node
        if (StringUtils.isBlank(upgradePack.getTarget())) {
            LOG.error("Upgrade pack " + upgradePackName + " is corrupted, it should contain <target> node");
            continue;
        }

        // check that upgrade pack can be applied to selected stack
        // converting 2.2.*.* -> 2\.2(\.\d+)?(\.\d+)?(-\d+)?
        String regexPattern = upgradePack.getTarget();
        regexPattern = regexPattern.replaceAll("\\.", "\\\\."); // . -> \.
        regexPattern = regexPattern.replaceAll("\\\\\\.\\*", "(\\\\\\.\\\\d+)?"); // \.* -> (\.\d+)?
        regexPattern = regexPattern.concat("(-\\d+)?");
        if (Pattern.matches(regexPattern, repositoryVersion)) {
            return upgradePackName;
        }
    }
    throw new AmbariException(
            "There were no suitable upgrade packs for stack " + stackName + " " + stackVersion);
}

From source file:com.morninz.ninepinview.widget.NinePINView.java

/**
 * Set correct PIN String used to check whether the drawn shape is correct
 * or not.//from   w ww .ja  v a2  s. c  o  m
 * <p>
 * You must call this method before begin draw.
 * </p>
 * 
 * @param pin
 *            the correct PIN String. 0 is index of the first point.
 *            <b>eg:</b> "012" PIN String represent that the shape connect
 *            one, two and three points in first row.
 * @throws IllegalArgumentException
 *             if parameter <b>pin</b> contains characters besides '0'-'8'
 *             or same charaters.
 */
public void setCorrectPIN(String pin) {
    boolean repeat = false;
    for (int i = 0; i < pin.length() - 1; i++) {
        for (int j = i + 1; j < pin.length(); j++) {
            if (pin.charAt(i) == pin.charAt(j)) {
                repeat = true;
                break;
            }
        }
    }
    boolean match = Pattern.matches("[0-8]{1,9}", pin);
    if (repeat || !match) {
        throw new IllegalArgumentException("The pin must only contains characters '0'-'8' and not be repeat.");
    }
    mCorrectPIN = pin;
}

From source file:com.adito.jdbc.JDBCSystemDatabase.java

/**
 * @param toCheck/*from  w ww.  j av  a2s .  co  m*/
 * @param ipRestrictionAddress
 * @return boolean
 */
private static boolean isIpAddressWildcardMatch(String toCheck, String ipRestrictionAddress) {
    String regex = Util.parseSimplePatternToRegExp(ipRestrictionAddress);
    return Pattern.matches(regex, toCheck);
}

From source file:com.microsoft.azure.management.resources.DeploymentOperationsImpl.java

/**
* Begin deleting deployment.To determine whether the operation has finished
* processing the request, call GetLongRunningOperationStatus.
*
* @param resourceGroupName Required. The name of the resource group. The
* name is case insensitive.//from w  w  w  .j  av a  2 s  .c o  m
* @param deploymentName Required. The name of the deployment to be deleted.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return A standard service response for long running operations.
*/
@Override
public LongRunningOperationResponse beginDeleting(String resourceGroupName, String deploymentName)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (resourceGroupName != null && resourceGroupName.length() > 1000) {
        throw new IllegalArgumentException("resourceGroupName");
    }
    if (Pattern.matches("^[-\\w\\._]+$", resourceGroupName) == false) {
        throw new IllegalArgumentException("resourceGroupName");
    }
    if (deploymentName == null) {
        throw new NullPointerException("deploymentName");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("resourceGroupName", resourceGroupName);
        tracingParameters.put("deploymentName", deploymentName);
        CloudTracing.enter(invocationId, this, "beginDeletingAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/subscriptions/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/resourcegroups/";
    url = url + URLEncoder.encode(resourceGroupName, "UTF-8");
    url = url + "/deployments/";
    url = url + URLEncoder.encode(deploymentName, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2014-04-01-preview");
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    CustomHttpDelete httpRequest = new CustomHttpDelete(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json; charset=utf-8");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_ACCEPTED && statusCode != HttpStatus.SC_NO_CONTENT) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        LongRunningOperationResponse result = null;
        // Deserialize Response
        result = new LongRunningOperationResponse();
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Location").length > 0) {
            result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue()));
        }
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }
        if (statusCode == HttpStatus.SC_CONFLICT) {
            result.setStatus(OperationStatus.Failed);
        }
        if (statusCode == HttpStatus.SC_ACCEPTED) {
            result.setStatus(OperationStatus.InProgress);
        }
        if (statusCode == HttpStatus.SC_NO_CONTENT) {
            result.setStatus(OperationStatus.Succeeded);
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:cx.fbn.nevernote.sql.REnSearch.java

private boolean matchListAny(List<String> list, String title) {
    if (list.size() == 0)
        return true;
    boolean negative = false;
    boolean found = false;
    for (int i = 0; i < list.size(); i++) {
        int pos = list.get(i).indexOf(":");
        negative = false;/*from w w  w.  j  av  a 2s . c  om*/
        if (list.get(i).startsWith("-"))
            negative = true;
        String filterName = cleanupWord(list.get(i).substring(pos + 1));
        filterName = filterName.replace("*", ".*"); // setup for regular expression pattern match
        boolean matches = Pattern.matches(filterName.toLowerCase(), title.toLowerCase());
        if (matches)
            found = true;
    }
    if (negative)
        return !found;
    else
        return found;
}

From source file:gda.jython.translator.GeneralTranslator.java

/**
 * inside pairs of brackets replaces spaces with commas. So when the command is later split by spaces, each bracket
 * group looks like a single element in the returned array.
 * /*from  w  ww  .j  av a2  s.  co  m*/
 * @param original_command
 *            String
 * @return String
 */

protected static String tidyBrackets(String original_command) {

    // return commands which are too short to tidy
    if (original_command.length() <= 1) {
        return original_command;
    }

    // return commands which look like Python list comprehensions
    if (Pattern.matches(".*?\\[.*?for.*?in.*?\\].*?", original_command)) {
        return original_command;
    }

    String command = original_command;
    String commasAdded = "";
    try {
        int bracketDepth = 0;
        // int braceDepth = 0; // too difficult to distinguish between operators, functions and variables inside()'s
        // so do not auto add commas within these
        boolean insideQuote = false;
        boolean insideSingleQuote = false;
        boolean insideDoubleQuote = false;
        for (int i = 0; i < command.length(); i++) {
            String thisElement = command.substring(i, i + 1);
            // record if a pair of []s opens
            if (thisElement.equals("[")) {
                bracketDepth++;
                commasAdded += thisElement;
            }
            // record if a pair of []s closes
            else if (thisElement.equals("]")) {
                bracketDepth--;
                commasAdded += thisElement;
            }
            // record if a pair of "s opens or closes
            else if (thisElement.equals("\"")) {
                if (insideDoubleQuote) {
                    insideDoubleQuote = false;
                } else {
                    insideDoubleQuote = true;
                }
                commasAdded += thisElement;
            }
            // record if a pair of `s opens or closes
            else if (thisElement.equals("`")) {
                if (insideQuote) {
                    insideQuote = false;
                } else {
                    insideQuote = true;
                }
                commasAdded += thisElement;
            }
            // record if a pair of 's opens or closes
            else if (thisElement.equals("'")) {
                if (insideSingleQuote) {
                    insideSingleQuote = false;
                } else {
                    insideSingleQuote = true;
                }
                commasAdded += thisElement;
            }
            // else if in []s but not in a quote and its a space
            else if (!(insideQuote || insideSingleQuote || insideDoubleQuote)
                    && (/* braceDepth >= 1 || */bracketDepth >= 1) && thisElement.equals(" ")) {

                // if space is between ] and [, add a comma
                if (previousPart(command, i) == ']' && nextPart(command, i) == '[') {
                    commasAdded += ",";
                }

                // ignoring spaces, if neither the previous nor next non-whitespace charactor is a comma or symbol,
                // then add a comma
                else if (!isNextPartASymbol(command, i) && !isPreviousPartASymbol(command, i)) {
                    commasAdded += ",";
                } else {
                    commasAdded += " ";
                }
            }
            // else simply add the next piece of the string
            else {
                commasAdded += thisElement;
            }
        }
    } catch (Exception ex) {
        return original_command;
    }

    return commasAdded;

}

From source file:org.eclipse.skalli.core.destination.DestinationComponent.java

private void setProxy(HttpClient client, URL url) {
    if (isLocalDomain(url)) {
        return;//from w ww. j  a va2  s  .c o m
    }

    String protocol = url.getProtocol();

    // use the system properties as default
    String defaultProxyHost = System.getProperty(HTTP_PROXY_HOST);
    String defaultProxyPort = System.getProperty(HTTP_PROXY_PORT);
    String proxyHost = HTTPS.equals(protocol) ? System.getProperty(HTTPS_PROXY_HOST, defaultProxyHost)
            : defaultProxyHost;
    int proxyPort = NumberUtils.toInt(
            HTTPS.equals(protocol) ? System.getProperty(HTTPS_PROXY_PORT, defaultProxyPort) : defaultProxyPort);
    String nonProxyHosts = System.getProperty(NON_PROXY_HOSTS, StringUtils.EMPTY);

    // allow to overwrite the system properties with configuration /api/config/proxy
    if (configService != null) {
        ProxyConfig proxyConfig = configService.readConfiguration(ProxyConfig.class);
        if (proxyConfig != null) {
            String defaultConfigProxyHost = proxyConfig.getHost();
            String defaultConfigProxyPort = proxyConfig.getPort();
            String configProxyHost = HTTPS.equals(protocol) ? proxyConfig.getHostSSL() : defaultConfigProxyHost;
            int configProxyPort = NumberUtils
                    .toInt(HTTPS.equals(protocol) ? proxyConfig.getPortSSL() : defaultConfigProxyPort);
            if (StringUtils.isNotBlank(configProxyHost) && configProxyPort > 0) {
                proxyHost = configProxyHost;
                proxyPort = configProxyPort;
            }
            String configNonProxyHosts = proxyConfig.getNonProxyHosts();
            if (StringUtils.isNotBlank(configNonProxyHosts)) {
                nonProxyHosts = configNonProxyHosts;
            }
        }
    }

    // sanitize the nonProxyHost pattern (remove whitespace etc.)
    if (StringUtils.isNotBlank(nonProxyHosts)) {
        nonProxyHosts = StringUtils.replaceEach(StringUtils.deleteWhitespace(nonProxyHosts), RE_SEARCH,
                RE_REPLACE);
    }

    if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0 && !Pattern.matches(nonProxyHosts, url.getHost())) {
        HttpHost proxy = new HttpHost(proxyHost, proxyPort, HTTP);
        client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }
}