/** 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; }
private static RDFWriter getWriter(CommandLine cmd) { RDFWriterF writerFactory = new RDFWriterFImpl(); RDFWriter writer = writerFactory.getWriter("RDF/XML"); if (cmd.hasOption("format")) { if (!cmd.getOptionValue("format").equalsIgnoreCase("NQUADS")) { try { writer = writerFactory.getWriter(cmd .getOptionValue("format")); } catch (NoWriterForLangException e) { System.out.println("Invalid format option selected!"); e.printStackTrace(); System.exit(0); } } } return writer; }