All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.common.GuideNumericBox Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2014 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.adobe.aemds.guide.common;

import com.adobe.aemds.guide.utils.GuideConstants;
import com.day.cq.wcm.foundation.forms.FormsHelper;

/**
 * GuideNumericBox class encapsulates basic properties of the adaptive forms numeric box Component.
 * Few are listed below:
 * 
    *
  • maximum value allowed *
  • minimum value allowed *
* */ public class GuideNumericBox extends GuideField { /** * Returns the value configured during authoring * * @return value configured during authoring */ public String[] getValues() { String[] values = FormsHelper.getValues(slingRequest, getResource()); if (values == null) { values = new String[]{""}; } return values; } /** * Returns the html5 input type which should be used in the widget * * @return string representing the html5 type to be used in the widget */ public String getHtml5Type() { return resourceProps.get("html5Type", "text"); } /** * Returns the field type of the adaptive forms Component * * @return String representing guide field type */ public String getGuideFieldType() { return GuideConstants.GUIDE_FIELD_NUMERICBOX; } /** * Returns if maximum value given is excluded form range of valid values. * * @return Boolean if maximum value given is excluded form range of valid values. */ public Boolean isMaxValueExcluded() { return resourceProps.get("exclusiveMaximum", false); } /** * Returns if minimum value given is excluded form range of valid values. * * @return Boolean if minimum value given is excluded form range of valid values. */ public Boolean isMinValueExcluded() { return resourceProps.get("exclusiveMinimum", false); } /** * Returns maximum valid value. * * @return String maximum valid value. */ public String getMaximumValue() { String maximumValueInString = resourceProps.get("maximum", ""); if (!maximumValueInString.isEmpty() && isMaxValueExcluded()) { int maximumValue = Integer.parseInt(maximumValueInString); maximumValue -= 1; maximumValueInString = Integer.toString(maximumValue); } return maximumValueInString; } /** * Returns minimum valid value. * * @return String minimum valid value. */ public String getMinimumValue() { String minimumValueInString = resourceProps.get("minimum", ""); if (!minimumValueInString.isEmpty() && isMinValueExcluded()) { int minimumValue = Integer.parseInt(minimumValueInString); minimumValue += 1; minimumValueInString = Integer.toString(minimumValue); } return minimumValueInString; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy