/**
   * Returns a view of the portion of this list between the specified <tt>fromIndex</tt>, inclusive,
   * and <tt>toIndex</tt>, exclusive. (If <tt>fromIndex</tt> and <tt>toIndex</tt> are equal, the
   * returned list is empty.)
   *
   * @param fromIndex low endpoint (inclusive) of the subList
   * @param toIndex high endpoint (exclusive) of the subList
   * @return a view of the specified range within this list
   */
  public BaseItem subList(int fromIndex, int toIndex) {
    BaseItem newInstance = getNewList(false);
    if (fromIndex < 0) {
      fromIndex += size;
    }
    if (toIndex > size() || toIndex == 0) {
      toIndex = size();
    }
    if (fromIndex < 0 || fromIndex > toIndex) {
      return newInstance;
    }

    while (fromIndex < toIndex) {
      newInstance.with(get(fromIndex++));
    }
    return newInstance;
  }
  public Object getValue(Object key) {
    int pos = indexOf(key);
    if (pos >= 0) {
      if ((flag & MAP) == MAP) {
        return this.getByIndex(SMALL_VALUE, pos + index, size);
      }
      return this.getByIndex(SMALL_KEY, pos, size);
    }
    if (!(key instanceof String)) {
      return null;
    }
    String keyString = "" + key;
    int len = 0;
    int end = 0;
    int id = 0;
    for (; len < keyString.length(); len++) {
      char temp = keyString.charAt(len);
      if (temp == '[') {
        for (end = len + 1; end < keyString.length(); end++) {
          temp = keyString.charAt(end);
          if (keyString.charAt(end) == ']') {
            end++;
            break;
          } else if (temp > 47 && temp < 58 && id >= 0) {
            id = id * 10 + temp - 48;
          } else if (temp == 'L') {
            id = -2;
          }
        }
        if (end == keyString.length()) {
          end = 0;
        }
        break;
      } else if (temp == '.') {
        end = len;
        id = -1;
        break;
      }
    }
    if (end == 0 && len == keyString.length()) {
      id = -1;
    }

    Object child = getByIndex(SMALL_VALUE, indexOf(keyString.substring(0, len)) + this.index, size);
    if (child != null) {
      if (end == 0) {
        if (id >= 0 || id == -2) {
          if (child instanceof AbstractList<?>) {
            AbstractList<?> list = (AbstractList<?>) child;
            if (id == -2) {
              id = list.size() - 1;
            }
            if (list.size() >= id) {
              return list.get(id);
            }
          }
        } else {
          return child;
        }
      } else {
        if (id >= 0 || id == -2) {
          if (child instanceof AbstractArray) {
            if (end == len + 2) {
              // Get List
              BaseItem result = this.getNewList(true);
              AbstractList<?> items = (AbstractList<?>) child;
              for (int z = 0; z < items.size(); z++) {
                result.with(
                    ((AbstractList<?>) items.get(z)).getValue(keyString.substring(end + 1)));
              }
              return result;
            }
            AbstractList<?> list = (AbstractList<?>) child;
            if (id == -2) {
              id = list.size() - 1;
            }
            if (list.size() >= id) {
              return ((SimpleKeyValueList<?, ?>) list.get(id))
                  .getValue(keyString.substring(end + 1));
            }
          }
        } else if (child instanceof SimpleKeyValueList<?, ?>) {
          return ((SimpleKeyValueList<?, ?>) child).getValue(keyString.substring(end + 1));
        }
      }
    }
    return null;
  }