• R/O
  • SSH
  • HTTPS

estocdb: Commit


Commit MetaInfo

Revisão27 (tree)
Hora2009-02-09 16:09:27
Autorshun_m

Mensagem de Log

add source comments

Mudança Sumário

Diff

--- trunk/src/estoc/dbm/DbmUtil.java (revision 26)
+++ trunk/src/estoc/dbm/DbmUtil.java (revision 27)
@@ -6,9 +6,19 @@
66 import java.sql.SQLException;
77 import java.util.Date;
88
9+/**
10+ * Util for estoc db
11+ */
912 public class DbmUtil {
1013 private static final Object[] EMPTY_ARRAY = new Object[0];
1114
15+ /**
16+ * to csv string
17+ * @param objects
18+ * @param sep Object separator
19+ * @param quote quoting String
20+ * @return string
21+ */
1222 public static String toCommaString(Object[] objects, String sep, String quote) {
1323 String qstr = "";
1424 if (quote != null) {
@@ -24,6 +34,15 @@
2434 return sb.toString();
2535 }
2636
37+
38+ /**
39+ * fill to TableObject from ResultSet
40+ * @param <T> Class
41+ * @param clz Table object
42+ * @param result ResultSet
43+ * @return filled object
44+ * @throws SQLException
45+ */
2746 public static <T> T fillData(Class<T> clz, ResultSet result) throws SQLException {
2847 try {
2948 T instance = clz.newInstance();
@@ -46,6 +65,13 @@
4665 }
4766 }
4867
68+
69+ /**
70+ * Set value to Field
71+ * @param obj target object
72+ * @param info target column
73+ * @param val set value
74+ */
4975 public static void setVlaueToField(Object obj, ColumnInfo info, Object val) {
5076 String setter = getSetterName(info.getName());
5177 try {
@@ -61,6 +87,12 @@
6187 }
6288 }
6389
90+ /**
91+ * Get value from Filed
92+ * @param obj target object
93+ * @param info target column
94+ * @return filed value
95+ */
6496 public static Object getVlaueFromField(Object obj, ColumnInfo info) {
6597 String getter = getGetterName(info.getName());
6698 Object rtn = null;
--- trunk/src/estoc/dbm/TableAccess.java (revision 26)
+++ trunk/src/estoc/dbm/TableAccess.java (revision 27)
@@ -13,15 +13,33 @@
1313 import estoc.dbm.annotate.Column;
1414 import estoc.dbm.annotate.Table;
1515
16+/**
17+ * Table access class <br>
18+ * create, drop
19+ */
1620 public abstract class TableAccess {
1721 private final static Logger LOG = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
1822
23+ /**
24+ * Drop table
25+ * @param clz Table class
26+ * @throws SQLException
27+ */
1928 public abstract void drop(Class<?> clz) throws SQLException;
2029
30+ /**
31+ * Create table
32+ * @param clz Table class
33+ * @throws SQLException
34+ */
2135 public abstract void create(Class<?> clz) throws SQLException;
2236
2337 private final Connection connection;
2438
39+ /**
40+ * constructor
41+ * @param connection JDBC connection
42+ */
2543 public TableAccess(Connection connection) {
2644 try {
2745 if (connection == null || connection.isClosed()) {
--- trunk/src/estoc/dbm/DbType.java (revision 26)
+++ trunk/src/estoc/dbm/DbType.java (revision 27)
@@ -1,9 +1,31 @@
11 package estoc.dbm;
22
3+/**
4+ * Define supported database types
5+ */
36 public enum DbType {
7+ /**
8+ * H2<br>
9+ * http://www.h2database.com/html/main.html
10+ */
411 H2,
12+ /**
13+ * Derby within JDK
14+ */
515 Derby,
16+ /**
17+ * Postgresql<br>
18+ * http://www.postgresql.org/
19+ */
620 Postgresql,
21+ /**
22+ * Mysql<br>
23+ * http://www.mysql.com/
24+ */
725 Mysql,
26+ /**
27+ * Oracle<br>
28+ * http://www.oracle.com/
29+ */
830 Oracle
931 }
--- trunk/src/estoc/dbm/annotate/AutoInc.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/AutoInc.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * auto increment column
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.FIELD)
1013 public @interface AutoInc {
--- trunk/src/estoc/dbm/annotate/TimeStamp.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/TimeStamp.java (revision 27)
@@ -6,7 +6,8 @@
66 import java.lang.annotation.Target;
77
88 /**
9- * Pkとの併用はできません
9+ * time stamp column
10+ * this can't use with <see>Pk</see>
1011 */
1112 @Retention(RetentionPolicy.RUNTIME)
1213 @Target(ElementType.FIELD)
--- trunk/src/estoc/dbm/annotate/Unique.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/Unique.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * unique column
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.FIELD)
1013 public @interface Unique {
--- trunk/src/estoc/dbm/annotate/Index.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/Index.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * index column
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.FIELD)
1013 public @interface Index {
--- trunk/src/estoc/dbm/annotate/Table.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/Table.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * Class as Table
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.TYPE)
1013 public @interface Table {
--- trunk/src/estoc/dbm/annotate/Pk.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/Pk.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * primary key column
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.FIELD)
1013 public @interface Pk {
--- trunk/src/estoc/dbm/annotate/NotNull.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/NotNull.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * not null column
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.FIELD)
1013 public @interface NotNull {
--- trunk/src/estoc/dbm/annotate/Column.java (revision 26)
+++ trunk/src/estoc/dbm/annotate/Column.java (revision 27)
@@ -5,6 +5,9 @@
55 import java.lang.annotation.RetentionPolicy;
66 import java.lang.annotation.Target;
77
8+/**
9+ * Field as Table column
10+ */
811 @Retention(RetentionPolicy.RUNTIME)
912 @Target(ElementType.FIELD)
1013 public @interface Column {
--- trunk/src/estoc/dbm/DataAccess.java (revision 26)
+++ trunk/src/estoc/dbm/DataAccess.java (revision 27)
@@ -2,12 +2,46 @@
22
33 import java.sql.SQLException;
44
5+/**
6+ * Data access class <br>
7+ * ex. select, delete, insert, update
8+ */
59 public interface DataAccess {
10+
11+
12+ /**
13+ * Select the record
14+ * @param <T> Class
15+ * @param clz Table object
16+ * @param pk conditions
17+ * @return selected record or null if record not found
18+ * @throws SQLException
19+ */
620 public abstract <T> T select(Class<T> clz, Object... params) throws SQLException;
721
22+ /**
23+ * Delete the record
24+ * @param obj TableClass
25+ * @return true: if success, false:faild
26+ * @throws SQLException
27+ */
828 public abstract boolean delete(Object obj) throws SQLException;
929
30+ /**
31+ * Insert the record
32+ * @param <T> Class
33+ * @param obj Table object
34+ * @return inserted record
35+ * @throws SQLException
36+ */
1037 public abstract <T> T insert(T obj) throws SQLException;
1138
39+ /**
40+ * Update the record
41+ * @param <T> Class
42+ * @param obj Table object
43+ * @return updated record
44+ * @throws SQLException
45+ */
1246 public abstract <T> T update(T obj) throws SQLException;
1347 }
\ No newline at end of file
--- trunk/src/estoc/dbm/AccessManager.java (revision 26)
+++ trunk/src/estoc/dbm/AccessManager.java (revision 27)
@@ -2,9 +2,16 @@
22
33 import java.sql.Connection;
44
5+/**
6+ * Database accesser factory
7+ */
58 public class AccessManager {
69 private final DbType dbType;
710
11+ /**
12+ * constructor
13+ * @param dbType the type of Database
14+ */
815 public AccessManager(DbType dbType) {
916 if (dbType == null) {
1017 throw new IllegalArgumentException();
@@ -12,6 +19,11 @@
1219 this.dbType = dbType;
1320 }
1421
22+ /**
23+ * get DataAccess object
24+ * @param connection JDBC connection
25+ * @return
26+ */
1527 public DataAccess getDataAccess(Connection connection) {
1628 SqlCreatorImpl creator = new SqlCreatorImpl();
1729 switch (dbType) {
@@ -31,6 +43,11 @@
3143 }
3244 }
3345
46+ /**
47+ * get TableAccess object
48+ * @param connection
49+ * @return
50+ */
3451 public TableAccess getTableAccess(Connection connection) {
3552 TableAccess tableAccess = null;
3653 switch (dbType) {
--- trunk/build.xml (revision 26)
+++ trunk/build.xml (revision 27)
@@ -1,8 +1,8 @@
11 <?xml version="1.0" encoding="Shift_JIS"?>
22
3-<project name="javahelloant" default="jar" basedir=".">
3+<project name="estocdb" default="jar" basedir=".">
44
5- <property name="release.version" value="0.3"/>
5+ <property name="release.version" value="0.4"/>
66
77 <!-- property -->
88 <property name="src.dir" value="src"/>
Show on old repository browser