Package org.eclipse.cdt.core.parser

# Class FileContent

java.lang.Object
org.eclipse.cdt.core.parser.FileContent

public abstract class FileContent extends Object
Abstract class for representing the content of a file. It serves as the input to the preprocessor.

Since:
  5.2
Restriction:
  This class is not intended to be subclassed by clients.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final long`
`NULL_FILE_SIZE`
`static final long`
`NULL_TIMESTAMP`

## Constructor Summary

Constructors
Constructor
Description
`FileContent()`

## Method Summary

Modifier and Type
Method
Description
`static FileContent`
`adapt(CodeReader reader)`
Deprecated.
`static FileContent`
`create(String filePath, boolean isSource, char[] contents)`
Creates a file content object for a fixed buffer.
`static FileContent`
`create(String filePath, char[] contents)`
Creates a file content object for a fixed buffer.
`static FileContent`
`create(IIndexFileLocation ifl)`
Creates a file content object for an index file location.
`static FileContent`
`create(ITranslationUnit tu)`
Creates a file content object for a translation-unit, which may be a working copy.
`static FileContent`
`create(org.eclipse.core.resources.IFile file)`
Creates a file content for a workspace header file.
`static FileContent`
`createForExternalFileLocation(String fileLocation)`
Creates a file content object for a header file that is not part of the workspace.
`static FileContent`
`createForExternalFileLocation(String fileLocation, boolean isSource, String encoding)`
Creates a file content object for a header or a source file that is not part of the workspace.
`static FileContent`
`createForExternalFileLocation(String fileLocation, String encoding)`
Creates a file content object for a header file that is not part of the workspace.
`abstract long`
`getContentsHash()`
Returns a 64-bit hash value of the file contents.
`abstract String`
`getFileLocation()`
Returns the location of this file content as it will appear in `IASTFileLocation.getFileName()`
`abstract long`
`getFileSize()`
Returns the size of the file, or NULL_FILE_SIZE if the content does not originate from a file.
`abstract long`
`getReadTime()`
Returns time when the file was read.
`abstract long`
`getTimestamp()`
Returns the modification time of the file containing the content, or NULL_TIMESTAMP if the content does not originate from a file.
`abstract boolean`
`hasError()`
Returns `true` if there were I/O errors while retrieving contents of this file.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### NULL_TIMESTAMP

public static final long NULL_TIMESTAMP

Since:
  5.4
See Also:
  - Constant Field Values

### NULL_FILE_SIZE

public static final long NULL_FILE_SIZE

Since:
  5.4
See Also:
  - Constant Field Values

## Constructor Details

### FileContent

public FileContent()

## Method Details

### getFileLocation

public abstract String getFileLocation()
Returns the location of this file content as it will appear in `IASTFileLocation.getFileName()`

### getTimestamp

public abstract long getTimestamp()
Returns the modification time of the file containing the content, or NULL_TIMESTAMP if the content does not originate from a file. A zero value may be returned if there was an I/O error.

Since:
  5.4

### getReadTime

public abstract long getReadTime()
Returns time when the file was read. Corresponds to the start of reading.

Returns:
  time before reading started in milliseconds since epoch
Since:
  5.4

### getFileSize

public abstract long getFileSize()
Returns the size of the file, or NULL_FILE_SIZE if the content does not originate from a file. A zero value may be returned if there was an I/O error.

Since:
  5.4

### hasError

public abstract boolean hasError()
Returns `true` if there were I/O errors while retrieving contents of this file.

Since:
  5.4

### getContentsHash

public abstract long getContentsHash()
Returns a 64-bit hash value of the file contents.

### create

public static FileContent create(String filePath, char[] contents)
Creates a file content object for a fixed buffer.

Parameters:
  `filePath` - the path of the file as it will appear in `IASTFileLocation.getFileName()`
  `contents` - the actual content.

### create

public static FileContent create(String filePath, boolean isSource, char[] contents)
Creates a file content object for a fixed buffer.

Parameters:
  `filePath` - the path of the file as it will appear in `IASTFileLocation.getFileName()`
  `contents` - the actual content.
Since:
  6.3

### create

public static FileContent create(ITranslationUnit tu)
Creates a file content object for a translation-unit, which may be a working copy.

### create

public static FileContent create(IIndexFileLocation ifl)
Creates a file content object for an index file location.

### create

public static FileContent create(org.eclipse.core.resources.IFile file)
Creates a file content for a workspace header file.

### createForExternalFileLocation

public static FileContent createForExternalFileLocation(String fileLocation)
Creates a file content object for a header file that is not part of the workspace.

### createForExternalFileLocation

public static FileContent createForExternalFileLocation(String fileLocation, String encoding)
Creates a file content object for a header file that is not part of the workspace.

Since:
  5.3

### createForExternalFileLocation

public static FileContent createForExternalFileLocation(String fileLocation, boolean isSource, String encoding)
Creates a file content object for a header or a source file that is not part of the workspace.

Since:
  6.3

### adapt

@Deprecated public static FileContent adapt(CodeReader reader)
Deprecated.
Provided to achieve backwards compatibility.