Exemple #1
0
  private void writeNodes(
      String s, PrintWriter out, ValidateNWBFile validator, List nodeAttrList, int mapper) {
    out.flush();
    String[] columns = NETFileFunctions.processTokens(s);

    int i = 0;
    for (Iterator ii = nodeAttrList.iterator(); ii.hasNext(); ) {
      NWBAttribute na = (NWBAttribute) ii.next();
      String value = columns[i];
      //	System.out.print(value + "::");
      // value.replace("\"", "");
      if (value.equalsIgnoreCase("*")) {

      } else if (NETFileFunctions.isInList(na.getAttrName(), noPrintParameters)) {
        if (na.getDataType().equalsIgnoreCase(NWBFileProperty.TYPE_STRING)) {
          String[] sa = value.split(" ");
          if (sa.length > 1) out.print(" \"" + value + "\" ");
          else out.print(value + " ");
        } else {
          if (na.getAttrName().equalsIgnoreCase(NWBFileProperty.ATTRIBUTE_ID)) {
            this.vertexToIdMap.put(new Integer(value), new Integer(mapper));
            out.print(mapper + " ");
          } else out.print(value + " ");
        }

      } else if (na.getDataType().equalsIgnoreCase("float")
          || na.getDataType().equalsIgnoreCase("int")) {
        if (!value.equalsIgnoreCase("")) {
          //	System.out.print(na.getAttrName() + " " + value + " ");
          String ss = na.getAttrName();

          if (ss.matches("[bil]?c1")) {

            ss = ss.replace("1", "");
            ss += " " + value + " ";
            for (int j = 1; j < 3; j++) {
              ss += columns[j + i] + " ";
              ii.next();
            }
            i = i + 2;
            out.print(ss);
          } else out.print(na.getAttrName() + " " + value + " ");
        }
      } else if (na.getDataType().equalsIgnoreCase("string")) {

        if (!value.equalsIgnoreCase("")) {
          if (na.getAttrName().startsWith("unknown")) {
            String[] sa = value.split(" ");
            if (sa.length > 1) out.print(" \"" + value + "\" ");
            else out.print(value + " ");
          } else out.print(na.getAttrName() + " \"" + value + "\" ");
        }
      } else ;

      i++;
    }

    out.print("\r\n");
  }
Exemple #2
0
 private void writeVertices(ValidateNETFile vmf, PrintWriter pw) {
   pw.write(MATFileProperty.HEADER_VERTICES + " " + vmf.getVertices().size() + "\n");
   for (int i = 0; i < vmf.getVertices().size(); i++) {
     NETVertex mv = (NETVertex) vmf.getVertices().get(i);
     String s = "";
     for (int j = 0; j < NETVertex.getVertexAttributes().size(); j++) {
       try {
         NETAttribute ma = (NETAttribute) NETVertex.getVertexAttributes().get(j);
         String attr = ma.getAttrName();
         String type = ma.getDataType();
         String value = mv.getAttribute(attr).toString();
         if (value == null) {
           s += "";
         } else {
           if (NETFileFunctions.isInList(attr, noPrintParameters)) {
             if (type.equalsIgnoreCase("string")) s += "\"" + mv.getAttribute(attr) + "\" ";
             else s += mv.getAttribute(attr) + " ";
           } else {
             if (type.equalsIgnoreCase("string")) {
               if (attr.startsWith("unknown")) s += " \"" + mv.getAttribute(attr) + "\" ";
               else s += attr + " \"" + mv.getAttribute(attr) + "\" ";
             } else s += attr + " " + mv.getAttribute(attr) + " ";
           }
         }
       } catch (NullPointerException ex) {
         s += "";
       }
     }
     // System.out.println(s);
     pw.println(s);
   }
   // System.out.println("done here");
 }
Exemple #3
0
  private void writeEdges(String s, PrintWriter out, ValidateNWBFile validator, List edgeAttrList)
      throws Exception {
    // System.out.println(s);
    out.flush();

    int i = 0;
    String[] columns = NETFileFunctions.processTokens(s);
    /*if (inDirectededgesSection)
    	edgeAttrList = validator.getDirectedEdgeAttrList();
    else if (inUndirectededgesSection)
    	edgeAttrList = validator.getUndirectedEdgeAttrList();*/
    for (Iterator ii = edgeAttrList.iterator(); ii.hasNext(); ) {
      NWBAttribute na = (NWBAttribute) ii.next();
      String value = columns[i];
      // System.out.println(value);
      // System.out.print(na.getAttrName()+ " ");
      if (value.equalsIgnoreCase("*")) {

      } else if (na.getAttrName().equals(NETFileProperty.ATTRIBUTE_LABEL)
          || na.getAttrName().equals(ARCEDGEParameter.PARAMETER_LABEL)) {
        out.print(ARCEDGEParameter.PARAMETER_LABEL + " \"" + value + "\" ");
      } else if ((NETFileFunctions.isInList(na.getAttrName(), noPrintParameters))
          && !(na.getAttrName().equals(NETFileProperty.ATTRIBUTE_LABEL))) {
        if (na.getDataType().equalsIgnoreCase(NWBFileProperty.TYPE_STRING)) {
          String[] sa = value.split(" ");
          if (sa.length > 1) out.print(" \"" + value + "\" ");
          else out.print(value + " ");
        } else {
          if (na.getAttrName().equals(NWBFileProperty.ATTRIBUTE_SOURCE)
              || na.getAttrName().equals(NWBFileProperty.ATTRIBUTE_TARGET)) {
            try {
              value = ((Integer) this.vertexToIdMap.get(new Integer(value))).toString();
            } catch (NullPointerException npe) {
              throw new Exception("Edge references an undefined node " + value);
            }
          }
          out.print(value + " ");
        }
      } else if (na.getDataType().equalsIgnoreCase("float")
          || na.getDataType().equalsIgnoreCase("int")) {
        if (!value.equalsIgnoreCase("")) {
          //	System.out.print(na.getAttrName() + " " + value + " ");
          String ss = na.getAttrName();

          if (ss.matches("[bil]?c1")) {

            ss = ss.replace("1", "");
            ss += " " + value + " ";
            for (int j = 1; j < 3; j++) {
              ss += columns[j + i] + " ";
              ii.next();
            }
            i = i + 2;
            out.print(ss);
          } else out.print(na.getAttrName() + " " + value + " ");
        }
      } else if (na.getDataType().equalsIgnoreCase("string")) {

        if (!value.equalsIgnoreCase("")) {
          if (na.getAttrName().startsWith("unknown")) {
            String[] sa = value.split(" ");
            if (sa.length > 1) out.print(" \"" + value + "\" ");
            else out.print(value + " ");
          } else out.print(na.getAttrName() + " \"" + value + "\" ");
        }
      } else ;
      i++;
    }

    out.print("\r\n");
  }