View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2015 VoyagerSearch
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Apache License, Version 2.0 which
5    * accompanies this distribution and is available at
6    *    http://www.apache.org/licenses/LICENSE-2.0.txt
7    ******************************************************************************/
8   
9   package org.locationtech.spatial4j.io;
10  
11  import java.io.IOException;
12  import java.io.Reader;
13  import java.text.ParseException;
14  
15  import org.locationtech.spatial4j.exception.InvalidShapeException;
16  import org.locationtech.spatial4j.shape.Shape;
17  
18  /**
19   * Implementations are expected to be thread safe
20   */
21  public interface ShapeReader extends ShapeIO {
22  
23    /**
24     * @param value -- the input value, could be a String or other object
25     * @return a shape valid shape (not null)
26     */
27    public Shape read(Object value) throws IOException, ParseException, InvalidShapeException;
28  
29    /**
30     * @param value -- the input value, could be a String or other object
31     * @return a shape or null, if the input was un readable.
32     * 
33     *         This will throw {@link InvalidShapeException} when we could read a shape, but it was
34     *         invalid
35     */
36    public Shape readIfSupported(Object value) throws InvalidShapeException;
37  
38    /**
39     * Read a {@link Shape} from the reader.
40     * 
41     * @param reader -- the input. Note, it will not be closed by this function
42     * @return a valid Shape (never null)
43     */
44    public Shape read(Reader reader) throws IOException, ParseException, InvalidShapeException;
45  }