001/*
002 * #%L
003 * HAPI FHIR - Core Library
004 * %%
005 * Copyright (C) 2014 - 2019 University Health Network
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.parser.json;
021
022import java.io.Reader;
023import java.io.Writer;
024
025import ca.uhn.fhir.parser.DataFormatException;
026
027/**
028 * This interface is the generic representation of any sort of data 
029 * structure that looks and smells like JSON. These data structures
030 * can be abstractly viewed as a <code.Map</code> or <code>List</code>
031 * whose members are other Maps, Lists, or scalars (Strings, Numbers, Boolean)
032 * 
033 * @author Bill.Denton
034 */
035public interface JsonLikeStructure {
036        public JsonLikeStructure getInstance();
037        
038        /**
039         * Parse the JSON document into the Json-like structure
040         * so that it can be navigated.
041         * 
042         * @param theReader a <code>Reader</code> that will
043         *                      process the JSON input stream
044         * @throws DataFormatException when invalid JSON is received
045         */
046        public void load (Reader theReader) throws DataFormatException;
047        public void load (Reader theReader, boolean allowArray) throws DataFormatException;
048        public JsonLikeObject getRootObject () throws DataFormatException;
049        public JsonLikeArray getRootArray () throws DataFormatException;
050        public JsonLikeWriter getJsonLikeWriter ();
051        public JsonLikeWriter getJsonLikeWriter (Writer writer);
052}