001package org.hl7.fhir.dstu2.formats;
002
003/*-
004 * #%L
005 * org.hl7.fhir.dstu2
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024import java.io.IOException;
025import java.io.OutputStreamWriter;
026import java.math.BigDecimal;
027
028import com.google.gson.stream.JsonWriter;
029
030public class JsonCreatorGson implements JsonCreator {
031
032  JsonWriter gson;
033  
034  public JsonCreatorGson(OutputStreamWriter osw) {
035    gson = new JsonWriter(osw);
036  }
037
038  @Override
039  public void setIndent(String indent) {
040    gson.setIndent(indent);
041  }
042
043  @Override
044  public void beginObject() throws IOException {
045    gson.beginObject();    
046  }
047
048  @Override
049  public void endObject() throws IOException {
050    gson.endObject();
051  }
052
053  @Override
054  public void nullValue() throws IOException {
055    gson.nullValue();
056  }
057
058  @Override
059  public void name(String name) throws IOException {
060    gson.name(name);
061  }
062
063  @Override
064  public void value(String value) throws IOException {
065    gson.value(value);
066  }
067
068  @Override
069  public void value(Boolean value) throws IOException {
070    gson.value(value);
071  }
072
073  @Override
074  public void value(BigDecimal value) throws IOException {
075    gson.value(value);
076  }
077
078  @Override
079  public void value(Integer value) throws IOException {
080    gson.value(value);
081  }
082
083  @Override
084  public void beginArray() throws IOException {
085    gson.beginArray();
086  }
087
088  @Override
089  public void endArray() throws IOException {
090    gson.endArray();
091  }
092
093  @Override
094  public void finish() {
095    // nothing to do here
096    
097  }
098
099}