/** * Constructor * * @param name name must be unique within group. Can be null only if not shared. * @param length length, or UNLIMITED.length or UNKNOWN.length * @param isShared whether its shared or local to Variable. * @param isUnlimited whether the length can grow. * @param isVariableLength whether the length is unknown until the data is read. */ public Dimension( String name, int length, boolean isShared, boolean isUnlimited, boolean isVariableLength) { setName(name); this.isShared = isShared; this.isUnlimited = isUnlimited; this.isVariableLength = isVariableLength; setLength(length); assert (this.name != null) || !this.isShared; }
// look if the wanted dimension is in the unknownDims list. private Dimension checkUnknownDims( String wantDim, List<Dimension> unknownDims, Dimension oldDim, String location) { for (Dimension dim : unknownDims) { if (dim.getShortName().equals(wantDim)) { int len = oldDim.getLength(); if (len == 0) dim.setUnlimited(true); // allow zero length dimension !! dim.setLength(len); // use existing (anon) dimension Group parent = dim.getGroup(); parent.addDimensionIfNotExists(dim); // add to the parent unknownDims.remove(dim); // remove from list LOOK is this ok? log.warn("unknownDim {} length set to {}{}", wantDim, oldDim.getLength(), location); return dim; } } return null; }
/** * Set whether the length is variable. * * @param b true if variable length */ public void setVariableLength(boolean b) { if (immutable) throw new IllegalStateException("Cant modify"); this.isVariableLength = b; setLength(this.length); // check legal }
/** * Set whether this is unlimited, meaning length can increase. * * @param b true if unlimited */ public void setUnlimited(boolean b) { if (immutable) throw new IllegalStateException("Cant modify"); this.isUnlimited = b; setLength(this.length); // check legal }