-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
240 additions
and
3 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
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
47 changes: 47 additions & 0 deletions
47
ph-diver-repo/src/main/java/com/helger/diver/repo/toptoc/RepoTopToc1Marshaller.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,47 @@ | ||
/* | ||
* Copyright (C) 2023 Philip Helger & ecosio | ||
* philip[at]helger[dot]com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.helger.diver.repo.toptoc; | ||
|
||
import com.helger.commons.collection.impl.CommonsArrayList; | ||
import com.helger.commons.io.resource.ClassPathResource; | ||
import com.helger.diver.repo.toptoc.jaxb.v10.ObjectFactory; | ||
import com.helger.diver.repo.toptoc.jaxb.v10.RepoTopTocType; | ||
import com.helger.jaxb.GenericJAXBMarshaller; | ||
|
||
/** | ||
* JAXB marshaller for {@link RepoTopTocType} objects. | ||
* | ||
* @author Philip Helger | ||
*/ | ||
public class RepoTopToc1Marshaller extends GenericJAXBMarshaller <RepoTopTocType> | ||
{ | ||
/** | ||
* The namespace URI of the RepoToc1 XML data model | ||
*/ | ||
public static final String NAMESPACE_URI = "urn:com:helger:diver:repotoptoc:v1.0"; | ||
|
||
/** | ||
* The XML Schema path to validate against. | ||
*/ | ||
public static final ClassPathResource XSD_RES = new ClassPathResource ("schemas/repotoptoc-1.0.xsd", | ||
RepoTopToc1Marshaller.class.getClassLoader ()); | ||
|
||
public RepoTopToc1Marshaller () | ||
{ | ||
super (RepoTopTocType.class, new CommonsArrayList <> (XSD_RES), new ObjectFactory ()::createRepotoptoc); | ||
} | ||
} |
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
File renamed without changes.
88 changes: 88 additions & 0 deletions
88
ph-diver-repo/src/main/resources/schemas/repotoptoc-1.0.xsd
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,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2023 Philip Helger & ecosio | ||
philip[at]helger[dot]com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns="urn:com:helger:diver:repotoptoc:v1.0" | ||
targetNamespace="urn:com:helger:diver:repotoptoc:v1.0" | ||
elementFormDefault="qualified" | ||
attributeFormDefault="unqualified" | ||
version="1.0"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
This XML Schema is used to describe a single Diver Repository top-level Table of Contents for all groups and artifacts. | ||
|
||
Version: 2023-11-28 | ||
</xs:documentation> | ||
</xs:annotation> | ||
|
||
<xs:complexType name="ArtifactType"> | ||
<xs:sequence> | ||
<!-- empty --> | ||
</xs:sequence> | ||
<xs:attribute name="name" type="xs:normalizedString" use="required"> | ||
<xs:annotation> | ||
<xs:documentation>The name of the artifact</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="GroupType"> | ||
<xs:sequence> | ||
<!-- Recursive type! --> | ||
<xs:element name="group" type="GroupType" minOccurs="0" maxOccurs="unbounded"> | ||
<xs:annotation> | ||
<xs:documentation>Nested child groups</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
<xs:element name="artifact" type="ArtifactType" minOccurs="0" maxOccurs="unbounded"> | ||
<xs:annotation> | ||
<xs:documentation>All the artifact names of this group</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="name" type="xs:normalizedString" use="required"> | ||
<xs:annotation> | ||
<xs:documentation>The name of the group</xs:documentation> | ||
</xs:annotation> | ||
</xs:attribute> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="RepoTopTocType"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
Top-level element may only contain groups but no artifacts. | ||
</xs:documentation> | ||
</xs:annotation> | ||
<xs:sequence> | ||
<xs:element name="group" type="GroupType" minOccurs="0" maxOccurs="unbounded"> | ||
<xs:annotation> | ||
<xs:documentation>All top level groups</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<xs:element name="repotoptoc" type="RepoTopTocType"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
The root element of the Repository top-level Table of Contents of all groups and artifacts. | ||
</xs:documentation> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:schema> |
59 changes: 59 additions & 0 deletions
59
ph-diver-repo/src/test/java/com/helger/diver/repo/toptoc/RepoTopToc1MarshallerTest.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,59 @@ | ||
/* | ||
* Copyright (C) 2023 Philip Helger & ecosio | ||
* philip[at]helger[dot]com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.helger.diver.repo.toptoc; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.junit.Test; | ||
|
||
import com.helger.commons.io.resource.ClassPathResource; | ||
import com.helger.diver.repo.toptoc.jaxb.v10.GroupType; | ||
import com.helger.diver.repo.toptoc.jaxb.v10.RepoTopTocType; | ||
|
||
/** | ||
* Test class for class {@link RepoTopToc1Marshaller}. | ||
* | ||
* @author Philip Helger | ||
*/ | ||
public final class RepoTopToc1MarshallerTest | ||
{ | ||
@Test | ||
public void testRepoToc1 () | ||
{ | ||
final RepoTopToc1Marshaller m = new RepoTopToc1Marshaller (); | ||
final RepoTopTocType aRepoTopToc1 = m.read (new ClassPathResource ("repotoptoc/repotoptoc-1.xml")); | ||
assertNotNull (aRepoTopToc1); | ||
|
||
assertEquals (2, aRepoTopToc1.getGroupCount ()); | ||
assertEquals ("com", aRepoTopToc1.getGroupAtIndex (0).getName ()); | ||
assertEquals ("org", aRepoTopToc1.getGroupAtIndex (1).getName ()); | ||
|
||
final GroupType aCom = aRepoTopToc1.getGroupAtIndex (0); | ||
assertEquals (3, aCom.getGroupCount ()); | ||
assertEquals ("ecosio", aCom.getGroupAtIndex (0).getName ()); | ||
assertEquals ("helger", aCom.getGroupAtIndex (1).getName ()); | ||
assertEquals ("rest", aCom.getGroupAtIndex (2).getName ()); | ||
|
||
assertEquals (0, aCom.getGroupAtIndex (0).getGroupCount ()); | ||
assertEquals (2, aCom.getGroupAtIndex (0).getArtifactCount ()); | ||
assertEquals (0, aCom.getGroupAtIndex (1).getGroupCount ()); | ||
assertEquals (1, aCom.getGroupAtIndex (1).getArtifactCount ()); | ||
assertEquals (0, aCom.getGroupAtIndex (2).getGroupCount ()); | ||
assertEquals (0, aCom.getGroupAtIndex (2).getArtifactCount ()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
ph-diver-repo/src/test/resources/repotoptoc/repotoptoc-1.xml
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,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2023 Philip Helger & ecosio | ||
philip[at]helger[dot]com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<repotoptoc xmlns="urn:com:helger:diver:repotoptoc:v1.0"> | ||
<group name="com"> | ||
<group name="ecosio"> | ||
<artifact name="artifact1" /> | ||
<artifact name="artifact2" /> | ||
</group> | ||
<group name="helger"> | ||
<artifact name="artifact3" /> | ||
</group> | ||
<group name="rest"> | ||
<!-- empty --> | ||
</group> | ||
</group> | ||
<group name="org"> | ||
<group name="example"> | ||
<artifact name="artifact4" /> | ||
</group> | ||
</group> | ||
</repotoptoc> |