This is an automated email from the ASF dual-hosted git repository.
hasan pushed a commit to branch CLEREZZA-1068-schemagen
in repository https://gitbox.apache.org/repos/asf/clerezza.git
The following commit(s) were added to refs/heads/CLEREZZA-1068-schemagen by
this push:
new 4df32e1 CLEREZZA-1068: Reformat codes
4df32e1 is described below
commit 4df32e107ed4ea3eb9e46bc13b931b7d96355858
Author: Hasan <[email protected]>
AuthorDate: Thu Jul 8 08:06:20 2021 +0200
CLEREZZA-1068: Reformat codes
---
schemagen/main/LICENSE | 201 -----------
schemagen/main/pom.xml | 43 ++-
schemagen/main/src/assembly/dist.xml | 82 +++--
.../org/apache/clerezza/schemagen/SchemaGen.java | 396 ++++++++++-----------
.../clerezza/schemagen/SchemaGenArguments.java | 36 +-
schemagen/maven-plugin/LICENSE | 201 -----------
schemagen/maven-plugin/pom.xml | 48 ++-
.../OntologyJavaClassCreatorMojo.java | 119 +++----
8 files changed, 356 insertions(+), 770 deletions(-)
diff --git a/schemagen/main/LICENSE b/schemagen/main/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/schemagen/main/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
diff --git a/schemagen/main/pom.xml b/schemagen/main/pom.xml
index f2695a6..1d2c68d 100644
--- a/schemagen/main/pom.xml
+++ b/schemagen/main/pom.xml
@@ -1,37 +1,34 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright
+ ownership. The ASF licenses this file to you 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
- 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.
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>clerezza</artifactId>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>clerezza</artifactId>
<version>9-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<version>2.0.0-SNAPSHOT</version>
<artifactId>schemagen</artifactId>
<packaging>jar</packaging>
- <name>Clerezza - RDF - SchemaGen: Class Generator for Ontologies</name>
+ <name>Clerezza - SchemaGen: Class Generator for Ontologies</name>
<dependencies>
<dependency>
<groupId>org.wymiwyg</groupId>
diff --git a/schemagen/main/src/assembly/dist.xml
b/schemagen/main/src/assembly/dist.xml
index 30c832d..95da964 100644
--- a/schemagen/main/src/assembly/dist.xml
+++ b/schemagen/main/src/assembly/dist.xml
@@ -1,48 +1,46 @@
-<?xml version='1.0'?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright
+ ownership. The ASF licenses this file to you 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
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
+ 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.
-->
-
<assembly>
- <id>dist</id>
- <formats>
- <format>dir</format>
- <format>zip</format>
- <!-- <format>tar.bz2</format> -->
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>target</directory>
- <outputDirectory></outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <outputDirectory>/lib</outputDirectory>
- <unpack>false</unpack>
- <scope>runtime</scope>
- <outputFileNameMapping>
${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- </dependencySet>
- </dependencySets>
+ <id>dist</id>
+ <formats>
+ <format>dir</format>
+ <format>zip</format>
+ <!-- <format>tar.bz2</format> -->
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/lib</outputDirectory>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ <outputFileNameMapping>
+
${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}
+ </outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
</assembly>
diff --git
a/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGen.java
b/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGen.java
index b832113..df20bca 100644
--- a/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGen.java
+++ b/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGen.java
@@ -1,20 +1,19 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you 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.
+ * 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 org.apache.clerezza.schemagen;
@@ -32,31 +31,30 @@ import java.io.PrintWriter;
import java.util.*;
/**
- * Generates the source code of a java-class with constants for an ontology
- * described in RDF
+ * Generates the source code of a java-class with constants for an ontology
described in RDF.
*
* @author reto
*/
public class SchemaGen {
- public static void main( String... args ) throws Exception {
+ public static void main(String... args) throws Exception {
SchemaGenArguments arguments;
try {
- arguments = new ArgumentHandler( args ).getInstance(
SchemaGenArguments.class );
- } catch ( InvalidArgumentsException e ) {
- System.out.println( e.getMessage() );
- System.out.print( "Usage: SchemaGen " );
- System.out.println(
AnnotatedInterfaceArguments.getArgumentsSyntax( SchemaGenArguments.class ) );
- PrintWriter out = new PrintWriter( System.out, true );
+ arguments = new
ArgumentHandler(args).getInstance(SchemaGenArguments.class);
+ } catch (InvalidArgumentsException e) {
+ System.out.println(e.getMessage());
+ System.out.print("Usage: SchemaGen ");
+
System.out.println(AnnotatedInterfaceArguments.getArgumentsSyntax(SchemaGenArguments.class));
+ PrintWriter out = new PrintWriter(System.out, true);
AnnotatedInterfaceArguments.printArgumentDescriptions(
- SchemaGenArguments.class, out );
+ SchemaGenArguments.class, out);
out.flush();
return;
}
- SchemaGen schemaGen = new SchemaGen( arguments );
- PrintWriter out = new PrintWriter( System.out );
- schemaGen.writeClass( out );
+ SchemaGen schemaGen = new SchemaGen(arguments);
+ PrintWriter out = new PrintWriter(System.out);
+ schemaGen.writeClass(out);
out.flush();
}
@@ -71,16 +69,16 @@ public class SchemaGen {
* @param arguments specification of the transformation
* @throws IOException If an IO error occurs.
*/
- public SchemaGen( SchemaGenArguments arguments )
+ public SchemaGen(SchemaGenArguments arguments)
throws IOException {
Parser parser = Parser.getInstance();
- parser.bindParsingProvider( new JenaParserProvider() );
+ parser.bindParsingProvider(new JenaParserProvider());
InputStream serializedGraph = arguments.getSchemaUrl().openStream();
- schemaGraph = parser.parse( serializedGraph,
- arguments.getFormatIdentifier() );
+ schemaGraph = parser.parse(serializedGraph,
+ arguments.getFormatIdentifier());
className = arguments.getClassName();
- if ( arguments.getNamespace() == null ) {
+ if (arguments.getNamespace() == null) {
namespace = getOntologyUri();
} else {
namespace = arguments.getNamespace();
@@ -88,15 +86,15 @@ public class SchemaGen {
}
private String getOntologyUri() {
- Iterator<Triple> ontologyTriples = schemaGraph.filter( null, RDF.type,
OWL.Ontology );
+ Iterator<Triple> ontologyTriples = schemaGraph.filter(null, RDF.type,
OWL.Ontology);
String result;
- if ( ontologyTriples.hasNext() ) {
- result = ( ( IRI ) ontologyTriples.next().getSubject()
).getUnicodeString();
+ if (ontologyTriples.hasNext()) {
+ result = ((IRI)
ontologyTriples.next().getSubject()).getUnicodeString();
} else {
- throw new RuntimeException( "No OWL Ontology found!" );
+ throw new RuntimeException("No OWL Ontology found!");
}
- if ( ontologyTriples.hasNext() ) {
- throw new RuntimeException( "More than one OWL Ontology found!" );
+ if (ontologyTriples.hasNext()) {
+ throw new RuntimeException("More than one OWL Ontology found!");
}
return result;
}
@@ -108,83 +106,83 @@ public class SchemaGen {
* @param out The print writer to write the transformation to.
* @throws IllegalArgumentException If out is <code>null</code>.
*/
- public void writeClass( PrintWriter out ) {
- if ( out == null ) {
- throw new IllegalArgumentException( "Invalid out: out" );
+ public void writeClass(PrintWriter out) {
+ if (out == null) {
+ throw new IllegalArgumentException("Invalid out: out");
}
- out.print( "// Generated by " );
- out.println( getClass().getName() );
+ out.print("// Generated by ");
+ out.println(getClass().getName());
String packageName = getPackageName();
- if ( packageName != null ) {
- out.print( "package " );
- out.print( packageName );
- out.println( ';' );
+ if (packageName != null) {
+ out.print("package ");
+ out.print(packageName);
+ out.println(';');
}
out.println();
- out.println( "import org.apache.clerezza.IRI;" );
+ out.println("import org.apache.clerezza.IRI;");
out.println();
- out.print( "public class " );
- out.print( getSimpleName() );
- out.println( " {" );
+ out.print("public class ");
+ out.print(getSimpleName());
+ out.println(" {");
SortedSet<OntologyResource> ontClasses = new TreeSet<>();
- ontClasses.addAll( getResourcesOfType( RDFS.Class ) );
- ontClasses.addAll( getResourcesOfType( RDFS.Datatype ) );
- ontClasses.addAll( getResourcesOfType( OWL.Class ) );
+ ontClasses.addAll(getResourcesOfType(RDFS.Class));
+ ontClasses.addAll(getResourcesOfType(RDFS.Datatype));
+ ontClasses.addAll(getResourcesOfType(OWL.Class));
- if ( ontClasses.size() > 0 ) {
- out.println( "\t// Classes" );
- printResources( ontClasses.iterator(), out );
+ if (ontClasses.size() > 0) {
+ out.println("\t// Classes");
+ printResources(ontClasses.iterator(), out);
}
SortedSet<OntologyResource> ontProperties = new TreeSet<>();
//some ontologies defining things that are both classes
//and properties, like image in RSS 1.0 - so we remove those
- ontProperties.addAll( getResourcesOfType( RDF.Property, ontClasses ) );
- ontProperties.addAll( getResourcesOfType( OWL.ObjectProperty,
ontClasses ) );
- ontProperties.addAll( getResourcesOfType( OWL.DatatypeProperty,
ontClasses ) );
+ ontProperties.addAll(getResourcesOfType(RDF.Property, ontClasses));
+ ontProperties.addAll(getResourcesOfType(OWL.ObjectProperty,
ontClasses));
+ ontProperties.addAll(getResourcesOfType(OWL.DatatypeProperty,
ontClasses));
- if ( ontProperties.size() > 0 ) {
+ if (ontProperties.size() > 0) {
out.println();
- out.println( "\t// Properties" );
- printResources( ontProperties.iterator(), out );
+ out.println("\t// Properties");
+ printResources(ontProperties.iterator(), out);
}
//create a set of classes and properties. Everything else should be
instances
- ontClasses.addAll( ontProperties );
- Collection<OntologyResource> instances = getResourcesOfType( null,
ontClasses );
+ ontClasses.addAll(ontProperties);
+ Collection<OntologyResource> instances = getResourcesOfType(null,
ontClasses);
- if ( instances.size() > 0 ) {
+ if (instances.size() > 0) {
out.println();
- out.println( "\t// Properties" );
- printResources( instances.iterator(), out );
+ out.println("\t// Properties");
+ printResources(instances.iterator(), out);
}
- out.println( "}" );
+ out.println("}");
}
- private void printResources( Iterator<OntologyResource> iterator,
- PrintWriter out ) {
- while ( iterator.hasNext() ) {
+ private void printResources(Iterator<OntologyResource> iterator,
+ PrintWriter out) {
+ while (iterator.hasNext()) {
OntologyResource ontologyResource = iterator.next();
String description = ontologyResource.getDescription();
- if ( description != null ) {
+ if (description != null) {
out.println();
- out.println( "\t/**" );
- out.print( "\t * " );
- out.println( description );
- out.println( "\t */" );
+ out.println("\t/**");
+ out.print("\t * ");
+ out.println(description);
+ out.println("\t */");
}
- out.print( "\tpublic static final IRI " );
- out.print( ontologyResource.getLocalName() );
- out.print( " = new IRI(\"" );
- out.print( ontologyResource.getUriString() );
- out.println( "\");" );
+ out.print("\tpublic static final IRI ");
+ out.print(ontologyResource.getLocalName());
+ out.print(" = new IRI(\"");
+ out.print(ontologyResource.getUriString());
+ out.println("\");");
}
}
- private Collection<OntologyResource> getResourcesOfType( IRI type ) {
- return getResourcesOfType( type, null );
+ private Collection<OntologyResource> getResourcesOfType(IRI type) {
+ return getResourcesOfType(type, null);
}
/**
@@ -192,83 +190,83 @@ public class SchemaGen {
* @param ignore a set things to ignore
* @return result
*/
- private Collection<OntologyResource> getResourcesOfType( IRI type,
Collection<OntologyResource> ignore ) {
+ private Collection<OntologyResource> getResourcesOfType(IRI type,
Collection<OntologyResource> ignore) {
Set<OntologyResource> result = new HashSet<>();
- Iterator<Triple> classStatement = schemaGraph.filter( null, RDF.type,
- type );
- while ( classStatement.hasNext() ) {
+ Iterator<Triple> classStatement = schemaGraph.filter(null, RDF.type,
+ type);
+ while (classStatement.hasNext()) {
Triple triple = classStatement.next();
BlankNodeOrIRI classResource = triple.getSubject();
- if ( classResource instanceof BlankNode ) {
- if ( type != null )
- System.err.println( "Ignoring anonymous resource of type "
+ type.getUnicodeString() );
- else System.err.println( "Ignoring anonymous resource" );
- for ( Triple contextTriple : getNodeContext( classResource,
schemaGraph ) ) {
- System.err.println( contextTriple );
+ if (classResource instanceof BlankNode) {
+ if (type != null)
+ System.err.println("Ignoring anonymous resource of type "
+ type.getUnicodeString());
+ else System.err.println("Ignoring anonymous resource");
+ for (Triple contextTriple : getNodeContext(classResource,
schemaGraph)) {
+ System.err.println(contextTriple);
}
continue;
}
// Test if the given resource belongs to the ontology
- final IRI classUri = ( IRI ) classResource;
+ final IRI classUri = (IRI) classResource;
final String strClassUri = classUri.getUnicodeString();
- if ( strClassUri.startsWith( namespace ) ) {
+ if (strClassUri.startsWith(namespace)) {
// The remaining part of the class URI must not contain
// a slash '/' or a hash '#' character. Otherwise we assume
// that is belongs to another ontology.
final int offset = namespace.length();
- int idxSlash = strClassUri.indexOf( '/', offset );
- int idxHash = strClassUri.indexOf( '#', offset );
+ int idxSlash = strClassUri.indexOf('/', offset);
+ int idxHash = strClassUri.indexOf('#', offset);
// Note that we generously ignore the first character of the
// remaining part that may be a '/' or a '#' because the
// namespace may not end with such a character.
- if ( idxSlash <= offset && idxHash <= offset ) {
+ if (idxSlash <= offset && idxHash <= offset) {
OntologyResource ontologyResource =
- new OntologyResource( classUri, schemaGraph );
- if ( ignore == null || !ignore.contains( ontologyResource
) )
- result.add( ontologyResource );
+ new OntologyResource(classUri, schemaGraph);
+ if (ignore == null || !ignore.contains(ontologyResource))
+ result.add(ontologyResource);
}
}
}
return result;
}
- private ImmutableGraph getNodeContext( BlankNodeOrIRI resource, Graph
graph ) {
+ private ImmutableGraph getNodeContext(BlankNodeOrIRI resource, Graph
graph) {
final HashSet<BlankNode> dontExpand = new HashSet<>();
- if ( resource instanceof BlankNode ) {
- dontExpand.add( ( BlankNode ) resource );
+ if (resource instanceof BlankNode) {
+ dontExpand.add((BlankNode) resource);
}
- return getContextOf( resource, dontExpand, graph ).getImmutableGraph();
+ return getContextOf(resource, dontExpand, graph).getImmutableGraph();
}
- private Graph getContextOf( BlankNodeOrIRI node, Set<BlankNode> dontExpand,
- Graph graph ) {
+ private Graph getContextOf(BlankNodeOrIRI node, Set<BlankNode> dontExpand,
+ Graph graph) {
Graph result = new SimpleGraph();
- Iterator<Triple> forwardProperties = graph.filter( node, null, null );
- while ( forwardProperties.hasNext() ) {
+ Iterator<Triple> forwardProperties = graph.filter(node, null, null);
+ while (forwardProperties.hasNext()) {
Triple triple = forwardProperties.next();
- result.add( triple );
+ result.add(triple);
RDFTerm object = triple.getObject();
- if ( object instanceof BlankNode ) {
- BlankNode bNodeObject = ( BlankNode ) object;
- if ( !dontExpand.contains( bNodeObject ) ) {
- dontExpand.add( bNodeObject );
- result.addAll( getContextOf( bNodeObject, dontExpand,
graph ) );
+ if (object instanceof BlankNode) {
+ BlankNode bNodeObject = (BlankNode) object;
+ if (!dontExpand.contains(bNodeObject)) {
+ dontExpand.add(bNodeObject);
+ result.addAll(getContextOf(bNodeObject, dontExpand,
graph));
}
}
}
- Iterator<Triple> backwardProperties = graph.filter( null, null, node );
- while ( backwardProperties.hasNext() ) {
+ Iterator<Triple> backwardProperties = graph.filter(null, null, node);
+ while (backwardProperties.hasNext()) {
Triple triple = backwardProperties.next();
- result.add( triple );
+ result.add(triple);
BlankNodeOrIRI subject = triple.getSubject();
- if ( subject instanceof BlankNode ) {
- BlankNode bNodeSubject = ( BlankNode ) subject;
- if ( !dontExpand.contains( bNodeSubject ) ) {
- dontExpand.add( bNodeSubject );
- result.addAll( getContextOf( bNodeSubject, dontExpand,
graph ) );
+ if (subject instanceof BlankNode) {
+ BlankNode bNodeSubject = (BlankNode) subject;
+ if (!dontExpand.contains(bNodeSubject)) {
+ dontExpand.add(bNodeSubject);
+ result.addAll(getContextOf(bNodeSubject, dontExpand,
graph));
}
}
}
@@ -276,19 +274,19 @@ public class SchemaGen {
}
private String getSimpleName() {
- int lastDotPos = className.lastIndexOf( '.' );
- if ( lastDotPos == -1 ) {
+ int lastDotPos = className.lastIndexOf('.');
+ if (lastDotPos == -1) {
return className;
}
- return className.substring( lastDotPos + 1 );
+ return className.substring(lastDotPos + 1);
}
private String getPackageName() {
- int lastDotPos = className.lastIndexOf( '.' );
- if ( lastDotPos == -1 ) {
+ int lastDotPos = className.lastIndexOf('.');
+ if (lastDotPos == -1) {
return null;
}
- return className.substring( 0, lastDotPos );
+ return className.substring(0, lastDotPos);
}
private static class OntologyResource implements
@@ -306,23 +304,23 @@ public class SchemaGen {
"new", "null", "package", "private", "protected", "public",
"return", "short", "static", "strictfp", "super", "switch",
"synchronized", "this", "throw", "throws", "transient",
- "true", "try", "void", "volatile", "while" );
+ "true", "try", "void", "volatile", "while");
- OntologyResource( IRI uri, Graph graph ) {
+ OntologyResource(IRI uri, Graph graph) {
this.uri = uri;
this.graph = graph;
}
String getLocalName() {
String uriValue = uri.getUnicodeString();
- int hashPos = uriValue.lastIndexOf( '#' );
- int slashPos = uriValue.lastIndexOf( '/' );
- int delimiter = Math.max( hashPos, slashPos );
- String val = uriValue.substring( delimiter + 1 );
- if ( val.length() == 0 ) return "THIS_ONTOLOGY";
+ int hashPos = uriValue.lastIndexOf('#');
+ int slashPos = uriValue.lastIndexOf('/');
+ int delimiter = Math.max(hashPos, slashPos);
+ String val = uriValue.substring(delimiter + 1);
+ if (val.length() == 0) return "THIS_ONTOLOGY";
//replace bad characters...
- val = val.replace( '-', '_' ).replace( '.', '_' );
- return reservedWords.contains( val ) ? val + "_" : val;
+ val = val.replace('-', '_').replace('.', '_');
+ return reservedWords.contains(val) ? val + "_" : val;
}
String getUriString() {
@@ -332,66 +330,66 @@ public class SchemaGen {
String getDescription() {
StringBuilder result = new StringBuilder();
Iterator<Triple> titleStatements = graph.filter(
- uri, DCTERMS.title, null );
- while ( titleStatements.hasNext() ) {
+ uri, DCTERMS.title, null);
+ while (titleStatements.hasNext()) {
RDFTerm object = titleStatements.next().getObject();
- if ( object instanceof Literal ) {
- result.append( "title: " );
- result.append( ( ( Literal ) object ).getLexicalForm() );
- result.append( "\n" );
+ if (object instanceof Literal) {
+ result.append("title: ");
+ result.append(((Literal) object).getLexicalForm());
+ result.append("\n");
}
}
Iterator<Triple> descriptionStatements = graph.filter(
- uri, DCTERMS.description, null );
- while ( descriptionStatements.hasNext() ) {
+ uri, DCTERMS.description, null);
+ while (descriptionStatements.hasNext()) {
RDFTerm object = descriptionStatements.next().getObject();
- if ( object instanceof Literal ) {
- result.append( "description: " );
- result.append( ( ( Literal ) object ).getLexicalForm() );
- result.append( "\n" );
+ if (object instanceof Literal) {
+ result.append("description: ");
+ result.append(((Literal) object).getLexicalForm());
+ result.append("\n");
}
}
Iterator<Triple> skosDefStatements = graph.filter(
- uri, SKOS.definition, null );
- while ( skosDefStatements.hasNext() ) {
+ uri, SKOS.definition, null);
+ while (skosDefStatements.hasNext()) {
RDFTerm object = skosDefStatements.next().getObject();
- if ( object instanceof Literal ) {
- result.append( "definition: " );
- result.append( ( ( Literal ) object ).getLexicalForm() );
- result.append( "\n" );
+ if (object instanceof Literal) {
+ result.append("definition: ");
+ result.append(((Literal) object).getLexicalForm());
+ result.append("\n");
}
}
Iterator<Triple> rdfsCommentStatements = graph.filter(
- uri, RDFS.comment, null );
- while ( rdfsCommentStatements.hasNext() ) {
+ uri, RDFS.comment, null);
+ while (rdfsCommentStatements.hasNext()) {
RDFTerm object = rdfsCommentStatements.next().getObject();
- if ( object instanceof Literal ) {
- result.append( "comment: " );
- result.append( ( ( Literal ) object ).getLexicalForm() );
- result.append( "\n" );
+ if (object instanceof Literal) {
+ result.append("comment: ");
+ result.append(((Literal) object).getLexicalForm());
+ result.append("\n");
}
}
Iterator<Triple> skosNoteStatements = graph.filter(
- uri, SKOS.note, null );
- while ( skosNoteStatements.hasNext() ) {
+ uri, SKOS.note, null);
+ while (skosNoteStatements.hasNext()) {
RDFTerm object = skosNoteStatements.next().getObject();
- if ( object instanceof Literal ) {
- result.append( "note: " );
- result.append( ( ( Literal ) object ).getLexicalForm() );
- result.append( "\n" );
+ if (object instanceof Literal) {
+ result.append("note: ");
+ result.append(((Literal) object).getLexicalForm());
+ result.append("\n");
}
}
Iterator<Triple> skosExampleStatements = graph.filter(
- uri, SKOS.example, null );
- while ( skosExampleStatements.hasNext() ) {
+ uri, SKOS.example, null);
+ while (skosExampleStatements.hasNext()) {
RDFTerm object = skosExampleStatements.next().getObject();
- if ( object instanceof Literal ) {
- result.append( "example: " );
- result.append( ( ( Literal ) object ).getLexicalForm() );
- result.append( "\n" );
- } else if ( object instanceof IRI ) {
- result.append( "see <a href=" ).append( ( ( IRI ) object
).getUnicodeString() ).append( ">example</a>" );
- result.append( "\n" );
+ if (object instanceof Literal) {
+ result.append("example: ");
+ result.append(((Literal) object).getLexicalForm());
+ result.append("\n");
+ } else if (object instanceof IRI) {
+ result.append("see <a href=").append(((IRI)
object).getUnicodeString()).append(">example</a>");
+ result.append("\n");
}
}
return result.toString();
@@ -403,21 +401,21 @@ public class SchemaGen {
}
@Override
- public boolean equals( Object obj ) {
- if ( obj == null ) {
+ public boolean equals(Object obj) {
+ if (obj == null) {
return false;
- } else if ( obj == this ) {
+ } else if (obj == this) {
return true;
- } else if ( OntologyResource.class.equals( obj.getClass() ) ) {
- final OntologyResource other = ( OntologyResource ) obj;
- return getUriString().equals( other.getUriString() );
+ } else if (OntologyResource.class.equals(obj.getClass())) {
+ final OntologyResource other = (OntologyResource) obj;
+ return getUriString().equals(other.getUriString());
}
return false;
}
@Override
- public int compareTo( OntologyResource o ) {
- return getUriString().compareTo( o.getUriString() );
+ public int compareTo(OntologyResource o) {
+ return getUriString().compareTo(o.getUriString());
}
}
@@ -433,12 +431,12 @@ public class SchemaGen {
private static final String NS = "http://www.w3.org/2002/07/owl#";
private static final IRI Class =
- new IRI( NS + "Class" );
- public static final RDFTerm Ontology = new IRI( NS + "Ontology" );
+ new IRI(NS + "Class");
+ public static final RDFTerm Ontology = new IRI(NS + "Ontology");
private static final IRI DatatypeProperty =
- new IRI( NS + "DatatypeProperty" );
+ new IRI(NS + "DatatypeProperty");
private static final IRI ObjectProperty =
- new IRI( NS + "ObjectProperty" );
+ new IRI(NS + "ObjectProperty");
}
@@ -449,9 +447,9 @@ public class SchemaGen {
private static final String NS =
"http://www.w3.org/2000/01/rdf-schema#";
- private static final IRI Class = new IRI( NS + "Class" );
- private static final IRI Datatype = new IRI( NS + "Datatype" );
- private static final IRI comment = new IRI( NS + "comment" );
+ private static final IRI Class = new IRI(NS + "Class");
+ private static final IRI Datatype = new IRI(NS + "Datatype");
+ private static final IRI comment = new IRI(NS + "comment");
}
@@ -462,23 +460,23 @@ public class SchemaGen {
private static final String NS =
"http://www.w3.org/1999/02/22-rdf-syntax-ns#";
- private static final IRI Property = new IRI( NS + "Property" );
- private static final IRI type = new IRI( NS + "type" );
+ private static final IRI Property = new IRI(NS + "Property");
+ private static final IRI type = new IRI(NS + "type");
}
private static class SKOS {
- static final IRI definition = new IRI(
"http://www.w3.org/2008/05/skos#definition" );
- static final IRI note = new IRI(
"http://www.w3.org/2004/02/skos/core#note" );
- static final IRI example = new IRI(
"http://www.w3.org/2004/02/skos/core#example" );
+ static final IRI definition = new
IRI("http://www.w3.org/2008/05/skos#definition");
+ static final IRI note = new
IRI("http://www.w3.org/2004/02/skos/core#note");
+ static final IRI example = new
IRI("http://www.w3.org/2004/02/skos/core#example");
}
private static class DCTERMS {
- public static final IRI title = new IRI(
"http://purl.org/dc/terms/title" );
- public static final IRI description = new IRI(
"http://purl.org/dc/terms/description" );
+ public static final IRI title = new
IRI("http://purl.org/dc/terms/title");
+ public static final IRI description = new
IRI("http://purl.org/dc/terms/description");
}
diff --git
a/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGenArguments.java
b/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGenArguments.java
index 0738771..ecdc1fd 100644
---
a/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGenArguments.java
+++
b/schemagen/main/src/main/java/org/apache/clerezza/schemagen/SchemaGenArguments.java
@@ -1,20 +1,19 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you 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.
+ * 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 org.apache.clerezza.schemagen;
@@ -24,26 +23,25 @@ import org.wymiwyg.commons.util.arguments.CommandLine;
/**
- *
* @author reto
*/
public interface SchemaGenArguments {
// comments omitted as redundant with description
- @CommandLine(longName = "schema", shortName = { "S" }, required = true,
+ @CommandLine(longName = "schema", shortName = {"S"}, required = true,
description = "The URL from which the vocabulary can be retrieved")
URL getSchemaUrl();
- @CommandLine(longName = "namespace", shortName = { "N" },
+ @CommandLine(longName = "namespace", shortName = {"N"},
description = "Namespace of the vocabulary, by default it uses the
URI of a resource of type owl:Ontology found in the vocabulary")
String getNamespace();
- @CommandLine(longName = "format", shortName = { "F" },
+ @CommandLine(longName = "format", shortName = {"F"},
description = "The RDF content-type of the schema (Content-Type in
an HTTP-Response is ignored)",
defaultValue = "application/rdf+xml")
String getFormatIdentifier();
-
- @CommandLine(longName = "classname", shortName = { "C" }, required = true,
+
+ @CommandLine(longName = "classname", shortName = {"C"}, required = true,
description = "The fully qualified class name of the class to be
created")
String getClassName();
}
diff --git a/schemagen/maven-plugin/LICENSE b/schemagen/maven-plugin/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/schemagen/maven-plugin/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
diff --git a/schemagen/maven-plugin/pom.xml b/schemagen/maven-plugin/pom.xml
index 91b78b6..f730cbb 100644
--- a/schemagen/maven-plugin/pom.xml
+++ b/schemagen/maven-plugin/pom.xml
@@ -1,46 +1,44 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8"?>
<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright
+ ownership. The ASF licenses this file to you 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
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
+ 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.
-->
-
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>clerezza</artifactId>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>clerezza</artifactId>
<version>9-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<artifactId>maven-ontologies-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.0.0-SNAPSHOT</version>
- <name>Clerezza - RDF - SchemaGen: Maven Ontologies Plugin</name>
+ <name>Clerezza - SchemaGen: Maven Ontologies Plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.8.1</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>1.7.30</version>
+ <version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
@@ -48,9 +46,9 @@
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0.9</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.9</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git
a/schemagen/maven-plugin/src/main/java/org/apache/clerezza/ontologiesplugin/OntologyJavaClassCreatorMojo.java
b/schemagen/maven-plugin/src/main/java/org/apache/clerezza/ontologiesplugin/OntologyJavaClassCreatorMojo.java
index 71fe302..40c1817 100644
---
a/schemagen/maven-plugin/src/main/java/org/apache/clerezza/ontologiesplugin/OntologyJavaClassCreatorMojo.java
+++
b/schemagen/maven-plugin/src/main/java/org/apache/clerezza/ontologiesplugin/OntologyJavaClassCreatorMojo.java
@@ -1,20 +1,19 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you 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.
+ * 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 org.apache.clerezza.ontologiesplugin;
@@ -81,78 +80,78 @@ public class OntologyJavaClassCreatorMojo extends
AbstractMojo {
@Override
public void execute() throws MojoExecutionException {
- supportedFormats.put( ".nt", "application/n-triples" );
- supportedFormats.put( ".n3", "text/rdf+n3" );
- supportedFormats.put( ".rdf", "application/rdf+xml" );
- supportedFormats.put( ".ttl", "text/turtle" );
- supportedFormats.put( ".turtle", "text/turtle" );
+ supportedFormats.put(".nt", "application/n-triples");
+ supportedFormats.put(".n3", "text/rdf+n3");
+ supportedFormats.put(".rdf", "application/rdf+xml");
+ supportedFormats.put(".ttl", "text/turtle");
+ supportedFormats.put(".turtle", "text/turtle");
File file;
- if ( resourcePath == null ) {
+ if (resourcePath == null) {
resourcePath = baseDir + File.separator + "src" + File.separator
+ "main" + File.separator + "ontologies";
- } else if ( resourcePath.contains( "/" ) ) {
- resourcePath = resourcePath.replace( "/", File.separator );
- } else if ( resourcePath.contains( "\\" ) ) {
- resourcePath = resourcePath.replace( "\\", File.separator );
+ } else if (resourcePath.contains("/")) {
+ resourcePath = resourcePath.replace("/", File.separator);
+ } else if (resourcePath.contains("\\")) {
+ resourcePath = resourcePath.replace("\\", File.separator);
}
- file = new File( resourcePath );
- checkDir( file );
- if ( sources != null ) {
- for ( File source : sources ) {
- project.addCompileSourceRoot( source.getAbsolutePath() );
- getLog().info( "Source directory: " + source + " added." );
+ file = new File(resourcePath);
+ checkDir(file);
+ if (sources != null) {
+ for (File source : sources) {
+ project.addCompileSourceRoot(source.getAbsolutePath());
+ getLog().info("Source directory: " + source + " added.");
}
}
}
- private void checkDir( File ontologiesDir ) {
- for ( File file : ontologiesDir.listFiles() ) {
- if ( file.isDirectory() ) {
- checkDir( file );
+ private void checkDir(File ontologiesDir) {
+ for (File file : ontologiesDir.listFiles()) {
+ if (file.isDirectory()) {
+ checkDir(file);
} else {
String fileName = file.getName();
- int indexOfLastDot = fileName.lastIndexOf( "." );
- if ( indexOfLastDot != -1 ) {
- String fileEnding = fileName.substring( indexOfLastDot );
- if ( supportedFormats.containsKey( fileEnding ) ) {
- createJavaClassFile( file, fileEnding );
+ int indexOfLastDot = fileName.lastIndexOf(".");
+ if (indexOfLastDot != -1) {
+ String fileEnding = fileName.substring(indexOfLastDot);
+ if (supportedFormats.containsKey(fileEnding)) {
+ createJavaClassFile(file, fileEnding);
}
}
}
}
}
- private void createJavaClassFile( final File file, final String fileEnding
) {
+ private void createJavaClassFile(final File file, final String fileEnding)
{
final String fileName = file.getName();
final String absolutePath = file.getAbsolutePath();
- final String className = fileName.replace( fileEnding, ""
).toUpperCase();
+ final String className = fileName.replace(fileEnding,
"").toUpperCase();
final String pathToJavaClass = absolutePath.substring(
- absolutePath.indexOf( resourcePath ) + resourcePath.length() +
1 )
- .replace( fileName, "" );
- final String packageName = pathToJavaClass.replace( File.separator,
"." )
+ absolutePath.indexOf(resourcePath) + resourcePath.length() + 1)
+ .replace(fileName, "");
+ final String packageName = pathToJavaClass.replace(File.separator, ".")
+ className;
SchemaGenArguments arguments = new SchemaGenArguments() {
public URL getSchemaUrl() {
try {
return file.toURI().toURL();
- } catch ( MalformedURLException e ) {
- getLog().error( e.getMessage(), e );
+ } catch (MalformedURLException e) {
+ getLog().error(e.getMessage(), e);
}
return null;
}
public String getNamespace() {
- if ( namespaceOfOntology != null
- && namespaceOfOntology.containsKey( fileName ) ) {
- return namespaceOfOntology.getProperty( fileName );
+ if (namespaceOfOntology != null
+ && namespaceOfOntology.containsKey(fileName)) {
+ return namespaceOfOntology.getProperty(fileName);
}
return null;
}
public String getFormatIdentifier() {
- return supportedFormats.get( fileEnding );
+ return supportedFormats.get(fileEnding);
}
public String getClassName() {
@@ -162,28 +161,28 @@ public class OntologyJavaClassCreatorMojo extends
AbstractMojo {
SchemaGen schemaGen;
try {
- schemaGen = new SchemaGen( arguments );
- } catch ( IOException e ) {
- getLog().error( e.getMessage(), e );
+ schemaGen = new SchemaGen(arguments);
+ } catch (IOException e) {
+ getLog().error(e.getMessage(), e);
return;
}
String rootPath = baseDir + File.separator + "target"
+ File.separator + "generated-sources" + File.separator
+ "main" + File.separator + "java" + File.separator;
- File dir = new File( rootPath + pathToJavaClass );
+ File dir = new File(rootPath + pathToJavaClass);
dir.mkdirs();
PrintWriter out;
try {
- out = new PrintWriter( rootPath + pathToJavaClass + className +
".java", "utf-8" );
- } catch ( FileNotFoundException e ) {
- getLog().error( e.getMessage(), e );
+ out = new PrintWriter(rootPath + pathToJavaClass + className +
".java", "utf-8");
+ } catch (FileNotFoundException e) {
+ getLog().error(e.getMessage(), e);
return;
- } catch ( UnsupportedEncodingException e ) {
- getLog().error( e.getMessage(), e );
- throw new RuntimeException( "utf-8 not supported!" );
+ } catch (UnsupportedEncodingException e) {
+ getLog().error(e.getMessage(), e);
+ throw new RuntimeException("utf-8 not supported!");
}
try {
- schemaGen.writeClass( out );
+ schemaGen.writeClass(out);
} finally {
out.flush();
}