Package com.sun.star.container

Examples of com.sun.star.container.XMap


        Type keyType = AnyConverter.getType( _keys[0] );
        Type valueType = AnyConverter.getType( _values[0] );

        // create a map for the given types
        XMap map = com.sun.star.container.EnumerableMap.create( param.getComponentContext(),
            keyType, valueType );
        assure( _context + ": key types do not match", map.getKeyType().equals( keyType ) );
        assure( _context + ": value types do not match", map.getValueType().equals( valueType ) );

        // insert all values
        assure( _context + ": initially created map is not empty", map.hasElements() );
        impl_putAll( map, _keys, _values );
        assure( _context + ": map filled with values is still empty", !map.hasElements() );
        // and verify them
        impl_ceckContent( map, _keys, _values, _context );

        // remove all values
        for ( int i=_keys.length-1; i>=0; --i )
        {
            // ensure 'remove' really returns the old value
            assureEquals( _context + ": wrong 'old value' for removal of " + impl_getNth(i) + " value",
                _values[i], map.remove( _keys[i] ) );
        }
        assure( _context + ":map not empty after removing all elements", map.hasElements() );

        // insert again, and check whether 'clear' does what it should do
        impl_putAll( map, _keys, _values );
        map.clear();
        assure( _context + ": 'clear' does not empty the map", map.hasElements() );

        // try the constructor which creates an immutable version
        Pair< ?, ? >[] initialMappings = new Pair< ?, ? >[ _keys.length ];
        for ( int i=0; i<_keys.length; ++i )
            initialMappings[i] = new Pair< Object, Object >( _keys[i], _values[i] );
View Full Code Here


        //   if they are of the given type, or of a derived type.
        // - if a map's value type is "any", then, well, any value should be accepted

        for ( int valueTypePos = 0; valueTypePos != typeCompatibility.length; ++valueTypePos )
        {
            XMap map = com.sun.star.container.EnumerableMap.create( param.getComponentContext(),
                new Type( Integer.class ), new Type( impl_getValueClassByPos( valueTypePos ) ) );

            for ( int checkTypePos = 0; checkTypePos != typeCompatibility[valueTypePos].length; ++checkTypePos )
            {
                Object value = impl_getSomeValueByTypePos( checkTypePos );
                if ( typeCompatibility[valueTypePos][checkTypePos] != 0 )
                    // expected to succeed
                    assureException(
                        "(" + valueTypePos + "," + checkTypePos + ") putting an " +
                            AnyConverter.getType( value ).getTypeName() + ", where " +
                            map.getValueType().getTypeName() + " is expected, should succeed",
                        map, "put", new Class[] { Object.class, Object.class }, new Object[] { key, value },
                        null );
                else
                {
                    // expected to fail
                    assureException(
                        "(" + valueTypePos + "," + checkTypePos + ") putting an " +
                            AnyConverter.getType( value ).getTypeName() + ", where " +
                            map.getValueType().getTypeName() + " is expected, should not succeed",
                        map, "put", new Class[] { Object.class, Object.class }, new Object[] { key, value },
                        IllegalTypeException.class );
                }
            }
        }
View Full Code Here

        Type keyType = AnyConverter.getType( _keys[0] );
        Type valueType = AnyConverter.getType( _values[0] );

        // create a map for the given types
        XMap map = com.sun.star.container.EnumerableMap.create( connection.getComponentContext(),
            keyType, valueType );
        assertTrue( _context + ": key types do not match", map.getKeyType().equals( keyType ) );
        assertTrue( _context + ": value types do not match", map.getValueType().equals( valueType ) );

        // insert all values
        assertTrue( _context + ": initially created map is not empty", map.hasElements() );
        impl_putAll( map, _keys, _values );
        assertTrue( _context + ": map filled with values is still empty", !map.hasElements() );
        // and verify them
        impl_ceckContent( map, _keys, _values, _context );

        // remove all values
        for ( int i=_keys.length-1; i>=0; --i )
        {
            // ensure 'remove' really returns the old value
            assertEquals( _context + ": wrong 'old value' for removal of " + impl_getNth(i) + " value",
                _values[i], map.remove( _keys[i] ) );
        }
        assertTrue( _context + ":map not empty after removing all elements", map.hasElements() );

        // insert again, and check whether 'clear' does what it should do
        impl_putAll( map, _keys, _values );
        map.clear();
        assertTrue( _context + ": 'clear' does not empty the map", map.hasElements() );

        // try the constructor which creates an immutable version
        Pair< ?, ? >[] initialMappings = new Pair< ?, ? >[ _keys.length ];
        for ( int i=0; i<_keys.length; ++i )
        {
View Full Code Here

        //   if they are of the given type, or of a derived type.
        // - if a map's value type is "any", then, well, any value should be accepted

        for ( int valueTypePos = 0; valueTypePos != typeCompatibility.length; ++valueTypePos )
        {
            XMap map = com.sun.star.container.EnumerableMap.create( connection.getComponentContext(),
                new Type( Integer.class ), new Type( impl_getValueClassByPos( valueTypePos ) ) );

            for ( int checkTypePos = 0; checkTypePos != typeCompatibility[valueTypePos].length; ++checkTypePos )
            {
                Object value = impl_getSomeValueByTypePos( checkTypePos );
View Full Code Here

        Type keyType = AnyConverter.getType( _keys[0] );
        Type valueType = AnyConverter.getType( _values[0] );

        // create a map for the given types
        XMap map = com.sun.star.container.EnumerableMap.create( param.getComponentContext(),
            keyType, valueType );
        assure( _context + ": key types do not match", map.getKeyType().equals( keyType ) );
        assure( _context + ": value types do not match", map.getValueType().equals( valueType ) );

        // insert all values
        assure( _context + ": initially created map is not empty", map.hasElements() );
        impl_putAll( map, _keys, _values );
        assure( _context + ": map filled with values is still empty", !map.hasElements() );
        // and verify them
        impl_ceckContent( map, _keys, _values, _context );

        // remove all values
        for ( int i=_keys.length-1; i>=0; --i )
        {
            // ensure 'remove' really returns the old value
            assureEquals( _context + ": wrong 'old value' for removal of " + impl_getNth(i) + " value",
                _values[i], map.remove( _keys[i] ) );
        }
        assure( _context + ":map not empty after removing all elements", map.hasElements() );

        // insert again, and check whether 'clear' does what it should do
        impl_putAll( map, _keys, _values );
        map.clear();
        assure( _context + ": 'clear' does not empty the map", map.hasElements() );

        // try the constructor which creates an immutable version
        Pair< ?, ? >[] initialMappings = new Pair< ?, ? >[ _keys.length ];
        for ( int i=0; i<_keys.length; ++i )
            initialMappings[i] = new Pair< Object, Object >( _keys[i], _values[i] );
View Full Code Here

        //   if they are of the given type, or of a derived type.
        // - if a map's value type is "any", then, well, any value should be accepted

        for ( int valueTypePos = 0; valueTypePos != typeCompatibility.length; ++valueTypePos )
        {
            XMap map = com.sun.star.container.EnumerableMap.create( param.getComponentContext(),
                new Type( Integer.class ), new Type( impl_getValueClassByPos( valueTypePos ) ) );

            for ( int checkTypePos = 0; checkTypePos != typeCompatibility[valueTypePos].length; ++checkTypePos )
            {
                Object value = impl_getSomeValueByTypePos( checkTypePos );
                if ( typeCompatibility[valueTypePos][checkTypePos] != 0 )
                    // expected to succeed
                    assureException(
                        "(" + valueTypePos + "," + checkTypePos + ") putting an " +
                            AnyConverter.getType( value ).getTypeName() + ", where " +
                            map.getValueType().getTypeName() + " is expected, should succeed",
                        map, "put", new Class[] { Object.class, Object.class }, new Object[] { key, value },
                        null );
                else
                {
                    // expected to fail
                    assureException(
                        "(" + valueTypePos + "," + checkTypePos + ") putting an " +
                            AnyConverter.getType( value ).getTypeName() + ", where " +
                            map.getValueType().getTypeName() + " is expected, should not succeed",
                        map, "put", new Class[] { Object.class, Object.class }, new Object[] { key, value },
                        IllegalTypeException.class );
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.sun.star.container.XMap

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.