@@ -28,6 +28,12 @@ protected Group(@Nonnull StoreHandle storeHandle, @Nonnull GroupMetadata groupMe
2828 this .metadata = groupMetadata ;
2929 }
3030
31+ /**
32+ * Opens an existing Zarr group at a specified storage location.
33+ *
34+ * @param storeHandle the storage location of the Zarr group
35+ * @throws IOException if the metadata cannot be read
36+ */
3137 public static Group open (@ Nonnull StoreHandle storeHandle ) throws IOException {
3238 ObjectMapper mapper = makeObjectMapper ();
3339 GroupMetadata metadata = mapper .readValue (
@@ -42,48 +48,126 @@ public static Group open(@Nonnull StoreHandle storeHandle) throws IOException {
4248 return new Group (storeHandle , metadata );
4349 }
4450
51+ /**
52+ * Opens an existing Zarr group at a specified storage location.
53+ *
54+ * @param path the storage location of the Zarr group
55+ * @throws IOException if the metadata cannot be read
56+ */
4557 public static Group open (Path path ) throws IOException {
4658 return open (new StoreHandle (new FilesystemStore (path )));
4759 }
4860
49- public static Group open (String path ) throws IOException {
61+ /**
62+ * Opens an existing Zarr group at a specified storage location.
63+ *
64+ * @param path the storage location of the Zarr group
65+ * @throws IOException if the metadata cannot be read
66+ */
67+ public static Group open (String path ) throws IOException {
5068 return open (Paths .get (path ));
5169 }
5270
71+ /**
72+ * Creates a new Zarr group with the provided metadata in an in-memory store.
73+ *
74+ * @param groupMetadata the metadata of the Zarr group
75+ * @throws IOException if the metadata cannot be serialized
76+ */
5377 public static Group create (@ Nonnull GroupMetadata groupMetadata ) throws IOException {
5478 return new Group (new MemoryStore ().resolve (), groupMetadata ).writeMetadata ();
5579 }
5680
81+ /**
82+ * Creates a new Zarr group with the provided metadata at a specified storage location.
83+ *
84+ * @param storeHandle the storage location of the Zarr group
85+ * @param groupMetadata the metadata of the Zarr group
86+ * @throws IOException if the metadata cannot be serialized
87+ */
5788 public static Group create (
5889 @ Nonnull StoreHandle storeHandle , @ Nonnull GroupMetadata groupMetadata
5990 ) throws IOException {
6091 return new Group (storeHandle , groupMetadata ).writeMetadata ();
6192 }
6293
94+ /**
95+ * Creates a new Zarr group with default metadata at a specified storage location.
96+ *
97+ * @param storeHandle the storage location of the Zarr group
98+ * @throws IOException if the metadata cannot be serialized
99+ * @throws ZarrException if the metadata is invalid
100+ */
63101 public static Group create (@ Nonnull StoreHandle storeHandle ) throws IOException , ZarrException {
64102 return create (storeHandle , new GroupMetadata ());
65103 }
66104
105+ /**
106+ * Creates a new Zarr group with the provided attributes at a specified storage location.
107+ *
108+ * @param storeHandle the storage location of the Zarr group
109+ * @param attributes the attributes of the Zarr group
110+ * @throws IOException if the metadata cannot be serialized
111+ * @throws ZarrException if the attributes are invalid
112+ */
67113 public static Group create (@ Nonnull StoreHandle storeHandle , Attributes attributes ) throws IOException , ZarrException {
68114 return create (storeHandle , new GroupMetadata (attributes ));
69115 }
70116
117+ /**
118+ * Creates a new Zarr group with default metadata at a specified storage location.
119+ *
120+ * @param path the storage location of the Zarr group
121+ * @throws IOException if the metadata cannot be serialized
122+ * @throws ZarrException if the metadata is invalid
123+ */
71124 public static Group create (Path path ) throws IOException , ZarrException {
72125 return create (new StoreHandle (new FilesystemStore (path )));
73126 }
74127
128+ /**
129+ * Creates a new Zarr group with the provided attributes at a specified storage location.
130+ *
131+ * @param path the storage location of the Zarr group
132+ * @param attributes the attributes of the Zarr group
133+ * @throws IOException if the metadata cannot be serialized
134+ * @throws ZarrException if the attributes are invalid
135+ */
75136 public static Group create (Path path , Attributes attributes ) throws IOException , ZarrException {
76137 return create (new StoreHandle (new FilesystemStore (path )), attributes );
77138 }
78139
140+ /**
141+ * Creates a new Zarr group with default metadata at a specified storage location.
142+ *
143+ * @param path the storage location of the Zarr group
144+ * @throws IOException if the metadata cannot be serialized
145+ * @throws ZarrException if the metadata is invalid
146+ */
79147 public static Group create (String path ) throws IOException , ZarrException {
80148 return create (Paths .get (path ));
81149 }
82150
151+ /**
152+ * Creates a new Zarr group with the provided attributes at a specified storage location.
153+ *
154+ * @param path the storage location of the Zarr group
155+ * @param attributes the attributes of the Zarr group
156+ * @throws IOException if the metadata cannot be serialized
157+ * @throws ZarrException if the attributes are invalid
158+ */
83159 public static Group create (String path , Attributes attributes ) throws IOException , ZarrException {
84160 return create (Paths .get (path ), attributes );
85161 }
86162
163+ /**
164+ * Retrieves a node (group or array) at the specified key within the current group.
165+ *
166+ * @param key the key of the node to retrieve
167+ * @return the node at the specified key, or null if it does not exist
168+ * @throws ZarrException if the node cannot be opened
169+ * @throws IOException if there is an error accessing the storage
170+ */
87171 @ Nullable
88172 public Node get (String key ) throws ZarrException , IOException {
89173 StoreHandle keyHandle = storeHandle .resolve (key );
@@ -94,15 +178,41 @@ public Node get(String key) throws ZarrException, IOException {
94178 }
95179 }
96180
181+ /**
182+ * Creates a new subgroup with default metadata at the specified key.
183+ *
184+ * @param key the key of the new Zarr group within the current group
185+ * @return the created subgroup
186+ * @throws IOException if the metadata cannot be serialized
187+ * @throws ZarrException if the group cannot be created
188+ */
97189 public Group createGroup (String key ) throws IOException , ZarrException {
98190 return Group .create (storeHandle .resolve (key ));
99191 }
100192
193+ /**
194+ * Creates a new array with the provided metadata at the specified key.
195+ *
196+ * @param key the key of the new Zarr array within the current group
197+ * @param arrayMetadata the metadata of the Zarr array
198+ * @return the created array
199+ * @throws IOException if the metadata cannot be serialized
200+ * @throws ZarrException if the array cannot be created
201+ */
101202 public Array createArray (String key , ArrayMetadata arrayMetadata )
102203 throws IOException , ZarrException {
103204 return Array .create (storeHandle .resolve (key ), arrayMetadata );
104205 }
105206
207+ /**
208+ * Creates a new array with the provided metadata at the specified key.
209+ *
210+ * @param key the key of the new Zarr array within the current group
211+ * @param arrayMetadataBuilderMapper a function that modifies the array metadata
212+ * @return the created array
213+ * @throws IOException if the metadata cannot be serialized
214+ * @throws ZarrException if the array cannot be created
215+ */
106216 public Array createArray (String key , Function <ArrayMetadataBuilder , ArrayMetadataBuilder > arrayMetadataBuilderMapper )
107217 throws IOException , ZarrException {
108218 return Array .create (storeHandle .resolve (key ), arrayMetadataBuilderMapper , false );
@@ -126,11 +236,27 @@ private Group writeMetadata(GroupMetadata newGroupMetadata) throws IOException {
126236 return this ;
127237 }
128238
239+ /**
240+ * Sets new attributes for the group, replacing any existing attributes.
241+ *
242+ * @param newAttributes the new attributes to set
243+ * @return the updated group
244+ * @throws ZarrException if the new attributes are invalid
245+ * @throws IOException if the metadata cannot be serialized
246+ */
129247 public Group setAttributes (Attributes newAttributes ) throws ZarrException , IOException {
130248 GroupMetadata newGroupMetadata = new GroupMetadata (newAttributes );
131249 return writeMetadata (newGroupMetadata );
132250 }
133251
252+ /**
253+ * Updates the attributes of the group using a mapper function.
254+ *
255+ * @param attributeMapper a function that takes the current attributes and returns the updated attributes
256+ * @return the updated group
257+ * @throws ZarrException if the new attributes are invalid
258+ * @throws IOException if the metadata cannot be serialized
259+ */
134260 public Group updateAttributes (Function <Attributes , Attributes > attributeMapper )
135261 throws ZarrException , IOException {
136262 return setAttributes (attributeMapper .apply (metadata .attributes ));
0 commit comments