public xDataOutput getUserDataAsStreamNew()
        {
            xDataOutput o = new xDataOutput(8 * 1024);

            o.writeInt(USER_DATA_SIGNATURE);

            int blockCnt = DATA_BLOCK_COUNT;   //  shares + filters + drawing

            if (_unknownBlocks != null)
            {
                blockCnt += _unknownBlocks.size();
            }
            o.writeInt(blockCnt);

            xDataOutput blockData     = shareGroupsBlock();
            xDataOutput blockGainloss = gainlossBlock();
            xDataOutput blockFilters  = filtersBlock();
            xDataOutput blockDrawings = drawingBlock();

            UserDataBlock.saveBlock(DATA_SHARE_GROUPS, blockData, o);
            UserDataBlock.saveBlock(DATA_GAINLOSS, blockGainloss, o);
            UserDataBlock.saveBlock(DATA_FILTERS_WINDOWS_NEW, blockFilters, o);
            UserDataBlock.saveBlock(DATA_DRAWING, blockDrawings, o);

            if (_unknownBlocks != null)
            {
                for (int i = 0; i < _unknownBlocks.size(); i++)
                {
                    UserDataBlock block = (UserDataBlock)_unknownBlocks.elementAt(i);
                    UserDataBlock.saveBlock(block.id, block.dataInput, o);
                }
            }

            return(o);
        }
        //  structure:ver |blockcnt| blocksize:id|data | blocksize:id|data
        public void loadUserData(xDataInput di)
        {
            int signal = di.readInt();

            if (signal != USER_DATA_SIGNATURE)
            {
                return; //  bad file
            }

            int blockCount = di.readInt();

            _unknownBlocks = new xVector();

            if (blockCount < 16)
            {
                for (int i = 0; i < blockCount; i++)
                {
                    UserDataBlock block = UserDataBlock.loadBlock(di);
                    if (block.id == DATA_SHARE_GROUPS)
                    {
                        loadShareGroup(block.dataInput);
                    }
                    else if (block.id == DATA_GAINLOSS)
                    {
                        loadGainload(block.dataInput);
                    }
                    else if (block.id == DATA_FILTERS_WINDOWS)
                    {
                        if (usingFilterWindowsNew)
                        {
                            continue;   //  old version, discard this block
                        }
                        bool ok = loadFilters(block.dataInput);
                        if (!ok)
                        {
                            _unknownBlocks.addElement(block);
                        }
                    }
                    else if (block.id == DATA_FILTERS_WINDOWS_NEW)
                    {
                        usingFilterWindowsNew = true;
                        loadFilters(block.dataInput);
                    }
                    else if (block.id == DATA_DRAWING)
                    {
                        loadDrawings(block.dataInput);
                    }
                    else
                    {
                        _unknownBlocks.addElement(block);
                    }
                }
            }
        }