|
| 1 | +/* |
| 2 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
| 3 | + * |
| 4 | + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. |
| 5 | + * |
| 6 | + * The contents of this file are subject to the terms of either the GNU |
| 7 | + * General Public License Version 2 only ("GPL") or the Common Development |
| 8 | + * and Distribution License("CDDL") (collectively, the "License"). You |
| 9 | + * may not use this file except in compliance with the License. You can |
| 10 | + * obtain a copy of the License at |
| 11 | + * https://oss.oracle.com/licenses/CDDL+GPL-1.1 |
| 12 | + * or LICENSE.txt. See the License for the specific |
| 13 | + * language governing permissions and limitations under the License. |
| 14 | + * |
| 15 | + * When distributing the software, include this License Header Notice in each |
| 16 | + * file and include the License file at LICENSE.txt. |
| 17 | + * |
| 18 | + * GPL Classpath Exception: |
| 19 | + * Oracle designates this particular file as subject to the "Classpath" |
| 20 | + * exception as provided by Oracle in the GPL Version 2 section of the License |
| 21 | + * file that accompanied this code. |
| 22 | + * |
| 23 | + * Modifications: |
| 24 | + * If applicable, add the following below the License Header, with the fields |
| 25 | + * enclosed by brackets [] replaced by your own identifying information: |
| 26 | + * "Portions Copyright [year] [name of copyright owner]" |
| 27 | + * |
| 28 | + * Contributor(s): |
| 29 | + * If you wish your version of this file to be governed by only the CDDL or |
| 30 | + * only the GPL Version 2, indicate your decision by adding "[Contributor] |
| 31 | + * elects to include this software in this distribution under the [CDDL or GPL |
| 32 | + * Version 2] license." If you don't indicate a single choice of license, a |
| 33 | + * recipient has the option to distribute your version of this file under |
| 34 | + * either the CDDL, the GPL Version 2 or to extend the choice of license to |
| 35 | + * its licensees as provided above. However, if you add GPL Version 2 code |
| 36 | + * and therefore, elected the GPL Version 2 license, then the option applies |
| 37 | + * only if the new code is made subject to such option by the copyright |
| 38 | + * holder. |
| 39 | + */ |
| 40 | + |
| 41 | +package org.glassfish.json.customprovider; |
| 42 | + |
| 43 | +import javax.json.JsonException; |
| 44 | +import javax.json.JsonValue; |
| 45 | +import javax.json.stream.JsonGenerator; |
| 46 | +import java.io.IOException; |
| 47 | +import java.io.Writer; |
| 48 | +import java.math.BigDecimal; |
| 49 | +import java.math.BigInteger; |
| 50 | + |
| 51 | +/** |
| 52 | + * @author Jitendra Kotamraju |
| 53 | + */ |
| 54 | +public class TestGenerator implements JsonGenerator { |
| 55 | + private final Writer writer; |
| 56 | + |
| 57 | + public TestGenerator(Writer writer) { |
| 58 | + this.writer = writer; |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public void flush() { |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public JsonGenerator writeStartObject() { |
| 67 | + return null; |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public JsonGenerator writeStartObject(String name) { |
| 72 | + return null; |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public JsonGenerator write(String name, String fieldValue) { |
| 77 | + return null; |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public JsonGenerator write(String name, int value) { |
| 82 | + return null; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public JsonGenerator write(String name, long value) { |
| 87 | + return null; |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public JsonGenerator write(String name, double value) { |
| 92 | + return null; |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public JsonGenerator write(String name, BigInteger value) { |
| 97 | + return null; |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public JsonGenerator write(String name, BigDecimal value) { |
| 102 | + return null; |
| 103 | + } |
| 104 | + |
| 105 | + @Override |
| 106 | + public JsonGenerator write(String name, boolean value) { |
| 107 | + return null; |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public JsonGenerator writeNull(String name) { |
| 112 | + return null; |
| 113 | + } |
| 114 | + |
| 115 | + @Override |
| 116 | + public JsonGenerator write(JsonValue value) { |
| 117 | + return null; |
| 118 | + } |
| 119 | + |
| 120 | + @Override |
| 121 | + public JsonGenerator writeStartArray() { |
| 122 | + try { |
| 123 | + writer.write("["); |
| 124 | + } catch(IOException ioe) { |
| 125 | + throw new JsonException("I/O error", ioe); |
| 126 | + } |
| 127 | + return this; |
| 128 | + } |
| 129 | + |
| 130 | + @Override |
| 131 | + public JsonGenerator writeStartArray(String name) { |
| 132 | + return null; |
| 133 | + } |
| 134 | + |
| 135 | + @Override |
| 136 | + public JsonGenerator write(String name, JsonValue value) { |
| 137 | + return null; |
| 138 | + } |
| 139 | + |
| 140 | + @Override |
| 141 | + public JsonGenerator write(String value) { |
| 142 | + return null; |
| 143 | + } |
| 144 | + |
| 145 | + |
| 146 | + @Override |
| 147 | + public JsonGenerator write(int value) { |
| 148 | + return null; |
| 149 | + } |
| 150 | + |
| 151 | + @Override |
| 152 | + public JsonGenerator write(long value) { |
| 153 | + return null; |
| 154 | + } |
| 155 | + |
| 156 | + @Override |
| 157 | + public JsonGenerator write(double value) { |
| 158 | + return null; |
| 159 | + } |
| 160 | + |
| 161 | + @Override |
| 162 | + public JsonGenerator write(BigInteger value) { |
| 163 | + return null; |
| 164 | + } |
| 165 | + |
| 166 | + @Override |
| 167 | + public JsonGenerator write(BigDecimal value) { |
| 168 | + return null; |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + public JsonGenerator write(boolean value) { |
| 173 | + return null; |
| 174 | + } |
| 175 | + |
| 176 | + @Override |
| 177 | + public JsonGenerator writeNull() { |
| 178 | + return null; |
| 179 | + } |
| 180 | + |
| 181 | + @Override |
| 182 | + public JsonGenerator writeEnd() { |
| 183 | + try { |
| 184 | + writer.write("]"); |
| 185 | + } catch(IOException ioe) { |
| 186 | + throw new JsonException("I/O error", ioe); |
| 187 | + } |
| 188 | + return this; |
| 189 | + } |
| 190 | + |
| 191 | + @Override |
| 192 | + public void close() { |
| 193 | + try { |
| 194 | + writer.close(); |
| 195 | + } catch(IOException ioe) { |
| 196 | + throw new JsonException("I/O error", ioe); |
| 197 | + } |
| 198 | + } |
| 199 | + |
| 200 | + @Override |
| 201 | + public JsonGenerator writeKey(String string) { |
| 202 | + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
| 203 | + } |
| 204 | + |
| 205 | +} |
0 commit comments