forked from tabulapdf/tabula-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangularTextContainerSerializer.java
More file actions
29 lines (21 loc) · 1.04 KB
/
RectangularTextContainerSerializer.java
File metadata and controls
29 lines (21 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package technology.tabula.json;
import java.lang.reflect.Type;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import technology.tabula.RectangularTextContainer;
public final class RectangularTextContainerSerializer implements JsonSerializer<RectangularTextContainer<?>> {
public static final RectangularTextContainerSerializer INSTANCE = new RectangularTextContainerSerializer();
private RectangularTextContainerSerializer() {}
@Override
public JsonElement serialize(RectangularTextContainer<?> textContainer, Type type, JsonSerializationContext context) {
JsonObject json = new JsonObject();
json.addProperty("top", textContainer.getTop());
json.addProperty("left", textContainer.getLeft());
json.addProperty("width", textContainer.getWidth());
json.addProperty("height", textContainer.getHeight());
json.addProperty("text", textContainer.getText());
return json;
}
}