001package ca.uhn.fhir.parser.json;
002
003import java.io.IOException;
004import java.io.Writer;
005import java.math.BigDecimal;
006import java.math.BigInteger;
007
008/*
009 * #%L
010 * HAPI FHIR - Core Library
011 * %%
012 * Copyright (C) 2014 - 2019 University Health Network
013 * %%
014 * Licensed under the Apache License, Version 2.0 (the "License");
015 * you may not use this file except in compliance with the License.
016 * You may obtain a copy of the License at
017 *
018 *      http://www.apache.org/licenses/LICENSE-2.0
019 *
020 * Unless required by applicable law or agreed to in writing, software
021 * distributed under the License is distributed on an "AS IS" BASIS,
022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
023 * See the License for the specific language governing permissions and
024 * limitations under the License.
025 * #L%
026 */
027
028public abstract class JsonLikeWriter {
029
030        private boolean prettyPrint;
031        private Writer writer;
032        
033        public void setPrettyPrint (boolean tf) {
034                prettyPrint = tf; 
035        }
036        public boolean isPrettyPrint () {
037                return prettyPrint;
038        }
039        
040        public void setWriter (Writer writer) {
041                this.writer = writer;
042        }
043        public Writer getWriter () {
044                return writer;
045        }
046        
047        public abstract JsonLikeWriter init () throws IOException;
048        public abstract JsonLikeWriter flush () throws IOException;
049        public abstract void close () throws IOException;
050        
051        public abstract JsonLikeWriter beginObject () throws IOException;
052        public abstract JsonLikeWriter beginArray () throws IOException;
053
054        public abstract JsonLikeWriter beginObject (String name) throws IOException;
055        public abstract JsonLikeWriter beginArray (String name) throws IOException;
056        
057        public abstract JsonLikeWriter write (String value) throws IOException;
058        public abstract JsonLikeWriter write (BigInteger value) throws IOException;
059        public abstract JsonLikeWriter write (BigDecimal value) throws IOException;
060        public abstract JsonLikeWriter write (long value) throws IOException;
061        public abstract JsonLikeWriter write (double value) throws IOException;
062        public abstract JsonLikeWriter write (Boolean value) throws IOException;
063        public abstract JsonLikeWriter write (boolean value) throws IOException;
064        public abstract JsonLikeWriter writeNull () throws IOException;
065        
066        public abstract JsonLikeWriter write (String name, String value) throws IOException;
067        public abstract JsonLikeWriter write (String name, BigInteger value) throws IOException;
068        public abstract JsonLikeWriter write (String name, BigDecimal value) throws IOException;
069        public abstract JsonLikeWriter write (String name, long value) throws IOException;
070        public abstract JsonLikeWriter write (String name, double value) throws IOException;
071        public abstract JsonLikeWriter write (String name, Boolean value) throws IOException;
072        public abstract JsonLikeWriter write (String name, boolean value) throws IOException;
073        public abstract JsonLikeWriter writeNull (String name) throws IOException;
074
075        public abstract JsonLikeWriter endObject () throws IOException;
076        public abstract JsonLikeWriter endArray () throws IOException;
077        public abstract JsonLikeWriter endBlock () throws IOException;
078        
079        public JsonLikeWriter() {
080                super();
081        }
082
083}