Refactor code
1) introduce VCardProperty and make use of it everywhere
Previously we had had two structures for it:
VCardParserImpl_V21.PropertyData and VCardEntry#Property.
The former was for holding raw data for property, while
the latter was for holding resultant (encoded) values.
Apparently we can share same structure.
To do so, we need to let VCardInterpreter pass the
structure to interpreter side, instead of splitting them
into smaller pieces by using several propertyXXX() calls.
Thus this change introduces onPropertyCreated(VCardProperty)
in lieu of propertyXXX().
Now vCard parser side is responsible for encoding
Quoted-Printable, BASE64, and several charsets.
Users are still able to do them manually by using
VCardEntry#getRawValue().
2) add better handling for data inside VCardEntry
Now VCardEntry has so many fields that it is harder to
iterate those data, while the iteration itself is common
use case for it. At least three functionalities are
now using iteration: toString(), isEmpty(), and
constructInsertOperations().
This change introduces inner iterator functionality.
VCardEntry.EntryElementIterator allows users to implement
their own iteration logic.
VCardEntry#iterateAllData(VCardEntry.EntryElementIterator)
iterates all data inside VCardEntry and pass them into
the inner iterator.
3) make VCardParser abstract class
VCardParser should provide some utility functionality like
VCardParser#getInstance(), while currently users have to
choose one of inherited classes like VCardParser_V21, which
is hindering encapsulation.
Currently no external library implements VCardParser,
so this change isn't so harmful.
Bug: 4167593
Bug: 4066223
Change-Id: Ic6bb453cf733cf1de356789b36dd90521dceff56
24 files changed