Class ArtifactAstSerializerMetadataSerializer
java.lang.Object
org.mule.runtime.ast.internal.serialization.ArtifactAstSerializerMetadataSerializer
This class deals with the adding/reading into/from an input stream the metadata associated to
ArtifactAst serialization. This metadata is generated during the artifact's serialization and
must be added to the resulting InputStream so that it can be then read in order to use the correct deserializing
implementation when deserializing.
The metadata is added to the stream in the form of a header string in the first line of the InputStream. This header
string is composed by the serializer's id and the version, delimited by a pound sign (#). The max allowed length of the header
string is 1001 as determined by the MAX_HEADER_LINE_LENGTH constant.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddArtifactAstSerializerMetadataToInputStream(InputStream inputStream, ArtifactAstSerializerMetadata artifactAstSerializerMetadata) This method serializes theArtifactAstSerializerMetadatainto a header string and adds it as a first line to the provided serializedArtifactAstwhich should be anInputStreamThis method reads the metadata from anInputStreamby reading the first line which should be a header string in a serializedArtifactAst).
-
Field Details
-
END_HEADER_DELIMITER
public static final char END_HEADER_DELIMITER- See Also:
-
DELIMITER
- See Also:
-
-
Constructor Details
-
ArtifactAstSerializerMetadataSerializer
public ArtifactAstSerializerMetadataSerializer()
-
-
Method Details
-
readArtifactAstSerializerMetadataFromInputStream
public ArtifactAstSerializerMetadata readArtifactAstSerializerMetadataFromInputStream(InputStream inputStream) throws IOException This method reads the metadata from anInputStreamby reading the first line which should be a header string in a serializedArtifactAst). This header string is composed by the serializer's id and the version, delimited by a pound sign (#).The max allowed length of the header string is 1001 as determined by the
MAX_HEADER_LINE_LENGTHconstant. Since this method only read the first line, the rest of the input stream will be still available for consumption.- Parameters:
inputStream- a serializedArtifactAstgenerated by anArtifactAstSerializer- Returns:
- a
ArtifactAstSerializerMetadatainstance containing the id and version indicated in the input stream's metadata. - Throws:
IOException- If an I/O error occurs
-
addArtifactAstSerializerMetadataToInputStream
public InputStream addArtifactAstSerializerMetadataToInputStream(InputStream inputStream, ArtifactAstSerializerMetadata artifactAstSerializerMetadata) This method serializes theArtifactAstSerializerMetadatainto a header string and adds it as a first line to the provided serializedArtifactAstwhich should be anInputStream- Parameters:
inputStream- the serializedArtifactAstcreated with anArtifactAstSerializerartifactAstSerializerMetadata- theArtifactAstSerializerMetadatathat represents the information associated with theArtifactAstSerializerused to generate the givenInputStream- Returns:
- an
InputStreamwhose first line is the serializedArtifactAstSerializerMetadataand is followed by the contents of the given serializedArtifactAst'sInputStream
-