Skip to content

Making few classes Serializable #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/com/dashjoin/jsonata/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package com.dashjoin.jsonata;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -63,7 +64,7 @@
import com.dashjoin.jsonata.utils.DateTimeUtils;

@SuppressWarnings({"rawtypes", "unchecked"})
public class Functions {
public class Functions implements Serializable {

/**
* Sum function
Expand Down Expand Up @@ -628,7 +629,7 @@ public static String rightPad(final String str, final int size, String padStr) {
return str.concat(substr(padding, 0, pads));
}

static class RegexpMatch {
static class RegexpMatch implements Serializable {
String match;
int index;
List<String> groups;
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/com/dashjoin/jsonata/Jsonata.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package com.dashjoin.jsonata;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand All @@ -50,19 +51,19 @@
* @description JSON query and transformation language
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class Jsonata {
public class Jsonata implements Serializable {

// Start of Evaluator code

public static interface EntryCallback {
public static interface EntryCallback extends Serializable {
void callback(Symbol expr, Object input, Frame environment);
}

public static interface ExitCallback {
public static interface ExitCallback extends Serializable {
void callback(Symbol expr, Object input, Frame environment, Object result);
}

public static class Frame {
public static class Frame implements Serializable {
final Map<String, Object> bindings = new LinkedHashMap<String,Object>();

final Frame parent;
Expand Down Expand Up @@ -2099,7 +2100,7 @@ public Frame createFrame(Frame enclosingEnvironment) {
// };
}

public static interface JLambda {
public static interface JLambda extends Serializable {
}

public static interface FnVarArgs<R> extends JLambda, Function<List<?>, R> {
Expand Down Expand Up @@ -2173,18 +2174,18 @@ default JFunctionCallable getJFunctionCallable() {
/**
* JFunction callable Lambda interface
*/
public static interface JFunctionCallable {
public static interface JFunctionCallable extends Serializable {
Object call(Object input, List args) throws Throwable;
}

public static interface JFunctionSignatureValidation {
public static interface JFunctionSignatureValidation extends Serializable {
Object validate(Object args, Object context);
}

/**
* JFunction definition class
*/
public static class JFunction implements JFunctionCallable, JFunctionSignatureValidation {
public static class JFunction implements JFunctionCallable, JFunctionSignatureValidation, Serializable {
JFunctionCallable function;
String functionName;
Signature signature;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/dashjoin/jsonata/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -40,7 +41,7 @@

//var parseSignature = require('./signature');
@SuppressWarnings({"unchecked"})
public class Parser {
public class Parser implements Serializable {

boolean dbg = false;

Expand Down Expand Up @@ -92,7 +93,7 @@ public static<T> T clone(T object) {
}
}

class Symbol implements Cloneable {
class Symbol implements Cloneable, Serializable {

//Symbol s;
String id;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/dashjoin/jsonata/Timebox.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

import com.dashjoin.jsonata.Jsonata.Frame;

import java.io.Serializable;

/**
* Configure max runtime / max recursion depth.
* See Frame.setRuntimeBounds - usually not used directly
*/
public class Timebox {
public class Timebox implements Serializable {

long timeout = 5000L;
int maxDepth = 100;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/dashjoin/jsonata/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
*/
package com.dashjoin.jsonata;

import java.io.Serializable;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Tokenizer { // = function (path) {
public class Tokenizer implements Serializable { // = function (path) {

static HashMap<String, Integer> operators = new HashMap<String, Integer>() {{
put(".", 75);
Expand Down Expand Up @@ -91,7 +92,7 @@ public class Tokenizer { // = function (path) {
length = path.length();
}

public static class Token {
public static class Token implements Serializable {
String type;
Object value;
int position;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/dashjoin/jsonata/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package com.dashjoin.jsonata;

import java.io.Serializable;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -28,7 +29,7 @@
import com.dashjoin.jsonata.Jsonata.JFunctionCallable;

@SuppressWarnings({"rawtypes"})
public class Utils {
public class Utils implements Serializable {
public static boolean isNumeric(Object v) {
if (v instanceof Long) return true;
boolean isNum = false;
Expand Down Expand Up @@ -117,7 +118,7 @@ public static boolean isSequence(Object result) {
*
* Used for late materialization of ranges.
*/
public static class RangeList extends AbstractList<Number> {
public static class RangeList extends AbstractList<Number> implements Serializable {

final long a, b;
final int size;
Expand Down