JDK代码写法总结4Java
文章发布较早,内容可能过时,阅读注意甄别。
# 总结4
# 顶层Number类
public abstract class Number implements java.io.Serializable {
/**
* Returns the value of the specified number as an {@code int},
* which may involve rounding or truncation.
*
* @return the numeric value represented by this object after conversion
* to type {@code int}.
*/
public abstract int intValue();
/**
* Returns the value of the specified number as a {@code long},
* which may involve rounding or truncation.
*
* @return the numeric value represented by this object after conversion
* to type {@code long}.
*/
public abstract long longValue();
/**
* Returns the value of the specified number as a {@code float},
* which may involve rounding.
*
* @return the numeric value represented by this object after conversion
* to type {@code float}.
*/
public abstract float floatValue();
/**
* Returns the value of the specified number as a {@code double},
* which may involve rounding.
*
* @return the numeric value represented by this object after conversion
* to type {@code double}.
*/
public abstract double doubleValue();
/**
* Returns the value of the specified number as a {@code byte},
* which may involve rounding or truncation.
*
* <p>This implementation returns the result of {@link #intValue} cast
* to a {@code byte}.
*
* @return the numeric value represented by this object after conversion
* to type {@code byte}.
* @since JDK1.1
*/
public byte byteValue() {
return (byte)intValue();
}
/**
* Returns the value of the specified number as a {@code short},
* which may involve rounding or truncation.
*
* <p>This implementation returns the result of {@link #intValue} cast
* to a {@code short}.
*
* @return the numeric value represented by this object after conversion
* to type {@code short}.
* @since JDK1.1
*/
public short shortValue() {
return (short)intValue();
}
/** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = -8742448824652078965L;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# AtomicInteger原子类
public class AtomicInteger extends Number implements java.io.Serializable {
private static final long serialVersionUID = 6214790243416807050L;
// setup to use Unsafe.compareAndSwapInt for updates
private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final long valueOffset;
static {
try {
valueOffset = unsafe.objectFieldOffset
(AtomicInteger.class.getDeclaredField("value"));
} catch (Exception ex) { throw new Error(ex); }
}
private volatile int value;
/**
* Creates a new AtomicInteger with the given initial value.
*
* @param initialValue the initial value
*/
public AtomicInteger(int initialValue) {
value = initialValue;
}
/**
* Creates a new AtomicInteger with initial value {@code 0}.
*/
public AtomicInteger() {
}
/**
* Gets the current value.
*
* @return the current value
*/
public final int get() {
return value;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Math有正弦余弦等方法
public final class Math {
/**
* Don't let anyone instantiate this class.
*/
private Math() {}
/**
* The {@code double} value that is closer than any other to
* <i>e</i>, the base of the natural logarithms.
*/
public static final double E = 2.7182818284590452354;
/**
* The {@code double} value that is closer than any other to
* <i>pi</i>, the ratio of the circumference of a circle to its
* diameter.
*/
public static final double PI = 3.14159265358979323846;
/**
* Returns the trigonometric sine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
* result is NaN.
* <li>If the argument is zero, then the result is a zero with the
* same sign as the argument.</ul>
*
* <p>The computed result must be within 1 ulp of the exact result.
* Results must be semi-monotonic.
*
* @param a an angle, in radians.
* @return the sine of the argument.
*/
public static double sin(double a) {
return StrictMath.sin(a); // default impl. delegates to StrictMath
}
/**
* Returns the trigonometric cosine of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the
* result is NaN.</ul>
*
* <p>The computed result must be within 1 ulp of the exact result.
* Results must be semi-monotonic.
*
* @param a an angle, in radians.
* @return the cosine of the argument.
*/
public static double cos(double a) {
return StrictMath.cos(a); // default impl. delegates to StrictMath
}
/**
* Returns the trigonometric tangent of an angle. Special cases:
* <ul><li>If the argument is NaN or an infinity, then the result
* is NaN.
* <li>If the argument is zero, then the result is a zero with the
* same sign as the argument.</ul>
*
* <p>The computed result must be within 1 ulp of the exact result.
* Results must be semi-monotonic.
*
* @param a an angle, in radians.
* @return the tangent of the argument.
*/
public static double tan(double a) {
return StrictMath.tan(a); // default impl. delegates to StrictMath
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# SocketFactory抽象类
顶级抽象类
public abstract class SocketFactory {
private static SocketFactory theFactory;
protected SocketFactory() {
}
public static SocketFactory getDefault() {
Class var0 = SocketFactory.class;
synchronized(SocketFactory.class) {
if (theFactory == null) {
theFactory = new DefaultSocketFactory();
}
}
return theFactory;
}
public Socket createSocket() throws IOException {
UnsupportedOperationException var1 = new UnsupportedOperationException();
SocketException var2 = new SocketException("Unconnected sockets not implemented");
var2.initCause(var1);
throw var2;
}
public abstract Socket createSocket(String var1, int var2) throws IOException, UnknownHostException;
public abstract Socket createSocket(String var1, int var2, InetAddress var3, int var4) throws IOException, UnknownHostException;
public abstract Socket createSocket(InetAddress var1, int var2) throws IOException;
public abstract Socket createSocket(InetAddress var1, int var2, InetAddress var3, int var4) throws IOException;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 脚本工厂
public interface ScriptEngineFactory {
/**
* Returns the full name of the <code>ScriptEngine</code>. For
* instance an implementation based on the Mozilla Rhino Javascript engine
* might return <i>Rhino Mozilla Javascript Engine</i>.
* @return The name of the engine implementation.
*/
public String getEngineName();
/**
* Returns the version of the <code>ScriptEngine</code>.
* @return The <code>ScriptEngine</code> implementation version.
*/
public String getEngineVersion();
/**
* Returns an immutable list of filename extensions, which generally identify scripts
* written in the language supported by this <code>ScriptEngine</code>.
* The array is used by the <code>ScriptEngineManager</code> to implement its
* <code>getEngineByExtension</code> method.
* @return The list of extensions.
*/
public List<String> getExtensions();
/**
* Returns an immutable list of mimetypes, associated with scripts that
* can be executed by the engine. The list is used by the
* <code>ScriptEngineManager</code> class to implement its
* <code>getEngineByMimetype</code> method.
* @return The list of mime types.
*/
public List<String> getMimeTypes();
/**
* Returns an immutable list of short names for the <code>ScriptEngine</code>, which may be used to
* identify the <code>ScriptEngine</code> by the <code>ScriptEngineManager</code>.
* For instance, an implementation based on the Mozilla Rhino Javascript engine might
* return list containing {"javascript", "rhino"}.
* @return an immutable list of short names
*/
public List<String> getNames();
/**
* Returns the name of the scripting language supported by this
* <code>ScriptEngine</code>.
* @return The name of the supported language.
*/
public String getLanguageName();
/**
* Returns the version of the scripting language supported by this
* <code>ScriptEngine</code>.
* @return The version of the supported language.
*/
public String getLanguageVersion();
/**
* Returns the value of an attribute whose meaning may be implementation-specific.
* Keys for which the value is defined in all implementations are:
* <ul>
* <li>ScriptEngine.ENGINE</li>
* <li>ScriptEngine.ENGINE_VERSION</li>
* <li>ScriptEngine.LANGUAGE</li>
* <li>ScriptEngine.LANGUAGE_VERSION</li>
* <li>ScriptEngine.NAME</li>
* </ul>
* <p>
* The values for these keys are the Strings returned by <code>getEngineName</code>,
* <code>getEngineVersion</code>, <code>getLanguageName</code>,
* <code>getLanguageVersion</code> for the first four keys respectively. For NAME, one of the Strings
* returned by <code>getNames</code> is returned.<br><br>
* A reserved key, <code><b>THREADING</b></code>, whose value describes the behavior of the engine
* with respect to concurrent execution of scripts and maintenance of state is also defined.
* These values for the <code><b>THREADING</b></code> key are:<br><br>
* <ul>
* <li><code>null</code> - The engine implementation is not thread safe, and cannot
* be used to execute scripts concurrently on multiple threads.
* <li><code>"MULTITHREADED"</code> - The engine implementation is internally
* thread-safe and scripts may execute concurrently although effects of script execution
* on one thread may be visible to scripts on other threads.
* <li><code>"THREAD-ISOLATED"</code> - The implementation satisfies the requirements
* of "MULTITHREADED", and also, the engine maintains independent values
* for symbols in scripts executing on different threads.
* <li><code>"STATELESS"</code> - The implementation satisfies the requirements of
* <li><code>"THREAD-ISOLATED"</code>. In addition, script executions do not alter the
* mappings in the <code>Bindings</code> which is the engine scope of the
* <code>ScriptEngine</code>. In particular, the keys in the <code>Bindings</code>
* and their associated values are the same before and after the execution of the script.
* </ul>
* <br><br>
* Implementations may define implementation-specific keys.
*
* @param key The name of the parameter
* @return The value for the given parameter. Returns <code>null</code> if no
* value is assigned to the key.
*
*/
public Object getParameter(String key);
/**
* Returns a String which can be used to invoke a method of a Java object using the syntax
* of the supported scripting language. For instance, an implementation for a Javascript
* engine might be;
*
* <pre>{@code
* public String getMethodCallSyntax(String obj,
* String m, String... args) {
* String ret = obj;
* ret += "." + m + "(";
* for (int i = 0; i < args.length; i++) {
* ret += args[i];
* if (i < args.length - 1) {
* ret += ",";
* }
* }
* ret += ")";
* return ret;
* }
* } </pre>
* <p>
*
* @param obj The name representing the object whose method is to be invoked. The
* name is the one used to create bindings using the <code>put</code> method of
* <code>ScriptEngine</code>, the <code>put</code> method of an <code>ENGINE_SCOPE</code>
* <code>Bindings</code>,or the <code>setAttribute</code> method
* of <code>ScriptContext</code>. The identifier used in scripts may be a decorated form of the
* specified one.
*
* @param m The name of the method to invoke.
* @param args names of the arguments in the method call.
*
* @return The String used to invoke the method in the syntax of the scripting language.
*/
public String getMethodCallSyntax(String obj, String m, String... args);
/**
* Returns a String that can be used as a statement to display the specified String using
* the syntax of the supported scripting language. For instance, the implementation for a Perl
* engine might be;
*
* <pre><code>
* public String getOutputStatement(String toDisplay) {
* return "print(" + toDisplay + ")";
* }
* </code></pre>
*
* @param toDisplay The String to be displayed by the returned statement.
* @return The string used to display the String in the syntax of the scripting language.
*
*
*/
public String getOutputStatement(String toDisplay);
/**
* Returns a valid scripting language executable program with given statements.
* For instance an implementation for a PHP engine might be:
*
* <pre>{@code
* public String getProgram(String... statements) {
* String retval = "<?\n";
* int len = statements.length;
* for (int i = 0; i < len; i++) {
* retval += statements[i] + ";\n";
* }
* return retval += "?>";
* }
* }</pre>
*
* @param statements The statements to be executed. May be return values of
* calls to the <code>getMethodCallSyntax</code> and <code>getOutputStatement</code> methods.
* @return The Program
*/
public String getProgram(String... statements);
/**
* Returns an instance of the <code>ScriptEngine</code> associated with this
* <code>ScriptEngineFactory</code>. A new ScriptEngine is generally
* returned, but implementations may pool, share or reuse engines.
*
* @return A new <code>ScriptEngine</code> instance.
*/
public ScriptEngine getScriptEngine();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# 自定义注解
package jdk;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.PACKAGE})
@Exported
public @interface Exported {
boolean value() default true;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 底层用Map
public class SimpleBindings implements Bindings {
/**
* The <code>Map</code> field stores the attributes.
*/
private Map<String,Object> map;
/**
* Constructor uses an existing <code>Map</code> to store the values.
* @param m The <code>Map</code> backing this <code>SimpleBindings</code>.
* @throws NullPointerException if m is null
*/
public SimpleBindings(Map<String,Object> m) {
if (m == null) {
throw new NullPointerException();
}
this.map = m;
}
/**
* Default constructor uses a <code>HashMap</code>.
*/
public SimpleBindings() {
this(new HashMap<String,Object>());
}
/**
* Sets the specified key/value in the underlying <code>map</code> field.
*
* @param name Name of value
* @param value Value to set.
*
* @return Previous value for the specified key. Returns null if key was previously
* unset.
*
* @throws NullPointerException if the name is null.
* @throws IllegalArgumentException if the name is empty.
*/
public Object put(String name, Object value) {
checkKey(name);
return map.put(name,value);
}
/**
* <code>putAll</code> is implemented using <code>Map.putAll</code>.
*
* @param toMerge The <code>Map</code> of values to add.
*
* @throws NullPointerException
* if toMerge map is null or if some key in the map is null.
* @throws IllegalArgumentException
* if some key in the map is an empty String.
*/
public void putAll(Map<? extends String, ? extends Object> toMerge) {
if (toMerge == null) {
throw new NullPointerException("toMerge map is null");
}
for (Map.Entry<? extends String, ? extends Object> entry : toMerge.entrySet()) {
String key = entry.getKey();
checkKey(key);
put(key, entry.getValue());
}
}
/** {@inheritDoc} */
public void clear() {
map.clear();
}
/**
* Returns <tt>true</tt> if this map contains a mapping for the specified
* key. More formally, returns <tt>true</tt> if and only if
* this map contains a mapping for a key <tt>k</tt> such that
* <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be
* at most one such mapping.)
*
* @param key key whose presence in this map is to be tested.
* @return <tt>true</tt> if this map contains a mapping for the specified
* key.
*
* @throws NullPointerException if key is null
* @throws ClassCastException if key is not String
* @throws IllegalArgumentException if key is empty String
*/
public boolean containsKey(Object key) {
checkKey(key);
return map.containsKey(key);
}
/** {@inheritDoc} */
public boolean containsValue(Object value) {
return map.containsValue(value);
}
/** {@inheritDoc} */
public Set<Map.Entry<String, Object>> entrySet() {
return map.entrySet();
}
/**
* Returns the value to which this map maps the specified key. Returns
* <tt>null</tt> if the map contains no mapping for this key. A return
* value of <tt>null</tt> does not <i>necessarily</i> indicate that the
* map contains no mapping for the key; it's also possible that the map
* explicitly maps the key to <tt>null</tt>. The <tt>containsKey</tt>
* operation may be used to distinguish these two cases.
*
* <p>More formally, if this map contains a mapping from a key
* <tt>k</tt> to a value <tt>v</tt> such that <tt>(key==null ? k==null :
* key.equals(k))</tt>, then this method returns <tt>v</tt>; otherwise
* it returns <tt>null</tt>. (There can be at most one such mapping.)
*
* @param key key whose associated value is to be returned.
* @return the value to which this map maps the specified key, or
* <tt>null</tt> if the map contains no mapping for this key.
*
* @throws NullPointerException if key is null
* @throws ClassCastException if key is not String
* @throws IllegalArgumentException if key is empty String
*/
public Object get(Object key) {
checkKey(key);
return map.get(key);
}
/** {@inheritDoc} */
public boolean isEmpty() {
return map.isEmpty();
}
/** {@inheritDoc} */
public Set<String> keySet() {
return map.keySet();
}
/**
* Removes the mapping for this key from this map if it is present
* (optional operation). More formally, if this map contains a mapping
* from key <tt>k</tt> to value <tt>v</tt> such that
* <code>(key==null ? k==null : key.equals(k))</code>, that mapping
* is removed. (The map can contain at most one such mapping.)
*
* <p>Returns the value to which the map previously associated the key, or
* <tt>null</tt> if the map contained no mapping for this key. (A
* <tt>null</tt> return can also indicate that the map previously
* associated <tt>null</tt> with the specified key if the implementation
* supports <tt>null</tt> values.) The map will not contain a mapping for
* the specified key once the call returns.
*
* @param key key whose mapping is to be removed from the map.
* @return previous value associated with specified key, or <tt>null</tt>
* if there was no mapping for key.
*
* @throws NullPointerException if key is null
* @throws ClassCastException if key is not String
* @throws IllegalArgumentException if key is empty String
*/
public Object remove(Object key) {
checkKey(key);
return map.remove(key);
}
/** {@inheritDoc} */
public int size() {
return map.size();
}
/** {@inheritDoc} */
public Collection<Object> values() {
return map.values();
}
private void checkKey(Object key) {
if (key == null) {
throw new NullPointerException("key can not be null");
}
if (!(key instanceof String)) {
throw new ClassCastException("key should be a String");
}
if (key.equals("")) {
throw new IllegalArgumentException("key can not be empty");
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# 多级注解使用
@Exported
public interface JConsoleContext {
String CONNECTION_STATE_PROPERTY = "connectionState";
MBeanServerConnection getMBeanServerConnection();
JConsoleContext.ConnectionState getConnectionState();
void addPropertyChangeListener(PropertyChangeListener var1);
void removePropertyChangeListener(PropertyChangeListener var1);
@Exported
public static enum ConnectionState {
CONNECTED,
DISCONNECTED,
CONNECTING;
private ConnectionState() {
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 适配器类中增加Cache
public class JUnit4TestAdapter implements Test, Filterable, Orderable, Describable {
private final Class<?> fNewTestClass;
private final Runner fRunner;
private final JUnit4TestAdapterCache fCache;
public JUnit4TestAdapter(Class<?> newTestClass) {
this(newTestClass, JUnit4TestAdapterCache.getDefault());
}
public JUnit4TestAdapter(Class<?> newTestClass, JUnit4TestAdapterCache cache) {
this.fCache = cache;
this.fNewTestClass = newTestClass;
this.fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();
}
public int countTestCases() {
return this.fRunner.testCount();
}
public void run(TestResult result) {
this.fRunner.run(this.fCache.getNotifier(result, this));
}
public List<Test> getTests() {
return this.fCache.asTestList(this.getDescription());
}
public Class<?> getTestClass() {
return this.fNewTestClass;
}
public Description getDescription() {
Description description = this.fRunner.getDescription();
return this.removeIgnored(description);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 门面类
public class JUnit4TestCaseFacade implements Test, Describable {
private final Description fDescription;
JUnit4TestCaseFacade(Description description) {
this.fDescription = description;
}
public String toString() {
return this.getDescription().toString();
}
public int countTestCases() {
return 1;
}
public void run(TestResult result) {
throw new RuntimeException("This test stub created only for informational purposes.");
}
public Description getDescription() {
return this.fDescription;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24