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 - 2021 Smile CDR, Inc.
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 JsonLikeWriter() {
034                super();
035        }
036
037        public boolean isPrettyPrint() {
038                return prettyPrint;
039        }
040
041        public void setPrettyPrint(boolean tf) {
042                prettyPrint = tf;
043        }
044
045        public Writer getWriter() {
046                return writer;
047        }
048
049        public void setWriter(Writer writer) {
050                this.writer = writer;
051        }
052
053        public abstract JsonLikeWriter init() throws IOException;
054
055        public abstract JsonLikeWriter flush() throws IOException;
056
057        public abstract void close() throws IOException;
058
059        public abstract JsonLikeWriter beginObject() throws IOException;
060
061        public abstract JsonLikeWriter beginObject(String name) throws IOException;
062
063        public abstract JsonLikeWriter beginArray(String name) throws IOException;
064
065        public abstract JsonLikeWriter write(String value) throws IOException;
066
067        public abstract JsonLikeWriter write(BigInteger value) throws IOException;
068
069        public abstract JsonLikeWriter write(BigDecimal value) throws IOException;
070
071        public abstract JsonLikeWriter write(long value) throws IOException;
072
073        public abstract JsonLikeWriter write(double value) throws IOException;
074
075        public abstract JsonLikeWriter write(Boolean value) throws IOException;
076
077        public abstract JsonLikeWriter write(boolean value) throws IOException;
078
079        public abstract JsonLikeWriter writeNull() throws IOException;
080
081        public abstract JsonLikeWriter write(String name, String value) throws IOException;
082
083        public abstract JsonLikeWriter write(String name, BigInteger value) throws IOException;
084
085        public abstract JsonLikeWriter write(String name, BigDecimal value) throws IOException;
086
087        public abstract JsonLikeWriter write(String name, long value) throws IOException;
088
089        public abstract JsonLikeWriter write(String name, double value) throws IOException;
090
091        public abstract JsonLikeWriter write(String name, Boolean value) throws IOException;
092
093        public abstract JsonLikeWriter write(String name, boolean value) throws IOException;
094
095        public abstract JsonLikeWriter endObject() throws IOException;
096
097        public abstract JsonLikeWriter endArray() throws IOException;
098
099        public abstract JsonLikeWriter endBlock() throws IOException;
100
101}