Method and Description | 85 |
---|
org.hjson.HjsonOptions.getEmitRootBraces()
89 | will always return true.
90 | |
91 |
org.hjson.HjsonOptions.setEmitRootBraces(boolean)
94 | root braces are always emitted.
95 | |
96 |
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
78 |Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
90 |Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
110 |Each annotation type has its own separate page with the following sections:
114 |Each enum has its own separate page with the following sections:
125 |There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
143 |The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
147 |These links take you to the next or previous class, interface, package, or related page.
151 |These links show and hide the HTML frames. All pages are available with or without frames.
155 |The All Classes link shows all classes and interfaces except non-static nested types.
159 |Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
163 |The Constant Field Values page lists the static final fields and their values.
167 |public class HjsonDsf
110 | extends java.lang.Object
111 | Modifier and Type | 128 |Method and Description | 129 |
---|---|
static IHjsonDsfProvider |
132 | hex(boolean stringify)
133 | Returns a hex DSF provider
134 | |
135 |
static IHjsonDsfProvider |
138 | math()
139 | Returns a math DSF provider
140 | |
141 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static IHjsonDsfProvider math()171 |
public static IHjsonDsfProvider hex(boolean stringify)185 |
stringify
- true to output all integers as hex valuespublic interface IHjsonDsfProvider
102 | Modifier and Type | 119 |Method and Description | 120 |
---|---|
java.lang.String |
123 | getDescription()
124 | Gets the description of this DSF.
125 | |
126 |
java.lang.String |
129 | getName()
130 | Gets the name of this DSF.
131 | |
132 |
JsonValue |
135 | parse(java.lang.String text)
136 | Tries to parse the text as a DSF value.
137 | |
138 |
java.lang.String |
141 | stringify(JsonValue value)
142 | Stringifies DSF values.
143 | |
144 |
java.lang.String getName()167 |
java.lang.String getDescription()181 |
JsonValue parse(java.lang.String text)195 |
text
- the DSF valuejava.lang.String stringify(JsonValue value)211 |
value
- the JSON valueInterface | 79 |Description | 80 |
---|---|
IHjsonDsfProvider | 84 |
85 | A interface to support Domain Specific Formats for Hjson.
86 | |
87 |
Class | 96 |Description | 97 |
---|---|
HjsonDsf | 101 |
102 | Provides standard DSF providers.
103 | |
104 |
HjsonOptions | 107 |
108 | Defines options for Hjson
109 | |
110 |
JsonArray | 113 |
114 | Represents a JSON array, an ordered collection of JSON values.
115 | |
116 |
JsonObject | 119 |
120 | Represents a JSON object, a set of name/value pairs, where the names are strings and the values
121 | are JSON values.
122 | |
123 |
JsonObject.Member | 126 |
127 | Represents a member of a JSON object, a pair of a name and a value.
128 | |
129 |
JsonValue | 132 |
133 | Represents a JSON value.
134 | |
135 |
Enum | 144 |Description | 145 |
---|---|
JsonType | 149 |
150 | Defines the known json types.
151 | |
152 |
Stringify | 155 |
156 | The ToString format.
157 | |
158 |
Exception | 167 |Description | 168 |
---|---|
ParseException | 172 |
173 | An unchecked exception to indicate that an input does not qualify as valid JSON.
174 | |
175 |
java.util.List<E> values88 |
private void readObject(java.io.ObjectInputStream inputStream) 104 | throws java.io.IOException, 105 | java.lang.ClassNotFoundException106 |
java.io.IOException
java.lang.ClassNotFoundException
java.util.List<E> names120 |
java.util.List<E> values124 |
int offset145 |
int line149 |
int column153 |
true
if this feature is enabled.
70 | */
71 | @Deprecated
72 | public boolean getEmitRootBraces() { return true; }
73 |
74 | /**
75 | * Sets whether root braces should be emitted.
76 | *
77 | * @deprecated root braces are always emitted.
78 | * @param value value
79 | */
80 | @Deprecated
81 | public void setEmitRootBraces(boolean value) { }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/org/hjson/HjsonWriter.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Christian Zangl
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.hjson;
23 |
24 | import java.io.IOException;
25 | import java.io.Writer;
26 | import java.util.regex.Matcher;
27 | import java.util.regex.Pattern;
28 |
29 | class HjsonWriter {
30 |
31 | private IHjsonDsfProvider[] dsfProviders;
32 |
33 | static String commonRange = "\\x7f-\\x9f\\x{00ad}\\x{0600}-\\x{0604}\\x{070f}\\x{17b4}\\x{17b5}\\x{200c}-\\x{200f}\\x{2028}-\\x{202f}\\x{2060}-\\x{206f}\\x{feff}\\x{fff0}-\\x{ffff}";
34 | // needsEscape tests if the string can be written without escapes
35 | static Pattern needsEscape = Pattern.compile("[\\\\\\\"\\x00-\\x1f" + commonRange + "]");
36 | // needsQuotes tests if the string can be written as a quoteless string (includes needsEscape but without \\\\ and \\")
37 | static Pattern needsQuotes = Pattern.compile("^\\s|^\"|^'|^#|^/\\*|^//|^\\{|^\\}|^\\[|^\\]|^:|^,|\\s$|[\\x00-\\x1f\\x7f-\\x9f\\x{00ad}\\x{0600}-\\x{0604}\\x{070f}\\x{17b4}\\x{17b5}\\x{200c}-\\x{200f}\\x{2028}-\\x{202f}\\x{2060}-\\x{206f}\\x{feff}\\x{fff0}-\\x{ffff}]");
38 | // needsEscapeML tests if the string can be written as a multiline string (like needsEscape but without \\n, \\\\, \\", \\t)
39 | static Pattern needsEscapeML = Pattern.compile("'''|^[\\s]+$|[\\x00-\\x08\\x0b-\\x1f" + commonRange + "]");
40 | static Pattern needsEscapeName=Pattern.compile("[,\\{\\[\\}\\]\\s:#\"']|//|/\\*");
41 |
42 | public HjsonWriter(HjsonOptions options) {
43 | if (options!=null) {
44 | dsfProviders=options.getDsfProviders();
45 | } else {
46 | dsfProviders=new IHjsonDsfProvider[0];
47 | }
48 | }
49 |
50 | void nl(Writer tw, int level) throws IOException {
51 | tw.write(JsonValue.eol);
52 | for (int i=0; i