-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a79bae7
commit 65b82f2
Showing
87 changed files
with
17,079 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apply from: "$rootDir/gradle/android.gradle" | ||
apply from: "$rootDir/gradle/test.gradle" | ||
|
||
android { | ||
defaultConfig { | ||
// Specifies the fully-qualified class name of the test instrumentation runner. | ||
testInstrumentationRunner "android.test.InstrumentationTestRunner" | ||
} | ||
// Gradle automatically adds 'android.test.runner' as a dependency. | ||
useLibrary 'android.test.runner' | ||
|
||
useLibrary 'android.test.base' | ||
useLibrary 'android.test.mock' | ||
} | ||
|
||
dependencies { | ||
implementation("org.slf4j:slf4j-api:1.7.31") | ||
|
||
testImplementation(project(":radar-commons-android")) { | ||
exclude group: 'org.apache.avro', module: 'avro' | ||
exclude group: 'com.gitlab.mvysny.slf4j', module: 'slf4j-handroid' | ||
} | ||
|
||
testImplementation("junit:junit:4.13.2") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest package="org.radarbase.android.avro"/> |
38 changes: 38 additions & 0 deletions
38
avro-android/src/main/java/org/apache/avro/AvroMissingFieldException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.avro; | ||
|
||
import org.apache.avro.Schema.Field; | ||
|
||
import java.util.List; | ||
|
||
/** Avro exception in case of missing fields. */ | ||
public class AvroMissingFieldException extends AvroRuntimeException { | ||
private final Field field; | ||
|
||
public AvroMissingFieldException(String message, Field field) { | ||
super(message); | ||
this.field = field; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Path in schema: --> " + field.name(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
avro-android/src/main/java/org/apache/avro/AvroRuntimeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.avro; | ||
|
||
/** Base Avro exception. */ | ||
public class AvroRuntimeException extends RuntimeException { | ||
public AvroRuntimeException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public AvroRuntimeException(String message) { | ||
super(message); | ||
} | ||
|
||
public AvroRuntimeException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
avro-android/src/main/java/org/apache/avro/AvroTypeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.avro; | ||
|
||
/** Thrown when an illegal type is used. */ | ||
public class AvroTypeException extends AvroRuntimeException { | ||
public AvroTypeException(String message) { | ||
super(message); | ||
} | ||
|
||
public AvroTypeException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
avro-android/src/main/java/org/apache/avro/InvalidAvroMagicException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.avro; | ||
|
||
import java.io.IOException; | ||
|
||
public class InvalidAvroMagicException extends IOException { | ||
public InvalidAvroMagicException(String message) { | ||
super(message); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
avro-android/src/main/java/org/apache/avro/InvalidNumberEncodingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.avro; | ||
|
||
import java.io.IOException; | ||
|
||
public class InvalidNumberEncodingException extends IOException { | ||
public InvalidNumberEncodingException(String message) { | ||
super(message); | ||
} | ||
} |
189 changes: 189 additions & 0 deletions
189
avro-android/src/main/java/org/apache/avro/JsonProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.avro; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* Base class for objects that have JSON-valued properties. Avro and JSON values | ||
* are represented in Java using the following mapping: | ||
* | ||
* <table> | ||
* <th> | ||
* <td>Avro type</td> | ||
* <td>JSON type</td> | ||
* <td>Java type</td></th> | ||
* <tr> | ||
* <td><code>null</code></td> | ||
* <td><code>null</code></td> | ||
* <td>{@link #NULL_VALUE}</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>boolean</code></td> | ||
* <td>Boolean</td> | ||
* <td><code>boolean</code></td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>int</code></td> | ||
* <td>Number</td> | ||
* <td><code>int</code></td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>long</code></td> | ||
* <td>Number</td> | ||
* <td><code>long</code></td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>float</code></td> | ||
* <td>Number</td> | ||
* <td><code>float</code></td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>double</code></td> | ||
* <td>Number</td> | ||
* <td><code>double</code></td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>bytes</code></td> | ||
* <td>String</td> | ||
* <td><code>byte[]</code></td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>string</code></td> | ||
* <td>String</td> | ||
* <td>{@link java.lang.String}</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>record</code></td> | ||
* <td>Object</td> | ||
* <td>{@link java.util.Map}</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>enum</code></td> | ||
* <td>String</td> | ||
* <td>{@link java.lang.String}</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>array</code></td> | ||
* <td>Array</td> | ||
* <td>{@link java.util.Collection}</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>map</code></td> | ||
* <td>Object</td> | ||
* <td>{@link java.util.Map}</td> | ||
* </tr> | ||
* <tr> | ||
* <td><code>fixed</code></td> | ||
* <td>String</td> | ||
* <td><code>byte[]</code></td> | ||
* </tr> | ||
* </table> | ||
*/ | ||
public abstract class JsonProperties { | ||
|
||
public static class Null { | ||
private Null() { | ||
} | ||
} | ||
|
||
/** A value representing a JSON <code>null</code>. */ | ||
public static final Null NULL_VALUE = new Null(); | ||
|
||
// use a ConcurrentHashMap for speed and thread safety, but keep a Queue of the | ||
// entries to maintain order | ||
// the queue is always updated after the main map and is thus is potentially a | ||
// subset of the map. | ||
// By making props private, we can control access and only implement/override | ||
// the methods | ||
// we need. We don't ever remove anything so we don't need to implement the | ||
// clear/remove functionality. | ||
// Also, we only ever ADD to the collection, never changing a value, so | ||
// putWithAbsent is the | ||
// only modifier | ||
private final JSONObject props = new JSONObject(); | ||
|
||
JsonProperties() { | ||
} | ||
|
||
/** | ||
* Returns the value of the named, string-valued property in this schema. | ||
* Returns <tt>null</tt> if there is no string-valued property with that name. | ||
*/ | ||
public String getProp(String name) { | ||
String prop = props.optString(name); | ||
return !prop.equals("") ? prop : null; | ||
} | ||
|
||
/** | ||
* Adds a property with the given name <tt>name</tt> and value <tt>value</tt>. | ||
* Neither <tt>name</tt> nor <tt>value</tt> can be <tt>null</tt>. It is illegal | ||
* to add a property if another with the same name but different value already | ||
* exists in this schema. | ||
* | ||
* @param name The name of the property to add | ||
* @param value The value for the property to add | ||
*/ | ||
public void addProp(String name, String value) { | ||
try { | ||
props.put(name, value); | ||
} catch (JSONException ex) { | ||
throw new IllegalArgumentException(ex); | ||
} | ||
} | ||
|
||
public void addProp(String name, Object value) { | ||
try { | ||
props.put(name, value); | ||
} catch (JSONException ex) { | ||
throw new IllegalArgumentException(ex); | ||
} | ||
} | ||
|
||
public void putAll(JsonProperties np) { | ||
for (Iterator<String> it = np.props.keys(); it.hasNext(); ) { | ||
String key = it.next(); | ||
try { | ||
props.put(key, np.props.get(key)); | ||
} catch (JSONException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
|
||
void writeProps(JSONObject gen) throws JSONException { | ||
for (Iterator<String> it = props.keys(); it.hasNext(); ) { | ||
String key = it.next(); | ||
gen.put(key, props.get(key)); | ||
} | ||
} | ||
|
||
int propsHashCode() { | ||
return props.hashCode(); | ||
} | ||
|
||
boolean propsEqual(JsonProperties np) { | ||
return props.equals(np.props); | ||
} | ||
|
||
public boolean hasProps() { | ||
return props.length() > 0; | ||
} | ||
} |
Oops, something went wrong.