Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
package org.greenrobot.greendao.query;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.InternalQueryDaoAccess;
/* loaded from: classes2.dex */
abstract class AbstractQuery<T> {
protected final AbstractDao<T, ?> a;
protected final InternalQueryDaoAccess<T> b;
protected final String c;
protected final String[] d;
protected final Thread e = Thread.currentThread();
protected AbstractQuery(AbstractDao<T, ?> abstractDao, String str, String[] strArr) {
this.a = abstractDao;
this.b = new InternalQueryDaoAccess<>(abstractDao);
this.c = str;
this.d = strArr;
}
protected static String[] a(Object[] objArr) {
int length = objArr.length;
String[] strArr = new String[length];
for (int i = 0; i < length; i++) {
Object obj = objArr[i];
if (obj != null) {
strArr[i] = obj.toString();
} else {
strArr[i] = null;
}
}
return strArr;
}
public AbstractQuery<T> a(int i, Object obj) {
a();
if (obj != null) {
this.d[i] = obj.toString();
} else {
this.d[i] = null;
}
return this;
}
protected void a() {
if (Thread.currentThread() != this.e) {
throw new DaoException("Method may be called only in owner thread, use forCurrentThread to get an instance for this thread");
}
}
}

View File

@@ -0,0 +1,61 @@
package org.greenrobot.greendao.query;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.AbstractQuery;
/* loaded from: classes2.dex */
abstract class AbstractQueryData<T, Q extends AbstractQuery<T>> {
final String a;
final AbstractDao<T, ?> b;
final String[] c;
final Map<Long, WeakReference<Q>> d = new HashMap();
AbstractQueryData(AbstractDao<T, ?> abstractDao, String str, String[] strArr) {
this.b = abstractDao;
this.a = str;
this.c = strArr;
}
protected abstract Q a();
Q a(Q q) {
if (Thread.currentThread() != q.e) {
return b();
}
String[] strArr = this.c;
System.arraycopy(strArr, 0, q.d, 0, strArr.length);
return q;
}
Q b() {
Q q;
long id = Thread.currentThread().getId();
synchronized (this.d) {
WeakReference<Q> weakReference = this.d.get(Long.valueOf(id));
q = weakReference != null ? weakReference.get() : null;
if (q == null) {
c();
q = a();
this.d.put(Long.valueOf(id), new WeakReference<>(q));
} else {
System.arraycopy(this.c, 0, q.d, 0, this.c.length);
}
}
return q;
}
void c() {
synchronized (this.d) {
Iterator<Map.Entry<Long, WeakReference<Q>>> it = this.d.entrySet().iterator();
while (it.hasNext()) {
if (it.next().getValue().get() == null) {
it.remove();
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
package org.greenrobot.greendao.query;
import org.greenrobot.greendao.AbstractDao;
/* loaded from: classes2.dex */
abstract class AbstractQueryWithLimit<T> extends AbstractQuery<T> {
protected final int f;
protected final int g;
protected AbstractQueryWithLimit(AbstractDao<T, ?> abstractDao, String str, String[] strArr, int i, int i2) {
super(abstractDao, str, strArr);
this.f = i;
this.g = i2;
}
@Override // org.greenrobot.greendao.query.AbstractQuery
public AbstractQueryWithLimit<T> a(int i, Object obj) {
if (i < 0 || !(i == this.f || i == this.g)) {
super.a(i, obj);
return this;
}
throw new IllegalArgumentException("Illegal parameter index: " + i);
}
}

View File

@@ -0,0 +1,28 @@
package org.greenrobot.greendao.query;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
/* loaded from: classes2.dex */
public class Join<SRC, DST> {
final String a;
final AbstractDao<DST, ?> b;
final Property c;
final Property d;
final String e;
final WhereCollector<DST> f;
public Join(String str, Property property, AbstractDao<DST, ?> abstractDao, Property property2, String str2) {
this.a = str;
this.c = property;
this.b = abstractDao;
this.d = property2;
this.e = str2;
this.f = new WhereCollector<>(abstractDao, str2);
}
public Join<SRC, DST> a(WhereCondition whereCondition, WhereCondition... whereConditionArr) {
this.f.a(whereCondition, whereConditionArr);
return this;
}
}

View File

@@ -0,0 +1,54 @@
package org.greenrobot.greendao.query;
import java.util.List;
import org.greenrobot.greendao.AbstractDao;
/* loaded from: classes2.dex */
public class Query<T> extends AbstractQueryWithLimit<T> {
private final QueryData<T> h;
private static final class QueryData<T2> extends AbstractQueryData<T2, Query<T2>> {
private final int e;
private final int f;
QueryData(AbstractDao<T2, ?> abstractDao, String str, String[] strArr, int i, int i2) {
super(abstractDao, str, strArr);
this.e = i;
this.f = i2;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // org.greenrobot.greendao.query.AbstractQueryData
public Query<T2> a() {
return new Query<>(this, this.b, this.a, (String[]) this.c.clone(), this.e, this.f);
}
}
static <T2> Query<T2> a(AbstractDao<T2, ?> abstractDao, String str, Object[] objArr, int i, int i2) {
return new QueryData(abstractDao, str, AbstractQuery.a(objArr), i, i2).b();
}
public Query<T> b() {
return (Query) this.h.a(this);
}
public List<T> c() {
a();
return this.b.a(this.a.d().a(this.c, this.d));
}
public T d() {
a();
return this.b.b(this.a.d().a(this.c, this.d));
}
private Query(QueryData<T> queryData, AbstractDao<T, ?> abstractDao, String str, String[] strArr, int i, int i2) {
super(abstractDao, str, strArr, i, i2);
this.h = queryData;
}
@Override // org.greenrobot.greendao.query.AbstractQueryWithLimit, org.greenrobot.greendao.query.AbstractQuery
public Query<T> a(int i, Object obj) {
return (Query) super.a(i, obj);
}
}

View File

@@ -0,0 +1,196 @@
package org.greenrobot.greendao.query;
import java.util.ArrayList;
import java.util.List;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.DaoLog;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.SqlUtils;
/* loaded from: classes2.dex */
public class QueryBuilder<T> {
public static boolean k;
public static boolean l;
private final WhereCollector<T> a;
private StringBuilder b;
private final List<Object> c;
private final List<Join<T, ?>> d;
private final AbstractDao<T, ?> e;
private final String f;
private Integer g;
private Integer h;
private boolean i;
private String j;
protected QueryBuilder(AbstractDao<T, ?> abstractDao) {
this(abstractDao, "T");
}
public static <T2> QueryBuilder<T2> a(AbstractDao<T2, ?> abstractDao) {
return new QueryBuilder<>(abstractDao);
}
private void d() {
StringBuilder sb = this.b;
if (sb == null) {
this.b = new StringBuilder();
} else if (sb.length() > 0) {
this.b.append(",");
}
}
private StringBuilder e() {
StringBuilder sb = new StringBuilder(SqlUtils.a(this.e.h(), this.f, this.e.c(), this.i));
a(sb, this.f);
StringBuilder sb2 = this.b;
if (sb2 != null && sb2.length() > 0) {
sb.append(" ORDER BY ");
sb.append((CharSequence) this.b);
}
return sb;
}
public QueryBuilder<T> b(Property... propertyArr) {
a(" DESC", propertyArr);
return this;
}
public T c() {
return a().d();
}
protected QueryBuilder(AbstractDao<T, ?> abstractDao, String str) {
this.e = abstractDao;
this.f = str;
this.c = new ArrayList();
this.d = new ArrayList();
this.a = new WhereCollector<>(abstractDao, str);
this.j = " COLLATE NOCASE";
}
private int b(StringBuilder sb) {
if (this.h == null) {
return -1;
}
if (this.g == null) {
throw new IllegalStateException("Offset cannot be set without limit");
}
sb.append(" OFFSET ?");
this.c.add(this.h);
return this.c.size() - 1;
}
public QueryBuilder<T> a(WhereCondition whereCondition, WhereCondition... whereConditionArr) {
this.a.a(whereCondition, whereConditionArr);
return this;
}
public <J> Join<T, J> a(Class<J> cls, Property property) {
return a(this.e.e(), cls, property);
}
public <J> Join<T, J> a(Property property, Class<J> cls, Property property2) {
return a(this.f, property, this.e.g().a((Class<? extends Object>) cls), property2);
}
private <J> Join<T, J> a(String str, Property property, AbstractDao<J, ?> abstractDao, Property property2) {
Join<T, J> join = new Join<>(str, property, abstractDao, property2, "J" + (this.d.size() + 1));
this.d.add(join);
return join;
}
public List<T> b() {
return a().c();
}
public QueryBuilder<T> a(Property... propertyArr) {
a(" ASC", propertyArr);
return this;
}
private void a(String str, Property... propertyArr) {
String str2;
for (Property property : propertyArr) {
d();
a(this.b, property);
if (String.class.equals(property.b) && (str2 = this.j) != null) {
this.b.append(str2);
}
this.b.append(str);
}
}
protected StringBuilder a(StringBuilder sb, Property property) {
this.a.a(property);
sb.append(this.f);
sb.append('.');
sb.append('\'');
sb.append(property.e);
sb.append('\'');
return sb;
}
public QueryBuilder<T> a(int i) {
this.g = Integer.valueOf(i);
return this;
}
public Query<T> a() {
StringBuilder e = e();
int a = a(e);
int b = b(e);
String sb = e.toString();
a(sb);
return Query.a(this.e, sb, this.c.toArray(), a, b);
}
private int a(StringBuilder sb) {
if (this.g == null) {
return -1;
}
sb.append(" LIMIT ?");
this.c.add(this.g);
return this.c.size() - 1;
}
private void a(String str) {
if (k) {
DaoLog.a("Built SQL for query: " + str);
}
if (l) {
DaoLog.a("Values for query: " + this.c);
}
}
private void a(StringBuilder sb, String str) {
this.c.clear();
for (Join<T, ?> join : this.d) {
sb.append(" JOIN ");
sb.append('\"');
sb.append(join.b.h());
sb.append('\"');
sb.append(' ');
sb.append(join.e);
sb.append(" ON ");
SqlUtils.a(sb, join.a, join.c);
sb.append('=');
SqlUtils.a(sb, join.e, join.d);
}
boolean z = !this.a.a();
if (z) {
sb.append(" WHERE ");
this.a.a(sb, str, this.c);
}
for (Join<T, ?> join2 : this.d) {
if (!join2.f.a()) {
if (!z) {
sb.append(" WHERE ");
z = true;
} else {
sb.append(" AND ");
}
join2.f.a(sb, join2.e, this.c);
}
}
}
}

View File

@@ -0,0 +1,74 @@
package org.greenrobot.greendao.query;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.query.WhereCondition;
/* loaded from: classes2.dex */
class WhereCollector<T> {
private final AbstractDao<T, ?> a;
private final List<WhereCondition> b = new ArrayList();
WhereCollector(AbstractDao<T, ?> abstractDao, String str) {
this.a = abstractDao;
}
void a(WhereCondition whereCondition, WhereCondition... whereConditionArr) {
a(whereCondition);
this.b.add(whereCondition);
for (WhereCondition whereCondition2 : whereConditionArr) {
a(whereCondition2);
this.b.add(whereCondition2);
}
}
void a(WhereCondition whereCondition) {
if (whereCondition instanceof WhereCondition.PropertyCondition) {
a(((WhereCondition.PropertyCondition) whereCondition).d);
}
}
void a(Property property) {
AbstractDao<T, ?> abstractDao = this.a;
if (abstractDao != null) {
Property[] f = abstractDao.f();
int length = f.length;
boolean z = false;
int i = 0;
while (true) {
if (i >= length) {
break;
}
if (property == f[i]) {
z = true;
break;
}
i++;
}
if (z) {
return;
}
throw new DaoException("Property '" + property.c + "' is not part of " + this.a);
}
}
void a(StringBuilder sb, String str, List<Object> list) {
ListIterator<WhereCondition> listIterator = this.b.listIterator();
while (listIterator.hasNext()) {
if (listIterator.hasPrevious()) {
sb.append(" AND ");
}
WhereCondition next = listIterator.next();
next.a(sb, str);
next.a(list);
}
}
boolean a() {
return this.b.isEmpty();
}
}

View File

@@ -0,0 +1,105 @@
package org.greenrobot.greendao.query;
import java.util.Date;
import java.util.List;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.SqlUtils;
/* loaded from: classes2.dex */
public interface WhereCondition {
void a(StringBuilder sb, String str);
void a(List<Object> list);
public static class PropertyCondition extends AbstractCondition {
public final Property d;
public final String e;
public PropertyCondition(Property property, String str) {
this.d = property;
this.e = str;
}
private static Object a(Property property, Object obj) {
if (obj != null && obj.getClass().isArray()) {
throw new DaoException("Illegal value: found array, but simple object required");
}
Class<?> cls = property.b;
if (cls == Date.class) {
if (obj instanceof Date) {
return Long.valueOf(((Date) obj).getTime());
}
if (obj instanceof Long) {
return obj;
}
throw new DaoException("Illegal date value: expected java.util.Date or Long for value " + obj);
}
if (cls == Boolean.TYPE || cls == Boolean.class) {
if (obj instanceof Boolean) {
return Integer.valueOf(((Boolean) obj).booleanValue() ? 1 : 0);
}
if (obj instanceof Number) {
int intValue = ((Number) obj).intValue();
if (intValue != 0 && intValue != 1) {
throw new DaoException("Illegal boolean value: numbers must be 0 or 1, but was " + obj);
}
} else if (obj instanceof String) {
String str = (String) obj;
if ("TRUE".equalsIgnoreCase(str)) {
return 1;
}
if ("FALSE".equalsIgnoreCase(str)) {
return 0;
}
throw new DaoException("Illegal boolean value: Strings must be \"TRUE\" or \"FALSE\" (case insensitive), but was " + obj);
}
}
return obj;
}
public PropertyCondition(Property property, String str, Object obj) {
super(a(property, obj));
this.d = property;
this.e = str;
}
@Override // org.greenrobot.greendao.query.WhereCondition
public void a(StringBuilder sb, String str) {
SqlUtils.a(sb, str, this.d);
sb.append(this.e);
}
}
public static abstract class AbstractCondition implements WhereCondition {
protected final boolean a;
protected final Object b;
protected final Object[] c;
public AbstractCondition() {
this.a = false;
this.b = null;
this.c = null;
}
@Override // org.greenrobot.greendao.query.WhereCondition
public void a(List<Object> list) {
if (this.a) {
list.add(this.b);
return;
}
Object[] objArr = this.c;
if (objArr != null) {
for (Object obj : objArr) {
list.add(obj);
}
}
}
public AbstractCondition(Object obj) {
this.b = obj;
this.a = true;
this.c = null;
}
}
}