001/*
002Copyright (c) 2011+, HL7, Inc
003All rights reserved.
004
005Redistribution and use in source and binary forms, with or without modification, 
006are permitted provided that the following conditions are met:
007
008 * Redistributions of source code must retain the above copyright notice, this 
009   list of conditions and the following disclaimer.
010 * Redistributions in binary form must reproduce the above copyright notice, 
011   this list of conditions and the following disclaimer in the documentation 
012   and/or other materials provided with the distribution.
013 * Neither the name of HL7 nor the names of its contributors may be used to 
014   endorse or promote products derived from this software without specific 
015   prior written permission.
016
017THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
018ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
019WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
020IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
021INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
022NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
023PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
024WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
025ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
026POSSIBILITY OF SUCH DAMAGE.
027
028*/
029package org.hl7.fhir.instance.utilities.xml;
030
031/*
032 * #%L
033 * HAPI FHIR Structures - HL7.org DSTU2
034 * %%
035 * Copyright (C) 2014 - 2015 University Health Network
036 * %%
037 * Licensed under the Apache License, Version 2.0 (the "License");
038 * you may not use this file except in compliance with the License.
039 * You may obtain a copy of the License at
040 * 
041 *      http://www.apache.org/licenses/LICENSE-2.0
042 * 
043 * Unless required by applicable law or agreed to in writing, software
044 * distributed under the License is distributed on an "AS IS" BASIS,
045 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
046 * See the License for the specific language governing permissions and
047 * limitations under the License.
048 * #L%
049 */
050
051
052import java.io.IOException;
053
054/**
055 * Generalize 
056 * @author dennisn
057 */
058public interface IXMLWriter {
059        
060        public abstract void start() throws IOException;
061
062        public abstract void attribute(String namespace, String name, String value,
063                        boolean onlyIfNotEmpty) throws IOException;
064
065        public abstract void attribute(String namespace, String name, String value)
066                        throws IOException;
067
068        public abstract void attribute(String name, String value,
069                        boolean onlyIfNotEmpty) throws IOException;
070
071        public abstract void attribute(String name, String value)
072                        throws IOException;
073
074        public abstract void attributeNoLines(String name, String value)
075                        throws IOException;
076
077//      public abstract XMLNamespace findByNamespace(String namespace);
078
079        public abstract boolean namespaceDefined(String namespace);
080
081//      public abstract XMLNamespace findByAbbreviation(String abbreviation);
082
083        public abstract boolean abbreviationDefined(String abbreviation);
084
085//      public abstract XMLNamespace findDefaultNamespace();
086
087        public abstract String getDefaultNamespace();
088
089        public abstract void namespace(String namespace) throws IOException;
090
091        public abstract void setDefaultNamespace(String namespace) throws IOException;
092
093        public abstract void namespace(String namespace, String abbreviation)
094                        throws IOException;
095
096        public abstract void comment(String comment, boolean doPretty)
097                        throws IOException;
098
099        public abstract void open(String namespace, String name) throws IOException;
100
101        public abstract void open(String namespace, String name, String comment)
102                        throws IOException;
103
104        public abstract void close(String name) throws IOException;
105
106        public abstract void close(String namespace, String name)
107                        throws IOException;
108
109        public abstract void closeToLevel(int count) throws IOException;
110
111        public abstract void close() throws IOException;
112
113        public abstract void open(String name) throws IOException;
114
115        public abstract void element(String namespace, String name, String content,
116                        boolean onlyIfNotEmpty) throws IOException;
117
118        public abstract void element(String namespace, String name, String content,
119                        String comment) throws IOException;
120
121        public abstract void element(String namespace, String name, String content)
122                        throws IOException;
123
124        public abstract void element(String name, String content,
125                        boolean onlyIfNotEmpty) throws IOException;
126
127        public abstract void element(String name, String content)
128                        throws IOException;
129
130        public abstract void text(String content) throws IOException;
131        
132        public abstract void text(String content, boolean dontEscape) throws IOException;
133
134        public abstract void cData(String text) throws IOException;
135
136        public abstract void writeBytes(byte[] bytes) throws IOException;
137
138        public abstract boolean isPretty() throws IOException;
139
140        public abstract void setPretty(boolean pretty) throws IOException;
141
142        /**
143         * Start comment inserts a <!-- in the stream, but allows the user to 
144         * go on creating xml content as usual, with proper formatting applied etc.
145         * Any comments inserted inside a comment will be terminated with -- > instead of -->
146         * so the comment doesn't close prematurely.
147         * @throws IOException 
148         */
149        public abstract void startCommentBlock() throws IOException;
150
151        public abstract void endCommentBlock() throws IOException;
152
153}