View Javadoc
1   package org.apache.fulcrum.json.jackson.jsonpath;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.EnumSet;
23  import java.util.Set;
24  
25  import org.apache.fulcrum.json.jackson.Jackson2MapperService;
26  
27  import com.fasterxml.jackson.databind.ObjectMapper;
28  import com.jayway.jsonpath.Configuration.Defaults;
29  import com.jayway.jsonpath.Option;
30  import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
31  import com.jayway.jsonpath.spi.json.JsonProvider;
32  import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
33  import com.jayway.jsonpath.spi.mapper.MappingProvider;
34  
35  /**
36   * Intermediary class implementing {@link Defaults} by glueing {@link Jackson2MapperService#getMapper()} with internal 
37   * objects {@link JacksonJsonProvider} and {@link JacksonMappingProvider}.
38   * 
39   * @author gkallidis
40   *
41   */
42  public class JsonPathDefault implements
43          Defaults {
44  
45      private final JsonProvider jsonProvider;
46      private final MappingProvider mappingProvider;
47  
48      // Jackson2MapperService.this.mapper
49      public JsonPathDefault(ObjectMapper mapper) {
50          jsonProvider = new JacksonJsonProvider(mapper);
51          mappingProvider = new JacksonMappingProvider(  mapper);
52      }
53  
54  
55      @Override
56      public JsonProvider jsonProvider() {
57          return jsonProvider;
58      }
59  
60      @Override
61      public MappingProvider mappingProvider() {
62          return mappingProvider;
63      }
64  
65      @Override
66      public Set<Option> options() {
67          return EnumSet.noneOf(Option.class);
68      }
69  }