//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Requires({"name != null", "! ( location == null && output == null )", "! ( enableOnTheFlyIndexing && location == null )"}) protected IndexingVariantContextWriter(final String name, final File location, final OutputStream output, final net.sf.samtools.SAMSequenceDictionary refDict, final boolean enableOnTheFlyIndexing) //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: protected internal IndexingVariantContextWriter(string name, File location, OutputStream output, SAMSequenceDictionary refDict, bool enableOnTheFlyIndexing) { outputStream = output; this.name = name; this.refDict = refDict; if (enableOnTheFlyIndexing) { try { idxStream = new LittleEndianOutputStream(new FileOutputStream(Tribble.indexFile(location))); //System.out.println("Creating index on the fly for " + location); indexer = new DynamicIndexCreator(IndexFactory.IndexBalanceApproach.FOR_SEEK_TIME); indexer.initialize(location, indexer.defaultBinSize()); positionalOutputStream = new PositionalOutputStream(output); outputStream = positionalOutputStream; } catch (IOException ex) { // No matter what we keep going, since we don't care if we can't create the index file idxStream = null; indexer = null; positionalOutputStream = null; } } }
public void TestFormatRun() { UnicodeString.FormatRun fr = new UnicodeString.FormatRun((short)4, (short)0x15c); Assert.AreEqual(4, fr.CharacterPos); Assert.AreEqual(0x15c, fr.FontIndex); MemoryStream baos = new MemoryStream(); LittleEndianOutputStream out1 = new LittleEndianOutputStream(baos); fr.Serialize(out1); byte[] b = baos.ToArray(); Assert.AreEqual(4, b.Length); Assert.AreEqual(4, b[0]); Assert.AreEqual(0, b[1]); Assert.AreEqual(0x5c, b[2]); Assert.AreEqual(0x01, b[3]); LittleEndianInputStream inp = new LittleEndianInputStream( new MemoryStream(b) ); fr = new UnicodeString.FormatRun(inp); Assert.AreEqual(4, fr.CharacterPos); Assert.AreEqual(0x15c, fr.FontIndex); }
public void ProcessPOIFSWriterEvent(POIFSWriterEvent event1) { try { LittleEndianOutputStream leos = new LittleEndianOutputStream(event1.Stream); // StreamSize (8 bytes): An unsigned integer that specifies the number of bytes used by data // encrypted within the EncryptedData field, not including the size of the StreamSize field. // Note that the actual size of the \EncryptedPackage stream (1) can be larger than this // value, depending on the block size of the chosen encryption algorithm leos.WriteLong(countBytes); long rawPos = rawStream.Position; //FileStream fis = new FileStream(fileOut.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); IOUtils.Copy(rawStream, leos.out1); //fis.Close(); rawStream.Position = rawPos; //File.Delete(fileOut.FullName + ".copy"); fileOut.Delete(); leos.Close(); } catch (IOException e) { throw new EncryptedDocumentException(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Requires({"name != null", "! ( location == null && output == null )", "! ( enableOnTheFlyIndexing && location == null )"}) protected IndexingVariantContextWriter(final String name, final File location, final OutputStream output, final net.sf.samtools.SAMSequenceDictionary refDict, final boolean enableOnTheFlyIndexing) //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: protected internal IndexingVariantContextWriter(string name, File location, OutputStream output, SAMSequenceDictionary refDict, bool enableOnTheFlyIndexing) { outputStream = output; this.name = name; this.refDict = refDict; if (enableOnTheFlyIndexing) { try { idxStream = new LittleEndianOutputStream(new FileOutputStream(Tribble.indexFile(location))); //System.out.println("Creating index on the fly for " + location); indexer = new DynamicIndexCreator(IndexFactory.IndexBalanceApproach.FOR_SEEK_TIME); indexer.initialize(location, indexer.defaultBinSize()); positionalOutputStream = new PositionalOutputStream(output); outputStream = positionalOutputStream; } catch (IOException ex) { // No matter what we keep going, since we don't care if we can't create the index file idxStream = null; indexer = null; positionalOutputStream = null; } } }
private void TestReadWrite(byte[] data, string message) { RecordInputStream is1 = TestcaseRecordInputStream.Create(81, data); DConRefRecord d = new DConRefRecord(is1); MemoryStream bos = new MemoryStream(data.Length); LittleEndianOutputStream o = new LittleEndianOutputStream(bos); d.Serialize(o); o.Flush(); Assert.IsTrue(Arrays.Equals(data, bos.ToArray()), message); }
/** * Have the contents printer out into an OutputStream, used when writing a * file back out to disk (Normally, atom classes will keep their bytes * around, but non atom classes will just request the bytes from their * children, then chuck on their header and return) */ public void WriteOut(Stream out1) { byte[] intbuf = new byte[LittleEndianConsts.INT_SIZE]; byte[] shortbuf = new byte[LittleEndianConsts.SHORT_SIZE]; byte[] zerobuf = { 0, 0, 0, 0 }; LittleEndianOutputStream leosOut = new LittleEndianOutputStream(out1); switch (mode) { case EncodingMode.parsed: { MemoryStream bos = new MemoryStream(); LittleEndianOutputStream leos = new LittleEndianOutputStream(bos); // total size, will be determined later .. leos.WriteShort(Flags1); leos.Write(Encoding.GetEncoding(ISO1).GetBytes(Label)); leos.WriteByte(0); leos.Write(Encoding.GetEncoding(ISO1).GetBytes(FileName)); leos.WriteByte(0); leos.WriteShort(Flags2); leos.WriteShort(Unknown1); leos.WriteInt(Command.Length + 1); leos.Write(Encoding.GetEncoding(ISO1).GetBytes(Command)); leos.WriteByte(0); leos.WriteInt(DataSize); leos.Write(DataBuffer); leos.WriteShort(Flags3); //leos.Close(); // satisfy compiler ... leosOut.WriteInt((int)bos.Length); // total size bos.WriteTo(out1); break; } case EncodingMode.compact: leosOut.WriteInt(DataSize + LittleEndianConsts.SHORT_SIZE); leosOut.WriteShort(Flags1); out1.Write(DataBuffer, 0, DataBuffer.Length); break; default: case EncodingMode.unparsed: leosOut.WriteInt(DataSize); out1.Write(DataBuffer, 0, DataBuffer.Length); break; } }
public void TestStore() { CellRangeAddress cref = new CellRangeAddress(0, 0, 0, 0); byte[] recordBytes; //ByteArrayOutputStream baos = new ByteArrayOutputStream(); MemoryStream baos = new MemoryStream(); LittleEndianOutputStream output = new LittleEndianOutputStream(baos); try { // With nothing set cref.Serialize(output); recordBytes = baos.ToArray(); Assert.AreEqual(recordBytes.Length, data.Length); for (int i = 0; i < data.Length; i++) { Assert.AreEqual(0, recordBytes[i], "At offset " + i); } // Now set the flags cref.FirstRow = ((short)2); cref.LastRow = ((short)4); cref.FirstColumn = ((short)0); cref.LastColumn = ((short)3); // Re-test //baos.reset(); baos.Seek(0, SeekOrigin.Begin); cref.Serialize(output); recordBytes = baos.ToArray(); Assert.AreEqual(recordBytes.Length, data.Length); for (int i = 0; i < data.Length; i++) { Assert.AreEqual(data[i], recordBytes[i], "At offset " + i); } } finally { //output.Close(); } }
public void TestRead() { MemoryStream baos = new MemoryStream(); ILittleEndianOutput leo = new LittleEndianOutputStream(baos); leo.WriteInt(12345678); leo.WriteShort(12345); leo.WriteByte(123); leo.WriteShort(40000); leo.WriteByte(200); leo.WriteLong(1234567890123456789L); leo.WriteDouble(123.456); ILittleEndianInput lei = new LittleEndianInputStream(new MemoryStream(baos.ToArray())); Assert.AreEqual(12345678, lei.ReadInt()); Assert.AreEqual(12345, lei.ReadShort()); Assert.AreEqual(123, lei.ReadByte()); Assert.AreEqual(40000, lei.ReadUShort()); Assert.AreEqual(200, lei.ReadUByte()); Assert.AreEqual(1234567890123456789L, lei.ReadLong()); Assert.AreEqual(123.456, lei.ReadDouble(), 0.0); }
public void TestExtRstFromEmpty() { UnicodeString.ExtRst ext = new UnicodeString.ExtRst(); Assert.AreEqual(0, ext.NumberOfRuns); Assert.AreEqual(0, ext.FormattingFontIndex); Assert.AreEqual(0, ext.FormattingOptions); Assert.AreEqual("", ext.PhoneticText); Assert.AreEqual(0, ext.PhRuns.Length); Assert.AreEqual(10, ext.DataSize); // Excludes 4 byte header MemoryStream baos = new MemoryStream(); LittleEndianOutputStream out1 = new LittleEndianOutputStream(baos); ContinuableRecordOutput cout = new ContinuableRecordOutput(out1, 0xffff); ext.Serialize(cout); cout.WriteContinue(); byte[] b = baos.ToArray(); Assert.AreEqual(20, b.Length); // First 4 bytes from the outputstream Assert.AreEqual(-1, (sbyte)b[0]); Assert.AreEqual(-1, (sbyte)b[1]); Assert.AreEqual(14, b[2]); Assert.AreEqual(00, b[3]); // Reserved Assert.AreEqual(1, b[4]); Assert.AreEqual(0, b[5]); // Data size Assert.AreEqual(10, b[6]); Assert.AreEqual(00, b[7]); // Font*2 Assert.AreEqual(0, b[8]); Assert.AreEqual(0, b[9]); Assert.AreEqual(0, b[10]); Assert.AreEqual(0, b[11]); // 0 Runs Assert.AreEqual(0, b[12]); Assert.AreEqual(0, b[13]); // Size=0, *2 Assert.AreEqual(0, b[14]); Assert.AreEqual(0, b[15]); Assert.AreEqual(0, b[16]); Assert.AreEqual(0, b[17]); // Last 2 bytes from the outputstream Assert.AreEqual(ContinueRecord.sid, b[18]); Assert.AreEqual(0, b[19]); // Load in again and re-test byte[] data = new byte[14]; Array.Copy(b, 4, data, 0, data.Length); LittleEndianInputStream inp = new LittleEndianInputStream( new MemoryStream(data) ); ext = new UnicodeString.ExtRst(inp, data.Length); Assert.AreEqual(0, ext.NumberOfRuns); Assert.AreEqual(0, ext.FormattingFontIndex); Assert.AreEqual(0, ext.FormattingOptions); Assert.AreEqual("", ext.PhoneticText); Assert.AreEqual(0, ext.PhRuns.Length); }