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
31 lines (23 loc) · 991 Bytes
/
RectangularTextContainerSerializer.java
File metadata and controls
31 lines (23 loc) · 991 Bytes
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
30
31
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() {
// singleton
}
@Override
public JsonElement serialize(RectangularTextContainer<?> src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject result = new JsonObject();
result.addProperty("top", src.getTop());
result.addProperty("left", src.getLeft());
result.addProperty("width", src.getWidth());
result.addProperty("height", src.getHeight());
result.addProperty("text", src.getText());
return result;
}
}