Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f2d3f51f
Commit
f2d3f51f
authored
Jan 08, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
c7f5f073
4568f14c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2446 additions
and
2268 deletions
+2446
-2268
JSON.java
...pringframework/boot/configurationprocessor/json/JSON.java
+103
-89
JSONArray.java
...framework/boot/configurationprocessor/json/JSONArray.java
+639
-564
JSONException.java
...ework/boot/configurationprocessor/json/JSONException.java
+3
-3
JSONObject.java
...ramework/boot/configurationprocessor/json/JSONObject.java
+788
-694
JSONStringer.java
...mework/boot/configurationprocessor/json/JSONStringer.java
+405
-371
JSONTokener.java
...amework/boot/configurationprocessor/json/JSONTokener.java
+508
-547
No files found.
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/json/JSON.java
View file @
f2d3f51f
...
@@ -17,100 +17,114 @@
...
@@ -17,100 +17,114 @@
package
org
.
springframework
.
boot
.
configurationprocessor
.
json
;
package
org
.
springframework
.
boot
.
configurationprocessor
.
json
;
class
JSON
{
class
JSON
{
/**
/**
* Returns the input if it is a JSON-permissible value; throws otherwise.
* Returns the input if it is a JSON-permissible value; throws otherwise.
*/
*/
static
double
checkDouble
(
double
d
)
throws
JSONException
{
static
double
checkDouble
(
double
d
)
throws
JSONException
{
if
(
Double
.
isInfinite
(
d
)
||
Double
.
isNaN
(
d
))
{
if
(
Double
.
isInfinite
(
d
)
||
Double
.
isNaN
(
d
))
{
throw
new
JSONException
(
"Forbidden numeric value: "
+
d
);
throw
new
JSONException
(
"Forbidden numeric value: "
+
d
);
}
}
return
d
;
return
d
;
}
}
static
Boolean
toBoolean
(
Object
value
)
{
static
Boolean
toBoolean
(
Object
value
)
{
if
(
value
instanceof
Boolean
)
{
if
(
value
instanceof
Boolean
)
{
return
(
Boolean
)
value
;
return
(
Boolean
)
value
;
}
else
if
(
value
instanceof
String
)
{
}
String
stringValue
=
(
String
)
value
;
else
if
(
value
instanceof
String
)
{
if
(
"true"
.
equalsIgnoreCase
(
stringValue
))
{
String
stringValue
=
(
String
)
value
;
return
true
;
if
(
"true"
.
equalsIgnoreCase
(
stringValue
))
{
}
else
if
(
"false"
.
equalsIgnoreCase
(
stringValue
))
{
return
true
;
return
false
;
}
}
else
if
(
"false"
.
equalsIgnoreCase
(
stringValue
))
{
}
return
false
;
return
null
;
}
}
}
return
null
;
}
static
Double
toDouble
(
Object
value
)
{
static
Double
toDouble
(
Object
value
)
{
if
(
value
instanceof
Double
)
{
if
(
value
instanceof
Double
)
{
return
(
Double
)
value
;
return
(
Double
)
value
;
}
else
if
(
value
instanceof
Number
)
{
}
return
((
Number
)
value
).
doubleValue
();
else
if
(
value
instanceof
Number
)
{
}
else
if
(
value
instanceof
String
)
{
return
((
Number
)
value
).
doubleValue
();
try
{
}
return
Double
.
valueOf
((
String
)
value
);
else
if
(
value
instanceof
String
)
{
}
catch
(
NumberFormatException
ignored
)
{
try
{
}
return
Double
.
valueOf
((
String
)
value
);
}
}
return
null
;
catch
(
NumberFormatException
ignored
)
{
}
}
}
return
null
;
}
static
Integer
toInteger
(
Object
value
)
{
static
Integer
toInteger
(
Object
value
)
{
if
(
value
instanceof
Integer
)
{
if
(
value
instanceof
Integer
)
{
return
(
Integer
)
value
;
return
(
Integer
)
value
;
}
else
if
(
value
instanceof
Number
)
{
}
return
((
Number
)
value
).
intValue
();
else
if
(
value
instanceof
Number
)
{
}
else
if
(
value
instanceof
String
)
{
return
((
Number
)
value
).
intValue
();
try
{
}
return
(
int
)
Double
.
parseDouble
((
String
)
value
);
else
if
(
value
instanceof
String
)
{
}
catch
(
NumberFormatException
ignored
)
{
try
{
}
return
(
int
)
Double
.
parseDouble
((
String
)
value
);
}
}
return
null
;
catch
(
NumberFormatException
ignored
)
{
}
}
}
return
null
;
}
static
Long
toLong
(
Object
value
)
{
static
Long
toLong
(
Object
value
)
{
if
(
value
instanceof
Long
)
{
if
(
value
instanceof
Long
)
{
return
(
Long
)
value
;
return
(
Long
)
value
;
}
else
if
(
value
instanceof
Number
)
{
}
return
((
Number
)
value
).
longValue
();
else
if
(
value
instanceof
Number
)
{
}
else
if
(
value
instanceof
String
)
{
return
((
Number
)
value
).
longValue
();
try
{
}
return
(
long
)
Double
.
parseDouble
((
String
)
value
);
else
if
(
value
instanceof
String
)
{
}
catch
(
NumberFormatException
ignored
)
{
try
{
}
return
(
long
)
Double
.
parseDouble
((
String
)
value
);
}
}
return
null
;
catch
(
NumberFormatException
ignored
)
{
}
}
}
return
null
;
}
static
String
toString
(
Object
value
)
{
static
String
toString
(
Object
value
)
{
if
(
value
instanceof
String
)
{
if
(
value
instanceof
String
)
{
return
(
String
)
value
;
return
(
String
)
value
;
}
else
if
(
value
!=
null
)
{
}
return
String
.
valueOf
(
value
);
else
if
(
value
!=
null
)
{
}
return
String
.
valueOf
(
value
);
return
null
;
}
}
return
null
;
}
public
static
JSONException
typeMismatch
(
Object
indexOrName
,
Object
actual
,
public
static
JSONException
typeMismatch
(
Object
indexOrName
,
Object
actual
,
String
requiredType
)
throws
JSONException
{
String
requiredType
)
throws
JSONException
{
if
(
actual
==
null
)
{
if
(
actual
==
null
)
{
throw
new
JSONException
(
"Value at "
+
indexOrName
+
" is null."
);
throw
new
JSONException
(
"Value at "
+
indexOrName
+
" is null."
);
}
else
{
}
throw
new
JSONException
(
"Value "
+
actual
+
" at "
+
indexOrName
else
{
+
" of type "
+
actual
.
getClass
().
getName
()
throw
new
JSONException
(
"Value "
+
actual
+
" at "
+
indexOrName
+
" cannot be converted to "
+
requiredType
);
+
" of type "
+
actual
.
getClass
().
getName
()
}
+
" cannot be converted to "
+
requiredType
);
}
}
}
public
static
JSONException
typeMismatch
(
Object
actual
,
String
requiredType
)
public
static
JSONException
typeMismatch
(
Object
actual
,
String
requiredType
)
throws
JSONException
{
throws
JSONException
{
if
(
actual
==
null
)
{
if
(
actual
==
null
)
{
throw
new
JSONException
(
"Value is null."
);
throw
new
JSONException
(
"Value is null."
);
}
else
{
}
throw
new
JSONException
(
"Value "
+
actual
else
{
+
" of type "
+
actual
.
getClass
().
getName
()
throw
new
JSONException
(
"Value "
+
actual
+
" cannot be converted to "
+
requiredType
);
+
" of type "
+
actual
.
getClass
().
getName
()
}
+
" cannot be converted to "
+
requiredType
);
}
}
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/json/JSONArray.java
View file @
f2d3f51f
This diff is collapsed.
Click to expand it.
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/json/JSONException.java
View file @
f2d3f51f
...
@@ -43,7 +43,7 @@ package org.springframework.boot.configurationprocessor.json;
...
@@ -43,7 +43,7 @@ package org.springframework.boot.configurationprocessor.json;
*/
*/
public
class
JSONException
extends
Exception
{
public
class
JSONException
extends
Exception
{
public
JSONException
(
String
s
)
{
public
JSONException
(
String
s
)
{
super
(
s
);
super
(
s
);
}
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/json/JSONObject.java
View file @
f2d3f51f
This diff is collapsed.
Click to expand it.
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/json/JSONStringer.java
View file @
f2d3f51f
This diff is collapsed.
Click to expand it.
spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/json/JSONTokener.java
View file @
f2d3f51f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment