/** * Creates bulk load CSV parser. * * @param format Format options (parsed from COPY command). */ public BulkLoadCsvParser(BulkLoadCsvFormat format) { try { Charset charset = format.inputCharsetName() == null ? BulkLoadFormat.DEFAULT_INPUT_CHARSET : Charset.forName(format.inputCharsetName()); inputBlock = new CharsetDecoderBlock(charset); } catch (IllegalCharsetNameException e) { throw new IgniteSQLException("Unknown charset name: '" + format.inputCharsetName() + "': " + e.getMessage()); } catch (UnsupportedCharsetException e) { throw new IgniteSQLException("Charset is not supported: '" + format.inputCharsetName() + "': " + e.getMessage()); } collectorBlock = new StrListAppenderBlock(); // Handling of the other options is to be implemented in IGNITE-7537. inputBlock.append(new LineSplitterBlock(format.lineSeparator())) .append(new CsvLineProcessorBlock(format.fieldSeparator(), format.quoteChars())) .append(collectorBlock); }
/** * Gets the charset belonging to the given {@code encoding}. * @param encoding The encoding - if {@code null} then the default platform * encoding is used. * @return The charset belonging to the given {@code encoding} or the platform default. * Never {@code null}. */ private static Charset getCharset(String encoding) { Charset charset = null; if (encoding != null) { try { charset = Charset.forName(encoding); } catch(IllegalCharsetNameException e) { LOG.log(Level.WARNING, "JNA Warning: Encoding ''{0}'' is unsupported ({1})", new Object[]{encoding, e.getMessage()}); } catch(UnsupportedCharsetException e) { LOG.log(Level.WARNING, "JNA Warning: Encoding ''{0}'' is unsupported ({1})", new Object[]{encoding, e.getMessage()}); } } if (charset == null) { LOG.log(Level.WARNING, "JNA Warning: Using fallback encoding {0}", Native.DEFAULT_CHARSET); charset = Native.DEFAULT_CHARSET; } return charset; }
@Override public String validate(String newValueCandidate) { try { Charset.forName(newValueCandidate); return ""; } catch (IllegalCharsetNameException e) { return "Illegal charset: " + e.getMessage(); } catch (UnsupportedCharsetException e) { return "Unsupported charset: " + e.getMessage(); } }
public String validate(String newValueCandidate) { try { Charset.forName(newValueCandidate); return ""; } catch (IllegalCharsetNameException e) { return "Illegal charset: " + e.getMessage(); } catch (UnsupportedCharsetException e) { return "Unsupported charset: " + e.getMessage(); } }
@Override public String validate(String newValueCandidate) { try { Charset.forName(newValueCandidate); return ""; } catch (IllegalCharsetNameException e) { return "Illegal charset: " + e.getMessage(); } catch (UnsupportedCharsetException e) { return "Unsupported charset: " + e.getMessage(); } }
public Charset getEncoding(FileObject file) { assert file != null; assert file.equals(getPrimaryFile()); String charsetName = getFileEncoding(); try { return Charset.forName(charsetName); } catch (IllegalCharsetNameException ichse) { //the jsp templates contains the ${encoding} property //so the ICHNE is always thrown for them, just ignore Boolean template = (Boolean)file.getAttribute("template");//NOI18N if(template == null || !template.booleanValue()) { Logger.getLogger("global").log(Level.INFO, "Detected illegal charset name in file " + file.getNameExt() + " (" + ichse.getMessage() + ")"); //NOI18N } } catch (UnsupportedCharsetException uchse) { Logger.getLogger("global").log(Level.INFO, "Detected unsupported charset name in file " + file.getNameExt() + " (" + uchse.getMessage() + ")"); //NOI18N } return null; }
/** * Creates bulk load CSV parser. * * @param format Format options (parsed from COPY command). */ public BulkLoadCsvParser(BulkLoadCsvFormat format) { try { Charset charset = format.inputCharsetName() == null ? BulkLoadFormat.DEFAULT_INPUT_CHARSET : Charset.forName(format.inputCharsetName()); inputBlock = new CharsetDecoderBlock(charset); } catch (IllegalCharsetNameException e) { throw new IgniteSQLException("Unknown charset name: '" + format.inputCharsetName() + "': " + e.getMessage()); } catch (UnsupportedCharsetException e) { throw new IgniteSQLException("Charset is not supported: '" + format.inputCharsetName() + "': " + e.getMessage()); } collectorBlock = new StrListAppenderBlock(); // Handling of the other options is to be implemented in IGNITE-7537. inputBlock.append(new LineSplitterBlock(format.lineSeparator())) .append(new CsvLineProcessorBlock(format.fieldSeparator(), format.quoteChars())) .append(collectorBlock); }