MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / IO

Class IO

src/main/java/fieldbox/io/IO.java:37–965  ·  view source on GitHub ↗

This class handles the persistence of Box graphs to disk. Key design challenge here is to allow individual properties of boxes to exist as separate files on disk if it makes sense to do so (for example disparate pieces of source code), and otherwise have properties associated with a box bound up in

Source from the content-addressed store, hash-verified

35 * documents was therefore completely impossible. This structure will give us the ability to drag and drop documents into the Field window and save side-car .box files next to them that contain the
36 * properties.
37 * <p>
38 * .box (the properties) and .field2 (the master document) files are stored as EDN files (see EDN.java for specifics).
39 */
40public class IO {
41 static public final String WORKSPACE = "{{workspace}}";
42 static public final String EXECUTION = "{{execution}}";
43 static public final String TEMPLATES = "{{templates}}";
44
45 public static final Dict.Prop<String> id = new Dict.Prop<>("__id__").autoConstructs(() -> Box.newID());
46 public static final Dict.Prop<String> desiredBoxClass = new Dict.Prop<>("__desiredBoxClass__");
47 public static final Dict.Prop<String> comment = new Dict.Prop<>("comment").toCanon()
48 .type()
49 .doc("A comment string that's easily searchable. Set it to provide comments on boxes used in templates.");
50
51 public static final Dict.Prop<String> language = new Dict.Prop<>("language").toCanon()
52 .type()
53 .doc("marks a property's editable (CodeMirror) language")
54 .set(Dict.domain, "*/attributes");
55 public static final Dict.Prop<Boolean> persistent = new Dict.Prop<>("persistent").toCanon()
56 .type()
57 .doc("marks a property as being saved to disk")
58 .set(Dict.domain, "*/attributes");
59 public static final Dict.Prop<Boolean> perDocument = new Dict.Prop<>("perDocument").toCanon()
60 .type()
61 .doc("marks a property as being saved, conceptually, with the document rather than with the box (which might be shared between documents).")
62 .set(Dict.domain, "*/attributes");
63 public static final Dict.Prop<Boolean> dontCopy = new Dict.Prop<>("dontCopy").toCanon()
64 .type()
65 .doc("marks a property as not being copyable between boxes.")
66 .set(Dict.domain, "*/attributes");
67
68 public static final Dict.Prop<List<String>> classpath = new Dict.Prop<>("classpath").toCanon()
69 .type()
70 .doc("This box asks the classloader to extend the classpath by this list of paths");
71
72 public static final Dict.Prop<IdempotencyMap<Runnable>> onPreparingToSave = new Dict.Prop<>("onPreparingToSave").toCanon()
73 .type()
74 .doc("Notification that this box is going to be saved to disk");
75 public static final Dict.Prop<IdempotencyMap<Runnable>> onFinishingSaving = new Dict.Prop<>("onFinishingSaving").toCanon()
76 .type()
77 .doc("Notification that this box is going to be saved to disk");
78
79
80 static Set<String> knownProperties = new LinkedHashSet<String>();
81 static Map<String, Filespec> knownFiles = new HashMap<String, Filespec>();
82
83 static {
84 persist(id);
85 persist(comment);
86 persist(classpath);
87 persist(perDocument);
88 }
89
90 private String defaultDirectory;
91 private String templateDirectory;
92
93
94 boolean lastWasNew = false;

Callers

nothing calls this directly

Calls 7

newIDMethod · 0.95
persistMethod · 0.95
autoConstructsMethod · 0.80
docMethod · 0.80
typeMethod · 0.80
toCanonMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected