forked from eclipse-rdf4j/rdf4j
-
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.
eclipse-rdf4jGH-5058: additional parser code (WIP)
- Loading branch information
1 parent
ee04b0d
commit 67252f9
Showing
6 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
core/rio/csvw/src/main/java/org/eclipse/rdf4j/rio/csvw/parsers/CellParserBoolean.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,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Eclipse RDF4J contributors. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Distribution License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*******************************************************************************/ | ||
package org.eclipse.rdf4j.rio.csvw.parsers; | ||
|
||
import java.util.Set; | ||
|
||
import org.eclipse.rdf4j.model.IRI; | ||
import org.eclipse.rdf4j.model.Namespace; | ||
import org.eclipse.rdf4j.model.Value; | ||
import org.eclipse.rdf4j.model.util.Values; | ||
|
||
/** | ||
* | ||
* @author Bart Hanssens | ||
*/ | ||
public class CellParserBoolean extends CellParser { | ||
private String valueTrue; | ||
private String valueFalse; | ||
|
||
@Override | ||
public void setFormat(String format) { | ||
String[] values = format.split("\\|"); | ||
valueTrue = values[0]; | ||
valueFalse = values[1]; | ||
} | ||
|
||
@Override | ||
public Value parse(String cell) { | ||
String s = cell; | ||
if ((s == null || s.isEmpty()) && (defaultValue != null)) { | ||
s = defaultValue; | ||
} | ||
return Values.literal(valueTrue.equals(s) ? "true" : "false", dataType); | ||
} | ||
|
||
} |
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
"wikidata_id","first_name","last_name,country_id","country_name_nl","country_name_en","date_of_birth","married","languages" | ||
"Q5582","Vincent","van Gogh","Q29999","Nederland","The Netherlands","30/3/1853","false","dutch french" | ||
"Q164712","Paul,Delvaux","Q31","België","Belgium","23/9/1897","true",french" | ||
"Q46408","Georgia","O'Keeffe","Q30","Verenigde Staten","United States","15/11/1887","true","english" | ||
"Q5582","Vincent","van Gogh","Q29999","Nederland","The Netherlands","30/3/1853","No","dutch french" | ||
"Q164712","Paul","Delvaux","Q31","België","Belgium","23/9/1897","Yes","french" | ||
"Q46408","Georgia","O'Keeffe","Q30","Verenigde Staten","United States","15/11/1887","Yes","english" | ||
|