XrefHeader.java revision 1384
1384N/A * The contents of this file are subject to the terms of the 1384N/A * Common Development and Distribution License (the "License"). 1384N/A * You may not use this file except in compliance with the License. 1384N/A * language governing permissions and limitations under the License. 1384N/A * When distributing Covered Code, include this CDDL HEADER in each 1384N/A * If applicable, add the following below this CDDL HEADER, with the 1384N/A * fields enclosed by brackets "[]" replaced with your own identifying 1384N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1384N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 1384N/A * Portions Copyright 2012 Jens Elkner. 1384N/A * The header of a crossfile. 1384N/A /** the default format version of a crossfile */ 1384N/A private static final byte[]
MAGIC = {
'O',
'p',
'E',
'n',
'G',
'r',
'O',
'k' };
1384N/A /** the size of the header in bytes */ 1384N/A * Create a new default header for a crossfile of the given genre. Data 1384N/A * section is assumed to be uncompressed and line and char counts are set 1384N/A * @param genre genre of the file. 1384N/A * @see XrefHeader#XrefHeader(Genre, boolean) 1384N/A * Create a new default header for a crossfile of the given genre and 1384N/A * parameters. Line and char counts are set to -1. 1384N/A * @param genre genre of the file. 1384N/A * @param compressed {@code true} if data section is compressed 1384N/A * @see XrefHeader#XrefHeader(Genre, boolean, int, long) 1384N/A * Create a new default header for a crossfile of the given genre and 1384N/A * @param genre genre of the data section. 1384N/A * @param compressed {@code true} if data section is compressed 1384N/A * @param lines number of lines represented by the data section. {@code -1} 1384N/A * @param chars number of characters in the [compressed] data section. 1384N/A * Creates a ByteBuffer backed by an new byte array of {@link #HEADER_SZ} 1384N/A * and fills in all relevant metadata. 1384N/A * @return an unshared byte buffer 1384N/A * Create a new instance by reading the required number of bytes 1384N/A * from the given byte array starting at index 0. 1384N/A * @param header byte array containing the header bytes. 1384N/A * @throws IOException if the header is invalid. 1384N/A +
" this may lead to unexpected results (supported is " 1384N/A * Create a new instance by reading the appropriate number of header bytes 1384N/A * @param in from where to read the header. 1384N/A * @throws IOException if the header is invalid or other error occures when 1384N/A * Write the header to the given stream. 1384N/A * @param out where to write the header. 1384N/A * Get the number of characters, which follow the header. NOTE: NOT the 1384N/A * @return number of characters in the data section. {@code -1} implies 1384N/A * Set the number of characters, which follow the header. NOTE: NOT the 1384N/A * @param size number of characters in the data section. {@code -1} implies 1384N/A * Get the number of lines represented by the data section. 1384N/A * @return number of lines. {@code -1} implies unknown. 1384N/A * Set the number of lines represented by the data section. 1384N/A * @param lines number of lines. {@code -1} implies unknown. 1384N/A * Get the version of the header (file format). 1384N/A * The genre to which the data section belongs to. 1384N/A * @return a non-{@code null} value. 1384N/A * Check, whether the data section of the file is compressed. 1384N/A * @return {@code true} if compressed.