Example usage for java.lang Character isDigit

List of usage examples for java.lang Character isDigit

Introduction

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

Prototype

public static boolean isDigit(int codePoint) 

Source Link

Document

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

Usage

From source file:de.jfachwert.math.PackedDecimal.java

/**
 * Liefert den uebergebenen String als {@link PackedDecimal} zurueck.
 * Diese Methode ist dem Konstruktor vorzuziehen, da fuer gaengige Zahlen
 * wie "0" oder "1" immer das gleiche Objekt zurueckgegeben wird.
 * <p>/*from   w w w .j av a 2  s  .  c o  m*/
 * Im Gegensatz zum String-Konstruktor darf man hier auch 'null' als Wert
 * uebergeben. In diesem Fall wird dies in {@link #EMPTY} uebersetzt.
 * </p>
 * <p>
 * Die erzeugten PackedDecimals werden intern in einem "weak" Cache
 * abgelegt, damit bei gleichen Zahlen auch die gleichen PackedDecimals
 * zurueckgegeben werden. Dies dient vor allem zur Reduktion des
 * Speicherverbrauchs.
 * </p>
 *
 * @param zahl String aus Zahlen
 * @return Zahl als {@link PackedDecimal}
 */
public static PackedDecimal valueOf(String zahl) {
    String trimmed = StringUtils.trimToEmpty(zahl);
    if (StringUtils.isEmpty(trimmed)) {
        return EMPTY;
    }
    if ((trimmed.length() == 1 && Character.isDigit(trimmed.charAt(0)))) {
        return CACHE[Character.getNumericValue(trimmed.charAt(0))];
    } else {
        return WEAK_CACHE.computeIfAbsent(zahl, PackedDecimal::new);
    }
}

From source file:com.tecapro.inventory.common.util.StringUtil.java

public static boolean isMobileNumber(final CharSequence cs) {

    final int seqLength = cs.length();

    if (seqLength == 0) {
        return false;
    }/*  w ww .j  a v a  2  s  . co  m*/

    boolean hasMobiPrefix = false;
    char firstChar = cs.charAt(0);

    if (cs.charAt(0) == '8' && cs.charAt(1) == '4') { // two first digits are country code
        firstChar = cs.charAt(2);
    }

    for (int i = 0; i < Constants.MOBI_PREFIX.length; i++) {
        if (firstChar == Constants.MOBI_PREFIX[i]) {
            hasMobiPrefix = true;
            break;
        }
    }

    if (!hasMobiPrefix) {
        return false;
    }

    for (int i = 1; i < seqLength; i++) {
        if (!Character.isDigit(cs.charAt(i))) {
            return false;
        }
    }

    return true;
}

From source file:com.manydesigns.portofino.actions.admin.page.PageAdminAction.java

private Resolution doCreateNewPage() throws Exception {
    prepareNewPageForm();/*from   www. ja  va2 s. com*/
    if (newPageForm.validate()) {
        NewPage newPage = new NewPage();
        newPageForm.writeToObject(newPage);
        InsertPosition insertPosition = InsertPosition.valueOf(newPage.getInsertPositionName());
        String pageClassName = newPage.getActionClassName();
        ClassLoader classLoader = (ClassLoader) context.getServletContext()
                .getAttribute(BaseModule.CLASS_LOADER);
        Class actionClass = Class.forName(pageClassName, true, classLoader);
        PageActionInfo info = registry.getInfo(actionClass);
        String scriptTemplate = info.scriptTemplate;
        Class<?> configurationClass = info.configurationClass;
        boolean supportsDetail = info.supportsDetail;

        String pageId = RandomUtil.createRandomId();
        String className = pageId;
        if (Character.isDigit(className.charAt(0))) {
            className = "_" + className;
        }
        OgnlContext ognlContext = ElementsThreadLocals.getOgnlContext();
        ognlContext.put("generatedClassName", className);
        ognlContext.put("pageClassName", pageClassName);
        String script = OgnlTextFormat.format(scriptTemplate, this);

        Page page = new Page();
        BeanUtils.copyProperties(page, newPage);
        page.setId(pageId);

        Object configuration = null;
        if (configurationClass != null) {
            configuration = ReflectionUtil.newInstance(configurationClass);
            if (configuration instanceof ConfigurationWithDefaults) {
                ((ConfigurationWithDefaults) configuration).setupDefaults();
            }
        }
        page.init();

        String fragment = newPage.getFragment();
        String configurePath;
        File directory;
        File parentDirectory;
        Page parentPage;
        PageInstance parentPageInstance;
        Layout parentLayout;
        switch (insertPosition) {
        case TOP:
            parentDirectory = pagesDir;
            directory = new File(parentDirectory, fragment);
            parentPage = DispatcherLogic.getPage(parentDirectory);
            parentLayout = parentPage.getLayout();
            configurePath = "";
            parentPageInstance = new PageInstance(null, parentDirectory, parentPage, null);
            break;
        case CHILD:
            parentPageInstance = getPageInstance();
            parentPage = parentPageInstance.getPage();
            parentLayout = parentPageInstance.getLayout();
            parentDirectory = parentPageInstance.getDirectory();
            directory = parentPageInstance.getChildPageDirectory(fragment);
            configurePath = originalPath;
            break;
        case SIBLING:
            parentPageInstance = dispatch.getPageInstance(-2);
            parentPage = parentPageInstance.getPage();
            parentLayout = parentPageInstance.getLayout();
            parentDirectory = parentPageInstance.getDirectory();
            directory = parentPageInstance.getChildPageDirectory(fragment);
            configurePath = parentPageInstance.getPath();
            break;
        default:
            throw new IllegalStateException(
                    "Don't know how to add page " + page + " at position " + insertPosition);
        }

        //Check permissions on target parent
        Subject subject = SecurityUtils.getSubject();
        if (!SecurityLogic.hasPermissions(portofinoConfiguration, parentPageInstance, subject,
                AccessLevel.EDIT)) {
            logger.warn("User not authorized to create page.");
            return new ForbiddenAccessResolution("You are not authorized to create a new page here.");
        }

        if (directory.exists()) {
            logger.error("Can't create page - directory {} exists", directory.getAbsolutePath());
            SessionMessages.addErrorMessage(
                    ElementsThreadLocals.getText("error.creating.page.the.directory.already.exists"));
            return new ForwardResolution("/m/pageactionsadmin/actions/admin/page/new-page.jsp");
        }
        if (ElementsFileUtils.safeMkdirs(directory)) {
            try {
                page.getLayout().setTemplate(parentPage.getLayout().getTemplate());
                page.getDetailLayout().setTemplate(parentPage.getDetailLayout().getTemplate());
                logger.debug("Creating the new child page in directory: {}", directory);
                DispatcherLogic.savePage(directory, page);
                if (configuration != null) {
                    DispatcherLogic.saveConfiguration(directory, configuration);
                }
                File groovyScriptFile = ScriptingUtil.getGroovyScriptFile(directory, "action");
                FileWriter fw = null;
                try {
                    fw = new FileWriter(groovyScriptFile);
                    fw.write(script);
                } finally {
                    IOUtils.closeQuietly(fw);
                }
                logger.debug("Registering the new child page in parent page (directory: {})", parentDirectory);
                ChildPage childPage = new ChildPage();
                childPage.setName(directory.getName());
                childPage.setShowInNavigation(true);
                parentLayout.getChildPages().add(childPage);

                if (supportsDetail) {
                    File detailDir = new File(directory, PageInstance.DETAIL);
                    logger.debug("Creating _detail directory: {}", detailDir);
                    if (!ElementsFileUtils.safeMkdir(detailDir)) {
                        logger.warn("Couldn't create detail directory {}", detailDir);
                    }
                }

                DispatcherLogic.savePage(parentDirectory, parentPage);
            } catch (Exception e) {
                logger.error("Exception saving page configuration");
                SessionMessages.addErrorMessage(ElementsThreadLocals.getText("error.creating.page._"));
                return new ForwardResolution("/m/pageactionsadmin/actions/admin/page/new-page.jsp");
            }
        } else {
            logger.error("Can't create directory {}", directory.getAbsolutePath());
            SessionMessages.addErrorMessage(
                    ElementsThreadLocals.getText("error.creating.page.the.directory.could.not.be.created"));
            return new ForwardResolution("/m/pageactionsadmin/actions/admin/page/new-page.jsp");
        }
        logger.info("Page " + pageId + " created. Path: " + directory.getAbsolutePath());
        SessionMessages.addInfoMessage(
                ElementsThreadLocals.getText("page.created.successfully.you.should.now.configure.it"));
        String url = context.getRequest().getContextPath() + configurePath + "/" + fragment;
        return new RedirectResolution(url, false).addParameter("configure").addParameter("returnUrl", url);
    } else {
        return new ForwardResolution("/m/pageactionsadmin/actions/admin/page/new-page.jsp");
    }
}

From source file:com.wavemaker.common.util.StringUtils.java

public static boolean isNumber(char c) {
    return Character.isDigit(c);
}

From source file:com.ing.connector.util.WStringUtil.java

/**
 *  checkForZip --> uppercases the state code where appropriate
 *//*from   w  w  w . j a  v  a  2  s . c  om*/
private String checkForZip(String aString) {
    String lString = aString;
    String lStateSubString = null;
    int lLength = lString.length();
    int lStateIndex = 0;
    boolean lHasStateCode = true;
    boolean lState = false;

    if (lLength >= 5) {
        for (int i = 0; i < lLength - 4; i++) {
            //various 5 char strings to test for zip codes
            String lZipSubString = lString.substring(i, (i + 5));

            char[] lZipSubArray = lZipSubString.toCharArray();

            boolean lZip = true;

            for (int j = 0; j < 5; j++) {
                if (!Character.isDigit(lZipSubArray[j])) {
                    lZip = false;
                }
            }

            if (lZip) {
                if (i > 0) {
                    String lPreZipSubString = lString.substring(0, i);

                    if (lPreZipSubString.length() >= 2) {
                        for (int k = lPreZipSubString.length() - 2; k >= 0; k--) {
                            //various 2 char strings to test for state codes
                            lStateSubString = lPreZipSubString.substring(k, (k + 2));

                            char[] lStateSubArray = lStateSubString.toCharArray();

                            lState = true;

                            for (int m = 0; m < 2; m++) {
                                if (!Character.isLetter(lStateSubArray[m])) {
                                    lState = false;
                                }
                            }

                            if (lState) {
                                //we have found a state code!
                                lStateIndex = k;
                                break;
                            }
                        }
                    }

                    if (lState) {
                        if (lStateSubString.equalsIgnoreCase("AL") || lStateSubString.equalsIgnoreCase("AK")
                                || lStateSubString.equalsIgnoreCase("AZ")
                                || lStateSubString.equalsIgnoreCase("AR")
                                || lStateSubString.equalsIgnoreCase("CA")
                                || lStateSubString.equalsIgnoreCase("CO")
                                || lStateSubString.equalsIgnoreCase("CT")
                                || lStateSubString.equalsIgnoreCase("DE")
                                || lStateSubString.equalsIgnoreCase("DC")
                                || lStateSubString.equalsIgnoreCase("FL")
                                || lStateSubString.equalsIgnoreCase("GA")
                                || lStateSubString.equalsIgnoreCase("HI")
                                || lStateSubString.equalsIgnoreCase("ID")
                                || lStateSubString.equalsIgnoreCase("IL")
                                || lStateSubString.equalsIgnoreCase("IN")
                                || lStateSubString.equalsIgnoreCase("IA")
                                || lStateSubString.equalsIgnoreCase("KS")
                                || lStateSubString.equalsIgnoreCase("KY")
                                || lStateSubString.equalsIgnoreCase("LA")
                                || lStateSubString.equalsIgnoreCase("ME")
                                || lStateSubString.equalsIgnoreCase("MD")
                                || lStateSubString.equalsIgnoreCase("MA")
                                || lStateSubString.equalsIgnoreCase("MI")
                                || lStateSubString.equalsIgnoreCase("MN")
                                || lStateSubString.equalsIgnoreCase("MS")
                                || lStateSubString.equalsIgnoreCase("MO")
                                || lStateSubString.equalsIgnoreCase("MT")
                                || lStateSubString.equalsIgnoreCase("NE")
                                || lStateSubString.equalsIgnoreCase("NV")
                                || lStateSubString.equalsIgnoreCase("NH")
                                || lStateSubString.equalsIgnoreCase("NJ")
                                || lStateSubString.equalsIgnoreCase("NM")
                                || lStateSubString.equalsIgnoreCase("NY")
                                || lStateSubString.equalsIgnoreCase("NC")
                                || lStateSubString.equalsIgnoreCase("ND")
                                || lStateSubString.equalsIgnoreCase("OH")
                                || lStateSubString.equalsIgnoreCase("OK")
                                || lStateSubString.equalsIgnoreCase("OR")
                                || lStateSubString.equalsIgnoreCase("PA")
                                || lStateSubString.equalsIgnoreCase("PR")
                                || lStateSubString.equalsIgnoreCase("RI")
                                || lStateSubString.equalsIgnoreCase("SC")
                                || lStateSubString.equalsIgnoreCase("SD")
                                || lStateSubString.equalsIgnoreCase("TN")
                                || lStateSubString.equalsIgnoreCase("TX")
                                || lStateSubString.equalsIgnoreCase("UT")
                                || lStateSubString.equalsIgnoreCase("VT")
                                || lStateSubString.equalsIgnoreCase("VA")
                                || lStateSubString.equalsIgnoreCase("WA")
                                || lStateSubString.equalsIgnoreCase("WV")
                                || lStateSubString.equalsIgnoreCase("WI")
                                || lStateSubString.equalsIgnoreCase("WY")) {
                            char[] lCharArray = lString.toCharArray();

                            lCharArray[lStateIndex] = Character.toUpperCase(lCharArray[lStateIndex]);
                            lCharArray[lStateIndex + 1] = Character.toUpperCase(lCharArray[lStateIndex + 1]);

                            lString = new String(lCharArray);
                        } // if (lStateSubString.equalsIgnoreCase("AL") || ...
                    } // if(lState)
                } // if(i > 0)
            } // if (lZip)
        } // for (int i=0; i < lLength - 4; i++)
    } // if(lLength >= 5)

    return lString;
}

From source file:CharUtils.java

/**
 * True if character is a digit./*from w w w.j  a v  a 2 s  . c om*/
 * 
 * @param c
 *            Character to check for being a digit.
 * 
 * @return true if character is a digit from 0 through 9.
 */

public static boolean isDigit(char c) {
    return Character.isDigit(c);
}

From source file:org.gvnix.service.roo.addon.addon.util.WsdlParserUtils.java

/**
 * Massage word into a form suitable for use in a Java package name.
 * <p>/*from   w ww  . j av  a  2  s  .c  o m*/
 * Append it to the target string buffer with a <tt>.</tt> delimiter if
 * <tt>word</tt> is not the first word in the package name.
 * </p>
 * 
 * @param sb the buffer to append to
 * @param word the word to append
 * @param firstWord a flag indicating whether this is the first word
 */
private static void addWordToPackageBuffer(StringBuffer sb, String word, boolean firstWord) {

    if (isJavaKeyword(word)) {
        word = makeNonJavaKeyword(word);
    }

    // separate with dot after the first word
    if (!firstWord) {
        sb.append('.');
    }

    // prefix digits with underscores
    if (Character.isDigit(word.charAt(0))) {
        sb.append('_');
    }

    // replace periods with underscores
    if (word.indexOf('.') != -1) {
        char[] buf = word.toCharArray();

        for (int i = 0; i < word.length(); i++) {
            if (buf[i] == '.') {
                buf[i] = '_';
            }
        }

        word = new String(buf);
    }

    sb.append(word);
}

From source file:com.kcs.core.utilities.Utility.java

public static boolean checkFormatDateDDMMYYYYHHMISS(String str) {
    if (str == null || str.length() == 0 || str == "null") {
        return false;
    }/*w w w  .  j ava 2s.  com*/
    for (int i = 0; i < str.length(); i++) {
        if (i == 8) {
            if (str.charAt(i) != ' ') {
                return false;
            }
        } else {
            if (!Character.isDigit(str.charAt(i)) && str.charAt(i) != ':') {
                return false;
            }
        }
    }
    return true;
}

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.// ww  w .  j av  a2 s .c om
* @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:com.baifendian.swordfish.execserver.parameter.placeholder.TimePlaceholderUtil.java

/**
 * ? <p>/*  w  w  w. ja va2 s  .c o m*/
 *
 * @return <, ?>
 */
private static Map.Entry<Date, String> addMinuteCalc(String expr, Date cycTime) {
    if (expr.contains("+")) {
        int index = expr.lastIndexOf('+');

        // HHmmss+N/24/60
        if (Character.isDigit(expr.charAt(index + 1))) {
            String addMinuteExpr = expr.substring(index + 1);
            Date targetDate = org.apache.commons.lang.time.DateUtils.addMinutes(cycTime,
                    calcAddMinute(addMinuteExpr));
            String dateFormat = expr.substring(0, index);

            return new AbstractMap.SimpleImmutableEntry<>(targetDate, dateFormat);
        }
    } else if (expr.contains("-")) {
        int index = expr.lastIndexOf('-');

        // HHmmss-N/24/60
        if (Character.isDigit(expr.charAt(index + 1))) {
            String addMinuteExpr = expr.substring(index + 1);
            Date targetDate = org.apache.commons.lang.time.DateUtils.addMinutes(cycTime,
                    0 - calcAddMinute(addMinuteExpr));
            String dateFormat = expr.substring(0, index);

            return new AbstractMap.SimpleImmutableEntry<>(targetDate, dateFormat);
        }

        // yyyy-MM-dd/HH:mm:ss
        return new AbstractMap.SimpleImmutableEntry<>(cycTime, expr);
    }

    //  $[HHmmss] 
    return new AbstractMap.SimpleImmutableEntry<>(cycTime, expr);
}