Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial support for new components from draft eventpub specific…
…ation
- Loading branch information
1 parent
cf7a29f
commit 50f0456
Showing
14 changed files
with
424 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/groovy/net/fortuna/ical4j/model/component/ParticipantFactory.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) 2012, Ben Fortuna | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* o Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* o Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* o Neither the name of Ben Fortuna nor the names of any other contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package net.fortuna.ical4j.model.component | ||
|
||
import net.fortuna.ical4j.model.PropertyList | ||
|
||
class ParticipantFactory extends AbstractComponentFactory{ | ||
|
||
Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { | ||
Participant participant | ||
if (FactoryBuilderSupport.checkValueIsType(value, name, Participant)) { | ||
participant = (Participant) value | ||
} | ||
else { | ||
participant = (Participant) super.newInstance(builder, name, value, attributes) | ||
} | ||
return participant | ||
} | ||
|
||
protected Object newInstance(PropertyList properties) { | ||
return new Participant(properties) | ||
} | ||
|
||
void setChild(FactoryBuilderSupport build, Object parent, Object child) { | ||
if (child instanceof VLocation) { | ||
parent.locations.add child | ||
} else if (child instanceof VResource) { | ||
parent.resources.add child | ||
} else { | ||
super.setChild(build, parent, child) | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/groovy/net/fortuna/ical4j/model/component/VLocationFactory.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2012, Ben Fortuna | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* o Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* o Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* o Neither the name of Ben Fortuna nor the names of any other contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package net.fortuna.ical4j.model.component | ||
|
||
import net.fortuna.ical4j.model.PropertyList | ||
|
||
class VLocationFactory extends AbstractComponentFactory{ | ||
|
||
Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) | ||
throws InstantiationException, IllegalAccessException { | ||
|
||
VLocation location | ||
if (FactoryBuilderSupport.checkValueIsType(value, name, VLocation)) { | ||
location = (VLocation) value | ||
} else { | ||
location = (VLocation) super.newInstance(builder, name, value, attributes) | ||
} | ||
return location | ||
} | ||
|
||
protected Object newInstance(PropertyList properties) { | ||
return new VLocation(properties) | ||
} | ||
} | ||
|
53 changes: 53 additions & 0 deletions
53
src/main/groovy/net/fortuna/ical4j/model/component/VResourceFactory.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright (c) 2012, Ben Fortuna | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* o Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* o Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* o Neither the name of Ben Fortuna nor the names of any other contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package net.fortuna.ical4j.model.component | ||
|
||
import net.fortuna.ical4j.model.PropertyList | ||
|
||
class VResourceFactory extends AbstractComponentFactory{ | ||
|
||
Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) | ||
throws InstantiationException, IllegalAccessException { | ||
|
||
VResource resource | ||
if (FactoryBuilderSupport.checkValueIsType(value, name, VResource)) { | ||
resource = (VResource) value | ||
} else { | ||
resource = (VResource) super.newInstance(builder, name, value, attributes) | ||
} | ||
return resource | ||
} | ||
|
||
protected Object newInstance(PropertyList properties) { | ||
return new VResource(properties) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/net/fortuna/ical4j/model/component/Participant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package net.fortuna.ical4j.model.component; | ||
|
||
import net.fortuna.ical4j.model.*; | ||
import net.fortuna.ical4j.util.Strings; | ||
import net.fortuna.ical4j.validate.ValidationException; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public class Participant extends Component { | ||
|
||
private final ComponentList<VLocation> locations; | ||
|
||
private final ComponentList<VResource> resources; | ||
|
||
public Participant() { | ||
this(new PropertyList<>()); | ||
} | ||
|
||
public Participant(PropertyList<Property> p) { | ||
super(PARTICIPANT, p); | ||
this.locations = new ComponentList<>(); | ||
this.resources = new ComponentList<>(); | ||
} | ||
|
||
public Participant(PropertyList<Property> p, final ComponentList<Component> subComponents) { | ||
super(PARTICIPANT, p); | ||
this.locations = new ComponentList<>(subComponents.stream() | ||
.filter(c -> c.getName().equals(VLOCATION)).map(c -> (VLocation) c) | ||
.collect(Collectors.toList())); | ||
this.resources = new ComponentList<>(subComponents.stream() | ||
.filter(c -> c.getName().equals(VRESOURCE)).map(c -> (VResource) c) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
public ComponentList<VLocation> getLocations() { | ||
return locations; | ||
} | ||
|
||
public ComponentList<VResource> getResources() { | ||
return resources; | ||
} | ||
|
||
@Override | ||
public void validate(boolean recurse) throws ValidationException { | ||
|
||
} | ||
|
||
@Override | ||
public final String toString() { | ||
return BEGIN + ':' + getName() + Strings.LINE_SEPARATOR + | ||
getProperties() + | ||
getLocations() + | ||
getResources() + | ||
END + ':' + getName() + Strings.LINE_SEPARATOR; | ||
} | ||
|
||
public static class Factory extends Content.Factory implements ComponentFactory<Participant> { | ||
|
||
public Factory() { | ||
super(PARTICIPANT); | ||
} | ||
|
||
@Override | ||
public Participant createComponent() { | ||
return new Participant(); | ||
} | ||
|
||
@Override | ||
public Participant createComponent(PropertyList<Property> properties) { | ||
return new Participant(properties); | ||
} | ||
|
||
@Override | ||
public Participant createComponent(PropertyList<Property> properties, ComponentList<Component> subComponents) { | ||
return new Participant(properties, subComponents); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/net/fortuna/ical4j/model/component/VLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.fortuna.ical4j.model.component; | ||
|
||
import net.fortuna.ical4j.model.*; | ||
import net.fortuna.ical4j.validate.ValidationException; | ||
|
||
public class VLocation extends Component { | ||
|
||
public VLocation() { | ||
super(VLOCATION); | ||
} | ||
|
||
public VLocation(PropertyList<Property> p) { | ||
super(VLOCATION, p); | ||
} | ||
|
||
@Override | ||
public void validate(boolean recurse) throws ValidationException { | ||
|
||
} | ||
|
||
public static class Factory extends Content.Factory implements ComponentFactory<VLocation> { | ||
|
||
public Factory() { | ||
super(VLOCATION); | ||
} | ||
|
||
@Override | ||
public VLocation createComponent() { | ||
return new VLocation(); | ||
} | ||
|
||
@Override | ||
public VLocation createComponent(PropertyList<Property> properties) { | ||
return new VLocation(properties); | ||
} | ||
|
||
@Override | ||
public VLocation createComponent(PropertyList<Property> properties, ComponentList<Component> subComponents) { | ||
throw new UnsupportedOperationException(String.format("%s does not support sub-components", VLOCATION)); | ||
} | ||
} | ||
} |
Oops, something went wrong.