001package Torello.Browser.BrowserAPI; 002 003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 004// Java-HTML Imports 005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 006 007import Torello.Browser.*; 008import Torello.Browser.helper.*; 009import Torello.Browser.JavaScriptAPI.*; 010import Torello.JSON.*; 011 012import Torello.Java.ReadOnly.ReadOnlyList; 013import Torello.Java.ReadOnly.ReadOnlyArrayList; 014 015import Torello.JavaDoc.Annotations.StaticFunctional; 016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg; 017 018import Torello.Browser.BrowserAPI.NestedHelpers.Commands.FileSystem$$Commands; 019 020 021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 022// JDK Imports 023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 024 025import javax.json.JsonObject; 026import javax.json.JsonValue; 027 028/** 029 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN> 030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE> 031 */ 032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE") 033public class FileSystem 034{ 035 // No Pubic Constructors 036 private FileSystem() { } 037 038 039 040 // ******************************************************************************************** 041 // ******************************************************************************************** 042 // Basic Types 043 // ******************************************************************************************** 044 // ******************************************************************************************** 045 046 047 /** 048 * <CODE>[No Description Provided by Google]</CODE> 049 * 050 * <EMBED CLASS=globalDefs DATA-DOMAIN=FileSystem DATA-API=BrowserAPI> 051 */ 052 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 053 public static class BucketFileSystemLocator 054 extends BaseType<BucketFileSystemLocator> 055 implements java.io.Serializable 056 { 057 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 058 protected static final long serialVersionUID = 1; 059 060 private static final NestedHelper<FileSystem.BucketFileSystemLocator> singleton = 061 Torello.Browser.BrowserAPI.NestedHelpers.Types. 062 FileSystem$$BucketFileSystemLocator$$.singleton; 063 064 /** Storage key */ 065 public final String storageKey; 066 067 /** 068 * Bucket name. Not passing a <CODE>bucketName</CODE> will retrieve the default Bucket. (https://developer.mozilla.org/en-US/docs/Web/API/Storage_API#storage_buckets) 069 * <BR /><B CLASS=Opt-Top>OPTIONAL</B> 070 */ 071 public final String bucketName; 072 073 /** Path to the directory using each path component as an array item. */ 074 public final String[] pathComponents; 075 076 /** Constructor. Please review this class' fields for documentation. */ 077 public BucketFileSystemLocator( 078 ReadOnlyList<Boolean> isPresent, String storageKey, String bucketName, 079 String[] pathComponents 080 ) 081 { 082 super(singleton, Domains.FileSystem, "BucketFileSystemLocator", 3); 083 084 this.storageKey = storageKey; 085 this.bucketName = bucketName; 086 this.pathComponents = pathComponents; 087 088 this.isPresent = (isPresent == null) 089 ? singleton.generateIsPresentList(this) 090 : THROWS.check(isPresent, 3, "FileSystem.BucketFileSystemLocator"); 091 } 092 093 /** Creates an instance of this class from a {@link JsonObject}.*/ 094 public static BucketFileSystemLocator fromJSON(JsonObject jo) 095 { return singleton.fromJSON(jo); } 096 097 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 098 public static NestedDescriptor<BucketFileSystemLocator> descriptor() 099 { return singleton.descriptor(); } 100 } 101 102 /** 103 * <CODE>[No Description Provided by Google]</CODE> 104 * 105 * <EMBED CLASS=globalDefs DATA-DOMAIN=FileSystem DATA-API=BrowserAPI> 106 */ 107 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 108 public static class Directory 109 extends BaseType<Directory> 110 implements java.io.Serializable 111 { 112 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 113 protected static final long serialVersionUID = 1; 114 115 private static final NestedHelper<FileSystem.Directory> singleton = 116 Torello.Browser.BrowserAPI.NestedHelpers.Types. 117 FileSystem$$Directory$$.singleton; 118 119 /** <CODE>[No Description Provided by Google]</CODE> */ 120 public final String name; 121 122 /** <CODE>[No Description Provided by Google]</CODE> */ 123 public final String[] nestedDirectories; 124 125 /** Files that are directly nested under this directory. */ 126 public final FileSystem.File[] nestedFiles; 127 128 /** Constructor. Please review this class' fields for documentation. */ 129 public Directory( 130 ReadOnlyList<Boolean> isPresent, String name, String[] nestedDirectories, 131 File[] nestedFiles 132 ) 133 { 134 super(singleton, Domains.FileSystem, "Directory", 3); 135 136 this.name = name; 137 this.nestedDirectories = nestedDirectories; 138 this.nestedFiles = nestedFiles; 139 140 this.isPresent = (isPresent == null) 141 ? singleton.generateIsPresentList(this) 142 : THROWS.check(isPresent, 3, "FileSystem.Directory"); 143 } 144 145 /** Creates an instance of this class from a {@link JsonObject}.*/ 146 public static Directory fromJSON(JsonObject jo) 147 { return singleton.fromJSON(jo); } 148 149 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 150 public static NestedDescriptor<Directory> descriptor() 151 { return singleton.descriptor(); } 152 } 153 154 /** 155 * <CODE>[No Description Provided by Google]</CODE> 156 * 157 * <EMBED CLASS=globalDefs DATA-DOMAIN=FileSystem DATA-API=BrowserAPI> 158 */ 159 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 160 public static class File 161 extends BaseType<File> 162 implements java.io.Serializable 163 { 164 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 165 protected static final long serialVersionUID = 1; 166 167 private static final NestedHelper<FileSystem.File> singleton = 168 Torello.Browser.BrowserAPI.NestedHelpers.Types. 169 FileSystem$$File$$.singleton; 170 171 /** <CODE>[No Description Provided by Google]</CODE> */ 172 public final String name; 173 174 /** Timestamp */ 175 public final Number lastModified; 176 177 /** Size in bytes */ 178 public final Number size; 179 180 /** <CODE>[No Description Provided by Google]</CODE> */ 181 public final String type; 182 183 /** Constructor. Please review this class' fields for documentation. */ 184 public File( 185 ReadOnlyList<Boolean> isPresent, String name, Number lastModified, Number size, 186 String type 187 ) 188 { 189 super(singleton, Domains.FileSystem, "File", 4); 190 191 this.name = name; 192 this.lastModified = lastModified; 193 this.size = size; 194 this.type = type; 195 196 this.isPresent = (isPresent == null) 197 ? singleton.generateIsPresentList(this) 198 : THROWS.check(isPresent, 4, "FileSystem.File"); 199 } 200 201 /** Creates an instance of this class from a {@link JsonObject}.*/ 202 public static File fromJSON(JsonObject jo) 203 { return singleton.fromJSON(jo); } 204 205 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 206 public static NestedDescriptor<File> descriptor() 207 { return singleton.descriptor(); } 208 } 209 210 211 212 213 // ******************************************************************************************** 214 // ******************************************************************************************** 215 // Commands 216 // ******************************************************************************************** 217 // ******************************************************************************************** 218 219 220 /** 221 * <CODE>[No Description Provided by Google]</CODE> 222 * 223 * @param bucketFileSystemLocator - 224 * 225 * @return An instance of <CODE>{@link Script}<{@link FileSystem.Directory}></CODE> 226 * 227 * <BR /><BR />This <B>script</B> may be <B STYLE='color: red'>executed</B>, using 228 * {@link Script#exec(WebSocketSender) Script.exec}, and afterwards, a {@link Promise} 229 * <CODE><{@link FileSystem.Directory}></CODE> will be returned 230 * 231 * <BR /><BR />Finally, the <B>{@code Promise}</B> may be <B STYLE='color: red'>awaited</B>, 232 * using {@link Promise#await()}, <I>and the returned result of this Browser Function may 233 * be retrieved.</I> 234 * 235 * <BR /><BR /><DIV CLASS=JDHint> 236 * This Browser Function's {@code Promise} returns: 237 * <CODE>{@link FileSystem.Directory} (<B>directory</B>)</CODE> 238 * <BR /> 239 * Returns the directory object at the path. 240 * </DIV> 241 */ 242 public static Script<FileSystem.Directory> getDirectory 243 (BucketFileSystemLocator bucketFileSystemLocator) 244 { 245 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 246 final String requestJSON = WriteJSON.get( 247 CDPTypes.CDP_TYPE, "bucketFileSystemLocator", false, "FileSystem.getDirectory", 248 bucketFileSystemLocator 249 ); 250 251 return new Script<>( 252 Domains.FileSystem, "getDirectory", requestJSON, 253 FileSystem$$Commands::getDirectory, 254 FileSystem.Directory.class 255 ); 256 } 257 258 259}