Пример #1
0
        /// <summary>
        ///   computes the min and max expression to check their values
        /// </summary>
        protected internal void compute(bool padValueWithMinMaxCharacters)
        {
            if (hasMinExp())
            {
                //evaluate the min expression
                //         String minVal = min.evaluate(getExpType(),size, true, DATA_TYPE_SKIP);
                String minVal = _min.evaluate(getExpType(), _size);

                if (minVal != null)
                {
                    minVal = minVal.TrimEnd();
                }

                _minExpVal = new GuiExpressionEvaluator.ExpVal(getExpType(), (minVal == null), minVal);

                // check and set the MaxEqualsMin before the wild chars are replaced on the string result
                MaxEqualsMin = IsMaxEqualsMin();

                if (!_minExpVal.IsNull && (_minExpVal.Attr == StorageAttribute.ALPHA || _minExpVal.Attr == StorageAttribute.UNICODE))
                {
                    if (padValueWithMinMaxCharacters)
                    {
                        _minExpVal.StrVal = DisplayConvertor.StringValueToMgValue(_minExpVal.StrVal, _minExpVal.Attr, Char.MinValue, _size).ToString();
                        MaxEqualsMin      = false;
                    }

                    _minExpVal.StrVal = StrUtil.SearchAndReplaceWildChars(_minExpVal.StrVal, _size, Char.MinValue);
                }

                DiscardMin = _min.DiscardCndRangeResult();
            }

            if (hasMaxExp())
            {
                //evaluate the max expression
                //         String maxVal = max.evaluate(getExpType(),size, true, DATA_TYPE_SKIP);
                String maxVal = _max.evaluate(getExpType(), _size);
                _maxExpVal = new GuiExpressionEvaluator.ExpVal(getExpType(), (maxVal == null), maxVal);

                if (!_maxExpVal.IsNull && (_maxExpVal.Attr == StorageAttribute.ALPHA || _maxExpVal.Attr == StorageAttribute.UNICODE))
                {
                    if (padValueWithMinMaxCharacters)
                    {
                        _maxExpVal.StrVal = DisplayConvertor.StringValueToMgValue(_maxExpVal.StrVal, _maxExpVal.Attr, Char.MaxValue, _size).ToString();
                    }

                    _maxExpVal.StrVal = StrUtil.SearchAndReplaceWildChars(_maxExpVal.StrVal, _size, Char.MaxValue);
                }

                DiscardMax = _max.DiscardCndRangeResult();
            }
        }
Пример #2
0
        /// <summary>
        /// init the boundary
        /// </summary>
        /// <param name="boundaryValue"></param>
        /// <param name="storageAttribute"></param>
        /// <param name="discard"></param>
        /// <param name="value"></param>
        private void InitBoundary(BoundaryValue boundaryValue, StorageAttribute storageAttribute, bool discard, string value, int length, char filler)
        {
            if (discard)
            {
                boundaryValue.Type         = RangeType.RangeNoVal;
                boundaryValue.Value.IsNull = true;
            }
            else
            {
                if (value == null)
                {
                    boundaryValue.Value.IsNull = true;
                }
                else
                {
                    if (storageAttribute == StorageAttribute.ALPHA ||
                        storageAttribute == StorageAttribute.UNICODE)
                    {
                        if (IsLocate)
                        {
                            boundaryValue.Value.Value = DisplayConvertor.StringValueToMgValue(value, storageAttribute, filler, length);
                        }
                        else
                        {
                            boundaryValue.Value.Value = value;
                        }

                        boundaryValue.Value.Value = StrUtil.SearchAndReplaceWildChars((string)boundaryValue.Value.Value, length, filler);
                    }
                    else
                    {
                        boundaryValue.Value.Value = DisplayConvertor.StringValueToMgValue(value, storageAttribute, filler, length);
                    }
                }

                boundaryValue.Type = RangeType.RangeParam;
            }
        }