vinnie

A lightweight Java library that reads and writes "vobject" data (vCard and iCalendar).

License

License

GroupId

GroupId

com.github.mangstadt
ArtifactId

ArtifactId

vinnie
Last Version

Last Version

2.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

vinnie
A lightweight Java library that reads and writes "vobject" data (vCard and iCalendar).
Project URL

Project URL

http://github.com/mangstadt/vinnie
Project Organization

Project Organization

Michael Angstadt
Source Code Management

Source Code Management

https://github.com/mangstadt/vinnie/commits/master

Download vinnie

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mangstadt/vinnie/ -->
<dependency>
    <groupId>com.github.mangstadt</groupId>
    <artifactId>vinnie</artifactId>
    <version>2.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mangstadt/vinnie/
implementation 'com.github.mangstadt:vinnie:2.0.2'
// https://jarcasting.com/artifacts/com.github.mangstadt/vinnie/
implementation ("com.github.mangstadt:vinnie:2.0.2")
'com.github.mangstadt:vinnie:jar:2.0.2'
<dependency org="com.github.mangstadt" name="vinnie" rev="2.0.2">
  <artifact name="vinnie" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mangstadt', module='vinnie', version='2.0.2')
)
libraryDependencies += "com.github.mangstadt" % "vinnie" % "2.0.2"
[com.github.mangstadt/vinnie "2.0.2"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19

Project Modules

There are no modules declared in this project.

vinnie

Continuous Integration:
Code Coverage: codecov.io
Maven Central: Maven Central
Chat Room: Gitter
License: MIT License

vinnie is a lightweight Java library that reads and writes "vobject" data (vCard and iCalendar). It is used by the ez-vcard and biweekly projects.

Downloads | Javadocs | Maven/Gradle | Documentation

Examples

Parsing

Code

String str =
"BEGIN:VCARD\r\n" +
"VERSION:2.1\r\n" +
"FN:John Doe\r\n" +
"NOTE;QUOTED-PRINTABLE;CHARSET=UTF-8:=C2=A1Hola, mundo!\r\n" +
"END:VCARD\r\n";

Reader reader = new StringReader(str);
SyntaxRules rules = SyntaxRules.vcard();
VObjectReader vobjectReader = new VObjectReader(reader, rules);
vobjectReader.parse(new VObjectDataAdapter() {
	private boolean inVCard = false;

	public void onComponentBegin(String name, Context context) {
		if (context.getParentComponents().isEmpty() && "VCARD".equals(name)){
			inVCard = true;
		}
	}

	public void onComponentEnd(String name, Context context) {
		if (context.getParentComponents().isEmpty()) {
			//end of vCard, stop parsing
			context.stop();
		}
	}

	public void onProperty(VObjectProperty property, Context context) {
		if (inVCard) {
			System.out.println(property.getName() + " = " + property.getValue());
		}
	}
});
vobjectReader.close();

Output

FN = John Doe
NOTE = ¡Hola, mundo!

Writing

Code

Writer writer = new OutputStreamWriter(System.out);
VObjectWriter vobjectWriter = new VObjectWriter(writer, SyntaxStyle.OLD);

vobjectWriter.writeBeginComponent("VCARD");
vobjectWriter.writeVersion("2.1");
vobjectWriter.writeProperty("FN", "John Doe");

VObjectProperty note = new VObjectProperty("NOTE", "¡Hola, mundo!");
note.getParameters().put(null, "QUOTED-PRINTABLE");
vobjectWriter.writeProperty(note);

vobjectWriter.writeEndComponent("VCARD");
vobjectWriter.close();

Output

BEGIN:VCARD
VERSION:2.1
FN:John Doe
NOTE;QUOTED-PRINTABLE;CHARSET=UTF-8:=C2=A1Hola, mundo!
END:VCARD

Features

  • Full ABNF compliance with vCard (versions 2.1, 3.0, and 4.0) and iCalendar (versions 1.0 and 2.0) specifications.
  • Automatic decoding/encoding of quoted-printable data.
  • Streaming API.
  • Extensive unit test coverage.
  • Low Java version requirement (1.5 or above).
  • No dependencies on external libraries.

Maven/Gradle

Maven

<dependency>
   <groupId>com.github.mangstadt</groupId>
   <artifactId>vinnie</artifactId>
   <version>2.0.2</version>
</dependency>

Gradle

compile 'com.github.mangstadt:vinnie:2.0.2'

Build Instructions

vinnie uses Maven as its build tool, and adheres to its conventions.

To build the project: mvn compile
To run the unit tests: mvn test
To build a JAR: mvn package

Questions / Feedback

You have some options:

Versions

Version
2.0.2
2.0.1
2.0.0
1.0.1
1.0.0