当前位置: 首页>>代码示例>>Java>>正文


Java RandomAccessData类代码示例

本文整理汇总了Java中org.springframework.boot.loader.data.RandomAccessData的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessData类的具体用法?Java RandomAccessData怎么用?Java RandomAccessData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RandomAccessData类属于org.springframework.boot.loader.data包,在下文中一共展示了RandomAccessData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: centralDirectoryVisitor

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
private CentralDirectoryVisitor centralDirectoryVisitor() {
	return new CentralDirectoryVisitor() {

		@Override
		public void visitStart(CentralDirectoryEndRecord endRecord,
				RandomAccessData centralDirectoryData) {
		}

		@Override
		public void visitFileHeader(CentralDirectoryFileHeader fileHeader,
				int dataOffset) {
			AsciiBytes name = fileHeader.getName();
			if (name.startsWith(META_INF)
					&& name.endsWith(SIGNATURE_FILE_EXTENSION)) {
				JarFile.this.signed = true;
			}
		}

		@Override
		public void visitEnd() {
		}

	};
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:JarFile.java

示例2: CentralDirectoryEndRecord

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
/**
 * Create a new {@link CentralDirectoryEndRecord} instance from the specified
 * {@link RandomAccessData}, searching backwards from the end until a valid block is
 * located.
 * @param data the source data
 * @throws IOException in case of I/O errors
 */
CentralDirectoryEndRecord(RandomAccessData data) throws IOException {
	this.block = createBlockFromEndOfData(data, READ_BLOCK_SIZE);
	this.size = MINIMUM_SIZE;
	this.offset = this.block.length - this.size;
	while (!isValid()) {
		this.size++;
		if (this.size > this.block.length) {
			if (this.size >= MAXIMUM_SIZE || this.size > data.getSize()) {
				throw new IOException("Unable to find ZIP central directory "
						+ "records after reading " + this.size + " bytes");
			}
			this.block = createBlockFromEndOfData(data, this.size + READ_BLOCK_SIZE);
		}
		this.offset = this.block.length - this.size;
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:CentralDirectoryEndRecord.java

示例3: getData

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
/**
 * Return the underlying {@link RandomAccessData} for this entry. Generally this
 * method should not be called directly and instead data should be accessed via
 * {@link JarFile#getInputStream(ZipEntry)}.
 * @return the data
 * @throws IOException if the data cannot be read
 */
public RandomAccessData getData() throws IOException {
	if (this.data == null) {
		// aspectjrt-1.7.4.jar has a different ext bytes length in the
		// local directory to the central directory. We need to re-read
		// here to skip them
		byte[] localHeader = Bytes.get(this.source.getData()
				.getSubsection(this.localHeaderOffset, LOCAL_FILE_HEADER_SIZE));
		long nameLength = Bytes.littleEndianValue(localHeader, 26, 2);
		long extraLength = Bytes.littleEndianValue(localHeader, 28, 2);
		this.data = this.source.getData().getSubsection(this.localHeaderOffset
				+ LOCAL_FILE_HEADER_SIZE + nameLength + extraLength,
				getCompressedSize());
	}
	return this.data;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:23,代码来源:JarEntryData.java

示例4: loadJarEntries

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
private List<JarEntryData> loadJarEntries(CentralDirectoryEndRecord endRecord)
		throws IOException {
	RandomAccessData centralDirectory = endRecord.getCentralDirectory(this.data);
	int numberOfRecords = endRecord.getNumberOfRecords();
	List<JarEntryData> entries = new ArrayList<JarEntryData>(numberOfRecords);
	InputStream inputStream = centralDirectory.getInputStream(ResourceAccess.ONCE);
	try {
		JarEntryData entry = JarEntryData.fromInputStream(this, inputStream);
		while (entry != null) {
			entries.add(entry);
			processEntry(entry);
			entry = JarEntryData.fromInputStream(this, inputStream);
		}
	}
	finally {
		inputStream.close();
	}
	return entries;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:20,代码来源:JarFile.java

示例5: get

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
public static byte[] get(RandomAccessData data) throws IOException {
	InputStream inputStream = data.getInputStream(ResourceAccess.ONCE);
	try {
		return get(inputStream, data.getSize());
	}
	finally {
		inputStream.close();
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:Bytes.java

示例6: JarFile

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot,
		RandomAccessData data, JarEntryFilter filter, JarFileType type)
				throws IOException {
	super(rootFile.getFile());
	this.rootFile = rootFile;
	this.pathFromRoot = pathFromRoot;
	CentralDirectoryParser parser = new CentralDirectoryParser();
	this.entries = parser.addVisitor(new JarFileEntries(this, filter));
	parser.addVisitor(centralDirectoryVisitor());
	this.data = parser.parse(data, filter == null);
	this.type = type;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:JarFile.java

示例7: createJarFileFromFileEntry

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
private JarFile createJarFileFromFileEntry(JarEntry entry) throws IOException {
	if (entry.getMethod() != ZipEntry.STORED) {
		throw new IllegalStateException("Unable to open nested entry '"
				+ entry.getName() + "'. It has been compressed and nested "
				+ "jar files must be stored without compression. Please check the "
				+ "mechanism used to create your executable jar file");
	}
	RandomAccessData entryData = this.entries.getEntryData(entry.getName());
	return new JarFile(this.rootFile, this.pathFromRoot + "!/" + entry.getName(),
			entryData, JarFileType.NESTED_JAR);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:JarFile.java

示例8: parse

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
/**
 * Parse the source data, triggering {@link CentralDirectoryVisitor visitors}.
 * @param data the source data
 * @param skipPrefixBytes if prefix bytes should be skipped
 * @return The actual archive data without any prefix bytes
 * @throws IOException on error
 */
public RandomAccessData parse(RandomAccessData data, boolean skipPrefixBytes)
		throws IOException {
	CentralDirectoryEndRecord endRecord = new CentralDirectoryEndRecord(data);
	if (skipPrefixBytes) {
		data = getArchiveData(endRecord, data);
	}
	RandomAccessData centralDirectoryData = endRecord.getCentralDirectory(data);
	visitStart(endRecord, centralDirectoryData);
	parseEntries(endRecord, centralDirectoryData);
	visitEnd();
	return data;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:CentralDirectoryParser.java

示例9: parseEntries

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
private void parseEntries(CentralDirectoryEndRecord endRecord,
		RandomAccessData centralDirectoryData) throws IOException {
	byte[] bytes = Bytes.get(centralDirectoryData);
	CentralDirectoryFileHeader fileHeader = new CentralDirectoryFileHeader();
	int dataOffset = 0;
	for (int i = 0; i < endRecord.getNumberOfRecords(); i++) {
		fileHeader.load(bytes, dataOffset, null, 0, null);
		visitFileHeader(dataOffset, fileHeader);
		dataOffset += this.CENTRAL_DIRECTORY_HEADER_BASE_SIZE
				+ fileHeader.getName().length() + fileHeader.getComment().length()
				+ fileHeader.getExtra().length;
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:CentralDirectoryParser.java

示例10: getArchiveData

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
private RandomAccessData getArchiveData(CentralDirectoryEndRecord endRecord,
		RandomAccessData data) {
	long offset = endRecord.getStartOfArchive(data);
	if (offset == 0) {
		return data;
	}
	return data.getSubsection(offset, data.getSize() - offset);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:CentralDirectoryParser.java

示例11: visitStart

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
@Override
public void visitStart(CentralDirectoryEndRecord endRecord,
		RandomAccessData centralDirectoryData) {
	int maxSize = endRecord.getNumberOfRecords();
	this.centralDirectoryData = centralDirectoryData;
	this.hashCodes = new int[maxSize];
	this.centralDirectoryOffsets = new int[maxSize];
	this.positions = new int[maxSize];
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JarFileEntries.java

示例12: getEntryData

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
public RandomAccessData getEntryData(String name) throws IOException {
	FileHeader entry = getEntry(name, FileHeader.class, false);
	if (entry == null) {
		return null;
	}
	return getEntryData(entry);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:JarFileEntries.java

示例13: load

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
void load(byte[] data, int dataOffset, RandomAccessData variableData,
		int variableOffset, JarEntryFilter filter) throws IOException {
	// Load fixed part
	this.header = data;
	this.headerOffset = dataOffset;
	long nameLength = Bytes.littleEndianValue(data, dataOffset + 28, 2);
	long extraLength = Bytes.littleEndianValue(data, dataOffset + 30, 2);
	long commentLength = Bytes.littleEndianValue(data, dataOffset + 32, 2);
	this.localHeaderOffset = Bytes.littleEndianValue(data, dataOffset + 42, 4);
	// Load variable part
	dataOffset += 46;
	if (variableData != null) {
		data = Bytes.get(variableData.getSubsection(variableOffset + 46,
				nameLength + extraLength + commentLength));
		dataOffset = 0;
	}
	this.name = new AsciiBytes(data, dataOffset, (int) nameLength);
	if (filter != null) {
		this.name = filter.apply(this.name);
	}
	this.extra = NO_EXTRA;
	this.comment = NO_COMMENT;
	if (extraLength > 0) {
		this.extra = new byte[(int) extraLength];
		System.arraycopy(data, (int) (dataOffset + nameLength), this.extra, 0,
				this.extra.length);
	}
	if (commentLength > 0) {
		this.comment = new AsciiBytes(data,
				(int) (dataOffset + nameLength + extraLength), (int) commentLength);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:33,代码来源:CentralDirectoryFileHeader.java

示例14: fromRandomAccessData

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
public static CentralDirectoryFileHeader fromRandomAccessData(RandomAccessData data,
		int offset, JarEntryFilter filter) throws IOException {
	CentralDirectoryFileHeader fileHeader = new CentralDirectoryFileHeader();
	byte[] bytes = Bytes.get(data.getSubsection(offset, 46));
	fileHeader.load(bytes, 0, data, offset, filter);
	return fileHeader;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:CentralDirectoryFileHeader.java

示例15: visitsInOrder

import org.springframework.boot.loader.data.RandomAccessData; //导入依赖的package包/类
@Test
public void visitsInOrder() throws Exception {
	CentralDirectoryVisitor visitor = mock(TestCentralDirectoryVisitor.class);
	CentralDirectoryParser parser = new CentralDirectoryParser();
	parser.addVisitor(visitor);
	parser.parse(this.jarData, false);
	InOrder ordered = inOrder(visitor);
	ordered.verify(visitor).visitStart(any(CentralDirectoryEndRecord.class),
			any(RandomAccessData.class));
	ordered.verify(visitor, atLeastOnce())
			.visitFileHeader(any(CentralDirectoryFileHeader.class), anyInt());
	ordered.verify(visitor).visitEnd();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:CentralDirectoryParserTests.java


注:本文中的org.springframework.boot.loader.data.RandomAccessData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。