Skip to content

Commit 6358b7f

Browse files
authored
Merge pull request stleary#854 from jscrdev/fixed-javadocs
Enhanced documentation for Java classes
2 parents 8550175 + 99c84fd commit 6358b7f

File tree

9 files changed

+68
-1
lines changed

9 files changed

+68
-1
lines changed

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<groupId>org.apache.maven.plugins</groupId>
127127
<artifactId>maven-javadoc-plugin</artifactId>
128128
<version>3.5.0</version>
129+
<configuration>
130+
<source>8</source>
131+
</configuration>
129132
<executions>
130133
<execution>
131134
<id>attach-javadocs</id>

src/main/java/org/json/JSONObject.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ public String toString() {
148148
*/
149149
private final Map<String, Object> map;
150150

151+
/**
152+
* Retrieves the type of the underlying Map in this class.
153+
*
154+
* @return The class object representing the type of the underlying Map.
155+
*/
151156
public Class<? extends Map> getMapType() {
152157
return map.getClass();
153158
}
@@ -369,7 +374,6 @@ private JSONObject(Map<?, ?> m, int recursionDepth, JSONParserConfiguration json
369374
* &#64;JSONPropertyIgnore
370375
* public String getName() { return this.name; }
371376
* </pre>
372-
* <p>
373377
*
374378
* @param bean
375379
* An object that has getter methods that should be used to make
@@ -2232,6 +2236,14 @@ public static String quote(String string) {
22322236
}
22332237
}
22342238

2239+
/**
2240+
* Quotes a string and appends the result to a given Writer.
2241+
*
2242+
* @param string The input string to be quoted.
2243+
* @param w The Writer to which the quoted string will be appended.
2244+
* @return The same Writer instance after appending the quoted string.
2245+
* @throws IOException If an I/O error occurs while writing to the Writer.
2246+
*/
22352247
public static Writer quote(String string, Writer w) throws IOException {
22362248
if (string == null || string.isEmpty()) {
22372249
w.write("\"\"");

src/main/java/org/json/JSONPointer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ public JSONPointer(final String pointer) {
163163
//}
164164
}
165165

166+
/**
167+
* Constructs a new JSONPointer instance with the provided list of reference tokens.
168+
*
169+
* @param refTokens A list of strings representing the reference tokens for the JSON Pointer.
170+
* Each token identifies a step in the path to the targeted value.
171+
*/
166172
public JSONPointer(List<String> refTokens) {
167173
this.refTokens = new ArrayList<String>(refTokens);
168174
}

src/main/java/org/json/JSONPointerException.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@
1414
public class JSONPointerException extends JSONException {
1515
private static final long serialVersionUID = 8872944667561856751L;
1616

17+
/**
18+
* Constructs a new JSONPointerException with the specified error message.
19+
*
20+
* @param message The detail message describing the reason for the exception.
21+
*/
1722
public JSONPointerException(String message) {
1823
super(message);
1924
}
2025

26+
/**
27+
* Constructs a new JSONPointerException with the specified error message and cause.
28+
*
29+
* @param message The detail message describing the reason for the exception.
30+
* @param cause The cause of the exception.
31+
*/
2132
public JSONPointerException(String message, Throwable cause) {
2233
super(message, cause);
2334
}

src/main/java/org/json/JSONTokener.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ public String toString() {
525525
this.line + "]";
526526
}
527527

528+
/**
529+
* Closes the underlying reader, releasing any resources associated with it.
530+
*
531+
* @throws IOException If an I/O error occurs while closing the reader.
532+
*/
528533
public void close() throws IOException {
529534
if(reader!=null){
530535
reader.close();

src/main/java/org/json/ParserConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ public class ParserConfiguration {
2929
*/
3030
protected int maxNestingDepth;
3131

32+
/**
33+
* Constructs a new ParserConfiguration with default settings.
34+
*/
3235
public ParserConfiguration() {
3336
this.keepStrings = false;
3437
this.maxNestingDepth = DEFAULT_MAXIMUM_NESTING_DEPTH;
3538
}
3639

40+
/**
41+
* Constructs a new ParserConfiguration with the specified settings.
42+
*
43+
* @param keepStrings A boolean indicating whether to preserve strings during parsing.
44+
* @param maxNestingDepth An integer representing the maximum allowed nesting depth.
45+
*/
3746
protected ParserConfiguration(final boolean keepStrings, final int maxNestingDepth) {
3847
this.keepStrings = keepStrings;
3948
this.maxNestingDepth = maxNestingDepth;

src/main/java/org/json/XML.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public class XML {
5656
*/
5757
public static final String NULL_ATTR = "xsi:nil";
5858

59+
/**
60+
* Represents the XML attribute name for specifying type information.
61+
*/
5962
public static final String TYPE_ATTR = "xsi:type";
6063

6164
/**

src/main/java/org/json/XMLParserConfiguration.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,20 @@ public XMLParserConfiguration withShouldTrimWhitespace(boolean shouldTrimWhiteSp
352352
return clonedConfiguration;
353353
}
354354

355+
/**
356+
* Checks if the parser should automatically close empty XML tags.
357+
*
358+
* @return {@code true} if empty XML tags should be automatically closed, {@code false} otherwise.
359+
*/
355360
public boolean isCloseEmptyTag() {
356361
return this.closeEmptyTag;
357362
}
363+
364+
/**
365+
* Checks if the parser should trim white spaces from XML content.
366+
*
367+
* @return {@code true} if white spaces should be trimmed, {@code false} otherwise.
368+
*/
358369
public boolean shouldTrimWhiteSpace() {
359370
return this.shouldTrimWhiteSpace;
360371
}

src/main/java/org/json/XMLXsiTypeConverter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,12 @@
4242
* @param <T> return type of convert method
4343
*/
4444
public interface XMLXsiTypeConverter<T> {
45+
46+
/**
47+
* Converts an XML xsi:type attribute value to the specified type {@code T}.
48+
*
49+
* @param value The string representation of the XML xsi:type attribute value to be converted.
50+
* @return An object of type {@code T} representing the converted value.
51+
*/
4552
T convert(String value);
4653
}

0 commit comments

Comments
 (0)