Package com.ibm.ucp

Examples of com.ibm.ucp.Profile


//                params.put("odbc-host", "not used");
//                params.put("odbc-port", "-1");
                Element parameters = createParameters(params);
                MCSDeviceRepositoryProvider provider =
                        new MCSDeviceRepositoryProvider("provider name", parameters);
                Profile profile = provider.getProfile("unknown device");
                assertNull(profile);

            }
        });
View Full Code Here


    }

    // Javadoc inherited.
    public Profile getProfile(String profileKey) {
       
        Profile profile = null;
        try {
            // Retrive our device
            DefaultDevice device = accessor.retrieveDevice(connection, profileKey);
            if (device != null) {
                // Adapt our device into a UCP profile.
View Full Code Here

     * @return the profile which adapts the device created.
     * @throws UCPException if there was a problem inside UCP.
     */
    private Profile adapt(DefaultDevice device) throws UCPException {

        Profile profile = null;

        // NOTE: The values passed to the constructors of the Profile
        // and Component objects below were an educated guess by me on the
        // basis of the Javadoc for UCP and the contents of the ProfileMgr
        // and UCP jars from Websphere Everyplace Access (which uses UCP).

        // I assume we do not require validation.
        boolean validating = false;

        // Create the Profile.
        profile = new Profile(profileSchema, profileName, validating);
       
        //
        // Component: HardwarePlatform
        //

        // Create the HardwarePlatform component.
        Component hardwarePlatformComponent =
                createComponent("HardwarePlatform");

        // pixeldepth -> BitsPerPixel
        int pixelDepth = getPolicyValueAsInt(device, "pixeldepth", 0);
        if (pixelDepth > 0) {
            Property bitsPerPixelProperty = new Property("BitsPerPixel",
                    new Integer(pixelDepth));
            hardwarePlatformComponent.addProperty(bitsPerPixelProperty);
        }
           
        // rendermode -> ColorCapable
        String renderMode = device.getComputedPolicyValue("rendermode");
        if (renderMode != null) {
            Boolean colorCapable = Boolean.FALSE;
            if ((renderMode.equals("rgb") ||
                    renderMode.equals("pallette")) && pixelDepth > 1) {
                colorCapable = Boolean.TRUE;
            }
            Property colorCapableProperty = new Property("ColorCapable",
                    colorCapable);
            hardwarePlatformComponent.addProperty(colorCapableProperty);
        }
           
        // modelnum -> Model
        String modelNum = device.getComputedPolicyValue("modelnum");
        if (modelNum != null) {
            Property modelProperty = new Property("Model", modelNum);
            hardwarePlatformComponent.addProperty(modelProperty);
        }
           
        // pixelsx,y -> ScreenSize
        int pixelsX = getPolicyValueAsInt(device, "pixelsx", 0);
        int pixelsY = getPolicyValueAsInt(device, "pixelsy", 0);
        if (pixelsX > 0 && pixelsY > 0) {
            Dimension screenSize = new Dimension(pixelsX, pixelsY);
            Property screenSizeProperty = new Property("ScreenSize",
                    screenSize);
            hardwarePlatformComponent.addProperty(screenSizeProperty);
        }
           
        // charactersx,y -> ScreenSizeChar
        Dimension screenSizeChar;
        int charactersX = getPolicyValueAsInt(device, "charactersx", 0);
        int charactersY = getPolicyValueAsInt(device, "charactersy", 0);
        if (charactersX > 0 && charactersY > 0) {
            screenSizeChar = new Dimension(charactersX, charactersY);
            Property screenSizeCharProperty = new Property("ScreenSizeChar",
                    screenSizeChar);
            hardwarePlatformComponent.addProperty(screenSizeCharProperty);
        }
           
        // mfg -> Vendor
        String manufacturer = device.getComputedPolicyValue("mfg");
        if (manufacturer != null) {
            Property vendorProperty = new Property("Vendor", manufacturer);
            hardwarePlatformComponent.addProperty(vendorProperty);
        }

        // HardwarePlatform component is complete, so add it to the Profile.
        profile.addComponent(hardwarePlatformComponent);

        //
        // Component: SoftwarePlatform
        //

        Component softwarePlatformComponent =
                createComponent("SoftwarePlatform");

        // UAProf.CcppAccept -> CcppAccept
        String ccppAccept = device.getComputedPolicyValue("UAProf.CcppAccept");
        if (ccppAccept != null) {
            Set ccppAcceptSet = new HashSet();
            ccppAcceptSet.add(ccppAccept);
            Property ccppAcceptProperty = new Property("CcppAccept",
                    ccppAcceptSet);
            softwarePlatformComponent.addProperty(ccppAcceptProperty);
        }
       
        // SoftwarePlatform component is complete, so add it to the Profile.
        profile.addComponent(softwarePlatformComponent);
       
        //
        // Component: BrowserUA
        //

        Component browserUAComponent =
                createComponent("BrowserUA");

        // brwsrname -> BrowserName
        String brwsrName = device.getComputedPolicyValue("brwsrname");
        if (brwsrName != null) {
            Property browserNameProperty = new Property("BrowserName",
                    brwsrName);
            browserUAComponent.addProperty(browserNameProperty);
        }

        // brwsrvers -> BrowserVersion
        String brwsrVers = device.getComputedPolicyValue("brwsrvers");
        if (brwsrVers != null) {
            Property browserVersionProperty = new Property("BrowserVersion",
                    brwsrVers);
            browserUAComponent.addProperty(browserVersionProperty);
        }

        // BrowserUA component is complete, so add it to the Profile.
        profile.addComponent(browserUAComponent);

        //
        // Component: WapCharacteristics
        //

        Component wapCharacteristicsComponent =
                createComponent("WapCharacteristics");

        // UAProf.WmlVersion -> WmlVersion
        String wmlVersion = device.getComputedPolicyValue("UAProf.WmlVersion");
        if (wmlVersion != null) {
            Set wmlVersionSet = new HashSet();
            wmlVersionSet.add(wmlVersion);
            Property wmlVersionProperty = new Property("WmlVersion",
                    wmlVersionSet);
            wapCharacteristicsComponent.addProperty(wmlVersionProperty);
        }

        // WapCharacteristics component is complete, so add it to the Profile.
        profile.addComponent(wapCharacteristicsComponent);

        // Return the created profile.
        return profile;
       
    }
View Full Code Here

            String deviceName = (String)names.next();
            ProfileValue profileValue = (ProfileValue)
                nameToProfile.get(deviceName);

            // Ensure provider returns test data we created in repository.
            Profile profile = provider.getProfile(deviceName);
            assertNotNull("cannot retrieve profile for empty device",
                          profile);
            assertEquals("profile description should equal device name",
                         deviceName,
                         provider.getProfileDescription(deviceName));

            // Test the results of the adapted device values.
            // NOTE: we only test getPropertyString since this is the only
            // method of Profile that the example code IBM gave us called.
            assertEquals("bitsPerPixel",
                         profileValue.bitsPerPixel,
                         profile.getPropertyString("BitsPerPixel"));
            assertEquals("colorCapable",
                         profileValue.colorCapable,
                         profile.getPropertyString("ColorCapable"));
            assertEquals("model",
                         profileValue.model,
                         profile.getPropertyString("Model"));
            assertEquals("screenSize",
                         profileValue.screenSize,
                         profile.getPropertyString("ScreenSize"));
            assertEquals("screenSizeChar",
                         profileValue.screenSizeChar,
                         profile.getPropertyString("ScreenSizeChar"));
            assertEquals("vendor",
                         profileValue.vendor,
                         profile.getPropertyString("Vendor"));
            assertEquals("ccppAccept",
                         profileValue.ccppAccept,
                         profile.getPropertyString("CcppAccept"));
            assertEquals("browserName",
                         profileValue.browserName,
                         profile.getPropertyString("BrowserName"));
            assertEquals("browserVersion",
                         profileValue.browserVersion,
                         profile.getPropertyString("BrowserVersion"));
            assertEquals("wmlVersion",
                         profileValue.wmlVersion,
                         profile.getPropertyString("WmlVersion"));
        }

        assertTrue("profile keys should contain all explicitly " +
                   "created device names",
                   provider.getProfileKeys().containsAll(nameSet));
View Full Code Here

TOP

Related Classes of com.ibm.ucp.Profile

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.