
wee0.net.HttpMediaType Maven / Gradle / Ivy
The newest version!
/**
* Copyright (c) 2016-2022, wee0.com.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package wee0.net;
/**
* An RFC 2045 Media Type, appropriate to describe
* the content type of an HTTP request or response body.
*
* @author baihw
* @date 2018年7月6日
**/
/**
*
* examples:
*
**/
public enum HttpMediaType{
/**
* JSON类型
*/
JSON( "application/json;charset=UTF-8" ),
/**
* XML类型
*/
XML( "text/xml;charset=UTF-8" );
/**
* 当前类型对应的值。
*/
private final String _VAL;
/**
* 设置当前类型对应的值。
*
* @param val 当前类型对应的值。
*/
HttpMediaType( String val ){
this._VAL = val;
}
/**
* @return 当前类型对应的值。
*/
public String value(){
return this._VAL;
}
/**
* 修改值中的charset指定。
*
* @param charset 要修改的字符集。
* @return 修改后的值
*/
public String valueCharset( String charset ){
if( null != charset && 5 < ( charset = charset.trim() ).length() ){
//
return this._VAL.substring( 0, this._VAL.length() - 5 ).concat( charset );
}
return this._VAL;
}
} // end class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy