
eu.interedition.text.json.NameSerializer 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 eu.interedition.text.Name;
import java.io.IOException;
import java.net.URI;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
/**
* @author Gregor Middell
*/
public class NameSerializer extends JsonSerializer {
@Override
public Class handledType() {
return Name.class;
}
@Override
public void serialize(Name value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartArray();
final URI ns = value.getNamespace();
if (ns == null) {
jgen.writeNull();
} else {
jgen.writeString(ns.toString());
}
jgen.writeString(value.getLocalName());
jgen.writeEndArray();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy