@Override public void hashCodeShow(Indent indent) { System.out.printf("%sDim hash = %d%n", indent, hashCode()); System.out.printf("%s shortName '%s' = %d%n", indent, getShortName(), getShortName() == null ? -1 : getShortName().hashCode()); System.out.printf("%s getLength %s%n", indent, getLength()); System.out.printf("%s isUnlimited %s%n", indent, isUnlimited()); System.out.printf("%s isVariableLength %s%n", indent, isVariableLength()); System.out.printf("%s isShared %s%n", indent, isShared()); if (getGroup() != null) System.out.printf("%s parentGroup %s = %d%n", indent, getGroup(), getGroup().hashCode()); }
@Override public void hashCodeShow(Indent indent) { System.out.printf("%sDim hash = %d%n", indent, hashCode()); System.out.printf("%s shortName '%s' = %d%n", indent, getShortName(), getShortName() == null ? -1 : getShortName().hashCode()); System.out.printf("%s getLength %s%n", indent, getLength()); System.out.printf("%s isUnlimited %s%n", indent, isUnlimited()); System.out.printf("%s isVariableLength %s%n", indent, isVariableLength()); System.out.printf("%s isShared %s%n", indent, isShared()); if (getGroup() != null) System.out.printf("%s parentGroup %s = %d%n", indent, getGroup(), getGroup().hashCode()); }
protected void addDimensionsClassic(List<? extends VariableSimpleIF> vars, Map<String, Dimension> dimMap) throws IOException { Set<Dimension> oldDims = new HashSet<>(20); // find all dimensions needed by these variables for (VariableSimpleIF var : vars) { List<Dimension> dims = var.getDimensions(); oldDims.addAll(dims); } // add them for (Dimension d : oldDims) { // The dimension we're creating below will be shared, so we need an appropriate name for it. String dimName = getSharedDimName(d); if (!writer.hasDimension(null, dimName)) { Dimension newDim = writer.addDimension(null, dimName, d.getLength(), false, d.isVariableLength()); dimMap.put(dimName, newDim); } } }
protected void addDimensionsClassic(List<? extends VariableSimpleIF> vars, Map<String, Dimension> dimMap) throws IOException { Set<Dimension> oldDims = new HashSet<>(20); // find all dimensions needed by these variables for (VariableSimpleIF var : vars) { List<Dimension> dims = var.getDimensions(); oldDims.addAll(dims); } // add them for (Dimension d : oldDims) { // The dimension we're creating below will be shared, so we need an appropriate name for it. String dimName = getSharedDimName(d); if (!writer.hasDimension(null, dimName)) { Dimension newDim = writer.addDimension(null, dimName, d.getLength(), true, false, d.isVariableLength()); dimMap.put(dimName, newDim); } } }
protected void writeCDL(Formatter out, Indent indent, boolean strict) { String name = strict ? NetcdfFile.makeValidCDLName(getShortName()) : getShortName(); out.format("%s%s", indent, name); if (isUnlimited()) out.format(" = UNLIMITED; // (%d currently)", getLength()); else if (isVariableLength()) out.format(" = UNKNOWN;"); else out.format(" = %d;", getLength()); /* { if (strict) { if (name.length() == 0) buff.append(getLength()); // CDL doesnt allow anon dimensions? } else { if (name.length() > 0) buff.append(" = "); // skip for anon dimensions buff.append(getLength()); } buff.append(";"); } */ }
protected void writeCDL(Formatter out, Indent indent, boolean strict) { String name = strict ? NetcdfFile.makeValidCDLName(getShortName()) : getShortName(); out.format("%s%s", indent, name); if (isUnlimited()) out.format(" = UNLIMITED; // (%d currently", getLength()); else if (isVariableLength()) out.format(" = UNKNOWN;"); else out.format(" = %d;", getLength()); /* { if (strict) { if (name.length() == 0) buff.append(getLength()); // CDL doesnt allow anon dimensions? } else { if (name.length() > 0) buff.append(" = "); // skip for anon dimensions buff.append(getLength()); } buff.append(";"); } */ }
private List<Dimension> getNewDimensions(Variable oldVar) { List<Dimension> result = new ArrayList<>(oldVar.getRank()); // dimensions for (Dimension oldD : oldVar.getDimensions()) { Dimension newD = gdimHash.get(oldD.getShortName()); if (newD == null) { newD = writer.addDimension(null, oldD.getShortName(), oldD.isUnlimited() ? 0 : oldD.getLength(), oldD.isUnlimited(), oldD.isVariableLength()); gdimHash.put(oldD.getShortName(), newD); if (debug) System.out.println("add dim= " + newD); } result.add(newD); } return result; }
public static Element writeDimension(Dimension dim, Namespace ns) { Element dimElem = new Element("dimension", ns); dimElem.setAttribute("name", dim.getShortName()); if (dim.isVariableLength()) dimElem.setAttribute("length", "*"); else dimElem.setAttribute("length", Integer.toString(dim.getLength())); if (dim.isUnlimited()) dimElem.setAttribute("isUnlimited", "true"); if (dim.isVariableLength()) dimElem.setAttribute("isVariableLength", "true"); return dimElem; }
private List<Dimension> getNewDimensions(Variable oldVar) { List<Dimension> result = new ArrayList<Dimension>(oldVar.getRank()); // dimensions for (Dimension oldD : oldVar.getDimensions()) { Dimension newD = gdimHash.get(oldD.getShortName()); if (newD == null) { newD = writer.addDimension(null, oldD.getShortName(), oldD.isUnlimited() ? 0 : oldD.getLength(), oldD.isShared(), oldD.isUnlimited(), oldD.isVariableLength()); gdimHash.put(oldD.getShortName(), newD); if (debug) System.out.println("add dim= " + newD); } result.add(newD); } return result; }
private List<Dimension> getNewDimensions(Variable oldVar) { List<Dimension> result = new ArrayList<>(oldVar.getRank()); // dimensions for (Dimension oldD : oldVar.getDimensions()) { Dimension newD = gdimHash.get(oldD.getShortName()); if (newD == null) { newD = writer.addDimension(null, oldD.getShortName(), oldD.isUnlimited() ? 0 : oldD.getLength(), oldD.isShared(), oldD.isUnlimited(), oldD.isVariableLength()); gdimHash.put(oldD.getShortName(), newD); if (debug) System.out.println("add dim= " + newD); } result.add(newD); } return result; }
/** * Add a Dimension to the file * * @param dim copy this dimension * @return the new Dimension */ public Dimension writeDimension(Dimension dim) { String useName = N3iosp.makeValidNetcdfObjectName(dim.getShortName()); Dimension newDim = ncfile.addDimension(useName, dim.isUnlimited() ? 0 : dim.getLength(), dim.isShared(), dim.isUnlimited(), dim.isVariableLength()); dimHash.put(useName, newDim); if (debug) System.out.println("write dim= " + newDim); return newDim; }
/** * Add a Dimension to the file * * @param dim copy this dimension * @return the new Dimension */ public Dimension writeDimension(Dimension dim) { String useName = N3iosp.makeValidNetcdfObjectName(dim.getShortName()); Dimension newDim = ncfile.addDimension(useName, dim.isUnlimited() ? 0 : dim.getLength(), dim.isShared(), dim.isUnlimited(), dim.isVariableLength()); dimHash.put(useName, newDim); if (debug) System.out.println("write dim= " + newDim); return newDim; }
/** * Add a Dimension to the file * * @param dim copy this dimension * @return the new Dimension */ public Dimension writeDimension(Dimension dim) { String useName = N3iosp.makeValidNetcdfObjectName(dim.getShortName()); Dimension newDim = ncfile.addDimension(useName, dim.isUnlimited() ? 0 : dim.getLength(), dim.isShared(), dim.isUnlimited(), dim.isVariableLength()); dimHash.put(useName, newDim); if (debug) System.out.println("write dim= " + newDim); return newDim; }
static NcStreamProto.Dimension.Builder encodeDim(Dimension dim) { NcStreamProto.Dimension.Builder dimBuilder = NcStreamProto.Dimension.newBuilder(); if (dim.getShortName() != null) dimBuilder.setName(dim.getShortName()); if (!dim.isVariableLength()) dimBuilder.setLength(dim.getLength()); dimBuilder.setIsPrivate(!dim.isShared()); dimBuilder.setIsVlen(dim.isVariableLength()); dimBuilder.setIsUnlimited(dim.isUnlimited()); return dimBuilder; }
public static Element writeDimension(Dimension dim, Namespace ns) { Element dimElem = new Element("dimension", ns); dimElem.setAttribute("name", dim.getShortName()); dimElem.setAttribute("length", Integer.toString(dim.getLength())); if (dim.isUnlimited()) dimElem.setAttribute("isUnlimited", "true"); if (dim.isVariableLength()) dimElem.setAttribute("isVariableLength", "true"); return dimElem; }
/** * Override Object.hashCode() to implement equals. */ @Override public int hashCode() { if (hashCode == 0) { int result = 17; Group g = getGroup(); if (g != null) result += 37 * result + g.hashCode(); if (null != getShortName()) result += 37 * result + getShortName().hashCode(); result += 37 * result + getLength(); result += 37 * result + (isUnlimited() ? 0 : 1); result += 37 * result + (isVariableLength() ? 0 : 1); result += 37 * result + (isShared() ? 0 : 1); hashCode = result; } return hashCode; }
/** * Instances which have same contents are equal. * Careful!! this is not object identity !! */ @Override public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof Dimension)) return false; Dimension other = (Dimension) oo; Group g = getGroup(); if ((g != null) && !g.equals(other.getGroup())) return false; if ((getShortName() == null) && (other.getShortName() != null)) return false; if ((getShortName() != null) && !getShortName().equals(other.getShortName())) return false; return (getLength() == other.getLength()) && (isUnlimited() == other.isUnlimited()) && (isVariableLength() == other.isVariableLength()) && (isShared() == other.isShared()); }
/** * Instances which have same contents are equal. * Careful!! this is not object identity !! */ @Override public boolean equals(Object oo) { if (this == oo) return true; if ( !(oo instanceof Dimension)) return false; Dimension other = (Dimension) oo; Group g = getGroup(); if ((g != null) && !g.equals(other.getGroup())) return false; if ((getShortName() == null) && (other.getShortName() != null)) return false; if ((getShortName() != null) && !getShortName().equals(other.getShortName())) return false; return (getLength() == other.getLength()) && (isUnlimited() == other.isUnlimited()) && (isVariableLength() == other.isVariableLength()) && (isShared() == other.isShared()); }
static NcStreamProto.Dimension.Builder encodeDim(Dimension dim) { NcStreamProto.Dimension.Builder dimBuilder = NcStreamProto.Dimension.newBuilder(); if (dim.getShortName() != null) dimBuilder.setName(dim.getShortName()); dimBuilder.setLength(dim.getLength()); if (!dim.isShared()) dimBuilder.setIsPrivate(true); if (dim.isVariableLength()) dimBuilder.setIsVlen(true); if (dim.isUnlimited()) dimBuilder.setIsUnlimited(true); return dimBuilder; }
static NcStreamProto.Dimension.Builder encodeDim(Dimension dim) { NcStreamProto.Dimension.Builder dimBuilder = NcStreamProto.Dimension.newBuilder(); dimBuilder.setName(dim.getShortName() == null ? "" : dim.getShortName()); dimBuilder.setLength(dim.getLength()); if (!dim.isShared()) dimBuilder.setIsPrivate(true); if (dim.isVariableLength()) dimBuilder.setIsVlen(true); if (dim.isUnlimited()) dimBuilder.setIsUnlimited(true); return dimBuilder; }