001/*
002 * Copyright 2013 Box, Inc. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.nuxeo.box.api.marshalling.interfaces;
017
018import org.nuxeo.box.api.marshalling.exceptions.BoxJSONException;
019
020import java.io.InputStream;
021
022public interface IBoxJSONParser {
023
024    /**
025     * Convert the object into String. No exception will be thrown, in case of failure, null is returned.
026     *
027     * @param object
028     * @return
029     */
030    String convertBoxObjectToJSONStringQuietly(final Object object);
031
032    /**
033     * Convert InputStream to object.No exception will be thrown, in case of failure, null is returned.
034     *
035     * @param inputStream
036     * @param theClass
037     * @return
038     */
039    <T> T parseIntoBoxObjectQuietly(final InputStream inputStream, final Class<T> theClass);
040
041    /**
042     * Convert the json string into object.No exception will be thrown, in case of failure, null is returned.
043     *
044     * @param jsonString
045     * @param theClass
046     * @return
047     */
048    <T> T parseIntoBoxObjectQuietly(final String jsonString, final Class<T> theClass);
049
050    /**
051     * Convert the object into String.
052     *
053     * @param object
054     * @return
055     * @throws BoxJSONException
056     */
057    String convertBoxObjectToJSONString(final Object object) throws BoxJSONException;
058
059    /**
060     * Convert InputStream to object.
061     *
062     * @param inputStream
063     * @param theClass
064     * @return
065     * @throws BoxJSONException
066     */
067    <T> T parseIntoBoxObject(final InputStream inputStream, final Class<T> theClass) throws BoxJSONException;
068
069    /**
070     * Convert the json string into object.
071     *
072     * @param jsonString
073     * @param theClass
074     * @return
075     * @throws BoxJSONException
076     */
077    <T> T parseIntoBoxObject(final String jsonString, final Class<T> theClass) throws BoxJSONException;
078}