Examples of ParseableFacet


Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

                    // XML
                    isisMetaModel.setAttributesForValue(xmlValueElement, valueNos.getShortIdentifier());

                    // return parsed string, else encoded string, else title.
                    String valueStr;
                    final ParseableFacet parseableFacet = fieldNos.getFacet(ParseableFacet.class);
                    final EncodableFacet encodeableFacet = fieldNos.getFacet(EncodableFacet.class);
                    if (parseableFacet != null) {
                        valueStr = parseableFacet.parseableTitle(value);
                    } else if (encodeableFacet != null) {
                        valueStr = encodeableFacet.toEncodedString(value);
                    } else {
                        valueStr = value.titleString();
                    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

        isisConfigurationDefault.add(ValueSemanticsProviderUtil.SEMANTICS_PROVIDER_NAME_KEY_PREFIX + canonical(className) + ValueSemanticsProviderUtil.SEMANTICS_PROVIDER_NAME_KEY_SUFFIX, className);
        facetFactory.process(new ProcessClassContext(MyValueWithSemanticsProviderSpecifiedUsingConfiguration.class, methodRemover, facetedMethod));
        final ValueFacetAbstract facet = (ValueFacetAbstract) facetedMethod.getFacet(ValueFacet.class);
        assertNotNull(facet);
        // should also be a ParserFacet, since the VSP implements Parser
        final ParseableFacet parseableFacet = facetedMethod.getFacet(ParseableFacet.class);
        assertNotNull(parseableFacet);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

        isisConfigurationDefault.add(ValueSemanticsProviderUtil.SEMANTICS_PROVIDER_NAME_KEY_PREFIX + canonical(className) + ValueSemanticsProviderUtil.SEMANTICS_PROVIDER_NAME_KEY_SUFFIX, className);
        facetFactory.process(new ProcessClassContext(NonAnnotatedValueSemanticsProviderSpecifiedUsingConfiguration.class, methodRemover, facetedMethod));
        final ValueFacetAbstract facet = (ValueFacetAbstract) facetedMethod.getFacet(ValueFacet.class);
        assertNotNull(facet);
        // should also be a ParserFacet, since the VSP implements Parser
        final ParseableFacet parseableFacet = facetedMethod.getFacet(ParseableFacet.class);
        assertNotNull(parseableFacet);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

            return null;
        }
        final String proposedString = (String) proposedValue;

        final ObjectSpecification parameterSpecification = getSpecification();
        final ParseableFacet p = parameterSpecification.getFacet(ParseableFacet.class);
        try {
            final ObjectAdapter parsedAdapter = p.parseTextEntry(null, proposedString, localization);
            return parsedAdapter;
        } catch(Exception ex) {
            return null;
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

                    final ObjectAdapter collection = association.get(object);
                    final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
                    facet.init(collection, elements);
                } else if (association.getSpecification().isParseable()) {
                    data = data.replaceAll("\\n", "\n");
                    final ParseableFacet facet = association.getSpecification().getFacet(ParseableFacet.class);
                    final ObjectAdapter value = facet.parseTextEntry(null, data, null);
                    ((OneToOneAssociation) association).initAssociation(object, value);
                } else if (association.isOneToOneAssociation()) {
                    final ObjectAdapter value = loaded.get(data);
                    ((OneToOneAssociation) association).initAssociation(object, value);
                }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

                    final String cls = element.getSpecification().getFullIdentifier();
                    writer.print(cls + "#" + refId + " ");
                }
                writer.println();
            } else if (association.getSpecification().isParseable()) {
                final ParseableFacet facet = associatedObject.getSpecification().getFacet(ParseableFacet.class);
                String encodedValue = facet.parseableTitle(associatedObject);
                encodedValue = encodedValue.replaceAll("\n", "\\n");
                writer.println(encodedValue);
            } else if (association.isOneToOneAssociation()) {
                final String refId = saved.getId(associatedObject);
                final String cls = associatedObject.getSpecification().getFullIdentifier();
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

    public void testFacetPickedUp() {

        facetFactory.process(new ProcessClassContext(MyParseableUsingParserName.class, methodRemover, facetedMethod));

        final ParseableFacet facet = facetedMethod.getFacet(ParseableFacet.class);
        assertNotNull(facet);
        assertTrue(facet instanceof ParseableFacetAbstract);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

            return null;
        }
        final String proposedString = (String) proposedValue;

        final ObjectSpecification parameterSpecification = getSpecification();
        final ParseableFacet p = parameterSpecification.getFacet(ParseableFacet.class);
        try {
            final ObjectAdapter parsedAdapter = p.parseTextEntry(null, proposedString, localization);
            return parsedAdapter;
        } catch(Exception ex) {
            return null;
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

            }
            // REVIEW this block uses the existing adapter as it contains the
            // regex needed. This needs to
            // be reviewed in line with Dan's proposed changes to the reflector.
            final ObjectAdapter valueAdapter = initialState[i];
            final ParseableFacet parser = spec.getFacet(ParseableFacet.class);
            Localization localization = IsisContext.getLocalization();
            parser.parseTextEntry(valueAdapter, textEntry, localization);
            // REVIEW what do we do when an exception is thrown - a parse fails?
        }
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

    public ObjectAdapter getAdapter(final ObjectAdapter contextAdapter, final ObjectSpecification noSpec, final CellBinding contextBinding, final ScenarioCell paramCell) throws ScenarioBoundValueException {

        final String cellText = paramCell.getText();

        // see if can handle as parseable value
        final ParseableFacet parseableFacet = noSpec.getFacet(ParseableFacet.class);
        if (parseableFacet != null) {
            try {
                return parseableFacet.parseTextEntry(contextAdapter, cellText, null);
            } catch (final TextEntryParseException ex) {
                throw ScenarioBoundValueException.arg(contextBinding, paramCell, "(cannot parse '" + cellText + "')");
            } catch (final IllegalArgumentException ex) {
                // REVIEW: isn't what is thrown, but perhaps
                // TextEntryParseException should inherit from
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.