Search in sources :

Example 1 with NoWriterForLangException

use of org.apache.jena.shared.NoWriterForLangException in project jena by apache.

the class TestIO_JenaWriters method testResetJena.

@Test
public void testResetJena() {
    IO_Jena.wireIntoJena();
    IO_Jena.resetJena();
    RDFWriterF writerF = new RDFWriterFImpl();
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter().getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("RDF/XML").getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("RDF/XML-ABBREV").getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("N-TRIPLE").getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("N-Triples").getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("N-TRIPLE").getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter("N3").getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterPrettyPrinter).getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterPlain).getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterTriples).getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.n3WriterTriplesAlt).getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriter).getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriterAlt1).getClass());
    assertNotEquals(RDFWriterRIOT.class, writerF.getWriter(N3JenaWriter.turtleWriterAlt2).getClass());
    try {
        writerF.getWriter("NT");
        fail("Exception expected");
    } catch (NoWriterForLangException ex) {
    }
    try {
        writerF.getWriter("RDF/JSON");
        fail("Exception expected");
    } catch (NoWriterForLangException ex) {
    }
    try {
        writerF.getWriter("RDFJSON");
        fail("Exception expected");
    } catch (NoWriterForLangException ex) {
    }
    IO_Jena.wireIntoJena();
}
Also used : RDFWriterFImpl(org.apache.jena.rdf.model.impl.RDFWriterFImpl) RDFWriterF(org.apache.jena.rdf.model.RDFWriterF) NoWriterForLangException(org.apache.jena.shared.NoWriterForLangException) Test(org.junit.Test)

Example 2 with NoWriterForLangException

use of org.apache.jena.shared.NoWriterForLangException in project jena by apache.

the class rdfcat method getCheckedLanguage.

/**
         Answer the full, checked, language name expanded from <code>shortName</code>.
        The shortName is expanded according to the table of abbreviations [below].
        It is then checked against RDFWriterFImpl's writer table [this is hacky but
        at the moment it's the most available interface] and the NoWriter exception
        trapped and replaced by the original IllegalArgument exception.
    */
public static String getCheckedLanguage(String shortLang) {
    String fullLang = unabbreviate.get(shortLang);
    String tryLang = (fullLang == null ? shortLang : fullLang);
    try {
        new RDFWriterFImpl().getWriter(tryLang);
    } catch (NoWriterForLangException e) {
        throw new IllegalArgumentException("'" + shortLang + "' is not recognised as a legal output format");
    }
    return tryLang;
}
Also used : RDFWriterFImpl(org.apache.jena.rdf.model.impl.RDFWriterFImpl) NoWriterForLangException(org.apache.jena.shared.NoWriterForLangException)

Aggregations

RDFWriterFImpl (org.apache.jena.rdf.model.impl.RDFWriterFImpl)2 NoWriterForLangException (org.apache.jena.shared.NoWriterForLangException)2 RDFWriterF (org.apache.jena.rdf.model.RDFWriterF)1 Test (org.junit.Test)1