Inheritance: OutputStream, ObjectOutput
Example #1
0
        /// <summary>
        /// WriteObject is called to save the state of the FilePermission
        /// to a stream. The actions are serialized, and the superclass
        /// takes care of the name.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(ObjectOutputStream s) throws IOException
        private void WriteObject(ObjectOutputStream s)
        {
            // Write out the actions. The superclass takes care of the name
            // call getActions to make sure actions field is initialized
            if (Actions_Renamed == null)
            {
                Actions;
            }
            s.DefaultWriteObject();
        }
Example #2
0
        /// <summary>
        /// @serialData "permissions" field (a Vector containing the FilePermissions).
        /// </summary>

        /*
         * Writes the contents of the perms field out as a Vector for
         * serialization compatibility with earlier releases.
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void writeObject(ObjectOutputStream out) throws IOException
        private void WriteObject(ObjectOutputStream @out)
        {
            // Don't call out.defaultWriteObject()

            // Write out Vector
            List <Permission> permissions = new List <Permission>(Perms.Count);

            lock (this)
            {
                permissions.AddRange(Perms);
            }

            ObjectOutputStream.PutField pfields = @out.PutFields();
            pfields.Put("permissions", permissions);
            @out.WriteFields();
        }
 public static void writeAttributedString(AttributedString @as, ObjectOutputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (@as != null)
   {
     stream.writeBoolean(false);
     AttributedCharacterIterator iterator = @as.getIterator();
     StringBuffer stringBuffer = new StringBuffer();
     for (int index = (int) ((CharacterIterator) iterator).first(); index != (int) ushort.MaxValue; index = (int) ((CharacterIterator) iterator).next())
       stringBuffer = stringBuffer.append((char) index);
     stream.writeObject((object) stringBuffer.toString());
     int num = (int) ((CharacterIterator) iterator).first();
     int beginIndex = ((CharacterIterator) iterator).getBeginIndex();
     for (; num != (int) ushort.MaxValue; {
       int runLimit;
       num = (int) ((CharacterIterator) iterator).setIndex(runLimit);
     }
     )
     {
       stream.writeChar(num);
       runLimit = iterator.getRunLimit();
       stream.writeInt(runLimit - beginIndex);
       HashMap hashMap = new HashMap(iterator.getAttributes());
       stream.writeObject((object) hashMap);
     }
     stream.writeChar((int) ushort.MaxValue);
   }
   else
     stream.writeBoolean(true);
 }
 public static void writePoint2D(Point2D p, ObjectOutputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (p != null)
   {
     stream.writeBoolean(false);
     stream.writeDouble(p.getX());
     stream.writeDouble(p.getY());
   }
   else
     stream.writeBoolean(true);
 }
 public static void writeShape(Shape shape, ObjectOutputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (shape != null)
   {
     stream.writeBoolean(false);
     if (shape is Line2D)
     {
       Line2D line2D = (Line2D) shape;
       stream.writeObject(SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Line2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Line2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Line2D = SerialUtilities.class\u0024("java.awt.geom.Line2D")));
       stream.writeDouble(line2D.getX1());
       stream.writeDouble(line2D.getY1());
       stream.writeDouble(line2D.getX2());
       stream.writeDouble(line2D.getY2());
     }
     else if (shape is Rectangle2D)
     {
       Rectangle2D rectangle2D = (Rectangle2D) shape;
       stream.writeObject(SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Rectangle2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Rectangle2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Rectangle2D = SerialUtilities.class\u0024("java.awt.geom.Rectangle2D")));
       stream.writeDouble(((RectangularShape) rectangle2D).getX());
       stream.writeDouble(((RectangularShape) rectangle2D).getY());
       stream.writeDouble(((RectangularShape) rectangle2D).getWidth());
       stream.writeDouble(((RectangularShape) rectangle2D).getHeight());
     }
     else if (shape is Ellipse2D)
     {
       Ellipse2D ellipse2D = (Ellipse2D) shape;
       stream.writeObject(SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Ellipse2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Ellipse2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Ellipse2D = SerialUtilities.class\u0024("java.awt.geom.Ellipse2D")));
       stream.writeDouble(((RectangularShape) ellipse2D).getX());
       stream.writeDouble(((RectangularShape) ellipse2D).getY());
       stream.writeDouble(((RectangularShape) ellipse2D).getWidth());
       stream.writeDouble(((RectangularShape) ellipse2D).getHeight());
     }
     else if (shape is Arc2D)
     {
       Arc2D arc2D = (Arc2D) shape;
       stream.writeObject(SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Arc2D != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Arc2D : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024Arc2D = SerialUtilities.class\u0024("java.awt.geom.Arc2D")));
       stream.writeDouble(((RectangularShape) arc2D).getX());
       stream.writeDouble(((RectangularShape) arc2D).getY());
       stream.writeDouble(((RectangularShape) arc2D).getWidth());
       stream.writeDouble(((RectangularShape) arc2D).getHeight());
       stream.writeDouble(arc2D.getAngleStart());
       stream.writeDouble(arc2D.getAngleExtent());
       stream.writeInt(arc2D.getArcType());
     }
     else if (shape is GeneralPath)
     {
       stream.writeObject(SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024GeneralPath != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024GeneralPath : (object) (SerialUtilities.class\u0024java\u0024awt\u0024geom\u0024GeneralPath = SerialUtilities.class\u0024("java.awt.geom.GeneralPath")));
       PathIterator pathIterator = shape.getPathIterator((AffineTransform) null);
       float[] numArray = new float[6];
       stream.writeBoolean(pathIterator.isDone());
       while (!pathIterator.isDone())
       {
         int num = pathIterator.currentSegment(numArray);
         stream.writeInt(num);
         for (int index = 0; index < 6; ++index)
           stream.writeFloat(numArray[index]);
         stream.writeInt(pathIterator.getWindingRule());
         pathIterator.next();
         stream.writeBoolean(pathIterator.isDone());
       }
     }
     else
     {
       stream.writeObject((object) Object.instancehelper_getClass((object) shape));
       stream.writeObject((object) shape);
     }
   }
   else
     stream.writeBoolean(true);
 }
 public static void writeStroke(Stroke stroke, ObjectOutputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (stroke != null)
   {
     stream.writeBoolean(false);
     if (stroke is BasicStroke)
     {
       BasicStroke basicStroke = (BasicStroke) stroke;
       stream.writeObject(SerialUtilities.class\u0024java\u0024awt\u0024BasicStroke != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024BasicStroke : (object) (SerialUtilities.class\u0024java\u0024awt\u0024BasicStroke = SerialUtilities.class\u0024("java.awt.BasicStroke")));
       stream.writeFloat(basicStroke.getLineWidth());
       stream.writeInt(basicStroke.getEndCap());
       stream.writeInt(basicStroke.getLineJoin());
       stream.writeFloat(basicStroke.getMiterLimit());
       stream.writeObject((object) basicStroke.getDashArray());
       stream.writeFloat(basicStroke.getDashPhase());
     }
     else
     {
       stream.writeObject((object) Object.instancehelper_getClass((object) stroke));
       stream.writeObject((object) stroke);
     }
   }
   else
     stream.writeBoolean(true);
 }
 public static void writePaint(Paint paint, ObjectOutputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (paint != null)
   {
     stream.writeBoolean(false);
     stream.writeObject((object) Object.instancehelper_getClass((object) paint));
     if (Serializable.IsInstance((object) paint))
     {
       stream.writeObject((object) paint);
     }
     else
     {
       if (!(paint is GradientPaint))
         return;
       GradientPaint gradientPaint = (GradientPaint) paint;
       stream.writeFloat((float) gradientPaint.getPoint1().getX());
       stream.writeFloat((float) gradientPaint.getPoint1().getY());
       stream.writeObject((object) gradientPaint.getColor1());
       stream.writeFloat((float) gradientPaint.getPoint2().getX());
       stream.writeFloat((float) gradientPaint.getPoint2().getY());
       stream.writeObject((object) gradientPaint.getColor2());
       stream.writeBoolean(gradientPaint.isCyclic());
     }
   }
   else
     stream.writeBoolean(true);
 }
        /**
           * Creates a new area code map serializing the provided area code map to a stream and then reading
           * this stream. The resulting area code map is expected to be strictly equal to the provided one
           * from which it was generated.
           */
        private static AreaCodeMap createNewAreaCodeMap(AreaCodeMap areaCodeMap)
        {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            areaCodeMap.writeExternal(objectOutputStream);
            objectOutputStream.flush();

            AreaCodeMap newAreaCodeMap = new AreaCodeMap();
            newAreaCodeMap.readExternal(
            new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())));
            return newAreaCodeMap;
        }
   /**
      * Gets the size of the provided area code map storage. The map storage passed-in will be filled
      * as a result.
      */
   private static int getSizeOfAreaCodeMapStorage(AreaCodeMapStorageStrategy mapStorage,
 SortedMap<Integer, String> areaCodeMap)
   {
       mapStorage.readFromSortedMap(areaCodeMap);
       ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
       ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
       mapStorage.writeExternal(objectOutputStream);
       objectOutputStream.flush();
       int sizeOfStorage = byteArrayOutputStream.size();
       objectOutputStream.close();
       return sizeOfStorage;
   }