
eu.interedition.text.json.QueryResultSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of text-core Show documentation
Show all versions of text-core Show documentation
Stand-off Markup/Annotation Text Model
The newest version!
package eu.interedition.text.json;
import com.google.common.collect.Iterables;
import eu.interedition.text.Layer;
import eu.interedition.text.QueryResult;
import java.io.IOException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
/**
* @author Gregor Middell
*/
public class QueryResultSerializer extends JsonSerializer {
@Override
public Class handledType() {
return QueryResult.class;
}
@Override
public void serialize(QueryResult value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeStartArray();
for (Layer layer : Iterables.filter(value, Layer.class)) {
jgen.writeObject(layer);
}
jgen.writeEndArray();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy