Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
9638c11e
Commit
9638c11e
authored
Jan 27, 2023
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSONから値を取り出すユーティリティを集約した
parent
ff4f0eee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
51 deletions
+48
-51
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/AcmsJSONParser.java
+27
-0
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/LockReportJSON.java
+13
-31
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/UnlockReportJSON.java
+8
-20
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/AcmsJSONParser.java
View file @
9638c11e
...
@@ -6,11 +6,15 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException;
...
@@ -6,11 +6,15 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import
jp.agentec.abook.abv.bl.common.exception.JSONValidationException
;
import
jp.agentec.abook.abv.bl.common.exception.JSONValidationException
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.adf.core.CloneableObject
;
import
jp.agentec.adf.core.CloneableObject
;
import
jp.agentec.adf.util.DateTimeFormat
;
import
jp.agentec.adf.util.DateTimeUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
jp.agentec.adf.util.StringUtil
;
import
org.json.adf.JSONException
;
import
org.json.adf.JSONException
;
import
org.json.adf.JSONObject
;
import
org.json.adf.JSONObject
;
import
java.util.Date
;
public
abstract
class
AcmsJSONParser
extends
CloneableObject
{
public
abstract
class
AcmsJSONParser
extends
CloneableObject
{
/**
/**
* {@link AcmsJSONParser} クラスのインスタンスを初期化します。
* {@link AcmsJSONParser} クラスのインスタンスを初期化します。
...
@@ -129,4 +133,27 @@ public abstract class AcmsJSONParser extends CloneableObject {
...
@@ -129,4 +133,27 @@ public abstract class AcmsJSONParser extends CloneableObject {
}
}
}
}
protected
int
getIntOrDef
(
JSONObject
json
,
String
key
,
int
def
)
{
if
(
json
.
has
(
key
))
{
return
json
.
getInt
(
key
);
}
else
{
return
def
;
}
}
protected
String
getStringOrNull
(
JSONObject
json
,
String
key
)
{
if
(
json
.
has
(
key
))
{
return
json
.
getString
(
key
);
}
else
{
return
null
;
}
}
protected
Date
getDateOrNull
(
JSONObject
json
,
String
key
)
{
if
(
json
.
has
(
key
))
{
return
DateTimeUtil
.
toDate
(
json
.
getString
(
key
),
"UTC"
,
DateTimeFormat
.
yyyyMMdd_hyphen
);
}
else
{
return
null
;
}
}
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/LockReportJSON.java
View file @
9638c11e
...
@@ -5,14 +5,13 @@ import org.json.adf.JSONObject;
...
@@ -5,14 +5,13 @@ import org.json.adf.JSONObject;
import
java.util.Date
;
import
java.util.Date
;
import
jp.agentec.abook.abv.bl.common.exception.AcmsException
;
import
jp.agentec.abook.abv.bl.common.exception.AcmsException
;
import
jp.agentec.adf.util.DateTimeFormat
;
import
jp.agentec.adf.util.DateTimeUtil
;
/**
/**
* checkapi/lockReport/のレスポンスを変換するクラス
* checkapi/lockReport/のレスポンスを変換するクラス
*/
*/
public
class
LockReportJSON
extends
AcmsCommonJSON
{
public
class
LockReportJSON
extends
AcmsCommonJSON
{
public
static
final
int
BAD_STATE
=
999
;
private
Date
presentTimeUTC
;
private
Date
presentTimeUTC
;
private
int
reportStatus
;
private
int
reportStatus
;
private
String
reportLockUserId
;
private
String
reportLockUserId
;
...
@@ -25,62 +24,45 @@ public class LockReportJSON extends AcmsCommonJSON {
...
@@ -25,62 +24,45 @@ public class LockReportJSON extends AcmsCommonJSON {
@Override
@Override
protected
void
parse
(
JSONObject
json
)
{
protected
void
parse
(
JSONObject
json
)
{
presentTimeUTC
=
d
ateOrNull
(
json
,
"presentTimeUTC"
);
presentTimeUTC
=
getD
ateOrNull
(
json
,
"presentTimeUTC"
);
reportStatus
=
intOrDef
(
json
,
"reportStatus"
,
999
);
reportStatus
=
getIntOrDef
(
json
,
"reportStatus"
,
BAD_STATE
);
reportLockUserId
=
s
tringOrNull
(
json
,
"reportLockUserId"
);
reportLockUserId
=
getS
tringOrNull
(
json
,
"reportLockUserId"
);
reportLockUserName
=
s
tringOrNull
(
json
,
"reportLockUserName"
);
reportLockUserName
=
getS
tringOrNull
(
json
,
"reportLockUserName"
);
reportLockTime
=
d
ateOrNull
(
json
,
"reportLockTime"
);
reportLockTime
=
getD
ateOrNull
(
json
,
"reportLockTime"
);
}
}
@SuppressWarnings
(
"unused"
)
int
getHttpStatus
()
{
int
getHttpStatus
()
{
return
httpStatus
;
return
httpStatus
;
}
}
@SuppressWarnings
(
"unused"
)
Date
getPresentTime
()
{
Date
getPresentTime
()
{
return
presentTime
;
return
presentTime
;
}
}
@SuppressWarnings
(
"unused"
)
public
Date
getPresentTimeUTC
()
{
public
Date
getPresentTimeUTC
()
{
return
presentTimeUTC
;
return
presentTimeUTC
;
}
}
@SuppressWarnings
(
"unused"
)
public
int
getReportStatus
()
{
public
int
getReportStatus
()
{
return
reportStatus
;
return
reportStatus
;
}
}
@SuppressWarnings
(
"unused"
)
public
String
getReportLockUserId
()
{
public
String
getReportLockUserId
()
{
return
reportLockUserId
;
return
reportLockUserId
;
}
}
@SuppressWarnings
(
"unused"
)
public
String
getReportLockUserName
()
{
public
String
getReportLockUserName
()
{
return
reportLockUserName
;
return
reportLockUserName
;
}
}
@SuppressWarnings
(
"unused"
)
public
Date
getReportLockTime
()
{
public
Date
getReportLockTime
()
{
return
reportLockTime
;
return
reportLockTime
;
}
}
private
int
intOrDef
(
JSONObject
json
,
String
key
,
int
def
)
{
if
(
json
.
has
(
key
))
{
return
json
.
getInt
(
key
);
}
else
{
return
def
;
}
}
private
String
stringOrNull
(
JSONObject
json
,
String
key
)
{
if
(
json
.
has
(
key
))
{
return
json
.
getString
(
key
);
}
else
{
return
null
;
}
}
private
Date
dateOrNull
(
JSONObject
json
,
String
key
)
{
if
(
json
.
has
(
key
))
{
return
DateTimeUtil
.
toDate
(
json
.
getString
(
key
),
"UTC"
,
DateTimeFormat
.
yyyyMMdd_hyphen
);
}
else
{
return
null
;
}
}
}
}
ABVJE_BL/src/jp/agentec/abook/abv/bl/acms/client/json/UnlockReportJSON.java
View file @
9638c11e
...
@@ -5,10 +5,10 @@ import org.json.adf.JSONObject;
...
@@ -5,10 +5,10 @@ import org.json.adf.JSONObject;
import
java.util.Date
;
import
java.util.Date
;
import
jp.agentec.abook.abv.bl.common.exception.AcmsException
;
import
jp.agentec.abook.abv.bl.common.exception.AcmsException
;
import
jp.agentec.adf.util.DateTimeFormat
;
import
jp.agentec.adf.util.DateTimeUtil
;
public
class
UnlockReportJSON
extends
AcmsCommonJSON
{
public
class
UnlockReportJSON
extends
AcmsCommonJSON
{
public
static
final
int
BAD_STATE
=
999
;
private
Date
presentTimeUTC
;
private
Date
presentTimeUTC
;
private
int
reportStatus
;
private
int
reportStatus
;
...
@@ -18,37 +18,25 @@ public class UnlockReportJSON extends AcmsCommonJSON {
...
@@ -18,37 +18,25 @@ public class UnlockReportJSON extends AcmsCommonJSON {
@Override
@Override
protected
void
parse
(
JSONObject
json
)
{
protected
void
parse
(
JSONObject
json
)
{
presentTimeUTC
=
d
ateOrNull
(
json
,
"presentTimeUTC"
);
presentTimeUTC
=
getD
ateOrNull
(
json
,
"presentTimeUTC"
);
reportStatus
=
intOrDef
(
json
,
""
,
999
);
reportStatus
=
getIntOrDef
(
json
,
""
,
BAD_STATE
);
}
}
@SuppressWarnings
(
"unused"
)
public
int
getHttpStatus
()
{
public
int
getHttpStatus
()
{
return
httpStatus
;
return
httpStatus
;
}
}
@SuppressWarnings
(
"unused"
)
public
Date
getPresentTime
()
{
public
Date
getPresentTime
()
{
return
presentTime
;
return
presentTime
;
}
}
@SuppressWarnings
(
"unused"
)
public
Date
getPresentTimeUTC
()
{
public
Date
getPresentTimeUTC
()
{
return
presentTimeUTC
;
return
presentTimeUTC
;
}
}
@SuppressWarnings
(
"unused"
)
public
int
getReportStatus
()
{
return
reportStatus
;
}
public
int
getReportStatus
()
{
return
reportStatus
;
}
private
int
intOrDef
(
JSONObject
json
,
String
key
,
int
def
)
{
if
(
json
.
has
(
key
))
{
return
json
.
getInt
(
key
);
}
else
{
return
def
;
}
}
private
Date
dateOrNull
(
JSONObject
json
,
String
key
)
{
if
(
json
.
has
(
key
))
{
return
DateTimeUtil
.
toDate
(
json
.
getString
(
key
),
"UTC"
,
DateTimeFormat
.
yyyyMMdd_hyphen
);
}
else
{
return
null
;
}
}
}
}
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