Examples of Hessian2Input


Examples of com.caucho.hessian.io.Hessian2Input

   */
  public static String getDeviceVersion(String partName){
    String fileName = getDeviceFileName(partName);
    String version;
    try{
      Hessian2Input his = FileTools.getInputStream(fileName);
      version = his.readString();
      his.close();
    }
    catch (FileNotFoundException e){
      return null;
    }
    catch (IOException e){
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

  public boolean readCompactEnumFile(String fileName, FamilyType familyType){
    // Set the family name for this wire enumerator
    this.familyType = familyType;
   
    try {
      Hessian2Input his = FileTools.getInputStream(fileName);
      
      //=======================================================//
      /* public static final String wireEnumeratorVersion;     */
      //=======================================================//
      String check = his.readString();
//      if(!check.equals(wireEnumeratorVersion)){
//        MessageGenerator.briefErrorAndExit("Error, the current version " +
//          "of RAPIDSMITH is not compatible with the wire enumerator " +
//          "file(s) present on this installation.  Delete the 'device' " +
//          "directory and run the Installer again to regenerate new wire" +
//          " enumerator files.\nCurrent RAPIDSMITH wire enumerator file " +
//          "version: " + wireEnumeratorVersion +", existing device file " +
//          "version: " + check + ".");
//      }
     
      //=======================================================//
      /* private String[] wireArray;                           */
      //=======================================================//
      wireArray = FileTools.readStringArray(his);

      //=======================================================//
      /* private HashMap<String,Integer> wireMap;              */
      //=======================================================//
      wireMap = new HashMap<>();
      for(int i=0; i < wireArray.length; i++){
        wireMap.put(wireArray[i], i);
      }
     
      //=======================================================//
      /* private WireType[] wireTypeArray;                     */
      /* private WireDirection[] wireDirectionArray;           */
      //=======================================================//     
      int[] wireAttributes = FileTools.readIntArray(his);
      wireDirectionArray = new WireDirection[wireAttributes.length];
      wireTypeArray = new WireType[wireAttributes.length];
      WireDirection[] directions = WireDirection.values();
      WireType[] types = WireType.values();
      for(int i=0; i < wireAttributes.length; i++){
        wireDirectionArray[i] =  directions[0x0000FFFF & (wireAttributes[i] >> 16)];
        wireTypeArray[i] = types[0x0000FFFF & wireAttributes[i]];
      }
     
      //=======================================================//
      /* private HashSet<String> pipSources;                 */
      //=======================================================//
      pipSources = new HashSet<>();
      for(int i : FileTools.readIntArray(his)){
        pipSources.add(wireArray[i]);
      }

      if (check.equals("0.2")) {
        //=======================================================//
      /* private HashSet<String> pipSinks;                 */
        //=======================================================//
        pipSinks = new HashSet<>();
        for (int i : FileTools.readIntArray(his)) {
          pipSinks.add(wireArray[i]);
        }
      }
      his.close();
    } catch (FileNotFoundException e){
      MessageGenerator.briefErrorAndExit("Error: could not find file: " + fileName);
    } catch (IOException e){
      MessageGenerator.briefErrorAndExit("Error reading in compactEnum file.");
    }
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

   * @param fileName The name of the compact device file
   * @return True if operation was successful, false otherwise.
   */
  public boolean readDeviceFromCompactFile(String fileName){
    try {
      Hessian2Input his = FileTools.getInputStream(fileName);
      int size;
     
      //=======================================================//
      /* public static final String deviceFileVersion;         */
      //=======================================================//
      String check = his.readString();
      if(!check.equals(deviceFileVersion)){
        MessageGenerator.briefErrorAndExit("Error, the current version " +
          "of RAPIDSMITH is not compatible with the device " +
          "file(s) present on this installation.  Delete the 'device' " +
          "directory and run the Installer again to regenerate new " +
          "device files.\nCurrent RAPIDSMITH device file " +
          "version: " + deviceFileVersion +", existing device file " +
          "version: " + check + ".");
      }
     
      //=======================================================//
      /* public int tileRows;                                  */
      //=======================================================//
      rows = his.readInt();
     
      //=======================================================//
      /* public int tileColumns;                               */
      //=======================================================//
      columns = his.readInt();

      //=======================================================//
      /* - wirePool -                                          */
      //=======================================================//
      WireConnection[] wires = new WireConnection[his.readInt()];
      for(int i=0; i < wires.length; i++){
        int part1 = his.readInt();
        int part2 = his.readInt();
        wires[i] = new WireConnection(0x7FFFFFFF&part1,part2 >> 16,(part2 << 16) >> 16,(part1 & 0x80000000) == 0x80000000);
      }

      //=======================================================//
      /* - wireArrayPool -                                     */
      //=======================================================//
      size = his.readInt();
      ArrayList<WireConnection[]> wireArrays = new ArrayList<WireConnection[]>(size);
      for(int i=0; i < size; i++){
        int len = his.readInt();
        WireConnection[] tmp = new WireConnection[len];
        for(int j=0; j < len; j++){
          tmp[j] = wires[his.readInt()];
        }
        wireArrays.add(tmp);
      }
     
      //Create a set of Integer objects to avoid duplication
      Integer[] allInts = new Integer[getFamilyWireCount(fileName)];
      for (int i = 0; i < allInts.length; i++) {
        allInts[i] = new Integer(i);
      }
     
      //=======================================================//
      /* - wireConnectionPool -                                */
      //=======================================================//
      size = his.readInt();
      ArrayList<WireArrayConnection> wireConnections = new ArrayList<WireArrayConnection>();
      for(int i=0; i < size; i++){
        wireConnections.add(new WireArrayConnection(his.readInt(),his.readInt()));
      }
     
      //=======================================================//
      /* - tileSinksPool -                                     */
      //=======================================================//
      size = his.readInt();
      ArrayList<HashMap<Integer,SinkPin>> sinks = new ArrayList<HashMap<Integer,SinkPin>>();
      for(int i=0; i < size; i++){
        int length = his.readInt();
        HashMap<Integer,SinkPin> tmp = new HashMap<Integer,SinkPin>();
        for(int j = 0; j < length; j++){
          tmp.put(allInts[his.readInt()], new SinkPin(his.readInt(),his.readInt()));
        }
        sinks.add(tmp);
      }
     
      //=======================================================//
      /* - tileSourcesPool -                                   */
      //=======================================================//
      size = his.readInt();
      ArrayList<int[]> sources = new ArrayList<int[]>();
      for(int i=0; i < size; i++){
        sources.add(FileTools.readIntArray(his));
      }
     
      //=======================================================//
      /* - tileWiresPool -                                     */
      //=======================================================//
      size = his.readInt();
      ArrayList<WireHashMap> wireMaps = new ArrayList<WireHashMap>(size);
      for(int i=0; i < size; i++){
        wireMaps.add(FileTools.readWireHashMap(his,wireArrays,wireConnections));
      }
     
      //=======================================================//
      /* public Tile[][] tiles;                                */
      //=======================================================//
      createTileArray();
      tileMap = new HashMap<String, Tile>();
      String[] tileNames = FileTools.readStringArray(his);
      int[] tileTypes = FileTools.readIntArray(his);
      int[] tileSinks = FileTools.readIntArray(his);
      int[] tileSources = FileTools.readIntArray(his);
      int[] tileWires = FileTools.readIntArray(his);
      int[] primitiveSiteCount = FileTools.readIntArray(his);
      TileType[] typeValues = TileType.values();
      int index = 0;
      for(Tile[] tileArray : tiles){
        for(Tile t : tileArray){
          // Name
          t.setName(tileNames[index]);
          // Type
          t.setType(typeValues[tileTypes[index]]);
          // Sinks
          t.setSinks(sinks.get(tileSinks[index]));
          // Sources
          t.setSources(sources.get(tileSources[index]));
          // Wires
          t.setWireHashMap(wireMaps.get(tileWires[index]));

          // Populate tileMap
          tileMap.put(tileNames[index], t);
         
          // Populate Device reference
          t.setDevice(this);
         
          index++;
        }
      }

      //=======================================================//
      /* public String partName;                               */
      //=======================================================//
      partName = his.readString();
     
      //=======================================================//
      /* - primitivePinPool -                                  */
      //=======================================================//
      size = his.readInt();
      ArrayList<HashMap<String,Integer>> primitivePinMaps = new ArrayList<HashMap<String,Integer>>();
      for(int i=0; i < size; i++){
        primitivePinMaps.add(FileTools.readHashMap(his, allInts));
      }
     
      //=======================================================//
      /* public HashMap<String,Primitive> primitives;          */
      //=======================================================//   
      size = his.readInt();
      PrimitiveType[] typeValues2 = PrimitiveType.values();
      int idx = 0;
      int zeros = 0;
      for(Tile[] tileArray : tiles){
        for(Tile t : tileArray){
          if(primitiveSiteCount[idx] == 0){
            t.setPrimitiveSites(null);
            zeros++;
          }
          else{
            PrimitiveSite[] p = new PrimitiveSite[primitiveSiteCount[idx]];
            for(int i = 0; i < primitiveSiteCount[idx]; i++){
              p[i] = FileTools.readPrimitiveSite(his, this, primitivePinMaps, typeValues2);
              primitiveSites.put(p[i].getName(), p[i]);
            }
            t.setPrimitiveSites(p);
          }
          idx++;
        }
      }

      //=======================================================//
      /* public HashMap<Wire,PIPRouteThrough> routeThroughMap; */
      //=======================================================//
      size = his.readInt();
      for(int i=0; i < size; i++){
        PIPRouteThrough prt = new PIPRouteThrough(typeValues2[his.readInt()],his.readInt(),his.readInt());
        routeThroughMap.put(wires[his.readInt()], prt);
      }

      //=======================================================//
      /* - populateDeviceTileMap -                             */
      //=======================================================//
      reconstructTileMap();
     
      his.close();
    }
    catch (FileNotFoundException e){
      return false;
    }
    catch (IOException e){
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

        try {
            InputStream is = request.getInputStream();
            OutputStream os = response.getOutputStream();

            Hessian2Input in = new Hessian2Input(is);
            AbstractHessianOutput out;

            SerializerFactory serializerFactory = getSerializerFactory();

            in.setSerializerFactory(serializerFactory);

            int code = in.read();

            if (code != 'c') {
                // XXX: deflate
                throw new IOException("expected 'c' in hessian input at " + code);
            }

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

            if (major >= 2)
                out = new Hessian2Output(os);
            else
                out = new HessianOutput(os);
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

  public Hessian2SkeletonInvoker(HessianSkeleton skeleton, SerializerFactory serializerFactory) {
    super(skeleton, serializerFactory);
  }

  public void invoke(InputStream inputStream, OutputStream outputStream) throws Throwable {
    Hessian2Input in = new Hessian2Input(inputStream);
    if (this.serializerFactory != null) {
      in.setSerializerFactory(this.serializerFactory);
    }

    int code = in.read();
    if (code != 'c') {
      throw new IOException("expected 'c' in hessian input at " + code);
    }

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

Examples of com.caucho.hessian.io.Hessian2Input

      if (debugOutputStreamAvailable) {
        osToUse = DebugStreamFactory.createDebugOutputStream(outputStream, debugWriter);
      }
    }

    Hessian2Input in = new Hessian2Input(isToUse);
    if (this.serializerFactory != null) {
      in.setSerializerFactory(this.serializerFactory);
    }

    int code = in.read();
    if (code != 'c') {
      throw new IOException("expected 'c' in hessian input at " + code);
    }

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

Examples of com.caucho.hessian.io.Hessian2Input

        OutputStream outputStream = arg1.getOutputStream();
        /*
         *This works only with hessian >= hessian-3.0.20!!
         *but remember this is not a framework 
         */
        Hessian2Input hessianInput = new Hessian2Input(inputStream);
        if (this.serializerFactory != null) {
                hessianInput.setSerializerFactory(this.serializerFactory);
        }

        int code = hessianInput.read();
        if (code != 'c') {
                throw new IOException("expected 'c' in hessian input at " + code);
        }

        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);
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

      if (debugOutputStreamAvailable) {
        osToUse = DebugStreamFactory.createDebugOutputStream(outputStream, debugWriter);
      }
    }

    Hessian2Input in = new Hessian2Input(isToUse);
    if (this.serializerFactory != null) {
      in.setSerializerFactory(this.serializerFactory);
    }

    int code = in.read();
    if (code != 'c') {
      throw new IOException("expected 'c' in hessian input at " + code);
    }

    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) {
      out.setSerializerFactory(this.serializerFactory);
    }

    try {
      this.skeleton.invoke(in, out);
    }
    finally {
      try {
        in.close();
        isToUse.close();
      }
      catch (IOException ex) {
      }
      try {
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

    System.out.println(bos.size()+","+Arrays.toString(bos.toByteArray()));
    return new ByteArrayInputStream(bos.toByteArray());
  }
 
  public static void readObject_Hessian(InputStream in) throws IOException{
    Hessian2Input hin=new Hessian2Input(in);
    Object o=hin.readObject();
    System.out.println(o);
  }
View Full Code Here

Examples of com.caucho.hessian.io.Hessian2Input

    out.close();
  }

  protected Hessian2Input createHessian2Input(InputStream is) {
    return new Hessian2Input(is);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.