Skip to content

Commit 75931a8

Browse files
author
veryben
committed
重新格式化所有java代码
1 parent 6941700 commit 75931a8

32 files changed

+7957
-9011
lines changed

src/main/java/org/csource/common/Base64.java

Lines changed: 408 additions & 456 deletions
Large diffs are not rendered by default.
Lines changed: 118 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,131 @@
11
/**
2-
* Copyright (C) 2008 Happy Fish / YuQing
3-
*
4-
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
5-
* General Public License (LGPL).
6-
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
7-
**/
2+
* Copyright (C) 2008 Happy Fish / YuQing
3+
* <p>
4+
* FastDFS Java Client may be copied only under the terms of the GNU Lesser
5+
* General Public License (LGPL).
6+
* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
7+
**/
88

99
package org.csource.common;
1010

1111
import java.io.*;
12-
import java.util.*;
13-
import org.csource.common.*;
12+
import java.util.ArrayList;
13+
import java.util.Hashtable;
1414

1515
/**
16-
* ini file reader / parser
17-
* @author Happy Fish / YuQing
18-
* @version Version 1.0
19-
*/
20-
public class IniFileReader
21-
{
22-
private Hashtable paramTable;
23-
private String conf_filename;
16+
* ini file reader / parser
17+
*
18+
* @author Happy Fish / YuQing
19+
* @version Version 1.0
20+
*/
21+
public class IniFileReader {
22+
private Hashtable paramTable;
23+
private String conf_filename;
24+
25+
/**
26+
* @param conf_filename config filename
27+
*/
28+
public IniFileReader(String conf_filename) throws FileNotFoundException, IOException {
29+
this.conf_filename = conf_filename;
30+
loadFromFile(conf_filename);
31+
}
2432

25-
/**
26-
* @param conf_filename config filename
27-
*/
28-
public IniFileReader(String conf_filename) throws FileNotFoundException, IOException
29-
{
30-
this.conf_filename = conf_filename;
31-
loadFromFile(conf_filename);
32-
}
33+
private static ClassLoader classLoader() {
34+
ClassLoader loader = Thread.currentThread().getContextClassLoader();
35+
if (loader == null) {
36+
loader = ClassLoader.getSystemClassLoader();
37+
}
38+
return loader;
39+
}
3340

34-
/**
35-
* get the config filename
36-
* @return config filename
37-
*/
38-
public String getConfFilename()
39-
{
40-
return this.conf_filename;
41-
}
41+
/**
42+
* get the config filename
43+
*
44+
* @return config filename
45+
*/
46+
public String getConfFilename() {
47+
return this.conf_filename;
48+
}
4249

43-
/**
44-
* get string value from config file
45-
* @param name item name in config file
46-
* @return string value
47-
*/
48-
public String getStrValue(String name)
49-
{
50-
Object obj;
51-
obj = this.paramTable.get(name);
52-
if (obj == null)
53-
{
54-
return null;
55-
}
56-
57-
if (obj instanceof String)
58-
{
59-
return (String)obj;
60-
}
61-
62-
return (String)((ArrayList)obj).get(0);
63-
}
50+
/**
51+
* get string value from config file
52+
*
53+
* @param name item name in config file
54+
* @return string value
55+
*/
56+
public String getStrValue(String name) {
57+
Object obj;
58+
obj = this.paramTable.get(name);
59+
if (obj == null) {
60+
return null;
61+
}
6462

65-
/**
66-
* get int value from config file
67-
* @param name item name in config file
68-
* @param default_value the default value
69-
* @return int value
70-
*/
71-
public int getIntValue(String name, int default_value)
72-
{
73-
String szValue = this.getStrValue(name);
74-
if (szValue == null)
75-
{
76-
return default_value;
77-
}
78-
79-
return Integer.parseInt(szValue);
80-
}
63+
if (obj instanceof String) {
64+
return (String) obj;
65+
}
8166

82-
/**
83-
* get boolean value from config file
84-
* @param name item name in config file
85-
* @param default_value the default value
86-
* @return boolean value
87-
*/
88-
public boolean getBoolValue(String name, boolean default_value)
89-
{
90-
String szValue = this.getStrValue(name);
91-
if (szValue == null)
92-
{
93-
return default_value;
94-
}
95-
96-
return szValue.equalsIgnoreCase("yes") || szValue.equalsIgnoreCase("on") ||
97-
szValue.equalsIgnoreCase("true") || szValue.equals("1");
98-
}
67+
return (String) ((ArrayList) obj).get(0);
68+
}
9969

100-
/**
101-
* get all values from config file
102-
* @param name item name in config file
103-
* @return string values (array)
104-
*/
105-
public String[] getValues(String name)
106-
{
107-
Object obj;
108-
String[] values;
109-
110-
obj = this.paramTable.get(name);
111-
if (obj == null)
112-
{
113-
return null;
114-
}
115-
116-
if (obj instanceof String)
117-
{
118-
values = new String[1];
119-
values[0] = (String)obj;
120-
return values;
121-
}
122-
123-
Object[] objs = ((ArrayList)obj).toArray();
124-
values = new String[objs.length];
125-
System.arraycopy(objs, 0, values, 0, objs.length);
126-
return values;
127-
}
70+
/**
71+
* get int value from config file
72+
*
73+
* @param name item name in config file
74+
* @param default_value the default value
75+
* @return int value
76+
*/
77+
public int getIntValue(String name, int default_value) {
78+
String szValue = this.getStrValue(name);
79+
if (szValue == null) {
80+
return default_value;
81+
}
82+
83+
return Integer.parseInt(szValue);
84+
}
85+
86+
/**
87+
* get boolean value from config file
88+
*
89+
* @param name item name in config file
90+
* @param default_value the default value
91+
* @return boolean value
92+
*/
93+
public boolean getBoolValue(String name, boolean default_value) {
94+
String szValue = this.getStrValue(name);
95+
if (szValue == null) {
96+
return default_value;
97+
}
98+
99+
return szValue.equalsIgnoreCase("yes") || szValue.equalsIgnoreCase("on") ||
100+
szValue.equalsIgnoreCase("true") || szValue.equals("1");
101+
}
102+
103+
/**
104+
* get all values from config file
105+
*
106+
* @param name item name in config file
107+
* @return string values (array)
108+
*/
109+
public String[] getValues(String name) {
110+
Object obj;
111+
String[] values;
112+
113+
obj = this.paramTable.get(name);
114+
if (obj == null) {
115+
return null;
116+
}
117+
118+
if (obj instanceof String) {
119+
values = new String[1];
120+
values[0] = (String) obj;
121+
return values;
122+
}
123+
124+
Object[] objs = ((ArrayList) obj).toArray();
125+
values = new String[objs.length];
126+
System.arraycopy(objs, 0, values, 0, objs.length);
127+
return values;
128+
}
128129

129130
private void loadFromFile(String confFilePath) throws IOException {
130131
InputStream in = null;
@@ -144,7 +145,7 @@ private void loadFromFile(String confFilePath) throws IOException {
144145
ex.printStackTrace();
145146
} finally {
146147
try {
147-
if(in != null) in.close();
148+
if (in != null) in.close();
148149
//System.out.println("loadFrom...finally...in.close(); done");
149150
} catch (Exception ex) {
150151
ex.printStackTrace();
@@ -193,21 +194,13 @@ private void readToParamTable(InputStream in) throws IOException {
193194
ex.printStackTrace();
194195
} finally {
195196
try {
196-
if(bufferedReader != null) bufferedReader.close();
197-
if(inReader != null) inReader.close();
197+
if (bufferedReader != null) bufferedReader.close();
198+
if (inReader != null) inReader.close();
198199
//System.out.println("readToParamTable...finally...bufferedReader.close();inReader.close(); done");
199200
} catch (Exception ex) {
200201
ex.printStackTrace();
201202
}
202203
}
203204
}
204205

205-
private static ClassLoader classLoader() {
206-
ClassLoader loader = Thread.currentThread().getContextClassLoader();
207-
if (loader == null) {
208-
loader = ClassLoader.getSystemClassLoader();
209-
}
210-
return loader;
211-
}
212-
213206
}

src/main/java/org/csource/common/MyException.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@
99
package org.csource.common;
1010

1111
/**
12-
* My Exception
13-
* @author Happy Fish / YuQing
14-
* @version Version 1.0
15-
*/
16-
public class MyException extends Exception
17-
{
18-
public MyException()
19-
{
20-
}
21-
22-
public MyException(String message)
23-
{
24-
super(message);
25-
}
12+
* My Exception
13+
*
14+
* @author Happy Fish / YuQing
15+
* @version Version 1.0
16+
*/
17+
public class MyException extends Exception {
18+
public MyException() {
19+
}
20+
21+
public MyException(String message) {
22+
super(message);
23+
}
2624
}

src/main/java/org/csource/common/NameValuePair.java

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,40 @@
99
package org.csource.common;
1010

1111
/**
12-
* name(key) and value pair model
13-
* @author Happy Fish / YuQing
14-
* @version Version 1.0
15-
*/
16-
public class NameValuePair
17-
{
18-
protected String name;
19-
protected String value;
20-
21-
public NameValuePair()
22-
{
23-
}
24-
25-
public NameValuePair(String name)
26-
{
27-
this.name = name;
28-
}
29-
30-
public NameValuePair(String name, String value)
31-
{
32-
this.name = name;
33-
this.value = value;
34-
}
35-
36-
public String getName()
37-
{
38-
return this.name;
39-
}
40-
41-
public String getValue()
42-
{
43-
return this.value;
44-
}
45-
46-
public void setName(String name)
47-
{
48-
this.name = name;
49-
}
50-
51-
public void setValue(String value)
52-
{
53-
this.value = value;
54-
}
12+
* name(key) and value pair model
13+
*
14+
* @author Happy Fish / YuQing
15+
* @version Version 1.0
16+
*/
17+
public class NameValuePair {
18+
protected String name;
19+
protected String value;
20+
21+
public NameValuePair() {
22+
}
23+
24+
public NameValuePair(String name) {
25+
this.name = name;
26+
}
27+
28+
public NameValuePair(String name, String value) {
29+
this.name = name;
30+
this.value = value;
31+
}
32+
33+
public String getName() {
34+
return this.name;
35+
}
36+
37+
public void setName(String name) {
38+
this.name = name;
39+
}
40+
41+
public String getValue() {
42+
return this.value;
43+
}
44+
45+
public void setValue(String value) {
46+
this.value = value;
47+
}
5548
}

0 commit comments

Comments
 (0)