View Javadoc
1   package ca.uhn.fhir.parser.json;
2   
3   import java.io.IOException;
4   import java.io.Writer;
5   import java.math.BigDecimal;
6   import java.math.BigInteger;
7   
8   /*
9    * #%L
10   * HAPI FHIR - Core Library
11   * %%
12   * Copyright (C) 2014 - 2018 University Health Network
13   * %%
14   * Licensed under the Apache License, Version 2.0 (the "License");
15   * you may not use this file except in compliance with the License.
16   * You may obtain a copy of the License at
17   * 
18   *      http://www.apache.org/licenses/LICENSE-2.0
19   * 
20   * Unless required by applicable law or agreed to in writing, software
21   * distributed under the License is distributed on an "AS IS" BASIS,
22   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23   * See the License for the specific language governing permissions and
24   * limitations under the License.
25   * #L%
26   */
27  
28  public abstract class JsonLikeWriter {
29  
30  	private boolean prettyPrint;
31  	private Writer writer;
32  	
33  	public void setPrettyPrint (boolean tf) {
34  		prettyPrint = tf; 
35  	}
36  	public boolean isPrettyPrint () {
37  		return prettyPrint;
38  	}
39  	
40  	public void setWriter (Writer writer) {
41  		this.writer = writer;
42  	}
43  	public Writer getWriter () {
44  		return writer;
45  	}
46  	
47  	public abstract JsonLikeWriter init () throws IOException;
48  	public abstract JsonLikeWriter flush () throws IOException;
49  	public abstract void close () throws IOException;
50  	
51  	public abstract JsonLikeWriter beginObject () throws IOException;
52  	public abstract JsonLikeWriter beginArray () throws IOException;
53  
54  	public abstract JsonLikeWriter beginObject (String name) throws IOException;
55  	public abstract JsonLikeWriter beginArray (String name) throws IOException;
56  	
57  	public abstract JsonLikeWriter write (String value) throws IOException;
58  	public abstract JsonLikeWriter write (BigInteger value) throws IOException;
59  	public abstract JsonLikeWriter write (BigDecimal value) throws IOException;
60  	public abstract JsonLikeWriter write (long value) throws IOException;
61  	public abstract JsonLikeWriter write (double value) throws IOException;
62  	public abstract JsonLikeWriter write (Boolean value) throws IOException;
63  	public abstract JsonLikeWriter write (boolean value) throws IOException;
64  	public abstract JsonLikeWriter writeNull () throws IOException;
65  	
66  	public abstract JsonLikeWriter write (String name, String value) throws IOException;
67  	public abstract JsonLikeWriter write (String name, BigInteger value) throws IOException;
68  	public abstract JsonLikeWriter write (String name, BigDecimal value) throws IOException;
69  	public abstract JsonLikeWriter write (String name, long value) throws IOException;
70  	public abstract JsonLikeWriter write (String name, double value) throws IOException;
71  	public abstract JsonLikeWriter write (String name, Boolean value) throws IOException;
72  	public abstract JsonLikeWriter write (String name, boolean value) throws IOException;
73  	public abstract JsonLikeWriter writeNull (String name) throws IOException;
74  
75  	public abstract JsonLikeWriter endObject () throws IOException;
76  	public abstract JsonLikeWriter endArray () throws IOException;
77  	public abstract JsonLikeWriter endBlock () throws IOException;
78  	
79  	public JsonLikeWriter() {
80  		super();
81  	}
82  
83  }