001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.httppart;
014
015import org.apache.juneau.*;
016import org.apache.juneau.parser.*;
017
018/**
019 * Interface used to convert HTTP headers, query parameters, form-data parameters, and URI path variables to POJOs
020 * 
021 * <p>
022 * The following default implementations are provided:
023 * <ul class='doctree'>
024 *    <li class='jc'>{@link org.apache.juneau.httppart.UonPartParser} - Parts encoded in UON notation.
025 *    <li class='jc'>{@link org.apache.juneau.httppart.SimplePartParser} - Parts encoded in plain text.
026 * </ul>
027 * 
028 * <p>
029 * Implementations must include either a public no-args constructor or a public constructor that takes in a single
030 * {@link PropertyStore} object.
031 */
032public interface HttpPartParser {
033
034   /**
035    * Represent "no" part parser.
036    * 
037    * <p>
038    * Used to represent the absence of a part parser in annotations.
039    */
040   public static interface Null extends HttpPartParser {}
041   
042   /**
043    * Converts the specified input to the specified class type.
044    * 
045    * @param partType The part type being parsed.
046    * @param in The input being parsed.
047    * @param type The category of value being parsed.
048    * @return The parsed value.
049    * @throws ParseException
050    */
051   public <T> T parse(HttpPartType partType, String in, ClassMeta<T> type) throws ParseException;
052}