3
* ====================================================================
4
* Licensed to the Apache Software Foundation (ASF) under one
5
* or more contributor license agreements. See the NOTICE file
6
* distributed with this work for additional information
7
* regarding copyright ownership. The ASF licenses this file
8
* to you under the Apache License, Version 2.0 (the
9
* "License"); you may not use this file except in compliance
10
* with the License. You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing,
15
* software distributed under the License is distributed on an
16
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
* KIND, either express or implied. See the License for the
18
* specific language governing permissions and limitations
20
* ====================================================================
27
#include "jni_list.hpp"
29
#include "svn_private_config.h"
33
// Class Java::BaseImmutableList
35
const char* const BaseImmutableList::m_class_name = "java/util/List";
37
BaseImmutableList::ClassImpl::ClassImpl(Env env, jclass cls)
38
: Object::ClassImpl(env, cls),
39
m_mid_size(env.GetMethodID(cls, "size", "()I")),
40
m_mid_get(env.GetMethodID(cls, "get", "(I)Ljava/lang/Object;")),
41
m_mid_add(env.GetMethodID(cls, "add", "(Ljava/lang/Object;)Z")),
42
m_mid_clear(env.GetMethodID(cls, "clear", "()V")),
43
m_mid_iter(env.GetMethodID(cls, "listIterator", "()Ljava/util/ListIterator;"))
46
BaseImmutableList::ClassImpl::~ClassImpl() {}
48
jobject BaseImmutableList::operator[](jint index) const
52
return m_env.CallObjectMethod(m_jthis, impl().m_mid_get, index);
54
catch (const SignalExceptionThrown&)
56
// Just rethrow if it's not an IndexOutOfBoundsException.
57
if (!m_env.IsInstanceOf(
58
m_env.ExceptionOccurred(),
59
ClassCache::get_exc_index_out_of_bounds(m_env)->get_class()))
62
m_env.ExceptionClear();
63
std::string msg(_("List index out of bounds: "));
65
throw std::out_of_range(msg.c_str());
69
BaseImmutableList::Iterator BaseImmutableList::get_iterator() const
71
return Iterator(m_env, m_env.CallObjectMethod(m_jthis, impl().m_mid_iter));
74
// Class Java::BaseList
76
const char* const BaseList::m_class_name = "java/util/ArrayList";
78
BaseList::ClassImpl::ClassImpl(Env env, jclass cls)
79
: BaseImmutableList::ClassImpl(env, cls),
80
m_mid_ctor(env.GetMethodID(cls, "<init>", "(I)V"))
83
BaseList::ClassImpl::~ClassImpl() {}