-
Notifications
You must be signed in to change notification settings - Fork 16
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
1,211 changed files
with
10,842 additions
and
5,867 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
**/target | ||
**/*.iml | ||
**/.idea | ||
.gradle | ||
**/results | ||
**/testResults | ||
**/example02-jopa-owlapi/repository.owl | ||
|
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
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>jopa-all</artifactId> | ||
<groupId>cz.cvut.kbss.jopa</groupId> | ||
<version>0.18.0</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>datatype</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Datatype mapping</name> | ||
<description>Datatype mapping module.</description> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>cz.cvut.kbss.jopa</groupId> | ||
<artifactId>ontodriver-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
34 changes: 34 additions & 0 deletions
34
datatype/src/main/java/cz/cvut/kbss/jopa/datatype/DatatypeMapper.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,34 @@ | ||
/** | ||
* Copyright (C) 2022 Czech Technical University in Prague | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cz.cvut.kbss.jopa.datatype; | ||
|
||
|
||
import cz.cvut.kbss.ontodriver.model.Literal; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Maps RDF literals to Java objects. | ||
*/ | ||
public interface DatatypeMapper { | ||
|
||
/** | ||
* Maps the specified RDF literal to a suitable basic (in terms of JOPA OOM) Java type. | ||
* | ||
* @param literal Literal to map | ||
* @return Mapped value wrapped in an {@code Optional}, empty Optional if no suitable mapping can be found | ||
*/ | ||
Optional<Object> map(Literal literal); | ||
} |
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
66 changes: 66 additions & 0 deletions
66
datatype/src/main/java/cz/cvut/kbss/jopa/datatype/DateTimeUtil.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,66 @@ | ||
/** | ||
* Copyright (C) 2022 Czech Technical University in Prague | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cz.cvut.kbss.jopa.datatype; | ||
|
||
import java.time.*; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Utility class for transformation between various date/time representations. | ||
*/ | ||
public class DateTimeUtil { | ||
|
||
/** | ||
* System timezone offset used for transforming local datetime values to offset ones | ||
*/ | ||
public static final ZoneOffset SYSTEM_OFFSET = ZoneId.systemDefault().getRules().getOffset(LocalDateTime.now()); | ||
|
||
private DateTimeUtil() { | ||
throw new AssertionError(); | ||
} | ||
|
||
/** | ||
* Transforms the specified {@link LocalDateTime} to an {@link OffsetDateTime}, using the system's default offset. | ||
* | ||
* @param value Datetime to transform | ||
* @return Offset datetime | ||
*/ | ||
public static OffsetDateTime toDateTime(LocalDateTime value) { | ||
Objects.requireNonNull(value); | ||
return OffsetDateTime.of(value.toLocalDate(), value.toLocalTime(), SYSTEM_OFFSET); | ||
} | ||
|
||
/** | ||
* Transforms the specified {@link Instant} to an {@link OffsetDateTime}. | ||
* <p> | ||
* The instant is taken to be at the UTC timezone. | ||
* | ||
* @param value Instant value to transform | ||
* @return Offset datetime | ||
*/ | ||
public static OffsetDateTime toDateTime(Instant value) { | ||
return Objects.requireNonNull(value).atOffset(ZoneOffset.UTC); | ||
} | ||
|
||
/** | ||
* Transforms the specified {@link LocalTime} to an {@link OffsetTime}, using the system's default offset. | ||
* | ||
* @param value Time to transform | ||
* @return Offset time | ||
*/ | ||
public static OffsetTime toTime(LocalTime value) { | ||
return OffsetTime.of(Objects.requireNonNull(value), SYSTEM_OFFSET); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
datatype/src/main/java/cz/cvut/kbss/jopa/datatype/exception/DatatypeMappingException.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,31 @@ | ||
/** | ||
* Copyright (C) 2022 Czech Technical University in Prague | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cz.cvut.kbss.jopa.datatype.exception; | ||
|
||
/** | ||
* Indicates that the mapping has failed. | ||
* <p> | ||
* For example, if the literal value is not valid (e.g., an integer literal that cannot be parsed to Java {@link Integer}). | ||
*/ | ||
public class DatatypeMappingException extends RuntimeException { | ||
|
||
public DatatypeMappingException(String message) { | ||
super(message); | ||
} | ||
|
||
public DatatypeMappingException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ain/java/cz/cvut/kbss/jopa/datatype/exception/UnsupportedTypeTransformationException.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,29 @@ | ||
/** | ||
* Copyright (C) 2022 Czech Technical University in Prague | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, either version 3 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cz.cvut.kbss.jopa.datatype.exception; | ||
|
||
/** | ||
* Thrown when it is not possible to execute a type transformation. | ||
*/ | ||
public class UnsupportedTypeTransformationException extends DatatypeMappingException { | ||
|
||
public UnsupportedTypeTransformationException(String message) { | ||
super(message); | ||
} | ||
|
||
public UnsupportedTypeTransformationException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
Oops, something went wrong.