Class IndexFileWriter
java.lang.Object
org.checkerframework.afu.scenelib.io.IndexFileWriter
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
formatAnnotationValue
(StringBuilder sb, AnnotationFieldType aft, Object o) Formats a literal argument of an annotation.static String
Deprecated.static void
Writes the annotations inscene
and their definitions toout
in index file format.static void
Writes the annotations inscene
and their definitions to the filefilename
in index file format; seewrite(AScene, Writer)
.
-
Method Details
-
formatAnnotationValue
Deprecated.Formats a literal argument of an annotation. Public to permit re-use in stub-based whole-program inference.- Parameters:
aft
- the type of the annotation fieldo
- the value or values to format- Returns:
- the String representation of the value
-
formatAnnotationValue
Formats a literal argument of an annotation. Public to permit re-use in stub-based whole-program inference.- Parameters:
sb
- where to format the arguments toaft
- the type of the annotation fieldo
- the value or values to format
-
write
Writes the annotations inscene
and their definitions toout
in index file format.An
AScene
can contain several annotations of the same type but different definitions, while an index file can accommodate only a single definition for each annotation type. This has two consequences:- Before writing anything, this method uses a
DefCollector
to ensure that all definitions of each annotation type are identical (modulo unknown array types). If not, aDefException
is thrown. - There is one case in which, even if a scene is written successfully, reading it back in
produces a different scene. Consider a scene containing two annotations of type Foo, each
with an array field bar. In one annotation, bar is empty and of unknown element type (see
AnnotationBuilder.addEmptyArrayField(java.lang.String)
); in the other, bar is of known element type. This method will unify the two definitions of Foo by writing a single definition with known element type. When the index file is read into a new scene, the definitions of both annotations will have known element type, whereas in the original scene, one had unknown element type.
- Throws:
DefException
- Before writing anything, this method uses a
-
write
Writes the annotations inscene
and their definitions to the filefilename
in index file format; seewrite(AScene, Writer)
.- Throws:
IOException
DefException
-