/** * Returns PatternParser used to parse the conversion string. Subclasses * may override this to return a subclass of PatternParser which recognize * custom conversion characters. * * @since 0.9.0 */ protected PatternParser createPatternParser(String pattern) { return new PatternParser(pattern); }
protected void addConverter(PatternConverter pc) { currentLiteral.setLength(0); // Add the pattern converter to the list. addToList(pc); // Next pattern is assumed to be a literal. state = LITERAL_STATE; // Reset formatting info formattingInfo.reset(); }
/** * Constructs a PatternLayout using the supplied conversion pattern. */ public PatternFormatter(String pattern) { this.pattern = pattern; head = createPatternParser((pattern == null) ? DEFAULT_CONVERSION_PATTERN : pattern).parse(); }
extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if (dOpt != null) dateFormatStr = dOpt; break; case 'X': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);
if (currentLiteral.length() != 0) addToList(new LiteralPatternConverter( currentLiteral.toString())); finalizeConverter(c); else finalizeConverter(c); else finalizeConverter(c); state = LITERAL_STATE; addToList(new LiteralPatternConverter(currentLiteral.toString()));
/** * The option is expected to be in decimal and positive. In case of * error, zero is returned. */ protected int extractPrecisionOption() { String opt = extractOption(); int r = 0; if (opt != null) { try { r = Integer.parseInt(opt); if (r <= 0) { System.err.println("Precision option (" + opt + ") isn't a positive integer."); r = 0; } } catch (NumberFormatException e) { System.err.println("Category option '" + opt + "' not a decimal integer." + e.getMessage()); } } return r; }
extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if (dOpt != null) dateFormatStr = dOpt; case 'X': case 'Z': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);
if (currentLiteral.length() != 0) addToList(new LiteralPatternConverter( currentLiteral.toString())); finalizeConverter(c); else finalizeConverter(c); else finalizeConverter(c); state = LITERAL_STATE; addToList(new LiteralPatternConverter(currentLiteral.toString()));
/** * The option is expected to be in decimal and positive. In case of * error, zero is returned. */ protected int extractPrecisionOption() { String opt = extractOption(); int r = 0; if (opt != null) { try { r = Integer.parseInt(opt); if (r <= 0) { System.err.println("Precision option (" + opt + ") isn't a positive integer."); r = 0; } } catch (NumberFormatException e) { System.err.println("Category option '" + opt + "' not a decimal integer." + e.getMessage()); } } return r; }
extractPrecisionOption()); case 'C': pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption()); String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT; DateFormat df; String dOpt = extractOption(); if (dOpt != null) dateFormatStr = dOpt; break; case 'X': String xOpt = extractOption(); pc = new MDCPatternConverter(formattingInfo, xOpt); currentLiteral.setLength(0); addConverter(pc);
if (currentLiteral.length() != 0) addToList(new LiteralPatternConverter( currentLiteral.toString())); finalizeConverter(c); else finalizeConverter(c); else finalizeConverter(c); state = LITERAL_STATE; addToList(new LiteralPatternConverter(currentLiteral.toString()));
/** * Constructs a PatternLayout using the supplied conversion pattern. */ public PatternFormatter(String pattern) { this.pattern = pattern; head = createPatternParser((pattern == null) ? DEFAULT_CONVERSION_PATTERN : pattern).parse(); }
protected void addConverter(PatternConverter pc) { currentLiteral.setLength(0); // Add the pattern converter to the list. addToList(pc); // Next pattern is assumed to be a literal. state = LITERAL_STATE; // Reset formatting info formattingInfo.reset(); }
/** * Returns PatternParser used to parse the conversion string. Subclasses * may override this to return a subclass of PatternParser which recognize * custom conversion characters. * * @param pattern the pattern * @return the parser * @since 0.9.0 */ protected PatternParser createPatternParser(String pattern) { return new PatternParser(pattern); }
/** * The option is expected to be in decimal and positive. In case of * error, zero is returned. * @return the precision option */ protected int extractPrecisionOption() { String opt = extractOption(); int r = 0; if (opt != null) { try { r = Integer.parseInt(opt); if (r <= 0) { System.err.println("Precision option (" + opt + ") isn't a positive integer."); r = 0; } } catch (NumberFormatException e) { System.err.println("Category option '" + opt + "' not a decimal integer." + e.getMessage()); } } return r; }
/** * Set the <b>ConversionPattern</b> option. This is the string which * controls formatting and consists of a mix of literal content and * conversion specifiers. */ public void setConversionPattern(String conversionPattern) { pattern = conversionPattern; head = createPatternParser(conversionPattern).parse(); }
protected void addConverter(PatternConverter pc) { currentLiteral.setLength(0); // Add the pattern converter to the list. addToList(pc); // Next pattern is assumed to be a literal. state = LITERAL_STATE; // Reset formatting info formattingInfo.reset(); }
/** * Returns PatternParser used to parse the conversion string. Subclasses * may override this to return a subclass of PatternParser which recognize * custom conversion characters. * * @since 0.9.0 */ protected PatternParser createPatternParser(String pattern) { return new PatternParser(pattern); }
/** * Constructs a PatternLayout using the supplied conversion pattern. * @param pattern */ public PatternFormatter(String pattern) { this.pattern = pattern; head = createPatternParser((pattern == null) ? DEFAULT_CONVERSION_PATTERN : pattern).parse(); }
/** * Set the <b>ConversionPattern</b> option. This is the string which * controls formatting and consists of a mix of literal content and * conversion specifiers. * @param conversionPattern */ public void setConversionPattern(String conversionPattern) { pattern = conversionPattern; head = createPatternParser(conversionPattern).parse(); }