
io.qt.core.QIODeviceBase Maven / Gradle / Ivy
package io.qt.core;
/**
* Base class for QIODevice that provides flags describing the mode in which a device is opened
* Java wrapper for Qt class QIODeviceBase
*/
public interface QIODeviceBase extends io.qt.QtObjectInterface
{
/**
* Java wrapper for Qt enum QIODeviceBase::OpenModeFlag
*
* @see OpenMode
*/
public enum OpenModeFlag implements io.qt.QtFlagEnumerator {
NotOpen(0),
ReadOnly(1),
WriteOnly(2),
ReadWrite(3),
Append(4),
Truncate(8),
Text(16),
Unbuffered(32),
NewOnly(64),
ExistingOnly(128);
private OpenModeFlag(int value) {
this.value = value;
}
/**
* {@inheritDoc}
*/
public int value() {
return value;
}
/**
* Create a QFlags of the enum entry.
* @return QFlags
*/
public OpenMode asFlags() {
return new OpenMode(value);
}
/**
* Combines this entry with other enum entry.
* @param e enum entry
* @return new flag
*/
public OpenMode combined(OpenModeFlag e) {
return new OpenMode(this, e);
}
/**
* Creates a new {@link OpenMode} from the entries.
* @param values entries
* @return new flag
*/
public static OpenMode flags(OpenModeFlag ... values) {
return new OpenMode(values);
}
/**
* Returns the corresponding enum entry for the given value.
* @param value
* @return enum entry
*/
public static OpenModeFlag resolve(int value) {
switch (value) {
case 0: return NotOpen;
case 1: return ReadOnly;
case 2: return WriteOnly;
case 3: return ReadWrite;
case 4: return Append;
case 8: return Truncate;
case 16: return Text;
case 32: return Unbuffered;
case 64: return NewOnly;
case 128: return ExistingOnly;
default: throw new io.qt.QNoSuchEnumValueException(value);
}
}
private final int value;
}
/**
* QFlags type for enum {@link OpenModeFlag}
*/
public static final class OpenMode extends io.qt.QFlags implements Comparable {
private static final long serialVersionUID = 0x6416216da160206aL;
/**
* Creates a new OpenMode where the flags in args
are set.
* @param args enum entries
*/
public OpenMode(OpenModeFlag ... args){
super(args);
}
/**
* Creates a new OpenMode with given value
.
* @param value
*/
public OpenMode(int value) {
super(value);
}
/**
* Combines this flags with enum entry.
* @param e enum entry
* @return new OpenMode
*/
@Override
public final OpenMode combined(OpenModeFlag e){
return new OpenMode(value() | e.value());
}
/**
* Sets the flag e
* @param e enum entry
* @return this
*/
public final OpenMode setFlag(OpenModeFlag e){
super.setFlag(e);
return this;
}
/**
* Sets or clears the flag flag
* @param e enum entry
* @param on set (true) or clear (false)
* @return this
*/
public final OpenMode setFlag(OpenModeFlag e, boolean on){
super.setFlag(e, on);
return this;
}
/**
* Returns an array of flag objects represented by this OpenMode.
* @return array of enum entries
*/
@Override
public final OpenModeFlag[] flags(){
return super.flags(OpenModeFlag.values());
}
/**
* {@inheritDoc}
*/
@Override
public final OpenMode clone(){
return new OpenMode(value());
}
/**
* {@inheritDoc}
*/
@Override
public final int compareTo(OpenMode other){
return Integer.compare(value(), other.value());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy