Skip to content

Commit d07cf9e

Browse files
committed
1.5.3 更新(谨慎更新)
1. 压缩到76K 2. 因为混淆压缩的问题,内部枚举类无法使用,导致1.5.3以及以后版本将枚举类从内部类调整出来成为独立的类,因此你的代码里如果用到里PrimaryK ey.AssignType, Mapping.Relation, Conflict.Strategy,那么package包名需要重新引入一下,带来不便,敬请见谅。
1 parent d64d1ec commit d07cf9e

30 files changed

+154
-93
lines changed

jars/jar使用和混淆注意.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#Orm混淆建议:
2+
# 1. 给你要持久化的每一个Java(Model)类设置一个表名:即为类添加@Table("table_name")注解。
3+
# 2. 给你要持久化的每一个属性(成员变量)设置一个列名: 即为属性加@Column("column_name")注解。
4+
# 满足1、2则可以将你要持久化的类和者属性随意混淆;
5+
# 反之,则需要将你要持久化的类和属性keep住,不可混淆。
6+
7+
另外,枚举和注解、签名要keep:
8+
# 使用注解
9+
-keepattributes *Annotation*,Signature,Exceptions
10+
11+
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
12+
-keepclassmembers enum * {
13+
**[] $VALUES;
14+
public *;
15+
}
16+
17+
使用1.5.3mini以及更新的版本请注意:
18+
因为混淆压缩的问题,内部枚举类无法使用,导致1.5.3以及以后版本将枚举类从内部类调整出来成为独立的类,因此你的代码里如果用到里PrimaryKey.AssignType, Mapping.Relation, Conflict.Strategy,那么package包名需要重新引入一下,带来不便,敬请见谅。

jars/lite-orm-1.5.2.jar

1.59 KB
Binary file not shown.

jars/lite-orm-1.5.3-mini.jar

74.7 KB
Binary file not shown.

library/AndroidManifest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.litesuits.orm"
4-
android:versionCode="152"
5-
android:versionName="1.5.2">
4+
android:versionCode="16"
5+
android:versionName="1.5.3">
66
<uses-sdk android:minSdkVersion="3"/>
77

88
<!-- db文件在sd卡:在SDCard中创建与删除文件权限 -->

library/proguard-android-optimize.txt

+32-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
1-
# 使用注解
2-
-keepattributes *Annotation*,Signature
1+
#Orm混淆建议:
2+
# 1. 给你要持久化的每一个Java(Model)类设置一个表名:即为类添加@Table("table_name")注解。
3+
# 2. 给你要持久化的每一个属性(成员变量)设置一个列名: 即为属性加@Column("column_name")注解。
4+
# 满足1、2则可以将你要持久化的类和者属性随意混淆;
5+
# 反之,则需要将你要持久化的类和属性keep住,不可混淆。
36

4-
# 保持混淆时类的实名及行号(--------------- 调试时打开 --------------)
5-
-keepattributes SourceFile,LineNumberTable
7+
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
8+
-optimizationpasses 5
9+
-allowaccessmodification
10+
-dontpreverify
11+
12+
# The remainder of this file is identical to the non-optimized version
13+
# of the Proguard configuration file (except that the other file has
14+
# flags to turn off optimization).
15+
16+
-dontusemixedcaseclassnames
17+
-dontskipnonpubliclibraryclasses
18+
-verbose
619

7-
# 枚举需要keep see http://proguard.sourceforge.net/manual/examples.html#enumerations
20+
# 使用注解
21+
-keepattributes *Annotation*,Signature,Exceptions
22+
23+
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
824
-keepclassmembers enum * {
925
**[] $VALUES;
1026
public *;
1127
}
1228

13-
#Orm混淆建议:
14-
# 1. 给你要持久化的每一个Java(Model)类设置一个表名:即为类添加@Table("table_name")注解。
15-
# 2. 给你要持久化的每一个属性(成员变量)设置一个列名: 即为属性加@Column("column_name")注解。
16-
# 满足1、2则可以将你要持久化的类和者属性随意混淆;
17-
# 反之,则需要将你要持久化的类和属性keep住,不可混淆。
29+
# 保持混淆时类的实名及行号(--------------- 调试时打开 --------------)
30+
#-keepattributes SourceFile,LineNumberTable
31+
32+
# 开发者需要调用,不可以混淆
33+
-keep public class com.litesuits.orm.LiteOrm { *; }
34+
-keep public class com.litesuits.orm.db.* { *; }
35+
-keep public class com.litesuits.orm.db.model.** { *; }
36+
-keep public class com.litesuits.orm.db.annotation.** { *; }
37+
-keep public class com.litesuits.orm.db.enums.** { *; }
38+
-keep public class com.litesuits.orm.log.* { *; }
39+
-keep public class com.litesuits.orm.db.assit.* { *; }

library/src/com/litesuits/orm/LiteOrm.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ public void setDebugged(boolean debugged) {
129129
}
130130

131131
@Override
132-
public ArrayList<Relation> queryRelation(Class class1, Class class2, List<String> key1List, List<String> key2List) {
132+
public ArrayList<RelationKey> queryRelation(Class class1, Class class2, List<String> key1List, List<String> key2List) {
133133
acquireReference();
134134
try {
135135
SQLStatement stmt = SQLBuilder.buildQueryRelationSql(class1, class2, key1List, key2List);
136136
final EntityTable table1 = TableManager.getTable(class1);
137137
final EntityTable table2 = TableManager.getTable(class2);
138-
final ArrayList<Relation> list = new ArrayList<Relation>();
138+
final ArrayList<RelationKey> list = new ArrayList<RelationKey>();
139139
Querier.doQuery(mHelper.getReadableDatabase(), stmt, new Querier.CursorParser() {
140140
@Override
141141
public void parseEachCursor(SQLiteDatabase db, Cursor c) throws Exception {
142-
Relation relation = new Relation();
142+
RelationKey relation = new RelationKey();
143143
relation.key1 = c.getString(c.getColumnIndex(table1.name));
144144
relation.key2 = c.getString(c.getColumnIndex(table2.name));
145145
list.add(relation);
@@ -393,7 +393,7 @@ private <E, T> boolean keepMapping(Collection<E> col1,
393393
}
394394
}
395395
}
396-
ArrayList<Relation> mapList = queryRelation(claxx1, claxx2, key1List, null);
396+
ArrayList<RelationKey> mapList = queryRelation(claxx1, claxx2, key1List, null);
397397
if (!Checker.isEmpty(mapList)) {
398398
HashMap<String, Object> map2 = new HashMap<String, Object>();
399399
// 构建第2个对象的value映射
@@ -405,7 +405,7 @@ private <E, T> boolean keepMapping(Collection<E> col1,
405405
}
406406
}
407407
}
408-
for (Relation m : mapList) {
408+
for (RelationKey m : mapList) {
409409
Object obj1 = map1.get(m.key1);
410410
Object obj2 = map2.get(m.key2);
411411
if (obj1 != null && obj2 != null) {

library/src/com/litesuits/orm/db/DataBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.litesuits.orm.db.impl.SQLiteHelper;
88
import com.litesuits.orm.db.model.ColumnsValue;
99
import com.litesuits.orm.db.model.ConflictAlgorithm;
10-
import com.litesuits.orm.db.model.Relation;
10+
import com.litesuits.orm.db.model.RelationKey;
1111

1212
import java.io.File;
1313
import java.util.ArrayList;
@@ -240,7 +240,7 @@ public interface DataBase {
240240
*
241241
* @return the relation list of class1 and class2;
242242
*/
243-
ArrayList<Relation> queryRelation(Class class1, Class class2, List<String> key1List,
243+
ArrayList<RelationKey> queryRelation(Class class1, Class class2, List<String> key1List,
244244
List<String> key2List);
245245

246246
/**

library/src/com/litesuits/orm/db/TableManager.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import android.database.Cursor;
55
import android.database.sqlite.SQLiteDatabase;
6-
import com.litesuits.orm.log.OrmLog;
76
import com.litesuits.orm.db.annotation.Column;
87
import com.litesuits.orm.db.annotation.Mapping;
98
import com.litesuits.orm.db.annotation.PrimaryKey;
@@ -12,10 +11,12 @@
1211
import com.litesuits.orm.db.assit.Querier;
1312
import com.litesuits.orm.db.assit.SQLBuilder;
1413
import com.litesuits.orm.db.assit.Transaction;
14+
import com.litesuits.orm.db.enums.AssignType;
1515
import com.litesuits.orm.db.impl.SQLStatement;
1616
import com.litesuits.orm.db.model.*;
1717
import com.litesuits.orm.db.utils.DataUtil;
1818
import com.litesuits.orm.db.utils.FieldUtil;
19+
import com.litesuits.orm.log.OrmLog;
1920

2021
import java.lang.reflect.Field;
2122
import java.util.ArrayList;
@@ -428,12 +429,12 @@ public static synchronized EntityTable getTable(Class<?> claxx, boolean needPK)
428429
if (p.field.getType() == String.class) {
429430
// 主键移除属性Map
430431
table.pmap.remove(col);
431-
table.key = new Primarykey(p, PrimaryKey.AssignType.BY_MYSELF);
432+
table.key = new Primarykey(p, AssignType.BY_MYSELF);
432433
break;
433434
} else if (FieldUtil.isNumber(p.field.getType())) {
434435
// 主键移除属性Map
435436
table.pmap.remove(col);
436-
table.key = new Primarykey(p, PrimaryKey.AssignType.AUTO_INCREMENT);
437+
table.key = new Primarykey(p, AssignType.AUTO_INCREMENT);
437438
break;
438439
}
439440

@@ -458,14 +459,14 @@ private static void checkPrimaryKey(Primarykey key) {
458459
if (key.isAssignedBySystem()) {
459460
if (!FieldUtil.isNumber(key.field.getType())) {
460461
throw new RuntimeException(
461-
PrimaryKey.AssignType.AUTO_INCREMENT
462+
AssignType.AUTO_INCREMENT
462463
+ " Auto increment primary key must be a number ...\n " +
463464
"错误提示:自增主键必须设置为数字类型");
464465
}
465466
} else if (key.isAssignedByMyself()) {
466467
if (String.class != key.field.getType() && !FieldUtil.isNumber(key.field.getType())) {
467468
throw new RuntimeException(
468-
PrimaryKey.AssignType.BY_MYSELF
469+
AssignType.BY_MYSELF
469470
+ " Custom primary key must be string or number ...\n " +
470471
"错误提示:自定义主键值必须为String或者Number类型");
471472
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.litesuits.orm.db.annotation;
22

3+
import com.litesuits.orm.db.enums.Strategy;
4+
35
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
57

@@ -9,22 +11,4 @@
911
@Retention(RetentionPolicy.RUNTIME)
1012
public @interface Conflict {
1113
public Strategy value();
12-
13-
public static enum Strategy {
14-
ROLLBACK(" ROLLBACK "),
15-
ABORT(" ABORT "),
16-
FAIL(" FAIL "),
17-
IGNORE(" IGNORE "),
18-
REPLACE(" REPLACE ");
19-
20-
Strategy(String sql) {
21-
this.sql = sql;
22-
}
23-
24-
public String sql;
25-
26-
public String getSql() {
27-
return sql;
28-
}
29-
}
3014
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.litesuits.orm.db.annotation;
22

3+
import com.litesuits.orm.db.enums.Relation;
4+
35
import java.lang.annotation.ElementType;
46
import java.lang.annotation.Retention;
57
import java.lang.annotation.RetentionPolicy;
@@ -14,12 +16,5 @@
1416
@Target(ElementType.FIELD)
1517
@Retention(RetentionPolicy.RUNTIME)
1618
public @interface Mapping {
17-
public Relation value();
18-
19-
public static enum Relation {
20-
ManyToMany,
21-
OneToMany,
22-
ManyToOne,
23-
OneToOne
24-
}
19+
Relation value();
2520
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.litesuits.orm.db.annotation;
22

3+
import com.litesuits.orm.db.enums.AssignType;
4+
35
import java.lang.annotation.ElementType;
46
import java.lang.annotation.Retention;
57
import java.lang.annotation.RetentionPolicy;
@@ -17,21 +19,5 @@
1719
@Target(ElementType.FIELD)
1820
@Retention(RetentionPolicy.RUNTIME)
1921
public @interface PrimaryKey {
20-
public AssignType value();
21-
22-
/**
23-
* @author MaTianyu
24-
* @date 2014-08-16
25-
*/
26-
enum AssignType {
27-
/**
28-
* 主键值自己来指定。
29-
*/
30-
BY_MYSELF,
31-
/**
32-
* 主键值由系统分配,系统将使用自动递增整数赋值给主键。
33-
* 系统将从1开始递增分配,每次在上一条最大ID上+1 。
34-
*/
35-
AUTO_INCREMENT
36-
}
22+
AssignType value();
3723
}

library/src/com/litesuits/orm/db/assit/SQLBuilder.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import android.util.SparseArray;
44
import com.litesuits.orm.db.TableManager;
55
import com.litesuits.orm.db.annotation.*;
6-
import com.litesuits.orm.db.annotation.PrimaryKey;
6+
import com.litesuits.orm.db.enums.AssignType;
77
import com.litesuits.orm.db.impl.SQLStatement;
88
import com.litesuits.orm.db.model.*;
99
import com.litesuits.orm.db.model.MapInfo.MapTable;
@@ -12,7 +12,10 @@
1212
import com.litesuits.orm.db.utils.FieldUtil;
1313

1414
import java.lang.reflect.Field;
15-
import java.util.*;
15+
import java.util.ArrayList;
16+
import java.util.Arrays;
17+
import java.util.Collection;
18+
import java.util.List;
1619
import java.util.Map.Entry;
1720

1821
public class SQLBuilder {
@@ -114,7 +117,7 @@ public static SQLStatement buildCreateTable(EntityTable table) {
114117
boolean hasKey = false;
115118
if (table.key != null) {
116119
hasKey = true;
117-
if (table.key.assign == PrimaryKey.AssignType.AUTO_INCREMENT) {
120+
if (table.key.assign == AssignType.AUTO_INCREMENT) {
118121
sb.append(table.key.column).append(DataUtil.INTEGER).append(PRIMARY_KEY_AUTOINCREMENT);
119122
} else {
120123
sb.append(table.key.column).append(DataUtil.getSQLDataType(table.key.field)).append(PRIMARY_KEY);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.litesuits.orm.db.enums;
2+
3+
/**
4+
* @author MaTianyu
5+
* @date 2014-08-16
6+
*/
7+
public enum AssignType {
8+
/**
9+
* 主键值自己来指定。
10+
*/
11+
BY_MYSELF,
12+
/**
13+
* 主键值由系统分配,系统将使用自动递增整数赋值给主键。
14+
* 系统将从1开始递增分配,每次在上一条最大ID上+1 。
15+
*/
16+
AUTO_INCREMENT
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.litesuits.orm.db.enums;
2+
3+
public enum Relation {
4+
ManyToMany,
5+
OneToMany,
6+
ManyToOne,
7+
OneToOne
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.litesuits.orm.db.enums;
2+
3+
public enum Strategy {
4+
ROLLBACK(" ROLLBACK "),
5+
ABORT(" ABORT "),
6+
FAIL(" FAIL "),
7+
IGNORE(" IGNORE "),
8+
REPLACE(" REPLACE ");
9+
10+
Strategy(String sql) {
11+
this.sql = sql;
12+
}
13+
14+
public String sql;
15+
16+
public String getSql() {
17+
return sql;
18+
}
19+
}

library/src/com/litesuits/orm/db/impl/CascadeSQLiteImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ private void queryMapToOne(final EntityTable table1, Object key1, Object obj1,
394394
throws IllegalAccessException, InstantiationException {
395395
final EntityTable table2 = TableManager.getTable(field.getType());
396396
SQLStatement relationSql = SQLBuilder.buildQueryRelationSql(table1, table2, key1);
397-
final Relation relation = new Relation();
397+
final RelationKey relation = new RelationKey();
398398
Querier.doQuery(db, relationSql, new Querier.CursorParser() {
399399
@Override
400400
public void parseEachCursor(SQLiteDatabase db, Cursor c) throws Exception {

library/src/com/litesuits/orm/db/model/MapProperty.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.litesuits.orm.db.model;
22

3-
import com.litesuits.orm.db.annotation.Mapping.Relation;
3+
import com.litesuits.orm.db.enums.Relation;
44

55
import java.lang.reflect.Field;
66

0 commit comments

Comments
 (0)