Package com.caucho.hessian.io

Examples of com.caucho.hessian.io.Hessian2Output


    }
    return true;
  }

  public static boolean saveToCompressedFile(Object o, String fileName){
    Hessian2Output hos = getOutputStream(fileName);
    try{
      hos.writeObject(o);
      hos.close();
    }
    catch(IOException e){
      return false;
    }
    return true;
View Full Code Here


   * @param fileName Name of the file to be created.
   * @return True if successful, false otherwise.
   */
  public boolean writeCompactEnumFile(String fileName){
    try{
      Hessian2Output hos = FileTools.getOutputStream(fileName);
     
      //=======================================================//
      /* public static final String wireEnumeratorVersion;     */
      //=======================================================//
      hos.writeString(wireEnumeratorVersion);
     
      //=======================================================//
      /* private HashMap<String,Integer> wireMap;              */
      //=======================================================//
           // We'll rebuild this from wireArray

      //=======================================================//
      /* private String[] wireArray;                           */
      //=======================================================//
      if(!FileTools.writeStringArray(hos, wireArray)){
        System.out.println("Failed to write out wireArray.");
        return false;
      }

      //=======================================================//
      /* private WireType[] wireTypeArray;                     */
      /* private WireDirection[] wireDirectionArray;           */
      //=======================================================//     
      int[] wireAttributes = new int[wireArray.length];
      for(int i=0; i < wireAttributes.length; i++){
        wireAttributes[i] = (getWireDirection(i).ordinal() << 16) + getWireType(i).ordinal();
      }
      if(!FileTools.writeIntArray(hos, wireAttributes)){
        System.out.println("Failed to write out wireAttributes.");
        return false;
      }
     
      //=======================================================//
      /* private HashSet<String> pipWireNames;                 */
      //=======================================================//
      int[] pips = new int[pipSources.size()];
      int j=0;
      for(String s : pipSources){
        pips[j] = getWireEnum(s);
        j++;
      }
      if(!FileTools.writeIntArray(hos, pips)){
        System.out.println("Failed to write out pipWires.");
        return false;
      }

      pips = new int[pipSinks.size()];
      j=0;
      for(String s : pipSinks){
        pips[j] = getWireEnum(s);
        j++;
      }
      if(!FileTools.writeIntArray(hos, pips)){
        System.out.println("Failed to write out pipWires.");
        return false;
      }

      hos.close();
    } catch (IOException e){
      MessageGenerator.briefErrorAndExit("Error writing to file: " + fileName);
    }
   
    return true;
View Full Code Here

        tile.setDevice(this);
      }
    }
    try{   
      FileOutputStream fos = new FileOutputStream(fileName);
      Hessian2Output h2os = new Hessian2Output(fos);
      Deflation deflate = new Deflation();
      Hessian2Output hos = deflate.wrap(h2os);
     
      /* DEBUG */ Long[] locations = new Long[2];
      /* DEBUG */ locations[1] = fos.getChannel().position();
      /* DEBUG */ System.out.println("\n");
      MessageGenerator.printHeader("File Usage Statistics");

      //=======================================================//
      /* public static final String deviceFileVersion;         */
      //=======================================================//
      hos.writeString(deviceFileVersion);     
      /* DEBUG */ debugWritingSize(hos,fos,"deviceFileVersion",locations);
     
      //=======================================================//
      /* public int tileRows;                                  */
      //=======================================================//
      hos.writeInt(rows);     
      /* DEBUG */ debugWritingSize(hos,fos,"tileRows",locations);

      //=======================================================//
      /* public int tileColumns;                               */
      //=======================================================//
      hos.writeInt(columns);
      /* DEBUG */ debugWritingSize(hos,fos,"tileColumns",locations);

      //=======================================================//
      /* - wirePool -                                          */
      //=======================================================//
      hos.writeInt(wirePool.getEnumerations().size());
      for(WireConnection w : wirePool.getEnumerations()){
        int mask = w.isPIP() ? 0x80000000 : 0x0;
        hos.writeInt(mask | (w.getWire()));       
        hos.writeInt((w.getRowOffset() << 16) | (w.getColumnOffset() & 0xFFFF));
      }
      /* DEBUG */ debugWritingSize(hos,fos,"wirePool",locations);
     
      //=======================================================//
      /* - wireArrayPool -                                     */
      //=======================================================//
      hos.writeInt(wireArrayPool.getEnumerations().size());
      for(WireArray wireArray : wireArrayPool.getEnumerations()){
        hos.writeInt(wireArray.array.length);
        /*if(wireArray.array.length > 128){
          System.out.println("Bad Assumption");
          System.exit(1);
        }*/
        for(WireConnection w : wireArray.array){
          hos.writeInt(wirePool.getEnumerationValue(w));
        }
      }
      /* DEBUG */ debugWritingSize(hos,fos,"wireArrayPool",locations);

      //=======================================================//
      /* - wireConnectionPool -                                */
      //=======================================================//
      hos.writeInt(wireConnectionPool.getEnumerations().size());
      for(WireArrayConnection wc : wireConnectionPool.getEnumerations()){
        hos.writeInt(wc.wire);
        hos.writeInt(wc.wireArrayEnum);
      }
      /* DEBUG */ debugWritingSize(hos,fos,"wireConnectionPool",locations);           
     
      //=======================================================//
      /* - tileSinksPool -                                     */
      //=======================================================//
      hos.writeInt(tileSinksPool.getEnumerations().size());
      for(TileSinks s : tileSinksPool.getEnumerations()){
        hos.writeInt(s.sinks.size());
        for(Integer key: s.sinks.keySet()) {
          SinkPin sp = s.sinks.get(key);
          hos.writeInt(key);
          hos.writeInt(sp.switchMatrixSinkWire);
          hos.writeInt(sp.switchMatrixTileOffset);
        }
      }
      /* DEBUG */ debugWritingSize(hos,fos,"tileSinksPool",locations);
     
      //=======================================================//
      /* - tileSourcesPool -                                   */
      //=======================================================//
      hos.writeInt(tileSourcesPool.getEnumerations().size());
      for(TileSources s : tileSourcesPool.getEnumerations()){
        FileTools.writeIntArray(hos, s.sources);
      }
      /* DEBUG */ debugWritingSize(hos,fos,"tileSourcesPool",locations);
     
      //=======================================================//
      /* - tileWiresPool -                                     */
      //=======================================================//
      hos.writeInt(tileWiresPool.getEnumerations().size());
      for(TileWires tw : tileWiresPool.getEnumerations()){
        FileTools.writeWireHashMap(hos, tw.wires, wireArrayPool, wireConnectionPool);
      }
      /* DEBUG */ debugWritingSize(hos,fos,"tileWiresPool",locations);
     
      //=======================================================//
      /* public Tile[][] tiles;                                */
      //=======================================================//
      int index = 0;
      String[] tileNames = new String[rows*columns];
      int[] tileTypes = new int[rows*columns];
      int[] tileSinks = new int[rows*columns];
      int[] tileSources = new int[rows*columns];
      int[] tileWires = new int[rows*columns];
      int[] primitiveSitesCount = new int[rows*columns];
      for(Tile[] tileArray : tiles){
        for(Tile t : tileArray){
          // Name
          tileNames[index] = t.getName();
          // Type
          tileTypes[index] = t.getType().ordinal();
          // Sinks
          tileSinks[index] = tileSinksPool.getEnumerationValue(new TileSinks(t.getSinks()));
          // Sources
          tileSources[index] = tileSourcesPool.getEnumerationValue(new TileSources(t.getSources()));
          // Wires
          tileWires[index] = tileWiresPool.getEnumerationValue(new TileWires(t.getWireHashMap()));
          // PrimitiveSites Count
          primitiveSitesCount[index] = t.getPrimitiveSites() == null 0 : t.getPrimitiveSites().length;
          index++;
        }
      }
      FileTools.writeStringArray(hos, tileNames);
      FileTools.writeIntArray(hos, tileTypes);
      FileTools.writeIntArray(hos, tileSinks);
      FileTools.writeIntArray(hos, tileSources);
      FileTools.writeIntArray(hos, tileWires);
      FileTools.writeIntArray(hos, primitiveSitesCount);
      /* DEBUG */ debugWritingSize(hos,fos,"tiles[][]",locations);

      //=======================================================//
      /* public String partName;                               */
      //=======================================================//
      //FileTools.writeString(dos, partName);
      hos.writeString(partName);
      /* DEBUG */ debugWritingSize(hos,fos,"partName",locations);

      //=======================================================//
      /* - primitivePinPool -                                  */
      //=======================================================//
      hos.writeInt(primitivePinPool.getEnumerations().size());
      for(PrimitivePinMap map : primitivePinPool.getEnumerations()){
        FileTools.writeHashMap(hos, map.pins);
      }
      /* DEBUG */ debugWritingSize(hos,fos,"primitivePinPool",locations);
     
      //=======================================================//
      /* public HashMap<String,Primitive> primitives;          */
      //=======================================================//   
      hos.writeInt(primitiveSites.values().size());
      for(Tile[] tileArray : tiles){
        for(Tile t : tileArray){
          if(t.getPrimitiveSites() != null){
            for(PrimitiveSite p : t.getPrimitiveSites()){
              FileTools.writePrimitiveSite(hos, p, this, primitivePinPool);
            }
          }
        }
      }
      /* DEBUG */ debugWritingSize(hos,fos,"primitives",locations);
     
      //=======================================================//
      /* public HashMap<Wire,PIPRouteThrough> routeThroughMap; */
      //=======================================================//
      hos.writeInt(routeThroughMap.size());
      for(WireConnection w : routeThroughMap.keySet()){
        PIPRouteThrough p = routeThroughMap.get(w);
        hos.writeInt(p.getType().ordinal());
        hos.writeInt(p.getInWire());
        hos.writeInt(p.getOutWire());
        hos.writeInt(wirePool.getEnumerationValue(w));
      }
      /* DEBUG */ debugWritingSize(hos,fos,"routeThroughMap",locations);     
      /* DEBUG */ System.out.println("------------------------------------------");     
      /* DEBUG */ System.out.printf("%10d bytes : %s\n\n",(fos.getChannel().position()),"Total");
     
      hos.close();
      fos.close();
    }
    catch (IOException e){
      return false;
    }   
View Full Code Here

            int major = in.read();
            int minor = in.read();

            if (major >= 2)
                out = new Hessian2Output(os);
            else
                out = new HessianOutput(os);

            out.setSerializerFactory(serializerFactory);
View Full Code Here

    AbstractHessianOutput out = null;
    int major = in.read();
    int minor = in.read();
    if (major >= 2) {
      out = new Hessian2Output(outputStream);
    }
    else {
      out = new HessianOutput(outputStream);
    }
    if (this.serializerFactory != null) {
View Full Code Here

    AbstractHessianOutput out = null;
    int major = in.read();
    int minor = in.read();
    if (major >= 2) {
      out = new Hessian2Output(osToUse);
    }
    else {
      out = new HessianOutput(osToUse);
    }
    if (this.serializerFactory != null) {
View Full Code Here

        AbstractHessianOutput  hessianOutput = null;
        int major = hessianInput.read();
        // useless read just get the stream in the right position.
        int minor = hessianInput.read();
        if (major >= 2) {
                hessianOutput = new Hessian2Output(outputStream);
        }
        else {
                hessianOutput = new HessianOutput(outputStream);
        }
        if (this.serializerFactory != null) {
View Full Code Here

    AbstractHessianOutput out = null;
    int major = in.read();
    int minor = in.read();
    if (major >= 2) {
      out = new Hessian2Output(osToUse);
    }
    else {
      out = new HessianOutput(osToUse);
    }
    if (this.serializerFactory != null) {
View Full Code Here

    //writeObject_JDK(s);
  }
 
  public static InputStream writeObject_Hessian(Serializable obj) throws IOException{
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    Hessian2Output out=new Hessian2Output(bos);
    out.writeObject(obj);
    out.flushBuffer();
    System.out.println(bos.size()+","+Arrays.toString(bos.toByteArray()));
    return new ByteArrayInputStream(bos.toByteArray());
  }
View Full Code Here

        minor = isToUse.read();
        if (major != 0x02) {
          throw new IOException("Version " + major + "." + minor + " is not understood");
        }
        in = new Hessian2Input(isToUse);
        out = new Hessian2Output(osToUse);
        in.readCall();
      }
      else if (code == 'C') {
        // Hessian 2.0 call... for some reason not handled in HessianServlet!
        isToUse.reset();
        in = new Hessian2Input(isToUse);
        out = new Hessian2Output(osToUse);
        in.readCall();
      }
      else if (code == 'c') {
        // Hessian 1.0 call
        major = isToUse.read();
        minor = isToUse.read();
        in = new HessianInput(isToUse);
        if (major >= 2) {
          out = new Hessian2Output(osToUse);
        }
        else {
          out = new HessianOutput(osToUse);
        }
      }
View Full Code Here

TOP

Related Classes of com.caucho.hessian.io.Hessian2Output

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.