public class NtSerializer extends Object implements ISerializer
| Modifier and Type | Field and Description |
|---|---|
protected File |
folder |
protected Map<String,String> |
prefixMap |
protected Set<String> |
statements |
protected PrintWriter |
writer |
| Constructor and Description |
|---|
NtSerializer() |
NtSerializer(HashMap<String,String> prefixes) |
| Modifier and Type | Method and Description |
|---|---|
void |
addStatement(String subject,
String predicate,
String object,
double similarity)
Adds a triple to the buffer of the serializer.
|
boolean |
close()
Closes the output file
|
static String |
expand(String s,
String predicate)
Expands a string by replacing a prefix by its full value
|
void |
flush() |
File |
getFile(String fileName)
Method to open the file with the specific name
|
String |
getFileExtension() |
String |
getName() |
boolean |
open(String file)
Opens the output file
|
void |
printPrefixes(Map<String,String> prefixMap,
String file)
Method to print prefixes: "@prefix key: url ."
|
void |
printStatement(String subject,
String predicate,
String object,
double similarity)
Writes in the file statement by statement.
|
void |
setFolderPath(File folder)
Method to set the folder where Serializations should be saved to.
|
void |
setPrefixes(Map<String,String> prefixes)
Sets the prefixes to be used in the file.
|
void |
writeToFile(AMapping mapping,
String predicate,
String file)
Gets a mapping and serializes it to a file in the N3 format.
|
protected PrintWriter writer
protected File folder
public static String expand(String s, String predicate)
s - Input stringpredicate - Predicate to expand withpublic void addStatement(String subject, String predicate, String object, double similarity)
ISerializeraddStatement in interface ISerializersubject - The subject of the triplepredicate - The predicate of the tripleobject - The object of the triplesimilarity - valuepublic void flush()
public void writeToFile(AMapping mapping, String predicate, String file)
writeToFile in interface ISerializermapping - Mapping to serializepredicate - Predicate to use while serializingfile - File in which the mapping is to be serializedpublic void printStatement(String subject, String predicate, String object, double similarity)
printStatement in interface ISerializersubject - Source object of a mapping, subject of the triple to be writtenpredicate - Predicate to be writtenobject - Target object of a mapping, object of the triple to be writtensimilarity - Similarity achieved by the subject and objectpublic void printPrefixes(Map<String,String> prefixMap, String file)
prefixMap - to be printedfile - file namepublic boolean close()
ISerializerclose in interface ISerializerpublic boolean open(String file)
ISerializeropen in interface ISerializerfile - Path to the file in which the output is to be writtenpublic String getName()
getName in interface ISerializerpublic void setPrefixes(Map<String,String> prefixes)
ISerializersetPrefixes in interface ISerializerprefixes - List of prefixes to usepublic String getFileExtension()
getFileExtension in interface ISerializerpublic File getFile(String fileName)
ISerializergetFile in interface ISerializerfileName - stringpublic void setFolderPath(File folder)
ISerializersetFolderPath in interface ISerializerfolder - File which points to the folder to serialize within.Copyright © 2018. All rights reserved.