All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.vdb.ArchiveDir Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.vdb;

import java.io.IOException;

import com.scudata.common.RQException;
import com.scudata.dm.ObjectReader;
import com.scudata.dm.ObjectWriter;

/**
 * ?鵵Ŀ¼
 * @author RunQian
 *
 */
class ArchiveDir extends IDir {
	private int header = -1; // ?׿??
	private int fileIndex = -1; // ??ǰ?ڶ?Ӧ?ı????ڸ?Ŀ¼?????е?????
	private long commitTime; // ?ύʱ??
	
	private ArchiveSection parent; // ????
	private ArchiveSection section; // ·????Ӧ?Ľ?
	
	public ArchiveDir(ArchiveDir src) {
		value = src.value;
		name = src.name;
		header = src.header;
		fileIndex = src.fileIndex;
		commitTime = src.commitTime;
	}

	public ArchiveDir(ArchiveSection parent) {
		this.parent = parent;
	}
	
	public ArchiveDir(Object value, String name, long commitTime, ArchiveSection parent) {
		this.value = value;
		this.name = name;
		this.commitTime = commitTime;
		this.parent = parent;
	}
	
	public ArchiveSection getParentSection() {
		return parent;
	}
	
	public ISection getParent() {
		return parent;
	}
	
	public void setHeader(int header) {
		this.header = header;
	}

	public int getHeader() {
		return header;
	}
	
	public void setFileIndex(int i) {
		fileIndex = i;
	}
	
	public long getCommitTime() {
		return commitTime;
	}
	
	public Object getFileData(VDB vdb) throws IOException {
		return parent.getSubFileData(vdb, fileIndex);
	}
	
	public boolean isFile() {
		return fileIndex >= 0;
	}
	
	public boolean isDir() {
		return header > 0;
	}
	
	public ArchiveSection getSection(Library library) {
		if (section == null) {
			if (header > 0) {
				try {
					byte []bytes = library.readBlocks(header);
					section = new ArchiveSection(this, header, bytes);
				} catch (IOException e) {
					throw new RQException(e.getMessage(), e);
				}
			} else {
				section = new ArchiveSection(this);
			}
		}
		
		return section;
	}
	
	public void setSection(ArchiveSection section) {
		this.section = section;
	}
	
	public void releaseSubSection() {
		section = null;
	}
	
	public void read(ObjectReader reader) throws IOException {
		value = reader.readObject();
		name = (String)reader.readObject();
		header = reader.readInt();
		fileIndex = reader.readInt();
		commitTime = reader.readLong();
	}
	
	public void write(ObjectWriter writer) throws IOException {
		writer.writeObject(value);
		writer.writeObject(name);
		writer.writeInt(header);
		writer.writeInt(fileIndex);
		writer.writeLong(commitTime);
	}
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy