001package org.hl7.fhir.r4.formats; 002 003import java.io.IOException; 004import java.io.OutputStreamWriter; 005import java.math.BigDecimal; 006 007import com.google.gson.stream.JsonWriter; 008 009public class JsonCreatorGson implements JsonCreator { 010 011 JsonWriter gson; 012 013 public JsonCreatorGson(OutputStreamWriter osw) { 014 gson = new JsonWriter(osw); 015 } 016 017 @Override 018 public void setIndent(String indent) { 019 gson.setIndent(indent); 020 } 021 022 @Override 023 public void beginObject() throws IOException { 024 gson.beginObject(); 025 } 026 027 @Override 028 public void endObject() throws IOException { 029 gson.endObject(); 030 } 031 032 @Override 033 public void nullValue() throws IOException { 034 gson.nullValue(); 035 } 036 037 @Override 038 public void name(String name) throws IOException { 039 gson.name(name); 040 } 041 042 @Override 043 public void value(String value) throws IOException { 044 gson.value(value); 045 } 046 047 @Override 048 public void value(Boolean value) throws IOException { 049 gson.value(value); 050 } 051 052 @Override 053 public void value(BigDecimal value) throws IOException { 054 gson.value(value); 055 } 056 057 @Override 058 public void value(Integer value) throws IOException { 059 gson.value(value); 060 } 061 062 @Override 063 public void beginArray() throws IOException { 064 gson.beginArray(); 065 } 066 067 @Override 068 public void endArray() throws IOException { 069 gson.endArray(); 070 } 071 072 @Override 073 public void finish() { 074 // nothing to do here 075 076 } 077 078 @Override 079 public void link(String href) { 080 // not used 081 } 082 083 @Override 084 public void valueNum(String value) throws IOException { 085 value(new BigDecimal(value)); 086 } 087 088}