11package effectivejava .chapter12 .item87 ;
22import java .io .*;
33
4- // StringList with a reasonable custom serialized form - Page 349
4+ // 코드 87-3 합리적인 커스텀 직렬화 형태를 갖춘 StringList (462-463쪽)
55public final class StringList implements Serializable {
66 private transient int size = 0 ;
77 private transient Entry head = null ;
88
9- // No longer Serializable!
9+ // 이제는 직렬화되지 않는다.
1010 private static class Entry {
1111 String data ;
1212 Entry next ;
1313 Entry previous ;
1414 }
1515
16- // Appends the specified string to the list
16+ // 지정한 문자열을 이 리스트에 추가한다.
1717 public final void add (String s ) { }
1818
1919 /**
20- * Serialize this {@code StringList} instance .
20+ * 이 {@code StringList} 인스턴스를 직렬화한다 .
2121 *
22- * @serialData The size of the list (the number of strings
23- * it contains) is emitted ({@code int}), followed by all of
24- * its elements (each a {@code String}), in the proper
25- * sequence.
22+ * @serialData 이 리스트의 크기(포함된 문자열의 개수)를 기록한 후
23+ * ({@code int}), 이어서 모든 원소를(각각은 {@code String})
24+ * 순서대로 기록한다.
2625 */
2726 private void writeObject (ObjectOutputStream s )
2827 throws IOException {
2928 s .defaultWriteObject ();
3029 s .writeInt (size );
3130
32- // Write out all elements in the proper order .
31+ // 모든 원소를 올바른 순서로 기록한다 .
3332 for (Entry e = head ; e != null ; e = e .next )
3433 s .writeObject (e .data );
3534 }
@@ -39,10 +38,10 @@ private void readObject(ObjectInputStream s)
3938 s .defaultReadObject ();
4039 int numElements = s .readInt ();
4140
42- // Read in all elements and insert them in list
41+ // 모든 원소를 읽어 이 리스트에 삽입한다.
4342 for (int i = 0 ; i < numElements ; i ++)
4443 add ((String ) s .readObject ());
4544 }
4645
47- // Remainder omitted
46+ // 나머지 코드는 생략
4847}
0 commit comments