readObject() private method

private readObject ( ) : global::java.lang.Object
return global::java.lang.Object
Example #1
0
    public static void Main(String[] args)
    {
        try
        {
            // Load the model
            java.io.ObjectInputStream   stream       = new java.io.ObjectInputStream(new java.io.FileInputStream("iris_j48.model"));
            weka.classifiers.Classifier qhClassifier = (weka.classifiers.Classifier)stream.readObject();
            stream.close();

            // This model was trained on 66% of instances from the iris dataset. Test the model on remaining 34% instances.
            weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader("iris.arff"));
            insts.setClassIndex(insts.numAttributes() - 1);
            int percentSplit = 66;
            int trainSize    = insts.numInstances() * percentSplit / 100;
            int testSize     = insts.numInstances() - trainSize;
            int numCorrect   = 0;
            for (int i = trainSize; i < insts.numInstances(); i++)
            {
                weka.core.Instance currentInst    = insts.instance(i);
                double             predictedClass = qhClassifier.classifyInstance(currentInst);
                if (predictedClass == insts.instance(i).classValue())
                {
                    numCorrect++;
                }
            }
            Console.WriteLine(numCorrect + " out of " + testSize + " correct (" + (double)((double)numCorrect / (double)testSize * 100.0) + "%)");
        }
        catch (java.lang.Exception e)
        {
            e.printStackTrace();
        }
    }
 public static Paint readPaint(ObjectInputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     object obj1 = (object) null;
     if (!stream.readBoolean())
     {
       Class c = (Class) stream.readObject();
       if (SerialUtilities.isSerializable(c))
         obj1 = (object) (Paint) stream.readObject();
       else if (Object.instancehelper_equals((object) c, SerialUtilities.class\u0024java\u0024awt\u0024GradientPaint != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024GradientPaint : (object) (SerialUtilities.class\u0024java\u0024awt\u0024GradientPaint = SerialUtilities.class\u0024("java.awt.GradientPaint"))))
         obj1 = (object) new GradientPaint(stream.readFloat(), stream.readFloat(), (Color) stream.readObject(), stream.readFloat(), stream.readFloat(), (Color) stream.readObject(), stream.readBoolean());
     }
     object obj2 = obj1;
     if (obj2 == null)
       return (Paint) null;
     Paint paint = obj2 as Paint;
     if (paint != null)
       return paint;
     else
       throw new IncompatibleClassChangeError();
   }
 }
 public static Shape readShape(ObjectInputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     object obj1 = (object) null;
     if (!stream.readBoolean())
     {
       Class @class = (Class) stream.readObject();
       if (Object.instancehelper_equals((object) @class, 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"))))
         obj1 = (object) new Line2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble());
       else if (Object.instancehelper_equals((object) @class, 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"))))
         obj1 = (object) new Rectangle2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble());
       else if (Object.instancehelper_equals((object) @class, 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"))))
         obj1 = (object) new Ellipse2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble());
       else if (Object.instancehelper_equals((object) @class, 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"))))
         obj1 = (object) new Arc2D.Double(stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readDouble(), stream.readInt());
       else if (Object.instancehelper_equals((object) @class, 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"))))
       {
         GeneralPath generalPath = new GeneralPath();
         float[] numArray = new float[6];
         for (int index1 = stream.readBoolean() ? 1 : 0; index1 == 0; index1 = stream.readBoolean() ? 1 : 0)
         {
           int num = stream.readInt();
           for (int index2 = 0; index2 < 6; ++index2)
             numArray[index2] = stream.readFloat();
           switch (num)
           {
             case 0:
               ((Path2D.Float) generalPath).moveTo(numArray[0], numArray[1]);
               break;
             case 1:
               ((Path2D.Float) generalPath).lineTo(numArray[0], numArray[1]);
               break;
             case 2:
               ((Path2D.Float) generalPath).quadTo(numArray[0], numArray[1], numArray[2], numArray[3]);
               break;
             case 3:
               ((Path2D.Float) generalPath).curveTo(numArray[0], numArray[1], numArray[2], numArray[3], numArray[4], numArray[5]);
               break;
             case 4:
               ((Path2D) generalPath).closePath();
               break;
             default:
               string str = "JFreeChart - No path exists";
               Throwable.__\u003CsuppressFillInStackTrace\u003E();
               throw new RuntimeException(str);
           }
           ((Path2D) generalPath).setWindingRule(stream.readInt());
         }
         obj1 = (object) generalPath;
       }
       else
         obj1 = (object) (Shape) stream.readObject();
     }
     object obj2 = obj1;
     if (obj2 == null)
       return (Shape) null;
     Shape shape = obj2 as Shape;
     if (shape != null)
       return shape;
     else
       throw new IncompatibleClassChangeError();
   }
 }
 public static AttributedString readAttributedString(ObjectInputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     AttributedString attributedString = (AttributedString) null;
     if (!stream.readBoolean())
     {
       attributedString = new AttributedString((string) stream.readObject());
       int num1 = (int) stream.readChar();
       int num2 = 0;
       for (; num1 != (int) ushort.MaxValue; num1 = (int) stream.readChar())
       {
         int num3 = stream.readInt();
         Map map = (Map) stream.readObject();
         attributedString.addAttributes(map, num2, num3);
         num2 = num3;
       }
     }
     return attributedString;
   }
 }
 public static Stroke readStroke(ObjectInputStream stream)
 {
   if (stream == null)
   {
     string str = "Null 'stream' argument.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     object obj1 = (object) null;
     if (!stream.readBoolean())
       obj1 = !Object.instancehelper_equals((object) (Class) stream.readObject(), SerialUtilities.class\u0024java\u0024awt\u0024BasicStroke != null ? (object) SerialUtilities.class\u0024java\u0024awt\u0024BasicStroke : (object) (SerialUtilities.class\u0024java\u0024awt\u0024BasicStroke = SerialUtilities.class\u0024("java.awt.BasicStroke"))) ? (object) (Stroke) stream.readObject() : (object) new BasicStroke(stream.readFloat(), stream.readInt(), stream.readInt(), stream.readFloat(), (float[]) stream.readObject(), stream.readFloat());
     object obj2 = obj1;
     if (obj2 == null)
       return (Stroke) null;
     Stroke stroke = obj2 as Stroke;
     if (stroke != null)
       return stroke;
     else
       throw new IncompatibleClassChangeError();
   }
 }