Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Jackson JAXB Annotations Source Code
Jackson JAXB Annotations Source Code files are provided in the source packge (jackson-module-jaxb-annotations-2.14.0-sources.jar). You can download it at Jackson Base module Maven Website.
You can also browse Jackson JAXB Annotations Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/module/jaxb/ser/DataHandlerJsonSerializer.java
package com.fasterxml.jackson.module.jaxb.ser;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import javax.activation.DataHandler;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
public class DataHandlerJsonSerializer extends StdSerializer<DataHandler>
{
private static final long serialVersionUID = 1L;
public DataHandlerJsonSerializer() { super(DataHandler.class); }
@Override
public void serialize(DataHandler value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException
{
final ByteArrayOutputStream out = new ByteArrayOutputStream();
/* for copy-through, a small buffer should suffice: ideally
* we might want to reuse a generic byte buffer, but for now
* there's no serializer context to hold them.
*
* Also: it'd be nice not to have buffer all data, but use a
* streaming output. But currently JsonGenerator won't allow
* that.
*/
byte[] buffer = new byte[1024 * 4];
InputStream in = value.getInputStream();
int len = in.read(buffer);
while (len > 0) {
out.write(buffer, 0, len);
len = in.read(buffer);
}
in.close();
jgen.writeBinary(out.toByteArray());
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.STRING);
}
}
}
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
ObjectNode o = createSchemaNode("array", true);
ObjectNode itemSchema = createSchemaNode("string"); //binary values written as strings?
o.set("items", itemSchema);
return o;
}
}
⏎ com/fasterxml/jackson/module/jaxb/ser/DataHandlerJsonSerializer.java
Or download all of them as a single archive file:
File name: jackson-module-jaxb-annotations-2.14.0-sources.jar File size: 27411 bytes Release date: 2022-11-05 Download
⇒ jackson-core-2.2.3.jar - Jackson
2022-05-03, ∼7097🔥, 1💬
Popular Posts:
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
JDK 11 java.naming.jmod is the JMOD file for JDK 11 Naming module. JDK 11 Naming module compiled cla...
JDK 17 java.compiler.jmod is the JMOD file for JDK 17 Compiler module. JDK 17 Compiler module compil...
What JAR files are required to run sax\Writer.java provided in the Apache Xerces package? 1 JAR file...
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...