public void replayOn(LoggingAdvisingAppendable appendable) throws IOException { if (commands != null) { for (Object o : getCommandsAndAddPendingStringData()) { if (o instanceof String) { appendable.append((String) o); } else if (o instanceof LoggingFunctionCommand) { ((LoggingFunctionCommand) o).replayOn(appendable); } else if (o == EXIT_LOG_STATEMENT_MARKER) { appendable.exitLoggableElement(); } else if (o instanceof LogStatement) { appendable.enterLoggableElement((LogStatement) o); } else if (o instanceof ContentKind) { appendable.setSanitizedContentKind((ContentKind) o); } else if (o instanceof Dir) { appendable.setSanitizedContentDirectionality((Dir) o); } else if (o == SET_SANITIZED_CONTENT_DIRECTIONALITY_NULL_MARKER) { appendable.setSanitizedContentDirectionality(null); } else { throw new AssertionError("unexpected command object: " + o); } } } else { appendable.append(delegate); } }
@Override public LoggingAdvisingAppendable appendLoggingFunctionInvocation( LoggingFunctionInvocation funCall, ImmutableList<Function<String, String>> escapers) throws IOException { delegate.appendLoggingFunctionInvocation(funCall, escapers); return this; } }
BidiWrapAppendable( LoggingAdvisingAppendable delegate, BidiGlobalDir globalDir, WrapType wrapType) { super(delegate); this.globalDir = globalDir; this.wrapType = Preconditions.checkNotNull(wrapType); buffer = new StringBuilder(); commandBuffer = LoggingAdvisingAppendable.buffering(); }
@Override public void render(LoggingAdvisingAppendable appendable) throws IOException { appendable .setSanitizedContentKind(getContentKind()) .setSanitizedContentDirectionality(getContentDirection()) .append(content); }
@Override public LoggingAdvisingAppendable append(CharSequence csq, int start, int end) throws IOException { delegate.append(csq, start, end); return this; }
@Override public LoggingAdvisingAppendable exitLoggableElement() { delegate.exitLoggableElement(); return this; }
@Override protected void notifyContentDirectionality(@Nullable Dir contentDir) throws IOException { delegate.setSanitizedContentDirectionality(contentDir); }
@Override protected void notifyContentKind(ContentKind kind) throws IOException { // |truncate converts all input to TEXT, so label the output appendable as such. This isn't // strictly necessary, as the autoescaper will have already made sure the output is properly // escaped, but it helps make the intent clear. delegate.setSanitizedContentKind(ContentKind.TEXT); }
@Override public LoggingAdvisingAppendable enterLoggableElement(LogStatement statement) { delegate.enterLoggableElement(statement); return this; }
@Override public void render(LoggingAdvisingAppendable appendable) throws IOException { appendable .setSanitizedContentKind(getContentKind()) .setSanitizedContentDirectionality(getContentDirection()); thunk.render(appendable); }
@Override public final void render(Appendable appendable) throws IOException { render(LoggingAdvisingAppendable.delegating(appendable)); }
/** * Marks the directionality of this appendable. All the {@link #append} commands should be * considered to be content of the given directionality that has already been sanitized. * * <p>Calls after the first call to this are ignored. */ public final LoggingAdvisingAppendable setSanitizedContentDirectionality(@Nullable Dir contentDir) throws IOException { if (!contentDirSet) { contentDirSet = true; this.contentDir = contentDir; notifyContentDirectionality(contentDir); } return this; }
/** * Marks the content kind of this appendable. All the {@link #append} commands should be * considered to be content of the given kind that has already been sanitized. * * <p>Calls after the first call to this are ignored. In the case of an appendable's content kind * changing, we trust that the autoescaper has inserted the correct escape directives, so we do * not need to track this in the appendable. */ public final LoggingAdvisingAppendable setSanitizedContentKind(ContentKind kind) throws IOException { checkNotNull(kind); if (this.kind == null) { this.kind = kind; notifyContentKind(kind); } return this; }
@Override public void render(LoggingAdvisingAppendable appendable) throws IOException { appendable .setSanitizedContentKind(getContentKind()) .setSanitizedContentDirectionality(getContentDirection()) .append(content); }
@Override public LoggingAdvisingAppendable append(char c) throws IOException { delegate.append(c); return this; }
@Override public LoggingAdvisingAppendable exitLoggableElement() { delegate.exitLoggableElement(); return this; }
@Override protected void notifyContentDirectionality(@Nullable Dir contentDir) throws IOException { delegate.setSanitizedContentDirectionality(contentDir); }
@Override protected void notifyContentKind(ContentKind kind) throws IOException { // |truncate converts all input to TEXT, so label the output appendable as such. This isn't // strictly necessary, as the autoescaper will have already made sure the output is properly // escaped, but it helps make the intent clear. delegate.setSanitizedContentKind(ContentKind.TEXT); }
@Override public LoggingAdvisingAppendable enterLoggableElement(LogStatement statement) { delegate.enterLoggableElement(statement); return this; }
@Override public final void render(Appendable appendable) throws IOException { render(LoggingAdvisingAppendable.delegating(appendable)); }