/*
Исходный код среды исполнения ПВТ-ОО.
Этот исходный код является частью проекта ПВТ-ОО.
Copyright © 2021 Малик Разработчик
Это свободная программа: вы можете перераспространять её и/или
изменять её на условиях Меньшей Стандартной общественной лицензии GNU в том виде,
в каком она была опубликована Фондом свободного программного обеспечения;
либо версии 3 лицензии, либо (по вашему выбору) любой более поздней версии.
Эта программа распространяется в надежде, что она может быть полезна,
но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЁННЫХ ЦЕЛЕЙ. Подробнее см. в Меньшей Стандартной
общественной лицензии GNU.
Вы должны были получить копию Меньшей Стандартной общественной лицензии GNU
вместе с этой программой. Если это не так, см.
<http://www.gnu.org/licenses/>.
*/
package platform.independent.filesystem;
public class ObjectAttributes(Object, AttributeSet)
{
private static String getAttributeId(int index) {
switch(index)
{
case 1: return "bDirectory";
case 2: return "bReadOnly";
case 101: return "lLastAccessTime";
case 102: return "lLastWriteTime";
}
return null;
}
private final AttributeSet fldSource;
public (AttributeSet source) { fldSource = source; }
public (FileSystem source) { fldSource = source == null ? null : source.newAttributeSet(); }
public void setBooleanAttribute(String attributeId, boolean attributeValue) { fldSource.setBooleanAttribute(attributeId, attributeValue); }
public void setLongAttribute(String attributeId, long attributeValue) { fldSource.setLongAttribute(attributeId, attributeValue); }
public void setStringAttribute(String attributeId, String attributeValue) { fldSource.setStringAttribute(attributeId, attributeValue); }
public boolean isSupportedAttributeId(String attributeId) { return fldSource.isSupportedAttributeId(attributeId); }
public boolean getBooleanAttribute(String attributeId) { return fldSource.getBooleanAttribute(attributeId); }
public long getLongAttribute(String attributeId) { return fldSource.getLongAttribute(attributeId); }
public String getStringAttribute(String attributeId) { return fldSource.getStringAttribute(attributeId); }
public String displayName(String attributeId) { return fldSource.displayName(attributeId); }
public String[] getSupportedAttributeIds() { return fldSource.getSupportedAttributeIds(); }
public final boolean directory { index = 1, read = getBooleanAttribute, write = setBooleanAttribute }
public final boolean readOnly { index = 2, read = getBooleanAttribute, write = setBooleanAttribute }
public final long lastAccessTime { index = 101, read = getLongAttribute, write = setLongAttribute }
public final long lastWriteTime { index = 102, read = getLongAttribute, write = setLongAttribute }
private void setBooleanAttribute(int index, boolean newAttributeValue) { setBooleanAttribute(getAttributeId(index), newAttributeValue); }
private void setLongAttribute(int index, long newAttributeValue) { setLongAttribute(getAttributeId(index), newAttributeValue); }
private boolean getBooleanAttribute(int index) { return getBooleanAttribute(getAttributeId(index)); }
private long getLongAttribute(int index) { return getLongAttribute(getAttributeId(index)); }
}