Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mihai.herda
keyjoana
Commits
16bd0497
Commit
16bd0497
authored
Nov 22, 2019
by
Joachim Müssig
Browse files
clear up code, javadoc
parent
7e591a76
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/joanakey/persistence/JsonHelper.java
View file @
16bd0497
...
...
@@ -11,16 +11,35 @@ package joanakey.persistence;
*/
public
class
JsonHelper
{
/**
* generate a key value pair and append it to the given stringBuilder object. The value is appended with quotes as String ("value").
* @param stringBuilder object to which you want append the key, value pair
* @param key json key
* @param value as string
*/
public
static
void
addJsonStringToStringBuilder
(
StringBuilder
stringBuilder
,
String
key
,
String
value
)
{
stringBuilder
.
append
(
"\""
+
key
+
"\" : "
+
"\""
+
value
+
"\""
);
}
/**
* generate a key value pair and append it to the given stringBuilder object. The value is appended without quotes.
* @param stringBuilder object to which you want append the key, value pair
* @param key json key
* @param value as string
*/
public
static
void
addKeyValueToJsonStringbuilder
(
StringBuilder
stringBuilder
,
String
key
,
String
value
)
{
stringBuilder
.
append
(
"\""
+
key
+
"\" : "
+
value
);
}
/**
* generate a key value pair and append it to the given stringBuilder object. The value is appended with curly brackets.
* @param stringBuilder object to which you want to append the key, value pair.
* @param key json key
* @param value as string
*/
public
static
void
addJsonObjValueToStringBuiler
(
StringBuilder
stringBuilder
,
String
key
,
String
value
)
{
stringBuilder
.
append
(
"\""
+
key
+
"\" : {\n"
);
...
...
src/joanakey/persistence/PersistentCGNode.java
View file @
16bd0497
...
...
@@ -12,6 +12,8 @@ import org.json.JSONObject;
import
com.ibm.wala.ipa.callgraph.CGNode
;
import
com.ibm.wala.ipa.callgraph.propagation.LocalPointerKey
;
import
net.bytebuddy.asm.Advice.This
;
/**
*
* @author hklein
...
...
@@ -25,6 +27,11 @@ public class PersistentCGNode {
private
static
final
String
CG_NODE_ID
=
"cg_node_id"
;
private
static
final
String
IR
=
"ir"
;
/**
* generate a {@link PersistentCGNode} object from the given jsonObj
* @param jsonObj which contains the call graph node information
* @return {@link PersistentCGNode}
*/
public
static
PersistentCGNode
generateFromJsonObj
(
JSONObject
jsonObj
)
{
PersistentCGNode
node
=
new
PersistentCGNode
(
jsonObj
.
getInt
(
ID
),
jsonObj
.
getInt
(
CG_NODE_ID
));
...
...
@@ -46,6 +53,10 @@ public class PersistentCGNode {
persistentIR
=
new
PersistentIR
(
localPointerKeys
,
n
,
uniqueId
);
}
/**
* generate a string which contain the information of this {@link PersistentCGNode}.
* @return String containing information about this object (ID, CG Node ID, IR)
*/
public
String
generateSaveString
()
{
return
"\""
+
ID
+
"\" : "
+
uniqueId
+
", "
+
"\""
+
CG_NODE_ID
+
"\" :"
+
cgNodeId
+
", "
+
...
...
src/joanakey/persistence/PersistentIR.java
View file @
16bd0497
...
...
@@ -25,6 +25,11 @@ public class PersistentIR {
private
Map
<
Integer
,
String
>
vnsToLocalNames
=
new
HashMap
<>();
private
int
containingNodeId
;
/**
* generate a {@link PersistentIR} object from the given jsonObj
* @param jsonObj which contains needed information
* @return {@link PersistentIR}
*/
public
static
PersistentIR
generateFromJsonObj
(
JSONObject
jsonObject
,
int
nodeId
)
{
PersistentIR
persistentIR
=
new
PersistentIR
();
persistentIR
.
containingNodeId
=
nodeId
;
...
...
@@ -57,7 +62,11 @@ public class PersistentIR {
}
}
}
/**
* generate a string which contain the information of this {@link PersistentIR} object.
* @return String containing information about this object.
*/
public
String
generateSaveString
()
{
StringBuilder
sb
=
new
StringBuilder
();
vnsToLocalNames
.
forEach
((
i
,
s
)
->
{
...
...
src/joanakey/persistence/PersistentLocalPointerKey.java
View file @
16bd0497
...
...
@@ -26,6 +26,12 @@ public class PersistentLocalPointerKey {
private
PersistentCGNode
persistentCGNode
;
private
int
id
;
/**
* generate a {@link PersistentLocalPointerKey} object from the given jsonObj
* @param jsonObj which contains needed information
* @param cgNodes, list of {@link PersistentCGNode}
* @return {@link PersistentCGNode}
*/
public
static
PersistentLocalPointerKey
generateFromJsonObj
(
JSONObject
jsonObj
,
List
<
PersistentCGNode
>
cgNodes
)
{
int
nodeIndex
=
jsonObj
.
getInt
(
NODE
);
...
...
@@ -42,6 +48,7 @@ public class PersistentLocalPointerKey {
private
PersistentLocalPointerKey
()
{
}
public
PersistentLocalPointerKey
(
LocalPointerKey
localPointerKey
,
PersistentCGNode
persistentCGNode
,
int
uniqueId
)
{
valueNumber
=
localPointerKey
.
getValueNumber
();
...
...
@@ -61,6 +68,10 @@ public class PersistentLocalPointerKey {
return
id
;
}
/**
* generate a string which contain the information of this {@link PersistentLocalPointerKey} object.
* @return String containing information about this object.
*/
public
String
generateSaveString
()
{
return
"\""
+
ID
+
"\" : "
+
id
+
", \""
+
VALUE_NUMBER
+
"\" : "
+
String
.
valueOf
(
valueNumber
)
...
...
src/joanakey/persistence/ViolationsSaverLoader.java
View file @
16bd0497
...
...
@@ -32,6 +32,11 @@ public class ViolationsSaverLoader {
private
static
final
String
VIOL_PATHS
=
"violpaths"
;
private
static
final
String
NODE_IDS
=
"node_ids"
;
/**
* generate a string which contain information of the given {@link IViolation} objects.
* @param violations you want to generate the String for.
* @return String
*/
public
static
String
generateSaveString
(
Collection
<?
extends
IViolation
<
SecurityNode
>>
violations
)
{
StringBuilder
created
=
new
StringBuilder
();
...
...
@@ -76,6 +81,12 @@ public class ViolationsSaverLoader {
return
created
.
toString
();
}
/**
* generate a collection of {@link ClassifiedViolation}s from the given {@link JSONArray}
* @param violationsArr, containg multiple {@link JSONObjects} with violation informations.
* @param sdg Graph, used to get the corresponding sdg nodes
* @return
*/
public
static
Collection
<
ClassifiedViolation
>
generateFromJSON
(
JSONArray
violationsArr
,
SDG
sdg
)
{
Collection
<
ClassifiedViolation
>
created
=
new
ArrayList
<>();
...
...
Write
Preview
Supports
Markdown
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