Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e986434a
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e986434a
编写于
7月 31, 2009
作者:
K
Keith Donald
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moved collection utilities to util
上级
4bf3a9c9
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
255 addition
and
23 deletion
+255
-23
org.springframework.core/src/main/java/org/springframework/core/collection/package-info.java
...ava/org/springframework/core/collection/package-info.java
+0
-6
org.springframework.core/src/main/java/org/springframework/util/CompositeIterator.java
...main/java/org/springframework/util/CompositeIterator.java
+3
-5
org.springframework.core/src/main/java/org/springframework/util/SharedMap.java
...ore/src/main/java/org/springframework/util/SharedMap.java
+3
-4
org.springframework.core/src/main/java/org/springframework/util/SharedMapDecorator.java
...ain/java/org/springframework/util/SharedMapDecorator.java
+3
-3
org.springframework.core/src/main/java/org/springframework/util/StringKeyedMapAdapter.java
.../java/org/springframework/util/StringKeyedMapAdapter.java
+3
-4
org.springframework.core/src/test/java/org/springframework/util/CompositeIteratorTests.java
...java/org/springframework/util/CompositeIteratorTests.java
+98
-0
org.springframework.core/src/test/java/org/springframework/util/SharedMapDecoratorTests.java
...ava/org/springframework/util/SharedMapDecoratorTests.java
+62
-0
org.springframework.core/src/test/java/org/springframework/util/StringKeyedMapAdapterTests.java
.../org/springframework/util/StringKeyedMapAdapterTests.java
+82
-0
org.springframework.web/src/main/java/org/springframework/web/context/request/NativeWebRequestParameterMap.java
...ork/web/context/request/NativeWebRequestParameterMap.java
+1
-1
未找到文件。
org.springframework.core/src/main/java/org/springframework/core/collection/package-info.java
已删除
100644 → 0
浏览文件 @
4bf3a9c9
/**
* Collection extensions used in the framework.
*/
package
org.springframework.core.collection
;
org.springframework.core/src/main/java/org/springframework/
core/collection
/CompositeIterator.java
→
org.springframework.core/src/main/java/org/springframework/
util
/CompositeIterator.java
浏览文件 @
e986434a
...
...
@@ -13,18 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.
core.collection
;
package
org.springframework.
util
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.NoSuchElementException
;
import
org.springframework.util.Assert
;
/**
* Iterator that combines multiple other iterators.
This is a simple implementation that just maintains a list of
*
iterators which are invoked in sequence until
l all iterators are exhausted.
* Iterator that combines multiple other iterators.
*
This implementation maintains a list of iterators which are invoked in sequence unti
l all iterators are exhausted.
* @author Erwin Vervaet
*/
public
class
CompositeIterator
<
E
>
implements
Iterator
<
E
>
{
...
...
org.springframework.core/src/main/java/org/springframework/
core/collection
/SharedMap.java
→
org.springframework.core/src/main/java/org/springframework/
util
/SharedMap.java
浏览文件 @
e986434a
...
...
@@ -13,16 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.
core.collection
;
package
org.springframework.
util
;
import
java.util.Map
;
/**
* A simple subinterface of {@link Map} that exposes a mutex that application code can synchronize on.
* <p>
* Expected to be implemented by Maps that are backed by shared objects that require synchronization between multiple
* threads. An example would be the HTTP session map.
*
* Expected to be implemented by Maps that are backed by shared objects that require synchronization between multiple threads.
* An example would be the HTTP session map.
* @author Keith Donald
*/
public
interface
SharedMap
<
K
,
V
>
extends
Map
<
K
,
V
>
{
...
...
org.springframework.core/src/main/java/org/springframework/
core/collection
/SharedMapDecorator.java
→
org.springframework.core/src/main/java/org/springframework/
util
/SharedMapDecorator.java
浏览文件 @
e986434a
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.
core.collection
;
package
org.springframework.
util
;
import
java.io.Serializable
;
import
java.util.Collection
;
...
...
@@ -23,9 +23,9 @@ import java.util.Set;
import
org.springframework.core.style.ToStringCreator
;
/**
* A map decorator that implements <code>SharedMap</code>. By default, simply returns the map itself as the mutex.
* A map decorator that implements <code>SharedMap</code>.
* By default, simply returns the map itself as the mutex.
* Subclasses may override to return a different mutex object.
*
* @author Keith Donald
*/
@SuppressWarnings
(
"serial"
)
...
...
org.springframework.core/src/main/java/org/springframework/
core/collection
/StringKeyedMapAdapter.java
→
org.springframework.core/src/main/java/org/springframework/
util
/StringKeyedMapAdapter.java
浏览文件 @
e986434a
...
...
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.
core.collection
;
package
org.springframework.
util
;
import
java.util.AbstractSet
;
import
java.util.Collection
;
...
...
@@ -23,9 +23,8 @@ import java.util.NoSuchElementException;
import
java.util.Set
;
/**
* Base class for map adapters whose keys are String values. Concrete classes need only implement the abstract hook
* methods defined by this class.
*
* Base class for map adapters whose keys are String values.
* Concrete classes need only implement the abstract hook methods defined by this class.
* @author Keith Donald
*/
public
abstract
class
StringKeyedMapAdapter
<
V
>
implements
Map
<
String
,
V
>
{
...
...
org.springframework.core/src/test/java/org/springframework/util/CompositeIteratorTests.java
0 → 100644
浏览文件 @
e986434a
package
org.springframework.util
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.NoSuchElementException
;
import
junit.framework.TestCase
;
/**
* Test case for {@link CompositeIterator}.
*
* @author Erwin Vervaet
*/
public
class
CompositeIteratorTests
extends
TestCase
{
public
void
testNoIterators
()
{
CompositeIterator
it
=
new
CompositeIterator
();
assertFalse
(
it
.
hasNext
());
try
{
it
.
next
();
fail
();
}
catch
(
NoSuchElementException
e
)
{
// expected
}
}
public
void
testSingleIterator
()
{
CompositeIterator
it
=
new
CompositeIterator
();
it
.
add
(
Arrays
.
asList
(
new
String
[]
{
"0"
,
"1"
}).
iterator
());
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
assertTrue
(
it
.
hasNext
());
assertEquals
(
String
.
valueOf
(
i
),
it
.
next
());
}
assertFalse
(
it
.
hasNext
());
try
{
it
.
next
();
fail
();
}
catch
(
NoSuchElementException
e
)
{
// expected
}
}
public
void
testMultipleIterators
()
{
CompositeIterator
it
=
new
CompositeIterator
();
it
.
add
(
Arrays
.
asList
(
new
String
[]
{
"0"
,
"1"
}).
iterator
());
it
.
add
(
Arrays
.
asList
(
new
String
[]
{
"2"
}).
iterator
());
it
.
add
(
Arrays
.
asList
(
new
String
[]
{
"3"
,
"4"
}).
iterator
());
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
assertTrue
(
it
.
hasNext
());
assertEquals
(
String
.
valueOf
(
i
),
it
.
next
());
}
assertFalse
(
it
.
hasNext
());
try
{
it
.
next
();
fail
();
}
catch
(
NoSuchElementException
e
)
{
// expected
}
}
public
void
testInUse
()
{
List
list
=
Arrays
.
asList
(
new
String
[]
{
"0"
,
"1"
});
CompositeIterator
it
=
new
CompositeIterator
();
it
.
add
(
list
.
iterator
());
it
.
hasNext
();
try
{
it
.
add
(
list
.
iterator
());
fail
();
}
catch
(
IllegalStateException
e
)
{
// expected
}
it
=
new
CompositeIterator
();
it
.
add
(
list
.
iterator
());
it
.
next
();
try
{
it
.
add
(
list
.
iterator
());
fail
();
}
catch
(
IllegalStateException
e
)
{
// expected
}
}
public
void
testDuplicateIterators
()
{
List
list
=
Arrays
.
asList
(
new
String
[]
{
"0"
,
"1"
});
Iterator
iterator
=
list
.
iterator
();
CompositeIterator
it
=
new
CompositeIterator
();
it
.
add
(
iterator
);
it
.
add
(
list
.
iterator
());
try
{
it
.
add
(
iterator
);
fail
();
}
catch
(
IllegalArgumentException
e
)
{
// expected
}
}
}
org.springframework.core/src/test/java/org/springframework/util/SharedMapDecoratorTests.java
0 → 100644
浏览文件 @
e986434a
package
org.springframework.util
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
junit.framework.TestCase
;
/**
* Unit tests for {@link org.springframework.binding.collection.SharedMapDecorator}.
*/
public
class
SharedMapDecoratorTests
extends
TestCase
{
private
SharedMapDecorator
map
=
new
SharedMapDecorator
(
new
HashMap
());
public
void
testGetPutRemove
()
{
assertTrue
(
map
.
size
()
==
0
);
assertTrue
(
map
.
isEmpty
());
assertNull
(
map
.
get
(
"foo"
));
assertFalse
(
map
.
containsKey
(
"foo"
));
map
.
put
(
"foo"
,
"bar"
);
assertTrue
(
map
.
size
()
==
1
);
assertFalse
(
map
.
isEmpty
());
assertNotNull
(
map
.
get
(
"foo"
));
assertTrue
(
map
.
containsKey
(
"foo"
));
assertTrue
(
map
.
containsValue
(
"bar"
));
assertEquals
(
"bar"
,
map
.
get
(
"foo"
));
map
.
remove
(
"foo"
);
assertTrue
(
map
.
size
()
==
0
);
assertNull
(
map
.
get
(
"foo"
));
}
public
void
testPutAll
()
{
Map
all
=
new
HashMap
();
all
.
put
(
"foo"
,
"bar"
);
all
.
put
(
"bar"
,
"baz"
);
map
.
putAll
(
all
);
assertTrue
(
map
.
size
()
==
2
);
}
public
void
testEntrySet
()
{
map
.
put
(
"foo"
,
"bar"
);
map
.
put
(
"bar"
,
"baz"
);
Set
entrySet
=
map
.
entrySet
();
assertTrue
(
entrySet
.
size
()
==
2
);
}
public
void
testKeySet
()
{
map
.
put
(
"foo"
,
"bar"
);
map
.
put
(
"bar"
,
"baz"
);
Set
keySet
=
map
.
keySet
();
assertTrue
(
keySet
.
size
()
==
2
);
}
public
void
testValues
()
{
map
.
put
(
"foo"
,
"bar"
);
map
.
put
(
"bar"
,
"baz"
);
Collection
values
=
map
.
values
();
assertTrue
(
values
.
size
()
==
2
);
}
}
org.springframework.core/src/test/java/org/springframework/util/StringKeyedMapAdapterTests.java
0 → 100644
浏览文件 @
e986434a
package
org.springframework.util
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
junit.framework.TestCase
;
/**
* Unit tests for {@link org.springframework.binding.collection.StringKeyedMapAdapter}.
*/
public
class
StringKeyedMapAdapterTests
extends
TestCase
{
private
Map
contents
=
new
HashMap
();
private
StringKeyedMapAdapter
map
=
new
StringKeyedMapAdapter
()
{
protected
Object
getAttribute
(
String
key
)
{
return
contents
.
get
(
key
);
}
protected
Iterator
getAttributeNames
()
{
return
contents
.
keySet
().
iterator
();
}
protected
void
removeAttribute
(
String
key
)
{
contents
.
remove
(
key
);
}
protected
void
setAttribute
(
String
key
,
Object
value
)
{
contents
.
put
(
key
,
value
);
}
};
public
void
testGetPutRemove
()
{
assertTrue
(
map
.
size
()
==
0
);
assertTrue
(
map
.
isEmpty
());
assertNull
(
map
.
get
(
"foo"
));
assertFalse
(
map
.
containsKey
(
"foo"
));
map
.
put
(
"foo"
,
"bar"
);
assertTrue
(
map
.
size
()
==
1
);
assertFalse
(
map
.
isEmpty
());
assertNotNull
(
map
.
get
(
"foo"
));
assertTrue
(
map
.
containsKey
(
"foo"
));
assertTrue
(
map
.
containsValue
(
"bar"
));
assertEquals
(
"bar"
,
map
.
get
(
"foo"
));
map
.
remove
(
"foo"
);
assertTrue
(
map
.
size
()
==
0
);
assertNull
(
map
.
get
(
"foo"
));
}
public
void
testPutAll
()
{
Map
all
=
new
HashMap
();
all
.
put
(
"foo"
,
"bar"
);
all
.
put
(
"bar"
,
"baz"
);
map
.
putAll
(
all
);
assertTrue
(
map
.
size
()
==
2
);
}
public
void
testEntrySet
()
{
map
.
put
(
"foo"
,
"bar"
);
map
.
put
(
"bar"
,
"baz"
);
Set
entrySet
=
map
.
entrySet
();
assertTrue
(
entrySet
.
size
()
==
2
);
}
public
void
testKeySet
()
{
map
.
put
(
"foo"
,
"bar"
);
map
.
put
(
"bar"
,
"baz"
);
Set
keySet
=
map
.
keySet
();
assertTrue
(
keySet
.
size
()
==
2
);
}
public
void
testValues
()
{
map
.
put
(
"foo"
,
"bar"
);
map
.
put
(
"bar"
,
"baz"
);
Collection
values
=
map
.
values
();
assertTrue
(
values
.
size
()
==
2
);
}
}
org.springframework.web/src/main/java/org/springframework/web/context/request/NativeWebRequestParameterMap.java
浏览文件 @
e986434a
...
...
@@ -17,8 +17,8 @@ package org.springframework.web.context.request;
import
java.util.Iterator
;
import
org.springframework.core.collection.StringKeyedMapAdapter
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringKeyedMapAdapter
;
/**
* Map backed by a Web request parameter map for accessing request parameters.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录