Package java.util

Examples of java.util.Formatter$FormatSpecifier


  void compare(String file, String remote) throws IOException {
    System.out.printf("---------------------------\n");
    NetcdfFile ncfile = NetcdfDataset.openFile(file, null);
    NetcdfFile ncfileRemote = new CdmRemote(remote);

    Formatter f= new Formatter();
    CompareNetcdf2 cn = new CompareNetcdf2(f, false, false, false);
    boolean ok = cn.compare(ncfile, ncfileRemote);
    if (ok)
      System.out.printf("compare %s ok %n", file);
    else
      System.out.printf("compare %s NOT OK %n%s", file, f.toString());
    ncfile.close();
    ncfileRemote.close();
  }
View Full Code Here


      writer.streamAll( wbc);
      wbc.close();

      NetcdfFile ncfileBack = NetcdfFile.open(file.getPath());

      Formatter f = new Formatter();
      CompareNetcdf2 cn = new CompareNetcdf2(f, false, false, true);
      boolean ok = cn.compare(ncfile, ncfileBack);
      if (ok)
        System.out.printf("compare %s ok %n", file);
      else
        System.out.printf("compare %s NOT OK %n%s", file, f.toString());

      ncfileBack.close();
      ncfile.close();

View Full Code Here

      NetcdfFile ncfileBack = NetcdfFile.open(fileOut);

      String filename = "C:/data/formats/netcdf3/testWrite.nc";
      NetcdfFile ncfileOrg = NetcdfFile.open(filename);

      Formatter f = new Formatter();
      CompareNetcdf2 cn = new CompareNetcdf2(f, false, false, true);
      boolean ok = cn.compare(ncfileOrg, ncfileBack);
      if (ok)
        System.out.printf("compare %s ok %n", fileOut);
      else
        System.out.printf("compare %s NOT OK %n%s", fileOut, f.toString());

      ncfileBack.close();
      ncfileOrg.close();
      ncfileRemote.close();
View Full Code Here

    }

    Variable v = new Variable(ncfile, g, null, vname);
    v.setDataType(DataType.FLOAT);

    Formatter dims = new Formatter();

    if (hasEnsemble()) {
      dims.format("ens ");
    }

    dims.format("%s ", tcs.getName());

    if (getVertIsUsed()) {
      dims.format("%s ",  getVertName());
      hasVert = true;
    }

    if (hcs.isLatLon()) {
      dims.format("lat lon");
    } else {
      dims.format("y x");
    }

    v.setDimensions(dims.toString());

    // add attributes
    GridParameter param = lookup.getParameter(firstRecord);
    String unit = param.getUnit();
    if (unit == null) unit = "";
View Full Code Here

   *
   * @return the variable
   */
  public String dump() {
    DateFormatter formatter = new DateFormatter();
    Formatter sbuff = new Formatter();
    sbuff.format("%s %d %n", name, records.size());
    for (GridRecord record : records) {
      sbuff.format(" level = %d %f", record.getLevelType1(), record.getLevel1());
      if (null != record.getValidTime())
        sbuff.format(" time = %s", formatter.toDateTimeString(record.getValidTime()));
      sbuff.format("%n");
    }
    return sbuff.toString();
  }
View Full Code Here

   *
   * @return long variable name
   */
  private String makeLongName() {

    Formatter f = new Formatter();
    GridParameter param = lookup.getParameter(firstRecord);
    f.format("%s", param.getDescription());

    if (firstRecord instanceof GribGridRecord) {
      GribGridRecord ggr = (GribGridRecord) firstRecord;

      if (ggr.getEdition() == 2) {
        Grib2Pds pds2 = (Grib2Pds) ggr.getPds();
        String useGenType = pds2.getUseGenProcessType();
        if (useGenType != null)
          f.format("_%s", useGenType);
      }

      String suffixName = ggr.makeSuffix( );
      if (suffixName != null && suffixName.length() != 0)
        f.format("%s", suffixName);

      if (ggr.isInterval()) {
        String intervalName = makeIntervalName();
        if (intervalName.length() != 0) {
          String stat = ggr.getStatisticalProcessTypeNameShort();
          if (stat != null)
            f.format(" (%s for %s)", ggr.getStatisticalProcessTypeName(), intervalName);
          else
            f.format(" (%s)", intervalName);
        }
      }
    }

    String levelName = GridIndexToNC.makeLevelName(firstRecord, lookup);
    if (levelName.length() != 0)
      f.format(" @ %s", levelName);

    return f.toString();
  }
View Full Code Here

  Formatter out;
  BufferedReader dataIS;
  String line;

  CodeTableGen(String filename) throws IOException {
    out = new Formatter(System.out);
    dataIS = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
    getNextLine();

    int count = 0;
    while (readCodeTable() && count < 100) {
View Full Code Here

  public static void main(String args[]) {
    long val1 = -1;
    long val2 = 234872309;
    int val3 = 2348;
    int val4 = 32;
    Formatter f = new Formatter(System.out);
    f.format("  address            dataPos            offset size\n");
    f.format("  %#-18x %#-18x %5d  %4d%n", val1, val2, val3, val4);

  }
View Full Code Here

   *
   * @return unique CDM variable name
   */
  @Override
  public String cdmVariableName(GridTableLookup lookup, boolean useLevel, boolean useStat) {
    Formatter f = new Formatter();
    String desc = getParameterDescription();
    f.format("%s", desc);

    if (edition == 2) {
      Grib2Pds pds2 = (Grib2Pds) pds;
      String useGenType = pds2.getUseGenProcessType();
      if (useGenType != null)
        f.format("_%s", useGenType);
    }

    if (useLevel) {
      String levelName = lookup.getLevelName(this);
      if (levelName.length() != 0) {
        boolean hasLayerInName = levelName.indexOf("layer") >= 0;
        boolean isLayer = lookup.isLayer(this);
        if (isLayer && !hasLayerInName)
          f.format("_%s_layer", levelName);
        // else if (!isLayer && hasLayerInName) LOOK remove for now - but see NAM_CONUS_12km_conduit
        //  f.format("_%s_level", levelName);
        else
          f.format("_%s", levelName);
      }
    }

    if (useStat) {
      f.format("%s", makeSuffix());
    }

    return f.toString();
  }
View Full Code Here

    return f.toString();
  }

  public String makeSuffix() {
    Formatter f = new Formatter();
    boolean disambig = false;

    String statName = getStatisticalProcessTypeNameShort();
    if (statName != null) {
       f.format("_%s", statName);
       disambig = true;
    }

    if (edition == 2) {
       Grib2Pds pds2 = (Grib2Pds) pds;

       if (pds2.isEnsembleDerived()) {
         Grib2Pds.PdsEnsembleDerived pdsDerived = (Grib2Pds.PdsEnsembleDerived) pds2;
         int type = pdsDerived.getDerivedForecastType(); // derived type (table 4.7)
         f.format("_%s", Grib2Tables.codeTable4_7short(type));
         disambig = true;

       } else if (pds2.isProbability()) {
         Grib2Pds.PdsProbability pdsProb = (Grib2Pds.PdsProbability) pds2;
         String name = getProbabilityVariableNameSuffix(pdsProb.getProbabilityLowerLimit(), pdsProb.getProbabilityUpperLimit(), pdsProb.getProbabilityType());
         f.format("_%s", name);
         disambig = true;
       }

        //if (!disambig) {
        //  f.format("_template%d", pds2.getProductDefinitionTemplate());
        //}
     }

    return f.toString();
  }
View Full Code Here

TOP

Related Classes of java.util.Formatter$FormatSpecifier

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.