Example usage for java.lang Character isLowerCase

List of usage examples for java.lang Character isLowerCase

Introduction

In this page you can find the example usage for java.lang Character isLowerCase.

Prototype

public static boolean isLowerCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is a lowercase character.

Usage

From source file:org.jrman.parser.Parser.java

private KeywordParser getKeyWordParser(String keyword) throws Exception {
    KeywordParser kp = (KeywordParser) keywordParsers.get(keyword);
    if (kp == null)
        kp = (KeywordParser) keywordParsers.get(keyword.toLowerCase());
    if (kp == null) {
        char c = keyword.charAt(0);
        if (Character.isLowerCase(c))
            keyword = Character.toUpperCase(c) + keyword.substring(1);
        kp = (KeywordParser) Class.forName(KEYWORD_PREFIX + keyword).newInstance();
        kp.setParser(this);
        keywordParsers.put(keyword, kp);
        keywordParsers.put(keyword.toLowerCase(), kp);
    }// w  w w.j  a  va2s  .co m
    return kp;
}

From source file:com.miz.functions.MizLib.java

/**
 * Adds spaces between capital characters.
 * @param s (input String)/*ww  w . j  ava2  s.c  om*/
 * @return Input string with spaces between capital characters.
 */
public static String addSpaceByCapital(String s) {
    if (TextUtils.isEmpty(s))
        return "";

    StringBuilder result = new StringBuilder();
    char[] chars = s.toCharArray();
    for (int i = 0; i < chars.length; i++)
        if (chars.length > (i + 1))
            if (Character.isUpperCase(chars[i])
                    && (Character.isLowerCase(chars[i + 1]) && !Character.isSpaceChar(chars[i + 1])))
                result.append(" ").append(chars[i]);
            else
                result.append(chars[i]);
        else
            result.append(chars[i]);
    return result.toString().trim();
}

From source file:com.microsoft.azure.management.storage.StorageAccountOperationsImpl.java

/**
* Asynchronously creates a new storage account with the specified
* parameters. Existing accounts cannot be updated with this API and should
* instead use the Update Storage Account API. If an account is already
* created and subsequent PUT request is issued with exact same set of
* properties, then HTTP 200 would be returned.
*
* @param resourceGroupName Required. The name of the resource group within
* the user's subscription.//from  ww w.  j  a  v a 2 s  .  c o m
* @param accountName Required. The name of the storage account within the
* specified resource group. Storage account names must be between 3 and 24
* characters in length and use numbers and lower-case letters only.
* @param parameters Required. The parameters to provide for the created
* account.
* @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.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return The Create storage account operation response.
*/
@Override
public StorageAccountCreateResponse beginCreate(String resourceGroupName, String accountName,
        StorageAccountCreateParameters parameters) throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (accountName == null) {
        throw new NullPointerException("accountName");
    }
    if (accountName.length() < 3) {
        throw new IllegalArgumentException("accountName");
    }
    if (accountName.length() > 24) {
        throw new IllegalArgumentException("accountName");
    }
    for (char accountNameChar : accountName.toCharArray()) {
        if (Character.isLowerCase(accountNameChar) == false && Character.isDigit(accountNameChar) == false) {
            throw new IllegalArgumentException("accountName");
        }
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getAccountType() == null) {
        throw new NullPointerException("parameters.AccountType");
    }
    if (parameters.getLocation() == null) {
        throw new NullPointerException("parameters.Location");
    }

    // 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("accountName", accountName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginCreateAsync", 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 + "/providers/Microsoft.Storage/storageAccounts/";
    url = url + URLEncoder.encode(accountName, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-06-15");
    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
    HttpPut httpRequest = new HttpPut(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json");
    httpRequest.setHeader("x-ms-client-request-id", UUID.randomUUID().toString());

    // Serialize Request
    String requestContent = null;
    JsonNode requestDoc = null;

    ObjectMapper objectMapper = new ObjectMapper();
    ObjectNode storageAccountCreateParametersJsonValue = objectMapper.createObjectNode();
    requestDoc = storageAccountCreateParametersJsonValue;

    ((ObjectNode) storageAccountCreateParametersJsonValue).put("location", parameters.getLocation());

    if (parameters.getTags() != null) {
        if (parameters.getTags() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getTags()).isInitialized()) {
            ObjectNode tagsDictionary = objectMapper.createObjectNode();
            for (Map.Entry<String, String> entry : parameters.getTags().entrySet()) {
                String tagsKey = entry.getKey();
                String tagsValue = entry.getValue();
                ((ObjectNode) tagsDictionary).put(tagsKey, tagsValue);
            }
            ((ObjectNode) storageAccountCreateParametersJsonValue).put("tags", tagsDictionary);
        }
    }

    ObjectNode propertiesValue = objectMapper.createObjectNode();
    ((ObjectNode) storageAccountCreateParametersJsonValue).put("properties", propertiesValue);

    ((ObjectNode) propertiesValue).put("accountType",
            StorageManagementClientImpl.accountTypeToString(parameters.getAccountType()));

    StringWriter stringWriter = new StringWriter();
    objectMapper.writeValue(stringWriter, requestDoc);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/json");

    // 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_OK && statusCode != HttpStatus.SC_ACCEPTED) {
            ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        StorageAccountCreateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new StorageAccountCreateResponse();
            JsonNode responseDoc = null;
            String responseDocContent = IOUtils.toString(responseContent);
            if (responseDocContent == null == false && responseDocContent.length() > 0) {
                responseDoc = objectMapper.readTree(responseDocContent);
            }

            if (responseDoc != null && responseDoc instanceof NullNode == false) {
                StorageAccount storageAccountInstance = new StorageAccount();
                result.setStorageAccount(storageAccountInstance);

                JsonNode idValue = responseDoc.get("id");
                if (idValue != null && idValue instanceof NullNode == false) {
                    String idInstance;
                    idInstance = idValue.getTextValue();
                    storageAccountInstance.setId(idInstance);
                }

                JsonNode nameValue = responseDoc.get("name");
                if (nameValue != null && nameValue instanceof NullNode == false) {
                    String nameInstance;
                    nameInstance = nameValue.getTextValue();
                    storageAccountInstance.setName(nameInstance);
                }

                JsonNode typeValue = responseDoc.get("type");
                if (typeValue != null && typeValue instanceof NullNode == false) {
                    String typeInstance;
                    typeInstance = typeValue.getTextValue();
                    storageAccountInstance.setType(typeInstance);
                }

                JsonNode locationValue = responseDoc.get("location");
                if (locationValue != null && locationValue instanceof NullNode == false) {
                    String locationInstance;
                    locationInstance = locationValue.getTextValue();
                    storageAccountInstance.setLocation(locationInstance);
                }

                JsonNode tagsSequenceElement = ((JsonNode) responseDoc.get("tags"));
                if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) {
                    Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields();
                    while (itr.hasNext()) {
                        Map.Entry<String, JsonNode> property = itr.next();
                        String tagsKey2 = property.getKey();
                        String tagsValue2 = property.getValue().getTextValue();
                        storageAccountInstance.getTags().put(tagsKey2, tagsValue2);
                    }
                }

                JsonNode propertiesValue2 = responseDoc.get("properties");
                if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) {
                    JsonNode provisioningStateValue = propertiesValue2.get("provisioningState");
                    if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) {
                        ProvisioningState provisioningStateInstance;
                        provisioningStateInstance = EnumUtility.fromString(ProvisioningState.class,
                                provisioningStateValue.getTextValue());
                        storageAccountInstance.setProvisioningState(provisioningStateInstance);
                    }

                    JsonNode accountTypeValue = propertiesValue2.get("accountType");
                    if (accountTypeValue != null && accountTypeValue instanceof NullNode == false) {
                        AccountType accountTypeInstance;
                        accountTypeInstance = StorageManagementClientImpl
                                .parseAccountType(accountTypeValue.getTextValue());
                        storageAccountInstance.setAccountType(accountTypeInstance);
                    }

                    JsonNode primaryEndpointsValue = propertiesValue2.get("primaryEndpoints");
                    if (primaryEndpointsValue != null && primaryEndpointsValue instanceof NullNode == false) {
                        Endpoints primaryEndpointsInstance = new Endpoints();
                        storageAccountInstance.setPrimaryEndpoints(primaryEndpointsInstance);

                        JsonNode blobValue = primaryEndpointsValue.get("blob");
                        if (blobValue != null && blobValue instanceof NullNode == false) {
                            URI blobInstance;
                            blobInstance = new URI(blobValue.getTextValue());
                            primaryEndpointsInstance.setBlob(blobInstance);
                        }

                        JsonNode queueValue = primaryEndpointsValue.get("queue");
                        if (queueValue != null && queueValue instanceof NullNode == false) {
                            URI queueInstance;
                            queueInstance = new URI(queueValue.getTextValue());
                            primaryEndpointsInstance.setQueue(queueInstance);
                        }

                        JsonNode tableValue = primaryEndpointsValue.get("table");
                        if (tableValue != null && tableValue instanceof NullNode == false) {
                            URI tableInstance;
                            tableInstance = new URI(tableValue.getTextValue());
                            primaryEndpointsInstance.setTable(tableInstance);
                        }

                        JsonNode fileValue = primaryEndpointsValue.get("file");
                        if (fileValue != null && fileValue instanceof NullNode == false) {
                            URI fileInstance;
                            fileInstance = new URI(fileValue.getTextValue());
                            primaryEndpointsInstance.setFile(fileInstance);
                        }
                    }

                    JsonNode primaryLocationValue = propertiesValue2.get("primaryLocation");
                    if (primaryLocationValue != null && primaryLocationValue instanceof NullNode == false) {
                        String primaryLocationInstance;
                        primaryLocationInstance = primaryLocationValue.getTextValue();
                        storageAccountInstance.setPrimaryLocation(primaryLocationInstance);
                    }

                    JsonNode statusOfPrimaryValue = propertiesValue2.get("statusOfPrimary");
                    if (statusOfPrimaryValue != null && statusOfPrimaryValue instanceof NullNode == false) {
                        AccountStatus statusOfPrimaryInstance;
                        statusOfPrimaryInstance = EnumUtility.fromString(AccountStatus.class,
                                statusOfPrimaryValue.getTextValue());
                        storageAccountInstance.setStatusOfPrimary(statusOfPrimaryInstance);
                    }

                    JsonNode lastGeoFailoverTimeValue = propertiesValue2.get("lastGeoFailoverTime");
                    if (lastGeoFailoverTimeValue != null
                            && lastGeoFailoverTimeValue instanceof NullNode == false) {
                        Calendar lastGeoFailoverTimeInstance;
                        lastGeoFailoverTimeInstance = DatatypeConverter
                                .parseDateTime(lastGeoFailoverTimeValue.getTextValue());
                        storageAccountInstance.setLastGeoFailoverTime(lastGeoFailoverTimeInstance);
                    }

                    JsonNode secondaryLocationValue = propertiesValue2.get("secondaryLocation");
                    if (secondaryLocationValue != null && secondaryLocationValue instanceof NullNode == false) {
                        String secondaryLocationInstance;
                        secondaryLocationInstance = secondaryLocationValue.getTextValue();
                        storageAccountInstance.setSecondaryLocation(secondaryLocationInstance);
                    }

                    JsonNode statusOfSecondaryValue = propertiesValue2.get("statusOfSecondary");
                    if (statusOfSecondaryValue != null && statusOfSecondaryValue instanceof NullNode == false) {
                        AccountStatus statusOfSecondaryInstance;
                        statusOfSecondaryInstance = EnumUtility.fromString(AccountStatus.class,
                                statusOfSecondaryValue.getTextValue());
                        storageAccountInstance.setStatusOfSecondary(statusOfSecondaryInstance);
                    }

                    JsonNode creationTimeValue = propertiesValue2.get("creationTime");
                    if (creationTimeValue != null && creationTimeValue instanceof NullNode == false) {
                        Calendar creationTimeInstance;
                        creationTimeInstance = DatatypeConverter
                                .parseDateTime(creationTimeValue.getTextValue());
                        storageAccountInstance.setCreationTime(creationTimeInstance);
                    }

                    JsonNode customDomainValue = propertiesValue2.get("customDomain");
                    if (customDomainValue != null && customDomainValue instanceof NullNode == false) {
                        CustomDomain customDomainInstance = new CustomDomain();
                        storageAccountInstance.setCustomDomain(customDomainInstance);

                        JsonNode nameValue2 = customDomainValue.get("name");
                        if (nameValue2 != null && nameValue2 instanceof NullNode == false) {
                            String nameInstance2;
                            nameInstance2 = nameValue2.getTextValue();
                            customDomainInstance.setName(nameInstance2);
                        }

                        JsonNode useSubDomainValue = customDomainValue.get("useSubDomain");
                        if (useSubDomainValue != null && useSubDomainValue instanceof NullNode == false) {
                            boolean useSubDomainInstance;
                            useSubDomainInstance = useSubDomainValue.getBooleanValue();
                            customDomainInstance.setUseSubDomain(useSubDomainInstance);
                        }
                    }

                    JsonNode secondaryEndpointsValue = propertiesValue2.get("secondaryEndpoints");
                    if (secondaryEndpointsValue != null
                            && secondaryEndpointsValue instanceof NullNode == false) {
                        Endpoints secondaryEndpointsInstance = new Endpoints();
                        storageAccountInstance.setSecondaryEndpoints(secondaryEndpointsInstance);

                        JsonNode blobValue2 = secondaryEndpointsValue.get("blob");
                        if (blobValue2 != null && blobValue2 instanceof NullNode == false) {
                            URI blobInstance2;
                            blobInstance2 = new URI(blobValue2.getTextValue());
                            secondaryEndpointsInstance.setBlob(blobInstance2);
                        }

                        JsonNode queueValue2 = secondaryEndpointsValue.get("queue");
                        if (queueValue2 != null && queueValue2 instanceof NullNode == false) {
                            URI queueInstance2;
                            queueInstance2 = new URI(queueValue2.getTextValue());
                            secondaryEndpointsInstance.setQueue(queueInstance2);
                        }

                        JsonNode tableValue2 = secondaryEndpointsValue.get("table");
                        if (tableValue2 != null && tableValue2 instanceof NullNode == false) {
                            URI tableInstance2;
                            tableInstance2 = new URI(tableValue2.getTextValue());
                            secondaryEndpointsInstance.setTable(tableInstance2);
                        }

                        JsonNode fileValue2 = secondaryEndpointsValue.get("file");
                        if (fileValue2 != null && fileValue2 instanceof NullNode == false) {
                            URI fileInstance2;
                            fileInstance2 = new URI(fileValue2.getTextValue());
                            secondaryEndpointsInstance.setFile(fileInstance2);
                        }
                    }
                }
            }

        }
        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 || statusCode == HttpStatus.SC_BAD_REQUEST) {
            result.setStatus(OperationStatus.Failed);
        }
        if (statusCode == HttpStatus.SC_OK) {
            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:de.micromata.genome.gwiki.auth.GWikiSimpleUserAuthorization.java

/**
 * //from www  .ja v  a 2  s .c  o  m
 * @param plainText
 * @return possible combinations of password.
 */
public static long getPasswortCombinations(String plainText) {
    if (plainText == null) {
        return 0;
    }
    int r = 0;
    boolean lc = false;
    boolean uc = false;
    boolean dig = false;
    boolean other = false;
    char[] chars = plainText.toCharArray();
    for (int c : chars) {
        if (Character.isLowerCase(c) == true) {
            if (lc == false) {
                r += 26;
            }
            lc = true;
        } else if (Character.isUpperCase(c) == true) {
            if (uc == false) {
                r += 26;
                uc = true;
            }
        } else if (Character.isDigit(c) == true) {
            if (dig == false) {
                r += 10;
                dig = true;
            }
        } else {
            if (other == false) {
                r += 50;
                other = true;
            }
        }
    }
    return (long) Math.pow(r, plainText.length());
}

From source file:de.hybris.platform.test.CaseInsensitiveStringMapTest.java

private List<String> shuffleCase(final List<String> keys) {
    final List<String> shuffled = new ArrayList<String>(keys.size());
    for (final String key : keys) {
        final char[] chars = key.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            final char character = chars[i];
            if (Character.isUpperCase(character)) {
                chars[i] = Character.toLowerCase(character);
            } else if (Character.isLowerCase(character)) {
                chars[i] = Character.toUpperCase(character);
            }//from  w w  w  .j  a v a  2 s  .  co  m
            shuffled.add(new String(chars));
        }
    }
    return shuffled;
}

From source file:org.webguitoolkit.ui.controls.form.popupselect.Popup.java

public static String splitByCapitalLetters(String string) {
    StringBuffer result = null;/*  www.j  a v  a2s. co  m*/
    if (string != null) {
        int l = string.length();
        for (int i = 0; i < l; i++) {
            if (i == 0) {
                // uppercase first letter in any case
                result = new StringBuffer();
                result.append(Character.toUpperCase(string.charAt(i)));
            } else {
                // insert blank if and lower case if
                // is upper case and previous is lower case orfollowing is lower case
                // this customerSAPNumber - > Customer SAP Number
                if (Character.isUpperCase(string.charAt(i)) && (Character.isLowerCase(string.charAt(i - 1))
                        || (((i + 1) < l) && Character.isLowerCase(string.charAt(i + 1))))) {
                    result.append(" " + Character.toLowerCase(string.charAt(i)));
                    // insert blank before number
                    // page123 -> Page 123
                } else if (Character.isDigit(string.charAt(i)) && !Character.isDigit(string.charAt(i - 1))) {
                    result.append(" " + string.charAt(i));
                } else {
                    result.append(string.charAt(i));
                }
            }
        }
        return result.toString();
    }
    return string;
}

From source file:org.languagetool.tagging.uk.CompoundTagger.java

@Nullable
private List<AnalyzedToken> doGuessCompoundTag(String word) {
    int dashIdx = word.lastIndexOf('-');
    if (dashIdx == word.length() - 1)
        return null;

    int firstDashIdx = word.indexOf('-');
    if (firstDashIdx == 0)
        return null;

    boolean startsWithDigit = Character.isDigit(word.charAt(0));

    if (!startsWithDigit && dashIdx != firstDashIdx) {
        int dashCount = StringUtils.countMatches(word, "-");

        if (dashCount >= 2 && dashIdx > firstDashIdx + 1) {
            List<AnalyzedToken> tokens = doGuessMultiHyphens(word, firstDashIdx, dashIdx);
            if (tokens != null)
                return tokens;
        }//from  w w  w.java  2s.com

        if (dashCount == 2 && dashIdx > firstDashIdx + 1) {
            return doGuessTwoHyphens(word, firstDashIdx, dashIdx);
        }

        return null;
    }

    String leftWord = word.substring(0, dashIdx);
    String rightWord = word.substring(dashIdx + 1);

    boolean dashPrefixMatch = dashPrefixes.contains(leftWord) || dashPrefixes.contains(leftWord.toLowerCase())
            || DASH_PREFIX_LAT_PATTERN.matcher(leftWord).matches();

    if (!dashPrefixMatch && (startsWithDigit || word.matches("[XLIV]+-.*"))) {
        return matchDigitCompound(word, leftWord, rightWord);
    }

    if (Character.isDigit(rightWord.charAt(0))) {
        return matchNumberedProperNoun(word, leftWord, rightWord);
    }

    // ..., ... ?? 
    //TODO:   : -?
    if (LEFT_INVALID.contains(leftWord.toLowerCase())) {
        List<TaggedWord> rightWdList = tagEitherCase(rightWord);

        rightWdList = PosTagHelper.filter2(rightWdList, Pattern.compile("(noun|adj)(?!.*pron).*"));

        if (rightWdList.isEmpty())
            return null;

        String lemma = leftWord + "-" + rightWdList.get(0).getLemma();
        String extraTag = StringTools.isCapitalizedWord(rightWord) ? "" : ":bad";
        rightWdList = PosTagHelper.addIfNotContains(rightWdList, extraTag, lemma);
        return ukrainianTagger.asAnalyzedTokenListForTaggedWordsInternal(word, rightWdList);
    }

    // wrong: -
    if (leftWord.equalsIgnoreCase("") && Character.isLowerCase(rightWord.charAt(0)))
        return null;

    List<TaggedWord> leftWdList = tagAsIsAndWithLowerCase(leftWord);

    // ?-, -, -, -, -

    if (rightPartsWithLeftTagMap.containsKey(rightWord) && !PosTagHelper.hasPosTagPart2(leftWdList, "abbr")) {

        if (leftWdList.isEmpty())
            return null;

        Pattern leftTagRegex = rightPartsWithLeftTagMap.get(rightWord);

        List<AnalyzedToken> leftAnalyzedTokens = ukrainianTagger
                .asAnalyzedTokenListForTaggedWordsInternal(leftWord, leftWdList);
        List<AnalyzedToken> newAnalyzedTokens = new ArrayList<>(leftAnalyzedTokens.size());

        // ignore -
        if (rightWord.equals("")
                && LemmaHelper.hasLemma(leftAnalyzedTokens, Arrays.asList("", "", "")))
            return null;

        for (AnalyzedToken analyzedToken : leftAnalyzedTokens) {
            String posTag = analyzedToken.getPOSTag();
            if (posTag != null && (leftWord.equals("") && posTag.contains("adv"))
                    || (leftTagRegex.matcher(posTag).matches())) {
                newAnalyzedTokens.add(new AnalyzedToken(word, posTag, analyzedToken.getLemma()));
            }
        }

        return newAnalyzedTokens.isEmpty() ? null : newAnalyzedTokens;
    }

    // -?, -?

    if (leftWord.equalsIgnoreCase("") && rightWord.endsWith("?")) {
        rightWord += "";
    }

    // ??-

    if (Character.isUpperCase(leftWord.charAt(0)) && LemmaHelper.CITY_AVENU.contains(rightWord)) {
        return PosTagHelper.generateTokensForNv(word, "f", ":prop");
    }

    List<TaggedWord> rightWdList = tagEitherCase(rightWord);

    if (rightWdList.isEmpty()) {

        if (word.startsWith("")) {
            // ?-?
            Matcher napivMatcher = Pattern.compile("(.+?)-(.+)").matcher(word);
            if (napivMatcher.matches()) {
                List<TaggedWord> napivLeftWdList = tagAsIsAndWithLowerCase(napivMatcher.group(1));
                List<TaggedWord> napivRightWdList = tagAsIsAndWithLowerCase(napivMatcher.group(2));

                List<AnalyzedToken> napivLeftAnalyzedTokens = ukrainianTagger
                        .asAnalyzedTokenListForTaggedWordsInternal(napivMatcher.group(1), napivLeftWdList);
                List<AnalyzedToken> napivRightAnalyzedTokens = ukrainianTagger
                        .asAnalyzedTokenListForTaggedWordsInternal(napivMatcher.group(2), napivRightWdList);

                List<AnalyzedToken> tagMatch = tagMatch(word, napivLeftAnalyzedTokens,
                        napivRightAnalyzedTokens);
                if (tagMatch != null) {
                    return tagMatch;
                }
            }
        }

        return null;
    }

    List<AnalyzedToken> rightAnalyzedTokens = ukrainianTagger
            .asAnalyzedTokenListForTaggedWordsInternal(rightWord, rightWdList);

    // -
    if (leftWord.length() == 1 && Character.isUpperCase(leftWord.charAt(0))
            && LemmaHelper.hasLemma(rightAnalyzedTokens, Arrays.asList(""))) {

        return generateTokensWithRighInflected(word, leftWord, rightAnalyzedTokens, IPOSTag.adj.getText());
    }

    if (leftWord.equalsIgnoreCase("")) {
        if (rightWord.endsWith("")) {
            return poAdvMatch(word, rightAnalyzedTokens, ADJ_TAG_FOR_PO_ADV_MIS);
        } else if (rightWord.endsWith("?")) {
            return poAdvMatch(word, rightAnalyzedTokens, ADJ_TAG_FOR_PO_ADV_NAZ);
        }
        return null;
    }

    // exclude: -, ?-

    List<AnalyzedToken> leftAnalyzedTokens = ukrainianTagger.asAnalyzedTokenListForTaggedWordsInternal(leftWord,
            leftWdList);

    if (PosTagHelper.hasPosTagPart(leftAnalyzedTokens, "&pron")
            && !PosTagHelper.hasPosTagPart(leftAnalyzedTokens, "numr"))
        return null;

    if (!leftWord.equalsIgnoreCase(rightWord)
            && PosTagHelper.hasPosTag(rightAnalyzedTokens, "(part|conj).*|.*?:&pron.*")
            && !(PosTagHelper.hasPosTag(leftAnalyzedTokens, "numr.*")
                    && PosTagHelper.hasPosTag(rightAnalyzedTokens, "numr.*")))
        return null;

    // -

    if (Character.isUpperCase(rightWord.charAt(0))) {
        if (word.startsWith("-")) {
            List<AnalyzedToken> newAnalyzedTokens = new ArrayList<>(rightAnalyzedTokens.size());

            for (AnalyzedToken rightAnalyzedToken : rightAnalyzedTokens) {
                String rightPosTag = rightAnalyzedToken.getPOSTag();

                if (rightPosTag == null)
                    continue;

                if (NOUN_SING_V_ROD_REGEX.matcher(rightPosTag).matches()) {
                    for (String vid : PosTagHelper.VIDMINKY_MAP.keySet()) {
                        if (vid.equals("v_kly"))
                            continue;
                        String posTag = rightPosTag.replace("v_rod", vid) + ":ua_1992";
                        newAnalyzedTokens.add(new AnalyzedToken(word, posTag, word));
                    }
                }
            }

            return newAnalyzedTokens;
        } else {
            // we don't want ?- but want ???-?
            if (StringTools.isCapitalizedWord(rightWord) || leftWord.endsWith("")
                    || PosTagHelper.hasPosTag(rightAnalyzedTokens, Pattern.compile("adj.*"))) {

                // tag ?/noun  ? adj
                List<TaggedWord> rightWdList2 = tagAsIsAndWithLowerCase(rightWord);
                List<AnalyzedToken> rightAnalyzedTokens2 = ukrainianTagger
                        .asAnalyzedTokenListForTaggedWordsInternal(rightWord, rightWdList2);

                List<AnalyzedToken> match = tryOWithAdj(word, leftWord, rightAnalyzedTokens2);
                if (match != null)
                    return match;
            }

            return null;
        }
    }

    // TODO: ua_2019
    // ?-?

    if (dashPrefixMatch) {
        List<AnalyzedToken> newTokens = new ArrayList<>();
        if (leftWord.length() == 1 && leftWord.matches("[a-zA-Z--]")) {
            List<AnalyzedToken> newTokensAdj = getNvPrefixLatWithAdjMatch(word, rightAnalyzedTokens, leftWord);
            if (newTokensAdj != null) {
                newTokens.addAll(newTokensAdj);
            }
        }
        List<AnalyzedToken> newTokensNoun = getNvPrefixNounMatch(word, rightAnalyzedTokens, leftWord);
        if (newTokensNoun != null) {
            newTokens.addAll(newTokensNoun);
        }
        return newTokens;
    }

    // don't allow: -, -, ?-

    // allow -!

    if (!PosTagHelper.hasPosTag(leftAnalyzedTokens, "intj.*")) {
        String noDashWord = word.replace("-", "");
        List<TaggedWord> noDashWordList = tagAsIsAndWithLowerCase(noDashWord);
        List<AnalyzedToken> noDashAnalyzedTokens = ukrainianTagger
                .asAnalyzedTokenListForTaggedWordsInternal(noDashWord, noDashWordList);

        if (!noDashAnalyzedTokens.isEmpty())
            return null;
    }

    // -, -, -

    if (!leftWdList.isEmpty() && leftWord.length() > 2) {
        List<AnalyzedToken> tagMatch = tagMatch(word, leftAnalyzedTokens, rightAnalyzedTokens);
        if (tagMatch != null) {
            return tagMatch;
        }
    }

    List<AnalyzedToken> match = tryOWithAdj(word, leftWord, rightAnalyzedTokens);
    if (match != null)
        return match;

    compoundDebugLogger.logUnknownCompound(word);

    return null;
}

From source file:org.codehaus.enunciate.modules.xfire.EnunciatedJAXWSOperationBinding.java

/**
 * Loads the property descriptors for the ordered properties of the specified class.
 *
 * @param wrapperClass The wrapper class.
 * @return The ordered property descriptors.
 *//* w ww  .j a v a  2  s  . co m*/
protected PropertyDescriptor[] loadOrderedProperties(Class wrapperClass) throws XFireFault {
    XmlType typeInfo = (XmlType) wrapperClass.getAnnotation(XmlType.class);
    if ((typeInfo == null) || (typeInfo.propOrder() == null)
            || ((typeInfo.propOrder().length == 1) && "".equals(typeInfo.propOrder()[0]))) {
        throw new XFireFault(
                "Unable use use " + wrapperClass.getName() + " as a wrapper class: no propOrder specified.",
                XFireFault.RECEIVER);
    }

    String[] propOrder = typeInfo.propOrder();
    BeanInfo beanInfo;
    try {
        beanInfo = Introspector.getBeanInfo(wrapperClass, Object.class);
    } catch (IntrospectionException e) {
        throw new XFireFault("Unable to introspect " + wrapperClass.getName(), e, XFireFault.RECEIVER);
    }

    PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
    PropertyDescriptor[] props = new PropertyDescriptor[propOrder.length];
    RESPONSE_PROPERTY_LOOP: for (int i = 0; i < propOrder.length; i++) {
        String property = propOrder[i];
        if ((property.length() > 1) && (!Character.isLowerCase(property.charAt(1)))) {
            //if the second letter is uppercase, javabean spec says the first character of the property is also to be kept uppercase.
            property = capitalize(property);
        }

        for (PropertyDescriptor descriptor : pds) {
            if (descriptor.getName().equals(property)) {
                props[i] = descriptor;
                continue RESPONSE_PROPERTY_LOOP;
            }
        }

        throw new XFireFault("Unknown property " + property + " on wrapper " + wrapperClass.getName(),
                XFireFault.RECEIVER);
    }

    return props;
}

From source file:org.wso2.carbon.governance.generic.ui.utils.GenericUtil.java

private static String convertName(String[] nameParts) {
    String convertedName = null;/*ww w  . j  av  a2s . c o m*/
    //  making widget name camel case

    for (String namePart : nameParts) {
        int i;
        for (i = 0; i < namePart.length(); i++) {
            char c = namePart.charAt(i);
            if (!Character.isLetter(c) || Character.isLowerCase(c)) {
                break;
            }
        }
        if (namePart.equals(nameParts[0])) {
            namePart = namePart.substring(0, i).toLowerCase() + namePart.substring(i);
        }
        if (convertedName == null) {
            convertedName = namePart;
        } else {
            convertedName += namePart;
        }
    }
    return convertedName;
}

From source file:org.languagetool.rules.de.VerbAgreementRule.java

private List<RuleMatch> match(AnalyzedSentence sentence, int pos) {

    AnalyzedTokenReadings finiteVerb = null;
    List<RuleMatch> ruleMatches = new ArrayList<>();
    AnalyzedTokenReadings[] tokens = getSentenceWithImmunization(sentence).getTokensWithoutWhitespace();

    if (tokens.length < 4) { // ignore one-word sentences (3 tokens: SENT_START, one word, SENT_END)
        return ruleMatches;
    }/*from   w  w w. j  a v  a 2 s. co m*/

    // position of the pronouns:
    int posIch = -1;
    int posDu = -1;
    int posEr = -1;
    int posWir = -1;
    // positions of verbs which do match in person and number, and do not match any other person nor number:
    int posVer1Sin = -1;
    int posVer2Sin = -1;
    int posVer1Plu = -1;
    /*int posVer2Plu = -1;*/
    // positions of verbs which do match in person and number:
    int posPossibleVer1Sin = -1;
    int posPossibleVer2Sin = -1;
    int posPossibleVer3Sin = -1;
    int posPossibleVer1Plu = -1;
    /*int posPossibleVer2Plu = -1;*/

    for (int i = 1; i < tokens.length; ++i) { // ignore SENT_START

        if (tokens[i].isImmunized()) {
            continue;
        }

        String strToken = tokens[i].getToken().toLowerCase();
        strToken = strToken.replace("", "");

        switch (strToken) {
        case "ich":
            posIch = i;
            break;
        case "du":
            posDu = i;
            break;
        case "er":
            posEr = i;
            break;
        case "wir":
            posWir = i;
            break;
        }

        if (tokens[i].hasPartialPosTag("VER") && (Character.isLowerCase(tokens[i].getToken().charAt(0))
                || i == 1 || isQuotationMark(tokens[i - 1]))) {
            if (hasUnambiguouslyPersonAndNumber(tokens[i], "1", "SIN")
                    && !(strToken.equals("bin") && (BIN_IGNORE.contains(tokens[i - 1].getToken())
                            || (tokens.length != i + 1 && tokens[i + 1].getToken().startsWith("Laden"))))) {
                posVer1Sin = i;
            } else if (hasUnambiguouslyPersonAndNumber(tokens[i], "2", "SIN")
                    && !"Probst".equals(tokens[i].getToken())) {
                posVer2Sin = i;
            } else if (hasUnambiguouslyPersonAndNumber(tokens[i], "1", "PLU")) {
                posVer1Plu = i;
                //      } else if (hasUnambiguouslyPersonAndNumber(tokens[i], "2", "PLU")) {
                //        posVer2Plu = i;
            }

            if (tokens[i].hasPartialPosTag(":1:SIN")) {
                posPossibleVer1Sin = i;
            }
            if (tokens[i].hasPartialPosTag(":2:SIN")) {
                posPossibleVer2Sin = i;
            }
            if (tokens[i].hasPartialPosTag(":3:SIN")) {
                posPossibleVer3Sin = i;
            }
            if (tokens[i].hasPartialPosTag(":1:PLU")) {
                posPossibleVer1Plu = i;
            }
            //      if (tokens[i].hasPartialPosTag(":2:PLU"))
            //        posPossibleVer2Plu = i;

        }

    } // for each token

    // "ich", "du", and "wir" must be subject (no other interpretation possible)
    // "ich", "du", "er", and "wir" must have a matching verb

    if (posVer1Sin != -1 && posIch == -1 && !isQuotationMark(tokens[posVer1Sin - 1])) { // 1st pers sg verb but no "ich"
        ruleMatches.add(ruleMatchWrongVerb(tokens[posVer1Sin], pos, sentence));
    } else if (posIch > 0 && !isNear(posPossibleVer1Sin, posIch) // check whether verb next to "ich" is 1st pers sg
            && (tokens[posIch].getToken().equals("ich") || tokens[posIch].getStartPos() <= 1) // ignore "lyrisches Ich" etc.
            && (!isQuotationMark(tokens[posIch - 1]) || posIch < 3
                    || (posIch > 1 && tokens[posIch - 2].getToken().equals(":")))) {
        int plus1 = ((posIch + 1) == tokens.length) ? 0 : +1; // prevent posIch+1 segfault
        BooleanAndFiniteVerb check = verbDoesMatchPersonAndNumber(tokens[posIch - 1], tokens[posIch + plus1],
                "1", "SIN", finiteVerb);
        if (!check.verbDoesMatchPersonAndNumber && !nextButOneIsModal(tokens, posIch)
                && !"uerst".equals(check.finiteVerb.getToken())) {
            ruleMatches
                    .add(ruleMatchWrongVerbSubject(tokens[posIch], check.finiteVerb, "1:SIN", pos, sentence));
        }
    }

    if (posVer2Sin != -1 && posDu == -1 && !isQuotationMark(tokens[posVer2Sin - 1])) {
        ruleMatches.add(ruleMatchWrongVerb(tokens[posVer2Sin], pos, sentence));
    } else if (posDu > 0 && !isNear(posPossibleVer2Sin, posDu) && (!isQuotationMark(tokens[posDu - 1])
            || posDu < 3 || (posDu > 1 && tokens[posDu - 2].getToken().equals(":")))) {
        int plus1 = ((posDu + 1) == tokens.length) ? 0 : +1;
        BooleanAndFiniteVerb check = verbDoesMatchPersonAndNumber(tokens[posDu - 1], tokens[posDu + plus1], "2",
                "SIN", finiteVerb);
        if (!check.verbDoesMatchPersonAndNumber && !tokens[posDu + plus1].hasPosTagStartingWith("VER:1:SIN:KJ2")
                && // "Wenn ich du wre"
                !(tokens[posDu + plus1].hasPosTagStartingWith("ADJ:")
                        && !tokens[posDu + plus1].hasPosTag("ADJ:PRD:GRU"))
                && // "dass du billige Klamotten..."
                !tokens[posDu - 1].hasPosTagStartingWith("VER:1:SIN:KJ2")
                && !nextButOneIsModal(tokens, posDu)) {
            ruleMatches.add(ruleMatchWrongVerbSubject(tokens[posDu], check.finiteVerb, "2:SIN", pos, sentence));
        }
    }

    if (posEr > 0 && !isNear(posPossibleVer3Sin, posEr) && (!isQuotationMark(tokens[posEr - 1]) || posEr < 3
            || (posEr > 1 && tokens[posEr - 2].getToken().equals(":")))) {
        int plus1 = ((posEr + 1) == tokens.length) ? 0 : +1;
        BooleanAndFiniteVerb check = verbDoesMatchPersonAndNumber(tokens[posEr - 1], tokens[posEr + plus1], "3",
                "SIN", finiteVerb);
        if (!check.verbDoesMatchPersonAndNumber && !nextButOneIsModal(tokens, posEr)
                && !"uerst".equals(check.finiteVerb.getToken())
                && !"regen".equals(check.finiteVerb.getToken())) { // "wo er regen Anteil nahm"
            ruleMatches.add(ruleMatchWrongVerbSubject(tokens[posEr], check.finiteVerb, "3:SIN", pos, sentence));
        }
    }

    if (posVer1Plu != -1 && posWir == -1 && !isQuotationMark(tokens[posVer1Plu - 1])) {
        ruleMatches.add(ruleMatchWrongVerb(tokens[posVer1Plu], pos, sentence));
    } else if (posWir > 0 && !isNear(posPossibleVer1Plu, posWir) && !isQuotationMark(tokens[posWir - 1])) {
        int plus1 = ((posWir + 1) == tokens.length) ? 0 : +1;
        BooleanAndFiniteVerb check = verbDoesMatchPersonAndNumber(tokens[posWir - 1], tokens[posWir + plus1],
                "1", "PLU", finiteVerb);
        if (!check.verbDoesMatchPersonAndNumber && !nextButOneIsModal(tokens, posWir)) {
            ruleMatches
                    .add(ruleMatchWrongVerbSubject(tokens[posWir], check.finiteVerb, "1:PLU", pos, sentence));
        }
    }

    return ruleMatches;
}