/** * Creates a SanitizedContent object. * * <p>Package-private. Ideally, if one is available, you should use an existing serializer, * sanitizer, verifier, or extractor that returns SanitizedContent objects. Or, you can use * UnsafeSanitizedContentOrdainer in this package, to make it clear that creating these objects * from arbitrary content is risky unless you absolutely know the input is safe. See the comments * in UnsafeSanitizedContentOrdainer for more recommendations. * * @param content A string of valid content with the given content kind. * @param kind Describes the kind of string that content is. * @param dir The content's direction; null if unknown and thus to be estimated when necessary. */ static SanitizedContent create(String content, ContentKind kind, @Nullable Dir dir) { checkArgument( kind != ContentKind.TEXT, "Use UnsanitizedString for SanitizedContent with a kind of TEXT"); if (Flags.stringIsNotSanitizedContent()) { return new SanitizedContent(content, kind, dir); } return SanitizedCompatString.create(content, kind, dir); }
/** Creates a SanitizedContent object with default direction. */ static SanitizedContent create(String content, ContentKind kind) { checkArgument( kind != ContentKind.TEXT, "Use UnsanitizedString for SanitizedContent with a kind of TEXT"); if (Flags.stringIsNotSanitizedContent()) { return new SanitizedContent(content, kind, kind.getDefaultDir()); } return SanitizedCompatString.create(content, kind, kind.getDefaultDir()); }