/** * Constructs a new GZip file resource. * @param metaData the name of the tar entry * @param identifier request identification object * @param tempDir the location to write temp files. */ public GZipIdentificationRequest(RequestMetaData metaData, RequestIdentifier identifier, File tempDir) { this.identifier = identifier; String path = identifier.getUri().getSchemeSpecificPart(); extension = ResourceUtils.getExtension(path); fileName = FilenameUtils.getName(path); this.tempDir = tempDir; this.requestMetaData = metaData; }
@Override public void open(InputStream in) throws IOException { reader = ResourceUtils.getStreamReader(in, tempDir, TOP_TAIL_CAPACITY, true); // Force read of entire input stream to build reader and remove dependence on source input stream. final long readSize = reader.length(); // getting the size of a reader backed by a stream forces a stream read. if (size != readSize) { //Possible to change log level im future as we did in ZIP. log.warn("Rar element metadata size is not same as read size : " + readSize); } }
/** * COnverts an long to base 128 integer. * @param value Value to convert to base 128 integer. * @param values char array to populate. */ public static void getBase128IntegerCharArray(final long value, final char[] values) { // Use printable characters in this range: // ASCII & UTF-8: 33 - 126 (no space) = 94 values. // ISO Latin 1 & UTF-8: 192 - 226 = 34 values. // Map 0-93 to 33-126 // Map 93-127 to 192-226 int i = 0; values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_25) & HEX_7F); // bits 26-32 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_18) & HEX_7F); // bits 19-25 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_11) & HEX_7F); // bits 12-18 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_4) & HEX_7F); // bits 5-11 values[i++] = (char) printableValue(value & HEX_F); // bits 1-4 }
@Override public void propertyChange(PropertyChangeEvent evt) { if (STATE.equals(evt.getPropertyName()) && evt.getNewValue().equals(SwingWorker.StateValue.DONE) && !action.isCancelled()) { setVisible(false); log.info("Closing DROID."); File tempDir = globalContext.getGlobalConfig().getTempDir(); ResourceUtils.attemptToDeleteTempFiles(tempDir); // CHECKSTYLE:OFF System.exit(0); // CHECKSTYLE:ON } } });
private void setNodeIds(ProfileResourceNode node, ResourceId parentId) { final Long nodeId = nodeIds.incrementAndGet(); node.setId(nodeId); String parentsPrefixString = ""; if (parentId != null) { parentsPrefixString = parentId.getPath(); node.setParentId(parentId.getId()); } int parentsPrefixStringLength = parentsPrefixString != null ? parentsPrefixString.length() : 0; final int buliderBaseSize = 5; final int nodeValueSize = 5; final StringBuilder builder = new StringBuilder(buliderBaseSize + parentsPrefixStringLength); builder.append(parentsPrefixString); final char[] nodeValue = new char[nodeValueSize]; ResourceUtils.getBase128IntegerCharArray(nodeId, nodeValue); builder.append(nodeValue); node.setPrefix(builder.toString()); //builder.setLength(parentsPrefixString.length()); builder.setLength(parentsPrefixStringLength); ResourceUtils.getBase128IntegerCharArray(nodeId + 1, nodeValue); builder.append(nodeValue); node.setPrefixPlusOne(builder.toString()); }
@Override public void propertyChange(PropertyChangeEvent evt) { if (STATE.equals(evt.getPropertyName()) && evt.getNewValue().equals(SwingWorker.StateValue.DONE) && !action.isCancelled()) { setVisible(false); log.info("Closing DROID."); final Path tempDir = globalContext.getGlobalConfig().getTempDir(); ResourceUtils.attemptToDeleteTempFiles(tempDir); // CHECKSTYLE:OFF System.exit(0); // CHECKSTYLE:ON } } });
private void setNodeIds(ProfileResourceNode node, ResourceId parentId) { final Long nodeId = nodeIds.incrementAndGet(); node.setId(nodeId); String parentsPrefixString = ""; if (parentId != null) { parentsPrefixString = parentId.getPath(); node.setParentId(parentId.getId()); } int parentsPrefixStringLength = parentsPrefixString != null ? parentsPrefixString.length() : 0; final int buliderBaseSize = 5; final int nodeValueSize = 5; final StringBuilder builder = new StringBuilder(buliderBaseSize + parentsPrefixStringLength); builder.append(parentsPrefixString); final char[] nodeValue = new char[nodeValueSize]; ResourceUtils.getBase128IntegerCharArray(nodeId, nodeValue); builder.append(nodeValue); node.setPrefix(builder.toString()); //builder.setLength(parentsPrefixString.length()); builder.setLength(parentsPrefixStringLength); ResourceUtils.getBase128IntegerCharArray(nodeId + 1, nodeValue); builder.append(nodeValue); node.setPrefixPlusOne(builder.toString()); }
/** * Constructs a new BZip file resource. * @param metaData the name of the tar entry * @param identifier request identification object * @param tempDir the location to write temp files. */ public BZipIdentificationRequest(RequestMetaData metaData, RequestIdentifier identifier, File tempDir) { this.identifier = identifier; String path = identifier.getUri().getSchemeSpecificPart(); extension = ResourceUtils.getExtension(path); fileName = FilenameUtils.getName(path); this.tempDir = tempDir; this.requestMetaData = metaData; }
/** * {@inheritDoc} */ @Override public final void open(final InputStream in) throws IOException { reader = ResourceUtils.getStreamReader(in, tempDir, TOP_TAIL_CAPACITY); // Force read of entire input stream to build reader and remove dependence on source input stream. size = reader.length(); // getting the size of a reader backed by a stream forces a stream read. }
/** * COnverts an long to base 128 integer. * @param value Value to convert to base 128 integer. * @param values char array to populate. */ public static void getBase128IntegerCharArray(long value, char[] values) { // Use printable characters in this range: // ASCII & UTF-8: 33 - 126 (no space) = 94 values. // ISO Latin 1 & UTF-8: 192 - 226 = 34 values. // Map 0-93 to 33-126 // Map 93-127 to 192-226 int i = 0; values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_25) & HEX_7F); // bits 26-32 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_18) & HEX_7F); // bits 19-25 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_11) & HEX_7F); // bits 12-18 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_4) & HEX_7F); // bits 5-11 values[i++] = (char) printableValue(value & HEX_F); // bits 1-4 }
/** * Constructs a new BZip file resource. * @param metaData the name of the tar entry * @param identifier request identification object * @param tempDir the location to write temp files. */ public BZipIdentificationRequest(final RequestMetaData metaData, final RequestIdentifier identifier, final Path tempDir) { this.identifier = identifier; String path = identifier.getUri().getSchemeSpecificPart(); extension = ResourceUtils.getExtension(path); fileName = FilenameUtils.getName(path); this.tempDir = tempDir; this.requestMetaData = metaData; }
/** * * @param in i * @throws IOException if open unsuccessful */ public final void open(final InputStream in) throws IOException { reader = ResourceUtils.getStreamReader(in, tempDir, TOP_TAIL_CAPACITY, true); reader.length(); }
/** * COnverts an long to base 128 integer. * @param value Value to convet to base 128 integer. * @return Base 128Integer. */ public static String getBase128Integer(long value) { // Use printable characters in this range: // ASCII & UTF-8: 33 - 126 (no space) = 94 values. // ISO Latin 1 & UTF-8: 192 - 226 = 34 values. // Map 0-93 to 33-126 // Map 93-127 to 192-226 char[] values = new char[ARRAYLENGTH]; int i = 0; values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_25) & HEX_7F); // bits 26-32 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_18) & HEX_7F); // bits 19-25 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_11) & HEX_7F); // bits 12-18 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_4) & HEX_7F); // bits 5-11 values[i++] = (char) printableValue(value & HEX_F); // bits 1-4 return new String(values); }
/** * Constructs a new GZip file resource. * @param metaData the name of the tar entry * @param identifier request identification object * @param tempDir the location to write temp files. */ public GZipIdentificationRequest(final RequestMetaData metaData, final RequestIdentifier identifier, final Path tempDir) { this.identifier = identifier; String path = identifier.getUri().getSchemeSpecificPart(); extension = ResourceUtils.getExtension(path); fileName = FilenameUtils.getName(path); this.tempDir = tempDir; this.requestMetaData = metaData; }
/** * {@inheritDoc} */ @Override public final void open(final InputStream in) throws IOException { reader = ResourceUtils.getStreamReader(in, tempDir, TOP_TAIL_CAPACITY); // Force read of entire input stream to build reader and remove dependence on source input stream. size = reader.length(); // getting the size of a reader backed by a stream forces a stream read. }
/** * COnverts an long to base 128 integer. * @param value Value to convet to base 128 integer. * @return Base 128Integer. */ public static String getBase128Integer(final long value) { // Use printable characters in this range: // ASCII & UTF-8: 33 - 126 (no space) = 94 values. // ISO Latin 1 & UTF-8: 192 - 226 = 34 values. // Map 0-93 to 33-126 // Map 93-127 to 192-226 char[] values = new char[ARRAYLENGTH]; int i = 0; values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_25) & HEX_7F); // bits 26-32 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_18) & HEX_7F); // bits 19-25 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_11) & HEX_7F); // bits 12-18 values[i++] = (char) printableValue((value >>> UNSIGNED_RIGHT_SHIFT_BY_4) & HEX_7F); // bits 5-11 values[i++] = (char) printableValue(value & HEX_F); // bits 1-4 return new String(values); }
/** * * @param file * the file to represent. */ public FileProfileResource(File file) { setUri(file.toURI()); setName(file.getName()); setSize(file.length()); setLastModifiedDate(new Date(file.lastModified())); //setExtension(FilenameUtils.getExtension(file.getName())); setExtension(ResourceUtils.getExtension(file.getName())); }
/** * {@inheritDoc} */ @Override public final void open(InputStream in) throws IOException { reader = ResourceUtils.getStreamReader(in, tempDir, TOP_TAIL_CAPACITY); // Force read of entire input stream to build reader and remove dependence on source input stream. size = reader.length(); // getting the size of a reader backed by a stream forces a stream read. }
/** * Constructs a new identification request. * @param metaData the metaData about the binary. * @param identifier the request's identifier */ public FileSystemIdentificationRequest(final RequestMetaData metaData, final RequestIdentifier identifier) { this.identifier = identifier; requestMetaData = metaData; size = metaData.getSize(); fileName = metaData.getName(); extension = ResourceUtils.getExtension(fileName); }
/** * * @param in i * @throws IOException if open unsuccessful */ public final void open(final InputStream in) throws IOException { reader = ResourceUtils.getStreamReader(in, tempDir, TOP_TAIL_CAPACITY, true); reader.length(); }