Search in sources :

Example 1 with StreamReader

use of ezvcard.io.StreamReader in project ez-vcard by mangstadt.

the class XCardDocumentTest method readXml.

private static VCardAsserter readXml(String xml) throws SAXException {
    XCardDocument xcard = new XCardDocument(xml);
    StreamReader reader = xcard.reader();
    return new VCardAsserter(reader);
}
Also used : StreamReader(ezvcard.io.StreamReader) InputStreamReader(java.io.InputStreamReader) VCardAsserter(ezvcard.property.asserter.VCardAsserter)

Example 2 with StreamReader

use of ezvcard.io.StreamReader in project ez-vcard by mangstadt.

the class XCardDocumentTest method readFile.

private static VCardAsserter readFile(String file) throws SAXException, IOException {
    XCardDocument document = new XCardDocument(XCardDocumentTest.class.getResourceAsStream(file));
    StreamReader reader = document.reader();
    return new VCardAsserter(reader);
}
Also used : StreamReader(ezvcard.io.StreamReader) InputStreamReader(java.io.InputStreamReader) VCardAsserter(ezvcard.property.asserter.VCardAsserter)

Example 3 with StreamReader

use of ezvcard.io.StreamReader in project ez-vcard by mangstadt.

the class ChainingParser method all.

/**
 * Reads all vCards from the stream.
 * @return the parsed vCards
 * @throws IOException if there's an I/O problem
 */
public List<VCard> all() throws IOException {
    StreamReader reader = constructReader();
    if (index != null) {
        reader.setScribeIndex(index);
    }
    try {
        List<VCard> vcards = new ArrayList<VCard>();
        VCard vcard;
        while ((vcard = reader.readNext()) != null) {
            if (warnings != null) {
                warnings.add(reader.getWarnings());
            }
            vcards.add(vcard);
        }
        return vcards;
    } finally {
        if (closeWhenDone()) {
            reader.close();
        }
    }
}
Also used : StreamReader(ezvcard.io.StreamReader) ArrayList(java.util.ArrayList) VCard(ezvcard.VCard)

Aggregations

StreamReader (ezvcard.io.StreamReader)3 VCardAsserter (ezvcard.property.asserter.VCardAsserter)2 InputStreamReader (java.io.InputStreamReader)2 VCard (ezvcard.VCard)1 ArrayList (java.util.ArrayList)1