/** * Convert to lower case. */ public override StringValue toUpperCase() { int length = _length; UnicodeBuilderValue string = new UnicodeBuilderValue(_length); char [] srcBuffer = _buffer; char [] dstBuffer = string._buffer; for (int i = 0; i < length; i++) { char ch = srcBuffer[i]; if ('a' <= ch && ch <= 'z') { dstBuffer[i] = (char)(ch + 'A' - 'a'); } else if (ch < 0x80) { dstBuffer[i] = ch; } else if (Character.isLowerCase(ch)) { dstBuffer[i] = Character.toUpperCase(ch); } else { dstBuffer[i] = ch; } } string._length = length; return(string); }
/** * sets the character at an index */ public override Value setCharValueAt(long indexL, Value value) { int len = _length; if (indexL < 0) { return(this); } else if (indexL < len) { UnicodeBuilderValue sb = new UnicodeBuilderValue(_buffer, 0, len); StringValue str = value.ToStringValue(); int index = (int)indexL; if (value.length() == 0) { sb._buffer[index] = 0; } else { sb._buffer[index] = str[0]; } return(sb); } else { int index = (int)indexL; UnicodeBuilderValue sb = (UnicodeBuilderValue)copyStringBuilder(); if (sb._buffer.length < index + 1) { sb.ensureCapacity(index + 1); } int padLen = index - len; for (int i = 0; i <= padLen; i++) { sb._buffer[sb._length++] = ' '; } StringValue str = value.ToStringValue(); if (value.length() == 0) { sb._buffer[index] = 0; } else { sb._buffer[index] = str[0]; } return(sb); } }
/** * Converts to a string builder */ public override StringValue ToStringBuilder() { UnicodeBuilderValue sb = new UnicodeBuilderValue(); sb.append(this); return(sb); }
/** * Converts to a string builder */ public override StringValue ToStringBuilder(Env env, Value value) { UnicodeBuilderValue v = new UnicodeBuilderValue(this); value.appendTo(v); return(v); }
/** * Returns true for equality */ public override bool eq(Value rValue) { rValue = rValue.toValue(); ValueType typeB = rValue.getValueType(); if (typeB.isNumber()) { double l = toDouble(); double r = rValue.toDouble(); return(l == r); } else if (typeB.isBoolean()) { return(toBoolean() == rValue.toBoolean()); } ValueType typeA = getValueType(); if (typeA.isNumberCmp() && typeB.isNumberCmp()) { double l = toDouble(); double r = rValue.toDouble(); return(l == r); } else if (rValue instanceof UnicodeBuilderValue) { UnicodeBuilderValue value = (UnicodeBuilderValue)rValue; int length = _length; if (length != value._length) { return(false); } char [] bufferA = _buffer; char [] bufferB = value._buffer; for (int i = length - 1; i >= 0; i--) { if (bufferA[i] != bufferB[i]) { return(false); } } return(true); }
/** * Returns a subsequence */ public override CharSequence subSequence(int start, int end) { int len = end - start; if (len == 0) { return(EMPTY); } UnicodeBuilderValue sb = new UnicodeBuilderValue(len); sb.append(_buffer, start, len); return(sb); }
/** * Append a Java buffer to the value. */ public StringValue append(UnicodeBuilderValue sb, int head, int tail) { int len = tail - head; if (_buffer.length < _length + len) { ensureAppendCapacity(len); } System.arraycopy(sb._buffer, head, _buffer, _length, len); _length += len; return(this); }
public UnicodeBuilderValue(UnicodeBuilderValue v) { if (v._isCopy) { _buffer = new char[v._buffer.length]; System.arraycopy(v._buffer, 0, _buffer, 0, v._length); _length = v._length; } else { _buffer = v._buffer; _length = v._length; v._isCopy = true; } }
/** * Converts to a string builder */ public StringValue ToStringBuilder(Env env, StringValue value) { if (value.isUnicode()) { UnicodeBuilderValue sb = new UnicodeBuilderValue(this); value.appendTo(sb); return(sb); } else { BinaryBuilderValue v = new BinaryBuilderValue(this); value.appendTo(v); return(v); } }
/** * Append to a string builder. */ public StringValue appendTo(UnicodeBuilderValue sb) { if (length() == 0) { return(sb); } Env env = Env.getInstance(); try { Reader reader = env.getRuntimeEncodingFactory().create(toInputStream()); if (reader != null) { sb.append(reader); reader.close(); } return(sb); } catch (IOException e) { throw new QuercusRuntimeException(e); } }
/** * Append to a string builder. */ public override StringValue appendTo(UnicodeBuilderValue sb) { sb.append(_buffer, 0, _length); return(sb); }
/** * Append to a unicode builder. */ public override StringValue appendTo(UnicodeBuilderValue sb) { return(sb.append(_value)); }
/** * Append to a string builder. */ public override StringValue appendTo(UnicodeBuilderValue sb) { return(getValue().appendTo(sb)); }
/** * Append to a string builder. */ public override StringValue appendTo(UnicodeBuilderValue sb) { return(sb.append(ToString(Env.getInstance()))); }