Examples of Percentage


Examples of org.apache.isis.applib.value.Percentage

    // //////////////////////////////////////////////////////////////////

    @Override
    protected Percentage doParse(final Object context, final String text) {
        try {
            return new Percentage(new Float(format.parse(text).floatValue()));
        } catch (final ParseException e) {
            try {
                return new Percentage(asFloat(text));
            } catch (final ParseException ee) {
                throw new TextEntryParseException("Not a number " + text, ee);
            }
        }
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

    // EncoderDecoder
    // //////////////////////////////////////////////////////////////////

    @Override
    protected String doEncode(final Object object) {
        final Percentage per = (Percentage) object;
        return String.valueOf(per.floatValue());
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

        return String.valueOf(per.floatValue());
    }

    @Override
    protected Percentage doRestore(final String data) {
        return new Percentage(Float.valueOf(data).floatValue());
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

    // FloatingPointValueFacet
    // //////////////////////////////////////////////////////////////////

    @Override
    public Float floatValue(final ObjectAdapter object) {
        final Percentage per = (Percentage) object.getObject();
        return new Float(per.floatValue());
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

                allowing(mockConfiguration).getString("isis.value.format.percentage");
                will(returnValue(null));
            }
        });

        percentage = new Percentage(0.105f);
        allowMockAdapterToReturn(percentage);

        holder = new FacetHolderImpl();

        setValue(adapter = new PercentageValueSemanticsProvider(holder, mockConfiguration, mockContext));
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

        assertEquals("0.105", encoded);
    }

    @Test
    public void testParseTextEntryWithNumber() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "21%", null);
        assertEquals(new Percentage(0.21f), parsed);
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

        assertEquals(new Percentage(0.21f), parsed);
    }

    @Test
    public void testParseTextEntryWithNumberAndDecimalPoint() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "21.4%", null);
        assertEquals(new Percentage(0.214f), parsed);
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

        assertEquals(new Percentage(0.214f), parsed);
    }

    @Test
    public void testParseTextEntryWithBlank() {
        final Percentage parsed = adapter.parseTextEntry(percentage, "", null);
        assertEquals(null, parsed);
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

    }

    @Test
    public void testRestoreFromEncodedString() {
        final Object restored = adapter.fromEncodedString("0.2134");
        assertEquals(new Percentage(0.2134f), restored);
    }
View Full Code Here

Examples of org.apache.isis.applib.value.Percentage

    // //////////////////////////////////////////////////////////////////

    @Override
    protected Percentage doParse(final Object context, final String text) {
        try {
            return new Percentage(new Float(format.parse(text).floatValue()));
        } catch (final ParseException e) {
            try {
                return new Percentage(asFloat(text));
            } catch (final ParseException ee) {
                throw new TextEntryParseException("Not a number " + text, ee);
            }
        }
    }
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.