Package com.cedarsoft

Examples of com.cedarsoft.Version


*/
public class ExtraSerializer extends AbstractStaxSerializer<Extra> {
  //START SNIPPET: fieldsAndConstructors

  public ExtraSerializer( MoneySerializer moneySerializer ) {
    super( "extra", "http://thecompany.com/test/extra", new VersionRange( new Version( 1, 5, 0 ), new Version( 1, 5, 0 ) ) );
    //We choose another version number. Maybe this is an old serializer that has been created within another project.

    add( moneySerializer ).responsibleFor( Money.class )
      .map( 1, 5, 0 ).toDelegateVersion( 1, 0, 0 )
    ;
View Full Code Here


*
*/
//START SNIPPET: body
public class MoneySerializer extends AbstractStaxSerializer<Money> {
  public MoneySerializer() {
    super( "money", "http://thecompany.com/test/money", new VersionRange( new Version( 1, 0, 0 ), new Version( 1, 0, 0 ) ) );
  }
View Full Code Here

*/
public class ExtraSerializer extends AbstractStaxSerializer<Extra> {
  //START SNIPPET: fieldsAndConstructors

  public ExtraSerializer( MoneySerializer moneySerializer ) {
    super( "extra", "http://thecompany.com/test/extra", new VersionRange( new Version( 1, 5, 0 ), new Version( 1, 5, 1 ) ) );
    //We choose another version number. Maybe this is an old serializer that has been created within another project.

    add( moneySerializer ).responsibleFor( Money.class )
      .map( 1, 5, 0 ).toDelegateVersion( 1, 0, 0 )
      .map( 1, 5, 1 ).toDelegateVersion( 1, 0, 1 ) //this is the only line that has to be added! Everything else (below) stays the same!
View Full Code Here

* Writing is only supported for the latest file.
*/
public class MoneySerializer extends AbstractStaxSerializer<Money> {
  public MoneySerializer() {
    //This serializer supports an old version, too
    super( "money", "http://thecompany.com/test/money", new VersionRange( new Version( 1, 0, 0 ), new Version( 1, 0, 1 ) ) );
  }
View Full Code Here

    //So it seems easier to add just one if/else.
    //If a serializer evolves further a switch to the strategy pattern might be done. A simple map holding the strategies should do it.


    //The common case - current version
    if ( formatVersion.equals( new Version( 1, 0, 1 ) ) ) {
      int cents = Integer.parseInt( deserializeFrom.getAttributeValue( null, "cents" ) );

      //We have to close the tag! Every stax based serializer has to close its tag
      //getText does this automatically for us. But when only using attributes, we have to close it manually.
      closeTag( deserializeFrom );

      return new Money( cents );

      //The old format that does not use an attribute but text instead
    } else if ( formatVersion.equals( new Version( 1, 0, 0 ) ) ) {
      int cents = Integer.parseInt( getText( deserializeFrom ) );

      //We don't have to close the tag. The getText method does that for us
      return new Money( cents );
View Full Code Here

*/
public class ModelSerializer extends AbstractStaxSerializer<Model> {
  //START SNIPPET: constructor

  public ModelSerializer() {
    super( "model", "http://thecompany.com/test/model", new VersionRange( new Version( 1, 0, 0 ), new Version( 1, 0, 0 ) ) );
  }
View Full Code Here

  public T deserialize( @NotNull InputStream in ) throws IOException, VersionException {
    try {
      Document document = new SAXBuilder().build( in );

      String namespaceURI = document.getRootElement().getNamespaceURI();
      Version formatVersion = parseVersionFromNamespaceUri( namespaceURI );

      Version.verifyMatch( getFormatVersion(), formatVersion );

      return deserialize( document.getRootElement(), formatVersion );
    } catch ( JDOMException e ) {
View Full Code Here

  @NotNull
  @NonNls
  private static final String ATTRIBUTE_DELIMITER = "delimiter";

  public ExtensionSerializer() {
    super( "extension", "http://www.cedarsoft.com/file/extension", new VersionRange( new Version( 1, 0, 0 ), new Version( 1, 0, 0 ) ) );
  }
View Full Code Here

  @NotNull
  public Application deserialize( @NotNull XMLStreamReader deserializeFrom, @NotNull Version formatVersion ) throws IOException, XMLStreamException {
    String name = getChildText( deserializeFrom, ELEMENT_NAME );

    nextTag( deserializeFrom, ELEMENT_VERSION );
    Version applicationVersion = versionSerializer.deserialize( deserializeFrom, VERSION_VERSION_SERIALIZER );
    closeTag( deserializeFrom );

    return new Application( name, applicationVersion );
  }
View Full Code Here

  @NotNull
  @NonNls
  private static final String ATTRIBUTE_DELIMITER = "delimiter";

  public ExtensionSerializer() {
    super( "extension", "http://www.cedarsoft.com/file/extension", new VersionRange( new Version( 1, 0, 0 ), new Version( 1, 0, 0 ) ) );
  }
View Full Code Here

TOP

Related Classes of com.cedarsoft.Version

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.