/** * Reads the next unsigned integer value (32 bits) from the stream. * The implementation is as below: * * {@preformat java * return Integer.toUnsignedLong(readInt()); * } * * @return the value of the next unsigned integer from the stream. * @throws IOException if an error (including EOF) occurred while reading the stream. */ public final long readUnsignedInt() throws IOException { return readInt() & 0xFFFFFFFFL; }
case 2: assertEquals("readUnsignedShort()", r.readUnsignedShort(), t.readUnsignedShort()); break; case 3: assertEquals("readChar()", r.readChar(), t.readChar()); break; case 4: assertEquals("readInt()", r.readInt(), t.readInt()); break; case 5: assertEquals("readUnsignedInt()", r.readInt() & 0xFFFFFFFFL, t.readUnsignedInt()); break; case 6: assertEquals("readLong()", r.readLong(), t.readLong()); break;
/** * Reads the next unsigned integer value (32 bits) from the stream. * The implementation is as below: * * {@preformat java * return Integer.toUnsignedLong(readInt()); * } * * @return the value of the next unsigned integer from the stream. * @throws IOException if an error (including EOF) occurred while reading the stream. */ public final long readUnsignedInt() throws IOException { return Integer.toUnsignedLong(readInt()); }
/** * Reads attribute values from the netCDF file header. Current implementation has no restriction on * the location in the header where the netCDF attribute can be declared. The record structure is: * * <ul> * <li>The attribute name (use {@link #readName()})</li> * <li>The attribute type (BYTE, SHORT, …) (use {@link ChannelDataInput#readInt()})</li> * <li>The number of values of the above type (use {@link ChannelDataInput#readInt()})</li> * <li>The actual values as a variable length list (use {@link #readValues(DataType,int)})</li> * </ul> * * If the value is a {@code String}, then leading and trailing spaces and control characters * have been trimmed by {@link String#trim()}. * * @param nelems the number of attributes to read. */ private Map<String,Object> readAttributes(int nelems) throws IOException, DataStoreException { final List<Map.Entry<String,Object>> attributes = new ArrayList<>(nelems); while (--nelems >= 0) { final String name = readName(); final Object value = readValues(DataType.valueOf(input.readInt()), input.readInt()); if (value != null) { attributes.add(new AbstractMap.SimpleEntry<>(name, value)); } } return CollectionsExt.toCaseInsensitiveNameMap(attributes, NAME_LOCALE); }
/** * Reads a string from the channel in the {@link #NAME_ENCODING}. This is suitable for the dimension, * variable and attribute names in the header. Note that attribute value may have a different encoding. */ private String readName() throws IOException, DataStoreContentException { final int length = input.readInt(); if (length < 0) { throw malformedHeader(); } final String text = input.readString(length, NAME_ENCODING); align(length); return text; }
/** * Reads a string from the channel in the {@link #NAME_ENCODING}. This is suitable for the dimension, * variable and attribute names in the header. Note that attribute value may have a different encoding. */ private String readName() throws IOException, DataStoreException { final int length = input.readInt(); if (length < 0) { throw malformedHeader(); } final String text = input.readString(length, NAME_ENCODING); align(length); return text; }
/** * Reads dimensions from the netCDF file header. The record structure is: * * <ul> * <li>The dimension name (use {@link #readName()})</li> * <li>The dimension length (use {@link ChannelDataInput#readInt()})</li> * </ul> * * @param nelems the number of dimensions to read. * @return the dimensions in the order they are declared in the netCDF file. */ private Dimension[] readDimensions(final int nelems) throws IOException, DataStoreException { final Dimension[] dimensions = new Dimension[nelems]; for (int i=0; i<nelems; i++) { final String name = readName(); int length = input.readInt(); if (length == 0) { length = numrecs; if (length == STREAMING) { throw new DataStoreContentException(errors().getString(Errors.Keys.MissingValueForProperty_1, "numrecs")); } } dimensions[i] = new Dimension(name, length); } dimensionMap = Dimension.toCaseInsensitiveNameMap(dimensions, NAME_LOCALE); return dimensions; }
/** * Reads dimensions from the netCDF file header. The record structure is: * * <ul> * <li>The dimension name (use {@link #readName()})</li> * <li>The dimension length (use {@link ChannelDataInput#readInt()})</li> * </ul> * * @param nelems the number of dimensions to read. * @return the dimensions in the order they are declared in the netCDF file. */ private Dimension[] readDimensions(final int nelems) throws IOException, DataStoreContentException { final Dimension[] dimensions = new Dimension[nelems]; for (int i=0; i<nelems; i++) { final String name = readName(); int length = input.readInt(); boolean isUnlimited = (length == 0); if (isUnlimited) { length = numrecs; if (length == STREAMING) { throw new DataStoreContentException(errors().getString(Errors.Keys.MissingValueForProperty_1, tagPath("numrecs"))); } } dimensions[i] = new Dimension(name, length, isUnlimited); } dimensionMap = toCaseInsensitiveNameMap(dimensions); return dimensions; }
case SHORT: {final short v = input.readShort(); align(2); return v;} case USHORT: {final int v = input.readUnsignedShort(); align(2); return v;} case INT: return input.readInt(); case INT64: return input.readLong(); case UINT: return input.readUnsignedInt();
case SHORT: {final short v = input.readShort(); align(2); return v;} case USHORT: {final int v = input.readUnsignedShort(); align(2); return v;} case INT: return input.readInt(); case INT64: return input.readLong(); case UINT: return input.readUnsignedInt();