Package com.google.javascript.jscomp
Class SourceFile.Builder
- java.lang.Object
-
- com.google.javascript.jscomp.SourceFile.Builder
-
- Enclosing class:
- SourceFile
public static class SourceFile.Builder extends java.lang.Object
A builder interface for source files. Allows users to customize the Charset, and the original path of the source file (if it differs from the path on disk).
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SourceFile
buildFromCode(java.lang.String fileName, java.lang.String code)
SourceFile
buildFromFile(java.lang.String fileName)
SourceFile
buildFromInputStream(java.lang.String fileName, java.io.InputStream s)
SourceFile
buildFromPath(java.nio.file.Path path)
SourceFile
buildFromReader(java.lang.String fileName, java.io.Reader r)
SourceFile
buildFromZipEntry(ZipEntryReader zipEntryReader)
SourceFile.Builder
withCharset(java.nio.charset.Charset charset)
Set the charset to use when reading from an input stream or file.SourceFile.Builder
withKind(StaticSourceFile.SourceKind kind)
Set the source kind.SourceFile.Builder
withOriginalPath(java.lang.String originalPath)
Sets a name for this source file that does not need to correspond to a path on disk.
-
-
-
Method Detail
-
withKind
public SourceFile.Builder withKind(StaticSourceFile.SourceKind kind)
Set the source kind.
-
withCharset
public SourceFile.Builder withCharset(java.nio.charset.Charset charset)
Set the charset to use when reading from an input stream or file.
-
withOriginalPath
public SourceFile.Builder withOriginalPath(java.lang.String originalPath)
Sets a name for this source file that does not need to correspond to a path on disk.Allow passing a reasonable human-readable name in cases like for zip files and for generated files with unstable artifact prefixes.
The name must still be unique.
Required for `buildFromZipEntry`. Optional for `buildFromFile` and `buildFromPath`. Forbidden for `buildFromInputStream`, `buildFromReader`, and `buildFromCode`, as those methods already take a source name that does not need to correspond to anything on disk.
-
buildFromFile
@GwtIncompatible("java.io.File") public SourceFile buildFromFile(java.lang.String fileName)
-
buildFromPath
@GwtIncompatible("java.io.File") public SourceFile buildFromPath(java.nio.file.Path path)
-
buildFromZipEntry
@GwtIncompatible("java.io.File") public SourceFile buildFromZipEntry(ZipEntryReader zipEntryReader)
-
buildFromCode
public SourceFile buildFromCode(java.lang.String fileName, java.lang.String code)
-
buildFromInputStream
@GwtIncompatible("java.io.InputStream") public SourceFile buildFromInputStream(java.lang.String fileName, java.io.InputStream s) throws java.io.IOException
- Throws:
java.io.IOException
-
buildFromReader
@GwtIncompatible("java.io.Reader") public SourceFile buildFromReader(java.lang.String fileName, java.io.Reader r) throws java.io.IOException
- Throws:
java.io.IOException
-
-