Class ANVLRecord
java.lang.Object
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<Element>, Collection<Element>, Deque<Element>, List<Element>, Queue<Element>, UTF8Bytes
- Author:
- stack
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringAn ANVL 'newline'.static final ANVLRecordprotected static final Stringstatic final longArbitrary upper bound on maximum size of ANVL Record.static final StringFields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddLabelValue(String l, String v) asMap()clone()intbyte[]static booleanisCR(char c) static booleanisCROrLF(char c) static booleanisLF(char c) static ANVLRecordload(InputStream is) Parses a single ANVLRecord from passed InputStream.static ANVLRecordParse passed String for an ANVL Record.toString()Methods inherited from class LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, spliterator, toArray, toArrayMethods inherited from class AbstractSequentialList
iteratorMethods inherited from class AbstractList
equals, hashCode, listIterator, removeRange, subListMethods inherited from class AbstractCollection
containsAll, isEmpty, removeAll, retainAllMethods inherited from interface Collection
parallelStream, removeIf, streamMethods inherited from interface List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, replaceAll, retainAll, sort, subList
-
Field Details
-
MIMETYPE
- See Also:
-
EMPTY_ANVL_RECORD
-
MAXIMUM_SIZE
public static final long MAXIMUM_SIZEArbitrary upper bound on maximum size of ANVL Record. Will throw an IOException if exceed this size.- See Also:
-
CRLF
-
FOLD_PREFIX
- See Also:
-
-
Constructor Details
-
ANVLRecord
public ANVLRecord() -
ANVLRecord
-
-
Method Details
-
addLabel
-
addLabelValue
-
toString
- Overrides:
toStringin classAbstractCollection<Element>
-
asMap
-
clone
- Overrides:
clonein classLinkedList<Element>
-
getUTF8Bytes
- Specified by:
getUTF8Bytesin interfaceUTF8Bytes- Returns:
- This ANVLRecord as UTF8 bytes.
- Throws:
UnsupportedEncodingException
-
load
Parses a single ANVLRecord from passed InputStream. Read as a single-byte stream until we get to a CRLFCRLF which signifies End-of-ANVLRecord. Then parse all read as a UTF-8 Stream. Doing it this way, while requiring a double-scan, it makes it so do not need to be passed a RepositionableStream or a Stream that supports marking. Also no danger of over-reading which can happen when we wrap passed Stream with an InputStreamReader for doing UTF-8 character conversion (See the ISR class comment).- Parameters:
is- InputStream- Returns:
- An ANVLRecord instance.
- Throws:
IOException
-
load
Parse passed String for an ANVL Record. Looked at writing javacc grammer but preprocessing is required to handle folding: See here. Looked at Terence Parr's ANTLR. More capable. Can set lookahead count. A value of 3 would help with folding. But its a pain defining UNICODE grammers -- needed by ANVL -- and support seems incomplete anyways: http://www.doc.ic.ac.uk/lab/secondyear/Antlr/lexer.html#unicode. For now, go with the below hand-rolled parser.- Parameters:
s- String with an ANVLRecord.- Returns:
- ANVLRecord parsed from passed String.
- Throws:
IOException
-
getLength
public int getLength()- Returns:
- Count of ANVLRecord bytes. Be careful, an empty ANVLRecord is CRLFCRLF so is of size 4. Also, expensive, since it makes String of the record so it can count bytes.
-
isCROrLF
public static boolean isCROrLF(char c) -
isCR
public static boolean isCR(char c) -
isLF
public static boolean isLF(char c)
-