Examples of LocalizedString


Examples of javax.xml.registry.infomodel.LocalizedString

        setValue(Locale.getDefault(), str);
    }

    public String getValue(Locale locale) throws JAXRException
    {
        LocalizedString localizedString = (LocalizedString) map.get(new MapKey(locale, LocalizedString.DEFAULT_CHARSET_NAME));
        return localizedString != null ? localizedString.getValue() : null;
    }
View Full Code Here

Examples of javax.xml.registry.infomodel.LocalizedString

            Object obj = i.next();
            Name name = objectFactory.createName();
            if (obj instanceof String) {
                name.setValue((String)obj);
            } else if (obj instanceof LocalizedString) {
                LocalizedString ls = (LocalizedString)obj;
                name.setValue(ls.getValue());
                name.setLang(ls.getLocale().getLanguage());
            }
            result[currLoc] = name;
            currLoc++;
        }
        return result;
View Full Code Here

Examples of javax.xml.registry.infomodel.LocalizedString

/**
* @version $Revision$ $Date$
*/
public class LocalizedStringTest extends TestCase {
    public void testEquals() {
        LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "Equal", "UTF-8");
        LocalizedString ls2 = new LocalizedStringImpl(Locale.US, "Equal", "UTF-8");
        assertTrue(ls1.equals(ls2));
        assertTrue(ls2.equals(ls1));
        ls2 = new LocalizedStringImpl(Locale.US, "NotEqual", "UTF-8");
        assertFalse(ls1.equals(ls2));
        assertFalse(ls2.equals(ls1));
        ls2 = new LocalizedStringImpl(Locale.US, "Equal", "US-ASCII");
        assertFalse(ls1.equals(ls2));
        assertFalse(ls2.equals(ls1));
    }
View Full Code Here

Examples of javax.xml.registry.infomodel.LocalizedString

        assertFalse(ls1.equals(ls2));
        assertFalse(ls2.equals(ls1));
    }

    public void testNullEquals() {
        LocalizedString ls1 = new LocalizedStringImpl(Locale.US, null, "UTF-8");
        LocalizedString ls2 = new LocalizedStringImpl(Locale.US, null, "UTF-8");
        assertTrue(ls1.equals(ls2));
        assertTrue(ls2.equals(ls1));
        ls2 = new LocalizedStringImpl(Locale.US, "NotEqual", "UTF-8");
        assertFalse(ls1.equals(ls2));
        assertFalse(ls2.equals(ls1));
        ls2 = new LocalizedStringImpl(Locale.US, null, "US-ASCII");
        assertFalse(ls1.equals(ls2));
        assertFalse(ls2.equals(ls1));
    }
View Full Code Here

Examples of javax.xml.registry.infomodel.LocalizedString

        assertFalse(ls1.equals(ls2));
        assertFalse(ls2.equals(ls1));
    }

    public void testSetCharsetName() throws JAXRException {
        LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "USA", "UTF-8");
        assertEquals("UTF-8", ls1.getCharsetName());
        ls1.setCharsetName("US-ASCII");
        assertEquals("US-ASCII", ls1.getCharsetName());
        try {
            ls1.setCharsetName(null);
            fail("expected IllegalArgumentException for null charsetName");
        } catch (IllegalArgumentException e) {
            // ok
        }
    }
View Full Code Here

Examples of javax.xml.registry.infomodel.LocalizedString

            // ok
        }
    }

    public void testSetLocale() throws JAXRException {
        LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "USA", "UTF-8");
        assertEquals(Locale.US, ls1.getLocale());
        ls1.setLocale(Locale.CANADA);
        assertEquals(Locale.CANADA, ls1.getLocale());
        try {
            ls1.setLocale(null);
            fail("expected IllegalArgumentException for null locale");
        } catch (IllegalArgumentException e) {
            // ok
        }
    }
View Full Code Here

Examples of javax.xml.registry.infomodel.LocalizedString

            // ok
        }
    }

    public void testSetValue() throws JAXRException {
        LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "USA", "UTF-8");
        assertEquals("USA", ls1.getValue());
        ls1.setValue("Foo");
        assertEquals("Foo", ls1.getValue());
        ls1.setValue(null);
        assertNull(ls1.getValue());
    }
View Full Code Here

Examples of oasis.names.tc.wsrp.v1.types.LocalizedString

        if ( portletKey == null ) {
            // no portlet window, so use a default behaviour
            XMLUtils.createElement(contenthandler, "title", copletInstanceData.getTitle());
        } else {
            copletInstanceData.setTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_LAYOUT, layout);
            LocalizedString localizedTitle = (LocalizedString)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_TITLE);
            String title;
            if ( localizedTitle == null ) {
                title = copletInstanceData.getTitle();
            } else {
                title = localizedTitle.getValue();
            }
            XMLUtils.createElement(contenthandler, "title", title);           

            final String portletInstanceKey = (String)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY);
            final User user = (User)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_USER);
View Full Code Here

Examples of org.apache.rave.portal.model.util.LocalizedString

  @Test
  public void testGetLocalizedElement() {
    // This should be independent of the actual build locale.
    LocalizedString[] elements = new LocalizedString[3];
    elements[0] = new LocalizedString("Hello World", "en");
    elements[1] = new LocalizedString("你好世界", "cn");
    elements[2] = new LocalizedString("Nom de plume!", "fr");
    LocalizedString testMatch = new LocalizedString("Nom de plume!", "fr");
    String[] locales = { "es", "fr", "en" };
    LocalizedString bestMatch = LocalizationUtils.getLocalizedElement(
        elements, locales);
    assertTrue("Localized element best match returned correctly",bestMatch.getValue().equals(testMatch.getValue()));
  }
View Full Code Here

Examples of org.apache.rave.portal.model.util.LocalizedString

    assertNotNull("Locales array is not null", locales);

    // Set up a dummy list of strings. Last one will be the
    // correct one.
    LocalizedString[] elements = new LocalizedString[4];
    elements[0] = new LocalizedString("Hollow World", locales.get(0)
        .toLanguageTag());
    elements[1] = new LocalizedString("Hello World", "xx-xx");
    elements[2] = new LocalizedString("你好世界", "xy-xx");
    elements[3] = new LocalizedString("Nom de plume!", "xz-xx");

    // Sort and test
    LocalizedString[] sortedElements = LocalizationUtils
        .processElementsByDefaultLocales(elements);
    assertNotNull("Sorted elements list is not null", sortedElements);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.