示例#1
0
        public override TextValue Trim()
        {
            int start = LtrimIndex(_value);
            int end   = RtrimIndex(_value);

            return(Values.StringValue(_value.Substring(start, Math.Max(end, start) - start)));
        }
示例#2
0
        public override TextValue Replace(string find, string replace)
        {
            Debug.Assert(!string.ReferenceEquals(find, null));
            Debug.Assert(!string.ReferenceEquals(replace, null));

            return(Values.StringValue(Value().Replace(find, replace)));
        }
示例#3
0
        public override TextValue Reverse()
        {
            StringBuilder stringBuilder = new StringBuilder(Value());

//JAVA TO C# CONVERTER TODO TASK: There is no .NET StringBuilder equivalent to the Java 'reverse' method:
            return(Values.StringValue(stringBuilder.reverse().ToString()));
        }
示例#4
0
        public override TextValue Substring(int start, int length)
        {
            int s = Math.Min(start, length());
            int e = Math.Min(s + length, length());
            int codePointStart = _value.offsetByCodePoints(0, s);
            int codePointEnd   = _value.offsetByCodePoints(0, e);

            return(Values.StringValue(_value.Substring(codePointStart, codePointEnd - codePointStart)));
        }
示例#5
0
 public override TextValue replace(string find, string replace)
 {
     if (find.Length == 0)
     {
         return(Values.StringValue(replace));
     }
     else
     {
         return(this);
     }
 }
示例#6
0
 public override ListValue Split(string separator)
 {
     if (separator.Equals(StringValue()))
     {
         return(EmptySplit);
     }
     else
     {
         return(list(Values.StringValue(StringValue())));
     }
 }
示例#7
0
 public override TextValue Replace(string find, string replace)
 {
     Debug.Assert(!string.ReferenceEquals(find, null));
     Debug.Assert(!string.ReferenceEquals(replace, null));
     if (StringValue().Equals(find))
     {
         return(Values.StringValue(replace));
     }
     else
     {
         return(this);
     }
 }
示例#8
0
        public override TextValue Plus(TextValue other)
        {
            if (other is UTF8StringValue)
            {
                UTF8StringValue rhs      = ( UTF8StringValue )other;
                sbyte[]         newBytes = new sbyte[_byteLength + rhs._byteLength];
                Array.Copy(_bytes, _offset, newBytes, 0, _byteLength);
                Array.Copy(rhs._bytes, rhs._offset, newBytes, _byteLength, rhs._byteLength);
                return(utf8Value(newBytes));
            }

            return(Values.StringValue(StringValueConflict() + other.StringValue()));
        }
示例#9
0
        /// <summary>
        /// Splits a string.
        /// </summary>
        /// <param name="input"> String to be split </param>
        /// <param name="delim"> delimiter, must not be not empty </param>
        /// <returns> the split string as a List of TextValues </returns>
        private static IList <AnyValue> SplitNonRegex(string input, string delim)
        {
            IList <AnyValue> l = new List <AnyValue>();
            int offset         = 0;

            while (true)
            {
                int index = input.IndexOf(delim, offset, StringComparison.Ordinal);
                if (index == -1)
                {
                    string substring = input.Substring(offset);
                    l.Add(Values.StringValue(substring));
                    return(l);
                }
                else
                {
                    string substring = input.Substring(offset, index - offset);
                    l.Add(Values.StringValue(substring));
                    offset = index + delim.Length;
                }
            }
        }
示例#10
0
 private static Test ShouldNotMatch(string propertyValue, object value)
 {
     return(new Test(Values.StringValue(propertyValue), value, false));
 }
示例#11
0
        public override TextValue Rtrim()
        {
            int end = RtrimIndex(_value);

            return(Values.StringValue(_value.Substring(0, end)));
        }
示例#12
0
        public override TextValue Ltrim()
        {
            int start = LtrimIndex(_value);

            return(Values.StringValue(_value.Substring(start, _value.Length - start)));
        }
示例#13
0
 public override TextValue Plus(TextValue other)
 {
     return(Values.StringValue(ValueConflict + other.StringValue()));
 }
示例#14
0
 private void InitializeInstanceFields()
 {
     _scalars = Arrays.asList(ShouldGivePublic(Values.ByteValue(( sbyte )1), ( sbyte )1), ShouldGivePublic(Values.ShortValue(( short )2), ( short )2), ShouldGivePublic(Values.IntValue(3), 3), ShouldGivePublic(Values.LongValue(4L), 4L), ShouldGivePublic(Values.FloatValue(5.0f), 5.0f), ShouldGivePublic(Values.DoubleValue(6.0), 6.0), ShouldGivePublic(Values.BooleanValue(false), false), ShouldGivePublic(Values.CharValue('a'), 'a'), ShouldGivePublic(Values.StringValue("b"), "b"));
 }