Class ModelPersistence
- java.lang.Object
 - 
- jetbrains.mps.smodel.persistence.def.ModelPersistence
 
 
- 
public class ModelPersistence extends Object
ModelPersistence handles all XML persistence versions supported by current MPS installation. The range of supported versions is [FIRST_SUPPORTED_VERSION, LAST_VERSION]. MPS must be able to read any of these persistence versions and write the last one. The "previous" persistence version being writable is not a must, but it is better to support it to have less moments when we accidentally need to convert between persistence versions. E.g. to be able to fix model before migration from previous version and save it in old persistence, or to merge two non-migrated branches without converting persistence. It is supposed that only one or two persistence versions are supported: the last persistence used by previous MPS version (to read and migrate project created in the previous version, and, sometimes, a new persistence introduced in current version. NOTE this is not mandatory, we can support more than two versions. We can't support full functionality on all created persistences as the change in persistence is actually made because of change in SModel. So, we can't actual SModel to a very old persistence or even read all the information from old persistence into a new SModel. The good thing about that is that we can "partially" support very old persistence versions where we might need such a support. See VCSPersistenceSupport for an example. 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModelPersistence.HeaderOnlyHandler 
- 
Field Summary
Fields Modifier and Type Field Description static intFIRST_SUPPORTED_VERSIONstatic intLAST_VERSIONstatic StringMODELstatic StringMODEL_UIDstatic StringNAMEstatic StringPERSISTENCEstatic StringPERSISTENCE_VERSIONstatic StringREFstatic StringVALUE 
- 
Constructor Summary
Constructors Constructor Description ModelPersistence() 
- 
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Map<String,String>calculateHashes(String content)static List<LineContent>getLineToContentMap(String content)static SModelDatagetModelData(InputStream input)static IModelPersistencegetPersistence(int version)static voidindex(byte[] data, IndexAwareModelFactory.Callback newConsumer)Deprecated.useindex(InputStream, Callback)insteadstatic voidindex(InputStream data, IndexAwareModelFactory.Callback newConsumer)static booleanisSupported(int version)static SModelHeaderloadDescriptor(StreamDataSource source)static SModelHeaderloadDescriptor(InputSource source)static StringmodelToString(SModel model)static DefaultSModelreadModel(String content, boolean interfaceOnly)static ModelLoadResultreadModel(SModelHeader header, StreamDataSource dataSource, ModelLoadingState state)static DefaultSModelreadModel(StreamDataSource source, boolean interfaceOnly)static org.jdom.DocumentsaveModel(SModel sourceModel)Serialize model into xml, conformant to actual model's persistence version, if any, or current persistence version otherwise.static DefaultSModelsaveModel(SModel model, StreamDataSource source, int persistenceVersion) 
 - 
 
- 
- 
Field Detail
- 
MODEL
public static final String MODEL
- See Also:
 - Constant Field Values
 
 
- 
REF
public static final String REF
- See Also:
 - Constant Field Values
 
 
- 
MODEL_UID
public static final String MODEL_UID
- See Also:
 - Constant Field Values
 
 
- 
NAME
public static final String NAME
- See Also:
 - Constant Field Values
 
 
- 
VALUE
public static final String VALUE
- See Also:
 - Constant Field Values
 
 
- 
PERSISTENCE
public static final String PERSISTENCE
- See Also:
 - Constant Field Values
 
 
- 
PERSISTENCE_VERSION
public static final String PERSISTENCE_VERSION
- See Also:
 - Constant Field Values
 
 
- 
FIRST_SUPPORTED_VERSION
public static final int FIRST_SUPPORTED_VERSION
- See Also:
 - Constant Field Values
 
 
- 
LAST_VERSION
public static final int LAST_VERSION
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
isSupported
public static boolean isSupported(int version)
 
- 
getPersistence
@Nullable public static IModelPersistence getPersistence(int version)
 
- 
loadDescriptor
@NotNull public static SModelHeader loadDescriptor(InputSource source) throws ModelReadException
- Throws:
 ModelReadException
 
- 
loadDescriptor
@NotNull public static SModelHeader loadDescriptor(StreamDataSource source) throws ModelReadException
- Throws:
 ModelReadException
 
- 
readModel
@NotNull public static ModelLoadResult readModel(@NotNull SModelHeader header, @NotNull StreamDataSource dataSource, ModelLoadingState state) throws ModelReadException
- Throws:
 ModelReadException
 
- 
getLineToContentMap
@Nullable public static List<LineContent> getLineToContentMap(String content) throws ModelReadException
- Throws:
 ModelReadException
 
- 
saveModel
public static DefaultSModel saveModel(@NotNull SModel model, @NotNull StreamDataSource source, int persistenceVersion) throws IOException
- Throws:
 IOException
 
- 
saveModel
@NotNull public static org.jdom.Document saveModel(@NotNull SModel sourceModel)
Serialize model into xml, conformant to actual model's persistence version, if any, or current persistence version otherwise. The method doesn't update persistence version of the model (as it used to do) 
- 
calculateHashes
public static Map<String,String> calculateHashes(String content) throws ModelReadException
- Throws:
 ModelReadException
 
- 
readModel
@NotNull public static DefaultSModel readModel(@NotNull StreamDataSource source, boolean interfaceOnly) throws ModelReadException
- Throws:
 ModelReadException
 
- 
readModel
@NotNull public static DefaultSModel readModel(@NotNull String content, boolean interfaceOnly) throws ModelReadException
- Throws:
 ModelReadException
 
- 
index
@Deprecated public static void index(byte[] data, IndexAwareModelFactory.Callback newConsumer) throws IOException
Deprecated.useindex(InputStream, Callback)instead- Throws:
 IOException
 
- 
index
public static void index(InputStream data, IndexAwareModelFactory.Callback newConsumer) throws IOException
- Throws:
 IOException
 
- 
getModelData
public static SModelData getModelData(@NotNull InputStream input) throws IOException
- Throws:
 IOException
 
 - 
 
 -