Example usage for com.fasterxml.jackson.core JsonToken FIELD_NAME

List of usage examples for com.fasterxml.jackson.core JsonToken FIELD_NAME

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonToken FIELD_NAME.

Prototype

JsonToken FIELD_NAME

To view the source code for com.fasterxml.jackson.core JsonToken FIELD_NAME.

Click Source Link

Document

FIELD_NAME is returned when a String token is encountered as a field name (same lexical value, different function)

Usage

From source file:com.github.shyiko.jackson.module.advice.AdvisedBeanDeserializer.java

protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser jp, DeserializationContext ctxt)
        throws IOException {
    final ExternalTypeHandler ext = _externalTypeIdHandler.start();
    final PropertyBasedCreator creator = _propertyBasedCreator;
    PropertyValueBuffer buffer = creator.startBuilding(jp, ctxt, _objectIdReader);

    TokenBuffer tokens = new TokenBuffer(jp);
    tokens.writeStartObject();/*from   w  ww .  j  av  a  2s  . co m*/

    JsonToken t = jp.getCurrentToken();
    for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) {
        String propName = jp.getCurrentName();
        jp.nextToken(); // to point to value
        // creator property?
        SettableBeanProperty creatorProp = creator.findCreatorProperty(propName);
        if (creatorProp != null) {
            // first: let's check to see if this might be part of value with external type id:
            if (!ext.handlePropertyValue(jp, ctxt, propName, buffer)) {
                // Last creator property to set?
                Object value = creatorProp.deserialize(jp, ctxt);
                if (buffer.assignParameter(creatorProp.getCreatorIndex(), value)) {
                    t = jp.nextToken(); // to move to following FIELD_NAME/END_OBJECT
                    Object bean;
                    try {
                        bean = creator.build(ctxt, buffer);
                    } catch (Exception e) {
                        wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
                        continue; // never gets here
                    }
                    // if so, need to copy all remaining tokens into buffer
                    while (t == JsonToken.FIELD_NAME) {
                        jp.nextToken(); // to skip name
                        tokens.copyCurrentStructure(jp);
                        t = jp.nextToken();
                    }
                    if (bean.getClass() != _beanType.getRawClass()) {
                        // !!! 08-Jul-2011, tatu: Could probably support; but for now
                        //   it's too complicated, so bail out
                        throw ctxt
                                .mappingException("Can not create polymorphic instances with unwrapped values");
                    }
                    return ext.complete(jp, ctxt, bean);
                }
            }
            continue;
        }
        // Object Id property?
        if (buffer.readIdProperty(propName)) {
            continue;
        }

        // regular property? needs buffering
        SettableBeanProperty prop = _beanProperties.find(propName);
        if (prop != null) {
            buffer.bufferProperty(prop, prop.deserialize(jp, ctxt));
            continue;
        }
        // external type id (or property that depends on it)?
        if (ext.handlePropertyValue(jp, ctxt, propName, null)) {
            continue;
        }
        /* As per [JACKSON-313], things marked as ignorable should not be
         * passed to any setter
         */
        if (_ignorableProps != null && _ignorableProps.contains(propName)) {
            handleIgnoredProperty(jp, ctxt, handledType(), propName);
            continue;
        }
        // "any property"?
        if (_anySetter != null) {
            buffer.bufferAnyProperty(_anySetter, propName, _anySetter.deserialize(jp, ctxt));
        }
    }

    // We hit END_OBJECT; resolve the pieces:
    try {
        return ext.complete(jp, ctxt, buffer, creator);
    } catch (Exception e) {
        wrapInstantiationProblem(e, ctxt);
        return null; // never gets here
    }
}

From source file:com.zenesis.qx.remote.RequestHandler.java

/**
 * Handles creating a server object to match one created on the client; expects className,
 * clientId, properties/*  w  ww. j a v a  2 s.c om*/
 * @param jp
 * @throws ServletException
 * @throws IOException
 */
protected void cmdNewObject(JsonParser jp) throws ServletException, IOException {
    // Get the basics
    String className = getFieldValue(jp, "className", String.class);
    int clientId = getFieldValue(jp, "clientId", Integer.class);

    // Get the class
    Class<? extends Proxied> clazz;
    try {
        clazz = (Class<? extends Proxied>) Class.forName(className);
    } catch (ClassNotFoundException e) {
        throw new ServletException("Unknown class " + className);
    }
    ProxyType type = ProxyTypeManager.INSTANCE.getProxyType(clazz);

    // Create the instance
    Proxied proxied;
    try {
        proxied = type.newInstance(clazz);
    } catch (InstantiationException e) {
        throw new ServletException("Cannot create class " + className + ": " + e.getMessage(), e);
    } catch (InvocationTargetException e) {
        throw new ServletException("Cannot create class " + className + ": " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
        throw new ServletException("Cannot create class " + className + ": " + e.getMessage(), e);
    }

    // Get the server ID
    int serverId = tracker.addClientObject(proxied);

    // Remember the client ID, in case there are subsequent commands which refer to it
    if (clientObjects == null)
        clientObjects = new HashMap<Integer, Proxied>();
    clientObjects.put(clientId, proxied);

    // Tell the client about the new ID - do this before changing properties
    tracker.invalidateCache(proxied);
    tracker.getQueue().queueCommand(CommandId.CommandType.MAP_CLIENT_ID, proxied, null,
            new MapClientId(serverId, clientId));

    // Set property values
    if (jp.nextToken() == JsonToken.FIELD_NAME) {
        if (jp.nextToken() != JsonToken.START_OBJECT)
            throw new ServletException("Unexpected properties definiton for 'new' command");
        while (jp.nextToken() != JsonToken.END_OBJECT) {
            String propertyName = jp.getCurrentName();
            jp.nextToken();

            // Read a Proxied object?  
            ProxyProperty prop = getProperty(type, propertyName);
            MetaClass propClass = prop.getPropertyClass();
            Object value = null;
            if (propClass.isSubclassOf(Proxied.class)) {

                if (propClass.isArray() || propClass.isCollection()) {
                    value = readArray(jp, propClass.getJavaType());

                } else if (propClass.isMap()) {
                    value = readMap(jp, propClass.getKeyClass(), propClass.getJavaType());

                } else {
                    Integer id = jp.readValueAs(Integer.class);
                    if (id != null)
                        value = getProxied(id);
                }
            } else {
                value = jp.readValueAs(Object.class);
                if (value != null && Enum.class.isAssignableFrom(propClass.getJavaType())) {
                    String str = Helpers.camelCaseToEnum(value.toString());
                    value = Enum.valueOf(propClass.getJavaType(), str);
                }
            }
            setPropertyValue(type, proxied, propertyName, value);
        }
    }

    // Done
    jp.nextToken();
}

From source file:com.adobe.communities.ugc.migration.importer.UGCImportHelper.java

protected void extractEvent(final JsonParser jsonParser, final Resource resource) throws IOException {

    String author = null;// www.j a  v a 2 s .  com
    final JSONObject requestParams = new JSONObject();
    try {
        jsonParser.nextToken();
        JsonToken token = jsonParser.getCurrentToken();
        while (token.equals(JsonToken.FIELD_NAME)) {
            String field = jsonParser.getCurrentName();
            jsonParser.nextToken();

            if (field.equals(PN_START) || field.equals(PN_END)) {
                final Long value = jsonParser.getValueAsLong();
                final Calendar calendar = new GregorianCalendar();
                calendar.setTimeInMillis(value);
                final Date date = calendar.getTime();
                final TimeZone tz = TimeZone.getTimeZone("UTC");
                // this is the ISO-8601 format expected by the CalendarOperations object
                final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm+00:00");
                df.setTimeZone(tz);
                if (field.equals(PN_START)) {
                    requestParams.put(CalendarRequestConstants.START_DATE, df.format(date));
                } else {
                    requestParams.put(CalendarRequestConstants.END_DATE, df.format(date));
                }
            } else if (field.equals(CalendarRequestConstants.TAGS)) {
                List<String> tags = new ArrayList<String>();
                if (jsonParser.getCurrentToken().equals(JsonToken.START_ARRAY)) {
                    token = jsonParser.nextToken();
                    while (!token.equals(JsonToken.END_ARRAY)) {
                        tags.add(URLDecoder.decode(jsonParser.getValueAsString(), "UTF-8"));
                        token = jsonParser.nextToken();
                    }
                    requestParams.put(CalendarRequestConstants.TAGS, tags);
                } else {
                    LOG.warn("Tags field came in without an array of tags in it - not processed");
                    // do nothing, just log the error
                }
            } else if (field.equals("jcr:createdBy")) {
                author = URLDecoder.decode(jsonParser.getValueAsString(), "UTF-8");
            } else if (field.equals(ContentTypeDefinitions.LABEL_TIMESTAMP_FIELDS)) {
                jsonParser.skipChildren(); // we do nothing with these because they're going to be put into json
            } else {
                try {
                    final String value = URLDecoder.decode(jsonParser.getValueAsString(), "UTF-8");
                    requestParams.put(field, value);
                } catch (NullPointerException e) {
                    throw e;
                }
            }
            token = jsonParser.nextToken();
        }
    } catch (final JSONException e) {
        throw new IOException("Unable to build a JSON object with the inputs provided", e);
    }
    try {
        Map<String, Object> eventParams = new HashMap<String, Object>();
        eventParams.put("event", requestParams.toString());
        calendarOperations.create(resource, author, eventParams, null,
                resource.getResourceResolver().adaptTo(Session.class));
    } catch (final OperationException e) {
        //probably caused by creating a folder that already exists. We ignore it, but still log the event.
        LOG.info("There was an operation exception while creating an event");
    }
}

From source file:com.cedarsoft.serialization.test.performance.XmlParserPerformance.java

private void benchParse(@Nonnull JsonFactory factory, @Nonnull String contentSample)
        throws XMLStreamException, IOException {
    for (int i = 0; i < BIG; i++) {
        JsonParser parser = factory.createParser(new StringReader(contentSample));

        assertEquals(JsonToken.START_OBJECT, parser.nextToken());

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("dependent", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_FALSE, parser.nextToken());
        boolean dependent = parser.getBooleanValue();
        assertFalse(dependent);// w  ww  .  j a va 2 s  .com

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("id", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
        String id = parser.getText();
        assertEquals("Canon Raw", id);

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("extension", parser.getCurrentName());
        assertEquals(JsonToken.START_OBJECT, parser.nextToken());

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("isDefault", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_TRUE, parser.nextToken());
        boolean isDefault = parser.getBooleanValue();
        assertTrue(isDefault);

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("delimiter", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
        String delimiter = parser.getText();
        assertEquals(".", delimiter);

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("extension", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
        String extension = parser.getText();
        assertEquals("cr2", extension);

        assertEquals(JsonToken.END_OBJECT, parser.nextToken());
        assertEquals(JsonToken.END_OBJECT, parser.nextToken());
        assertNull(parser.nextToken());

        parser.close();

        FileType type = new FileType(id, new Extension(delimiter, extension, isDefault), dependent);
        assertNotNull(type);
    }
}

From source file:com.cedarsoft.serialization.test.performance.XmlParserPerformance.java

private void benchParse(@Nonnull JsonFactory factory, @Nonnull byte[] contentSample)
        throws XMLStreamException, IOException {
    for (int i = 0; i < BIG; i++) {
        JsonParser parser = factory.createParser(contentSample);

        assertEquals(JsonToken.START_OBJECT, parser.nextToken());

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("id", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
        String id = parser.getText();
        assertEquals("Canon Raw", id);

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("dependent", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_FALSE, parser.nextToken());
        boolean dependent = parser.getBooleanValue();
        assertFalse(dependent);/*ww w. jav  a  2 s .c om*/

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("extension", parser.getCurrentName());
        assertEquals(JsonToken.START_OBJECT, parser.nextToken());

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("extension", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
        String extension = parser.getText();
        assertEquals("cr2", extension);

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("default", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_TRUE, parser.nextToken());
        boolean isDefault = parser.getBooleanValue();
        assertTrue(isDefault);

        assertEquals(JsonToken.FIELD_NAME, parser.nextToken());
        assertEquals("delimiter", parser.getCurrentName());
        assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
        String delimiter = parser.getText();
        assertEquals(".", delimiter);

        assertEquals(JsonToken.END_OBJECT, parser.nextToken());
        assertEquals(JsonToken.END_OBJECT, parser.nextToken());
        assertNull(parser.nextToken());

        parser.close();

        FileType type = new FileType(id, new Extension(delimiter, extension, isDefault), dependent);
        assertNotNull(type);
    }
}

From source file:com.adobe.communities.ugc.migration.importer.UGCImportHelper.java

protected static void importTranslation(final JsonParser jsonParser, final Resource post) throws IOException {
    JsonToken token = jsonParser.getCurrentToken();
    final Map<String, Object> properties = new HashMap<String, Object>();
    if (token != JsonToken.START_OBJECT) {
        throw new IOException("expected a start object token, got " + token.asString());
    }//from w w  w .  j a  v a  2 s .co  m
    properties.put("jcr:primaryType", "social:asiResource");
    Resource translationFolder = null;
    token = jsonParser.nextToken();
    while (token == JsonToken.FIELD_NAME) {
        token = jsonParser.nextToken(); //advance to the field value
        if (jsonParser.getCurrentName().equals((ContentTypeDefinitions.LABEL_TRANSLATIONS))) {
            if (null == translationFolder) {
                // begin by creating the translation folder resource
                translationFolder = post.getResourceResolver().create(post, "translation", properties);
            }
            //now check to see if any translations exist
            if (token == JsonToken.START_OBJECT) {
                token = jsonParser.nextToken();
                if (token == JsonToken.FIELD_NAME) {
                    while (token == JsonToken.FIELD_NAME) { // each new field represents another translation
                        final Map<String, Object> translationProperties = new HashMap<String, Object>();
                        translationProperties.put("jcr:primaryType", "social:asiResource");
                        String languageLabel = jsonParser.getCurrentName();
                        token = jsonParser.nextToken();
                        if (token != JsonToken.START_OBJECT) {
                            throw new IOException("expected a start object token for translation item, got "
                                    + token.asString());
                        }
                        token = jsonParser.nextToken();
                        while (token != JsonToken.END_OBJECT) {
                            jsonParser.nextToken(); //get next field value
                            if (jsonParser.getCurrentName()
                                    .equals(ContentTypeDefinitions.LABEL_TIMESTAMP_FIELDS)) {
                                jsonParser.nextToken(); // advance to first field name
                                while (!jsonParser.getCurrentToken().equals(JsonToken.END_ARRAY)) {
                                    final String timestampLabel = jsonParser.getValueAsString();
                                    if (translationProperties.containsKey(timestampLabel)) {
                                        final Calendar calendar = new GregorianCalendar();
                                        calendar.setTimeInMillis(Long
                                                .parseLong((String) translationProperties.get(timestampLabel)));
                                        translationProperties.put(timestampLabel, calendar.getTime());
                                    }
                                    jsonParser.nextToken();
                                }
                            } else if (jsonParser.getCurrentName()
                                    .equals(ContentTypeDefinitions.LABEL_SUBNODES)) {
                                jsonParser.skipChildren();
                            } else {
                                translationProperties.put(jsonParser.getCurrentName(),
                                        URLDecoder.decode(jsonParser.getValueAsString(), "UTF-8"));
                            }
                            token = jsonParser.nextToken(); //get next field label
                        }
                        // add the language-specific translation under the translation folder resource
                        Resource translation = post.getResourceResolver().create(post.getChild("translation"),
                                languageLabel, translationProperties);
                        if (null == translation) {
                            throw new IOException("translation not actually imported");
                        }
                    }
                    jsonParser.nextToken(); //skip END_OBJECT token for translation
                } else if (token == JsonToken.END_OBJECT) {
                    // no actual translation to import, so we're done here
                    jsonParser.nextToken();
                }
            } else {
                throw new IOException(
                        "expected translations to be contained in an object, saw instead: " + token.asString());
            }
        } else if (jsonParser.getCurrentName().equals("mtlanguage")
                || jsonParser.getCurrentName().equals("jcr:createdBy")) {
            properties.put(jsonParser.getCurrentName(), jsonParser.getValueAsString());
        } else if (jsonParser.getCurrentName().equals("jcr:created")) {
            final Calendar calendar = new GregorianCalendar();
            calendar.setTimeInMillis(jsonParser.getLongValue());
            properties.put("jcr:created", calendar.getTime());
        }
        token = jsonParser.nextToken();
    }
    if (null == translationFolder && properties.containsKey("mtlanguage")) {
        // it's possible that no translations existed, so we need to make sure the translation resource (which
        // includes the original post's detected language) is created anyway
        post.getResourceResolver().create(post, "translation", properties);
    }
}

From source file:com.zenesis.qx.remote.RequestHandler.java

/**
 * Reads the current token value, with special consideration for enums
 * @param jp/* w w w .j a  v  a  2s .c o m*/
 * @param clazz
 * @return
 * @throws IOException
 */
private Object readSimpleValue(JsonParser jp, Class clazz) throws IOException {
    if (jp.getCurrentToken() == JsonToken.VALUE_NULL)
        return null;

    Object obj = null;
    if (Enum.class.isAssignableFrom(clazz)) {
        if (jp.getCurrentToken() == JsonToken.FIELD_NAME)
            obj = jp.getCurrentName();
        else
            obj = jp.readValueAs(Object.class);
        if (obj != null) {
            String str = Helpers.camelCaseToEnum(obj.toString());
            obj = Enum.valueOf(clazz, str);
        }
    } else {
        if (jp.getCurrentToken() == JsonToken.FIELD_NAME)
            obj = jp.getCurrentName();
        else
            obj = jp.readValueAs(clazz);
    }
    return obj;
}

From source file:com.zenesis.qx.remote.RequestHandler.java

/**
 * Reads the next token and ensures that it is a field name called <code>fieldName</code>; leaves the current
 * token on the start of the field value
 * @param jp/*from  w  w  w.j a  v a  2  s  . c  o m*/
 * @param fieldName
 * @throws ServletException
 * @throws IOException
 */
private void skipFieldName(JsonParser jp, String fieldName) throws ServletException, IOException {
    if (jp.nextToken() != JsonToken.FIELD_NAME)
        throw new ServletException("Cannot find field name - looking for " + fieldName + " found "
                + jp.getCurrentToken() + ":" + jp.getText());
    String str = jp.getText();
    if (!fieldName.equals(str))
        throw new ServletException("Cannot find field called " + fieldName + " found " + str);
    jp.nextToken();
}

From source file:org.apache.olingo.client.core.edm.xml.ActionDeserializer.java

@Override
protected ActionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final ActionImpl action = new ActionImpl();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Name".equals(jp.getCurrentName())) {
                action.setName(jp.nextTextValue());
            } else if ("IsBound".equals(jp.getCurrentName())) {
                action.setBound(BooleanUtils.toBoolean(jp.nextTextValue()));
            } else if ("EntitySetPath".equals(jp.getCurrentName())) {
                action.setEntitySetPath(jp.nextTextValue());
            } else if ("Parameter".equals(jp.getCurrentName())) {
                jp.nextToken();/*w  w w. j  a  v  a 2 s  .  c  om*/
                action.getParameters().add(jp.readValueAs(ParameterImpl.class));
            } else if ("ReturnType".equals(jp.getCurrentName())) {
                action.setReturnType(parseReturnType(jp, "Action"));
            } else if ("Annotation".equals(jp.getCurrentName())) {
                jp.nextToken();
                action.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
            }
        }
    }

    return action;
}

From source file:org.apache.olingo.client.core.edm.xml.annotation.DynamicAnnotationExpressionDeserializer.java

@Override
protected AbstractDynamicAnnotationExpression doDeserialize(final JsonParser jp,
        final DeserializationContext ctxt) throws IOException, JsonProcessingException {

    AbstractDynamicAnnotationExpression expression = null;

    if ("Not".equals(jp.getCurrentName())) {
        final NotImpl not = new NotImpl();

        jp.nextToken();/*  w  w  w  .  j  a  v a  2  s  .com*/
        for (; jp.getCurrentToken() != JsonToken.FIELD_NAME; jp.nextToken()) {
        }
        not.setExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
        for (; jp.getCurrentToken() != JsonToken.END_OBJECT || !jp.getCurrentName().equals("Not"); jp
                .nextToken()) {
        }

        expression = not;
    } else if (TwoParamsOpDynamicAnnotationExpression.Type.fromString(jp.getCurrentName()) != null) {
        final TwoParamsOpDynamicAnnotationExpressionImpl dynExprDoubleParamOp = new TwoParamsOpDynamicAnnotationExpressionImpl();
        dynExprDoubleParamOp
                .setType(TwoParamsOpDynamicAnnotationExpression.Type.fromString(jp.getCurrentName()));

        jp.nextToken();
        for (; jp.getCurrentToken() != JsonToken.FIELD_NAME; jp.nextToken()) {
        }
        dynExprDoubleParamOp.setLeftExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
        dynExprDoubleParamOp.setRightExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
        for (; jp.getCurrentToken() != JsonToken.END_OBJECT
                || !jp.getCurrentName().equals(dynExprDoubleParamOp.getType().name()); jp.nextToken()) {
        }

        expression = dynExprDoubleParamOp;
    } else if (ArrayUtils.contains(EL_OR_ATTR, jp.getCurrentName())) {
        final AbstractElementOrAttributeExpression elOrAttr = getElementOrAttributeExpressio(
                jp.getCurrentName());
        elOrAttr.setValue(jp.nextTextValue());

        expression = elOrAttr;
    } else if (APPLY.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(ApplyImpl.class);
    } else if (CAST.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(CastImpl.class);
    } else if (COLLECTION.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(CollectionImpl.class);
    } else if (IF.equals(jp.getCurrentName())) {
        jp.nextToken();
        jp.nextToken();

        final IfImpl _if = new IfImpl();
        _if.setGuard(parseConstOrEnumExpression(jp));
        _if.setThen(parseConstOrEnumExpression(jp));
        _if.setElse(parseConstOrEnumExpression(jp));

        expression = _if;
    } else if (IS_OF.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(IsOfImpl.class);
    } else if (LABELED_ELEMENT.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(LabeledElementImpl.class);
    } else if (NULL.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(NullImpl.class);
    } else if (RECORD.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(RecordImpl.class);
    } else if (URL_REF.equals(jp.getCurrentName())) {
        jp.nextToken();
        expression = jp.readValueAs(UrlRefImpl.class);
    }

    return expression;
}