Class Spec
Javadoc 27 generates this reference during each site build from the exported packages and the annotation processor. The Java guide shows the API in use.
A spec is immutable, so threads can share it.
-
Method Summary
Modifier and TypeMethodDescriptioncatalog(byte[] input) Lists the instances of an input without an origin or parameters (§9.6).Lists the instances of an input without parameters, ascatalog(byte[])says.Lists the instances of an input, ascatalog(byte[])says.Lists the instances of an input without an origin or parameters, ascatalog(byte[])says.Lists the instances of an input without parameters, ascatalog(byte[])says.Lists the instances of an input, ascatalog(byte[])says.Lists the instances of a file without parameters, ascatalog(byte[])says.Lists the instances of a file, ascatalog(byte[])says.@Nullable Stringformat()Returns the name of the format that the reader spec reads, or null if it names none.static Specparse(byte[] source) Parses a reader spec without an origin.static SpecParses a reader spec.static SpecParses a reader spec without an origin.static SpecParses a reader spec.read(byte[] input) Reads an input without an origin or parameters.Reads an input without parameters.Reads an input.Reads an input without an origin or parameters.Reads an input without parameters.Reads an input.Reads a file without parameters.Reads a file.<R extends Record>
RecordReader<R> reader(Class<R> type, MethodHandles.Lookup lookup) Makes a reader of data into records oftype, after checking every component against the entries that a read can produce, so that a mismatch fails here rather than in a read.
-
Method Details
-
parse
Parses a reader spec without an origin.- Parameters:
source- the UTF-8 bytes of the reader spec- Returns:
- the parsed reader spec
- Throws:
IrisException- for the first parse-time error
-
parse
Parses a reader spec.- Parameters:
source- the UTF-8 bytes of the reader specorigin- the name of the source in errors- Returns:
- the parsed reader spec
- Throws:
IrisException- for the first parse-time error
-
parse
Parses a reader spec without an origin.- Parameters:
source- the text of the reader spec- Returns:
- the parsed reader spec
- Throws:
IrisException- for the first parse-time error
-
parse
Parses a reader spec.- Parameters:
source- the text of the reader specorigin- the name of the source in errors- Returns:
- the parsed reader spec
- Throws:
IrisException- for the first parse-time error
-
format
Returns the name of the format that the reader spec reads, or null if it names none.- Returns:
- the name of the format that the reader spec reads, or null if it names none
-
read
Reads an input without an origin or parameters.- Parameters:
input- the bytes of the input- Returns:
- the data read
- Throws:
IrisException- for the first error
-
read
Reads an input without parameters.- Parameters:
input- the bytes of the inputorigin- the name of the input in errors- Returns:
- the data read
- Throws:
IrisException- for the first error
-
read
Reads an input.- Parameters:
input- the bytes of the inputorigin- the name of the input in errorsparams- the parameters- Returns:
- the data read
- Throws:
IrisException- for the first error
-
read
Reads an input without an origin or parameters.- Parameters:
input- the text of the input- Returns:
- the data read
- Throws:
IrisException- for the first errorIllegalArgumentException- if the text has an unpaired surrogate, which has no UTF-8 form
-
read
Reads an input without parameters.- Parameters:
input- the text of the inputorigin- the name of the input in errors- Returns:
- the data read
- Throws:
IrisException- for the first errorIllegalArgumentException- if the text has an unpaired surrogate, which has no UTF-8 form
-
read
Reads an input.- Parameters:
input- the text of the inputorigin- the name of the input in errorsparams- the parameters- Returns:
- the data read
- Throws:
IrisException- for the first errorIllegalArgumentException- if the text has an unpaired surrogate, which has no UTF-8 form
-
read
Reads a file without parameters. Its path is the origin of the input.- Parameters:
input- the file- Returns:
- the data read
- Throws:
IrisException- for the first errorUncheckedIOException- if the file cannot be read
-
read
Reads a file. Its path is the origin of the input.- Parameters:
input- the fileparams- the parameters- Returns:
- the data read
- Throws:
IrisException- for the first errorUncheckedIOException- if the file cannot be read
-
catalog
Lists the instances of an input without an origin or parameters (§9.6). The data has the entryinstanceswith their number,namewith their names if all have one, andfailedwith the first rejection of each if any has one.- Parameters:
input- the bytes of the input- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instance
-
catalog
Lists the instances of an input without parameters, ascatalog(byte[])says.- Parameters:
input- the bytes of the inputorigin- the name of the input in errors- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instance
-
catalog
Lists the instances of an input, ascatalog(byte[])says.- Parameters:
input- the bytes of the inputorigin- the name of the input in errorsparams- the parameters- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instance
-
catalog
Lists the instances of an input without an origin or parameters, ascatalog(byte[])says.- Parameters:
input- the text of the input- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instanceIllegalArgumentException- if the text has an unpaired surrogate, which has no UTF-8 form
-
catalog
Lists the instances of an input without parameters, ascatalog(byte[])says.- Parameters:
input- the text of the inputorigin- the name of the input in errors- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instanceIllegalArgumentException- if the text has an unpaired surrogate, which has no UTF-8 form
-
catalog
Lists the instances of an input, ascatalog(byte[])says.- Parameters:
input- the text of the inputorigin- the name of the input in errorsparams- the parameters- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instanceIllegalArgumentException- if the text has an unpaired surrogate, which has no UTF-8 form
-
catalog
Lists the instances of a file without parameters, ascatalog(byte[])says. Its path is the origin of the input.- Parameters:
input- the file- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instanceUncheckedIOException- if the file cannot be read
-
catalog
Lists the instances of a file, ascatalog(byte[])says. Its path is the origin of the input.- Parameters:
input- the fileparams- the parameters- Returns:
- the catalog
- Throws:
IrisException- for the first error that is not a rejection in an instanceUncheckedIOException- if the file cannot be read
-
reader
Makes a reader of data into records oftype, after checking every component against the entries that a read can produce, so that a mismatch fails here rather than in a read.A component reads the entry of its own name, spelled exactly as the component is, or the entry that its
Entryannotation names. Entries without a component are left out. A component's type must be what a typed handle of the entry reads:- at depth 0,
longorLongforint,doubleorDoubleforfloat,Stringforstring, andNumberfornum, whose values are int or float as the data decides; - at depth 1,
long[],double[],List<String>orList<Number>; - at each further depth, a
Listof the type one depth less, as inList<long[]>; - at any value type and depth,
Value, which an entry with no single value type and depth needs, such as a parameter without a default.
An entry that a read may leave out needs a reference type annotated
@Nullable, as in@Nullable String name, and reads as null when it is absent. JSpecify's annotation does, and so does any other namedNullablethat the class file keeps for run time.The reader constructs records through their canonical constructor, which
lookupfinds, so the record's module need not open its package. PassMethodHandles.lookup()from code that can access the constructor. A method handle can pass at most 253 parameter slots, where alongordoubletakes two, so a record whose components take 254, the most a constructor can take, is constructed throughConstructor.newInstance(Object...)as the lookup class calls it, after the checks that a method handle's lookup makes, which needs a lookup with original access, asMethodHandles.lookup()has.- Type Parameters:
R- the record type- Parameters:
type- the record classlookup- a lookup that can access the canonical constructor oftype- Returns:
- the reader
- Throws:
IllegalArgumentException- iftypeis not a record class, if a component names an entry that no read produces or has a type that does not fit its entry, iflookupcannot access the canonical constructor, or if the components take 254 parameter slots andlookuplacks original access
- at depth 0,
-