Skip to content

Commit

Permalink
LOV dependency #34 #39
Browse files Browse the repository at this point in the history
  • Loading branch information
jimkont committed Sep 26, 2015
1 parent 2015e28 commit 3bbee49
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

Expand Down Expand Up @@ -78,4 +80,37 @@ public List<SchemaEntry> getAllLOVEntries() {

return lovEntries;
}

public void writeAllLOVEntriesToFile(String filename) {

List<SchemaEntry> lovEntries = getAllLOVEntries();
Collections.sort(lovEntries);
String header =
"#This file is auto-generated from the (amazing) LOV service" +
"# if you don't want to load this use the available CLI / code options " +
"# To override some of it's entries use the schemaDecl.csv";


try (Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("outfilename"), "UTF-8")) ){

out.write(header);
out.write("\n");

for (SchemaEntry entry: lovEntries) {
out.write(entry.getPrefix());
out.write(',');
out.write(entry.getVocabularyURI());
if (!entry.getVocabularyDefinedBy().isEmpty()) {
out.write(',');
out.write(entry.getVocabularyDefinedBy());
}
out.write('\n');
}
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}


}
}
36 changes: 19 additions & 17 deletions rdfunit-core/src/main/java/org/aksw/rdfunit/prefix/SchemaEntry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.aksw.rdfunit.prefix;

import com.google.common.base.Objects;

/**
* Encapsulates an LOV Entry
*
Expand Down Expand Up @@ -76,33 +78,33 @@ public String getVocabularyDefinedBy() {
return vocabularyDefinedBy;
}

/** {@inheritDoc} */
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

SchemaEntry lovEntry = (SchemaEntry) o;

return prefix.equals(lovEntry.prefix);
public int hashCode() {
return Objects.hashCode(prefix, vocabularyURI, vocabularyNamespace, vocabularyDefinedBy);
}

/** {@inheritDoc} */
@Override
public int hashCode() {
int result = prefix.hashCode();
result = 31 * result + vocabularyURI.hashCode();
result = 31 * result + vocabularyNamespace.hashCode();
result = 31 * result + vocabularyDefinedBy.hashCode();
return result;
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final SchemaEntry other = (SchemaEntry) obj;
return Objects.equal(this.prefix, other.prefix)
&& Objects.equal(this.vocabularyURI, other.vocabularyURI)
&& Objects.equal(this.vocabularyNamespace, other.vocabularyNamespace)
&& Objects.equal(this.vocabularyDefinedBy, other.vocabularyDefinedBy);
}

/** {@inheritDoc} */
@Override
public String toString() {
return "LOVEntry{" +
return "SchemaEntry{" +
"prefix='" + prefix + '\'' +
", vocabularyURI='" + vocabularyURI + '\'' +
", vocabularyNamespace='" + vocabularyNamespace + '\'' +
", vocabularyDefinedBy='" + vocabularyDefinedBy + '\'' +
'}';
}

Expand Down

0 comments on commit 3bbee49

Please sign in to comment.