Skip to content

Commit

Permalink
Merge pull request #9 from ical4j/develop
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
benfortuna committed Nov 11, 2021
2 parents 6a59867 + 1c9dd8d commit f14ab6d
Show file tree
Hide file tree
Showing 118 changed files with 817 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ical4j-json.iml
ical4j-serializer.iml
.idea
.gradle
build
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# iCal4j Javascript Object Notation
# iCal4j Serializer

[jCal]: https://tools.ietf.org/html/rfc7265
[xCal]: https://www.rfc-editor.org/rfc/rfc6321.html
[JSCalendar]: https://datatracker.ietf.org/doc/html/rfc8984
[jCard]: https://tools.ietf.org/html/rfc7095
[JSCard]: https://datatracker.ietf.org/doc/html/draft-ietf-jmap-jscontact
[Schema.org]: https://schema.org/
[JSON-LD]: https://json-ld.org/
[Jot API]: https://github.com/micronode/jotapi
[CalDAV]: https://tools.ietf.org/html/rfc4791
[JSON Feed]: https://www.jsonfeed.org/version/1.1/

The purpose of this library is to provide custom marshalling between iCal4j objects and JSON formats.
The purpose of this library is to provide custom marshalling between iCal4j objects and other formats.

## Overview

Interoperability is a very important aspect of the iCalendar specification(s), and as such it is important
to support seamless and accurate translation between different data formats. JSON is currently the de-facto
standard for structural data formats, and as such this library aims to provide a mechanism for conversion
between iCalendar objects and JSON formats.
to support seamless and accurate translation between different data formats. There are many alternate formats
using JSON and XML, and as such this library aims to provide a mechanism for conversion
between iCalendar objects and other popular JSON and XML-based formats.

The following JSON calendar formats are the current focus of this library.
The following calendar formats are the current focus of this library.

### jCal - The JSON Format for iCalendar

Expand All @@ -29,6 +31,10 @@ when translating between iCalendar objects and this JSON format.
This format is a good choice when unambiguous interoperability is required, as in theory if an agent supports
the iCalendar specification then it should be reasonably trivial to have equivalent support for this format.

### xCal - The XML Format for iCalendar

TBD.

### JSCalendar - A JSON representation of calendar data

[JSCalendar] is a relatively new format
Expand All @@ -55,6 +61,11 @@ object model. [jCard] provides a specification for converting JSON to/from vCard
[Schema.org] presents a collection of collaborative data models to represent data on the Web. This includes
data representations in [JSON-LD] format, which is included here.

### JSON Feed - a format similar to RSS and Atom but in JSON

[JSON Feed] is a pragmatic syndication format, like RSS and Atom, but with one big difference:
it’s JSON instead of XML.


### Jot API - An open REST API based on the iCalendar specification

Expand Down Expand Up @@ -96,7 +107,7 @@ String serialized = mapper.writeValueAsString(calendar);
Result:

```
["vcalendar",[["prodid",{},"text","-//Ben Fortuna//iCal4j 1.0//EN"],["version",{},"text","2.0"],["uid",{},"text","123"]],[["vevent",[["uid",{},"text","1"],["summary",{},"text","Test Event 1"],["dtstart",{"value":"date"},"date","20090810"],["action",{},"text","DISPLAY"],["attach",{"encoding":"base64","value":"binary"},"binary","..."]],[]],["vevent",[["uid",{},"text","2"],["summary",{},"text","Test Event 2"],["dtstart",{"value":"date"},"date","20100810"]],[]]]]
["vcalendar",[["prodid",{},"text","-//Ben Fortuna//iCal4j 3.1//EN"],["version",{},"text","2.0"],["uid",{},"text","123"]],[["vevent",[["uid",{},"text","1"],["summary",{},"text","Test Event 1"],["dtstart",{"value":"date"},"date","20090810"],["action",{},"text","DISPLAY"],["attach",{"encoding":"base64","value":"binary"},"binary","..."]],[]],["vevent",[["uid",{},"text","2"],["summary",{},"text","Test Event 2"],["dtstart",{"value":"date"},"date","20100810"]],[]]]]
```


Expand Down Expand Up @@ -151,6 +162,7 @@ Calendar calendar = mapper.readValue(json, Calendar.class);
* [RFC7953](https://datatracker.ietf.org/doc/html/rfc7953) (iCalendar Availability)
* [RFC6350](https://datatracker.ietf.org/doc/html/rfc6350) (vCard)
* [RFC7265](https://tools.ietf.org/html/rfc7265) (jCal)
* [RFC6321](https://www.rfc-editor.org/rfc/rfc6321.html) (xCal)
* [RFC7095](https://tools.ietf.org/html/rfc7095) (jCard)
* [RFC8984](https://datatracker.ietf.org/doc/html/rfc8984) (JSCalendar)
* [JSCalendar to iCalendar Draft](https://datatracker.ietf.org/doc/html/draft-ietf-calext-jscalendar-icalendar-05)
Expand Down
4 changes: 2 additions & 2 deletions bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Export-Package: org.mnode.ical4j.json
Automatic-Module-Name: org.mnode.ical4j.json
Export-Package: org.mnode.ical4j.serializer
Automatic-Module-Name: org.mnode.ical4j.serializer
Bundle-License: https://raw.githubusercontent.com/ical4j/ical4j/master/LICENSE.txt
26 changes: 18 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ targetCompatibility = 1.8
dependencies {
api "org.mnode.ical4j:ical4j:$ical4jVersion",
"org.mnode.ical4j:ical4j-vcard:$ical4jVCardVersion",
"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion"

testCompile "org.codehaus.groovy:groovy:$groovyVersion"

testImplementation platform("org.spockframework:spock-bom:2.0-M4-groovy-3.0"),
testImplementation platform("org.spockframework:spock-bom:$spockVersion"),
"org.spockframework:spock-core",
"org.slf4j:slf4j-log4j12:$slf4jVersion"
}
Expand All @@ -34,9 +35,10 @@ test {
javadoc {
options {
links 'https://docs.oracle.com/en/java/javase/11/docs/api/',
'http://ical4j.github.io/docs/ical4j/api/4.0.0-alpha6/',
'http://fasterxml.github.io/jackson-core/javadoc/2.12/',
'http://fasterxml.github.io/jackson-databind/javadoc/2.12/'
'http://ical4j.github.io/docs/ical4j/api/3.1.0/',
'http://fasterxml.github.io/jackson-core/javadoc/2.13/',
'http://fasterxml.github.io/jackson-databind/javadoc/2.13/',
'http://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.13/'
}
}

Expand All @@ -55,6 +57,14 @@ artifacts {
archives sourcesJar
}

scmVersion {
tag {
prefix = 'ical4j-serializer-'
}
versionCreator 'versionWithBranch'
branchVersionCreator = ['main': 'simple']
}

group = 'org.mnode.ical4j'
description = 'Custom marshalling between iCal4j objects and JSON formats'
version = scmVersion.version
Expand All @@ -75,9 +85,9 @@ publishing {
asNode().appendNode('url', 'http://ical4j.github.io')

def scmNode = asNode().appendNode('scm')
scmNode.appendNode('url', 'https://github.com/ical4j/ical4j-json')
scmNode.appendNode('connection', 'scm:[email protected]:ical4j/ical4j-json.git')
scmNode.appendNode('developerConnection', 'scm:[email protected]:ical4j/ical4j-json.git')
scmNode.appendNode('url', 'https://github.com/ical4j/ical4j-serializer')
scmNode.appendNode('connection', 'scm:[email protected]:ical4j/ical4j-serializer.git')
scmNode.appendNode('developerConnection', 'scm:[email protected]:ical4j/ical4j-serializer.git')

def licenseNode = asNode().appendNode('licenses').appendNode('license')
licenseNode.appendNode('name', 'iCal4j - License')
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ical4jVersion = 3.1.1
ical4jVCardVersion = 1.0.6
jacksonVersion = 2.12.1
groovyVersion = 3.0.7
slf4jVersion = 1.7.30
jacksonVersion = 2.13.0
groovyVersion = 3.0.8
slf4jVersion = 1.7.32
spockVersion = 2.0-groovy-3.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import net.fortuna.ical4j.model.ZoneOffsetAdapter;
import org.apache.commons.codec.StringDecoder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import org.apache.commons.codec.StringEncoder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import com.fasterxml.jackson.databind.node.ObjectNode;
import net.fortuna.ical4j.model.Property;
Expand All @@ -12,6 +12,13 @@ default ObjectNode putIfNotNull(String propertyName, ObjectNode node, Property p
return node;
}

// default ObjectNode putIfNotNull(String propertyName, ObjectNode node, DateProperty property) {
// if (property != null) {
// node.put(propertyName, property.getValue());
// }
// return node;
// }

default ObjectNode putIfNotNull(String propertyName, ObjectNode node, net.fortuna.ical4j.vcard.Property property) {
if (property != null) {
node.put(propertyName, property.getValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mnode.ical4j.json;
package org.mnode.ical4j.serializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
Expand All @@ -9,31 +9,37 @@ public interface JsonMapper {

default void assertNextToken(JsonParser p, JsonToken token) throws IOException {
if (!token.equals(p.nextToken())) {
throw new IllegalArgumentException("Invalid input");
throw new IllegalArgumentException(String.format("Invalid input: %s", p.currentToken()));
}
}

default void assertCurrentToken(JsonParser p, JsonToken token) {
if (!token.equals(p.currentToken())) {
throw new IllegalArgumentException("Invalid input");
throw new IllegalArgumentException(String.format("Invalid input: %s", p.currentToken()));
}
}

default void assertNextScalarValue(JsonParser p) throws IOException {
if (!p.nextToken().isScalarValue()) {
throw new IllegalArgumentException("Invalid input");
throw new IllegalArgumentException("Invalid input: non-scalar value");
}
}

default void assertCurrentScalarValue(JsonParser p) throws IOException {
if (!p.currentToken().isScalarValue()) {
throw new IllegalArgumentException("Invalid input");
throw new IllegalArgumentException("Invalid input: non-scalar value");
}
}

default void assertTextValue(JsonParser p, String value) throws IOException {
if (!value.equals(p.nextTextValue())) {
throw new IllegalArgumentException("Invalid input");
throw new IllegalArgumentException(String.format("Invalid input: %s", p.currentValue()));
}
}

default void assertNextName(JsonParser p, String value) throws IOException {
if (!value.equals(p.nextFieldName())) {
throw new IllegalArgumentException(String.format("Invalid input: %s", p.currentName()));
}
}

Expand Down
Loading

0 comments on commit f14ab6d

Please sign in to comment.