@Test public void testConvertLiteral_validLanguage() { final String expectedData = "Hello"; for (final String language : LANGUAGE_CODES) { assertTrue(Literals.isValidLanguageTag(language)); final Literal literal = VF.createLiteral(expectedData, language); final RyaType ryaType = RdfToRyaConversions.convertLiteral(literal); assertEquals(RDF.LANGSTRING, ryaType.getDataType()); assertEquals(expectedData, ryaType.getData()); assertEquals(language, ryaType.getLanguage()); final RyaType expectedRyaType = new RyaType(RDF.LANGSTRING, expectedData, language); assertEquals(expectedRyaType, ryaType); } }
public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); } }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }  }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }  static RyaIRI convertIRI(final IRI iri); static RyaType convertLiteral(final Literal literal); static RyaType convertValue(final Value value); static RyaIRI convertResource(final Resource resource); static RyaStatement convertStatement(final Statement statement); }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }  static RyaIRI convertIRI(final IRI iri); static RyaType convertLiteral(final Literal literal); static RyaType convertValue(final Value value); static RyaIRI convertResource(final Resource resource); static RyaStatement convertStatement(final Statement statement);  }