Exemplo n.º 1
0
        private void  InitBlock()
        {
            ExtUtil.writeNumeric(out_Renamed, attributes.size());

            for (TreeElement e: attributes)
            {
                ExtUtil.write(out_Renamed, e.getNamespace());
                ExtUtil.write(out_Renamed, e.getName());
                ExtUtil.write(out_Renamed, e.getAttributeValue());
            }
            int size = (int)ExtUtil.readNumeric(in_Renamed);

            List <TreeElement> attributes = new List <TreeElement>();

            for (int i = 0; i < size; ++i)
            {
                System.String namespace_Renamed = ExtUtil.readString(in_Renamed);
                System.String name          = ExtUtil.readString(in_Renamed);
                System.String value_Renamed = ExtUtil.readString(in_Renamed);

                TreeElement attr = TreeElement.constructAttributeElement(namespace_Renamed, name, value_Renamed);
                attr.setParent(parent);
                attributes.addElement(attr);
            }
            return(attributes);

            ExtUtil.stringCache = stringCache;
        }
Exemplo n.º 2
0
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public static void  writeTag(System.IO.BinaryWriter out_Renamed, System.Object o)
        {
            if (o is ExternalizableWrapper && !(o is ExtWrapBase))
            {
                out_Renamed.Write(SupportClass.ToByteArray(WRAPPER_TAG), 0, PrototypeFactory.CLASS_HASH_SIZE);
                ExtUtil.writeNumeric(out_Renamed, WRAPPER_CODES.get_Renamed(o.GetType()));
                ((ExternalizableWrapper)o).metaWriteExternal(out_Renamed);
            }
            else
            {
                System.Type type = null;

                if (o is ExtWrapBase)
                {
                    ExtWrapBase extType = (ExtWrapBase)o;
                    if (extType.val != null)
                    {
                        o = extType.val;
                    }
                    else
                    {
                        type = extType.type;
                    }
                }
                if (type == null)
                {
                    type = o.GetType();
                }

                sbyte[] tag = PrototypeFactory.getClassHash(type);                 //cache this?
                out_Renamed.Write(SupportClass.ToByteArray(tag), 0, tag.Length);
            }
        }
Exemplo n.º 3
0
 //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
 public static void  writeBytes(System.IO.BinaryWriter out_Renamed, sbyte[] bytes)
 {
     ExtUtil.writeNumeric(out_Renamed, bytes.Length);
     if (bytes.Length > 0)
     {
         //i think writing zero-length array might close the stream
         out_Renamed.Write(SupportClass.ToByteArray(bytes));
     }
 }
Exemplo n.º 4
0
        //functions like these are bad; they should use the built-in list serialization facilities
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public static void  writeInts(System.IO.BinaryWriter out_Renamed, int[] ints)
        {
            ExtUtil.writeNumeric(out_Renamed, ints.Length);

            for (int i: ints)
            {
                ExtUtil.writeNumeric(out_Renamed, i);
            }
        }
Exemplo n.º 5
0
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public override void writeExternal(System.IO.BinaryWriter out_Renamed)
        {
            System.Collections.ArrayList v = (System.Collections.ArrayList)val;

            ExtUtil.writeNumeric(out_Renamed, v.Count);
            for (int i = 0; i < v.Count; i++)
            {
                ExtUtil.write(out_Renamed, type == null ? v[i] : type.clone(v[i]));
            }
        }
Exemplo n.º 6
0
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public override void writeExternal(System.IO.BinaryWriter out_Renamed)
        {
            System.Collections.ArrayList v = (System.Collections.ArrayList)val;

            ExtUtil.writeNumeric(out_Renamed, v.Count);
            for (int i = 0; i < v.Count; i++)
            {
                ExtUtil.write(out_Renamed, new ExtWrapTagged(v[i]));
            }
        }
Exemplo n.º 7
0
 //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
 public override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     if (in_Renamed.ReadBoolean())
     {
         val = ExtUtil.read(in_Renamed, type, pf);
     }
     else
     {
         val = null;
     }
 }
Exemplo n.º 8
0
        //bad
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public static int[] readInts(System.IO.BinaryReader in_Renamed)
        {
            int size = (int)ExtUtil.readNumeric(in_Renamed);

            int[] ints = new int[size];
            for (int i = 0; i < size; ++i)
            {
                ints[i] = (int)ExtUtil.readNumeric(in_Renamed);
            }
            return(ints);
        }
Exemplo n.º 9
0
 //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
 public override void  writeExternal(System.IO.BinaryWriter out_Renamed)
 {
     if (val != null)
     {
         out_Renamed.Write(true);
         ExtUtil.write(out_Renamed, val);
     }
     else
     {
         out_Renamed.Write(false);
     }
 }
Exemplo n.º 10
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(0));

            long size = ExtUtil.readNumeric(in_Renamed);

            for (int i = 0; i < size; i++)
            {
                v.Add(ExtUtil.read(in_Renamed, new ExtWrapTagged(), pf));
            }

            val = v;
        }
Exemplo n.º 11
0
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public override void  metaWriteExternal(System.IO.BinaryWriter out_Renamed)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable h = (System.Collections.Hashtable)val;
            System.Object keyTagObj;

            ExtUtil.writeBool(out_Renamed, ordered);

            //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
            //UPGRADE_TODO: Method 'java.util.HashMap.keySet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapkeySet'"
            keyTagObj = (keyType == null?(h.Count == 0?new System.Object():new SupportClass.HashSetSupport(h.Keys).GetEnumerator().Current):keyType);
            ExtWrapTagged.writeTag(out_Renamed, keyTagObj);
        }
Exemplo n.º 12
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public static ExternalizableWrapper readTag(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            sbyte[] tag = new sbyte[PrototypeFactory.CLASS_HASH_SIZE];

            in_Renamed.Read((byte[])(Array)tag, 0, tag.Length);



            if (PrototypeFactory.compareHash(tag, WRAPPER_TAG))
            {
                int wrapperCode = ExtUtil.readInt(in_Renamed);

                //find wrapper indicated by code
                ExternalizableWrapper type = null;

                foreach (Object key in WRAPPER_CODES.Keys)
                {
                    System.Type t = (System.Type)key;
                    if ((int)WRAPPER_CODES[key] == wrapperCode)
                    {
                        try
                        {
                            type = (ExternalizableWrapper)PrototypeFactory.getInstance(t);
                        }
                        catch (CannotCreateObjectException ccoe)
                        {
                            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                            throw new CannotCreateObjectException("Serious problem: cannot create built-in ExternalizableWrapper [" + t.FullName + "]");
                        }
                    }
                }
                if (type == null)
                {
                    throw new DeserializationException("Unrecognized ExternalizableWrapper type [" + wrapperCode + "]");
                }

                type.metaReadExternal(in_Renamed, pf);
                return(type);
            }
            else
            {
                System.Type type = pf.getClass(tag);
                if (type == null)
                {
                    throw new DeserializationException("No datatype registered to serialization code " + ExtUtil.printBytes((byte[])(Array)tag));
                }

                return(new ExtWrapBase(type));
            }
        }
Exemplo n.º 13
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            if (type != TYPE_SLOW_READ_ONLY)
            {
                System.Collections.IDictionary h;
                long size = ExtUtil.readNumeric(in_Renamed);
                switch (type)
                {
                case (TYPE_NORMAL):
                    //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
                    h = new System.Collections.Hashtable((int)size);
                    break;

                case (TYPE_ORDERED):
                    h = new OrderedMap();
                    break;

                case (TYPE_SLOW_COMPACT):
                    h = (IDictionary)(new Map((int)size));
                    break;

                default:
                    //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
                    h = new System.Collections.Hashtable((int)size);
                    break;
                }

                for (int i = 0; i < size; i++)
                {
                    System.Object key  = ExtUtil.read(in_Renamed, keyType, pf);
                    System.Object elem = ExtUtil.read(in_Renamed, dataType, pf);
                    h[key] = elem;
                }

                val = h;
            }
            else
            {
                int       size = ExtUtil.readInt(in_Renamed);
                ArrayList k    = new ArrayList(size);
                ArrayList v    = new ArrayList(size);
                for (int i = 0; i < size; i++)
                {
                    k[i] = ExtUtil.read(in_Renamed, keyType, pf);
                    v[i] = ExtUtil.read(in_Renamed, dataType, pf);
                }
                val = (IDictionary)(new Map(k, v));
            }
        }
Exemplo n.º 14
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public static sbyte[] readBytes(System.IO.BinaryReader in_Renamed)
        {
            int size = (int)ExtUtil.readNumeric(in_Renamed);

            sbyte[] bytes  = new sbyte[size];
            int     read   = 0;
            int     toread = size;

            while (read != size)
            {
                read    = SupportClass.ReadInput(in_Renamed.BaseStream, bytes, 0, toread);
                toread -= read;
            }
            return(bytes);
        }
Exemplo n.º 15
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public static sbyte[] readBytes(System.IO.BinaryReader in_Renamed)
        {
            int size = (int)ExtUtil.readNumeric(in_Renamed);

            sbyte[] bytes  = new sbyte[size];
            int     read   = 0;
            int     toread = size;

            while (read != size)
            {
                read    = in_Renamed.Read((byte[])(Array)bytes, 0, toread);
                toread -= read;
            }
            return(bytes);
        }
Exemplo n.º 16
0
        /// <summary> serialize a numeric value, only using as many bytes as needed. splits up the value into
        /// chunks of 7 bits, using as many chunks as needed to unambiguously represent the value. each
        /// chunk is serialized as a single byte, where the most-significant bit is set to 1 to indicate
        /// there are more bytes to follow, or 0 to indicate the last byte
        ///
        /// </summary>
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public override void  writeExternal(System.IO.BinaryWriter out_Renamed)
        {
            int n = ExtUtil.toInt((long)((System.Int64)val));

            if (n >= -bias && n < 255 - bias)
            {
                n += bias;
                out_Renamed.Write((byte)(n >= 128?n - 256:n));
            }
            else
            {
                out_Renamed.Write((System.Byte) 0xff);
                out_Renamed.Write(n);
            }
        }
Exemplo n.º 17
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable h = ordered?new OrderedMap():new System.Collections.Hashtable();

            long size = ExtUtil.readNumeric(in_Renamed);

            for (int i = 0; i < size; i++)
            {
                System.Object key  = ExtUtil.read(in_Renamed, keyType, pf);
                System.Object elem = ExtUtil.read(in_Renamed, new ExtWrapTagged(), pf);
                h[key] = elem;
            }

            val = h;
        }
Exemplo n.º 18
0
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public override void  writeExternal(System.IO.BinaryWriter out_Renamed)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable h = (System.Collections.Hashtable)val;

            ExtUtil.writeNumeric(out_Renamed, h.Count);

            for (Object key: h.keySet())
            {
                //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
                System.Object elem = h[key];

                ExtUtil.write(out_Renamed, keyType == null?key:keyType.clone(key));
                ExtUtil.write(out_Renamed, new ExtWrapTagged(elem));
            }
        }
Exemplo n.º 19
0
 //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
 public override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     if (!sealed_Renamed)
     {
         long size = ExtUtil.readNumeric(in_Renamed);
         System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(0));
         for (int i = 0; i < size; i++)
         {
             v.Add(ExtUtil.read(in_Renamed, type, pf));
         }
         val = v;
     }
     else
     {
         int             size   = (int)ExtUtil.readNumeric(in_Renamed);
         System.Object[] theval = new System.Object[size];
         for (int i = 0; i < size; i++)
         {
             theval[i] = ExtUtil.read(in_Renamed, type, pf);
         }
         val = theval;
     }
 }
Exemplo n.º 20
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            ExternalizableWrapper type = readTag(in_Renamed, pf);

            val = ExtUtil.read(in_Renamed, type, pf);
        }
Exemplo n.º 21
0
 //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
 public override void  metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     ordered = ExtUtil.readBool(in_Renamed);
     keyType = ExtWrapTagged.readTag(in_Renamed, pf);
 }
Exemplo n.º 22
0
 public override ExternalizableWrapper clone(System.Object val)
 {
     return(new ExtWrapIntEncodingUniform(ExtUtil.toLong(val)));
 }
Exemplo n.º 23
0
 public override ExternalizableWrapper clone(System.Object val)
 {
     return(new ExtWrapIntEncodingSmall(ExtUtil.toLong(val), bias));
 }
Exemplo n.º 24
0
 //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
 public override void  writeExternal(System.IO.BinaryWriter out_Renamed)
 {
     writeTag(out_Renamed, val);
     ExtUtil.write(out_Renamed, val);
 }
Exemplo n.º 25
0
 //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
 public override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     val = ExtUtil.read(in_Renamed, type, pf);
 }