• R/O
  • SSH
  • HTTPS

wolf-desktop: コミット


コミットメタ情報

リビジョン380 (tree)
日時2016-06-14 17:12:50
作者l_v_yonsama

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- Libraries/Common/src/hiro/yoshioka/util/FileUtil.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/util/FileUtil.java (revision 380)
@@ -70,7 +70,7 @@
7070 if (name == null) {
7171 return name;
7272 }
73- return name.replaceAll("[\\\\/:*?\"<>|]", replacement);
73+ return StringUtil.stripInvalidFileNameCharacter(name);
7474 }
7575
7676 public static boolean existsAndReadableFile(File[] files) {
--- Libraries/Common/src/hiro/yoshioka/util/ImageUtil.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/util/ImageUtil.java (revision 380)
@@ -25,6 +25,7 @@
2525 public static final String ACTION_38_SHOW_SESSION = "action/38show_session.gif";
2626 public static final String ACTION_39_CANSEL = "action/39cancel.gif";
2727 public static final String ACTION_42_BACK = "action/42back.gif";
28+ public static final String ACTION_42_TEST_RUNNER = "action/42open_sqt_editor.gif";
2829 public static final String ACTION_43_GO = "action/43go.gif";
2930
3031 public static final String ACTION_52_reflect = "action/52reflect.gif";
@@ -97,6 +98,7 @@
9798
9899 putImage(ACTION_80_LOCK);
99100 putImage(ACTION_42_BACK);
101+ //putImage(ACTION_42_TEST_RUNNER);
100102 putImage(ACTION_43_GO);
101103
102104 putImage(ACTION_52_reflect);
--- Libraries/Common/src/hiro/yoshioka/util/SQLUtil.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/util/SQLUtil.java (revision 380)
@@ -100,6 +100,12 @@
100100 return null;
101101 }
102102 return String.format("%tF", new java.util.Date(tt.getTime()));
103+ case TIME:
104+ return String.valueOf(st.getTime(idx));
105+ case INTEGER:
106+ return String.valueOf(st.getInt(idx));
107+ case FLOAT:
108+ return String.valueOf(st.getFloat(idx));
103109 case DECIMAL:
104110 case NUMERIC:
105111 BigDecimal decimal = st.getBigDecimal(idx);
@@ -211,6 +217,7 @@
211217 // 3/17/2005 18:40:21
212218 // json:2011-09-16T00:25:40.827+0000
213219 value = value.replaceAll("T", StringUtil.HALF_SPACE__STRING);
220+ value = value.replaceAll("Z", StringUtil.EMPTY_STRING);
214221 value = value.replaceAll("\\+[0-9]+", StringUtil.EMPTY_STRING);
215222 if (ignoreHHMMSS) {
216223 value = value.replaceAll("\\s*\\d+:\\d+:\\d+(\\.[0-9]+)?\\s*",
--- Libraries/Common/src/hiro/yoshioka/util/StringUtil.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/util/StringUtil.java (revision 380)
@@ -1,8 +1,12 @@
11 package hiro.yoshioka.util;
22
3+import java.io.UnsupportedEncodingException;
4+import java.net.URLDecoder;
5+import java.net.URLEncoder;
36 import java.nio.charset.Charset;
47 import java.text.DecimalFormat;
58 import java.util.ArrayList;
9+import java.util.Arrays;
610 import java.util.Calendar;
711 import java.util.Collection;
812 import java.util.Collections;
@@ -46,12 +50,45 @@
4650 }
4751
4852 public static void main(String[] args) {
49- char[] dic = { 'a', 'b', 'c', 'd', '0', '/' };
50- for (int i = 0; i < 500; i++) {
51- System.out.println("[" + i + "]=" + convertRadix(i, dic));
53+ System.out
54+ .println(stripInvalidFileNameCharacter("あいうえ/<>おじょ%\"#$$#\"%\"'(にゃん.pdf"));
55+ }
56+
57+ /**
58+ * 指定した文字列が半角文字のみか判断する
59+ *
60+ * @param source
61+ * 対象文字列
62+ * @return trueなら半角文字のみ 空の場合は常にtrueとなる
63+ */
64+ public static boolean isHankakuOnly(String source) {
65+ if (source == null || source.equals("")) {
66+ return true;
5267 }
68+ String regText = "[ -~。-゚]+";
69+ Pattern pattern = Pattern.compile(regText);
70+ return pattern.matcher(source).matches();
5371 }
5472
73+ public static String stripInvalidFileNameCharacter(String name) {
74+ if (StringUtil.isEmpty(name)) {
75+ return StringUtil.EMPTY_STRING;
76+ }
77+ name = name.replaceAll(" ", "_");
78+ StringBuffer sb = new StringBuffer();
79+ String ignore = "/\\:*?\"<>|#{}%&,~";
80+ for (int i = 0; i < name.length(); i++) {
81+ String c = String.valueOf(name.charAt(i));
82+ if (ignore.indexOf(c) >= 0) {
83+ // ignore
84+ } else {
85+ sb.append(c);
86+ }
87+ }
88+
89+ return sb.toString();
90+ }
91+
5592 /**
5693 * charactors = { 'a', 'b', 'c', 'd', '0', '/' };<BR>
5794 * l = {0,16}<BR>
@@ -77,6 +114,43 @@
77114 return ret.toString();
78115 }
79116
117+ public static String convertNumToColString(int col) {
118+ // Excel counts column A as the 1st column, we
119+ // treat it as the 0th one
120+ int excelColNum = col + 1;
121+
122+ String colRef = "";
123+ int colRemain = excelColNum;
124+
125+ while (colRemain > 0) {
126+ int thisPart = colRemain % 26;
127+ if (thisPart == 0) {
128+ thisPart = 26;
129+ }
130+ colRemain = (colRemain - thisPart) / 26;
131+
132+ // The letter A is at 65
133+ char colChar = (char) (thisPart + 64);
134+ colRef = colChar + colRef;
135+ }
136+
137+ return colRef;
138+ }
139+
140+ public static String toHankaku(String value) {
141+ StringBuilder sb = new StringBuilder(value);
142+ for (int i = 0; i < sb.length(); i++) {
143+ int c = (int) sb.charAt(i);
144+ if ((c >= 0xFF10 && c <= 0xFF19) || (c >= 0xFF21 && c <= 0xFF3A)
145+ || (c >= 0xFF41 && c <= 0xFF5A)) {
146+ sb.setCharAt(i, (char) (c - 0xFEE0));
147+ }
148+ }
149+ value = sb.toString().replaceAll("(", "(").replaceAll(")", ")");
150+
151+ return value;
152+ }
153+
80154 public static void append(StringBuilder buf, String text) {
81155 buf.append(text);
82156 }
@@ -162,6 +236,17 @@
162236 }
163237 }
164238
239+ public static String first(Iterable<String> ite) {
240+ if (ite == null) {
241+ return null;
242+ }
243+ Iterator<String> i = ite.iterator();
244+ if (i.hasNext()) {
245+ return i.next();
246+ }
247+ return null;
248+ }
249+
165250 public static int parseIntNoneException(String num) {
166251 return parseIntNoneException(num, 0);
167252 }
@@ -302,6 +387,65 @@
302387 return string == null ? EMPTY_STRING : string.toString();
303388 }
304389
390+ public static String toUnixLikeDate(java.util.Date date) {
391+ if (date == null) {
392+ return StringUtil.EMPTY_STRING;
393+ }
394+ Calendar cal = GregorianCalendar.getInstance();
395+ Calendar targetCal = GregorianCalendar.getInstance();
396+ targetCal.setTime(date);
397+ if (cal.get(Calendar.YEAR) == targetCal.get(Calendar.YEAR)) {
398+ return String.format("%tm/%1$td(%1$ta)", date);
399+ } else if (cal.get(Calendar.MONTH) == targetCal.get(Calendar.MONTH)) {
400+ return String.format("%tm/%1$td(%1$ta)", date);
401+ } else if (cal.get(Calendar.DAY_OF_MONTH) == targetCal
402+ .get(Calendar.DAY_OF_MONTH)) {
403+ return String.format("%tH:%1$tM:%1$tS", date);
404+ } else {
405+ return String.format("%tY/%1$tm/%1$td", date);
406+ }
407+ }
408+
409+ /**
410+ * 年月日 曜日の形式で文字列化
411+ */
412+ public static String toYmdEDate(Calendar cal) {
413+ if (cal == null) {
414+ return StringUtil.EMPTY_STRING;
415+ }
416+ return toYmdEDate(cal.getTime());
417+ }
418+
419+ /**
420+ * 年月日 曜日の形式で文字列化
421+ */
422+ public static String toYmdEDate(java.util.Date date) {
423+ if (date == null) {
424+ return StringUtil.EMPTY_STRING;
425+ }
426+ return String.format("%1$ty-%1$tm-%1$td(%1$ta)", date);
427+ }
428+
429+ /**
430+ * 月日時分の形式で文字列化
431+ */
432+ public static String toMDHMDate(Calendar cal) {
433+ if (cal == null) {
434+ return StringUtil.EMPTY_STRING;
435+ }
436+ return toYmdEDate(cal.getTime());
437+ }
438+
439+ /**
440+ * 年月時分の形式で文字列化
441+ */
442+ public static String toMDHMDate(java.util.Date date) {
443+ if (date == null) {
444+ return StringUtil.EMPTY_STRING;
445+ }
446+ return String.format("%1$tm-%1$td %1$tH:%1$tM", date);
447+ }
448+
305449 public static String getShortenDate(java.util.Date date) {
306450 Calendar cal = GregorianCalendar.getInstance();
307451 Calendar targetCal = GregorianCalendar.getInstance();
@@ -337,6 +481,10 @@
337481 return s;
338482 }
339483
484+ public static String join(String[] strings, String separator) {
485+ return join(Arrays.asList(strings), separator);
486+ }
487+
340488 public static String join(Collection collection, String separator) {
341489 if (collection == null || collection.size() == 0) {
342490 return StringUtil.EMPTY_STRING;
@@ -426,6 +574,9 @@
426574 }
427575
428576 public static String escName(String str) {
577+ if (str == null) {
578+ return StringUtil.EMPTY_STRING;
579+ }
429580 // ●「<」→「&lt;」
430581 // ●「&」→「&amp;」
431582 // ●「>」→「&gt;」
@@ -471,6 +622,9 @@
471622 }
472623
473624 public static String esc(String str) {
625+ if (str == null) {
626+ return StringUtil.EMPTY_STRING;
627+ }
474628 // ●「<」→「&lt;」
475629 // ●「&」→「&amp;」
476630 // ●「>」→「&gt;」
@@ -504,11 +658,30 @@
504658 return buf.toString();
505659 }
506660
661+ public static final String url_encode(String target) {
662+ try {
663+ return URLEncoder.encode(target, "UTF8");
664+ } catch (UnsupportedEncodingException e) {
665+ return target;
666+ }
667+ }
668+
669+ public static final String url_decode(String target) {
670+ try {
671+ return URLDecoder.decode(target, "UTF8");
672+ } catch (UnsupportedEncodingException e) {
673+ return target;
674+ }
675+ }
676+
507677 public static String getThisLineSeparator(String text) {
508678 return LineSeparatorEnum.getThisLineSeparator(text).getLineSeparator();
509679 }
510680
511681 public static String[] getLines(String text) {
682+ if (text == null) {
683+ return new String[0];
684+ }
512685 return text.split("\r\n|\r|\n");
513686 }
514687
--- Libraries/Common/src/hiro/yoshioka/sdh/CSVRecordDataHolder.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/sdh/CSVRecordDataHolder.java (revision 380)
@@ -195,6 +195,7 @@
195195 clones[i] = (StringRecordData) data[i].clone();
196196 }
197197 fBackUpMap.put(new Integer(row), clones);
198+ System.out.println("generate backup : " + row);
198199 }
199200 }
200201
@@ -313,7 +314,7 @@
313314 addRow((StringRecordData[]) null);
314315 }
315316 try {
316- createBackUp(from + i);
317+ createBackUp(from + myrow);
317318 } catch (CloneNotSupportedException e) {
318319 log.fatal(StringUtil.EMPTY_STRING, e);
319320 return false;
--- Libraries/Common/src/hiro/yoshioka/sdh/diff/DiffToResultSetDataHolder.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/sdh/diff/DiffToResultSetDataHolder.java (revision 380)
@@ -1,5 +1,7 @@
11 package hiro.yoshioka.sdh.diff;
22
3+import java.io.Serializable;
4+
35 import hiro.yoshioka.sdh.StringRecordDataHolder;
46 import hiro.yoshioka.sdh.pair.DifferenceStringData;
57 import hiro.yoshioka.sdh.pair.FlashStringData;
@@ -8,7 +10,8 @@
810 import org.apache.commons.logging.Log;
911 import org.apache.commons.logging.LogFactory;
1012
11-public class DiffToResultSetDataHolder {
13+public class DiffToResultSetDataHolder implements Serializable {
14+ private static final long serialVersionUID = -7381587115369066139L;
1215 protected Log fLogger = LogFactory.getLog(getClass());
1316 int[] fDifferenceKeys;
1417
@@ -42,6 +45,14 @@
4245 public StringRecordDataHolder getRightTarget() {
4346 return fRightTarget;
4447 }
48+
49+ public void setLeftTarget(StringRecordDataHolder fLeftTarget) {
50+ this.fLeftTarget = fLeftTarget;
51+ }
52+
53+ public void setRightTarget(StringRecordDataHolder fRightTarget) {
54+ this.fRightTarget = fRightTarget;
55+ }
4556
4657 public void diffConfigure(StringRecordDataHolder targetLeft,
4758 StringRecordDataHolder targetRight, int[] matchKeys) {
--- Libraries/Common/src/hiro/yoshioka/sdh/DatabaseType.java (revision 379)
+++ Libraries/Common/src/hiro/yoshioka/sdh/DatabaseType.java (revision 380)
@@ -65,6 +65,10 @@
6565 this.driverPattern = driverPattern;
6666 this.driverName = driverName;
6767 }
68+
69+ public static void main(String[] args) {
70+ System.out.println(" result ==" + POSTGRES.getDatabaseNameByUrl("jdbc:postgresql://localhost:5432/cda_taiyo"));
71+ }
6872
6973 public static DatabaseType parse(String str) {
7074 if (StringUtil.isEmpty(str)) {
@@ -250,6 +254,17 @@
250254 }
251255 return false;
252256 }
257+
258+ public String getDatabaseNameByUrl(String jdbc_url){
259+ if(StringUtil.isEmpty(jdbc_url)){
260+ return null;
261+ }
262+ switch(this){
263+ case POSTGRES:
264+ return jdbc_url.replaceFirst("jdbc:postgresql://[0-9a-zA-Z:_-]+/([^?]+)\\??.*", "$1");
265+ }
266+ return null;
267+ }
253268
254269 public boolean needsColumnNameQuote(String col_name) {
255270 switch (this) {
旧リポジトリブラウザで表示