Class FileSaver
- All Implemented Interfaces:
Proxy
Buffer into a file.
A GtkSourceFileSaver object permits to save a Buffer into a
File.
A file saver should be used only for one save operation, including errors
handling. If an error occurs, you can reconfigure the saver and relaunch the
operation with saveAsync(int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFileSaver.Builder<B extends FileSaver.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FileSaverasParent()Returns this instance as if it were its parent type.static FileSaver.Builder<? extends FileSaver.Builder> builder()AFileSaver.Builderobject constructs aFileSaverwith the specified properties.getFile()getFlags()static @Nullable TypegetType()Get the GType of the FileSaver classvoidsaveAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Saves asynchronously the buffer into the file.booleansaveFinish(AsyncResult result) Finishes a file saving started withsaveAsync(int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback).voidsetCompressionType(CompressionType compressionType) Sets the compression type.voidsetEncoding(@Nullable Encoding encoding) Sets the encoding.voidsetFlags(Set<FileSaverFlags> flags) voidsetFlags(FileSaverFlags... flags) voidsetNewlineType(NewlineType newlineType) Sets the newline type.static FileSaverwithTarget(Buffer buffer, File file, File targetLocation) Creates a newGtkSourceFileSaverobject with a target location.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
FileSaver
Create a FileSaver proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
FileSaver
Creates a newGtkSourceFileSaverobject. Thebufferwill be saved to theFile's location.This constructor is suitable for a simple "save" operation, when the
filealready contains a non-nullFile:location.- Parameters:
buffer- theGtkSourceBufferto save.file- theGtkSourceFile.
-
FileSaver
public FileSaver()Creates a new FileSaver.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
withTarget
Creates a newGtkSourceFileSaverobject with a target location.When the file saving is finished successfully,
targetLocationis set to thefile'sFile:locationproperty. If an error occurs, the previous valid location is still available inFile.This constructor is suitable for a "save as" operation, or for saving a new buffer for the first time.
- Parameters:
buffer- theGtkSourceBufferto save.file- theGtkSourceFile.targetLocation- theGFilewhere to save the buffer to.- Returns:
- a new
GtkSourceFileSaverobject.
-
getBuffer
-
getCompressionType
-
getEncoding
-
getFile
-
getFlags
-
getLocation
-
getNewlineType
-
saveAsync
public void saveAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Saves asynchronously the buffer into the file.See the
AsyncResultdocumentation to know how to use this function.- Parameters:
ioPriority- the I/O priority of the request. E.g.G_PRIORITY_LOW,G_PRIORITY_DEFAULTorG_PRIORITY_HIGH.cancellable- optionalGCancellableobject,nullto ignore.progressCallback- function to call back with progress information, ornullif progress information is not needed.callback- aGAsyncReadyCallbackto call when the request is satisfied.
-
saveFinish
Finishes a file saving started withsaveAsync(int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback).If the file has been saved successfully, the following
Fileproperties will be updated: the location, the encoding, the newline type and the compression type.Since the 3.20 version,
TextBuffer.setModified(boolean)is called withfalseif the file has been saved successfully.- Parameters:
result- aGAsyncResult.- Returns:
- whether the file was saved successfully.
- Throws:
GErrorException- seeGError
-
setCompressionType
Sets the compression type. By default the compression type is taken from theGtkSourceFile.- Parameters:
compressionType- the new compression type.
-
setEncoding
Sets the encoding. Ifencodingisnull, the UTF-8 encoding will be set.By default the encoding is taken from the
GtkSourceFile.- Parameters:
encoding- the new encoding, ornullfor UTF-8.
-
setFlags
-
setFlags
-
setNewlineType
Sets the newline type. By default the newline type is taken from theGtkSourceFile.- Parameters:
newlineType- the new newline type.
-
builder
AFileSaver.Builderobject constructs aFileSaverwith the specified properties. Use the variousset...()methods to set properties, and finish construction withFileSaver.Builder.build().- Returns:
- the builder object
-