Changeset 13231 in josm for trunk/src/org/glassfish/json/JsonWriterImpl.java
- Timestamp:
- 2017-12-23T02:40:43+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/glassfish/json/JsonWriterImpl.java
r6756 r13231 2 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 3 * 4 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. 4 * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved. 5 5 * 6 6 * The contents of this file are subject to the terms of either the GNU … … 9 9 * may not use this file except in compliance with the License. You can 10 10 * obtain a copy of the License at 11 * https:// glassfish.dev.java.net/public/CDDL+GPL_1_1.html12 * or packager/legal/LICENSE.txt. See the License for the specific11 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 12 * or LICENSE.txt. See the License for the specific 13 13 * language governing permissions and limitations under the License. 14 14 * 15 15 * When distributing the software, include this License Header Notice in each 16 * file and include the License file at packager/legal/LICENSE.txt.16 * file and include the License file at LICENSE.txt. 17 17 * 18 18 * GPL Classpath Exception: … … 49 49 import java.io.Writer; 50 50 import java.nio.charset.Charset; 51 import java.nio.charset.StandardCharsets; 51 52 import java.util.Map; 52 53 … … 57 58 */ 58 59 class JsonWriterImpl implements JsonWriter { 59 private static final Charset UTF_8 = Charset.forName("UTF-8");60 60 61 61 private final JsonGeneratorImpl generator; … … 75 75 76 76 JsonWriterImpl(OutputStream out, BufferPool bufferPool) { 77 this(out, UTF_8, false, bufferPool); 77 this(out, StandardCharsets.UTF_8, false, bufferPool); 78 78 } 79 79 80 80 JsonWriterImpl(OutputStream out, boolean prettyPrinting, BufferPool bufferPool) { 81 this(out, UTF_8, prettyPrinting, bufferPool); 81 this(out, StandardCharsets.UTF_8, prettyPrinting, bufferPool); 82 82 } 83 83 … … 146 146 147 147 @Override 148 public void write(JsonValue value) { 149 switch (value.getValueType()) { 150 case OBJECT: 151 writeObject((JsonObject) value); 152 return; 153 case ARRAY: 154 writeArray((JsonArray) value); 155 return; 156 default: 157 if (writeDone) { 158 throw new IllegalStateException(JsonMessages.WRITER_WRITE_ALREADY_CALLED()); 159 } 160 writeDone = true; 161 generator.write(value); 162 generator.flushBuffer(); 163 if (os != null) { 164 generator.flush(); 165 } 166 } 167 } 168 169 @Override 148 170 public void close() { 149 171 writeDone = true;
Note:
See TracChangeset
for help on using the changeset viewer.