public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._originatingID.Unmarshal(dis);
                    this._receivingID.Unmarshal(dis);
                    this._realWorldTime.Unmarshal(dis);
                    this._reason         = dis.ReadUnsignedByte();
                    this._frozenBehavior = dis.ReadUnsignedByte();
                    this._padding1       = dis.ReadShort();
                    this._requestID      = dis.ReadUnsignedInt();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Esempio n. 2
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._parameterIndex = dis.ReadUnsignedShort();
                    this._parameterValue = dis.ReadShort();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Esempio n. 3
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._beamDirection.Unmarshal(dis);
                    this._azimuthBeamwidth = dis.ReadFloat();
                    this._referenceSystem  = dis.ReadFloat();
                    this._padding1         = dis.ReadShort();
                    this._padding2         = dis.ReadByte();
                    this._ez    = dis.ReadFloat();
                    this._ex    = dis.ReadFloat();
                    this._phase = dis.ReadFloat();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._receivingEntityID.Unmarshal(dis);
                    this._repairingEntityID.Unmarshal(dis);
                    this._repairResult = dis.ReadUnsignedByte();
                    this._padding1     = dis.ReadShort();
                    this._padding2     = dis.ReadByte();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._issuingEntityID.Unmarshal(dis);
                    this._collidingEntityID.Unmarshal(dis);
                    this._collisionEventID.Unmarshal(dis);
                    this._pad = dis.ReadShort();
                    this._contactVelocity.Unmarshal(dis);
                    this._mass = dis.ReadFloat();
                    this._locationOfImpact.Unmarshal(dis);
                    this._collisionIntermediateResultXX = dis.ReadFloat();
                    this._collisionIntermediateResultXY = dis.ReadFloat();
                    this._collisionIntermediateResultXZ = dis.ReadFloat();
                    this._collisionIntermediateResultYY = dis.ReadFloat();
                    this._collisionIntermediateResultYZ = dis.ReadFloat();
                    this._collisionIntermediateResultZZ = dis.ReadFloat();
                    this._unitSurfaceNormal.Unmarshal(dis);
                    this._coefficientOfRestitution = dis.ReadFloat();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
        /// <summary>Read word vectors from an input stream.</summary>
        /// <remarks>Read word vectors from an input stream. The stream is not closed on finishing the function.</remarks>
        /// <param name="in">The stream to read from. This is not closed.</param>
        /// <returns>The word vectors encoded on the stream.</returns>
        /// <exception cref="System.IO.IOException">Thrown if we could not read from the stream.</exception>
        public static VectorMap Deserialize(InputStream @in)
        {
            DataInputStream dataIn = new DataInputStream(@in);

            // Read the max key length
            VectorMap.Itype keyIntType = VectorMap.Itype.GetType(dataIn.ReadInt());
            // Read the vector dimensionality
            int dim = dataIn.ReadInt();
            // Read the size of the dataset
            int size = dataIn.ReadInt();
            // Read the vectors
            VectorMap vectors = new VectorMap();

            for (int i = 0; i < size; ++i)
            {
                // Read the key
                int    strlen = keyIntType.Read(dataIn);
                byte[] buffer = new byte[strlen];
                if (dataIn.Read(buffer, 0, strlen) != strlen)
                {
                    throw new IOException("Could not read string buffer fully!");
                }
                string key = Sharpen.Runtime.GetStringForBytes(buffer);
                // Read the vector
                float[] vector = new float[dim];
                for (int k = 0; k < vector.Length; ++k)
                {
                    vector[k] = ToFloat(dataIn.ReadShort());
                }
                // Add the key/value
                vectors[key] = vector;
            }
            return(vectors);
        }
            /// <summary>Read an integer of this type from the given input stream</summary>
            /// <exception cref="System.IO.IOException"/>
            public int Read(DataInputStream @in)
            {
                switch (this)
                {
                case VectorMap.Itype.Int8:
                {
                    return(@in.ReadByte());
                }

                case VectorMap.Itype.Int16:
                {
                    return(@in.ReadShort());
                }

                case VectorMap.Itype.Int32:
                {
                    return(@in.ReadInt());
                }

                default:
                {
                    throw new Exception("Unknown itype: " + this);
                }
                }
            }
Esempio n. 8
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._realWorldTime.Unmarshal(dis);
                    this._reason         = dis.ReadUnsignedByte();
                    this._frozenBehavior = dis.ReadUnsignedByte();
                    this._padding1       = dis.ReadShort();
                    this._requestID      = dis.ReadUnsignedInt();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._requestingEntityID.Unmarshal(dis);
                    this._servicingEntityID.Unmarshal(dis);
                    this._serviceTypeRequested  = dis.ReadUnsignedByte();
                    this._numberOfSupplyTypes   = dis.ReadUnsignedByte();
                    this._serviceRequestPadding = dis.ReadShort();
                    for (int idx = 0; idx < this.NumberOfSupplyTypes; idx++)
                    {
                        SupplyQuantity anX = new SupplyQuantity();
                        anX.Unmarshal(dis);
                        this._supplies.Add(anX);
                    }
                    ;
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
        public virtual void TestGetMetaData()
        {
            SimulatedFSDataset fsdataset = GetSimulatedFSDataset();
            ExtendedBlock      b         = new ExtendedBlock(bpid, 1, 5, 0);

            try
            {
                NUnit.Framework.Assert.IsTrue(fsdataset.GetMetaDataInputStream(b) == null);
                NUnit.Framework.Assert.IsTrue("Expected an IO exception", false);
            }
            catch (IOException)
            {
            }
            // ok - as expected
            AddSomeBlocks(fsdataset);
            // Only need to add one but ....
            b = new ExtendedBlock(bpid, 1, 0, 0);
            InputStream     metaInput     = fsdataset.GetMetaDataInputStream(b);
            DataInputStream metaDataInput = new DataInputStream(metaInput);
            short           version       = metaDataInput.ReadShort();

            NUnit.Framework.Assert.AreEqual(BlockMetadataHeader.Version, version);
            DataChecksum checksum = DataChecksum.NewDataChecksum(metaDataInput);

            NUnit.Framework.Assert.AreEqual(DataChecksum.Type.Null, checksum.GetChecksumType(
                                                ));
            NUnit.Framework.Assert.AreEqual(0, checksum.GetChecksumSize());
        }
Esempio n. 11
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._protocolVersion = dis.ReadUnsignedByte();
                    this._exerciseID      = dis.ReadUnsignedByte();
                    this._pduType         = dis.ReadUnsignedByte();
                    this._protocolFamily  = dis.ReadUnsignedByte();
                    this._timestamp       = dis.ReadUnsignedInt();
                    this._length          = dis.ReadUnsignedShort();
                    this._padding         = dis.ReadShort();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Esempio n. 12
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void ReadFields(DataInputStream @in)
        {
            this.packetLen = @in.ReadInt();
            short protoLen = @in.ReadShort();

            byte[] data = new byte[protoLen];
            @in.ReadFully(data);
            proto = DataTransferProtos.PacketHeaderProto.ParseFrom(data);
        }
Esempio n. 13
0
        // Permissions
        /// <summary>Extract CachePool permissions stored in the fsimage file.</summary>
        /// <param name="in">Datastream to process</param>
        /// <param name="v">Visitor to walk over inodes</param>
        /// <exception cref="System.IO.IOException"/>
        private void ProcessCachePoolPermission(DataInputStream @in, ImageVisitor v)
        {
            v.VisitEnclosingElement(ImageVisitor.ImageElement.Permissions);
            v.Visit(ImageVisitor.ImageElement.CachePoolOwnerName, Text.ReadString(@in));
            v.Visit(ImageVisitor.ImageElement.CachePoolGroupName, Text.ReadString(@in));
            FsPermission fsp = new FsPermission(@in.ReadShort());

            v.Visit(ImageVisitor.ImageElement.CachePoolPermissionString, fsp.ToString());
            v.LeaveEnclosingElement();
        }
Esempio n. 14
0
        /// <summary>Read an Op.</summary>
        /// <remarks>Read an Op.  It also checks protocol version.</remarks>
        /// <exception cref="System.IO.IOException"/>
        protected internal OP ReadOp()
        {
            short version = @in.ReadShort();

            if (version != DataTransferProtocol.DataTransferVersion)
            {
                throw new IOException("Version Mismatch (Expected: " + DataTransferProtocol.DataTransferVersion
                                      + ", Received: " + version + " )");
            }
            return(OP.Read(@in));
        }
Esempio n. 15
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._currentShaftRPMs     = dis.ReadShort();
                    this._orderedShaftRPMs     = dis.ReadShort();
                    this._shaftRPMRateOfChange = dis.ReadFloat();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Loads the rules from a DateInputStream, often in a jar file.
        /// </summary>
        /// <param name="dis">  the DateInputStream to load, not null </param>
        /// <exception cref="Exception"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void load(java.io.DataInputStream dis) throws Exception
        private void Load(DataInputStream dis)
        {
            if (dis.ReadByte() != 1)
            {
                throw new StreamCorruptedException("File format not recognised");
            }
            // group
            String groupId = dis.ReadUTF();

            if ("TZDB".Equals(groupId) == false)
            {
                throw new StreamCorruptedException("File format not recognised");
            }
            // versions
            int versionCount = dis.ReadShort();

            for (int i = 0; i < versionCount; i++)
            {
                VersionId = dis.ReadUTF();
            }
            // regions
            int regionCount = dis.ReadShort();

            String[] regionArray = new String[regionCount];
            for (int i = 0; i < regionCount; i++)
            {
                regionArray[i] = dis.ReadUTF();
            }
            RegionIds = Arrays.AsList(regionArray);
            // rules
            int ruleCount = dis.ReadShort();

            Object[] ruleArray = new Object[ruleCount];
            for (int i = 0; i < ruleCount; i++)
            {
                sbyte[] bytes = new sbyte[dis.ReadShort()];
                dis.ReadFully(bytes);
                ruleArray[i] = bytes;
            }
            // link version-region-rules
            for (int i = 0; i < versionCount; i++)
            {
                int versionRegionCount = dis.ReadShort();
                RegionToRules.Clear();
                for (int j = 0; j < versionRegionCount; j++)
                {
                    String region = regionArray[dis.ReadShort()];
                    Object rule   = ruleArray[dis.ReadShort() & 0xffff];
                    RegionToRules[region] = rule;
                }
            }
        }
Esempio n. 17
0
        // INode
        /// <exception cref="System.IO.IOException"/>
        private void ProcessINodeFileAttributes(DataInputStream @in, ImageVisitor v, string
                                                parentName)
        {
            string pathName = ReadINodePath(@in, parentName);

            v.Visit(ImageVisitor.ImageElement.InodePath, pathName);
            ProcessPermission(@in, v);
            v.Visit(ImageVisitor.ImageElement.ModificationTime, FormatDate(@in.ReadLong()));
            if (NameNodeLayoutVersion.Supports(LayoutVersion.Feature.FileAccessTime, imageVersion
                                               ))
            {
                v.Visit(ImageVisitor.ImageElement.AccessTime, FormatDate(@in.ReadLong()));
            }
            v.Visit(ImageVisitor.ImageElement.Replication, @in.ReadShort());
            v.Visit(ImageVisitor.ImageElement.BlockSize, @in.ReadLong());
        }
Esempio n. 18
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._parameterIndex = dis.ReadUnsignedShort();
                    this._parameterValue = dis.ReadShort();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Esempio n. 19
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._munitionID.Unmarshal(dis);
                    this._eventID.Unmarshal(dis);
                    this._velocity.Unmarshal(dis);
                    this._locationInWorldCoordinates.Unmarshal(dis);
                    this._burstDescriptor.Unmarshal(dis);
                    this._locationInEntityCoordinates.Unmarshal(dis);
                    this._detonationResult = dis.ReadUnsignedByte();
                    this._numberOfArticulationParameters = dis.ReadUnsignedByte();
                    this._pad = dis.ReadShort();

                    for (int idx = 0; idx < this.NumberOfArticulationParameters; idx++)
                    {
                        ArticulationParameter anX = new ArticulationParameter();
                        anX.Unmarshal(dis);
                        this._articulationParameters.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>Process CacheManager state from the fsimage.</summary>
        /// <exception cref="System.IO.IOException"/>
        private void ProcessCacheManagerState(DataInputStream @in, ImageVisitor v)
        {
            v.Visit(ImageVisitor.ImageElement.CacheNextEntryId, @in.ReadLong());
            int numPools = @in.ReadInt();

            for (int i = 0; i < numPools; i++)
            {
                v.Visit(ImageVisitor.ImageElement.CachePoolName, Text.ReadString(@in));
                ProcessCachePoolPermission(@in, v);
                v.Visit(ImageVisitor.ImageElement.CachePoolWeight, @in.ReadInt());
            }
            int numEntries = @in.ReadInt();

            for (int i_1 = 0; i_1 < numEntries; i_1++)
            {
                v.Visit(ImageVisitor.ImageElement.CacheEntryPath, Text.ReadString(@in));
                v.Visit(ImageVisitor.ImageElement.CacheEntryReplication, @in.ReadShort());
                v.Visit(ImageVisitor.ImageElement.CacheEntryPoolName, Text.ReadString(@in));
            }
        }
Esempio n. 21
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._issuingEntityID.Unmarshal(dis);
                    this._collidingEntityID.Unmarshal(dis);
                    this._collisionEventID.Unmarshal(dis);
                    this._pad = dis.ReadShort();
                    this._contactVelocity.Unmarshal(dis);
                    this._mass = dis.ReadFloat();
                    this._location.Unmarshal(dis);
                    this._collisionResultXX = dis.ReadFloat();
                    this._collisionResultXY = dis.ReadFloat();
                    this._collisionResultXZ = dis.ReadFloat();
                    this._collisionResultYY = dis.ReadFloat();
                    this._collisionResultYZ = dis.ReadFloat();
                    this._collisionResultZZ = dis.ReadFloat();
                    this._unitSurfaceNormal.Unmarshal(dis);
                    this._coefficientOfRestitution = dis.ReadFloat();
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Esempio n. 22
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._receivingEntityID.Unmarshal(dis);
                    this._supplyingEntityID.Unmarshal(dis);
                    this._numberOfSupplyTypes = dis.ReadUnsignedByte();
                    this._padding1            = dis.ReadShort();
                    this._padding2            = dis.ReadByte();

                    for (int idx = 0; idx < this.NumberOfSupplyTypes; idx++)
                    {
                        SupplyQuantity anX = new SupplyQuantity();
                        anX.Unmarshal(dis);
                        this._supplies.Add(anX);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
Esempio n. 23
0
        public override void Unmarshal(DataInputStream dis)
        {
            base.Unmarshal(dis);

            if (dis != null)
            {
                try
                {
                    this._receivingEntityID.Unmarshal(dis);
                    this._repairingEntityID.Unmarshal(dis);
                    this._repair   = dis.ReadUnsignedShort();
                    this._padding2 = dis.ReadShort();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Esempio n. 24
0
        public virtual void Unmarshal(DataInputStream dis)
        {
            if (dis != null)
            {
                try
                {
                    this._protocolVersion = dis.ReadUnsignedByte();
                    this._exerciseID      = dis.ReadUnsignedByte();
                    this._pduType         = dis.ReadUnsignedByte();
                    this._protocolFamily  = dis.ReadUnsignedByte();
                    this._timestamp       = dis.ReadUnsignedInt();
                    this._length          = dis.ReadUnsignedShort();
                    this._padding         = dis.ReadShort();
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
Esempio n. 25
0
 /// <summary>This reads all the fields till the beginning of checksum.</summary>
 /// <returns>Metadata Header</returns>
 /// <exception cref="System.IO.IOException"/>
 public static Org.Apache.Hadoop.Hdfs.Server.Datanode.BlockMetadataHeader ReadHeader
     (DataInputStream @in)
 {
     return(ReadHeader(@in.ReadShort(), @in));
 }
Esempio n. 26
0
        // ----------------------------------------------------------------
        // Constructor

        /// <summary>
        /// Constructs a UPropertyAliases object. The binary file DATA_FILE_NAME is
        /// read from the jar/classpath and unflattened into member variables of this
        /// object.
        /// </summary>
        ///
        public UPropertyAliases()
        {
            // Open the .icu file from the jar/classpath
            Stream
                           mask0 = IBM.ICU.Impl.ICUData.GetRequiredStream(DATA_FILE_NAME);
            BufferedStream b     = new BufferedStream(mask0, DATA_BUFFER_SIZE);

            // Read and discard Unicode version...
            /* byte unicodeVersion[] = */
            IBM.ICU.Impl.ICUBinary.ReadHeader(b, DATA_FORMAT_ID,
                                              this);
            DataInputStream d = new DataInputStream(b);

            // Record the origin position of the file. Keep enough around
            // to seek back to the start of the header.
            d.Mark(256);

            short enumToName_offset    = d.ReadShort();
            short nameToEnum_offset    = d.ReadShort();
            short enumToValue_offset   = d.ReadShort();
            short total_size           = d.ReadShort();
            short valueMap_offset      = d.ReadShort();
            short valueMap_count       = d.ReadShort();
            short nameGroupPool_offset = d.ReadShort();
            short nameGroupPool_count  = d.ReadShort();
            short stringPool_offset    = d.ReadShort();
            short stringPool_count     = d.ReadShort();

            if (DEBUG)
            {
                System.Console.Out.WriteLine("enumToName_offset=" + enumToName_offset + "\n"
                                             + "nameToEnum_offset=" + nameToEnum_offset + "\n"
                                             + "enumToValue_offset=" + enumToValue_offset + "\n"
                                             + "total_size=" + total_size + "\n" + "valueMap_offset="
                                             + valueMap_offset + "\n" + "valueMap_count="
                                             + valueMap_count + "\n" + "nameGroupPool_offset="
                                             + nameGroupPool_offset + "\n" + "nameGroupPool_count="
                                             + nameGroupPool_count + "\n" + "stringPool_offset="
                                             + stringPool_offset + "\n" + "stringPool_count="
                                             + stringPool_count);
            }

            byte[] raw = new byte[total_size];
            d.Reset();
            d.ReadFully(raw);
            d.Close();

            UPropertyAliases.Builder builder = new UPropertyAliases.Builder(raw);

            stringPool = builder
                         .ReadStringPool(stringPool_offset, stringPool_count);

            nameGroupPool = builder.ReadNameGroupPool(nameGroupPool_offset,
                                                      nameGroupPool_count);

            builder.SetupValueMap_map(valueMap_offset, valueMap_count);

            // Some of the following data structures have to be set up
            // here, _not_ in Builder. That's because they are instances
            // of non-static inner classes, and they contain implicit
            // references to this.

            builder.Seek(enumToName_offset);
            enumToName = new UPropertyAliases.NonContiguousEnumToShort(builder);
            builder.NameGroupOffsetToIndex(enumToName.offsetArray);

            builder.Seek(nameToEnum_offset);
            nameToEnum = new UPropertyAliases.NameToEnum(this, builder);

            builder.Seek(enumToValue_offset);
            enumToValue = new UPropertyAliases.NonContiguousEnumToShort(builder);
            builder.ValueMapOffsetToIndex(enumToValue.offsetArray);

            valueMapArray = new UPropertyAliases.ValueMap [valueMap_count];
            for (int i = 0; i < valueMap_count; ++i)
            {
                // Must seek to the start of each entry.
                builder.Seek(builder.valueMap_map[i]);
                valueMapArray[i] = new UPropertyAliases.ValueMap(this, builder);
            }

            builder.Close();
        }
Esempio n. 27
0
        public void Handle(byte[] data, RtpMidiServer rtpMidiServer)
        {
            DataInputStream dataInputStream = new DataInputStream(new MemoryStream(data));
            byte            header1         = (byte)dataInputStream.ReadByte();
            byte            version         = (byte)((header1 >> 6) & 0x03);
            bool            paddingFlag     = ((header1 >> 5) & 0x01) == 1;
            bool            extensionFlag   = ((header1 >> 4) & 0x01) == 1;
            byte            contributingSourceIdentifiersCount = (byte)(header1 & 0x0F);

            byte header2     = (byte)dataInputStream.ReadByte();
            bool markerFlag  = ((header2 >> 7) & 0x01) == 1;
            byte payloadType = (byte)(header2 & 0x7F);

            if (payloadType != RTP_MIDI)
            {
                return;
            }

            short sequenceNumber = dataInputStream.ReadShort();
            int   timestamp      = dataInputStream.ReadInt();
            int   ssrc           = dataInputStream.ReadInt();

            RtpHeader rtpHeader = new RtpHeader(version, paddingFlag, extensionFlag, contributingSourceIdentifiersCount, markerFlag,
                                                payloadType, sequenceNumber, timestamp, ssrc);

            byte midiCommandHeader1 = (byte)dataInputStream.ReadByte();
            bool b = ((midiCommandHeader1 >> 7) & 0x01) == 1;
            bool j = ((midiCommandHeader1 >> 6) & 0x01) == 1;
            bool z = ((midiCommandHeader1 >> 5) & 0x01) == 1;
            bool p = ((midiCommandHeader1 >> 4) & 0x01) == 1;
            // Header 2 octets
            short length;

            if (b)
            {
                byte midiCommandHeader2 = (byte)dataInputStream.ReadByte();
                length = (short)((midiCommandHeader1 << 8 | midiCommandHeader2) & 0x0FFF);
            }
            else
            {
                length = (short)(midiCommandHeader1 & 0x0F);
            }

            MidiCommandHeader midiCommandHeader = new MidiCommandHeader(b, j, z, p, length, rtpHeader);

            byte[] midiCommandBuffer    = new byte[length];
            int    midiCommandBytesRead = dataInputStream.Read(midiCommandBuffer);

            if (((short)midiCommandBytesRead) != length)
            {
                return;
            }

            List <MidiTimestampPair> messages = new List <MidiTimestampPair>();

            try
            {
                DataInputStream midiInputStream = new DataInputStream(new MemoryStream(midiCommandBuffer));
                messages.AddRange(ReadMidiMessages(midiCommandHeader, midiInputStream));
                HandleMessage(new RtpMidiMessage(midiCommandHeader, messages));
            }
            catch (System.IO.IOException e)
            {
                Log.Error("RtpMidi", "IOException while processing MIDI message", e);
            }
        }
Esempio n. 28
0
        /// <summary>Process an INode</summary>
        /// <param name="in">image stream</param>
        /// <param name="v">visitor</param>
        /// <param name="skipBlocks">skip blocks or not</param>
        /// <param name="parentName">the name of its parent node</param>
        /// <param name="isSnapshotCopy">whether or not the inode is a snapshot copy</param>
        /// <exception cref="System.IO.IOException"/>
        private void ProcessINode(DataInputStream @in, ImageVisitor v, bool skipBlocks, string
                                  parentName, bool isSnapshotCopy)
        {
            bool supportSnapshot = NameNodeLayoutVersion.Supports(LayoutVersion.Feature.Snapshot
                                                                  , imageVersion);
            bool supportInodeId = NameNodeLayoutVersion.Supports(LayoutVersion.Feature.AddInodeId
                                                                 , imageVersion);

            v.VisitEnclosingElement(ImageVisitor.ImageElement.Inode);
            string pathName = ReadINodePath(@in, parentName);

            v.Visit(ImageVisitor.ImageElement.InodePath, pathName);
            long inodeId = INodeId.GrandfatherInodeId;

            if (supportInodeId)
            {
                inodeId = @in.ReadLong();
                v.Visit(ImageVisitor.ImageElement.InodeId, inodeId);
            }
            v.Visit(ImageVisitor.ImageElement.Replication, @in.ReadShort());
            v.Visit(ImageVisitor.ImageElement.ModificationTime, FormatDate(@in.ReadLong()));
            if (NameNodeLayoutVersion.Supports(LayoutVersion.Feature.FileAccessTime, imageVersion
                                               ))
            {
                v.Visit(ImageVisitor.ImageElement.AccessTime, FormatDate(@in.ReadLong()));
            }
            v.Visit(ImageVisitor.ImageElement.BlockSize, @in.ReadLong());
            int numBlocks = @in.ReadInt();

            ProcessBlocks(@in, v, numBlocks, skipBlocks);
            if (numBlocks >= 0)
            {
                // File
                if (supportSnapshot)
                {
                    // make sure subtreeMap only contains entry for directory
                    Sharpen.Collections.Remove(subtreeMap, inodeId);
                    // process file diffs
                    ProcessFileDiffList(@in, v, parentName);
                    if (isSnapshotCopy)
                    {
                        bool underConstruction = @in.ReadBoolean();
                        if (underConstruction)
                        {
                            v.Visit(ImageVisitor.ImageElement.ClientName, FSImageSerialization.ReadString(@in
                                                                                                          ));
                            v.Visit(ImageVisitor.ImageElement.ClientMachine, FSImageSerialization.ReadString(
                                        @in));
                        }
                    }
                }
                ProcessPermission(@in, v);
            }
            else
            {
                if (numBlocks == -1)
                {
                    // Directory
                    if (supportSnapshot && supportInodeId)
                    {
                        dirNodeMap[inodeId] = pathName;
                    }
                    v.Visit(ImageVisitor.ImageElement.NsQuota, numBlocks == -1 ? @in.ReadLong() : -1);
                    if (NameNodeLayoutVersion.Supports(LayoutVersion.Feature.DiskspaceQuota, imageVersion
                                                       ))
                    {
                        v.Visit(ImageVisitor.ImageElement.DsQuota, numBlocks == -1 ? @in.ReadLong() : -1);
                    }
                    if (supportSnapshot)
                    {
                        bool snapshottable = @in.ReadBoolean();
                        if (!snapshottable)
                        {
                            bool withSnapshot = @in.ReadBoolean();
                            v.Visit(ImageVisitor.ImageElement.IsWithsnapshotDir, bool.ToString(withSnapshot));
                        }
                        else
                        {
                            v.Visit(ImageVisitor.ImageElement.IsSnapshottableDir, bool.ToString(snapshottable
                                                                                                ));
                        }
                    }
                    ProcessPermission(@in, v);
                }
                else
                {
                    if (numBlocks == -2)
                    {
                        v.Visit(ImageVisitor.ImageElement.Symlink, Text.ReadString(@in));
                        ProcessPermission(@in, v);
                    }
                    else
                    {
                        if (numBlocks == -3)
                        {
                            // reference node
                            bool isWithName = @in.ReadBoolean();
                            int  snapshotId = @in.ReadInt();
                            if (isWithName)
                            {
                                v.Visit(ImageVisitor.ImageElement.SnapshotLastSnapshotId, snapshotId);
                            }
                            else
                            {
                                v.Visit(ImageVisitor.ImageElement.SnapshotDstSnapshotId, snapshotId);
                            }
                            bool firstReferred = @in.ReadBoolean();
                            if (firstReferred)
                            {
                                // if a subtree is linked by multiple "parents", the corresponding dir
                                // must be referred by a reference node. we put the reference node into
                                // the subtreeMap here and let its value be false. when we later visit
                                // the subtree for the first time, we change the value to true.
                                subtreeMap[inodeId] = false;
                                v.VisitEnclosingElement(ImageVisitor.ImageElement.SnapshotRefInode);
                                ProcessINode(@in, v, skipBlocks, parentName, isSnapshotCopy);
                                v.LeaveEnclosingElement();
                            }
                            else
                            {
                                // referred inode
                                v.Visit(ImageVisitor.ImageElement.SnapshotRefInodeId, @in.ReadLong());
                            }
                        }
                    }
                }
            }
            v.LeaveEnclosingElement();
        }
Esempio n. 29
0
        /*
         * Get an RBBIDataWrapper from an InputStream onto a pre-compiled set of
         * RBBI rules.
         */
        static internal RBBIDataWrapper Get(Stream mask0)
        {
            int i;

            DataInputStream dis  = new DataInputStream(new BufferedStream(mask0));
            RBBIDataWrapper This = new RBBIDataWrapper();

            // Seek past the ICU data header.
            // TODO: verify that the header looks good.
            dis.SkipBytes(0x80);

            // Read in the RBBI data header...
            This.fHeader                   = new RBBIDataWrapper.RBBIDataHeader();
            This.fHeader.fMagic            = dis.ReadInt();
            This.fHeader.fVersion          = dis.ReadInt();
            This.fHeader.fFormatVersion[0] = (byte)(This.fHeader.fVersion >> 24);
            This.fHeader.fFormatVersion[1] = (byte)(This.fHeader.fVersion >> 16);
            This.fHeader.fFormatVersion[2] = (byte)(This.fHeader.fVersion >> 8);
            This.fHeader.fFormatVersion[3] = (byte)(This.fHeader.fVersion);
            This.fHeader.fLength           = dis.ReadInt();
            This.fHeader.fCatCount         = dis.ReadInt();
            This.fHeader.fFTable           = dis.ReadInt();
            This.fHeader.fFTableLen        = dis.ReadInt();
            This.fHeader.fRTable           = dis.ReadInt();
            This.fHeader.fRTableLen        = dis.ReadInt();
            This.fHeader.fSFTable          = dis.ReadInt();
            This.fHeader.fSFTableLen       = dis.ReadInt();
            This.fHeader.fSRTable          = dis.ReadInt();
            This.fHeader.fSRTableLen       = dis.ReadInt();
            This.fHeader.fTrie             = dis.ReadInt();
            This.fHeader.fTrieLen          = dis.ReadInt();
            This.fHeader.fRuleSource       = dis.ReadInt();
            This.fHeader.fRuleSourceLen    = dis.ReadInt();
            This.fHeader.fStatusTable      = dis.ReadInt();
            This.fHeader.fStatusTableLen   = dis.ReadInt();
            dis.SkipBytes(6 * 4);                                                       // uint32_t fReserved[6];

            if (This.fHeader.fMagic != 0xb1a0 || !(This.fHeader.fVersion == 1 ||        // ICU
                                                                                        // 3.2
                                                                                        // and
                                                                                        // earlier
                                                   This.fHeader.fFormatVersion[0] == 3) // ICU 3.4
                )
            {
                throw new IOException(
                          "Break Iterator Rule Data Magic Number Incorrect, or unsupported data version.");
            }

            // Current position in input stream.
            int pos = 24 * 4;     // offset of end of header, which has 24 fields, all

            // int32_t (4 bytes)

            //
            // Read in the Forward state transition table as an array of shorts.
            //

            // Quick Sanity Check
            if (This.fHeader.fFTable < pos ||
                This.fHeader.fFTable > This.fHeader.fLength)
            {
                throw new IOException("Break iterator Rule data corrupt");
            }

            // Skip over any padding preceding this table
            dis.SkipBytes(This.fHeader.fFTable - pos);
            pos = This.fHeader.fFTable;

            This.fFTable = new short[This.fHeader.fFTableLen / 2];
            for (i = 0; i < This.fFTable.Length; i++)
            {
                This.fFTable[i] = dis.ReadShort();
                pos            += 2;
            }

            //
            // Read in the Reverse state table
            //

            // Skip over any padding in the file
            dis.SkipBytes(This.fHeader.fRTable - pos);
            pos = This.fHeader.fRTable;

            // Create & fill the table itself.
            This.fRTable = new short[This.fHeader.fRTableLen / 2];
            for (i = 0; i < This.fRTable.Length; i++)
            {
                This.fRTable[i] = dis.ReadShort();
                pos            += 2;
            }

            //
            // Read in the Safe Forward state table
            //
            if (This.fHeader.fSFTableLen > 0)
            {
                // Skip over any padding in the file
                dis.SkipBytes(This.fHeader.fSFTable - pos);
                pos = This.fHeader.fSFTable;

                // Create & fill the table itself.
                This.fSFTable = new short[This.fHeader.fSFTableLen / 2];
                for (i = 0; i < This.fSFTable.Length; i++)
                {
                    This.fSFTable[i] = dis.ReadShort();
                    pos += 2;
                }
            }

            //
            // Read in the Safe Reverse state table
            //
            if (This.fHeader.fSRTableLen > 0)
            {
                // Skip over any padding in the file
                dis.SkipBytes(This.fHeader.fSRTable - pos);
                pos = This.fHeader.fSRTable;

                // Create & fill the table itself.
                This.fSRTable = new short[This.fHeader.fSRTableLen / 2];
                for (i = 0; i < This.fSRTable.Length; i++)
                {
                    This.fSRTable[i] = dis.ReadShort();
                    pos += 2;
                }
            }

            //
            // Unserialize the Character categories TRIE
            // Because we can't be absolutely certain where the Trie deserialize
            // will
            // leave the input stream, leave position unchanged.
            // The seek to the start of the next item following the TRIE will get us
            // back in sync.
            //
            dis.SkipBytes(This.fHeader.fTrie - pos);          // seek input stream from end of
            // previous section to
            pos = This.fHeader.fTrie;                         // to the start of the trie

            dis.Mark(This.fHeader.fTrieLen + 100);            // Mark position of start of TRIE
                                                              // in the input
                                                              // and tell Java to keep the mark
                                                              // valid so long
                                                              // as we don't go more than 100
                                                              // bytes past the
                                                              // past the end of the TRIE.

            This.fTrie = new CharTrie(dis, fTrieFoldingFunc); // Deserialize the
                                                              // TRIE, leaving input
            // stream at an unknown position, preceding the
            // padding between TRIE and following section.

            dis.Reset();     // Move input stream back to marked position at
                             // the start of the serialized TRIE. Now our
                             // "pos" variable and the input stream are in
                             // agreement.

            //
            // Read the Rule Status Table
            //
            if (pos > This.fHeader.fStatusTable)
            {
                throw new IOException("Break iterator Rule data corrupt");
            }
            dis.SkipBytes(This.fHeader.fStatusTable - pos);
            pos = This.fHeader.fStatusTable;
            This.fStatusTable = new int[This.fHeader.fStatusTableLen / 4];
            for (i = 0; i < This.fStatusTable.Length; i++)
            {
                This.fStatusTable[i] = dis.ReadInt();
                pos += 4;
            }

            //
            // Put the break rule source into a String
            //
            if (pos > This.fHeader.fRuleSource)
            {
                throw new IOException("Break iterator Rule data corrupt");
            }
            dis.SkipBytes(This.fHeader.fRuleSource - pos);
            pos = This.fHeader.fRuleSource;
            StringBuilder sb = new StringBuilder(This.fHeader.fRuleSourceLen / 2);

            for (i = 0; i < This.fHeader.fRuleSourceLen; i += 2)
            {
                sb.Append(dis.ReadChar());
                pos += 2;
            }
            This.fRuleSource = sb.ToString();

            if (IBM.ICU.Text.RuleBasedBreakIterator.fDebugEnv != null &&
                IBM.ICU.Text.RuleBasedBreakIterator.fDebugEnv.IndexOf("data") >= 0)
            {
                This.Dump();
            }
            return(This);
        }
Esempio n. 30
0
        /// <exclude/>
        public void ReadDictionaryFile(DataInputStream ins0)
        {
            int l;

            // read in the version number (right now we just ignore it)
            ins0.ReadInt();

            // read in the column map (this is serialized in its internal form:
            // an index array followed by a data array)
            l = ins0.ReadInt();
            char[] temp = new char[l];
            for (int i = 0; i < temp.Length; i++)
            {
                temp[i] = (char)ins0.ReadShort();
            }
            l = ins0.ReadInt();
            sbyte[] temp2 = new sbyte[l];
            for (int i_0 = 0; i_0 < temp2.Length; i_0++)
            {
                temp2[i_0] = ins0.ReadByte();
            }
            columnMap = new CompactByteArray(temp, temp2);

            // read in numCols and numColGroups
            numCols = ins0.ReadInt();
            /* numColGroups = */ ins0.ReadInt();

            // read in the row-number index
            l        = ins0.ReadInt();
            rowIndex = new short[l];
            for (int i_1 = 0; i_1 < rowIndex.Length; i_1++)
            {
                rowIndex[i_1] = ins0.ReadShort();
            }

            // load in the populated-cells bitmap: index first, then bitmap list
            l = ins0.ReadInt();
            rowIndexFlagsIndex = new short[l];
            for (int i_2 = 0; i_2 < rowIndexFlagsIndex.Length; i_2++)
            {
                rowIndexFlagsIndex[i_2] = ins0.ReadShort();
            }
            l             = ins0.ReadInt();
            rowIndexFlags = new int[l];
            for (int i_3 = 0; i_3 < rowIndexFlags.Length; i_3++)
            {
                rowIndexFlags[i_3] = ins0.ReadInt();
            }

            // load in the row-shift index
            l = ins0.ReadInt();
            rowIndexShifts = new sbyte[l];
            for (int i_4 = 0; i_4 < rowIndexShifts.Length; i_4++)
            {
                rowIndexShifts[i_4] = ins0.ReadByte();
            }

            // finally, load in the actual state table
            l     = ins0.ReadInt();
            table = new short[l];
            for (int i_5 = 0; i_5 < table.Length; i_5++)
            {
                table[i_5] = ins0.ReadShort();
            }

            // this data structure is only necessary for testing and debugging
            // purposes
            reverseColumnMap = new char[numCols];
            for (char c = (char)(0); c < 0xffff; c++)
            {
                int col = columnMap.ElementAt(c);
                if (col != 0)
                {
                    reverseColumnMap[col] = c;
                }
            }

            // close the stream
            ins0.Close();
        }