class ValueMetaBase implements ValueMetaInterface {

  @Override
  public String getDataXML( Object object ) throws IOException {
    StringBuilder xml = new StringBuilder();

    String string;

    if ( object != null ) {
      try {
        switch ( storageType ) {
          case STORAGE_TYPE_NORMAL:
            // Handle Content -- only when not NULL
            //
            switch ( getType() ) {
              case TYPE_STRING:
                string = (String) object;
                break;
              case TYPE_NUMBER:
                string = Double.toString( (Double) object );
                break;
              case TYPE_INTEGER:
                string = Long.toString( (Long) object );
                break;
              case TYPE_DATE:
                string = XMLHandler.date2string( (Date) object );
                break;
              case TYPE_BIGNUMBER:
                string = ( (BigDecimal) object ).toString();
                break;
              case TYPE_BOOLEAN:
                string = Boolean.toString( (Boolean) object );
                break;
              case TYPE_BINARY:
                string = XMLHandler.encodeBinaryData( (byte[]) object );
                break;
              case TYPE_TIMESTAMP:
                string = XMLHandler.timestamp2string( (Timestamp)  object );
                break;
              case TYPE_INET:
                string = ( (InetAddress) object ).toString();
                break;
              default:
                throw new IOException( toString() + " : Unable to serialize data type to XML " + getType() );
            }

            break;

          case STORAGE_TYPE_BINARY_STRING:
            // Handle binary string content -- only when not NULL
            // In this case, we opt not to convert anything at all for speed.
            // That way, we can save on CPU power.
            // Since the streams can be compressed, volume shouldn't be an issue
            // at all.
            //
            string = XMLHandler.addTagValue( "binary-string", (byte[]) object );
            xml.append( XMLHandler.openTag( XML_DATA_TAG ) ).append( string ).append( XMLHandler.closeTag( XML_DATA_TAG ) );
            return xml.toString();

          case STORAGE_TYPE_INDEXED:
            // Just an index
            string = XMLHandler.addTagValue( "index-value", (Integer) object );
            break;

          default:
            throw new IOException( toString() + " : Unknown storage type " + getStorageType() );
        }
      } catch ( ClassCastException e ) {
        throw new RuntimeException( toString() + " : There was a data type error: the data type of "
            + object.getClass().getName() + " object [" + object + "] does not correspond to value meta ["
            + toStringMeta() + "]", e );
      } catch ( Exception e ) {
        throw new RuntimeException( toString() + " : there was a value XML encoding error", e );
      }
    } else {
      // If the object is null: give an empty string
      //
      string = "";
    }
    xml.append( XMLHandler.addTagValue( XML_DATA_TAG, string ) );

    return xml.toString();
  }

  public  ValueMetaBase();
  public  ValueMetaBase( String name );
  public  ValueMetaBase( String name, int type );
  public  ValueMetaBase( String name, int type, int length, int precision );
  public  ValueMetaBase( Node node );
  @Deprecated public  ValueMetaBase( DataInputStream inputStream );
  @Deprecated public  ValueMetaBase( String name, int type, int storageType );

}