@Test public void testGetValue() throws ReadOnlyException, ValidatorException, IOException { addPref(basePrefs, "key1", false, null); addPref(basePrefs, "key2", false, new String[] {}); addPref(basePrefs, "key3", false, new String[] {null}); addPref(basePrefs, "key4", false, new String[] {"value1", "value2"}); String value = portletPreferences.getValue("key0", "FOOBAR"); assertEquals("FOOBAR", value); value = portletPreferences.getValue("key1", "FOOBAR"); assertEquals("FOOBAR", value); value = portletPreferences.getValue("key2", "FOOBAR"); assertEquals("FOOBAR", value); value = portletPreferences.getValue("key3", "FOOBAR"); assertNull(value); value = portletPreferences.getValue("key4", "FOOBAR"); assertEquals("value1", value); value = portletPreferences.getValue("key1", null); assertNull(value); value = portletPreferences.getValue("key2", null); assertNull(value); value = portletPreferences.getValue("key3", null); assertNull(value); }
@Override public final String getValue(String key, String def) { final IPortletPreference portletPreference = this.getPortletPreference(key); if (portletPreference != null) { final String[] values = portletPreference.getValues(); if (values == null || values.length == 0) { return def; } return values[0]; } return def; }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final String getValue(String key, String def) { final IPortletPreference portletPreference = this.getPortletPreference(key); if (portletPreference != null) { final String[] values = portletPreference.getValues(); if (values == null || values.length == 0) { return def; } return values[0]; } return def; } }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final String getValue(String key, String def) { final IPortletPreference portletPreference = this.getPortletPreference(key); if (portletPreference != null) { final String[] values = portletPreference.getValues(); if (values == null || values.length == 0) { return def; } return values[0]; } return def; } AbstractPortletPreferencesImpl(boolean render); }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final String getValue(String key, String def) { final IPortletPreference portletPreference = this.getPortletPreference(key); if (portletPreference != null) { final String[] values = portletPreference.getValues(); if (values == null || values.length == 0) { return def; } return values[0]; } return def; } AbstractPortletPreferencesImpl(boolean render); @Override final boolean isReadOnly(String key); @Override final String getValue(String key, String def); @Override final String[] getValues(String key, String[] def); @Override final void setValue(String key, String value); @Override final void setValues(String key, String[] values); @Override final Enumeration<String> getNames(); @Override final Map<String, String[]> getMap(); @Override final void reset(String key); @Override final void store(); }
AbstractPortletPreferencesImpl implements PortletPreferences { @Override public final String getValue(String key, String def) { final IPortletPreference portletPreference = this.getPortletPreference(key); if (portletPreference != null) { final String[] values = portletPreference.getValues(); if (values == null || values.length == 0) { return def; } return values[0]; } return def; } AbstractPortletPreferencesImpl(boolean render); @Override final boolean isReadOnly(String key); @Override final String getValue(String key, String def); @Override final String[] getValues(String key, String[] def); @Override final void setValue(String key, String value); @Override final void setValues(String key, String[] values); @Override final Enumeration<String> getNames(); @Override final Map<String, String[]> getMap(); @Override final void reset(String key); @Override final void store();  }