Package org.apache.isis.core.metamodel.facets.object.parseable

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


        return newValue;
    }

    private ObjectAdapter parse(final String entryText) {
        final ObjectSpecification fieldSpecification = field.getSpecification();
        final ParseableFacet p = fieldSpecification.getFacet(ParseableFacet.class);
        try {
            return p.parseTextEntry(object, entryText);
        } catch (final IllegalArgumentException ex) {
            throw new InvalidEntryException(ex.getMessage(), ex);
        }
    }
View Full Code Here


        super.setObject(adapter); // associated value
    }

    public void setObjectAsString(final String enteredText) {
        // parse text to get adapter
        final ParseableFacet parseableFacet = getTypeOfSpecification().getFacet(ParseableFacet.class);
        if (parseableFacet == null) {
            throw new RuntimeException("unable to parse string for " + getTypeOfSpecification().getFullIdentifier());
        }
        final ObjectAdapter adapter = parseableFacet.parseTextEntry(getObject(), enteredText);

        setObject(adapter);
    }
View Full Code Here

        final ObjectAdapter[] params = new ObjectAdapter[parameters.length];
        final List<ObjectActionParameter> pars = action.getParameters();
        for (int i = 0; i < parameters.length; i++) {
            final ObjectSpecification typ = pars.get(i).getSpecification();
            if (typ.getFacet(ParseableFacet.class) != null) {
                final ParseableFacet facet = typ.getFacet(ParseableFacet.class);
                params[i] = facet.parseTextEntry(null, parameters[i]);
            } else {
                params[i] = request.getContext().getMappedObject(parameters[i]);
            }
        }
        return params;
View Full Code Here

        for (final ObjectActionParameter spec : action.getParameters()) {
            final ObjectSpecification typ = spec.getSpecification();
            if (parameters[i] == null) {
                objectParameters[i] = null;
            } else if (typ.getFacet(ParseableFacet.class) != null) {
                final ParseableFacet facet = typ.getFacet(ParseableFacet.class);
                objectParameters[i] = facet.parseTextEntry(null, parameters[i]);
            } else {
                objectParameters[i] = MethodsUtils.findObject(request.getContext(), parameters[i]);
            }
            i++;
        }
View Full Code Here

    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

                    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);
                    ((OneToOneAssociation) association).initAssociation(object, value);
                } else if (association.isOneToOneAssociation()) {
                    final ObjectAdapter value = loaded.get(data);
                    ((OneToOneAssociation) association).initAssociation(object, value);
                }
View Full Code Here

                    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

    }

    private ObjectAdapter getObjectAdapter(final String proposedValue, final ObjectAdapter nakedObject,
        final ObjectFeature nakedObjectFeature) {
        ObjectAdapter proposedValueNO = null;
        ParseableFacet parseable = nakedObjectFeature.getFacet(ParseableFacet.class);
        if (parseable == null) {
            parseable = nakedObjectFeature.getSpecification().getFacet(ParseableFacet.class);
        }

        if (parseable != null) {
            proposedValueNO = parseable.parseTextEntry(nakedObject, proposedValue);
        } else {
            final String proposedValueOidStr = proposedValue;
            proposedValueNO = getObjectAdapter(proposedValueOidStr);
        }
        return proposedValueNO;
View Full Code Here

        final ObjectAdapter propertyValue = property.get(getNakedObject());
        if (propertyValue == null) {
            return xhtmlRenderer.p(null, HtmlClass.PROPERTY);
        }

        ParseableFacet parseable = property.getFacet(ParseableFacet.class);
        if (parseable == null) {
            final ObjectSpecification propertySpec = property.getSpecification();
            parseable = propertySpec.getFacet(ParseableFacet.class);
        }
        if (parseable != null) {
View Full Code Here

        invocation.setParameter(index, object);
    }

    private ObjectAdapter parse(final String entryText) {
        final ObjectSpecification parameterSpecification = parameter.getSpecification();
        final ParseableFacet p = parameterSpecification.getFacet(ParseableFacet.class);
        try {
            return p.parseTextEntry(object, entryText);
        } catch (final IllegalArgumentException ex) {
            throw new InvalidEntryException(ex.getMessage(), ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet

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.