• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision144 (tree)
Time2015-11-17 23:03:24
Authort_nakayama1971

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/framework/fwBase/src/core/file/ZippedLineOutputStream.java (revision 143)
+++ trunk/framework/fwBase/src/core/file/ZippedLineOutputStream.java (revision 144)
@@ -1,20 +1,16 @@
11 package core.file;
22
3-import java.io.FilterOutputStream;
43 import java.io.IOException;
54 import java.io.OutputStream;
65 import java.nio.charset.Charset;
7-
86 import java.util.zip.ZipEntry;
97 import java.util.zip.ZipOutputStream;
108
11-import core.config.Factory;
12-
139 /**
1410 * 改行テキスト出力(Zip)
1511 * @author Tadashi Nakayama
1612 */
17-public final class ZippedLineOutputStream extends FilterOutputStream {
13+public final class ZippedLineOutputStream extends ZipOutputStream {
1814
1915 /** ページ内最大数 */
2016 private int line = -1;
@@ -28,6 +24,8 @@
2824 private int prev = 0;
2925 /** ページタイトル */
3026 private byte[] title;
27+ /** タイトル出力フラグ */
28+ private boolean titleFlg;
3129
3230 /**
3331 * コンストラクタ
@@ -34,7 +32,7 @@
3432 * @param os OutputStream
3533 */
3634 public ZippedLineOutputStream(final OutputStream os) {
37- super(getZipOutputStream(os));
35+ super(os);
3836 }
3937
4038 /**
@@ -43,28 +41,24 @@
4341 * @param val Charset
4442 */
4543 public ZippedLineOutputStream(final OutputStream os, final Charset val) {
46- super(getZipOutputStream(os, val));
44+ super(os, val);
4745 }
4846
4947 /**
50- * ZipOutputStream取得
51- * @param os OutputStream
52- * @return ZipOutputStream
48+ * @see java.io.FilterOutputStream#write(byte[])
5349 */
54- private static ZipOutputStream getZipOutputStream(final OutputStream os) {
55- return Factory.construct(Factory.getConstructor(
56- ZipOutputStream.class, OutputStream.class), os);
50+ @Override
51+ public void write(final byte[] b) throws IOException {
52+ throw new UnsupportedOperationException();
5753 }
5854
5955 /**
60- * ZipOutputStream取得
61- * @param os OutputStream
62- * @param val Charset
63- * @return ZipOutputStream
56+ * @see java.util.zip.ZipOutputStream#write(byte[], int, int)
6457 */
65- private static ZipOutputStream getZipOutputStream(final OutputStream os, final Charset val) {
66- return Factory.construct(Factory.getConstructor(
67- ZipOutputStream.class, OutputStream.class, Charset.class), os, val);
58+ @Override
59+ public synchronized void write(
60+ final byte[] b, final int off, final int len) throws IOException {
61+ throw new UnsupportedOperationException();
6862 }
6963
7064 /**
@@ -73,9 +67,9 @@
7367 @Override
7468 public void write(final int b) throws IOException {
7569 if (this.line == this.count) {
76- putNextEntry(true);
70+ putNextEntry(getEntry(true));
7771 } else if (!hasEntry()) {
78- putNextEntry(false);
72+ putNextEntry(getEntry(false));
7973 }
8074
8175 super.out.write(b);
@@ -120,25 +114,27 @@
120114 * エントリ終了
121115 * @throws IOException IO例外
122116 */
117+ @Override
123118 public void finish() throws IOException {
124119 if (hasEntry()) {
125- getZipStream().closeEntry();
126- getZipStream().finish();
120+ super.closeEntry();
121+ super.finish();
127122 }
128123 }
129124
130125 /**
131126 * エントリ設定
132- * @param flg タイトル出力フラグ
127+ * @param ze ZipEntry
133128 * @throws IOException IO例外
134129 */
135- public void putNextEntry(final boolean flg) throws IOException {
130+ @Override
131+ public void putNextEntry(final ZipEntry ze) throws IOException {
136132 if (hasEntry()) {
137- getZipStream().closeEntry();
133+ super.closeEntry();
138134 }
139135
140- getZipStream().putNextEntry(getEntry(this.entries));
141- outputTitle(flg);
136+ super.putNextEntry(ze);
137+ outputTitle();
142138
143139 this.count = 0;
144140 this.entries++;
@@ -146,11 +142,10 @@
146142
147143 /**
148144 * タイトル出力
149- * @param flg タイトル出力フラグ
150145 * @throws IOException IO例外
151146 */
152- private void outputTitle(final boolean flg) throws IOException {
153- if (this.title != null && flg) {
147+ private void outputTitle() throws IOException {
148+ if (this.title != null && this.titleFlg) {
154149 super.out.write(this.title);
155150 }
156151 }
@@ -164,25 +159,18 @@
164159 }
165160
166161 /**
167- * ZipOutputStream取得
168- * @return ZipOutputStream
169- */
170- private ZipOutputStream getZipStream() {
171- return ZipOutputStream.class.cast(super.out);
172- }
173-
174- /**
175162 * ZipEntry取得
176- * @param entry エントリ数
163+ * @param flg タイトル出力フラグ
177164 * @return ZipEntry
178165 */
179- private ZipEntry getEntry(final int entry) {
166+ public ZipEntry getEntry(final boolean flg) {
167+ this.titleFlg = flg;
180168 String str = this.name;
181169 int loc = str.lastIndexOf('.');
182170 if (0 <= loc) {
183- str = str.substring(0, loc).trim() + addEntry(entry) + str.substring(loc);
171+ str = str.substring(0, loc).trim() + addEntry(this.entries) + str.substring(loc);
184172 } else {
185- str = str + addEntry(entry);
173+ str = str + addEntry(this.entries);
186174 }
187175 return new ZipEntry(str);
188176 }
--- trunk/framework/pjCom/src/project/common/file/CsvPageBreakOutputStream.java (revision 143)
+++ trunk/framework/pjCom/src/project/common/file/CsvPageBreakOutputStream.java (revision 144)
@@ -110,7 +110,7 @@
110110 }
111111 if (entry != null) {
112112 getZipStream().setEntryName(entry);
113- getZipStream().putNextEntry(true);
113+ getZipStream().putNextEntry(getZipStream().getEntry(true));
114114 }
115115 }
116116