Skip to content

Commit

Permalink
(V1.0.1) REVERT FIX should be less tolerant against unrecognized data…
Browse files Browse the repository at this point in the history
…types
  • Loading branch information
mdesalvo committed Apr 21, 2017
1 parent ac06ba1 commit 6fbc403
Showing 1 changed file with 128 additions and 86 deletions.
214 changes: 128 additions & 86 deletions RDFSharp/Model/RDFModelUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ internal static RDFModelEnums.RDFDatatypes GetDatatypeFromString(String datatype
return RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDSHORT;
}
else {
throw new RDFModelException("Cannot recognize datatype representation of given \"datatypeString\" parameter.");
//Unknown datatypes default to instances of "rdfs:Literal"
return RDFModelEnums.RDFDatatypes.RDFS_LITERAL;
}

}
Expand All @@ -455,91 +456,132 @@ internal static RDFModelEnums.RDFDatatypes GetDatatypeFromString(String datatype
/// Gives the string representation of the given RDF/RDFS/XSD datatype
/// </summary>
internal static String GetDatatypeFromEnum(RDFModelEnums.RDFDatatypes datatype) {
switch (datatype) {
case RDFModelEnums.RDFDatatypes.RDF_XMLLITERAL:
return RDFVocabulary.RDF.XML_LITERAL.ToString();
case RDFModelEnums.RDFDatatypes.RDFS_LITERAL:
return RDFVocabulary.RDFS.LITERAL.ToString();
case RDFModelEnums.RDFDatatypes.XSD_ANYURI:
return RDFVocabulary.XSD.ANY_URI.ToString();
case RDFModelEnums.RDFDatatypes.XSD_BASE64BINARY:
return RDFVocabulary.XSD.BASE64_BINARY.ToString();
case RDFModelEnums.RDFDatatypes.XSD_BOOLEAN:
return RDFVocabulary.XSD.BOOLEAN.ToString();
case RDFModelEnums.RDFDatatypes.XSD_BYTE:
return RDFVocabulary.XSD.BYTE.ToString();
case RDFModelEnums.RDFDatatypes.XSD_DATE:
return RDFVocabulary.XSD.DATE.ToString();
case RDFModelEnums.RDFDatatypes.XSD_DATETIME:
return RDFVocabulary.XSD.DATETIME.ToString();
case RDFModelEnums.RDFDatatypes.XSD_DECIMAL:
return RDFVocabulary.XSD.DECIMAL.ToString();
case RDFModelEnums.RDFDatatypes.XSD_DOUBLE:
return RDFVocabulary.XSD.DOUBLE.ToString();
case RDFModelEnums.RDFDatatypes.XSD_DURATION:
return RDFVocabulary.XSD.DURATION.ToString();
case RDFModelEnums.RDFDatatypes.XSD_FLOAT:
return RDFVocabulary.XSD.FLOAT.ToString();
case RDFModelEnums.RDFDatatypes.XSD_GDAY:
return RDFVocabulary.XSD.G_DAY.ToString();
case RDFModelEnums.RDFDatatypes.XSD_GMONTH:
return RDFVocabulary.XSD.G_MONTH.ToString();
case RDFModelEnums.RDFDatatypes.XSD_GMONTHDAY:
return RDFVocabulary.XSD.G_MONTH_DAY.ToString();
case RDFModelEnums.RDFDatatypes.XSD_GYEAR:
return RDFVocabulary.XSD.G_YEAR.ToString();
case RDFModelEnums.RDFDatatypes.XSD_GYEARMONTH:
return RDFVocabulary.XSD.G_YEAR_MONTH.ToString();
case RDFModelEnums.RDFDatatypes.XSD_HEXBINARY:
return RDFVocabulary.XSD.HEX_BINARY.ToString();
case RDFModelEnums.RDFDatatypes.XSD_INT:
return RDFVocabulary.XSD.INT.ToString();
case RDFModelEnums.RDFDatatypes.XSD_INTEGER:
return RDFVocabulary.XSD.INTEGER.ToString();
case RDFModelEnums.RDFDatatypes.XSD_LANGUAGE:
return RDFVocabulary.XSD.LANGUAGE.ToString();
case RDFModelEnums.RDFDatatypes.XSD_LONG:
return RDFVocabulary.XSD.LONG.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NAME:
return RDFVocabulary.XSD.NAME.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NCNAME:
return RDFVocabulary.XSD.NCNAME.ToString();
case RDFModelEnums.RDFDatatypes.XSD_ID:
return RDFVocabulary.XSD.ID.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NEGATIVEINTEGER:
return RDFVocabulary.XSD.NEGATIVE_INTEGER.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NMTOKEN:
return RDFVocabulary.XSD.NMTOKEN.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NONNEGATIVEINTEGER:
return RDFVocabulary.XSD.NON_NEGATIVE_INTEGER.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NONPOSITIVEINTEGER:
return RDFVocabulary.XSD.NON_POSITIVE_INTEGER.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NORMALIZEDSTRING:
return RDFVocabulary.XSD.NORMALIZED_STRING.ToString();
case RDFModelEnums.RDFDatatypes.XSD_NOTATION:
return RDFVocabulary.XSD.NOTATION.ToString();
case RDFModelEnums.RDFDatatypes.XSD_POSITIVEINTEGER:
return RDFVocabulary.XSD.POSITIVE_INTEGER.ToString();
case RDFModelEnums.RDFDatatypes.XSD_QNAME:
return RDFVocabulary.XSD.QNAME.ToString();
case RDFModelEnums.RDFDatatypes.XSD_SHORT:
return RDFVocabulary.XSD.SHORT.ToString();
case RDFModelEnums.RDFDatatypes.XSD_STRING:
return RDFVocabulary.XSD.STRING.ToString();
case RDFModelEnums.RDFDatatypes.XSD_TIME:
return RDFVocabulary.XSD.TIME.ToString();
case RDFModelEnums.RDFDatatypes.XSD_TOKEN:
return RDFVocabulary.XSD.TOKEN.ToString();
case RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDBYTE:
return RDFVocabulary.XSD.UNSIGNED_BYTE.ToString();
case RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDINT:
return RDFVocabulary.XSD.UNSIGNED_INT.ToString();
case RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDLONG:
return RDFVocabulary.XSD.UNSIGNED_LONG.ToString();
case RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDSHORT:
return RDFVocabulary.XSD.UNSIGNED_SHORT.ToString();
default:
throw new RDFModelException("Cannot recognize datatype representation of given \"datatype\" parameter because it is unsupported.");
if (datatype.Equals(RDFModelEnums.RDFDatatypes.RDF_XMLLITERAL)) {
return RDFVocabulary.RDF.XML_LITERAL.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.RDFS_LITERAL)) {
return RDFVocabulary.RDFS.LITERAL.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_STRING)) {
return RDFVocabulary.XSD.STRING.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_ANYURI)) {
return RDFVocabulary.XSD.ANY_URI.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_BASE64BINARY)) {
return RDFVocabulary.XSD.BASE64_BINARY.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_BOOLEAN)) {
return RDFVocabulary.XSD.BOOLEAN.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_BYTE)) {
return RDFVocabulary.XSD.BYTE.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_DATE)) {
return RDFVocabulary.XSD.DATE.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_DATETIME)) {
return RDFVocabulary.XSD.DATETIME.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_DECIMAL)) {
return RDFVocabulary.XSD.DECIMAL.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_DOUBLE)) {
return RDFVocabulary.XSD.DOUBLE.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_DURATION)) {
return RDFVocabulary.XSD.DURATION.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_FLOAT)) {
return RDFVocabulary.XSD.FLOAT.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_GDAY)) {
return RDFVocabulary.XSD.G_DAY.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_GMONTH)) {
return RDFVocabulary.XSD.G_MONTH.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_GMONTHDAY)) {
return RDFVocabulary.XSD.G_MONTH_DAY.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_GYEAR)) {
return RDFVocabulary.XSD.G_YEAR.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_GYEARMONTH)) {
return RDFVocabulary.XSD.G_YEAR_MONTH.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_HEXBINARY)) {
return RDFVocabulary.XSD.HEX_BINARY.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_INT)) {
return RDFVocabulary.XSD.INT.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_INTEGER)) {
return RDFVocabulary.XSD.INTEGER.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_LANGUAGE)) {
return RDFVocabulary.XSD.LANGUAGE.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_LONG)) {
return RDFVocabulary.XSD.LONG.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NAME)) {
return RDFVocabulary.XSD.NAME.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NCNAME)) {
return RDFVocabulary.XSD.NCNAME.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_ID)) {
return RDFVocabulary.XSD.ID.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NEGATIVEINTEGER)) {
return RDFVocabulary.XSD.NEGATIVE_INTEGER.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NMTOKEN)) {
return RDFVocabulary.XSD.NMTOKEN.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NONNEGATIVEINTEGER)) {
return RDFVocabulary.XSD.NON_NEGATIVE_INTEGER.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NONPOSITIVEINTEGER)) {
return RDFVocabulary.XSD.NON_POSITIVE_INTEGER.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NORMALIZEDSTRING)) {
return RDFVocabulary.XSD.NORMALIZED_STRING.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_NOTATION)) {
return RDFVocabulary.XSD.NOTATION.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_POSITIVEINTEGER)) {
return RDFVocabulary.XSD.POSITIVE_INTEGER.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_QNAME)) {
return RDFVocabulary.XSD.QNAME.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_SHORT)) {
return RDFVocabulary.XSD.SHORT.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_TIME)) {
return RDFVocabulary.XSD.TIME.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_TOKEN)) {
return RDFVocabulary.XSD.TOKEN.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDBYTE)) {
return RDFVocabulary.XSD.UNSIGNED_BYTE.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDINT)) {
return RDFVocabulary.XSD.UNSIGNED_INT.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDLONG)) {
return RDFVocabulary.XSD.UNSIGNED_LONG.ToString();
}
else if (datatype.Equals(RDFModelEnums.RDFDatatypes.XSD_UNSIGNEDSHORT)) {
return RDFVocabulary.XSD.UNSIGNED_SHORT.ToString();
}
else {
//Unknown datatypes default to instances of "rdfs:Literal"
return RDFVocabulary.RDFS.LITERAL.ToString();
}
}

Expand Down

0 comments on commit 6fbc403

Please sign in to comment.