StringBuilder sb = new StringBuilder();
sb.append("Del:\n");
for (Statement stm : deletions) {
- sb.append(NameUtils.getSafeName(graph, stm.getSubject()) + " "+
- NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
- NameUtils.getSafeName(graph, stm.getObject()) + " (" +
- stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ sb.append(toString(graph, stm));
+ sb.append("\n");
}
sb.append("Add:\n");
for (Statement stm : additions) {
- sb.append(NameUtils.getSafeName(graph, stm.getSubject()) + " "+
- NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
- NameUtils.getSafeName(graph, stm.getObject()) + " (" +
- stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ sb.append(toString(graph, stm));
+ sb.append("\n");
}
sb.append("Mod:\n");
for (Modification mod :modifications) {
- {
- Statement stm = mod.getLeftStm();
- if (stm != null) {
- sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+
- NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
- truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
- mod.getLeftSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
- } else {
- sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ mod.getLeftSub() + " N/A\n");
- }
+ sb.append(toString(graph, mod));
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ public static String toString(ReadGraph graph, Statement stm) throws DatabaseException{
+ return NameUtils.getSafeName(graph, stm.getSubject()) + " "+
+ NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
+ NameUtils.getSafeName(graph, stm.getObject()) + " (" +
+ stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject();
+ }
+
+ public static String toString(ReadGraph graph, Modification mod) throws DatabaseException{
+ StringBuilder sb = new StringBuilder();
+ {
+ Statement stm = mod.getLeftStm();
+ if (stm != null) {
+ sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+
+ NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
+ truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
+ mod.getLeftSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ } else {
+ sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ mod.getLeftSub() + " N/A\n");
}
- {
- Statement stm = mod.getRightStm();
- if (stm != null) {
- sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+
- NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
- truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
- mod.getRightSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
- } else {
- sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ mod.getRightSub() + " N/A\n");
- }
-
+ }
+ {
+ Statement stm = mod.getRightStm();
+ if (stm != null) {
+ sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+
+ NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
+ truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
+ mod.getRightSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")");
+ } else {
+ sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ mod.getRightSub() + " N/A");
}
- }
+
+ }
return sb.toString();
}
- public String truncate(String s) {
+ public static String truncate(String s) {
if (s.length() < 100)
return s;
return s.substring(0, 100)+"...";