Skip to content

Commit b297fca

Browse files
committed
javadoc and format
1 parent 27e00dd commit b297fca

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

datalog/src/main/java/org/wpilib/datalog/DataLogReader.java

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ public boolean isValid() {
6767
/**
6868
* Gets the data log version. Returns 0 if data log is invalid.
6969
*
70-
* @return Version number; most significant byte is major, least significant is
71-
* minor (so version
72-
* 1.0 will be 0x0100)
70+
* @return Version number; most significant byte is major, least significant is minor (so version
71+
* 1.0 will be 0x0100)
7372
*/
7473
public short getVersion() {
7574
if (m_buf.remaining() < 12) {
@@ -138,16 +137,16 @@ DataLogRecord getRecord(int pos) {
138137
if (record.isStart()) {
139138
StartRecordData startData = record.getStartData();
140139
boolean isNew = m_entriesByName.containsKey(startData.name);
141-
DataLogReaderEntry readerEntry = new DataLogReaderEntry(entry, startData.name,
142-
startData.type, startData.metadata);
140+
DataLogReaderEntry readerEntry =
141+
new DataLogReaderEntry(entry, startData.name, startData.type, startData.metadata);
143142
if (isNew) {
144-
readerEntry.m_ranges.add(new DataLogReaderRange(new DataLogIterator(this, pos),
145-
new DataLogIterator(this, pos + m_buf.remaining())));
143+
readerEntry.m_ranges.add(
144+
new DataLogReaderRange(
145+
new DataLogIterator(this, pos),
146+
new DataLogIterator(this, pos + m_buf.remaining())));
146147
}
147148
m_entriesByName.put(startData.name, readerEntry);
148-
m_entriesById.put(
149-
entry,
150-
readerEntry);
149+
m_entriesById.put(entry, readerEntry);
151150
} else if (record.isFinish()) {
152151
// update range
153152
List<DataLogReaderRange> ranges = m_entriesById.get(record.getEntry()).m_ranges;
@@ -183,10 +182,22 @@ int size() {
183182
return m_buf.remaining();
184183
}
185184

185+
/**
186+
* Fetches the entry with the given id.
187+
*
188+
* @param entry Id number of the desired entry, which is associated with all of its records.
189+
* @return The DataLogReaderEntry associated with that entry id.
190+
*/
186191
DataLogReaderEntry getEntry(int entry) {
187192
return m_entriesById.get(entry);
188193
}
189194

195+
/**
196+
* Fetches the entry with the given name.
197+
*
198+
* @param name Name string of an entry.
199+
* @return The DataLogReaderEntry associated with that name.
200+
*/
190201
DataLogReaderEntry getEntry(String name) {
191202
return m_entriesByName.get(name);
192203
}
@@ -195,9 +206,18 @@ DataLogReaderEntry getEntry(String name) {
195206
private HashMap<Integer, DataLogReaderEntry> m_entriesById;
196207
private HashMap<String, DataLogReaderEntry> m_entriesByName;
197208

209+
/**
210+
* DataLogReader Entry class, which associates an entry's ID with its name, type, and metadata in
211+
* a persistent way.
212+
*/
198213
public static class DataLogReaderEntry extends StartRecordData {
199214
private final List<DataLogReaderRange> m_ranges;
200215

216+
/**
217+
* Returns the list of ranges for which this entry is valid
218+
*
219+
* @return List of DataLogReaderRange for which this entry is valid
220+
*/
201221
public List<DataLogReaderRange> getRanges() {
202222
return m_ranges;
203223
}
@@ -208,6 +228,6 @@ public DataLogReaderEntry(int entry, String name, String type, String metadata)
208228
}
209229
}
210230

211-
public record DataLogReaderRange(DataLogIterator begin, DataLogIterator end) {
212-
}
231+
/** Range of records during which an entry is valid. */
232+
public record DataLogReaderRange(DataLogIterator begin, DataLogIterator end) {}
213233
}

0 commit comments

Comments
 (0)