Package de.desy.tine.csvUtils

Examples of de.desy.tine.csvUtils.csv


  private static String dbFilePath = null;
  public String[] getGroupMembersFromFileCache(String ctxName,String srvName)
  {
    String grpCacheFile = dbFilePath+"GROUPS"+File.separator+
                   ctxName+File.separator+srvName+".csv";
    csv grpDbFile = new csv(grpCacheFile);
   
    String fn = grpDbFile.getFileName();
    if (fn == null)
      fn = TInitializerFactory.getInstance().getInitializer().getFecHome()+File.separator+"eqpdbase.csv";
    ArrayList<String> lst = new ArrayList<String>();
    try
    {
      String s, hdr;
      int mem_col = -1;
      boolean done = false;
      while((s=grpDbFile.readLine()) != null)
      {
        if (s.length() == 0) continue;
        if (s.startsWith("#") || s.startsWith(";") || s.startsWith("%")) continue;
        if (!done)
        {
          hdr = s;
          if ((mem_col=grpDbFile.findcol(hdr,"MEMBERS")) < 0) throw new NoSuchFieldException();
          done = true;
          continue;
        }
        lst.add(srvFile.colptr(mem_col,s));
      }
    }
    catch (Exception e)
    { // database corrupt or not found
      MsgLog.log("getGroupMembersFromFileCache", e.getMessage(),TErrorList.database_not_loaded,e,1);
      resolutionHistory += "getGroupMembersFromFileCache: "+e.getMessage()+"\n";
    }
    finally
    {
      grpDbFile.close();
    }
    return lst.toArray(new String[0])
  }
View Full Code Here


  boolean groupFileHasDevice(String ctxName,String memName,String tgtName)
  {
    String grpCacheFile = dbFilePath+"GROUPS"+File.separator+
                   ctxName+File.separator+memName+File.separator+
                   "devices.csv";
    csv grpDbFile = new csv(grpCacheFile);
   
    String fn = grpDbFile.getFileName();
    if (fn == null)
      fn = TInitializerFactory.getInstance().getInitializer().getFecHome()+File.separator+"eqpdbase.csv";
    boolean found = false;
    try
    {
      String s, hdr;
      int dev_col = -1;
      boolean done = false;
      while((s=grpDbFile.readLine()) != null)
      {
        if (s.length() == 0) continue;
        if (s.startsWith("#") || s.startsWith(";") || s.startsWith("%")) continue;
        if (!done)
        {
          hdr = s;
          if ((dev_col=grpDbFile.findcol(hdr,"DEVICES")) < 0) throw new NoSuchFieldException();
          done = true;
          continue;
        }
        if (grpDbFile.namcmp(tgtName,s,dev_col) == 0)
        {
          found = true;
          break;
        }
      }
    }
    catch (Exception e)
    { // database corrupt or not found
      MsgLog.log("groupFileHasDevice", e.getMessage(),TErrorList.database_not_loaded,e,1);
      resolutionHistory += "groupFileHasDevice: "+e.getMessage()+"\n";
    }
    finally
    {
      grpDbFile.close();
    }   
    return found;
  }
View Full Code Here

    stCols[9] = new csvColumn("WAIT","",new TQuery().new tmrHndlr(stRows));
    stCols[10] = new csvColumn("ACCESS","",new TQuery().new accHndlr(stRows));
    stCols[11] = new csvColumn("TOLERANCE","",new TQuery().new tolHndlr(stRows));
    stCols[12] = new csvColumn("REQUIRED","",new TQuery().new reqHndlr(stRows));
    // open it   
    csv expFile = new csv(stString.toCharArray());
    // read it
    rc = expFile.readFile(stCols,stRows);
    // close it
    if (rc != TErrorList.no_such_file)
      TFecLog.log("get registered exports and properties from exports.csv : " + TErrorList.errorString[rc]);
   
    return stRows.lst.toArray(new SelfTestItem[0]);
View Full Code Here

      if (myip != null) return myip;
      // try file
      csvColumn[] ipCols = new csvColumn[1];
      String[] ipa = new String[1];
      ipCols[0] = new csvColumn("ADDRESS","",new IpNameHndlr(ipa));
      csv myipFile = new csv(getCfgResource(myipFileLocation));
      int rc = myipFile.readFile(ipCols);
      myipFile.close();
      if (rc == 0 && ipa[0] != null)
      { // file found !
        TFecLog.log("fix local ip address to "+ipa[0]+" from file");
        MsgLog.log("TInitializer","fix local ip address to "+ipa[0]+" from file",0,null,1);
        return myip = ipa[0];     
View Full Code Here

        // first try csv
        csvColumn[] addrCols = new csvColumn[1];
        addrHndlr hdlr = new addrHndlr();
        addrCols[0] = new csvColumn("ADDRESS", "", hdlr);
        int rc;
        csv mcastMaskFile = new csv(getCfgResource(getFecHome() +File.separator+ "gcastmask.csv"));
        rc = mcastMaskFile.readFile(addrCols);
        mcastMaskFile.close();
        if (rc != 0)
        {
          mcastMaskFile = new csv(getCfgResource(getTineHome()+File.separator+"gcastmask.csv"));
          rc = mcastMaskFile.readFile(addrCols);
          mcastMaskFile.close();
        }
        if (rc == 0)
        {
          GCAST = hdlr.getStrValue();
          TFecLog.log("set globals multicast address from config file to " + MCAST);
View Full Code Here

        // first try csv file
        csvColumn[] addrCols = new csvColumn[1];
        addrHndlr hdlr = new addrHndlr();
        addrCols[0] = new csvColumn("ADDRESS", "", hdlr);
        int rc;
        csv mcastMaskFile = new csv(getCfgResource(getFecHome()+File.separator+"mcastmask.csv"));
        rc = mcastMaskFile.readFile(addrCols);
        mcastMaskFile.close();
        if (rc != 0)
        {
          mcastMaskFile = new csv(getCfgResource(getTineHome()+File.separator+"mcastmask.csv"));
          rc = mcastMaskFile.readFile(addrCols);
          mcastMaskFile.close();
        }
        if (rc == 0)
        {
          MCAST = hdlr.getStrValue();
          TFecLog.log("set server multicast address from config file to " + MCAST);
View Full Code Here

  {
    String cntName;
    ArrayList<String> ctxNames = new ArrayList<String>(10);
    if (srvName != null && srvName.length() == 0) srvName = null;
    String[] lst = null;
    srvFile = new csv(initializer.getEquipmentResource());
    try
    {
      String s, hdr;
      int nam_col = -1,ctxt_col = -1;
      boolean done = false;
View Full Code Here

    setAddrFileLocation();
  }
  private static boolean isInSrvFile(SrvAddr srv)
  {
    boolean hasEntry = false;
    csv csvf = new csv(srvCacheFile);
    try
    {
      String s, hdr;
      int srv_col = -1,eqn_col = -1 ,fec_col = -1,ctx_col = -1;
      boolean done = false;
      while((s=csvf.readLine()) != null)
      {
        if (s.length() == 0) continue;
        if (s.startsWith("#") || s.startsWith(";") || s.startsWith("%")) continue;
        if (!done)
        {
          hdr = s;
          if ((srv_col=csvf.findcol(hdr,"NAME")) < 0) throw new NoSuchFieldException();
          if ((eqn_col=csvf.findcol(hdr,"EQPMODULE")) < 0) throw new NoSuchFieldException();
          if ((fec_col=csvf.findcol(hdr,"FECNAME")) < 0) throw new NoSuchFieldException();
          if ((ctx_col=csvf.findcol(hdr,"CONTEXT")) < 0) throw new NoSuchFieldException();
          done = true;
          continue;
        }
        if (csvf.namcmp(srv.expName,s,srv_col) != 0) continue;
        if (csvf.namcmp(srv.eqmName,s,eqn_col) != 0) continue;
        if (csvf.namcmp(srv.fecName,s,fec_col) != 0) continue;
        if (csvf.namcmp(srv.eqmContext,s,ctx_col) != 0) continue;
        hasEntry = true;
        break;
      }
    }
    catch (Exception e)
    { // database corrupt or not found
      MsgLog.log("TSrvEntry.isInSrvFile", e.getMessage(),TErrorList.database_not_loaded,e,1);
      hasEntry = false;
    }
    finally
    {
      csvf.close();
    }
    return hasEntry;
  }
View Full Code Here

    return hasEntry;
  }
  private static boolean isInFecFile(SrvAddr srv)
  {
    boolean hasEntry = false;
    csv csvf = new csv(fecCacheFile);
    try
    {
      String s, hdr;
      int fec_col = -1,ip_col = -1 ,port_col = -1,prot_col = -1;
      boolean done = false;
      while((s=csvf.readLine()) != null)
      {
        if (s.length() == 0) continue;
        if (s.startsWith("#") || s.startsWith(";") || s.startsWith("%")) continue;
        if (!done)
        {
          hdr = s;
          if ((fec_col=csvf.findcol(hdr,"FEC_NAME")) < 0) throw new NoSuchFieldException();
          if ((ip_col=csvf.findcol(hdr,"IP_ADDR")) < 0) throw new NoSuchFieldException();
          if ((port_col=csvf.findcol(hdr,"PORT_OFFSET")) < 0) throw new NoSuchFieldException();
          prot_col = csvf.findcol(hdr,"TINE_PROTOCOL");
          done = true;
          continue;
        }
        if (csvf.namcmp(srv.fecName,s,fec_col) != 0) continue;
        if (csvf.namcmp(srv.ipAddr,s,ip_col) != 0) continue;
        try
        {
          if (srv.portOffset != Integer.parseInt(csvf.colptr(port_col,s))) continue;
          if (prot_col < 0) continue;
          if (srv.tineProtocol != Integer.parseInt(csvf.colptr(prot_col,s))) continue;
        }
        catch (Exception e)
        {
          continue;
        }
        hasEntry = true;
        break;
      }
    }
    catch (Exception e)
    { // database corrupt or not found
      MsgLog.log("TSrvEntry.isInFecFile", e.getMessage(),TErrorList.database_not_loaded,e,1);
      hasEntry = false;
    }
    finally
    {
      csvf.close();
    }
    return hasEntry;
  }
View Full Code Here

    stCols[9] = new csvColumn("WAIT","",new TQuery().new tmrHndlr(stRows));
    stCols[10] = new csvColumn("ACCESS","",new TQuery().new accHndlr(stRows));
    stCols[11] = new csvColumn("TOLERANCE","",new TQuery().new tolHndlr(stRows));
    stCols[12] = new csvColumn("REQUIRED","",new TQuery().new reqHndlr(stRows));
    // open it   
    csv expFile = new csv(stString.toCharArray());
    // read it
    rc = expFile.readFile(stCols,stRows);
    // close it
    if (rc != TErrorList.no_such_file)
      TFecLog.log("get registered exports and properties from exports.csv : " + TErrorList.errorString[rc]);
   
    return stRows.lst.toArray(new SelfTestItem[0]);
View Full Code Here

TOP

Related Classes of de.desy.tine.csvUtils.csv

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.